akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python
# coding: utf-8


inf = float('inf')

def main():
    A, B, Q = list(map(int, input().split()))
    ls = []
    lt = []
    lx = []
    for _ in range(A):
        ls.append(int(input()))
    for _ in range(B):
        lt.append(int(input()))
    for i in range(Q):
        lx.append((int(input()), i))
    ls.sort()
    lt.sort()
    lx.sort()
    ans = {}
    s = 0
    t = 0
    for i in range(Q):
        dist = -1
        x = lx[i][0]
        while s < A and ls[s] < x:
            s += 1
        while t < B and lt[t] < x:
            t += 1
        s_min = ls[s-1] if s > 0 else ls[0]
        s_max = ls[s] if s < A else ls[s-1]
        t_min = lt[t-1] if t > 0 else lt[0]
        t_max = lt[t] if t < B else lt[t-1]
        if s_min > x:
            s_min = -inf
        if t_min > x:
            t_min = -inf
        if s_max < x:
            s_max = inf
        if t_max < x:
            t_max = inf
        assert(t_max > x)
        assert(s_max > x)
        assert(t_min < x)
        assert(s_min < x)
        d = min(max(s_max-x, t_max-x),
                (s_max-x)*2 + (x-t_min),
                (t_max-x)*2 + (x-s_min),
                (s_max-x) + (x-t_min)*2,
                (t_max-x) + (x-s_min)*2,
                max(x-s_min,x-t_min))
        ans[lx[i][1]] = d
    for i in range(Q):
        print(ans[i])


if __name__ == '__main__':
    main()


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;

bool dp[5001][5001];

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    sort(ALL(a));

    dp[0][0] = 1;
    int left = 0, right = n;
    while (right - left > 0)
    {
        int mid = (right + left) / 2;
        int b[n - 1];
        int m = 0;
        rep(i, n - 1)
        {
            if (m == mid)
            {
                m++;
                i--;
                continue;
            }
            b[i] = a[m];
            m++;
        }
        rep(i, n - 1)
        {
            rep(j, k)
            {
                dp[i + 1][j] = dp[i][j];
                if (j - b[i] >= 0)
                    dp[i + 1][j] = dp[i][j - b[i]] || dp[i][j];
            }
        }
        bool flag = 0;
        rep(j, k)
        {
            if (dp[n - 1][j] == 1 && j + a[mid] >= k)
                flag = 1;
        }
        if (flag == 0)
            left = mid + 1;
        else
            right = mid;
    }
    OP(right);
    return 0;
}

/*
bool dp[5001][5001];

int main()
{
    int n, k;
    cin >> n >> k;
    deque<int> q;
    rep(i, n)
    {
        int a;
        cin >> a;
        q.push_back(a);
    }

    int cnt = 0;
    rep(t, n)
    {
        rep(i, n + 1) rep(j, k + 1) dp[i][j] = 0;
        dp[0][0] = 1;
        q.push_back(q.front());
        q.pop_front();
        rep(i, n - 1)
        {
            rep(j, k)
            {
                dp[i + 1][j] = dp[i][j];
                if (j - q[i] >= 0)
                    dp[i + 1][j] = dp[i][j - q[i]] || dp[i][j];
            }
        }

        bool flag = 0;
        rep(j, k)
        {
            if (dp[n - 1][j] == 1 && j + q.back() >= k)
            {
                flag = 1;
                break;
            }
        }
        if (!flag)
            cnt++;
    }
    OP(cnt);

    return 0;
}*/

Measured memory_bytes: 24704
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long ll;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)

int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	cout<<a*b*c/max(max(a,b),c)/2<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <tuple>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

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

