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

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

Measured memory_bytes: 512
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0].split(" ")[0]);
    const D = arg.slice(1, N + 1).map(n=>n.split(" ").map(l=>parseInt(l)));
    
    let max = 0;
    let temp = 0;
    
    for(let i in D) {
        if(D[i][0] === D[i][1]) {
            temp++;
        } else {
            temp = 0;
        }
        
        max = Math.max(max, temp);
    }
    
    console.log(max >= 3 ? "Yes" : "No");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29768
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

vector<int> cnt(1000001, 0);

bool check(int k){
    if (k == 1)
        return cnt[k] == 1;
    if (cnt[k] != 1) return false;
    if (cnt[1]) return false;
    for (int i = 2; i * i <= k; ++i){
        if (k % i == 0){
            if (cnt[i] || cnt[k / i]) return false;
        }
    }
    return true;
}

int main(void){
    int N; cin >> N;
    vector<int> A(N);
    for (auto& ai : A)
        cin >> ai;
    for (auto ai : A)
        ++cnt[ai];
    int res = 0;
    for (auto ai : A){
        res += check(ai);
    }
    cout << res << endl;
    return 0;
}


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

using namespace std;

int main(void){
  int x, c = 0;
  int i = 1;
  cin >> x;
  if(x == 2){
    cout << x << endl;
    return 0;
  }
  else if(x % 2 == 0){
    x = x + 1;
  }
  while(1){
    c = 1;
    for(i = 3; i < x / 2; i = i + 2){
      if(x % i == 0){
        c = 0;
        break;
      }
    }
   if(c == 1){
    	break;
    }
    x = x + 2;
  }
  cout << x << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vp vector<pair<int,int>>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//cout<<fixed<<setprecision(15)<<

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

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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 (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define N_HAND 3


int main() {
    i64 N, K; cin >> N >> K;
    i64 R, S, P; cin >> R >> S >> P;
    string T; cin >> T;
    vector<i64> winscore = {R, P, S};
    vector<i64> preds(N);
    REP(i, N) {
        if (T[i] == 'r') preds[i] = 0;
        if (T[i] == 'p') preds[i] = 1;
        if (T[i] == 's') preds[i] = 2;
    }

    i64 score = 0;
    vector<i64> hands(N);
    REP(i, N) {
        if (i < K) {
            hands[i] = (preds[i] + 1) % N_HAND;
            score += winscore[hands[i]];
            continue;
        }

        i64 prev_h = hands[i - K];
        i64 winnable_h = (preds[i] + 1) % N_HAND;
        if (winnable_h != prev_h) {
            hands[i] = winnable_h;
            score += winscore[hands[i]];
            continue;
        }

        if (i + K >= N) {
            hands[i] = (winnable_h + 1) % N_HAND;
            continue;
        }

        REP(j, 2) {
            hands[i] = (preds[i + K] - j + 3) % N_HAND;
            if (prev_h != hands[i]) break;
        }
    }

    cout << score << endl;

    return 0;
}

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

typedef long long int int64;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))

void run(void){
  int x;
  scanf("%d",&x);
  int n=1;
  while(n*(n+1)/2<x) n++;
  printf("%d\n",n);
}

int main(void){
  run();
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#define forn(i, n) for(int i = 1; i <= int(n); i++) 
using namespace std;
typedef long long ll;
inline int read() {
    char ch = getchar(); int x = 0, f = 1;
    while(ch < '0' || ch > '9') {
        if(ch == '-') f = -1;
        ch = getchar();
    } while('0' <= ch && ch <= '9') {
        x = x * 10 + ch - '0';
        ch = getchar();
    } return x * f;
}
inline void out(int x)
{
    if(x<0){
    	putchar('-');
		x=-x;
	}
    if(x>9) out(x/10);
    putchar(x%10+'0');
}
int main()
{
	long long sum=0;
	int n=read();
	forn(i,n)
	{
		if(i%3==0||i%5==0) continue;
		else sum+=i;
	}
	printf("%lld",sum);
	return 0;
 } 

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

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

  int dp[n][n];
  for (int i = n-1; i >= 0; i--)
  {
    for (int j = n-1; j >= 0; j--)
    {
      if(s[i]==s[j]){
        if(i==n-1 || j==n-1) dp[i][j]=1;
        else dp[i][j]=dp[i+1][j+1]+1;
      }
      else dp[i][j]=0;
    }
  }
  
  int maxlen=0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < n; j++)
    {
      if(i+dp[i][j]<=j){
        maxlen = max(maxlen,dp[i][j]);
      }
    }
  }

  cout << maxlen << endl;  
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if(s == "ABC") puts("ARC");
  else puts("ABC");
  return 0;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Main.run();
	}

	@SuppressWarnings("resource")
	private static void run() {
		Scanner scan = new Scanner(System.in);
		int n;
		while ((n = scan.nextInt()) != 0) {
			char[] cvt = new char[Byte.MAX_VALUE];
			for (int i = 0; i < Byte.MAX_VALUE; i++)
				cvt[i] = (char) i;
			for (int i = 0; i < n; i++) {
				int idx =  scan.next().charAt(0);
				cvt[idx] = scan.next().charAt(0);
			}

			int m = scan.nextInt();
			for (int i = 0; i < m; i++) {
				System.out.print(cvt[scan.next().charAt(0)]);
			}
			System.out.println("");
		}
		System.exit(0);

	}
}

