akhauriyash/Code-Regression huggingface dataset:
//package solution;

import java.io.*;
import java.util.*;
import java.math.*;
import java.awt.Point;

public final class Main {
    BufferedReader br;
    StringTokenizer stk;

    public static void main(String[] args) throws Exception {
        new Main().run();
    }
    
    {
        stk = null;
        br = new BufferedReader(new InputStreamReader(System.in));
    }
    
    void run() throws Exception {
        int n = ni(), w = ni();
        long[][] wv = new long[n+1][];
        wv[0] = new long[] {0, 0};
        for(int i=1; i<wv.length; i++) {
            wv[i] = new long[] {ni(), ni()};
        }
        long[][] dp = new long[n + 1][w + 1];
        
        for(int i=1; i<=n; i++) {
            for(int j=1; j<dp[0].length; j++) {
                if(wv[i][0] > j) {
                    dp[i][j] = dp[i-1][j];
                } else {
                    dp[i][j] = Math.max(dp[i-1][j], dp[i-1][j-(int)wv[i][0]] + wv[i][1]);
                }
            }
        }
        
        pl(dp[dp.length - 1][dp[0].length - 1]);
    }
    
    //Reader & Writer
    String nextToken() throws Exception {
        if (stk == null || !stk.hasMoreTokens()) {
            stk = new StringTokenizer(br.readLine(), " ");
        }
        return stk.nextToken();
    }

    String nt() throws Exception {
        return nextToken();
    }

    String ns() throws Exception {
        return br.readLine();
    }

    int ni() throws Exception {
        return Integer.parseInt(nextToken());
    }

    long nl() throws Exception {
        return Long.parseLong(nextToken());
    }

    double nd() throws Exception {
        return Double.parseDouble(nextToken());
    }

    void p(Object o) {
        System.out.print(o);
    }

    void pl(Object o) {
        System.out.println(o);
    }
    
    void selector() {
        Random rd = new Random();
        String[] s = new String[] {"Strings", "Sorting", "Search"
                , "Graph theory", "Greedy", "Dynamic programming"
                , "Constructive algos", "Bit manipulation", "Recursion"};
        pl(s[rd.nextInt(s.length)] + " " + (rd.nextInt(5)+1));
    }
}

Measured memory_bytes: 126544
// -*- coding:utf-8-unix -*-

use proconio::input;