int main()
{

  ll N, X;
  cin >> N >> X;

  ll x[N];
  vector<ll> d(N);
  rep(i, N)
  {
    cin >> x[i];
    d[i] = abs(x[i] - X);
  };

  if (d.size() == 1)
  {
    cout << d[0];
    return 0;
  }

  ll ans = gcd(d[0], d[1]);
  repd(i, 2, N)
  {
    ans = gcd(ans, d[i]);
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define INF 114514810
#define FOR(i, r, n) for(int i=(r); i<(n); i++) 
#define REP(i, n) FOR(i, 0, n)

using namespace std;

vector<int> v;
int t;

int main(){
	REP(i, 10) {
		cin >> t;
		v.push_back(t);
	}
	sort(v.begin(), v.end());
	cout << v[9] << endl << v[8] << endl << v[7] << endl;
}

Measured memory_bytes: 1216
n = int(input())
ls = list(map(int, input().split()))

minus = 0
sm = 0
mn = abs(ls[0])

for i in range(n):
    if ls[i] < 0:
        minus += 1
    
    z = abs(ls[i])
    if z < mn:
        mn = z
    
    sm += z

if minus % 2 == 0:
    print(sm)
elif minus % 2 == 1:
    print(sm - 2 * mn)

Measured memory_bytes: 14412
package main

import (
	"fmt"
	"math"
)

func main() {
	var n int
	fmt.Scan(&n)
	t, x, y := make([]int, n+1), make([]int, n+1), make([]int, n+1)
	for i := 1; i <= n; i++ {
		fmt.Scan(&t[i], &x[i], &y[i])
	}
	for i := 1; i <= n; i++ {
		a := t[i] - t[i-1]
		b := math.Abs(float64(x[i]-x[i-1])) + math.Abs(float64(y[i]-y[i-1]))
		if a < int(b) || int(b)%2 != a%2 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll, char>> vpii;
	vector<ll> hanabi;
	map<ll, bool> mib;
	REP(i, n) {
		int a, b;
		cin >> a >> b;
		if (a < b) {
			vpii.push_back({ a, 'b' });
			vpii.push_back({ b, 'e' });
		}else{
			vpii.push_back({ a, 'e' });
			vpii.push_back({ b, 'b' });
		}
	}

	REP(i, m) {
		int a;
		cin >> a;
		vpii.push_back({ a,'f' });
		hanabi.push_back(a);
	}
	SORT(hanabi);
	REP(i, n) {
		if (vpii[i * 2].first < vpii[i * 2 + 1].first) {
			mib[vpii[i * 2 + 1].first] =
				(bool)((lower_bound(ALL(hanabi), vpii[i * 2 + 1].first) -
						lower_bound(ALL(hanabi), vpii[i * 2].first)+1) % 2);
			mib[vpii[i * 2].first] = true;
		}
		else {
			mib[vpii[i * 2+1].first] =
				(bool)((lower_bound(ALL(hanabi), vpii[i * 2].first) -
						lower_bound(ALL(hanabi), vpii[i * 2+1].first)+1) % 2);
			mib[vpii[i * 2].first] = true;
		}
	}
	SORT(vpii);
	ll ans = 0;
	ll ex = 0;
	ll vo = 0;
	if (vpii[0].second == 'b')
		if (mib[vpii[0].first]) {
			ex++;
		}
		else {
			vo++;
		}
	FOR(i, 1, vpii.size()) {
		ans += ex*(vpii[i].first - vpii[i - 1].first);
		if (vpii[i].second == 'b')
			if (mib[vpii[i].first]) {
				ex++;
			}
			else {
				vo++;
			}
		if (vpii[i].second == 'e') {
			if (mib[vpii[i].first]) {
				ex--;
			}
			else {
				vo--;
				
				
			}
		}
		if (vpii[i].second == 'f') {
			swap(ex,vo);
		}
	}
	cout << ans << endl;
}

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

#define pb push_back
#define fi first
#define se second
#define ll long long
#define ld long double
#define pii pair < int , int >

const int M = 1e9 + 7;

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

    string s;
    int x;
    cin >> s;
    cin >> x;
    ll dp[s.size()][x][3] = {};

    for (int i = 1; i < 10; ++i)
    {
        if (i + '0' < s[0])
            dp[0][i % x][0]++;
        else
        if (i + '0' == s[0])
            dp[0][i % x][1]++;
        else
            dp[0][i % x][2]++;
    }

    for (int i = 0 ;i + 1 < s.size(); ++i)
        for (int j = 0; j < x; ++j)
          for (int l = 0; l < 10; ++l)
            {
                int zn = (j + l) % x;
                if (l + '0' < s[i + 1])
                    dp[i + 1][zn][0] += dp[i][j][0] + dp[i][j][1],
                    dp[i + 1][zn][2] += dp[i][j][2]; else
                if (l + '0' == s[i + 1])
                    dp[i + 1][zn][0] += dp[i][j][0],
                    dp[i + 1][zn][1] += dp[i][j][1],
                    dp[i + 1][zn][2] += dp[i][j][2];
                else
                    dp[i + 1][zn][0] += dp[i][j][0],
                    dp[i + 1][zn][2] += dp[i][j][1] + dp[i][j][2];
                dp[i + 1][zn][0] %= M;
                dp[i + 1][zn][1] %= M;
                dp[i + 1][zn][2] %= M;
            }
    ll ans = 0;
    for (int i = 0; i  + 1< s.size(); ++i)
        for (int fl = 0; fl < 3; ++fl)
          ans += dp[i][0][fl], ans%=M;
    ans += dp[s.size() - 1][0][0] + dp[s.size() - 1][0][1];
    cout << ans % M;
}


Measured memory_bytes: 23680
using System;
using System.Linq;

namespace B_Digital_Gifts
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            double sum = 0;

            for (int i = 0; i < N; i++)
            {
                var xu = Console.ReadLine().Split().ToArray();

                sum += xu[1] == "JPY" ? double.Parse(xu[0]) : double.Parse(xu[0]) * 380000.0;
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13268
n = int(input())
(t,a) = map(int, input().split())
hs = list(map(int, input().split()))

def calc(h):
    return abs((t - 0.006 * h) - a)

def findMinIndex(xs):
    minv = xs[0]
    mini = 0
    for i in range( len(xs)):
        #print(xs[i], minv)
        if xs[i] < minv:
            minv = xs[i]
            mini = i
    return mini


res = findMinIndex(list(map(calc, hs)))
print(res+1)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

// 0: 海, 1: 陸
int board[50][50] = {{0}};

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

bool DFS(int i, int j, int w, int h) {
  if (i < 0 || i >= h || j < 0 || j >= w) return false;

  if (!board[i][j]) return false;

  board[i][j] = 0;
  for (int d = 0; d < 8; ++d)
    DFS(i + dy[d], j + dx[d], w, h);

  return true;
}

int main() {
  for (;;) {
    int w, h;
    cin >> w >> h;
    if (w == 0 && h == 0) break;

    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> board[i][j];
      }
    }

    int ans = 0;
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        if (DFS(i, j, w, h)) ++ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3232
N = int(input())
s = [int(input()) for _ in range(N)]

DP = [-1] * (100 * 100 + 1)
DP[0] = 1

for i in range(N):
    for j in reversed(range(10001)):
        if DP[j] != -1:
            DP[j + s[i]] = 1

for j in reversed(range(10001)):
    if (DP[j] != -1 and j % 10 != 0) or j == 0:
        print(j)
        break



Measured memory_bytes: 40556
def inp():
	global n
	n = int(input())
	return n
def strinp():
	l = 0
	s = list(input())
	for i in s:
		if i == '.':
			l += 1
		else:
			c = i
	return [l,c]
def calc(p):
	global f
	l = f[p][0]
	c = f[p][1]
	p += 1
	if c == '+':
		ans = 0
		for i in range(p,n):
			if f[i][0] == l:
				break
			elif f[i][0] == l+1:
				ans += calc(i)
	elif c == '*':
		ans = 1
		for i in range(p,n):
			if f[i][0] == l:
				break
			elif f[i][0] == l+1:
				ans *= calc(i)
	else:
		ans = int(c)
	return ans

while inp() > 0:
	f = []
	for i in range(n):
		f.append(strinp())
	print(calc(0))




Measured memory_bytes: 5604
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main()
{
ll ans,n;

cin >> n;

int table[n]={};
rep(i,n) {
    cin >> table[i];
}
ll sum=0;
rep(i,n) {
    sum+=table[i];
}
ans=sum-n;
cout << ans << endl;
return 0;
}





Measured memory_bytes: 256
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int x,y,z;
  cin>>x>>y>>z;
  swap(x,y);
  swap(x,z);
  cout<<x<<" "<<y<<" "<<z;

  return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
#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) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}

char c[1000010];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);

	int K;
	scanf("%d ", &K);

	fread(c, 1, 1000010, stdin);
	int L = 0, R = 1000000;
	while (L + 1 < R) {
		int M = (L + R) / 2;
		if (c[M] >= 'a') L = M;
		else R = M;
	}
	int M = R;

	int inv[1000010];
	inv[0] = 1;
	inv[1] = 1;
	rep1(i, K - 1) inv[i + 1] = ll(inv[i]) * i % mod;
	ll tmp = modpow(ll(inv[K]) * K % mod, mod - 2);
	for (int i = K; i > 0; i--) {
		inv[i] = inv[i] * tmp % mod;
		tmp = tmp * i % mod;
	}

	const ll are = 423076927;
	tmp = modpow(26, K);
	ll kotae = 0;
	rep(i, K + 1) {
		tmp = tmp * inv[i] % mod;
		kotae += tmp;
		tmp = tmp * (M + i) % mod;
		tmp = tmp * are % mod;
	}

	printf("%lld\n", kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 8596
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.TreeMap;

public class Main {
	InputStream is;
	PrintWriter out;
	String INPUT = "";

	void solve() {
		char[] s = ns().toCharArray();
		int n = s.length;
		for(int i = 0; i < n-1; i++) {
			if(s[i] != s[i+1]) {
				out.println("Yes");
				return;
			}
		}
		out.println("No");
	}

	
	void run() throws Exception {
		is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
		out = new PrintWriter(System.out);

		long s = System.currentTimeMillis();
		solve();
		out.flush();
		if (!INPUT.isEmpty())
			tr(System.currentTimeMillis() - s + "ms");
	}

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

	private byte[] inbuf = new byte[1024];
	public int lenbuf = 0, ptrbuf = 0;

	private int readByte() {
		if (lenbuf == -1)
			throw new InputMismatchException();
		if (ptrbuf >= lenbuf) {
			ptrbuf = 0;
			try {
				lenbuf = is.read(inbuf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (lenbuf <= 0)
				return -1;
		}
		return inbuf[ptrbuf++];
	}

	private boolean isSpaceChar(int c) {
		return !(c >= 33 && c <= 126);
	}

	private int skip() {
		int b;
		while ((b = readByte()) != -1 && isSpaceChar(b))
			;
		return b;
	}

	private double nd() {
		return Double.parseDouble(ns());
	}

	private char nc() {
		return (char) skip();
	}

	private String ns() {
		int b = skip();
		StringBuilder sb = new StringBuilder();
		while (!(isSpaceChar(b))) { // when nextLine, (isSpaceChar(b) && b != ' ')
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	private char[] ns(int n) {
		char[] buf = new char[n];
		int b = skip(), p = 0;
		while (p < n && !(isSpaceChar(b))) {
			buf[p++] = (char) b;
			b = readByte();
		}
		return n == p ? buf : Arrays.copyOf(buf, p);
	}

	private char[][] nm(int n, int m) {
		char[][] map = new char[n][];
		for (int i = 0; i < n; i++)
			map[i] = ns(m);
		return map;
	}

	private int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}

	private int ni() {
		int num = 0, b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private long nl() {
		long num = 0;
		int b;
		boolean minus = false;
		while ((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'))
			;
		if (b == '-') {
			minus = true;
			b = readByte();
		}

		while (true) {
			if (b >= '0' && b <= '9') {
				num = num * 10 + (b - '0');
			} else {
				return minus ? -num : num;
			}
			b = readByte();
		}
	}

	private static void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 23124
import sys
from collections import deque


N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for s in sys.stdin.readlines():
    a, b = map(lambda x: int(x) - 1, s.split())
    edge[a].append(b)
    edge[b].append(a)

path = [0] * N
cnt = 0
for i in range(N):
    if path[i] == 0:
        cnt += 1
        q = deque()
        path[i] = 1
        q.append(i)
        while q:
            p = q.popleft()
            for np in edge[p]:
                if path[np] == 0:
                    path[np] = 1
                    q.append(np)

print(cnt - 1)


Measured memory_bytes: 91224
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (int i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (int i = x.size()-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define fst first
#define scd second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int n;
int a[3][3];
int b[10];
bool f[3][3];
bool flag;

int main()
{
    REP(i,3) REP(j, 3) {
        cin>>a[i][j];
    }
    cin>>n;
    REP(k, n) {
        cin>>b[k];
        REP(i,3) REP(j, 3) {
            if (b[k] == a[i][j]) {
                f[i][j] = true;
            }
        }
    }
    REP(i,3) {
        flag |= f[i][0] & f[i][1] & f[i][2];
    }
    REP(j,3) {
        flag |= f[0][j] & f[1][j] & f[2][j];
    }
    flag |= f[0][0] & f[1][1] & f[2][2];
    flag |= f[2][0] & f[1][1] & f[0][2];

    Yes(flag);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b;
	int i,sum=0;
	cin>>a;
	b=a;
	reverse(a.begin(),a.end());
	for(i=0;i<a.size();i++)
	{
		if(a[i]=='p') a[i]='q';
		else if(a[i]=='q') a[i]='p';
		else if(a[i]=='d') a[i]='b';
		else if(a[i]=='b') a[i]='d';
	}
	if(a==b) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
    return 0;
}

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

int main()
{
    string s, weather[3] = {"Sunny", "Cloudy", "Rainy"};
    int i;
    cin >> s;
    switch(s.at(0))
    {
        case 'S': i = 1; break;
        case 'C': i = 2; break;
        case 'R': i = 0; break;
    }
    cout << weather[i] << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#define MAX(x,y) x=max(x,y)
using namespace std;

const int N=105;

int n,m,a[N][N],sx,sy,f[2][N][N][N];
char str[N];

int get(int x1,int x2,int y1,int y2)
{
	return a[x2][y2]-a[x2][y1-1]-a[x1-1][y2]+a[x1-1][y1-1];
}

int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++)
	{
		scanf("%s",str+1);
		for (int j=1;j<=m;j++)
			if (str[j]=='E') sx=i,sy=j;
			else if (str[j]=='o') a[i][j]++;
	}
	for (int i=1;i<=n;i++)
		for (int j=1;j<=m;j++)
			a[i][j]+=a[i-1][j]+a[i][j-1]-a[i-1][j-1];
	int ans=0,now=0;
	for (int i=0;i<sx;i++)
	{
		now^=1;
		for (int j=0;j<sy;j++)
			for (int k=0;k<n-sx+1;k++)
				for (int l=0;l<m-sy+1;l++)
				{
					f[now][j][k][l]=0;
					if (i&&sx-i>k) MAX(f[now][j][k][l],f[now^1][j][k][l]+get(sx-i,sx-i,max(sy-j,l+1),min(sy+l,m-j)));
					if (j&&sy-j>l) MAX(f[now][j][k][l],f[now][j-1][k][l]+get(max(sx-i,k+1),min(sx+k,n-i),sy-j,sy-j));
					if (k&&n-sx-k+1>i) MAX(f[now][j][k][l],f[now][j][k-1][l]+get(sx+k,sx+k,max(sy-j,l+1),min(sy+l,m-j)));
					if (l&&m-sy-l+1>j) MAX(f[now][j][k][l],f[now][j][k][l-1]+get(max(sx-i,k+1),min(sx+k,n-i),sy+l,sy+l));
					MAX(ans,f[now][j][k][l]);
				}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
#define ll  long long
#define ull unsigned long long  
using namespace std;
#define  inf 1e6+18
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL)
#define mod 1000000007
#define  f1(i,n) for(i=1;i<=n;i++)
#define f0(i,n)  for(i=0;i<n;i++)
#define w(x)   while(x--)
const int maxn=1000001;
#define  pq priority_queue
#define  ff first
#define  ss second 
#define pb  push_back
#define lb lower_bound
map<int,int>mp;
vector<int>pr;
int p[maxn];
void sieve()
{
  ll i,j;
  for(i=2;i<maxn;i++)
  {
  	if(p[i]==0)
  	{
  		pr.pb(i);
  		for(j=i*i;j<maxn;j+=i)
  			p[j]=1;
  	}
  }

 
}
int main()
{
	fastio;
	//int t;
	sieve();
	ll int i,j,k,n,m,g=0;
	cin>>n>>k>>m;
	//ll a[n];
	//if(n%k)
   j=(n+k-1)/k;
   cout<<j*m;

	
	

}
//Lordvishnu@almighty

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

int main() {
  int n;
  cin >> n;
  ll s = 0;
  for (int i = 1; i <= n; ++i) {
    if (i % 3 == 0 && i % 5 == 0) {
      continue;
    } else if (i % 3 == 0) {
      continue;
    } else if (i % 5 == 0) {
      continue;
    } else {
      s += i;
    }
  }
  cout << s << endl;
  return 0;
}

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


signed main()
{

	int k,n;
	cin>>n;
	cin>>k;
	int a[n];
	int dp[n];
	for (int i = 1; i <=n; ++i)
	{
		cin>>a[i];
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(int i=1;i<=n;i+=1){
		for(int j=1;j<=k;j+=1){
			if(i-j>=1)
			dp[i]=min(dp[i],dp[i-j]+abs(a[i]-a[i-j]));
		}
	}
	cout<<dp[n]<<endl;
	
}









Measured memory_bytes: 1920
#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=1
for tt in range(t):
    s=str(input())
    v=s.count('o')
    v+=15-len(s)
    if(v<8):
        print("NO")
    else:
        print("YES")
    #n,k,s= map(int, sys.stdin.readline().split(' '))
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

Measured memory_bytes: 3064
#include<iostream>
#include<vector>
using namespace std;
int main(){
  int n,a;
  vector<int>v(1,0);
  cin >> n;
  while(n--){
    cin >> a;
    v.push_back(a);
  }
  for(int j=1;j<v.size();j++){
    int key = v[j],i = j - 1;
    while(i > 0 && v[i] > key){
      v[i+1] = v[i];
      i--;
    }
    v[i+1] = key;
    for(int j=1;j<v.size();j++){
      cout << (j==1?"":" ") << v[j];
    }
    cout << endl;
  }
}



Measured memory_bytes: 3148
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rapido ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

void solve()
{
    int n;string s;
    cin>>n>>s;
    int ans=0;
    for(int i=0;i<=n-3;i++)
    {
        string str=s.substr(i,3);
        if(str=="ABC")
        {
        ans++;
        i+=2;
        }
    }
    cout<<ans<<endl;
}
int32_t main()
{
    rapido;
    int t;
    // cin>>t;
    t=1;
    while(t--)
    solve();
}

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

using namespace std ;

long long int a[500009]={} ;

int main () {

    long long int n ,cnt=1 ;

    cin >> n ;

    a[n]++ ;

    while(n){

    if (n%2==0)
        n/=2 ;
    else
        n=3*n+1 ;

    a[n]++ ;
    cnt++ ;

    if(a[n]==2)
    {
        cout<< cnt <<endl ;
        return 0 ;

    }
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <set>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>

using namespace std;

typedef long long ll;

#define forn(i, n) for(int i = 0; i < (int)(n);++i)
#define fore(i, a, b) for(int i = (int)(a); i <= (int)(b); ++i)
#define fi first
#define se second
#define pb push_back
#define pll pair<ll,ll>
#define vi vector<int>
#define vb vector<bool>
#define vvi vector<vi>
#define vpll vector<pll>
#define vll vector<ll>
#define vvll vector<vll>
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const ll mod = ll(1e9+7);

void fastik() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
}

//ifstream &cin
void solve(){

}

int main() {
    fastik();
    ll n,m;cin>>n >> m;
    vll a(m);
    forn(i,m) cin>>a[i];
    vll d(n,-1);
    d[0] = 1;
    forn(i,m){
        d[a[i]-1] = 0;
    }
    if(d[1] != 0) d[1] = d[0] + 1;
    fore(i,2,n-1){
        if(d[i] == 0){
            continue;
        }
        d[i] = (d[i-1]+d[i-2])%mod;
    }
    cout << d[n-1]%mod;
}

Measured memory_bytes: 1792
import itertools
n = int(input())
a = list(map(int,input().split()))

x = list(itertools.product([-1,0,1 ],repeat=n))
ans = 0
for i in x:
    for j in range(n):
        if (a[j] + i[j]) % 2 == 0:
            ans += 1
            break
print(ans)

Measured memory_bytes: 11252
#include <stdio.h>

#define MAXNUM 100
#define MAXDI 100

int main(){
  int n, d[MAXNUM],  count = 0;
  int num[MAXDI] = {};
  int i;
  scanf("%d", &n);
  if( n < 0 || MAXNUM < n)
    return 1;

  for(i = 0;i < n; i++){
    scanf("%d", &d[i]);
      if( d[i] < 0 || MAXDI < d[i])
        return 1;
  }
  for(i = 0; i < n; i++){
    num[d[i]-1] += 1;
  }
  for(i = 0; i < MAXDI; i++){
    if(num[i])
      count += 1;
  }

  printf("%d\n",count);
  return 0;
}

Measured memory_bytes: 128
a,b,c=map(int,input().split())
if a==b==c and a%2==0:
    print(-1)
elif a==b==c and a%2==1:
    print(0)
    
else:
    cnt=0
    while a%2==b%2==c%2==0:
        total=a+b+c
        a=total//2-a//2
        b=total//2-b//2
        c=total//2-c//2
        cnt+=1
    print(cnt)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
  char asd;
  cin>>asd;
  if(asd=='a' || asd=='e' || asd=='i' || asd == 'u' || asd == 'o'){
    cout<<"vowel"<<endl;
  }
  else{
        cout<<"consonant"<<endl;
  }



    return 0;
}



Measured memory_bytes: 256
import java.io.*;
import java.text.*;
import java.util.*;

public class Main {

    static InputReader sc = new InputReader(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws IOException {
        solver s = new solver();
        int t = 1;
        while (t > 0) {
            s.solve();
            t--;
        }
        out.close();
    }

    static class InputReader {

        public BufferedReader br;
        public StringTokenizer token;

        public InputReader(InputStream stream) {
            br = new BufferedReader(new InputStreamReader(stream), 32768);
            token = null;
        }

        public String sn() {
            while (token == null || !token.hasMoreTokens()) {
                try {
                    token = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return token.nextToken();
        }

        public int ni() {
            return Integer.parseInt(sn());
        }

        public String snl() throws IOException {
            return br.readLine();
        }

        public long nlo() {
            return Long.parseLong(sn());
        }

        public double nd() {
            return Double.parseDouble(sn());
        }

        public int[] na(int n) {
            int a[] = new int[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.ni();
            return a;
        }

        public long[] nal(int n) {
            long a[] = new long[n];
            for (int i = 0; i < n; i++)
                a[i] = sc.nlo();
            return a;
        }
    }

    static int inf = 5000013;

    static class solver {
        DecimalFormat df = new DecimalFormat("0.00000000");
        long maxi = Integer.MAX_VALUE;
        long mod = (long) (1e9 + 7);
        int n, a[][];

        void solve() {
            n = sc.ni();
            a = new int[n][n];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n; j++)
                    a[i][j] = sc.ni();

            }
            int mask = 1 << n;
            long dp[] = new long[mask];
            dp[0] = 1;
            for (int i = 0; i < mask; i++) {
                int x = Integer.bitCount(i);
                for (int j = 0; j < n; j++) {
                    if (x < n && a[x][j] == 0)
                        continue;
                    if ((i & (1 << j)) == 0)
                        dp[i | (1 << j)] = (dp[i | (1 << j)] + dp[i]) % mod;
                }
            }
            out.println((dp[mask - 1] + mod) % mod);
        }
    }
}


Measured memory_bytes: 40276
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
using ll = long long;
int main(){
    int l, r, d;
    cin >>l >> r >> d;
    int ans =0;
    for(l;l<r+1;l++){
        if(l%d==0){
            ans ++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

long long koyaku_max(long long a,long long b){
    long long r;
    r = a % b;
    while(r!=0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
long long kobai_min(long long a,long long b){
    long long tmp;
    tmp =  a / koyaku_max(a,b);
    return tmp * b;
}

int main(){

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

    cin >> A;
    cin >> B;
    cout << kobai_min(A,B) << endl;    

}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
#define N 1000
using namespace std;
int r[N],h[N];

int syori(int,int);
void sort(int,int);

int main(){
  int n1,n2,i,ans;
  
  while(1){
  
    for(i=1;i<=N;i++){
      r[i]=0;
      h[i]=0;
    }


    r[0]=-1;
    h[0]=-1;
    
    cin >> n1; 
    if(n1==0)break;
    
    for(i=1;i<=n1;i++){    // 1ツつゥツづァツづ債つカツづ淞づ?つ「ツづゥツ篠鳴づ可陳債暗?
      cin >> h[i] >> r[i];
    }
    
    cin >> n2;
    
    for(i=n1+1;i<=n1+n2;i++){ // ツ１ツつゥツづァツづ債つカツづ淞づ?つ「ツづゥツ篠鳴づ可陳債暗?
      cin >> h[i] >> r[i];
    }
    
    sort(n1,n2);

    ans=syori(n1,n2);
    
    cout << ans << endl;
  }
  
  
}

void sort(int n1,int n2){
  int i,j,max,rr;

  for(i=1;i<=(n1+n2);i++){
    for(j=1;j<=(n1+n2);j++){
      if(h[j] > h[i]){
	
	rr=h[i];
	h[i]=h[j];
	h[j]=rr;
	
	rr=r[i];
	r[i]=r[j];
	r[j]=rr;
	
	
      }
    }
    
    
  }
  
}



int syori(int n1,int n2){
  int ANS[N],i,j; //ANS[N]ツづ債陳キツつウツづーツ陳イツづ猟づゥツ配ツ療ア 
  int max=0,res=0;
  
  for(i=0;i<N;i++){
    ANS[i]=0;
   
  }
 
  
  for(i=1;i<=(n1+n2);i++){
    max=0;
    //  cout <<endl<< "h["<<i<<"]--"<<h[i]<<endl;     
    // cout << "r["<<i<<"]--"<<r[i]<<endl;
    // cout << "ANS["<<i<<"]--"<<ANS[i]<<endl;
   


    for(j=0;j<i;j++){
      if(h[j]<h[i] && r[j]<r[i] && ANS[j]>ANS[max]){
	max=j;    
      }
    
    }
 ANS[i]=ANS[max]+1;
       
  }

  //  for(i=1;i<=(n1+n2);i++){
  //  cout << "ANS[" << i << "]--" << ANS[i]<< endl;
  // }


  for(i=1;i<=(n1+n2);i++){
      if(res<=ANS[i]){
	res=ANS[i];
    }
  }
  return res;
}

Measured memory_bytes: 1168
package main

import (
	"fmt"
)

func main() {
	var a,b,c string
	fmt.Scan(&a,&b,&c)
	
	if a[len(a)-1] == b[0] && b[len(b)-1] == c[0] {
		fmt.Println("YES")
	} else {
		fmt.Println("NO")
	}
	
}

Measured memory_bytes: 512
import java.util.*;

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s="";
        while(true){
            int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
            if(a==-1 && b==-1 &&c==-1) break;
            if(a==-1 || b==-1) s="F";
            else if(a+b>=80) s="A";
            else if(a+b>=65) s= "B";
            else if(a+b>=50 || (a+b>=30 && c>=50)) s= "C";
            else if(a+b>=30) s= "D";
            else if(a+b<30) s= "F";
            System.out.println(s);
        }
    }
}


Measured memory_bytes: 26348
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
typedef int long long ll;
using namespace std;





int main(){
    
    ll n;
    cin>>n;
    ll na[n][3];
    for(int i=0;i<n;i++){
        cin>>na[i][0]>>na[i][1]>>na[i][2];
    }
    ll ans[n][3];
    ans[0][0]=na[0][0];
    ans[0][1]=na[0][1];
    ans[0][2]=na[0][2];
    
    for(ll i=1;i<n;i++){
        ans[i][0]=max(ans[i-1][1]+na[i][0],ans[i-1][2]+na[i][0]);
        
        ans[i][1]=max(ans[i-1][0]+na[i][1],ans[i-1][2]+na[i][1]);
        
        ans[i][2]=max(ans[i-1][0]+na[i][2],ans[i-1][1]+na[i][2]);
    }
    cout<<max({ans[n-1][0],ans[n-1][1],ans[n-1][2]});

   
    

    
    
return 0;
}


Measured memory_bytes: 4992
N, A, B, *X = map(int, open(0).read().split())

ub = 10 ** 15
lb = 0
while ub - lb > 1:
    mid = (ub + lb) // 2
    cnt = 0
    for i in range(N):
        if X[i] - B * mid > 0:
            cnt += -(-(X[i] - B * mid) // (A - B))

    if cnt > mid:
        lb = mid
    else:
        ub = mid

print(ub)


Measured memory_bytes: 71228
icase=0
if icase==0:
    m=int(input())
    dc=[[0]*2 for i in range(m)]
    for i in range(m):
        dc[i]=list(map(int,input().split()))
elif icase==1:
    m=1
    dc=[[5,2]]

    
dsum=0
csum=0
for i in range(m):
    dsum+=dc[i][0]*dc[i][1]
    csum+=dc[i][1]

ans=(dsum-1)//9+csum-1

print(ans)
    

Measured memory_bytes: 45300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

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

    int cnt = 1;
    int maxH = H[0];
    for (int i = 1; i < N; i++) {
        if (maxH <= H[i]) {
            cnt++;
            maxH = H[i];
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
# 写経AC
from collections import deque, defaultdict

N,M = map(int, input().split())
A = [[int(i) - 1 for i in input().split()] for _ in range(N)]

def check(X):
    """
    最多参加のスポーツの参加人数がX以下になるか
    """
    # que[i]: 人iが参加したいスポーツ
    que = [deque() for _ in range(N)]
    # ng[j]: スポーツjはダメ
    ng = [False] * M
    for i in range(N):
        for j in range(M):
            que[i].append(A[i][j])
    
    while True:
        # cnt[j]: スポーツjに参加したい人数
        cnt = defaultdict(int)
        for i in range(N):
            cnt[que[i][0]] += 1

        # 定員over フラグ
        flag = False
        for s, c in cnt.items():
            if X < c:
                flag = True
                ng[s] = True

        # 参加人数が全てX以下
        if not flag:
            return True
        
        for i in range(N):
            # 参加したいスポーツがngの場合
            while que[i] and ng[que[i][0]]:
                que[i].popleft()
            # 参加できるスポーツがない場合
            if not que[i]:
                return False

def main():
    ng, ok = 0, N
    while ok - ng > 1:
        mid = (ng + ok) // 2
        if check(mid):
            ok = mid
        else:
            ng = mid
    print(ok)

if __name__ == "__main__":
    main()

Measured memory_bytes: 7464
#include <stdio.h>
#include <string.h>

int main(){
  char s[201], v[101], p[101] = {};

  scanf("%s %s", s, p);
  strcpy(v, s);
  strcat(s, v);

  if( strstr(s, p) == NULL ) printf ("No\n");
  else printf("Yes\n");

  return 0;
}

Measured memory_bytes: 1824
#include "bits/stdc++.h"

#pragma warning(disable:4996)
using namespace std;


int main() {
	int N;cin>>N;
	vector<int>ls(N),nums(N);
	for(int i=0;i<N;++i)cin>>ls[i];
	for(int i=0;i<N;++i)cin>>nums[i];

	int min_l=1e9+1,min_r=1e9+1;
	for (int i = 0; i < N; ++i) {
		if (ls[i]) {
			min_r=min(min_r,nums[i]);
		}
		else {
			min_l=min(min_l,nums[i]);
		}
	}
	if(min_l+min_r>=1e9)cout<<0<<endl;
	else {
		cout<<min_l+min_r<<endl;
	}
	return 0;
}


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

const int MAXN = 2e5;

char S[MAXN + 9];
int n, s[MAXN + 9], top = 0, ans;

int main() {
  scanf("%s", S + 1); ans = n = strlen(S + 1);
  
  for (int i = 1; i <= n; ++i) {
    if (S[i] == 'S' || !top) s[++top] = S[i];
    else if (s[top] == 'S') --top, ans -= 2;
  }

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

  return 0;
}

Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> m(N);
  for (int i=0; i<N; ++i) {
    cin >> m.at(i);
  }
  
  // 各々1個の合計を求める
  int one_sum = 0;
  for (int i=0; i<N; ++i) {
    one_sum += m.at(i);
  }
  
  // Xからone_sumを引いて，それを最小のmで割って商qを求める
  sort(m.begin(), m.end());
  int q = (X - one_sum) / m.at(0);
  
  // mのサイズにqを加えたものが解
  cout << m.size() + q << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int A, B;
  cin >> A >> B;
  string S;
  cin >> S;
  int flag = 0;
  REP(i,S.size()){
    if((i<=A-1||(A+1<=i&&i<=A+B)) && S.at(i) == '-'){
      flag = 1;
      break;
    }else if(i==A&&S.at(i) != '-'){
      flag = 1;
      break;
    }
  }
  if(flag == 1){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[200005];

int main(int argc, char* argv[])
{    
    scanf("%s", str);
    int len=strlen(str);
    vector<int> flag(len);

    int cnt=0;
    int i;
    for(i=0; i<len; i++) {
        if(i==0) {
            flag[i]=1; cnt++;
        }
        else {
            if(flag[i-1]) {
                if(i==1 || flag[i-2]) {
                    if(str[i-1]!=str[i]) {
                        flag[i]=1; cnt++;
                    }
                }
                else {
                    flag[i]=1; cnt++;
                }
            }
            else {
                flag[i]=1; cnt++;
            }
        }
    }
    printf("%d\n", cnt);

    return 0;
}

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

int main() {
  string S;
  cin >> S;
  if(S[0] == S[1]) {
    cout << "Bad" << endl;
  }
   else if(S[1] == S[2]) {
    cout << "Bad" << endl;
  }
   else if(S[2] == S[3]) {
    cout << "Bad" << endl;
  }
  else cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> pll;
#define mod 1000000007
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define pb push_back
const long double PI = acos(-1);
const long long INF = (1 << 30);
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a / gcd(a,b) * b;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(const ll a, const ll b){return ((a)+(b)-1)/b;}


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

  ll n, m;
  cin >> n >> m;

  cout << (1900*m + (n-m)*100) * pow(2, m) << endl;
  return 0;
}

Measured memory_bytes: 256
// B

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,p[10];
  cin>>N;
  for (int i(0);i<N;i++){
    cin>>p[i];
  }
  sort(p,p+N,greater<int>());
  p[0] /= 2;
  int ans(0);
  for (int i(0);i<N;i++){
    ans += p[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
def strmax(a, b):
    if len(a) > len(b):
        return a
    elif len(a) < len(b):
        return b
    else:
        return max(a, b)


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    dp = [None] * (N+1)
    dp[0] = ""
    cost = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
    for i in range(N+1):
        for d in A:
            if i < cost[d]:
                continue
            prev = dp[i - cost[d]]
            if prev is None:
                continue
            else:
                candidate = strmax(prev + str(d),
                                   str(d) + prev)
            if dp[i] is None:
                dp[i] = candidate
            else:
                dp[i] = strmax(dp[i], candidate)
    print(dp[N])


if __name__ == "__main__":
    main()


Measured memory_bytes: 134792
import sys
import os
import math
import bisect
import collections

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X = ii()
    x = 100
    ret = 0
    while x < X:
        ret += 1
        x += x // 100
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9488
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int A, B, C, X;
    cin >> A >> B >> C >> X;

    int cnt = 0;
    rep(i, A + 1) {
        rep(j, B + 1) {
            rep(k, C + 1) {
                if(i * 500 + j * 100 + k * 50 == X) {
                    cnt++;
                }
            }
        }
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

v = inl()
v.sort()


def solve():
    k1 = (v[2] - v[0]) // 2
    v[0] += 2 * k1
    k2 = (v[2] - v[1]) // 2
    v[1] += 2 * k2
    if v[0] == v[1] == v[2]:
        return k1 + k2
    elif v[0] == v[1] == (v[2] - 1):
        return k1 + k2 + 1
    else:
        return k1 + k2 + 2


print(solve())


Measured memory_bytes: 9196
package main

import "fmt"

func main() {
	var s string
	fmt.Scan(&s)

	for i := 0; i < len(s)-1; i++ {
		for j := i + 1; j < len(s); j++ {
			if s[i] == s[j] {
				fmt.Println("no")
				return
			}
		}
	}
	fmt.Println("yes")
}


Measured memory_bytes: 512
import bisect,collections,copy,heapq,itertools,math,numpy,string,decimal
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def SS(): return map(str,sys.stdin.readline().rstrip().split())
def II(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
K = I()
x = LI()

ans = 0

for xi in x:
  ans += min(xi,abs(K-xi))
print(ans*2)

Measured memory_bytes: 13300