Measured memory_bytes: 67372
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 998244353
mans = inf ;ans = 0 ;count = 0 ;pro = 1
sys.setrecursionlimit(10**6)

n = int(input())
XD = [(-10**10,inf)]
for i in range(n):
  x,d = map(int,input().split())
  XD.append((x,d))
XD.sort()

def dfs(node):
  res = 1
  i = node + 1
  while i < n+1:
    if XD[i][0] < XD[node][0] + XD[node][1]:
      pro,i = dfs(i)
      res *= pro
      res %= mod
    else: break

  return res + 1 , i
print((dfs(0)[0]-1)%mod)


Measured memory_bytes: 202324
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin>>N;
  int A=N/100;
  int B=N%100;
  if(A*5<B){
    cout<<"0"<<endl;
  }else{
    cout<<"1"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "vector"
#include "algorithm"

using namespace std;

long long power_int(long long a, int b)
{
  long long x = 1;
  while (b > 0)
  {
    x *= a;
    b--;
  }
  return x;
}

int main()
{
  int n, k;
  cin >> n >> k;
  long long a[1010];
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  long long sum[1010];
  sum[0] = 0;
  for (int i = 1; i < n + 1; i++)
  {
    sum[i] = sum[i - 1] + a[i - 1];
  }
  vector<long long> v;
  for (int i = 0; i < n + 1; i++)
  {
    for (int j = 0; j < i; j++)
    {
      v.push_back(sum[i] - sum[j]);
    }
  }

  int size = v.size();
  bool check[size][60];
  for (int i = 0; i < size; i++)
  {
    for (int j = 0; j < 60; j++)
    {
      check[i][j] = (v[i] % 2 == 1);
      v[i] /= 2;
    }
  }

  int digitsum[60] = {0};
  int digitans[60];

  for (int i = 59; i >= 0; i--)
  {
    for (int j = 0; j < size; j++)
    {
      if (check[j][i])
      {
        digitsum[i]++;
      }
    }
    if (digitsum[i] >= k)
    {
      digitans[i] = 1;
      for (int j = 0; j < size; j++)
      {
        if (check[j][i] == false)
        {
          for (int ii = 0; ii < 60; ii++)
          {
            check[j][ii] = false;
          }
        }
      }
    }
    else
    if (digitsum[i] < k)
    {
      digitans[i] = 0;
    }
  }
  long long ans = 0;
  for (int i = 0; i < 60; i++)
  {
    ans += digitans[i] * power_int(2,i);
  }
  cout << ans << endl;
}

Measured memory_bytes: 33772
#include <bits/stdc++.h>
using namespace std;
const int maxn=4000+10;
const int mod=924844033;
int n,k,fac[maxn],f[maxn][maxn][2],vis[maxn],a[maxn],tot;

int main()
{
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	for(int i=1;i<=k;i++){
		vis[++tot]=1;
		for(int j=i+k;j<=n;j+=k) vis[++tot]=0;
		vis[++tot]=1;
		for(int j=i+k;j<=n;j+=k) vis[++tot]=0;
	}
	f[0][0][0]=1;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<=n;j++){
			f[i][j][0]=(f[i-1][j][0]+f[i-1][j][1])%mod;
			if(j>0&&!vis[i]) f[i][j][1]=f[i-1][j-1][0];
		}
	int ans=0;
	for(int i=0;i<=n;i++){
		if(i&1) ans=(ans-1ll*fac[n-i]*(f[tot][i][0]+f[tot][i][1])%mod+mod)%mod;
		else ans=(ans+1ll*fac[n-i]*(f[tot][i][0]+f[tot][i][1])%mod)%mod;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 124672
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

int a, b, c, d, temp;

int main(){
    ios::sync_with_stdio(0);
    cin >> a >> b >> c >> d;

    temp = min(b,d) - max(a,c);

    if(temp < 0){
        cout << "0\n";
    }else{
        cout << temp << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=1e6;
int main()
{
	int n,k;
	cin>>n;
	vector<int>a(n);
	int ans=1e9;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int ret=0;
	for(int i=1;i<=100;i++){
		ret=0;
		for(int j=0;j<n;j++){
			ret+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ret,ans);
	}
	cout<<ans;
}

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

int main() {
	string s;
  	long long int k;
  	cin>>s>>k;
  	int cnt1=0;
  	
  	for(int i=0;i<100;i++){
    	if(s[i]=='1'){
        	cnt1++;
        }else{
        	break;
        }
    }
  
  	if(cnt1>=k){
    	cout<<1<<endl;
    }else{
    	cout<<s[cnt1]<<endl;
    }
}



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

h, w = [ int(v) for v in input().split() ]

field = [ list(map(int,input().replace("#","0").replace(".","1").replace("\n",""))) for i in range(h)]

yoko = [ copy.deepcopy(field[i]) for i in range(h)]


for i in range(h):
	for j in range(1,w):
		if yoko[i][j] == 0:
			yoko[i][j] = 0
		else:
			yoko[i][j] += yoko[i][j-1]
	for j in range(w-1,0,-1):
		if yoko[i][j-1] != 0:
			yoko[i][j-1] = max(yoko[i][j-1],yoko[i][j])

tate = [ [ field[i][j] for i in range(h)] for j in range(w) ]

for i in range(w):
	for j in range(1,h):
		if tate[i][j] == 0:
			tate[i][j] = 0
		else:
			tate[i][j] += tate[i][j-1]
	for j in range(h-1,0,-1):
		if tate[i][j-1] != 0:
			tate[i][j-1] = max(tate[i][j-1],tate[i][j])


ans = 0
for i in range(h):
	for j in range(w):
		ans = max((yoko[i][j] + tate[j][i]),ans)

print(ans-1)


Measured memory_bytes: 139016
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)

using namespace std;

class Point {
    public:
    double x, y;
    
    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator + (Point p) {return Point(x + p.x, y + p.y); }
    Point operator - (Point p) {return Point(x - p.x, y - p.y); }
    Point operator * (double a) {return Point(a * x, a * y); }
    Point operator / (double a) {return Point(x / a, y / a); }
    
    double abs() { return sqrt(norm()); }
    double norm() { return x * x + y * y; }
    
    bool operator < (const Point &p) const {
        return x != p.x ? x < p.x : y < p.y;
    }
    
    bool operator == (const Point &p) const {
        return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS; 
    }
};

struct Segment {
    Point p1, p2;
};

typedef Segment Line;

class Circle {
    public:
    Point c;
    double r;
    Circle(Point c = Point(), double r = 0.0): c(c), r(r) {}
};

typedef Point Vector;

double norm(Vector a) {
    return a.x * a.x + a.y * a.y;
}

double abs(Vector a) {
    return sqrt(norm(a));
}

double dot(Vector a, Vector b) {
    return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
    return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b) {
    return equals(dot(a, b), 0.0);
}

bool isOrthogonal(Point a1, Point a2, Point b1, Point b2) {
    return isOrthogonal(a1 - a2, b1 - b2);
}

bool isOrthogonal(Segment s1, Segment s2) {
    return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

bool isParallel(Vector a, Vector b) {
    return equals(cross(a, b), 0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2) {
    return isParallel(a1 - a2, b1 - b2);
}

bool isParallel(Segment s1, Segment s2) {
    return equals(cross(s1.p2 - s1.p1, s2.p2 - s2.p1), 0.0);
}

Point project(Segment s, Point p) {
    Vector base = s.p2 - s.p1;
    double r = dot(p - s.p1, base) / norm(base);
    return s.p1 + base * r;
}

Point reflect(Segment s, Point p) {
    return p + (project(s, p) - p) * 2.0;
}

int main() {
    int n;
    double x1, y1, x2, y2, x, y;
    Segment s;
    cin >> x1 >> y1 >> x2 >> y2;
    s.p1 = Point(x1, y1); s.p2 = Point(x2, y2);
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        cin >> x >> y;
        Point p = reflect(s, Point(x, y));
        cout << fixed << setprecision(10) << p.x
        << " " << fixed << setprecision(10) << p.y << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3296
n, k = map(int, input().split())
arr = list(map(int, input().split()))

from collections import deque
d = deque()

maxE = 0
sumE = 0

# pの期待値(p+1)/2
for i in range(n):
    p = arr[i]
    e = (p+1)/2
    # print(e)
    sumE += e
    d.append(e)
    # print(sumE)
    if i+1 >= k:
        if sumE > maxE:
            maxE = sumE
        sumE -= d.popleft()

print(maxE)

Measured memory_bytes: 71792
#include<iostream>
#include<vector>
#include <utility>
#include <string>
#include <algorithm> // sort
#include <map> // pair

typedef long long ll;
using namespace std;


ll N;



int main(){
  cin >> N;
  vector<pair<ll,ll> > pairs(N);
  //pair<int,int> pairs(N);
  for(int i=0;i<N;i++){
    ll a,b;
    cin >> a >> b;
    pairs[i] = make_pair(b,a);
  }
  sort(pairs.begin(),pairs.end());
  //for (int i = 0; i < N; i++) {
  //  cout << pairs[i].first<< " " << pairs[i].second<<endl;;
  //}
  ll sum=0;
  bool k=true;
  for(int j=0;j<N;j++){
    sum +=pairs[j].second;
    if(sum>pairs[j].first){
      k=false;
      break;
    }
  }
  if(k) cout << "Yes" << endl;
  else cout <<"No" << endl;
  
}


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

using namespace std;

int main()
{
    int n,a[100];
    string s;
    cin >> n >> s;
    int Ans = 0;
    for(int i = 0;i<n;i++){
        while(i + 1 < n && s[i] == s[i + 1])   i++;
        Ans++;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	double students[1000] = {0},sum,m,div;

	while(true){
		scanf("%d",&n);
		if(n == 0) break;
		div = sum = 0;
		for(int i = 0; i < n; i++){
			scanf("%lf",&students[i]);
			sum += students[i];
		}
		m = sum/n;
		for(int i = 0; i < n;i++){
			div += (students[i] - m)*(students[i] - m);
			students[i] = 0;
		}
		printf("%.8lf\n",sqrt(div/n));
	}
}


Measured memory_bytes: 2708
#pragma GCC optimize("O3")
#include <iostream>
#include <iomanip>
#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 <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

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

template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}
template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}

constexpr int MOD = 1e9 + 7;
constexpr int inf = 1e9;
constexpr long long INF = 1e18;

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

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

    string s; cin>>s;
    
    if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
/*bit全探索を用いたABC167のCの解法*/
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    vector<vector<int>> a(n, vector<int>(m));
    vector<int> c(n);
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++)cin >> a[i][j];
    }
    int ans = 12345678;
    int all = 1<<n;
    for(int mask = 0; mask < all; mask++){
        vector<int> level(m);
        int cost = 0;
        for(int i = 0; i < n; i++){
            if((mask>>i)&1){
                cost += c[i];
                for(int j = 0; j < m; j++){
                    level[j] += a[i][j];
                }
            }
        }
        bool ok = true;
        for(int j = 0; j < m; j++){
            if(level[j] < x) ok = false;
        }
        if(ok) ans = min(ans,cost);
    }
    if(ans == 12345678) cout << -1 << endl;
    else cout << ans << endl;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

ll minverse(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return minverse((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*minverse((x*x)%M,(n-1)/2,M))%M;

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
    	   ll n,k;
    	   cin>>n>>k;
    	   ll p=(2*k+1);
    	   ll u=ceil((double)n/p);
    	   cout<<u<<endl;
    	   
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        StringBuffer str = new StringBuffer(S);
        S = str.reverse().toString();
        int i = 0;
        int len = S.length();
        while(true) {
            if(len - i >= 5 && S.substring(i, i+5).equals("esare")) {
                //S = S.replace("esare","");
                i += 5;
            }else if(len - i >= 5 && S.substring(i, i+5).equals("maerd")) {
                //S = S.replace("maerd","");
                i+= 5;
            }else if(len - i >= 7 && S.substring(i, i+7).equals("remaerd")) {
                //S = S.replace("remaerd","");
                i += 7;
            }else if(len - i >= 6 && S.substring(i, i+6).equals("resare")) {
                //S = S.replace("resare","");
                i += 6;
            }else {
                break;
            }
        }
        if(i == len) System.out.println("YES");
        else System.out.println("NO");
    }
}

Measured memory_bytes: 28396
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const long long INF = 1e10;
const long long MOD = 1e9+7;
using Graph = vector<vector<ll>>;
using pll = pair<ll, ll>;
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 ceilll(ll a, ll b) {return (a + b-1) / b;}
ll get_digit(ll a) {ll digit = 0; while(a != 0){a /= 10; digit++;} return digit;} // a != 0

// 0 false, 1 true 
// string number to int : -48
// a to A : -32
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp
// global vector -> 0 initialization

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n; cin >> n;
    vector<long long> vec(n);
    for(long long i = 0; i < n; i ++){
        cin >> vec[i];
    }
    ll ans = 0;
    rep(i, n){
        if(i == 0) continue;
        if(vec[i-1] > vec[i]){
            ans += vec[i-1] - vec[i];
            vec[i] = vec[i-1];
        }
    }
    cout << ans << endl;

}

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

int dp[3001]={0};
int a,b;

int main(){
    int n,t,s,ans=0;
    cin>>n>>t>>s;
    for(int i=0;i<n;++i){
        cin>>a>>b;
        for(int j=t;j>=b;--j)
        if(j<=s||j-b>=s) dp[j]=max(dp[j],dp[j-b]+a);
    }
    for(int i=0;i<=t;++i) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3116
#include <iostream>
#include <vector>
#include <string>

using namespace std;

using ll = long long;

class Node {
    public:
        Node();
        ll p, l, r;
};


Node::Node()
    : p(-1), l(-1), r(-1)
{
}


void depth(vector<Node> &nodes, vector<ll> &D, ll id, ll d)
{
    D[id] = d;
    if (nodes[id].l != -1)
        depth(nodes, D, nodes[id].l, d + 1);
    if (nodes[id].r != -1)
        depth(nodes, D, nodes[id].r, d);
}


string node_type(vector<Node> &nodes, ll id)
{
    if (nodes[id].p == -1)
        return string("root");
    else if (nodes[id].l == -1)
        return string("leaf");
    else
        return string("internal node");
}


int main()
{
    ll n;
    cin >> n;
    vector<Node> nodes(n);

    for (ll i = 0; i < n; i++) {
        ll id, k;
        cin >> id >> k;
        for (ll j = 0; j < k; j++) {
            ll c, sib;
            cin >> c;
            if (j == 0) {
                nodes[id].l = c;
            } else {
                nodes[sib].r = c;
            }
            nodes[c].p = id;
            sib = c;
        }
    }

    ll root;
    for (ll i = 0; i < n; i++) {
        if (nodes[i].p == -1) {
            root = i;
            break;
        }
    }

    vector<ll> D(n);
    depth(nodes, D, root, 0);

    for (ll i = 0; i < n; i++) {
        cout << "node " << i << ": parent = " << nodes[i].p << ", depth = " << D[i] << ", " << node_type(nodes, i) << ", ";
        cout << "[";

        ll c = nodes[i].l;
        while (c != -1) {
            cout << c;
            if (nodes[c].r != -1)
                cout << ", ";
            c = nodes[c].r;
        }
        cout << "]";

        cout << endl;
    }
}



Measured memory_bytes: 5892
#include <bits/stdc++.h>
#define L(i, m, n) for(int i(m);i < n;i++)
#define pb push_back
#define D(X) cout<<"  "<<#X": "<<X<<endl;
#define in(x) cin >> x
#define SZ(X) int(X.size())
#define ff first
#define ss second
#define RF(X) freopen(X, "r", stdin)
#define WF(X) freopen(X, "w", stdout)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<int, string> pis;
typedef vector<string> vs;
typedef pair<pair<int, int>, pair<int, int > > piiii;


int main(){
	int a[3];
	L(i,0,3) in(a[i]);sort(a,a+3);
	cout << a[0]+a[1]<<endl;
	
	
	
	return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())
lis=[]
for i in range(m):
    lis.append(list(map(int,input().split())))
    lis[i].append(i)
lis.sort()
lis[0][1]=1
for i in range(m-1):
    if lis[i][0]==lis[i+1][0]:
        lis[i+1][1]=lis[i][1]+1
    else:
        lis[i+1][1]=1
for i in range(m):
    lis[i].append(str(lis[i][0]).rjust(6,"0")+str(lis[i][1]).rjust(6,"0"))
    del lis[i][0]
    del lis[i][0]
lis.sort()
for i in range(m):
    print(lis[i][1])


Measured memory_bytes: 38648
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const long long INF = 1e15;

#include <math.h>
#define PI 3.14159265358979323846264338327950L

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

long long gcd(long long a, long long b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

vector<long long> common_divisors(long long a, long long b) {
    long long n = gcd(a, b);
    vector<long long> ans;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            if (n / i == i) {
                ans.push_back(i);
            }
            else {
                ans.push_back(n / i);
                ans.push_back(i);
            }
        }
    }
    return ans;
}

bool is_sorted(vector<int> a) {
    int n = a.size();
    for (int i = 0; i < n - 1; i++) {
        if (a[i + 1] < a[i]) return false;
    }
    return true;
}

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

Measured memory_bytes: 3636
#include <stdio.h>
int A[3001],d[3001],M=998244353,i,K,N,S,j,P;
int main(){scanf("%d%d",&N,&S);while(i++<N)scanf("%d",&A[i]);while(--i){j=S+1;P=A[i];while(j--){d[j]+=(j>=A[i]?d[j-P]:0)+(j==P);d[j]%=M;}K=(K+d[S])%M;d[0]++;}printf("%d\n",K);}

Measured memory_bytes: 1752
n, *a = map(int, open(0).read().split())

a.sort(reverse=True)

width = 0
length = 0
flg = False
cnt = 0
for i in range(n - 1):
    if flg:
        flg = False
        continue
    
    if a[i] == a[i + 1]:
        if cnt == 0:
            width = a[i]
        elif cnt == 1:
            length = a[i]
            break
        
        flg = True
        cnt += 1

print(width * length)

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

int main(){
    int n;
    cin>>n;
    vector<int>s(n);
    rep(i,n) cin>>s[i];
    sort(s.begin(),s.end());
    int ans=0;
    rep(i,n){
        ans+=s[i];
    }
    if(ans%10!=0){
        cout<<ans<<endl;
        return 0;
    }
    int key=-1;
    rep(i,n){
        if(s[i]%10!=0){
            key=i;
            break;
        }
    }
    
    if(key==-1)ans=0;
    else ans-=s[key];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
/// Author: Yen-Jen Wang
#include <bits/stdc++.h>

using namespace std;

const int MAX_N = 50 + 7;

struct Dsu {
	int n, cc;
	int par[MAX_N];
	int sz[MAX_N];

	void init(int _n) {
		n = _n;
		cc = n;
		for (int i = 1; i <= n; i++) {
			par[i] = i;
			sz[i] = 1;
		}
	}

	int find(int x) {
		return par[x] == x ? x : (par[x] = find(par[x]));
	}

	bool merge(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y)
			return 1;
		cc--;
		if (sz[x] < sz[y])
			swap(x, y);
		sz[x] += sz[y];
		par[y] = x;
		return 1;
	}
} dsu;

int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int> > es;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		es.emplace_back(a, b);
	}
	int ans = 0;
	for (int i = 0; i < M; i++) {
		dsu.init(N);
		for (int j = 0; j < M; j++) {
			if (j != i)
				dsu.merge(es[j].first, es[j].second);
		}
		if (dsu.cc != 1)
			ans++;
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<iostream>

#include <string>
using namespace std;

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

    cin >> a;
    cin >>b;
    cin >> c;
    cin >> k;
    int sum = 0;

    for(int i = 0; i<k;i++){
        if(a>0){
            sum += 1;
            a--;

        }else if(b>0){
            b--;

        }else{
            sum -= 1;
            c--;

        }
    }

    cout << sum << endl;
     
}

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

using namespace std;

int main(){
  int N; cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  
  int max1,max2;
  if(A.at(0) > A.at(1)){
    max1 = 0;
    max2 = 1;
  }else{
    max1 = 1;
    max2 = 0;
  }

  for(int i = 2; i < N; i++){
    if(A.at(i) > A.at(max1)){
      max2 = max1;
      max1 = i;
    }else if(A.at(i) > A.at(max2)){
      max2 = i;
    }
  }

  //  cout << "max1 max2" << max1 << " " << max2 << endl;
  for(int i = 0; i < N; i++){
    if(i != max1) cout << A.at(max1) << endl;
    else cout << A.at(max2) << endl;
  }

}


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

//https://atcoder.jp/contests/nikkei2019-qual/tasks/nikkei2019_qual_d

const int nm = 1e5 - 1;
int n, m, p[nm], d[nm];
vector<int> g[nm];
bool b[nm];

void dfs(int v) {
	if (g[v].empty()) {
		p[v] = -1;
		d[v] = 0;
	} else {
		for (int nv : g[v]) {
			if (!b[nv])
				dfs(nv);
			if (d[nv] + 1 > d[v]) {
				d[v] = d[nv] + 1;
				p[v] = nv;
			}
		}
	}
	b[v] = 1;
}

int main() {
	cin >> n >> m;
	for (int i = 0; i < n - 1 + m; ++i) {
		int u, v;
		cin >> u >> v;
		--u, --v;
		g[v].push_back(u);
	}
	for (int i = 0; i < n; ++i)
		if (!b[i])
			dfs(i);
	for (int i = 0; i < n; ++i)
		cout << p[i] + 1 << endl;
}


Measured memory_bytes: 10112
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stdio.h>
#include<vector>
using namespace std;
int res[100001];
vector<int> g[100001];
queue<int> q;
int main(){
  int n;cin>>n;
  memset(res,-1,sizeof(res));
  res[1]=0,res[n]=1;
  for(int i=0;i<n-1;i++){
    int x,y;
    cin>>x>>y;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  q.push(1);
  q.push(n);
  int cnt[2];
  cnt[0]=1,cnt[1]=1;
  while(!q.empty()){
    int x=q.front();
    q.pop();
    for(int i=0;i<g[x].size();i++)
      if(res[g[x][i]]==-1){
        res[g[x][i]]=res[x];
        cnt[res[x]]++;
        q.push(g[x][i]);
      }
  }
  puts((cnt[0]>cnt[1])?"Fennec":"Snuke");
  return 0;
}

Measured memory_bytes: 6272
n = int(input())
Big_lis = []
A = []

for i in range(n):
    lis = []
    a = int(input())
    A.append(a)
    for j in range(a):
        x, y = map(int, input().split())
        lis.append((x, y))
    Big_lis.append(lis)
ANS = 0

for i in range(2 ** n):
    check = bin(i)[2:]
    check = '0' * (n - len(check)) + check
    ans = check.count('1')
    for j in range(n):
        if i >> j & 1:
            for k in range(A[j]):
                if str(check[n - Big_lis[j][k][0]]) != str(Big_lis[j][k][1]):
                    ans = 0
    ANS = max(ANS, ans)
print(ANS)

Measured memory_bytes: 74360
#include<stdio.h>
main(){
  int x, y, z, d;
  scanf("%d", &x);
  scanf("%d", &y);
  if(x < y){
    z = x;
    x = y;
    y = z;
  }
  while((d = x%y) != 0){
    x = y;
    y = d;
  }
  printf("%d\n", y);
  return 0;
}

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

int main() {
	long long n;
	cin>>n;
	int flag  = false;
	for(int i = 1 ; i<= 9 ;i++)
	{
	   if(n%i==0)
	   {
	       if(n/i <= 9)
	       {
	           cout<<"Yes"<<endl;
	           exit(0);
	       }
	   }
	}
	cout<<"No"<<endl;
	exit(0);
	return 0;
}


Measured memory_bytes: 256
fn print_vec(arr: &Vec<u32>) {
    for i in 0..arr.len() {
        print!("{}", arr[i]);
        if i < arr.len() - 1 {
            print!(" ");
        }
    }
}
fn bubble_sort(arr: &Vec<u32>, n: u32) -> Vec<u32> {
    let mut sorted = arr.to_vec();
    let mut n_swap = 0;
    for j in 1..arr.len() {
        for i in (j..arr.len()).rev() {
            if sorted[i - 1] > sorted[i] {
                let tmp = sorted[i - 1];
                sorted[i - 1] = sorted[i];
                sorted[i] = tmp;
                n_swap += 1;
            }
        }
    }
    print_vec(&sorted);
    println!("\n{}", n_swap);

    sorted
}

fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let n: u32 = line.trim().parse().ok().unwrap();

    line.clear();
    std::io::stdin().read_line(&mut line).ok();
    let arr = line.split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect();

    bubble_sort(&arr, n);
}



Measured memory_bytes: 5032
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10

#solve
def solve():
    n = II()
    d = LI()
    m = II()
    t = LI()
    d.sort()
    t.sort()
    i = 0
    for j in range(m):
        while i < n and d[i] < t[j]:
            i += 1
        if i >= n:
            print("NO")
            return
        if d[i] == t[j]:
            i += 1
        elif d[i] > t[j]:
            print("NO")
            return
    print("YES")
    return


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


Measured memory_bytes: 117584
///mAAria...
#include<bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define all(v) v.begin(),v.end()
#define allr(v) v.rbegin(),v.rend()
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pii pair<int,int>
#define pi 3.1415926535897932384626433832
#define mod 1000000007
//#define mod 998244353
#define inf 1000000000
#define pr1(a) cout << a << "\n"
#define pr2(a,b)cout << a <<  " " <<b<< "\n"
#define pr3(a,b,c) cout << a <<" " << b << " " << c << "\n"

const long double PI = acos(-1);

int powm(int a, int b) {
    int res=1;
    while(b) {
        if(b&1)
            res=(res*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return res;
}

int gcd(int a, int b){
    if(b==0)return a;
    gcd(b,a%b);
}
const int maxn = 2*1e5 + 10;
void solve(){

   int n,m;
   cin >> n >> m;
   int sum = 0;

   int a[n+2];
   for(int i = 1;i<=n;i++){
    cin >> a[i];
    sum+=a[i];
   }

   int x = sum/(4*m);
   if(sum%(4*m)!=0)x+=1;

   int cnt = 0;
   for(int i = 1;i<=n;i++){
    if(a[i]>=x){
        cnt++;
    }
   }
   // cout << cnt <<endl;

   if(cnt>=m)cout << "Yes" << endl;
   else cout << "No" << endl;

} 

signed main() 
{   
    IOS;
    int t = 1;
    // cin >> t;

    for(int i = 1;i<=t;i++){
        solve();
    }
    return 0;
} 

 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
string s;
int main()
{
	int k;
	cin>>s>>k;int n=s.size();
	for (int i=0;i<n-1;i++){
		if (s[i]=='a') continue;
		int t=('a'-s[i]+26);
		if (t<=k){
			k-=t;
			s[i]='a';
		}
	}
	s[n-1]=(s[n-1]+k-'a')%26+'a';
	cout<<s<<endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

int main() {
  string s;
  cin >> s;
  vi num(4);
  rep(i, 4) num[i] = s[i] - '0';
  REP(x, 0, (1 << 3)) {
    int tmp = num[0];
    rep(i, 3) {
      if ((x >> i) & 1) {
        tmp += num[i + 1];
      } else {
        tmp -= num[i + 1];
      }
    }
    if (tmp == 7) {
      cout << num[0];
      rep(i, 3) {
        if ((x >> i) & 1) {
          cout << "+" << num[i + 1];
        } else {
          cout << "-" << num[i + 1];
        }
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
char f[100][100];
bool isBrackW[100];
bool isBrackH[100];
int main() {
	int h, w;
	bool isErase;
	scanf("%d%d", &h, &w);
	for (int i = 0; i < h; i++) {
		scanf("%s", f[i]);
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (f[i][j] == '#')
				isBrackH[i] = true;
		}
	}
	for (int i = 0; i < w; i++) {
		for (int j = 0; j < h; j++) {
			if (f[j][i] == '#')
				isBrackW[i] = true;
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (isBrackH[i] && isBrackW[j])
				printf("%c", f[i][j]);
		}
		if (isBrackH[i])
			printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
n, k = map(int, input().split())
a = tuple(map(int, input().split()))

dp = [None] * (k + k + 1)
# dp[手番の石の数] := 手番の勝敗
# True(勝ち) / None(負け)

for opponent_remains in range(k):  # 自分が石を取った残りなので、k未満
    if dp[opponent_remains] is None:  # 相手が負ける場合
        for my_take in a:  # 自分が取る石の数
            my_remains = opponent_remains + my_take  # 相手が負けるようにできる、自分の手番の石の数
            dp[my_remains] = True

ans = dp[k]
print('First' if ans else 'Second')


Measured memory_bytes: 4596
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 1001001001;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> X(N);

    ll ans = INF;
    for(ll i=0;i<N;i++) cin >> X[i];
    for(ll i=0;i<N;i++){
        if(i+K-1 >= N) continue;
        ll pre_ans;
        ll l = i,r = i+K-1;
        if(X[l]*X[r] < 0){
            pre_ans = min(abs(X[l]),abs(X[r]))*2 + max(abs(X[l]),abs(X[r]));
        }
        else{
            pre_ans = max(abs(X[l]),abs(X[r]));
        }
        ans = min(ans,pre_ans);
    }
    cout << ans << endl;

}


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

using namespace std;

int main() {

    string in_data;
    string mae_data;
    string ato_data;

    cin >> in_data;

    mae_data = in_data.substr(0,2);
    ato_data = in_data.substr(2,2);

    int mae = atoi(mae_data.c_str());
    int ato = atoi(ato_data.c_str());

    bool mae_mm, ato_mm;
    mae_mm  = false;
    ato_mm  = false;

    if (mae >= 1 && mae <= 12) {
        //前がMM可能
        mae_mm = true;
    }
    
    if (ato >= 1 && ato <= 12) {
        //後がMM可能
        ato_mm = true;
    }

    string message;
    message = "";

    if (mae_mm  && ato_mm ) {
        //なんとも言えない
        message ="AMBIGUOUS";

    } else {

        if (ato_mm) {
            //YYMM
            message = "YYMM";

        } else if (mae_mm) {
            //MMYY
            message = "MMYY";

        } else {
            //other
            message = "NA";
        }

    }


    cout << message << endl;


    return 0;

}

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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  int x,y;
  x=0;
  y=0;
  if(a==5) x++;
  else if(a==7) y++;
  if(b==5) x++;
  else if(b==7) y++;
  if(c==5) x++;
  else if(c==7) y++;
  if(x==2 && y==1) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}


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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

int main() {

    int k, x;
    cin >> k >> x;

    if(500*k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
height = []
sum = 0
i = 1
while ( sum <= 498501)
    sum += i
    i += 1
    height.push(sum)
end

#puts height
#puts height[5]
a,b = gets.chomp.split(" ").map(&:to_i)
(1..997).each do |n|
    if a - height[n] == b - height[n+1]
        puts (height[n] - a)
    end
end

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

void bfs(queue<int> que, vector<int> &isVisited, vector<vector<int> > &vec){
    que.push(0);
    isVisited[0] = 1;
    while(que.size() != 0){
        int q = que.front();
        rep(i,vec[q].size()){
            if (isVisited[vec[q][i]] == 0){
                que.push(vec[q][i]);
                isVisited[vec[q][i]] = q + 1;
            }
        }
        /*rep(i,isVisited.size()){
            cout << isVisited[i] << endl;
        }*/
        que.pop();
    }
}

int main(){
    int N,M;
    cin >> N >> M;
    vector<pair<int,int> > route(M);
    rep(i,M){
        cin >> route[i].first >> route[i].second;
        route[i].first--;
        route[i].second--;
    }
    vector<vector<int> > connection(N,vector<int> (0));
    rep(i,M){
        connection[route[i].first].push_back(route[i].second);
        connection[route[i].second].push_back(route[i].first);
    }
    /*rep(i,N){
        rep(j,connection[i].size()){
            cout << connection[i][j] << " ";
        }
        cout << endl;
    }*/
    vector<int> isVisited(N,0);
    queue<int> que;
    bfs(que, isVisited, connection);
    bool possible = true;
    rep(i,N){
        if (isVisited[i] == 0) possible = false;
    }
    if (possible){
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++){
            cout << isVisited[i] << endl;
        }
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 11748
#![allow(unused_imports)]

use std::{i32, i64, u32, u64, usize, f64};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use maplit::*;
use proconio::{input, marker::{Isize1, Usize1, Bytes, Chars}};

//#[proconio::fastout]
fn main() {
    input!(
        n: usize,
        arr: [i64; n],
    );
    let mut presum = arr.iter().copied().scan(0, |acc, a| {
        *acc += a;
        Some(*acc)
        }
    ).collect::<Vec<_>>();
    let sum = presum.pop().unwrap();
    println!("{}", presum.into_iter().map(|s| (sum - 2*s).abs()).min().unwrap());
}


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

#define ll long long
#define PB push_back
#define PII pair<int, int>
#define MP make_pair
#define all(x) x.begin(), x.end()
#define REP(x, y, z) for(int x = y; x <= z; x++)
#define REPP(x, y, z) for(int x = y; x >= z; x--)
#define F first
#define S second
#define MSET(x, y) memset(x, y, sizeof(x)) 
#define EB emplace_back
#define maxn 20

//structure

//declaration
vector<PII> v[maxn];
//functions

int main(void)
{
	#ifdef DBG
	freopen("in.in", "r", stdin);
	freopen("out.out", "w", stdout);
	#endif

	int n, m;

	scanf("%d", &n);

	REP(i, 1, n)
	{
		scanf("%d", &m);

		int x, y;

		REP(j, 1, m)
		{
			scanf("%d %d", &x, &y);

			v[i].PB(MP(x, y));
		}
	}

	int check[maxn], ans = 0;

	MSET(check, -1);

	for(int i = 0; i < (1 << n); i++)
	{
		bitset<15> b(i);

		REP(j, 0, n-1)
		{
			if(b[j] == 1)
				check[j+1] = 1;
			else
				check[j+1] = 0;
		}

		bool flag = true;

		REP(j, 1, n)
		{
			for(auto k : v[j])
			{
				if(check[j] == 1)
				{
					if(check[k.F] != k.S)
					{
						flag = false;
						break;
					}
				}

				// if(check[j] == 0)
				// {
				// 	if(check[k.F] == k.S)
				// 	{
				// 		flag = false;
				// 		break;
				// 	}
				// }
			}

			if(!flag)
				break;
		}

		if(flag)
			ans = max(ans, (int)b.count());
	}

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

	return 0;
}

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

int DigitSum(int n){
int ans = 0;
while(n!=0){
    ans += n % 10;
    n /= 10;
}
return ans;
}

int main(){
    int n, a, b, sum = 0;
    cin >> n >> a >> b;
    for (int i = 1; i <= n; i++) {
        int sumdig = DigitSum(i);
        if(a <= sumdig && sumdig <= b) sum += i;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256