akhauriyash/Code-Regression huggingface dataset:
//18
#include<iostream>
#include<algorithm>
#include<utility>
#include<queue>

using namespace std;

int w,h;
char g[61][10];
bool f;

typedef pair<int,int> pii;
typedef pair<double,int> pdi;

struct xyd{
  int x,y,d;
};

pdi cc(pdi a,pdi b){
  return make_pair((b.first*b.second+a.first*a.second)/(a.second+b.second),a.second+b.second);
}

bool p[61][10];

pdi dfs(int sy,int sx,bool fs){
  int l=sx,r=sx;
  xyd is={sx,sy,0};
  queue<xyd> que;
  que.push(is);
  pdi cp;
  int cb=0;
  while(!que.empty()){
    int y=que.front().y;
    int x=que.front().x;
    int cd=que.front().d;
    que.pop();
    if(x<0||w<=x||y<0||h<=y||g[y][x]=='.')continue;
    if(g[y][x]==g[sy][sx]){
      if(p[y][x]++)continue;
      if(g[y][x]!=g[y+1][x]&&g[y+1][x]!='.'){
	l=min(l,x);
	r=max(r,x);
      }
      cp=cc(cp,make_pair(x+.5,1));
      for(int i=0;i<4;i++){
	int d[]={0,1,0,-1,0};
	int ny=y+d[i];
	int nx=x+d[i+1];
	xyd n={nx,ny,d[i]};
	que.push(n);
      }
    }else if(cd==-1&&!p[y][x]){
      cb|=1<<(g[y][x]-'0');
      cp=cc(cp,dfs(y,x,false));
    }
  }
  f&=(l+1e-9<cp.first&&cp.first<r+1-1e-9);
  return cp;
}

int main(){
  while(cin>>w>>h,w|h){
    int sx,sy;
    for(int y=0;y<h;y++){
      for(int x=0;x<w;x++){
	cin>>g[y][x];
	if(g[y][x]!='.'){
	  sy=y;
	  sx=x;
	}
      }
    }
    fill(g[sy+1],g[sy+2],'*');
    f=true;
    fill(p[0],p[61],false);
    dfs(sy,sx,true);
    cout<<(f?"STABLE":"UNSTABLE")<<endl;
  }
  return 0;
}

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

using namespace std;

int main(){
    int n;
    int q;
    string s;
    cin >> n >> q;
    cin >> s;
    int t[n-1];
    for(int i = 0; i < n - 1; i++){
        if(i == 0){
            if (s.substr(i, 2) == "AC"){
                t[0] = 1;
            }else{
                t[0] = 0;
            }
        }
        else if(s.substr(i, 2) == "AC"){
            t[i] = t[i - 1] + 1;
        }else{
            t[i] = t[i - 1];
        }
    }
    int ans[q];
    for(int i = 0; i < q; i++){
        int a, b;
        cin >> a >> b;
        if(a - 2 < 0){
            ans[i] = t[b - 2];
        }else{
            ans[i] =t[b - 2] - t[a - 2];
        }
    }
    for(int i = 0; i < q; i++){
        cout << ans[i] << "\n";
    }
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;

#define int long long int
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define dbg(x) { cerr<<"> "<<#x<<": "<<x<< endl; }
#define dbg2(x,y) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<endl; }
#define dbg3(x,y,z) { cerr<<"> "<<#x<<": "<<x<<" , "<<#y<<": "<<y<<" , "<<#z<<": "<<z<<endl; }
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
const int inf = INT_MAX;
const double eps = 0.0000001;
const double PI = acos(-1.0);
const int MOD = 1e9+7;
const int N  = 1e5+5;

int a[N], dp[N], n, k;

int solve (int i) {
	if (i > n) return inf;
	if (i == n) return 0;
	if (i == n-1) return abs (a[n] - a[n-1]);
	if (dp[i] >= 0) return dp[i];
	int ans = inf;
	for (int j = i+1; j <= i+k; j++) {
		ans = min(ans, solve(j)+abs(a[j]-a[i]));
	}
	dp[i] = ans;
	return ans;
}

signed main(){
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        //freopen("output.txt", "w", stdout);
    #endif  
    IOS;

    cin >> n >> k;
   	memset(dp, -1, sizeof (dp));
    for (int i = 1; i <= n; i++)
    	cin >> a[i];
    cout << solve(1);
    return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>

int masu[14][14]={0};

void function(int i,int j,int count){
	masu[i][j]=count;
	//printf("%d\n",count);
	if(masu[i+1][j]==1){
		function(i+1,j,count);
	}
	if(masu[i-1][j]==1){
		function(i-1,j,count);
	}
	if(masu[i][j+1]==1){
		function(i,j+1,count);
	}
	if(masu[i][j-1]==1){
		function(i,j-1,count);
	}
}

int main(){
	int i,j;
	
	char masu1[12]={0};
	int count=2;
	while(1){
		for(i=0;i<12;i++){
			if(scanf("%s",masu1)==EOF){
				return 0;
			}
			for(j=0;j<12;j++){
				masu[i+1][j+1]=(int)masu1[j]-'0';
			}
		}
		for(i=1;i<=12;i++){
			for(j=1;j<=12;j++){
				if(masu[i][j]==1){
					function(i,j,count);
					count++;
				}
			}
		}
		printf("%d\n",count-2);
		count=2;
	}
	
	return 0;
}

Measured memory_bytes: 548
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <istream>
#include <map>
#include <set>
#include <queue>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define REP(a,b) for (int ii = a; ii <= (b); ++ii) 
#define mREP(a,b) for (int i = a; i == (b); --i)
#define mod 1e9 + 7
typedef long long ll;
using namespace std;
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	/*
	　　　　　 　 _... ..._
	　　　　　 , ´⌒ ⌒ヽ
	　　　 　 ﾉｨ（ノﾉ）ﾉ）ﾉ）
	　　　 　 （（q|.ﾟ ヮﾟﾉ|ﾊ
	　　　　　　△ﾑ,8ﾑﾌつ
	　　　　　/(ﾝ_/＿ヽ＼
	　　　　 ～～i_ﾌ_ﾌ～´
	*/
	int a, b;
	cin >> a >> b;
	cout << (a + b) % 24 << endl;
	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
	int mat[3][3];
    int marking[3][3];
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        cin>>mat[i][j];
      }
    }
   int res_flag=false;
   int t;
   cin>>t;
  while(t--){
  	int k;
    cin>>k;
    for(int i=0;i<3;i++){
    	for(int j=0;j<3;j++){
          if(mat[i][j] == k) marking[i][j] = 1;
        }
    }
  }
    for(int i=0;i<3;i++){
    	if(marking[i][0]==1 && marking[i][1] == 1 && marking[i][2] == 1) res_flag = true;
    	if(marking[0][i]==1 && marking[1][i] == 1 && marking[2][i] == 1) res_flag = true;
    }
    
    if(marking[0][0] == 1 && marking[1][1] == 1 && marking[2][2] == 1) res_flag=true;
    if(marking[0][2] == 1 && marking[1][1] == 1 && marking[2][0] == 1) res_flag=true;

      if(res_flag == true) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
}