fn main() {
    input! {
        s: String,
    }

    let vc: Vec<char> = s.chars().collect();
    let mut ans = 0;
    for i in 1..vc.len() {
        if vc[i] != vc[i - 1] {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2612
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

void solve() {
	int n, y, d;
    while(cin >> n >> y >> d) {
        if(n == 0 && y == 0 && d == 0) break;
        vector<P> ps;
        ps.push_back({y, d});
        rep(i, n) {
            int p, s; cin >> p >> s;
            --p;
            int t = ps[p].fr, w = ps[p].sc;
            ps.erase(ps.begin() + p);
            int cn = s % (2 * (t + w));
            //cerr << cn << endl;
            if(0 < cn && cn < t) {
                int t1 = max(t - cn, cn), t2 = min(t - cn, cn);
                ps.push_back({t2, w});
                ps.push_back({t1, w});
            } else if(t < cn && cn < t + w) {
                int w1 = max(cn - t, t + w - cn), w2 = min(cn - t, t + w - cn);
                ps.push_back({t, w2});
                ps.push_back({t, w1});
            } else if(t + w < cn && cn < t + w + t) {
                int t1 = max(cn - t - w, 2 * t + w - cn), t2 = min(cn - t - w, 2 * t + w - cn);
                ps.push_back({t2, w});
                ps.push_back({t1, w});
            } else {
                //cerr << cn - 2 * t - w << endl;
                int w1 = max(cn - 2 * t - w, 2 * t + 2 * w - cn), w2 = min(cn - 2 * t - w, 2 * t + 2 * w - cn);
                //cerr << w1 << " " << w2 << endl;
                ps.push_back({t, w2});
                ps.push_back({t, w1});
            }
        }
        sort(all(ps), [&](P a, P b){ return a.fr * a.sc < b.fr * b.sc; });
        cout << ps[0].fr * ps[0].sc;
        for(int i = 1; i < (int)ps.size(); ++i) {
            cout << " " << ps[i].fr * ps[i].sc;
        }
        cout << endl;
    }
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}


Measured memory_bytes: 3028
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
from fractions import gcd
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n,m = inpm()
a = list(reversed(sorted(inpl())))
s = sum(a)

ans = "Yes"
for i in range(m):
    if a[i] < s/4/m:
        ans = "No"

print(ans)

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

string S, T;
char A[105], B[105];

int main(){
  cin >> S >> T;
  int N = S.length(), M = T.length();
  for (int i = 0; i < N; i++) A[i] = S[i];
  for (int i = 0; i < M; i++) B[i] = T[i];

  sort(A, A + N);
  sort(B, B + M, greater<char>());

  string a = "", b = "";
  for (int i = 0; i < N; i++) a += A[i];
  for (int i = 0; i < M; i++) b += B[i];

  if (a < b) Yes();
  else No();

  return 0;
}


Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,k,max,ansa,ansb;
string s;
cin >> s;
//cout << s <<endl;
n=s.size();
ansa=0;
ansb=0;
for(i=0;i<n;i++)
{
if((i%2==0&&s.at(i)=='0')||(i%2==1&&s.at(i)=='1'))
{
ansa++;
}
else
{
ansb++;
}
}
if(ansa>ansb)
{
k=ansb;
}
else
{
k=ansa;
}
cout <<k<< endl;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0;true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}



//ここまでライブラリ
//ここから本文
//周りはみんなおとなになってます


int main() {
	int a,b,c;
	cin >> a >> b;
	cout << max(a + b, max(a - b, a * b)) << endl;

	

}


Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
A = [1] * N
for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    if H[a] <= H[b]:
        A[a] = 0
    if H[b] <= H[a]:
        A[b] = 0
print(A.count(1))


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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<vector<char>> A(N);
  rep(i, N) {
    A[i].resize(N);
    rep(j, N) {
      cin >> A[i][j];
    }
  }

  vector<vector<char>> B(M);
  rep(i, M) {
    B[i].resize(M);
    rep(j, M) {
      cin >> B[i][j];
    }
  }

  rep(i, N) {
    rep(j, N) {
      bool match = true;
      rep(y, M) {
          if (i + y >= N) {
            match = false;
            break;
          }
        rep(x, M) {
          if (j + x >= N) {
            match = false;
            break;
          }

          if (A[i+y][j+x] != B[y][x]) {
            match = false;
            break;
          }
        }
      }

      if (match) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())

    A = [int(i) for i in input().split()]

    total_A = sum(A)

    ans = N - total_A

    if ans >= 0:
        print('{}'.format(ans))
    else:
        print('{}'.format(-1))



if __name__ == '__main__':
    main()

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

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


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

typedef long long ll;
const ll mod = 1e9+7;
const ll lim = 1e5+5;
ll n,k;
ll arr[102];
ll dp[102][lim];

ll solve(ll pos,ll k)
{
	ll ub = k;
	ll lb = max(0LL,k-arr[pos]);
	ll ans = dp[pos+1][ub];
	if(lb>0LL)
		ans -= dp[pos+1][lb-1];
	return (ans%mod+mod)%mod;
}

int main()
{
	cin>>n>>k;
	for(ll i=0;i<n;++i)
		cin>>arr[i];
	if(n==1)
	{
	    cout<<(arr[0]==k);
	    return 0;
	}
	memset(dp,0,sizeof dp);

	for(ll i=n-1;i>=0;--i)
		for(ll j=0;j<=k;++j)
		{
			if(j==0)
				dp[i][j] = 1;
			else if(i==n-1)
			{
				dp[i][j] += dp[i][j-1];
				if(j<=arr[i])
					dp[i][j] += 1;
				dp[i][j] %= mod;
			}
			else
				dp[i][j] = (dp[i][j-1]%mod + solve(i,j)%mod + mod)%mod;
		}

	cout<<solve(0,k);
	return 0;	
}

Measured memory_bytes: 80000
#include<stdio.h>
#define MAX 100
#define INFTY 1000000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n,M[MAX][MAX];

void dijkstra(){
    int minv,i,u,v;
    int d[MAX],color[MAX];

    for(i = 0; i < n; i++){
        d[i] = INFTY;
        color[i] = WHITE;
    }

    d[0] = 0;
    color[0] = GRAY;
    while(1){
        minv = INFTY;
        u = -1;
        for(i = 0;i < n; i++){
            if(minv > d[i] && color[i] != BLACK){
                u = i;
                minv = d[i];
            }
        }
        if(u == -1) break;
        color[u] = BLACK;
        for(v = 0; v < n; v++){
            if(color[v] != BLACK && M[u][v] != INFTY){
                if(d[v] > d[u] + M[u][v]){
                    d[v] = d[u] + M[u][v];
                    color[v] = GRAY;
                }
            }
        }
    }
    for(i = 0; i < n; i++){
        printf("%d %d\n",i,d[i] == INFTY ? -1 : d[i]);
        //
    }
}

int main(){
    int i,j;
    int k,c,u,v;
    scanf("%d",&n);
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            M[i][j] = INFTY;
        }
    }

    for( i = 0; i < n; i++){
        scanf("%d%d",&u,&k);
        for(j = 0; j < k; j++){
            scanf("%d%d",&v,&c);
            M[u][v] = c;
        }
    }

    dijkstra();

    return 0;
}


Measured memory_bytes: 2112
N = int(input())
A = list(map(int,input().split()))

print(*A)
for i in range(1,N):
    v = A[i]
    j = i - 1
    while j >= 0 and A [j] > v :
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = v
    print(*A)

Measured memory_bytes: 5980
#include <bits/stdc++.h>
using namespace std;
 
using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;
 
#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
 
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
 
int dx[] = {-1,0,1,0};
int dy[] = {0,-1,0,1};
 
int H, W;
 
int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
 while(
  cin >> W >> H,W){
  int N;
  cin >> N;
  vector<pair<PII,PII>> ps(N);
  {
	set<int> xs, ys;
	REP(i,N){
	  cin >> ps[i].FF >> ps[i].SS;
	  
	  FOR(d,-1,1){
		if(0 <= ps[i].FF.FF+d && ps[i].FF.FF+d <= W)
		  xs.insert(ps[i].FF.FF + d);
		if(0 <= ps[i].FF.SS+d && ps[i].FF.SS+d <= H)
		  ys.insert(ps[i].FF.SS + d);
	  }
	  FOR(d,0,2){
		if(0 <= ps[i].SS.FF+d && ps[i].SS.FF+d <= W)
		  xs.insert(ps[i].SS.FF + d);
		if(0 <= ps[i].SS.SS+d && ps[i].SS.SS+d <= H)
		  ys.insert(ps[i].SS.SS + d);
	  }
	}
	
	xs.insert(0);
	xs.insert(W-1);
	xs.insert(W);
	ys.insert(0);
	ys.insert(H-1);
	ys.insert(H);
	
  
	map<int,int> xs2ix, ys2ix;
	int it = 0;
	for(int x: xs){
	  xs2ix[x] = it++;
	}
	it = 0;
	for(int y: ys){
	  ys2ix[y] = it++;
	}
 
	W = SZ(xs);
	H = SZ(ys);
	for(auto& p: ps){
	  p.FF.FF = xs2ix[p.FF.FF];
	  p.SS.FF = xs2ix[p.SS.FF];
	  p.FF.SS = ys2ix[p.FF.SS];
	  p.SS.SS = ys2ix[p.SS.SS];
	}
  }
 
  vector<vector<short>> acc(H+1, vector<short>(W+1));
  for(auto& p: ps){
	acc[p.FF.SS][p.FF.FF]++;
	acc[p.SS.SS][p.SS.FF]++;
	acc[p.FF.SS][p.SS.FF]--;
	acc[p.SS.SS][p.FF.FF]--;
  }
 
  REP(y,H+1) REP(x,W+1){
	acc[y][x] += (y>0? acc[y-1][x]: 0) + (x>0? acc[y][x-1]: 0) - (y>0&&x>0?acc[y-1][x-1]: 0);
  }
 
  int ans = 0;
  REP(y,H-1) REP(x,W-1){
	if(!acc[y][x]){
	  ++ans;
 
	  queue<PII> q;
	  q.push(MP(x,y));
	  while(!q.empty()){
		PII p = q.front();
		q.pop();
		REP(d,4){
		  PII np(p.FF + dx[d], p.SS + dy[d]);
		  if(np.FF < 0 || W-1 <= np.FF || np.SS < 0 || H-1 <= np.SS) continue;
		  if(!acc[np.SS][np.FF]){
			acc[np.SS][np.FF] = 1;
			q.push(np);
		  }
		}
	  }
	}
  }
  cout << ans << endl;
 }
  return 0;
}

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

