akhauriyash/Code-Regression huggingface dataset:
function Main(input) {
    input = input.trim().split("\n").map(function(x) { return x.split(" ")});
    var l = 0;
    while (true){
        var w = parseInt(input[l][0], 10);
        var h = parseInt(input[l][1], 10);
        if (w === 0 && h === 0) break;
        var line;
        var arr_c = [];
        for (var i = 0; i < h; i++){
            line = input[i + l + 1].map(e => parseInt(e, 10));
            arr_c.push(line);
        }
        arr_v = [];
        var countGround = 0;
        for (var i = 0; i < h; i++){
            for (var j = 0; j < w; j++){
                if (arr_c[i][j] === 1) countGround ++;
                arr_v.push([]);
                if (i - 1 >= 0 && j - 1 >= 0 && arr_c[i - 1][j - 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i - 1, j - 1, w));
                if (i - 1 >= 0 && arr_c[i - 1][j] === 1) arr_v[arr_v.length - 1].push(calcIndex(i - 1, j, w));
                if (i - 1 >= 0 && j + 1 < w && arr_c[i - 1][j + 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i - 1, j + 1, w));
                if (j - 1 >= 0 && arr_c[i][j - 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i, j - 1, w));
                if (j + 1 < w && arr_c[i][j + 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i, j + 1, w));
                if (i + 1 < h && j - 1 >= 0 && arr_c[i + 1][j - 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i + 1, j - 1, w));
                if (i + 1 < h && arr_c[i + 1][j] === 1) arr_v[arr_v.length - 1].push(calcIndex(i + 1, j, w));
                if (i + 1 < h && j + 1 < w && arr_c[i + 1][j + 1] === 1) arr_v[arr_v.length - 1].push(calcIndex(i + 1, j + 1, w));
            }
        }
        var tmp = 0;
        arr_time = Array.from({length: h * w}, () => [0, 0, 0]);
        time = 1;
        var countIsland = 0;
        history = [];
        whole_loop:
        while (time < countGround * 2){
            for (var i = tmp; i < h * w; i++){
                if (arr_c[calcIndex2(i, w)[0]][calcIndex2(i, w)[1]] === 1 && arr_time[i][1] === 0) {
                    arr_time[i] = [i, time, 0];
                    history = [i];
                    time ++;
                    finished = DFS(i);
                    tmp = i;
                    countIsland ++;
                    continue whole_loop;
                }
            }
        }
        // for (var x of arr_time){
        //     console.log(x.join(" "))
        // }
        console.log(countIsland);
        l += h + 1;
    }
}
function calcIndex(i, j, w){
    return i * w + j;
}

function calcIndex2(n, w){ // n >= 0
    return [(n / w | 0), n % w]
}

function DFS(tmpNode){
    for (let x of arr_v[tmpNode]){
        if (arr_time[x][1] === 0) {
            arr_time[x] = [x, time, 0];
            time ++;
            history.push(x);
            DFS(x);
        } 
    }
    arr_time[tmpNode][2] = time;
    time ++;
    history.pop();
    return true;
}

Main(require("fs").readFileSync("/dev/stdin", "utf8")); 




Measured memory_bytes: 22328
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 西を表す文字 */
	private static final char WEST = 'W';

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			char[] s = scanner.next().toCharArray();
			int[] wCounts = new int[n + 1], eCounts = new int[n + 1];
			wCounts[0] = eCounts[0] = 0;
			IntStream.range(0, n).forEach(i -> {
				wCounts[i + 1] = (s[i] == WEST) ? wCounts[i] + 1 : wCounts[i];
				eCounts[i + 1] = (s[i] == WEST) ? eCounts[i] : eCounts[i] + 1;
			});
			System.out.println(
					IntStream.rangeClosed(1, n).map(i -> wCounts[i - 1] + eCounts[n] - eCounts[i]).min().getAsInt());
		}
	}
}


Measured memory_bytes: 45992
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vii = vector<ii>;

const ll oo = 1e9+5;