Measured memory_bytes: 256
// Aizu Vol0 0032: Plastic Board
// 2017.7.29

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

int main()
{
	int a, b, c;
	int rec, loz;

	rec = loz = 0;
	while (scanf("%d,%d,%d", &a, &b, &c) == 3) {
		if (a*a + b*b == c*c) rec++;
		else {
			if (a == b && a + b > c && b + c > a && c + a > b) loz++;
		}
	}
	printf("%d\n%d\n", rec, loz);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
const int N = 2e5 + 5, INF = 0x3f3f3f3f;
inline int read() {
    int x = 0, f = 0; char ch = 0;
    while (!isdigit(ch)) f |= ch == '-', ch = getchar();
    while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
    return f ? -x : x;
}
int ans[N];
vector <int> G[N], col[2], mod[3];
void dfs(int x, int c, int fa) {
    col[c].push_back(x);
    for (auto y : G[x]) if (y != fa) dfs(y, c ^ 1, x);
}
void sol(int i, int j) {
    while (!col[i].empty() && !mod[j].empty()) {
        ans[col[i].back()] = mod[j].back();
        col[i].pop_back(), mod[j].pop_back();
    }
}
int main() {
    int n = read();
    for (int i = 1; i < n; i++) {
        int x = read(), y = read();
        G[x].pb(y), G[y].pb(x);
    }
    for (int i = 1; i <= n; i++) mod[i % 3].pb(i);
    dfs(1, 0, 0);
    sol(col[0].size() < col[1].size(), 1), sol(col[0].size() < col[1].size(), 2);
    sol(0, 0), sol(1, 0);
    for (int i = 1; i <= n; i++) printf("%d ", ans[i]);
    return 0;
}     

Measured memory_bytes: 22296
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;


void solve()
{
	int a;
	cin>>a;
	cout<<a+a*a+a*a*a;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
void main(){
   char n[3];
   int judg=0;
   scanf("%s",n);
   for(int i=0;i<3;i++){
      if(n[i]=='7'){
         judg++;
      }
   }
   if(judg==0){
      printf("No\n");
   }else{
      printf("Yes\n");
   }
}


Measured memory_bytes: 1624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<int> x,y{5,5,7};
    int t;
    for(int i=0;i!=3;++i){
        cin>>t;
        x.push_back(t);
    }
    sort(x.begin(),x.end());
    cout<<(x==y ? "YES":"NO")<<endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
K, A = [], []
for i in range(N):
    k, *a = list(map(int, input().split()))
    K.append(k)
    A.append(a)

like = [0]*M

for i in range(N):
    for j in range(K[i]):
        like[A[i][j]-1] += 1 

print(like.count(N))

Measured memory_bytes: 38256
#include <iostream>
using namespace std;
struct edge{ int u, v, l; }e[102];
int main(){
	int l;
	cin >> l;
	int m = 0;
	for (int i = 19, s = 1; i >= 2; -- i, s <<= 1){//20是0位 2^0-1 19是1位 2^1-1
		e[++ m] = {i, i + 1, s};
		e[++ m] = {i, i + 1, 0};
	}
	bool have = false;
	for (int i = 0; i <= 18; ++ i)
		if (l & (1 << i)){//1000 0111
			e[++ m] = {1, 20 - i, (l >> i + 1) << i + 1};//去掉s的后i位
		}
	if (l & (1 << 19)){
		e[++ m] = {1, 2, 0};
		e[++ m] = {1, 2, 1 << 18};
	}
	cout << 20 << " " << m << endl;
	for (int i = 1; i <= m; ++ i)
		cout << e[i].u << " " << e[i].v << " " << e[i].l << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
ps = []
MOD = 998244353
s = set()
for _ in range(k):
    l,r = map(int, input().split())
    ps.append([l,r])

dp = [0] * (n+1)
dp[0] = 1
acc = [0,1]

for i in range(1,n):
    for l, r in ps:
        dp[i] += acc[max(0,i-l+1)] - acc[max(0,i-r)]
    acc.append((acc[i] + dp[i])%MOD)
print(dp[n-1]%MOD)


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

#define rep(i, n)  for (int i = 0; i < (n) ; ++i)
#define mod 1000000007

using namespace std;
using ll=long long;

const int INF = 100000000;

int main() {
    ll x;
    cin >> x;
    ll res = 0;
    ll a = 100;
    while (true) {
        a = a * 1.01;
        res++;
        if (a >= x) {
            break;
        }
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 3640
using System;
using System.Linq;
using System.Collections.Generic;

namespace ABC
{
    class ProgramB
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).ToList();
            var k = long.Parse(Console.ReadLine());
            var max = list.Max();
            var index = list.IndexOf(max);

            list[index] *= (long)Math.Pow(2, k);

            Console.WriteLine(list.Sum());
        }
    }
}


Measured memory_bytes: 28612
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  var line, buffer []byte
  var isPrefix bool = true
  var err error
  for isPrefix {
    line, isPrefix, err = reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
  }
  return string(buffer)
}
func NextInt() int {
  var n int
  n, _ = strconv.Atoi(NextLine())
  return n
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func Bipartite(S *[]string) bool {
  N := len((*S))
  D := make([]int, N)
  D[0] = 1
  Q := make([]int, N)
  ret := true
  pos := 1
  for i := 0; i < N; i++ {
    if !ret { break }
    q := Q[i]
    for j, s := range (*S)[q] {
      if s == '0' {
        continue
      }
      if D[j] == 0 {
        D[j] = D[q] + 1
        Q[pos] = j
        pos++
        continue
      }
      if D[j] % 2 == D[q] % 2 {
        ret = false
        break
      }
    }
  }
  return ret
}

func WarshallFloyd(S *[]string) int {
  N := len(*(S))
  G := make([][]int, N)
  for i := range G {
    G[i] = make([]int, N)
    for j := range G[i] {
      if i == j { continue }
      if (*S)[i][j] == '0' {
        G[i][j] = N
      } else {
        G[i][j] = 1
      }
    }
  }
  for k := 0; k < N; k++ {
    for i := 0; i < N; i++ {
      for j := 0; j < N; j++ {
        if G[i][k] + G[k][j] < G[i][j] {
          G[i][j] = G[i][k] + G[k][j]
        }
      }
    }
  }
  ans := 0
  for i := 0; i < N; i++ {
    for j := 0; j < N; j++ {
      if ans < G[i][j] { ans = G[i][j] }
    }
  }
  return ans + 1
}

func main() {
  N := NextInt()
  S := make([]string, N)
  for i := range S {
    S[i] = NextLine()
  }
  if !Bipartite(&S) {
    Write(-1)
  } else {
    Write(WarshallFloyd(&S))
  }
  Output()
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main(){
  int H,W;
  cin>>H>>W;
  string S[H];
  rep(i,H) cin>>S[i];
  VVI X(H,VI(W));
  int ans=0;
  rep(i,H) rep(j,W){
    rep(i1,H) rep(j1,W) X[i1][j1]=-1;
    VVI Y(401,VI(0));
    if(S[i][j]=='.'){
      Y[0].push_back(i*20+j);
      X[i][j]=0;
      rep(i2,401){
        rep(k,Y[i2].size()){
          int A=Y[i2][k]/20;
          int B=Y[i2][k]%20;
          if(A>0){
            if(S[A-1][B]=='.'&&X[A-1][B]==-1){
              X[A-1][B]=i2+1;
              Y[i2+1].push_back((A-1)*20+B);
            }
          }
          if(B>0){
            if(S[A][B-1]=='.'&&X[A][B-1]==-1){
              X[A][B-1]=i2+1;
              Y[i2+1].push_back(A*20+B-1);
            }
          }
          if(A<H-1){
            if(S[A+1][B]=='.'&&X[A+1][B]==-1){
              X[A+1][B]=i2+1;
              Y[i2+1].push_back((A+1)*20+B);
            }
          }
          if(B<W-1){
            if(S[A][B+1]=='.'&&X[A][B+1]==-1){
              X[A][B+1]=i2+1;
              Y[i2+1].push_back(A*20+B+1);
            }
          }
        }
      }
    }
    int M=-1;
    rep(i,H) rep(j,W) M=max(M,X[i][j]);
    ans=max(ans,M);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  vll a(5);
  rep(i, 5){
    cin >> a[i];
    if(a[i] == 0){
      print(i+1);
      return 0;
    }
  }
  
}


Measured memory_bytes: 3608
H, W, K = map(int, input().split())
C = [0] * H
for h in range(H):
    C[h] = input()

ans = 0
for tate in range(2 ** H):
    for yoko in range(2 ** W):
        tate_ = tate
        T = []
        for _ in range(H):
            T.append(tate_ % 2 == 0)
            tate_ //= 2
        Y = []
        yoko_ = yoko
        for _ in range(W):
            Y.append(yoko_ % 2 == 0)
            yoko_ //= 2
#         print(tate, T, yoko, Y)
        count = 0
        for h in range(H):
            if T[h]: continue
            for w in range(W):
                if Y[w]: continue
                if C[h][w] == '#':
                    count += 1
        if count == K:
            ans += 1
print(ans)

Measured memory_bytes: 9236
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W>>H>>x>>y>>r;
    if (x+r<=W&&y+r<=H&&x-r>=0&&y-r>=0) {
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }


}


Measured memory_bytes: 3100
num = int(input())
lists = list(map(int, input().split()))

sum_left = 0
sum_right = 0
result = 10000
for i in range (num):
    sum_left = sum(lists[:i])
    sum_right = sum(lists[i:])

    if result > abs(sum_right - sum_left):
        result = abs(sum_right - sum_left)
        
        
print(result)

Measured memory_bytes: 3064
import collections
N = int(input())
S = []
answer = []
for _ in range(N):
    S.append(input())

S_dict = collections.Counter(S)
# print(S_dict.most_common())
max_num = S_dict.most_common()[0][1]
# i = 0
# while True:
#     if max_num != S_dict.most_common()[i][1]:
#         break
#     else:
#         answer.append(S_dict.most_common()[i][0])
#     i += 1
for i in S_dict.most_common():
    # print(i[1])
    if i[1] == max_num:
        answer.append(i[0])

answer.sort()
for v in answer:
    print(v)
# print(answer)

Measured memory_bytes: 45040
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
 
stringstream input;
 
struct complex{
    bool ov;
    int re, im;
 
    complex( int re_, int im_, bool ov_ = false ):
        re(re_), im(im_), ov(ov_)
        {
            if( !ov ){
                ov = max( abs(re), abs(im) ) > 10000;
            }
        }
 
    complex operator -(){
        return complex( -re, -im, ov );
    }
    void operator +=( const complex &c ){
        *this = complex( re + c.re, im + c.im, ov | c.ov );
    }
    void operator -=( const complex &c ){
        *this = complex( re - c.re, im - c.im, ov | c.ov );
    }
    void operator *=( const complex &c ){
        *this = complex(
            re * c.re - im * c.im,
            re * c.im + im * c.re,
            ov | c.ov
        );
    }
};
const complex i( 0, 1 );
 
complex term();
complex factor();
complex expr();
 
complex expr(){
    complex c = term();
    char ch;
    for(;;){
        if( input.peek() == '+' ){
            input >> ch;
            c += term();
        }
        else if( input.peek() == '-' ){
            input >> ch;
            c -= term();
        }
        else break;
    }
    return c;
}
 
complex term(){
    complex c = factor();
    char ch;
    while( input.peek() == '*' ){
        input >> ch;
        c *= factor();
    }
    return c;
}
 
complex factor(){
    char ch;
    if( input.peek() ==  '(' ){
        input >> ch;
        complex c = expr();
        input >> ch;
        return c;
    }
    if( input.peek() == 'i' ){
        input >> ch;
        return i;
    }
    if( input.peek() == '+' ){
        input >> ch;
        return factor();
    }
    if( input.peek() == '-' ){
        input >> ch;
        return -factor();
    }
     
    int val;
    input >> val;
    return complex( val, 0, input.fail() );
}
 
int main(){
    for( string s; getline( cin, s ); ){
        input.clear();
        input.str(s);
        complex c = expr();
 
        if( c.ov ) cout << "overflow";
        else{
            if( c.re ){
                cout << c.re;
                if( c.im > 0 ) cout << '+';
            }
            else if( !c.im )
                cout << '0';
 
            if( c.im ){
                cout << c.im << 'i';
            }
        }
        cout << endl;
    }
}

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


int32_t main(){
    int n,r=0,g=0,b=0;
    string s;
    cin>>n;
    cin>>s;

    for(int i=0;i<n;i++){
        if(s[i]=='R')r++;
        else if(s[i]=='G')g++;
        else b++;
    }

    int ans=r*g*b;

    for(int i=0;i<n;i++){
        for(int j=1;j<n;j++){
            int l=i-j;
            int rr=i+j;

            if(l>=0  &&  rr<n && s[l]!=s[i] && s[i]!=s[rr] && s[rr]!=s[l])ans--;

        }
    }

    cout<<ans;
}

Measured memory_bytes: 3612
import java.util.Scanner;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;


public class Main{

	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		HashSet<String> dictionary = new HashSet<>();
		List<String> answer = new ArrayList<>();
		String str;
		
		// 命令の数を受け取る
		int num = scan.nextInt();
		
		// 命令を受け取る
		for(int i = 0; i < num; i++){
			str = scan.next();
			switch(str){
				case "insert":
					dictionary.add(scan.next());
					break;
				case "find":
					if(dictionary.contains(scan.next())){
						answer.add("yes");
					} else {
						answer.add("no");
					}
					break;
			}
		}
		
		answer.forEach(System.out::println);
		
	}
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define int long long
#define ALL(x) (x).begin(),(x).end()
typedef pair<int, int> pii;


const double EPS=1e-12;
string A[100];
bool vis[100][100];
int num[100][100];
int H,W;
int dx[4]={0,0,-1,1},dy[4]={1,-1,0,0};
set<int>G[1010];
double g_x[1010];
int L[1010],R[1010];
int m[1010];
void init(){
    REP(i,H){
        cin>>A[i];
    }
    REP(i,H)REP(j,W){
        vis[i][j]=false;
        num[i][j]=0;
    }
    REP(i,H*W+10){
        G[i].clear();
        g_x[i]=0;
        m[i]=0;
        L[i]=1000;
        R[i]=-1;
    }
}

void bfs(int x,int y,int id,char c){
    num[x][y]=id;
    vis[x][y]=true;
    queue<pii>que;
    que.push({x,y});
    while(!que.empty()){
        pii p =que.front();
        que.pop();
        REP(k,4){
            int nx=p.first+dx[k];
            int ny=p.second+dy[k];
            if(nx>=0&&nx<H&&ny>=0&&ny<W&&!vis[nx][ny]&&A[nx][ny]==c){
                vis[nx][ny]=true;
                num[nx][ny]=id;
                que.push({nx,ny});
            }
        }
    }
}

int calc_sum(int v){
    int res = m[v];
    for(auto nxt:G[v]){
        res+=calc_sum(nxt);
    }
    return res;
}
double calc_x(int v){
    double res = g_x[v]*m[v];
    for(auto nxt:G[v]){
        res+=calc_x(nxt);
    }
    return res;
}

bool check(int v){
    int sum=calc_sum(v);
    double sum_x=calc_x(v);
    double gx=sum_x/sum;
    // cout<<"id:"<<v<<endl;
    // cout<<"gx:"<<gx<<endl;
    // cout<<"l:"<<L[v]<<"r:"<<R[v]<<endl;
    if(L[v]+EPS<gx&&gx<R[v]-EPS)return true;
    else return false;
}
void solve() {
    cin>>W>>H;
    if(H==0)exit(0);
    init();
    int id = 1;
    REP(i,H){
        REP(j,W){
            if(A[i][j]=='.'||vis[i][j])continue;
            else{
                bfs(i,j,id,A[i][j]);
                id++;
            }
        }
    }
    // REP(i,H){
    //     REP(j,W){
    //         cout<<num[i][j]<<" ";
    //     }cout<<endl;
    // }
    for(int i=H-1;i>=1;i--){
        REP(j,W){
            if(num[i][j]>0&&num[i-1][j]>0&&num[i][j]!=num[i-1][j]){
                G[num[i][j]].insert(num[i-1][j]);
            }
        }
    }
    REP(i,H){
        REP(j,W){
            m[num[i][j]]++;
            double x=j+0.5;
            g_x[num[i][j]]+=x;
        }
    }
    for(int i=H-1;i>=0;i--){
        REP(j,W){
            if(i==H-1||(num[i+1][j]>0&&num[i+1][j]!=num[i][j]))L[num[i][j]]=min(L[num[i][j]],j);
        }
    }
    for(int i=H-1;i>=0;i--){
        REPR(j,W){
            if(i==H-1||(num[i+1][j]>0&&num[i+1][j]!=num[i][j]))R[num[i][j]]=max(R[num[i][j]],j+1);
        }
    }
    REP(i,id){
        if(m[i]){
            g_x[i]/=(double)m[i];
        }
    }
    bool ok = true;
    for(int v=1;v<id;v++){
        if(!check(v)){
            ok=false;
        }
    }
    if(ok)cout<<"STABLE"<<endl;
    else cout<<"UNSTABLE"<<endl;
}

signed main() {
	while(true)solve();
}



Measured memory_bytes: 3204
h, w = map(int, input().split())
s = ['.'*(w+2)] + ['.' + input() + '.' for i in range(h)] + ['.'*(w+2)]
d = [[1, 0], [0, 1], [-1, 0], [0, -1]]

ans = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '.':
            continue
        c = 0
        for k in range(4):
            if s[i+d[k][0]][j+d[k][1]] == "#":
                c += 1
        if c == 0:
            ans = -1

if ans == -1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
long a[300000];

int cmp(const void *a,const void *b){
	return *(long*)b-*(long*)a;
}

int main(int argc, char const *argv[]){
	long n,i;
	long long ans=0;
	scanf("%ld",&n);
	for(i=0;i<3*n;i++){
		scanf("%ld",&a[i]);
	}
	qsort(a,3*n,sizeof(long),cmp);
	for(i=0;i<n;i++){
		ans+=(long long)a[i*2+1];
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4860
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <assert.h>

using namespace std;
typedef long long ll;
typedef set<int>::iterator ssii;

#define Cmp(a, b) memcmp(a, b, sizeof(b))
#define Cpy(a, b) memcpy(a, b, sizeof(b))
#define Set(a, v) memset(a, v, sizeof(a))
#define debug(x) cout << #x << ": " << x << endl
#define _forS(i, l, r) for(set<int>::iterator i = (l); i != (r); i++)
#define _rep(i, l, r) for(int i = (l); i <= (r); i++)
#define _for(i, l, r) for(int i = (l); i < (r); i++)
#define _forDown(i, l, r) for(int i = (l); i >= r; i--)
#define debug_(ch, i) printf(#ch"[%d]: %d\n", i, ch[i])
#define debug_m(mp, p) printf(#mp"[%d]: %d\n", p->first, p->second)
#define debugS(str) cout << "dbg: " << str << endl;
#define debugArr(arr, x, y) _for(i, 0, x) { _for(j, 0, y) printf("%c", arr[i][j]); printf("\n"); }
#define _forPlus(i, l, d, r) for(int i = (l); i + d < (r); i++)
#define lowbit(i) (i & (-i))
#define MPR(a, b) make_pair(a, b)

pair<int, int> crack(int n) {
    int st = sqrt(n);
    int fac = n / st;
    while (n % st) {
        st += 1;
        fac = n / st;
    }

    return make_pair(st, fac);
}

inline ll qpow(ll a, int n) {
    ll ans = 1;
    for(; n; n >>= 1) {
        if(n & 1) ans *= 1ll * a;
        a *= a;
    }
    return ans;
}

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

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

// ============================================================== //

const int maxn = 3;
int a[maxn];
int K;
int d[10];

bool finished() {
    return a[0] < a[1] && a[1] < a[2];
}

bool dfs(int cnt, int a[]) {
    int& res = d[cnt];
    if(cnt == K) {
        if(finished()) res |= 1;
        return res;
    }

    if(finished()) {
        res |= 1;
        return res;
    }
    res = 0;
    for(int i = 0; i < maxn; i++) {
        a[i] <<= 1;
        res |= dfs(cnt+1, a);
        a[i] >>= 1;
    }
    return res;
}

void init() {
    //
    Set(d, 0);
}

int main() {
    //freopen("input.txt", "r", stdin);
    init();
    _for(i, 0, maxn) {
        int x;
        scanf("%d", &x);
        a[i] = x;
    }
    scanf("%d", &K);

    dfs(0, a);
    bool ans = 0;
    for(int i = 0; i <= K; i++) ans |= d[i];
    ans == 0 ? printf("No") : printf("Yes");
}



Measured memory_bytes: 3704
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0

for i in range(0, a+1):
    for j in range(0, b+1):
        for k in range(0, c+1):
            if (i)*500 + (j)*100 + (k)*50 == x:
                cnt += 1

print(cnt)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define REP(i, n) FOR(i, 0, n)
#define INF 999999999
typedef long long ll;
using namespace std;
int main() {
    int N;
    cin >> N;
    cout << N/3 << endl;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> t(n);
  vector<int> x(n);
  vector<int> y(n);
  for(int i=0;i<n;i++){
  	cin >> t[i] >> x[i] >> y[i];
  }
  bool flg=true;
  if(x[0]+y[0]>t[0]){flg=false;}
  if(x[0]+y[0]<=t[0]){
  	if((x[0]+y[0]-t[0])%2==1){flg=false;}
  }
  for(int i=1;i<n;i++){
  	int a=abs(x[i]-x[i-1]);
    int b=abs(y[i]-y[i-1]);
    int c=abs(t[i]-t[i-1]);
    if(a+b>c){
    	flg=false;
      break;
    }
    if(a+b<c){
    	if((c-a-b)%2==1){
        	flg=false;
          break;
        }
    }
  }
  if(flg){cout << "Yes" << endl;}
  else{cout << "No" << endl;}
}



Measured memory_bytes: 4584
while True:
    m, f, r = list(map(int, input().split()))
    if m == -1 and f == -1 and r == -1:
        break
    t = m + f
    if m == -1 or f == -1 or t < 30:
        print("F")
    elif 80 <= t:
        print("A")
    elif 65 <= t and t < 80:
        print("B")
    elif 50 <= t and t < 65:
        print("C")
    elif 30 <= t and t < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")



Measured memory_bytes: 5596
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N, M;
  vector<ll> X, Y;
  cin >> N >> M;
  REP(i, M) {
    ll x = 0;
    cin >> x;
    X.push_back(x);
  }
  sort(ALL(X));
  REP(i, M - 1) { Y.push_back(X[i + 1] - X[i]); }
  sort(ALL(Y));

  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  ll ans = 0;
  REP(i, M - N) { ans += Y[i]; }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2548
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = input()
    N = len(S)

    isKaibun = lambda s: s == s[::-1]
    if isKaibun(S) and isKaibun(S[:N//2]) and isKaibun(S[(N+1)//2:]):
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
from bisect import bisect_left
n=int(input())
lst=sorted(map(int,input().split()))
ans=0
for i in range(n):
    for j in range(i+1,n):
        p=lst[i]+lst[j]
        out=bisect_left(lst,p)
        ans+=(out-j-1)
print(ans)

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

int main(int argc, char const *argv[]) {
  char a;
  cin>>a;
  if(a=='a'||a=='i'||a=='u'||a=='e'||a=='o'){
    cout<<"vowel"<<endl;
  }else{
    cout<<"consonant"<<endl;
  }
  return 0;
}


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

static const int N = 100;
static const unsigned int INF = (1 << 31);

int n,m[N][N];
int dist[N];

void bfs(int s){
    queue<int> q;
    q.push(s);
    for(int i=0;i<n;i++) dist[i] = INF;
    dist[s] = 0;
    int u;
    while(!q.empty()){
        u = q.front();
        q.pop();
        for(int v=0;v<n;v++){
            if(m[u][v] == 0)   continue;
            if(dist[v] != INF) continue;
            dist[v] = dist[u]+1;
            q.push(v);
        }
    }
    for(int i=0;i<n;i++){
        cout << i+1 << ' ' << ((dist[i] == INF) ? -1 : dist[i]) << endl;
    }
}

int main(){
    int u,k,v;
    cin >> n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            m[i][j] = 0;

    for(int i=0;i<n;i++){
        cin >> u >> k;
        u--;
        for(int j=0;j<k;j++){
            cin >> v;
            v--;
            m[u][v] = 1;
        }
    }

    bfs(0);
}



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

using ll = long long;
using P = pair<int, int>;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  ll x, y, z, k;
  cin >> x >> y >> z >> k;
  ll a[x], b[y], c[z];
  for (int i = 0; i < x; i++) scanf("%lld", a + i);
  for (int i = 0; i < y; i++) scanf("%lld", b + i);
  for (int i = 0; i < z; i++) scanf("%lld", c + i);

  vector<ll> tmp;
  for (int i = 0; i < x; i++) {
    for (int j = 0; j < y; j++) {
      tmp.push_back(a[i] + b[j]);
    }
  }
  sort(tmp.begin(), tmp.end());
  reverse(tmp.begin(), tmp.end());

  vector<ll> ans;
  ll size = tmp.size();
  for (int i = 0; i < min(k, size); i++) {
    for (int j = 0; j < z; j++) {
      ans.push_back(tmp[i] + c[j]);
    }
  }
  sort(ans.begin(), ans.end());
  reverse(ans.begin(), ans.end());

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

Measured memory_bytes: 43364
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <cassert>
#include <fstream>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

const ll mod = 1e9 + 7;

vector<ll> dx = {1, -1, 0, 0};
vector<ll> dy = {0, 0, 1, -1};

vector<string> g;


int main() {
    
    
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    ll n;
    cin >> n;
    if (n % 2)
    {
        cout << 0 << endl;
        return 0;
    }
    ll tmp = (ll)pow(5, 25) * 2ll;
    ll tt = 0;
    vector<ll> p(26);
    for (int i = 25; i >= 1; --i)
    {
        p[i] = n / tmp - tt;
        tt = n / tmp;
        tmp /= 5ll;
    }
    
    ll ret = 0;
    for (int i = 1; i < p.size(); ++i)
    {
        ret += (ll)i * p[i];
    }
    
    cout << ret << endl;
    

    return 0;
}

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

using namespace std;
using ll = long long int;
#define INF 20000000000000000
#define MOD 1000000007

int main(void){
  int a, b;
  cin >> a >> b;
  
  if(a+b < 10) cout << a+b << endl;
  else cout << "error" << endl;
}

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

using namespace std;

const int N = 300005;

int n, m;
int cnty[N];
vector<int> posx[N];
int cnt[N], mx;

void add(int pos, int val) {
	cnt[ cnty[pos] ]--;
	cnty[pos] += val;
	cnt[ cnty[pos] ]++;
	while(cnty[pos] > mx) mx++;
	while(cnt[mx] == 0) mx--;
}

int main() {
	scanf("%d %d", &n, &m);

	int bombs;
	scanf("%d", &bombs);
	cnt[0] = bombs;
	for(int i = 0; i < bombs; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		posx[x].push_back(y);
		add(y, 1);
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) {
		for(int pos : posx[i]) add(pos, -1);
		int cand = (int)posx[i].size();
		ans = max(ans, cand + mx);
		for(int pos : posx[i]) add(pos, 1);
	}

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


Measured memory_bytes: 21400
import collections
def main():

    N, X, Y = map(int, input().split())
    count = collections.defaultdict(int)
    for i in range(1, N+1):
        for j in range(1, i):
            v = i-j
            v = min(v, abs(i-Y)+1+abs(X-j))

            count[v] += 1

    for i in range(1, N):
        print(count[i])


if __name__ == '__main__':
    main()
    # print(main())

Measured memory_bytes: 49116
if __name__ == '__main__':
    n, m = [int(i) for i in input().split()]
    A = [[int(i) for i in input().split()] for j in range(n)]
    b = [int(input()) for i in range(m)]
    c = [sum(map(lambda x,y: x*y, A[i], b)) for i in range(n)]
    print('\n'.join([str(i) for i in c]))

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

int main(){
	int X,Y;
	cin >> X >> Y;
	for(int i=0;i<=X;i++){
		if(2*i+4*(X-i)==Y){
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 3636
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner scanner = new Scanner(System.in);
        while(true){
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            if(x == 0 && y == 0){
                break;
            }else{
                if(x > y){
                    int a = x;
                    x = y;
                    y = a;
                }
                System.out.println(x +" "+ y);
            }
        }
    }
}



Measured memory_bytes: 37064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int> v(n+1);
    for(int i=1; i<=n; i++){
    	cin>>v[i];
    }
    int dp[n];
    dp[1]=0;
    dp[2]=abs(v[2]-v[1]);
    for(int i=3; i<=n; i++){
    	dp[i]=min((dp[i-1]+abs(v[i]-v[i-1])),(dp[i-2]+abs(v[i]-v[i-2])));
    }
    cout<<dp[n]<<'\n';
}



















//   #ifndef ONLINE_JUDGE
//     // for getting input from input.txt
//     freopen("input.txt", "r", stdin);
//     // for writing output to output.txt
//     freopen("output.txt", "w", stdout);
// #endif

Measured memory_bytes: 4000
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
using namespace std;
int main(){
	int A,B,C,D;
	scanf("%d %d %d %d", &A, &B, &C, &D);
	if (A + B > C + D){
		printf("Left\n"); 
	} else if (A + B == C + D){
		printf("Balanced\n");
	} else {
		printf("Right\n");
	}
	return 0;
} 

Measured memory_bytes: 256
#include<math.h>
#include<iostream>

using namespace std;

int main()
{
	long long a,i,b;
	cin >> a;
	b = a-1;
	for(i=1;i<=sqrt(a);i++)
	{
		if(a%i == 0)
		{
			if(b > i + a/i - 2)
			{
				b = i + a/i - 2;
			}
		}
	}
	cout <<b << endl;
}

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

int n;
string s;
int cnt;

int main(){

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

    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='(')cnt++;
        if(s[i]==')')cnt--;
        if(cnt<0){
            cout<<'(';
            cnt++;
        }
    }
    cout<<s;
    while(cnt>0){
        cout<<')';
        cnt--;
    }
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
s = list(input())

es = list("es")
ss = list("s")

#print(len(s))


f = s[len(s)-1]
#print(f)

if f == "s":
  ans = s+es
  ans = "".join(ans)
  print(ans)
else:
  ans = s+ss
  ans = "".join(ans)
  print(ans)
  


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

using ll = long long;

constexpr ll MOD = 1000000007;

ll modpow(ll n, ll r) {
    if(r == 0) return 1;
    if(r % 2 == 0) {
        ll tmp = modpow(n, r / 2);
        return tmp * tmp % MOD;
    }
    else {
        return n * modpow(n, r - 1) % MOD;
    }
}

ll X, Y;

void solve(){
    ll a = 2 * Y - X;
    ll b = 2 * X - Y;
    ll ans = 0;
    if(a >= 0 && a % 3 == 0 && b >= 0 && b % 3 == 0) {
        a /= 3;
        b /= 3;
        if(a > b) swap(a, b);
        ll u = 1;
        ll d = 1;
        for(ll i = 1; i <= a; ++i){
            u = u * (a + b - i + 1) % MOD;
            d = d * i % MOD;
        }
        ans = u * modpow(d, MOD - 2) % MOD;
    }
    cout << ans;
}
int main(){
    cin >> X >> Y;
    solve();
    return 0;
}

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

public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int digit = (int)Math.Floor(Math.Log(N,10)) + 1;
        int sum = 0;
        if(digit%2==0){
            for(int i=1;i<=digit-1;i+=2){
                sum += 9 * (int)Math.Pow(10,i-1);
            }
        }else{
            for(int i=1;i<=digit-2;i+=2){
                sum += 9 * (int)Math.Pow(10,i-1);
            }
            sum += N - (int)Math.Pow(10,digit-1) + 1;
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 11220
/*
[abc148] C - Snack
*/

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

ll gcd(ll a, ll b) {
    while (b > 0) {
        swap(b, a %= b);
    }
    return a;
}

ll lcm(ll a, ll b) {
    ll d = gcd(a, b);
    return a * b / d;
}

int A, B;

ll solve() { return lcm(A, B); }

int main() {
    cin >> A >> B;

    cout << solve() << endl;

    return 0;
}


Measured memory_bytes: 256
// #include <iostream>
// #include <string>
// #include <math.h>
// #include <map>
// #include <vector>
// #include <tuple>
// #include <algorithm>
// #include <queue>
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define vi vector<int>
#define vlli vector<lli>
#define pii pair<int, int>
#define plli pair <lli, lli>
#define F(i,n) for(lli (i)=0;(i)<(n);(i)++)
#define FR(i,n) for(lli (i)=(n)-1;(i)>=0;(i)--)
#define FSG(i,a,b) for(lli (i)=(a);(i)<(b);(i)++)
#define FSGR(i,a,b) for(lli (i)=(b)-1;(i)>=(a);(i)--)
#define VAL(n) cout << n << endl;
#define VALD(n) cout << #n << ": " << n << endl;
int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  lli ans[N] = {0};
  if (K > Q){
    F(i, N){
      cout << "Yes" << endl;
    }
  }
  else{
    F(i, Q){
      lli tmp = 0;
      cin >> tmp;
      ans[tmp-1] = ans[tmp-1] + 1;
    }
    F(i, N){
      if (K - (Q - ans[i]) > 0){
        cout << "Yes" << endl;
      }
      else{
        cout << "No" << endl;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 1408
a, b, c, x, y = map(int, input().split())
if a + b <= 2 * c:
  print(a*x + b*y)
else:
  ans = min(x, y) * 2 * c
  if x <= y:
    ans += min((y-x)*b, (y-x)*2*c)
  else:
    ans += min((x-y)*a, (x-y)*2*c)
  print(ans)

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

int digit(long N, long K){
  int digit = 1;
  while(N >= K){
    N = N / K;
    digit++;
  }
  return(digit);
}


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

  cout << digit(N, K) << endl;
}


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

int A[101010];
const int INF=INT_MAX/2;

int main(){
  int N,K; cin>>N>>K;
  int ind=0;
  rep(i,N){
    cin>>A[i];
    if(A[i]<A[ind]) ind=i;
  }
  if(K==N){
    cout<<1<<endl;
    return 0;
  }else if(K+1==N){
    cout<<2<<endl;
    return 0;
  }
  int ans=INF;
  for(int l=max(0,ind-K+1);l<=ind;l++){
    int a,b;
    if(l==0) a=0;
    else a=l/(K-1)+(l%(K-1)!=0?1:0);
    b=(N-l-K)/(K-1)+((N-l-K)%(K-1)!=0?1:0);
    ans=min(ans,1+a+b);
  }
  cout<<ans<<endl;
  return 0;
}


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

int N, K;

int main() {
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int x;  cin >> x;
		ans += 2 * min(x, K - x);
	}
	cout << ans << endl;
}


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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())
#define pqasc priority_queue<long long, vector<long long>, greater<long long>>

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

class UnionFind{
private:
  vector<int> Parent; 
 public:
  UnionFind(int N){
    Parent = vector<int>(N, -1);
  }
  
  int root(int A){
    if(Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  
  int size(int A){
    return -Parent[root(A)]; 
  }
  
  bool connect(int A, int B){
    A = root(A);
    B = root(B);
    if(A == B){
      return false;
    }
    if(size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
  
  bool isSame(int A, int B){
    return root(A) == root(B);
  }
};

long long gcd(long long a, long long b) { return b ? gcd(b, a%b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }

long long ngcd(vector<long long> a) {
  long long res = a[0];
  for(int i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}

long long nlcm(vector<long long> a){
  long long res = a[0];
  for(int i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}

bool is_prime(long long n) {
  if(n < 2) return false;
  for (long long i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}

int digsum(int n) {
  int res=0;
  while(n) res += n%10, n /= 10;
  return res;
}

int digcnt(int n){
  int res=0;
  while(n) res++, n /= 10;
  return res;
}

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  int n=s.size();
  int ans=INF;
  rep(i,n-2){
    int tmp=abs((s[i]-'0')*100+(s[i+1]-'0')*10+(s[i+2]-'0')-753);
    chmin(ans,tmp);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256