int main() {
	int N;
	int M;
	cin >> N; //city
	cin >> M; //road

	vector<int> vec(N);
	for (int i; i < M; i++) {
		int a;
		cin >> a;
		vec.at(a-1) += 1;
		int b;
		cin >> b;
		vec.at(b-1) += 1;
	}

	for (int i; i < N; i++) {
		cout << vec.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int value[100], weight[100], dp[110][10010];
int N, W;
int main()
{
    cin >> N >> W;
    for (int i = 0; i < N; i++)
    {
        cin >> value[i] >> weight[i];
    }
    //初期条件
    for (int w = 0; w <= W; w++)
    {
        dp[0][w] = 0;
    }
    for (int j = 0; j < N; j++)
    {                                //weight
        for (int w = 0; w <= W; w++) //w=Wを含み、初期値w=0も含む
        {                            //component index
            if (w >= weight[j])//入りそう(=含む)
            {
                dp[j + 1][w] = max(dp[j][w - weight[j]] + value[j], dp[j][w]);
            }
            else
            {
                dp[j + 1][w] = dp[j][w];
            }
        }
    }

    cout << dp[N][W] << endl; //行列はN*W

    return 0;
}

/*
漸化式
dp[i+1][w]=
    (w>weight[i])
    dp[i][w-weight[i]]+value[i] or dp[i][w]
    (w>=weight[i])
    dp[i][w]
*/


Measured memory_bytes: 7032
/* ABC146-B
   Takatan */

#include<stdio.h>
#include<string.h>
int main(void){
    int number, length, i;
    char string[10001];

    scanf( "%d %s" , &number, string);
    length = strlen(string);

    for(i=0; i < length; i++){
        if(string[i]+number > 'Z'){
            string[i] += number - 'Z' + 'A' - 1;
        }else{
            string[i] += number;
        }
    }

    printf( "%s\n" , string);
    return 0;
}

Measured memory_bytes: 128
// ABC075
// A - One out of Three
#include<bits/stdc++.h>

using namespace std;

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


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

int main(){
	string s,t;
	cin>>s>>t;
	string ds=s+s;
	vector<vector<int>> abc(26);
	for (int i = 0; i < ds.length(); i++) {
		abc[ds[i]-'a'].push_back(i);
	}
	for (int i = 0; i < 26; i++) {
		sort(abc[i].begin(),abc[i].end());
	}
	//now:今のsでの添字
	int now=-1;
	long long int ans=0;
	for (int i = 0; i < t.length(); i++) {
		//vector<int> temp=abc[t[i]-'a'];
		auto itr=lower_bound(abc[t[i]-'a'].begin(),abc[t[i]-'a'].end(),now+1);
		if (itr!=abc[t[i]-'a'].end()) {
			ans+=*itr-now;
			now=*itr%s.length();
		}else {
			cout<<-1<<endl;
			return 0;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1980
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	//freopen("input.txt","r",stdin);
#endif

	int n,m,k;
	cin>>n>>m>>k;
	vector<vector<int> > a(n,vector<int>(m,0));
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			char x;
			cin>>x;
			if(x=='.')
				a[i][j]=0;
			else
				a[i][j]=1;
		}
	}

	ll count=0;

	ll x=pow(2,n)-1;
	ll y=pow(2,m)-1;

	for(int i=x;i>=0;i--)
	{
		vector<vector<int> > temp(n,vector<int>(m));
		temp=a;

		for(int k=0;k<n;k++)
		{
			if(i&(1<<k))
			{
				for(int l=0;l<m;l++)
				{
					temp[k][l]=0;
				}
			}
		}


		for(int j=y;j>=0;j--)
		{

			vector<vector<int> > temp1(n,vector<int>(m));

			temp1=temp;

			for(int k=0;k<m;k++)
		    {
			if(j&(1<<k))
			{
				for(int l=0;l<n;l++)
				{
					temp1[l][k]=0;
				}
			}
		  
		    }

		    int tt=0;

		   for(int k=0;k<n;k++)
		   {
		   	for(int l=0;l<m;l++)
		   	{
		   		if(temp1[k][l])
		   			tt++;
		   	}
		   }

		   if(tt==k)
		   	count++;


		}
	}


	cout<<count<<endl;


	return 0;
}

Measured memory_bytes: 4064
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int v[70];
  for(int i=0; i<n; i++){
    cin >> v[i];
  }
  sort(v, v+n);
  double ans = v[0];
  for(int i=0; i<n-1; i++){
    ans = (ans + v[i+1]) / 2;
  }
  cout << ans << endl;
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    ll sum = 0;
    for(i = 0;i < n;++i){
        cin >> a.at(i);
        sum += a.at(i);
    }
    ll supy = sqrt(sum);
    set<ll> b;
    for(i = 1;i <= supy+1;++i){
        if(sum%i == 0){
            b.insert(i);
            b.insert(sum/i);
        }
    }
    vector<ll> betsu;
    for(auto x:b){
        betsu.push_back(x);
    }
    for(i = betsu.size()-1;i >= 1;--i){
        ll x = betsu.at(i);
        vector<ll> tasu(n);
        vector<ll> lower(n);
        ll tmp = 0;
        rep(j,n){
            if(a.at(j)%x == 0){
                tasu.at(j) = 0;
                lower.at(j) = a.at(j);
                tmp += lower.at(j);
            }else{
                ll spare = a.at(j)%x;
                tasu.at(j) = x - spare;
                lower.at(j) = a.at(j) - spare;
                tmp += lower.at(j);
            }
        }
        ll need = (sum - tmp)/x;
        sort(all(tasu));
        ll nokori = 0;
        ll cnt = 0;
        rep(j,n){
            if(nokori == need) break;
            if(tasu.at(j) == 0) continue;
            else{
                ++nokori;
                cnt += tasu.at(j);
            }
        }
        if(cnt <= k){
            cout << x << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3704
N,M = map(int,input().split())
A = list()
B = list()
for i in range(N):
  A.append(input())
for i in range(M):
  B.append(input())
def check(posx, posy):
  for y in range(M):
    for x in range(M):
      if not B[y][x] == A[y + posy][x + posx]:
        return False
  return True
for y in range(N - M + 1):
  for x in range(N - M + 1):
    if check(x,y):
      print("Yes")
      exit()
print("No")

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

typedef long long LL;
typedef pair<int,int> PII;
typedef vector<int> VI;

const int INF = 1000000009;

char text[10];

int main(){
    scanf("%s", text+1);
    puts((text[3] == text[4] && text[5]==text[6]) ? "Yes" : "No");
    
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  static final int MOD = 1000000000 + 7;

  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    String[] strings = scanner.nextLine().split(" ");
    int H = Integer.parseInt(strings[0]);
    int W = Integer.parseInt(strings[1]);
    String[] str = new String[H];
    for (int i = 0; i < H; i++) {
      str[i] = scanner.nextLine();
    }
    System.out.println(solve(str, H, W));
  }

  private static int solve(String[] str, int h, int w) {
    int[][] dp = new int[h][w];
    dp[0][0] = 1;
    for (int i = 1; i < w; i++) {
      if (str[0].charAt(i) == '#') {
        break;
      }
      dp[0][i] = dp[0][i - 1];
    }
    for (int i = 1; i < h; i++) {
      if (str[i].charAt(0) == '#') {
        break;
      }
      dp[i][0] = dp[i - 1][0];
    }

    for (int i = 1; i < h; i++) {
      for (int j = 1; j < w; j++) {
        if (str[i].charAt(j) != '#' && (dp[i - 1][j] != 0 || dp[i][j - 1] != 0)) {
          dp[i][j] = (dp[i - 1][j] % MOD + dp[i][j - 1] % MOD) % MOD;
        }
      }
    }
    return dp[h - 1][w - 1];
  }
}


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

ll f(ll n){
  if(n==0){
    return 0;
  }
  bitset<20> a(n);
  ll i,k=0;
  for(i=0;i<20;i++){
    if(a.test(i)){
      k++;
    }
  }
  return f(n%k)+1;
}

int main(){
  ll n,i,m=0,m1,m0;
  string s;
  cin >> n >> s;
  
  for(i=0;i<n;i++){
    m += s.at(i)-'0';
  }
  
  if(m==0){
    for(i=0;i<n;i++){
      cout << 1 << endl;
    }
    return 0;
  }
  
  if(m==1){
    for(i=0;i<n;i++){
      if(s.at(i)=='1'){
        cout << 0 << endl;
      }else{
        if(i!=n-1){
          cout << (s.at(n-1)-'0')+1 << endl;
        }else{
          cout << 2 << endl;
        }
      }
    }
    return 0;
  }
  
  m1=m+1;
  m0=m-1;
  
  vector<int> p1(n),p0(n);
  p1.at(0)=1%m1;
  p0.at(0)=1%m0;
  for(i=1;i<n;i++){
    p1.at(i)=(p1.at(i-1)*2)%m1;
    p0.at(i)=(p0.at(i-1)*2)%m0;
  }
  ll s1=0,s0=0;
  for(i=0;i<n;i++){
    s1=(s1+p1.at(i)*(s.at(n-1-i)-'0'))%m1;
    s0=(s0+p0.at(i)*(s.at(n-1-i)-'0'))%m0;
  }
  
  for(i=0;i<n;i++){
    if(s.at(i)=='0'){
      ll X=(s1+p1.at(n-1-i))%m1;
      cout << f(X)+1 << endl;
    }else{
      ll X=(s0-p0.at(n-1-i))%m0;
      if(X<0){
        X += m0;
      }
      cout << f(X)+1 << endl;
    }
  }
}

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

int noi(int *N,int *D)
{
  int val=2*(*D)+1;
  float num=(*N)/val;

  if((val*num)==*N)
    return num;
  else
    return num+1;

}

int main()
{
    int N;
    int D;
    scanf("%d %d",&N,&D);
    printf("%d",noi(&N,&D));
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <cstdio>
#include <cstdlib>
#include <string>

struct Node{
    int key;
    Node *parent, *left, *right;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x  = root; // root of T

    Node *z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        } else x = x->right;
    }
    z->parent = y;

    if(y == NIL){
        root = z;
    } else if(z->key < y->key){
        y->left = z;
    } else {
        y->right = z;
    }
}
Node* find(Node *x, int k){
    while(x != NIL && k != x->key){
        if(k < x->key){
            x = x->left;
        } else {
            x = x->right;
        }
    }
    return x;
}
Node* treeMinimum(Node *x){
    while(x->left != NIL) x = x->left;
    return x;
}
Node* getSuccessor(Node *x){
    if(x->right != NIL) return treeMinimum(x->right);
    Node *y = x->parent;
    while(y != NIL && x == y->right){
        x = y;
        y = y->parent;
    }
    return y;
}
void treeDelete(Node *z){
    Node *x;
    Node *y;
    if(z->left == NIL || z->right == NIL){
        y = z;;
    }
    else {
        y = getSuccessor(z);
    }
    if(y->left != NIL){
        x = y->left;
    } else {
        x = y->right;
    }

    if(x != NIL){
        x->parent = y->parent;
    }

    if(y->parent == NIL){
        root = x;
    } else if(y == y->parent->left){
        y->parent->left = x;
    } else{
        y->parent->right = x;
    }
    
    if(y != z){
        z->key = y->key;
    }
    free(y);
}
void inorder(Node *u){
    if( u == NIL) return;
    inorder(u->left);
    printf(" %d", u->key);
    inorder(u->right);
}
void preorder(Node *u){
    if(u == NIL) return;
    printf(" %d", u->key);
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n, i, x;
    string com;

    scanf("%d", &n);
    for(i=0; i<n; i++){
        cin >> com;
        if(com == "insert"){
            scanf("%d", &x);
            insert(x);
        } else if(com == "print"){
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        } else if(com == "find"){
            scanf("%d", &x);
            Node *z = find(root, x);
            if(z == NIL){
                printf("no\n");
            } else {
                printf("yes\n");
            }
        } else if(com == "delete"){
            scanf("%d", &x);
            Node *z = find(root, x);
            treeDelete(z);
        }
    }

    return 0;
}


Measured memory_bytes: 22044
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;

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

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

int main()
{
    int n,d,x,a,ans;
    cin >> n >> d >> x;
    ans = x;
    rep(i, n){
        cin >> a;
        ans += (d - 1) / a + 1;
    }
    cout << ans << 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();
    String T_ = sc.next();

    sc.close();

    Set<String> treeSet = new TreeSet<String>();

    String[] s = s_.split("");
    String[] T = T_.split("");
    
    for (int i = 0; i < s.length; i++) {
      if (s[i].equals(T[0]) || s[i].equals("?")) {
        int k = 0;
        for (int j = i; j < s.length; j++) {
          if (s[j].equals(T[k]) || s[j].equals("?")) {
            s[j] = T[k];
            if (k == T.length - 1) {          
              String str_ = "";
              for (int l = 0; l < s.length; l++) {
                if (s[l].equals("?")) {
                  s[l] = "a";
                }
                str_ += s[l];
              }
              treeSet.add(str_);
              s = s_.split("");
              j = s.length;
            } else {
              k++;
            }
          } else {
            s = s_.split("");
            j = s.length;
          }
        }
      }
    }

    if (treeSet.size() == 0) {
      System.out.println("UNRESTORABLE");
    } else {
      for(String value : treeSet) {
        System.out.println(value);
        break;
      }
    }

  }

}

Measured memory_bytes: 23508
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
#include<unordered_map>
using namespace std ;

#define MAXN 200007

int n , k ;
int a[ MAXN ] ;
long long pref[ MAXN ] ;

pair < long long , int > srt[ MAXN ] ;

class Tree {
public :
    int tr[ 5 * MAXN ] ;
    void init ( int where , int IL , int IR ) {
        tr[ where ] = 0 ;
        if ( IL == IR ) { return ; }
        int mid = ( IL + IR ) / 2 ;
        init ( 2 * where , IL , mid ) ;
        init ( 2 * where + 1 , mid + 1 , IR ) ;
    }
    void update ( int where , int IL , int IR , int pos ) {
        if ( IR < pos || pos < IL ) { return ; }
        ++ tr[ where ] ;
        if ( IL == IR ) { return ; }
        int mid = ( IL + IR ) / 2 ;
        if ( pos <= mid ) {
            update ( 2 * where , IL , mid , pos ) ;
        }
        else {
            update ( 2 * where + 1 , mid + 1 , IR , pos ) ;
        }
    }
    int query ( int where , int IL , int IR , int CURL , int CURR ) {
        if ( CURL > CURR ) { return 0 ; }
        if ( CURR < IL || IR < CURL ) { return 0 ; }
        if ( CURL <= IL && IR <= CURR ) {
            return tr[ where ] ;
        }
        int mid = ( IL + IR ) / 2 ;
        return ( query ( 2 * where , IL , mid , CURL , CURR ) + query ( 2 * where + 1 , mid + 1 , IR , CURL , CURR ) ) ;
    }
};
Tree w ;

void input ( ) {
    scanf ( "%d%d" , &n , &k ) ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        scanf ( "%d" , &a[ i ] ) ;
        pref[ i ] = ( pref[ i - 1 ] + a[ i ] - k ) ;
    }
}