int main() {
    
    int n;
    scanf("%d",&n);
    
    vector<ll> h(n);
    for(int i = 0; i < n; ++i) {
        scanf("%lld",&h[i]);
    }
    
    vector<ll> dp(n, oo);
    dp[0] = 0;
    
    for(int i = 0; i < n; ++i) {
        if(i+1 < n) dp[i+1] = min(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
        if(i+2 < n) dp[i+2] = min(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
    }
    
    printf("%lld\n", dp[n-1]);
    
    return 0;
}




Measured memory_bytes: 1792
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#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 int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

vector<ll> val;

void bfs() {
    queue<ll> que;
    for(int k=1; k<=9; k++) {
        que.emplace(k);
    }

    while(val.size() <= 100010) {
        queue<ll> n_que;
        while(que.size()) {
            ll v = que.front(); que.pop();
            val.emplace_back(v);
            if(val.size() >= 100010) break;
            int c = v % 10;
            for(int k=c-1; k<=c+1; k++) {
                if(k >= 10 or k < 0) continue;
                ll nv = v * 10 + k;
                n_que.emplace(nv);
            }
        }
        swap(que, n_que);
    }

    /*
    fprintf(stderr, "val: %zu\n", val.size());
    if(val.size() >= 100010) return;
    if(s == "") {
        for(int i=1; i<=9; i++) {
            if(val.size() >= 100010) return;
            s += (char)('0' + i);
            val.emplace_back(stoll(s));
            dfs(s);
            s.pop_back();
        }
    }
    else {
        int c = s.back() - '0';
        cerr << c << endl;
        for(int k=c-1; k<=c+1; k+=2) {
            if(val.size() >= 100010) return;
            if(k >= 10 or k < 0) continue;
            s += (char)('0' + k);
            val.emplace_back(stoll(s));
            dfs(s);
            s.pop_back();
        }
    }
    */
}

int main() {
    bfs();
    sort(val.begin(), val.end());

    int K; cin >> K;
    cout << val[K-1] << endl;
    return 0;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

const double PI = 3.14159265358979323846;

int main(){
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double hx = a * cos(2.0 * PI * h / 12.0 + 2.0 * PI / 12.0 * m / 60);
	double hy = a * sin(2.0 * PI * h / 12.0 + 2.0 * PI / 12.0 * m / 60);
	
	double mx = b * cos(2.0 * PI * m / 60.0);
	double my = b * sin(2.0 * PI * m / 60.0);

	// cout << hx << " " << hy << " " << mx << " " << my << endl;

	double ans = sqrtl(powl(hx - mx, 2) + powl(hy - my, 2));
	printf("%.15f", ans);

	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    int n;
    cin >> n;
    ll a[200002], b[200002];
    ll sum = 0;
    ll les = 10000000000000;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] > b[i]) les = min(les, b[i]);
        sum += a[i];
    }
    if(les == 10000000000000) cout << 0 << endl;
    else cout << sum - les << endl;
}

Measured memory_bytes: 2432
#include <cstdio>

int main() {
  int A, B, K;
  scanf("%d %d %d", &A, &B, &K);

  for (int i = 100; i > 0; --i)
    if (A % i == 0 && B % i == 0)
      if (--K == 0) return !printf("%d\n", i);
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int n;
	cin >> n;
	int cnt=0;
	for(int i=1; i<=n; i++){
		int a;
		cin >> a;
		if(i!=a) cnt++;
	}
	if(cnt==0 || cnt==2) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream> //53~70
using namespace std;

int main(){
	int a[1000];
	int b[1000];
	int t[1000];
	int n=0;
	int m=0;
	int i=0;
	int j=0;
	int k=0;
	
	cin>>n;
	cin>>m;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=0;i<m;i++){
		cin>>b[i];
	}
	for(i=0;i<1000;i++){
		t[i]=0;
	}
	for(i=0;i<m;i++){
		for(j=0;j<n;j++){
			if(b[i]>=a[j]){
				t[j]++;
				break;
			}
		}
	}
	for(i=0;i<n;i++){
		if(t[k]<t[i]){
			k=i;
		}
	}
	k++;
	cout<<k<<endl;
}

Measured memory_bytes: 3116
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
long long combi(long long n, long long k) {
  std::map<std::string, long long> memo;
  if (n == k || k == 0)
    return 1;
  else {
    std::string key = std::to_string(n) + std::to_string(k);
    if (memo.count(key) != 0) {
      return memo[key];
    } else {
      LL out = combi(n - 1, k - 1) + combi(n - 1, k);
      memo[key] = out;
      return out;
    }
  }
}
//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}