void solve ( ) {
    for ( int i = 0 ; i <= n ; ++ i ) {
        srt[ i ] = { pref[ i ] , i } ;
    }
    sort ( srt , srt + n + 1 ) ;
    w.init ( 1 , 0 , n ) ;
    long long ans = 0 ;
    for ( int i = 0 ; i <= n ; ++ i ) {
        ans += w.query ( 1 , 0 , n , 0 , srt[ i ].second ) ;
        w.update ( 1 , 0 , n , srt[ i ].second ) ;
    }
    printf ( "%lld\n" , ans ) ;
}


int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 9600
def countbomb(i,j):
    bomb = 0
    for y in range(i-1,i+2):
        for x in range(j-1,j+2):
            if a[y][x] == '#':
                bomb += 1
    return bomb      
            
h, w = list(map(int, input().split()))
a = [['w']*(w+2) for _ in range(h+2)]
for i in range(1,h+1):
    si = list(input())
    a[i][1:w+1] = si
#print(*a, sep='\n')
for i in range(1,h+1):
    for j in range(1,w+1):
        if a[i][j] != '.':
            continue
        cnt = countbomb(i,j)
        a[i][j] = cnt
for i in range(1,h+1):
    si = a[i][1:w+1]
    print(''.join(map(str,si)))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}
		int[] b = new int[n];
		for(int i = 0; i < n; i++){
			b[i] = sc.nextInt();
		}
		int[] c = new int[n - 1];
		for(int i = 0; i < n - 1; i++){
			c[i] = sc.nextInt();
		}
		int sum = 0;
		int before = -10;
		for(int i = 0; i < n; i++){
			int num = a[i] - 1;
			sum += b[num];
			if(before == num - 1){
				sum += c[num - 1];
			}
			before = num;
		}
		System.out.println(sum);
	}
}


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