void solve(long long N, std::vector<long long> A){
    vector<LL> s;
    LL sum=0;
    REP(i, N){
        s.PB(A[i]+sum);
        sum+=A[i];
    }s.PB(0);
    SORT(s);
    map<LL,LL> m;
    REP(i, s.size()){
        m[s[i]]=0;
    }
    
    REP(i, s.size()){
        m[s[i]]++;
    }
    LL ans=0;
    REP(i, s.size()){
        if(m[s[i]]>=2){
            LL num=m[s[i]];
            ans+=num*(num-1)/2;
            m[s[i]]=0;
        }
    }cout<<ans<<endl;

}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 15856
numbers = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]

field = [[False for _ in range(3)] for _ in range(3)]
for x in b:
    for i in range(3):
        for j in range(3):
            if x == numbers[i][j]:
                field[i][j] = True

for i in range(3):
    bingo = True
    for j in range(3):
        bingo &= field[i][j]
    if bingo:
        print('Yes')
        exit()

for j in range(3):
    bingo = True
    for i in range(3):
        bingo &= field[i][j]
    if bingo:
        print('Yes')
        exit()

bingo = True
for i in range(3):
    bingo &= field[2-i][i]
if bingo:
    print('Yes')
    exit()
bingo = True
for i in range(3):
    bingo &= field[i][i]
if bingo:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
template <typename T> using posteriority_queue = priority_queue<T, vector<T>, greater<T> >;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
int popcount(int x) { return __builtin_popcount(x); }
int popcountll(ll x) { return __builtin_popcountll(x); }
template <typename T> void unique(vector<T> &a) { a.erase(unique(ALL(a)), a.end()); }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename T>
T lcs(const T &a, const T &b) {
  int a_sz = a.size(), b_sz = b.size();
  vector<vector<int> > dp(a_sz + 1, vector<int>(b_sz + 1, 0));
  REP(i, a_sz) REP(j, b_sz) {
    dp[i + 1][j + 1] = (a[i] == b[j] ? dp[i][j] + 1 : max(dp[i][j + 1], dp[i + 1][j]));
  }
  T res;
  while (a_sz > 0 && b_sz > 0) {
    if (dp[a_sz][b_sz] == dp[a_sz - 1][b_sz]) {
      --a_sz;
    } else if (dp[a_sz][b_sz] == dp[a_sz][b_sz - 1]) {
      --b_sz;
    } else {
      res.push_back(a[a_sz - 1]);
      --a_sz; --b_sz;
    }
  }
  reverse(ALL(res));
  return res;
}

int main() {
  string s, t; cin >> s >> t;
  cout << lcs(s, t) << '\n';
  return 0;
}


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

int main() {
  int N;
  cin >> N;
  char c;

  for (int i = 0; i < N; i++) {
	   cin >> c;
	   if (c == 'Y') {
		   cout << "Four";
		   return 0;
	   }
      // cout.put(c);
  }
  cout << "Three";
  return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
using namespace std;
#define REP(i,n) for(int i = 0; i < (int)n; i++)
#define FOR(i,a,b) for(int i = a; i < (int)b; i++)
#define pb push_back
#define mp make_pair
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef long long ll;
const int INF = 1<<28;
const ll MOD = 1000000007;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

void area(double bx, double by, double ux, double uy, bool b[201][201]) {
	FOR(i, bx, ux)
		FOR(j, by, uy)
			b[i][j] = true;
	return;
}

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

	int n, cnt = 1;
	while(cin >> n, n) {
		vector<double> x, y, bx, by, ux, uy;
		REP(i, n) {
			double x2, y2, r;
			cin >> x2 >> y2 >> r;
			x.pb(x2-r); x.pb(x2+r);
			y.pb(y2-r); y.pb(y2+r);
			bx.pb(x2-r); by.pb(y2-r);
			ux.pb(x2+r); uy.pb(y2+r);
		}
		sort(x.begin(), x.end());
		sort(y.begin(), y.end());

		x.erase(unique(x.begin(), x.end()), x.end());
		y.erase(unique(y.begin(), y.end()), y.end());

		REP(i, n) {
			bx[i] = find(x.begin(), x.end(), bx[i]) - x.begin();
			by[i] = find(y.begin(), y.end(), by[i]) - y.begin();
			ux[i] = find(x.begin(), x.end(), ux[i]) - x.begin();
			uy[i] = find(y.begin(), y.end(), uy[i]) - y.begin();
		}

		bool b[201][201] = {};
		REP(i, n)
			area(bx[i], by[i], ux[i], uy[i], b);

		double sum = 0;
		REP(i, x.size()) REP(j, y.size())
			if(b[i][j])
				sum += (x[i+1] - x[i]) * (y[j+1] - y[j]);

		cout << fixed << setprecision(2) << cnt << ' ' << sum << endl;

		cnt++;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

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

  vector<int> a;
  int cur = 0;
  int c = 1;
  rep(i, n) {
    if (s[i] == c + '0')
      ++cur;
    else {
      a.push_back(cur);
      cur = 1;
      c = 1 - c;
    }
  }
  a.push_back(cur);

  vector<int> sum(a.size() + 1);
  rep(i, a.size()) sum[i + 1] = sum[i] + a[i];

  int ans = 0;
  for (int i = 0; i < (int)a.size(); i += 2) {
    int last = min(i + 2 * k + 1, (int)sum.size() - 1);
    int now = sum[last] - sum[i];
    ans = max(ans, now);
  }

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


Measured memory_bytes: 4192
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

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

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <utility>
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    //cout<<setprecision(32);
    int n;
    cin >> n;
    cout << n*n*n << '\n';
}


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

void do_ex_2(int N) {
  for (int i = 0; i <= N / 4; i++) {
    for (int j = 0; j <= N/7; j++) {
      if (i * 4 + j * 7 == N) {
        cout << "Yes" << endl;
        return;
      }
    }
  }
  cout << "No" << endl;
}

int main(int, char**) {
  int N;
  cin >> N;
  do_ex_2(N);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string a,b;
    cin>>a;
    cin>>b;
        if(a[0]==b[2]&&a[2]==b[0]&&a[1]==b[1])
    {
     cout<<"YES";
    }
         else
     {
      cout<<"NO";
     }
}



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

// #include</home/edison/Coding/cpp/template/debug.cpp>

int spre[100005],tpre[100005];

int main(){
    string s,t; cin>>s>>t;
    for(int i=1;i<=s.size();++i)spre[i]=spre[i-1]+(s[i-1]=='A');
    for(int i=1;i<=t.size();++i)tpre[i]=tpre[i-1]+(t[i-1]=='A');
    auto csa=[&](int l,int r){ return spre[r]-spre[l-1]; };
    auto csb=[&](int l,int r){ return r-l+1-spre[r]+spre[l-1]; };
    auto cta=[&](int l,int r){ return tpre[r]-tpre[l-1]; };
    auto ctb=[&](int l,int r){ return r-l+1-tpre[r]+tpre[l-1]; };
    int q; cin>>q; while(q--){
        int a,b,c,d; cin>>a>>b>>c>>d;
        // PDE(csa(a,b),csb(a,b),cta(c,d),ctb(c,d));
        if((csa(a,b)+csb(a,b)*2)%3==(cta(c,d)+ctb(c,d)*2)%3)cout<<"YES"<<endl;
        else cout<<"NO"<<endl;
    }
}


Measured memory_bytes: 1664
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a1: u32 = read();
    let a2: u32 = read();
    let a3: u32 = read();

    if a1 + a2 + a3 >= 22 {
        println!("bust");
    } else {
        println!("win");
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s, t;
  cin >> s >> t;
  int sn = s.size(), tn = t.size();
  if (tn > sn) {
    cout << "UNRESTORABLE" << "\n";
    return 0;
  }
  for (int i = sn - tn; i >= 0; i--) {
    bool b = 1;
    for (int j = 0; j < tn; j++) {
      if (t[j] != s[i + j] && s[i + j] != '?') {
        b = 0;
        break;
      }
    }
    if (b) {
      for (int j = 0; j < tn; j++) s[i + j] = t[j];
      break;
    }
    if (i == 0) {
      cout << "UNRESTORABLE" << "\n";
      return 0;
    }
  }
  for (int i = 0; i < sn; i++) if (s[i] == '?') s[i] = 'a';
  cout << s << "\n";
  return 0;
}

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

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

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 10000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second

int main(int argc, char const *argv[]) {
    int n, d;
    cin >> n >> d;
    float x[n][d];

    REP(i, n)
    REP(j, d)
    cin >> x[i][j];

    int ans = 0;
    float dis;

    REP(i, n - 1)
    {
        FOR(j, i+1, n-1)
        {
            float tmp = 0;
            REP(k, d)
            {
                tmp += pow(x[i][k]-x[j][k], 2);
            }
            if (sqrt(tmp) == float(int(sqrt(tmp))))
                ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            new ABC129().SolveB(new ConsoleInput(Console.In, ' '));
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
  
  class ABC129
  {
  	public void SolveB(ConsoleInput cin)
        {
            var n = cin.ReadInt;
            var W = cin.ReadIntArray(n);
            var dif = new List<int>();
            for (int i = 1; i < n; i++)
            {
                var s1 = W.Skip(0).Take(i).ToArray();
                var s2 = W.Skip(i).Take(n - i).ToArray();
                dif.Add(Math.Abs(s1.Sum() - s2.Sum()));
            }
            WriteLine(dif.Min());
            ReadLine();
        }
  }
}


Measured memory_bytes: 13524
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n,arr[maxn],dp[maxn];
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)cin>>arr[i];
  dp[0]=0;dp[1]=arr[1]-arr[0];
  if(dp[1]<0)dp[1]*=-1;
  for(int i=2;i<n;i++)
  {
    int val1=arr[i]-arr[i-1];
    int val2=arr[i]-arr[i-2];
    if(val1<0)val1*=-1;
    if(val2<0)val2*=-1;
    dp[i]=min(dp[i-2]+val2,dp[i-1]+val1);
  }
  cout<<dp[n-1]<<endl;
  return 0;
}

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

int main(){
    int n,m; cin >> n >> m;
    vector<vector<char>> A(n,vector<char>(n)),B(m,vector<char>(m));
    rep(i,n){
        rep(j,n){
            cin >> A[i][j];
        }
    }
    rep(i,m){
        rep(j,m){
            cin >> B[i][j];
        }
    }
    bool flag = false;
    vector<vector<char>> C(m,vector<char>(m));

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

            for(int k = 0; k < m; k++){
                for(int l = 0 ; l < m; l++){
                    C[k][l] = A[k+i][l+j];
                }
            }
            flag = true;
            for(int k = 0; k < m; k++){
                for(int l = 0; l < m; l++){
                    if(B[k][l] == C[k][l]){
                        continue;
                    }else{
                        flag = false;
                        break;
                    }
                }
                if(!flag){
                    break;
                }   
            }
            if(flag){
                break;
            }
        }
        if(flag){
            break;
        }
    }

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

    
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){

int S;
int h=0, m=0, s=0;

scanf("%d",&S);

h=S/3600;
m=(S-h*3600)/60;
s=(S-h*3600-m*60);


printf("%d:%d:%d\n",h,m,s);

return 0;
}

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