use std::cmp::{self, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{self, Debug, Display};
use std::io::{self, Read};
use std::str::{self, FromStr};


fn solve(n_: u64) -> String {
    for h in 1..3051 {
        for n in 1..3051 {
            let numer = n_ * h * n;
            let denom = 4 * h * n - n_ * (h + n);
            if denom > 0 && numer % denom == 0 {
                let w = numer / denom;
                return format!("{} {} {}", h, n, w);
            }
        }
    }
    panic!()
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next()))
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
// typedef
using ll  = long long;
using str = string;
using PL  = pair<ll, ll>;
using P   = pair<int, int>;
using VL  = vector<ll>;
using VI  = vector<int>;
using VS  = vector<str>;
using VP  = vector<P>;
using VPL = vector<PL>;
using VVL = vector<VL>;
using VVI = vector<VI>;

// const num
const ll INF         = 1e18 + 18;
const ll MAX         = 100005;
const ll MOD         = 1000000007;
const long double PI = acosl(-1.0);

// loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

// YesNo
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
// All
#define ALL(v) v.begin(), v.end()
#define deduplicate(v) (v).erase(unique(ALL(d)), (v).end())

int main(void) {
	int n;
	bool ans = false;
	cin >> n;
	VVI d(n, VI(2));
	rep(i, n) {
		cin >> d[i][0] >> d[i][1];
	}
	rep(i, n - 2) {
		if(d[i][0] == d[i][1] && d[i + 1][0] == d[i + 1][1]
		   && d[i + 2][0] == d[i + 2][1]) {
			ans = true;
		}
	}
	cout << ((ans) ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3592
MOD = 998244353
N,M,K = gets.split.map &:to_i

fact = [1]
fact_inv = [1]
1.upto(N) do |i|
    fact[i] = i*fact[i-1] % MOD
    inv = i.pow(MOD-2, MOD)
    fact_inv[i] = inv*fact_inv[i-1] % MOD
end

ans = 0
0.upto(K) do |i|
    comb = fact[N-1] * fact_inv[N-1-i] * fact_inv[i] % MOD

    ans += comb * M * (M-1).pow((N-1)-i, MOD)
    ans %= MOD
end

p ans

Measured memory_bytes: 17528
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD=1000000007;
using Graph = vector<vector<int>>;
 

int cut(int a, int b) {//切り捨て
	return (a - a % b) / b;
}
ull up(ull a, ull b) {
	return (a + a % b) / b;
}

int main() {
	ll a, b, c;
	cin >> a >> b >> c;
	ll n = c - a - b;
	if (n > 0 && 4 * a * b < n*n) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i,k,n) for(int i = k; i < (int)(n); i++)
using namespace std;

int w,h;
int field[51][51];

void dfs(int y, int x){
        field[y][x]= 0;

        int dx[] = {-1,-1,-1,0,0,1,1,1};
        int dy[] = {-1,0,1,-1,1,-1,0,1,};
        rep(i,8){
                int nx = x+dx[i];
                int ny = y+dy[i];
                if(nx>=0 && nx<w && ny>=0 && ny<h && field[ny][nx] == 1) dfs(ny,nx);
        }
        return;
}

int main(){
        while(true) {
                cin >> w >> h;
                if(w==0) break;
                rep(y,h) rep(x,w){
                        cin >> field[y][x];
                }
                int ans = 0;
                rep(y,h) rep(x,w){
                        if(field[y][x] == 1) {
                                dfs(y,x);
                                ans++;
                        }
                }
                cout << ans << endl;
        }

        return 0;
}



Measured memory_bytes: 3356
N = int(input())
A = list(map(int, input().split()))

L, R = [0]*(N+1), [0]*(N+1)
L[N] = R[N] = A[N]
for i in range(N)[::-1]:
    L[i] = A[i] + (L[i+1]+1)//2
    R[i] = A[i] + R[i+1]

if L[0] > 1:
    print(-1)
    exit()

v, ans = 1, 1
for i in range(N):
    v = min((v-A[i])*2, R[i+1])
    ans += v

print(ans)

Measured memory_bytes: 22260
#include <stdio.h>

int n;
char a[110];
int check;

int main(void)
{
	scanf("%d %s", &n, a);
	
	if(n % 2 == 1)
	{
		printf("No");
		return 0;
	}
	
	for(int i = 0 ; i < n / 2 ; i++)
	{
		if(a[i] != a[i + n / 2])
		{
			check = 1;
		}
	}
	
	if(check == 1)
	{
		printf("No");
		return 0;
	}
	
	else
	{
		printf("Yes");
		return 0;
	}
	
	return 0;
}

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;

int main() {
    int H, W;
    cin >> H >> W;

    vector<string> vec(H);
    for (int i = 0; i < H; i++) {
        cin >> vec.at(i);
    }

    for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;
    for (int i = 0; i < H; i++) {
        cout << "#" << vec.at(i) << "#" << endl;
    }
        for (int i = 0; i < W + 2; i++) {
        cout << "#";
    }
    cout << endl;

}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Monad
import Control.Applicative

addFixed :: [Int] -> [Int] -> [Int]
addFixed = iter 0 where
    iter s [] []
        | s == 0 = []
        | p == 0 = [q]
        | otherwise = [q,p]
        where (p,q) = s `divMod` 10
    iter s xs [] = iter s xs [0]
    iter s [] ys = iter s [0] ys
    iter !s (x:xs) (y:ys) = let
        (surp,n) = (x+y+s) `divMod` 10
        in n: iter surp  xs ys

f :: String -> String -> String
f n m = let
    n' = map (read . return) . reverse $ n
    m' = map (read . return) . reverse $ m
    in concatMap show . reverse $ addFixed n' m'

g :: String -> String -> String
g n m = let
    n' = read n :: Integer
    m' = read m :: Integer
    in show (n'+m')

main = do
    n <- readLn
    replicateM_ n $ do
        x <- reverse . map (read . return) <$> getLine
        y <- reverse . map (read . return) <$> getLine
        let s = concatMap show . reverse $ addFixed x y
        putStrLn $ if length s > 80
                        then "overflow"
                        else s

Measured memory_bytes: 4188
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

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

const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;

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; }
void SWAP(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
void SWAP(int& a, int& b) { a ^= b; b ^= a; a ^= b; }


class B {
	string s, t;
public:
	B()
	{
		cin >> s >> t;
	}
	void solve()
	{
		sort(ALL(s));
		sort(ALL(t));
		reverse(ALL(t));

		if (s < t)
			cout << "Yes";
		else
			cout << "No";
		cout << endl;

	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
int main() {
  int N,ans=0;
  cin>>N;
  vector<int64_t> A(N);
  vector<bool> div(1000050,true);
  rep(i,N) cin>>A.at(i);
  sort(A.begin(),A.end());
  rep(i,N){
    int64_t k=A.at(i),l=2;
    if(div.at(k)){
      while(k*l<=1000010){
        div.at(k*l)=false;
        l++;
      }
    }
    if(i>0&&k==A.at(i-1)) div.at(k)=false;
  }

  rep(i,N){
    if(div.at(A.at(i))) ans++;
  } 
  cout<<ans;     
}


Measured memory_bytes: 4764
#include<iostream>
using namespace std;
int main(){
long s[5],a,b,i,m,mm;
while(cin>>a>>b,a*a+b*b){
s[0]=a+b;
for(i=1;i<5;i++){
cin>>a>>b;
s[i]=a+b;
}
for(m=s[0],mm=0,i=1;i<5;i++)if(m<s[i]){m=s[i];mm=i;}
cout<<"ABCDE"[mm]<<" "<<m<<endl;
}
return 0;
}

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

n,m,p=map(int,input().split())
E=[]
for i in range(m):
	a,b,c=map(int,input().split())
	a-=1; b-=1; c-=p; c*=-1
	E.append((a,b,c))

def BellmanFord(edges,n,s):
	#edgesは有向グラフの辺集合で辺は(始点,終点,コスト)
  #グラフの初期化
  dist=[inf for i in range(n)]
  dist[s]=0
  
  #辺の緩和
  for i in range(3*n):
    for u,v,cost in edges:
      if dist[u] != inf and dist[v] > dist[u] + cost:
        dist[v] = dist[u] + cost
        if i>=n: dist[v]=-inf
  return dist

dist = BellmanFord(E,n,0)
if dist[n-1] == -inf:
	print(-1)
else:
	print(max(0,-dist[n-1]))

	

Measured memory_bytes: 44608
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N;
  cin >> N;
  int ans = 1e9 + 3;
  int a;
  for (int i = 0; i < N; ++i) {
    cin >> a;
    if (a % 2 != 0) {
      cout << 0 << '\n';
      return 0;
    }
    int total = 0;
    while (a % 2 == 0) {
      a /= 2;
      total++;
    }
    ans = min(ans, total);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def computeGCD(x, y): 
   while(y):
   		x, y = y, x % y
   return x 
n=int(raw_input())
ar=[]
for i in range(0,n):
	k=int(raw_input())
	ar.append(k)

an=ar[0]
for x in range(1,n):
	an=(an*ar[x])/computeGCD(an,ar[x]);
print(an)

Measured memory_bytes: 2568
# N, K = gets.chomp.split.map(&:to_i)
N = gets.chomp.to_i
A = gets.chomp.split.map(&:to_i)
# N, K = gets.chomp..to_i

# p N
# p A
l = 0
r = 0
ans = 0
xored = 0
while (l < N)
  while (r < N) && (xored ^ A[r] == xored + A[r])
    # p "A[#{l}]: #{A[l]}, A[#{r}]: #{A[r]}"
    xored = xored ^ A[r]
    r += 1
  end
  # Here, the condition is not satisfied between xored and A[r]
  ans += r - l  # (r-1)-l+1
  xored = xored ^ A[l] # decrease l
  l += 1
end

p ans

Measured memory_bytes: 16772