int main(){
   
    long long N,M;
    long long a[200009];
    long long b[200009]={};
    long long ans;
    long long max=0,sec=0,cnt=0;

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

    for(int i = N; i >= 1; i--){
        if(i > N/2){
            b[i] = a[i];
        }else{
            for(int k = i; k <= N;k = k+i ){
                b[i] ^= b[k];
                //cout << i << endl;
            }
            if(a[i] == 1){
                b[i] ^= 1;
            }
        }
        if(b[i] == 1){
            cnt++;
        }
    }

    cout << cnt << endl;
    for(int i = 1; i <= N; i++){
        if(b[i] == 1){
            cout << i << " ";
        }
        
    }
    if(cnt != 0){
        cout << endl;
    }

   
    
    
    return 0;
}

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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

template<typename T>
vector<vector<T>> Make2DVector(int d1, int d2, T default_value) {
  return vector<vector<T>>(d1, vector<T>(d2, default_value));
}

template<typename T>
vector<vector<vector<T>>> Make3DVector(int d1, int d2, int d3, T default_value) {
  return vector<vector<vector<T>>>(d1, vector<vector<T>>(d2, vector<T>(d3, default_value)));
}

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

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

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

  constexpr int BASE = 12800;
  int h, w;
  cin >> h >> w;

  auto v1_table = Make2DVector(h, w, 0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> v1_table[y][x];
    }
  }
  auto v2_table = Make2DVector(h, w, 0);
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      cin >> v2_table[y][x];
    }
  }

  auto dp = Make3DVector<char>(h, w, 2 * BASE + 1, 0);
  dp[0][0][BASE + v1_table[0][0] - v2_table[0][0]] = 1;
  dp[0][0][BASE - v1_table[0][0] + v2_table[0][0]] = 1;
  for (int y = 0; y < h; y++) {
    for (int x = 0; x < w; x++) {
      if (y - 1 >= 0) {
        for (int k = 0; k <= 2 * BASE; k++) {
          if (dp[y - 1][x][k]) {
            dp[y][x][k + v1_table[y][x] - v2_table[y][x]] = 1;
            dp[y][x][k - v1_table[y][x] + v2_table[y][x]] = 1;
          }
        }
      }

      if (x - 1 >= 0) {
        for (int k = 0; k <= 2 * BASE; k++) {
          if (dp[y][x - 1][k]) {
            dp[y][x][k + v1_table[y][x] - v2_table[y][x]] = 1;
            dp[y][x][k - v1_table[y][x] + v2_table[y][x]] = 1;
          }
        }
      }
    }
  }

  int ans = INT32_MAX;
  for (int k = 0; k <= 2 * BASE; k++) {
    if (dp[h - 1][w - 1][k]) {
      UpdateMin(ans, abs(BASE - k));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 162560
n = int(input())
a = list(map(int,input().split()))
a1 = [i for i in a if i >= 0]
a2 = [i for i in a if i < 0]
if a1 and a2:
  print(sum(a1)-sum(a2))
  for i in range(len(a1)-1):
    print(a2[0],a1[i])
    a2[0] = a2[0] - a1[i]
  acur = a1[len(a1)-1] - a2[0]
  print(a1[len(a1)-1],a2[0])
  for i in range(1,len(a2)):
    print(acur,a2[i])
    acur = acur - a2[i]
elif a1:
  a1.sort()
  print(sum(a1)-2*a1[0])
  for i in range(1,n-1):
    print(a1[0],a1[i])
    a1[0] -= a1[i]
  print(a1[n-1],a1[0])
else:
  a2.sort()
  print(2*a2[n-1]-sum(a2))
  for i in range(n-1):
    print(a2[n-1],a2[i])
    a2[n-1] -= a2[i]

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

using namespace std;
using ll = long long;

const int MOD = 1e9 + 7;
#define REP(i, n)  for(int i = 0; i < n; ++i)
#define FOR(i, t, n)  for(ll i = t; i <= (ll)n; ++i)
struct edge {
    int from, to;
    ll cost;
};


class Eratosthenes {
public:
    vector<bool> prime;

    Eratosthenes(int size) {
        prime.resize(size + 1, 1);
        prime[0] = 0;
        prime[1] = 0;
        FOR(i, 2, size) {
            if (prime[i]) {
                for (int j = 2 * i; j <= size; j += i) {
                    prime[j] = 0;
                }
            }
        }
    }

};


class Combination {
    vector<ll> fac; //n!(mod M)
    vector<ll> ifac; //k!^{M-2} (mod M)
public:
    Combination(ll size) {
        fac.resize(size);
        ifac.resize(size);
        fac[0] = 1;
        ifac[0] = 1;
        for (ll i = 0; i < size; i++) {
            fac[i + 1] = fac[i] * (i + 1) % MOD;
            ifac[i + 1] = ifac[i] * mpow(i + 1, MOD - 2) % MOD;
        }
    }

    ll mpow(ll x, ll n) {
        ll ans = 1;
        while (n != 0) {
            if (n & 1) ans = ans * x % MOD;
            x = x * x % MOD;
            n = n >> 1;
        }
        return ans;
    }

    ll comb(ll a, ll b) {
        if (a == 0 && b == 0)return 1;
        if (a < b || a < 0)return 0;
        ll tmp = ifac[a - b] * ifac[b] % MOD;
        return tmp * fac[a] % MOD;
    }
};


ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

int N, C, K;

int main() {
    cin >> N;
    vector<int> A(N);
    REP(i, N)cin >> A[i];
    int res = 0;
    for (int i = 0; i < N;) {
        if (A[i] == A[i + 1]) {
            i++;
            continue;
        }
        res++;
        int x = A[i];
        bool b = A[i] < A[i + 1];
        while (i < N) {
            i++;
            if (b && x > A[i])break;
            if (!b && x < A[i])break;
            x = A[i];
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 640
/*<----------------------------------------------------------------------->

<-------------------------------------------------------------------------->
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
long const M=1e9+7;
const long mxN =1e5+2 ;
const long mxNN =1e6+2 ;
int a[mxNN] ;
void solve(){
    int k , n ; cin  >> k >> n ;
    For(i,n)
        cin >> a[i]  ;
    a[n]=a[0] ;
    int val = INT_MIN ;
    for(int i =1;i<n;i++){
        val=max(val,a[i]-a[i-1]) ;
    }
    val = max(val,k-a[n-1]+a[0]) ;
    pf(k-val) ;
    
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve() ;
    //ll t ; cin >> t ; while(t--)solve();
	return 0;
}


Measured memory_bytes: 1024
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
dir = [(-1,0),(0,-1),(1,0),(0,1)]
alp = "abcdefghijklmnopqrstuvwxyz"

#UnionFindのクラス
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return set([i for i in range(self.n) if self.find(i) == root])
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())
    def all_group_members(self):
        return [self.members(r) for r in self.roots()]
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


def main():
    n,m = map(int,ipt().split())
    p = [int(i)-1 for i in ipt().split()]
    uf = UnionFind(n)
    for i in range(m):
        x,y = map(int,ipt().split())
        uf.union(x-1,y-1)

    ans = 0
    for i in range(n):
        if uf.same(i,p[i]):
            ans += 1

    print(ans)

    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 92568
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using tp3 = tuple<int, int, int>;
using Mat = vector<vector<ll>>;
constexpr int INF = 1 << 28;
constexpr ll INFL = 1ll << 60;
constexpr int dh[4] = { 0,1,0,-1 };
constexpr int dw[4] = { -1,0,1,0 };
bool isin(const int H, const int W, const int h, const int w) {
    return 0 <= h && h < H && 0 <= w && w < W;
}
// ============ template finished ============

int main()
{
    ll N;
    cin >> N;
    vector<ll> A(N + 1);
    rep(i, N + 1)cin >> A[i];

    // exceptions
    if (N == 0) {
        if (A[0] == 1) {
            cout << 1 << endl;
        }
        else {
            cout << -1 << endl;
        }
        return 0;
    }
    else {
        if (A[0] != 0) {
            cout << -1 << endl;
            return 0;
        }
    }

    assert(N > 0 && A[0] == 0);

    constexpr ll LIM = 1e15;
    vector<ll> limits(N + 1);
    limits[0] = 1;
    REP(i, 1, N + 1) {
        limits[i] = limits[i - 1] * 2 - A[i];
        if (limits[i] < 0) {
            cout << -1 << endl;
            return 0;
        }
        if (limits[i] > LIM) {
            // should focus on overflow
            REP(j, i, N + 1)limits[j] = LIM;
            break;
        }
    }

    ll result = 0;
    ll node = 0;
    for (int depth = N; depth >= 1; depth--) {
        ll newleafs = A[depth];
        node += newleafs;
        result += node;
        node = min(node, limits[depth - 1]);
    }
    result += node;
    assert(node == 1);
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 4792
N, K = map(int, input().split())
MOD = 10**9 + 7

D = [[0]*(K+1) for i in range(N+1)]
D[0][0] = 1
for n in range(1, N+1):
    D0 = D[n-1]
    for k in range(1, K+1):
        D[n][k] = (D0[k-1] + k * D0[k]) % MOD
print(D[N][K])



Measured memory_bytes: 29212
#define  _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <math.h>
#include <time.h>
#include <fstream>
#include <list>
#include <climits>

using namespace std;

typedef long long int lld;
typedef long double ld;
typedef vector<int> vi;
typedef vector<lld> vlld;

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

	int mx = 0, now = 0;
	string str;

	cin >> str;

	for (int i = 0; i < 3; ++i)
	{
		if (str[i] == 'R')
			now++;
		else
			now = 0;

		mx = max(mx, now);
	}

	cout << mx << '\n';

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	int a,b,c; cin >> a >> b >> c;
	int ans = b/a;
	if (ans > c) ans = c;
	cout << ans << endl;
}


Measured memory_bytes: 256
/**************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

***************************/

#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define MAXI 1000000007
#define mp make_pair
using namespace std;
/*long long int fib(long long int n) 
{ 
  
  long long int f[n+2];   // 1 extra to handle case, n = 0 
  long long int i; 
  f[0] = 0; 
  f[1] = 1; 
  
  for (i = 2; i <= n; i++) 
  { 
      f[i] = f[i-1] + f[i-2]; 
  } 
  
  return f[n]; 
}*/ 
int main()
{   ll v=0,h=0,d,m,n,cnt=0,j=0,l=0,y=0,t,k=0,sum=1,x=0,i,mask,min,r=1,adv,g=0,low,high,yeah=0;
    string s1,s2,s3;
    map<char,long long int>mp;
    vector<long long int> v1;
    vector<long long int> v2;
    set<char> sy;
    char c;
    long long pos=0,pred=0;
    long long MAX=1e9+7;
    i=0;
    cin>>s1;
    if(s1[0]=='7'||s1[1]=='7'||s1[2]=='7'){cout<<"Yes";}
    else{cout<<"No";}
     return 0;   
    
}

Measured memory_bytes: 3612
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int f(int N){
    if(N<10)return N;
    return f(N/10)+N%10;
}
int main(){
    int N; R(N);
    if(N%f(N)==0)W("Yes");
    else W("No");
    return 0;
}


Measured memory_bytes: 764
//
//  main.cpp
//  F
//
//  Created by 曾憲揚 on 2020/8/12.
//  Copyright © 2020 曾憲揚. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;

int a[maxn];
vector<int> e[maxn];
//bool vis[maxn];
int dp[maxn];
int ans[maxn];

int bs(int l, int r, int t){
    //cout << "BS\n";
    if(dp[0] >= t) return 0;
    if(dp[r] < t) return r+1;
    
    while(r > l){
        //cout << l << r << endl;
        int m = (l+r)/2;
        if(dp[m] < t) l=m+1;
        else r = m;
    }
    
    //cout << "BS" << r << endl;
    return r;
}

void dfs(int p, int cur, int r){
    //cout << p << " " << cur << " " << r << " " << a[cur] << '\n';
    int pos = bs(0, r, a[cur]);
    
    int reg = dp[pos];
    dp[pos] = a[cur];
    
    ans[cur] = pos== (r+1) ? ++r + 1: r + 1;
    for(int i: e[cur]){
        if(i!=p) dfs(cur, i, r);
    }
    dp[pos] = reg;
}

int main(int argc, const char * argv[]) {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //memset(vis, 0, sizeof(vis));
    
    int n; cin >> n;
    fill(dp, dp+n+1, 2e9);
    
    for(int i=0; i<n; i++)
        cin >> a[i];
    for(int i=1; i<n ; i++){
        int u, v; cin >> u >> v;
        u--; v--;
        e[u].push_back(v); e[v].push_back(u);
    }
    dfs(0, 0, 0);
    for(int i=0; i<n; i++){
        cout << ans[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 31200
import sys
sys.setrecursionlimit(100000)

N, K = map(int, input().split())
V = list(map(int, input().split())) # N


ans = 0
for i in range(K+1):
  hand = V[:i]
  for j in range(K-i+1):
    if j != 0:
      x = hand + V[max(N-j, i):]
    else:
      x = hand
    rest = K - i - j
    summ = sum(v for i, v in enumerate(sorted(x)) if i >= rest or v > 0)
    ans = max(ans, summ)
    # print(f"K={K}, i={i}, j={j}, rest={rest}, sum={summ}, x={x}")
print(ans)



Measured memory_bytes: 3064
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<climits>//long long型の最大値(LLONG_MAX)など
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;
typedef long double ld;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)


int main() {
   string S;
   cin >> S;
   ll sizeS = S.size();
   ll ans = 0;
   rep(i,sizeS){
       ans += (S[i] - '0');
   }

    if(ans%9 == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
   
}




Measured memory_bytes: 3744