akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

//long long
using ll = long long;

// pair<int, int>
using PII = pair<int, int>;

//最大値、mod
const int MOD = 1000000007;
const int INF = 1000000000;
const long long LINF = 1e18;
const int MAX = 510000;

//出力系
#define print(x) cout << x << endl
#define prints(x) cout << fixed << setprecision(10) << x << endl
#define printc(x) cout << setw(2) << setfill('0') << x << endl;
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

//for
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

// 最小公倍数
unsigned lcm(unsigned a, unsigned b){
    return a / gcd(a, b) * b; 
}

// a = max(a, b), a = min(a, b)
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; }

// 階乗(MODをとる)
ll pow_mod(ll num, ll pow, ll mod) {
    ll prod = 1;
    num %= mod;
    while (pow > 0) {
        if (pow & 1) prod = prod * num % mod;
        num = num * num % mod;
        pow >>= 1;
    }
    return prod;
}



// 二項係数(MODとる、1 ≦ k ≦ n ≦ 10^7 程度)
// COMinit()
// COM(x, y)
// とコンビで使う

// テーブルを作る前処理
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

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

int main(){

    string N;
    cin >> N;
    string target;
    stack<char>x;
    REP(i, N.length()){
        if(N.at(i) == 'S') x.push('S');
        else if(N.at(i) == 'T'){
            if(x.empty()) x.push('T');
            else{
            char c = x.top();
                if(c == 'T') x.push('T');
            else if(c == 'S') x.pop();
            }
        }
    }
  int ans = 0;
    while(!x.empty()){
       ans++;
        x.pop();
    }
  print(ans);
}

Measured memory_bytes: 644
//Mahir Ratanpara (DA-IICT)
#include<bits/stdc++.h>
using namespace std;
#define Ff(i,a,n) for(i=a;i<n;i++)
#define Fr(i,a,n) for(i=a;i>n;i--)
#define ll long long
#define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
typedef pair<ll, ll>	pa;
typedef vector<ll>		vc;
typedef vector<pa>		vp;
typedef vector<vc>		vvc;
int mpow(int base, int exp); 
void ipgraph(ll n,ll m);
void dfs(int u, int par);
const int mod = 1000000007;
const int N = 3e5, M = N;
//=======================

vc g[N];

int main() {
    FAST;
    int h,w,x;
    cin>>h>>w>>x;
    string s[h],temp[h];
    for(int i=0;i<h;i++){
        cin>>s[i];
    }
    int ans=0;
    for(int i=0;i<(1<<h);i++){
        for(int j=0;j<(1<<w);j++){
            for(int k=0;k<h;k++){
                temp[k]=s[k];
            }
            for(int k=0;k<h;k++){
                if(i&(1<<k)){
                    for(int col=0;col<w;col++){
                        temp[k][col]='*';
                    }
                }
            }
            for(int k=0;k<w;k++){
                if(j&(1<<k)){
                    for(int row=0;row<h;row++){
                        temp[row][k]='*';
                    }
                }
            }
            int cnt=0;
            for(int row=0;row<h;row++){
                for(int col=0;col<w;col++){
                    if(temp[row][col]=='#')cnt++;
                }
            }
            if(cnt==x){
               ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

int mpow(int base, int exp) {
  base %= mod;
  int result = 1;
  while (exp > 0) {
    if (exp & 1) result = ((ll)result * base) % mod;
    base = ((ll)base * base) % mod;
    exp >>= 1;
  }
  return result;
}

void ipgraph(ll n, ll m){
	int i, u, v;
	while(m--){
		cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
}

void dfs(int u, int par){
	for(int v:g[u]){
		if (v == par) continue;
		dfs(v, u);
	}
}

Measured memory_bytes: 10584
package main

import "fmt"

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

	cs := make(map[byte][]int)
	cs['R'] = make([]int, n+1)
	cs['G'] = make([]int, n+1)
	cs['B'] = make([]int, n+1)
	for i := 0; i < n; i++ {
		c := s[i]

		cs['R'][i+1] = cs['R'][i]
		cs['G'][i+1] = cs['G'][i]
		cs['B'][i+1] = cs['B'][i]

		cs[c][i+1]++
	}

	ans := 0
	for i := 0; i < n-2; i++ {
		rgb := map[byte]int{'R': 0, 'G': 0, 'B': 0}
		rgb[s[i]]++
		for j := i + 1; j < n; j++ {
			if s[i] == s[j] {
				continue
			}
			rgb[s[j]]++

			t := byte('@')
			if rgb['R'] == 0 {
				t = 'R'
			} else if rgb['G'] == 0 {
				t = 'G'
			} else {
				t = 'B'
			}

			cc := cs[t]
			cnt := cc[n] - cc[j]
			d := j - i
			if j+d < n {
				if s[j+d] == t {
					cnt--
				}
			}
			ans += cnt

			rgb[s[j]]--
		}
		rgb[s[i]]--
	}

	fmt.Println(ans)
}


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

#define Set(a, b) memset(a, b, sizeof (a))
#define For(i, j, k) for (register int i = j; i <= k; ++ i)
#define Forr(i, j, k) for (register int i = j; i >= k; -- i)

using namespace std;

inline int read() {
	int x = 0, p = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') p = -1;
	for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
	return x * p;
}

inline void File() {
	freopen("duliu.in", "r", stdin);
	freopen("duliu.out", "w", stdout);
}

const int N = 2e5 + 10, M = N << 1, inf = 0x3f3f3f3f;
int n, a[N], b[N], c, sum, lim, p[N], ls[M], tot;
int cnt1[M], cnt2[M], fa[M], ta[N], tb[N], ans, cc[M];

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

int main() {

	n = read();
	For(i, 1, n) sum ^= a[i] = ls[++ tot] = read();
	ls[++ tot] = sum;

	For(i, 1, n) b[i] = ls[++ tot] = read();

	For(i, 1, n) if (a[i] ^ b[i]) p[++ c] = i;	

	if (c == 0) return puts("0"), 0;

	sort(ls + 1, ls + 1 + tot), tot = unique(ls + 1, ls + 1 + tot) - ls - 1;

	For(i, 1, n) if (a[i] ^ b[i]) {
		ta[i] = lower_bound(ls + 1, ls + 1 + tot, a[i]) - ls, ++ cnt1[ta[i]];
		tb[i] = lower_bound(ls + 1, ls + 1 + tot, b[i]) - ls, ++ cnt2[tb[i]];
	}

	int tt = 0, tmp1 = inf, tmp2 = inf; 
	For(i, 1, tot) {
		tt += abs(cnt1[i] - cnt2[i]);
		if (cnt1[i] > cnt2[i]) tmp1 = ls[i];
		if (cnt2[i] > cnt1[i]) tmp2 = ls[i];
	}
	tt >>= 1;	

	if (tt > 1) return puts("-1"), 0;	

	if (tt == 0 || tmp2 == sum) {

		int ps = lower_bound(ls + 1, ls + 1 + tot, sum) - ls, cnt = 0;

		Set(fa, 0), fa[ps] = ps;

		For(i, 1, n) if (a[i] ^ b[i]) {
			if (!fa[ta[i]]) fa[ta[i]] = ta[i];
			if (!fa[tb[i]]) fa[tb[i]] = tb[i];
	
			int fx = find(ta[i]), fy = find(tb[i]);
			fa[fx] = fy;	
		}

		For(i, 1, tot) cnt += i == fa[i];
		ans = c + cnt - 1;
		return printf("%d\n", ans), 0;
	}

	return puts("-1"), 0;
}


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

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


Measured memory_bytes: 3104
import java.util.Scanner;

class Main{
  public static void main(String args[]){
    int i,j,r,c,wsum;
    int [][] table = new int[101][101];
    int [] hsum = new int[101];
    Scanner sc = new Scanner(System.in);
    r = sc.nextInt();
    c = sc.nextInt();
    for(i = 0;i < r;i++){
      for(j = 0;j < c;j++){
        table[i][j]  = sc.nextInt();
      }
    }
    for(i = 0;i < c + 1;i++){
      hsum[i] = 0;
    }
    for(i = 0;i < r;i++){
      wsum = 0;
      for(j = 0;j < c;j++){
        System.out.print(table[i][j] + " ");
        wsum += table[i][j];
        if(j == c - 1){
          System.out.println(wsum);
          hsum[c] += wsum;
        }
        hsum[j] += table[i][j];
      }
    }
    for(i = 0;i < c;i++){
      System.out.print(hsum[i] + " ");
    }
    System.out.println(hsum[i]);
  }
}

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

public class ABC155_A
{

    public static void Main()
    {
        int a = 0, b = 0, c = 0;
        InLine(ref a, ref b, ref c);
        if ((a == b || b == c || a == c) && !(a == b && b == c)) OutYes();
        else OutNo();
    }

  	//Template
    private static object[] nullobjs = null;
    private static object nullobj = null;

    public static int ConvertInt(char c)
    {
        return c;
    }

    public static void InArgs<A>(int count, ref A[] var)
    {
        InArgs(count, ref var, ref nullobjs, ref nullobjs);
    }

    public static void InArgs<A, B>(int count, ref A[] var1, ref B[] var2)
    {
        InArgs(count, ref var1, ref var2, ref nullobjs);
    }

    public static void InArgs<A, B, C>(int count, ref A[] var1, ref B[] var2, ref C[] var3)
    {
        A a = default(A);
        B b = default(B);
        C c = default(C);
        for (int i = 0; i < count; i++)
        {
            InLine(ref a, ref b, ref c);
            var1[i] = a;
            if (var2 != null) var2[i] = b;
            if (var3 != null) var3[i] = c;
        }
    }

    public static void InLine<A>(ref A var)
    {
        InLine(ref var, ref nullobj, ref nullobj);
    }

    public static void InLine<A, B>(ref A var1, ref B var2)
    {
        InLine(ref var1, ref var2, ref nullobj);
    }

    public static void InLine<A, B, C>(ref A var1, ref B var2, ref C var3)
    {
        object[] o = new object[] { var1, var2, var3 };
        Type[] t = new Type[] { typeof(A), typeof(B), typeof(C) };
        if (var3 == null)
        {
            if (var2 == null) o = new object[] { var1 };
            else o = new object[] { var1, var2 };
        }

        string[] s = Console.ReadLine().Split(' ');
        for (int i = 0; i < s.Length; i++)
        {
            if (typeof(int) == t[i]) o[i] = int.Parse(s[i]);
            else if (typeof(long) == t[i]) o[i] = long.Parse(s[i]);
            else if (typeof(double) == t[i]) o[i] = double.Parse(s[i]);
            else o[i] = s[i];
        }
        var1 = (A)o[0];
        if (var2 != null) var2 = (B)o[1];
        if (var3 != null) var3 = (C)o[2];
    }

    public static string JoinString(object[] obj, string sep)
    {
        return string.Join(sep, obj.Select(i => i.ToString()).ToArray());
    }

    public static void Out(object o)
    {
        Console.WriteLine(o);
    }

    public static void OutYes()
    {
        Console.WriteLine("Yes");
    }

    public static void OutNo()
    {
        Console.WriteLine("No");
    }
    public static void OutYES()
    {
        Console.WriteLine("YES");
    }

    public static void OutNO()
    {
        Console.WriteLine("NO");
    }

    private static Dictionary<A, B> PutDict<A, B>(A[] key, B[] value)
    {
        if (key.Length != value.Length) return null;
        var dic = new Dictionary<A, B>();
        for (int i = 0; i < key.Length; i++)
        {
            if (!dic.ContainsKey(key[i])) dic.Add(key[i], value[i]);
            else dic[key[i]] = value[i];
        }
        return dic;
    }
}

Measured memory_bytes: 13268
#include <iostream>

using namespace std;

int main(){
  
  int a , b , c;
  int x=0;
  cin >> a >> b >> c;
  
  for(int i=a ; i<=b ; i++){
    
    if(c % i == 0){ 
      x++;
    }
    
  }
  
  cout << x << endl;
}


Measured memory_bytes: 3112
n,m,x,y = map(int,input().split())
l1 = list(map(int,input().split()))
l2 = list(map(int,input().split()))
l1.sort()
l2.sort()
for i in range(x+1,y+1):
  if l1[-1] < i <= l2[0]:
    print("No War")
    exit()
print("War")


Measured memory_bytes: 3060
import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10**9)
INF = 10**19
MOD = 10**9 + 7
EPS = 10**-10

class BIT:
    """ Binary Indexed Tree """

    def __init__(self, n):
        self.n = n
        # 0-indexed
        n += 1
        nv = 1
        while nv < n:
            nv *= 2
        self.size = nv
        self.tree = [0] * nv

    def sum(self, i):
        """ [0, i]を合計する """
        s = 0
        i += 1
        while i > 0:
            s += self.tree[i-1]
            i -= i & -i
        return s

    def add(self, i, x):
        """ 値の追加：添字i, 値x """
        i += 1
        while i <= self.size:
            self.tree[i-1] += x
            i += i & -i

    def query(self, l, r):
        """ 区間和の取得 [l, r) """
        return self.sum(r-1) - self.sum(l-1)
    
    def get(self, i):
        """ 一点取得 """
        return self.query(i, i+1)

    def update(self, i, x):
        """ 値の更新：添字i, 値x """
        self.add(i, x - self.get(i))

    def print(self):
        for i in range(self.n):
            print(self.get(i), end=' ')
        print()

N, Q = MAP()
A = LIST()
bit = BIT(N)
for i in range(N):
    bit.add(i, A[i])

for i in range(Q):
    q, a, b = MAP()

    if q == 0:
        bit.add(a, b)
    else:
        ans = bit.query(a, b)
        print(ans)


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

int main(){
    int N, M; cin >> N >> M;
    vector<int> A(M);
    vector<string> dp(N+1); // dp[i] := iほん使って作れる最大の数
    map<int,int> MP;
    MP[1] = 2, MP[2] = 5, MP[3] = 5,MP[4] = 4, MP[5] = 5,
    MP[6] = 6, MP[7] = 3, MP[8] = 7, MP[9] = 6;

    for(int i = 0; i < M; i++) cin >> A[i];
    
    for (int i = 1; i <= N; i++){
        for(auto e: A){
            if(i >= MP[e]){
                if(dp[i - MP[e]].size() + 1 == dp[i].size()){
                    if((dp[i - MP[e]].empty() && i - MP[e] == 0) || !dp[i-MP[e]].empty()){
                        string t = {(char)(e + '0')};
                        string tS = dp[i - MP[e]] + t;
                        sort(tS.begin(), tS.end(), greater<char>());
                        dp[i] = max(dp[i], tS);
                    }
                }
                else if(dp[i - MP[e]].size() + 1 > dp[i].size()){
                    if((dp[i - MP[e]].empty() && i - MP[e] == 0) || !dp[i-MP[e]].empty()){
                        string t = {(char)(e + '0')};
                        string tS = dp[i - MP[e]] + t;
                        sort(tS.begin(), tS.end(), greater<char>());
                        dp[i] = tS;
                    }
                }
            }
        }
    }
    //for(int i = 0; i < N; i++) cout << i << " " << dp[i] << endl;
    cout << dp[N] << endl;
    
    
    
}

Measured memory_bytes: 25344
/* ----------------------- reclone_rk -------------------------*/ 
#include<bits/stdc++.h>
using namespace std;
#define int long long int
const int mod=1e9+7;

int gcd(int a, int b){ if(a == 0) return b; return gcd(b%a, a);}
int MOD(int n){ return ((n%mod)+mod)%mod;}
int power(int a,int b){ if(b==0)return 1LL;int s=power(a,b/2LL);s*=s;s%=mod;if(b&1LL)return (s*a)%mod;return s;}
int inv(int a){return power(a,mod-2);}
int nCr(int n,int r){if(r>n)return 0LL;if(n-r<r)r=n-r;int ans=1;for(int i=0;i<r;i++){ans*=(n-i);ans=MOD(ans);ans*=inv(i+1);ans=MOD(ans);}return ans;}
 
signed main()
{
	int n, k;
	cin>>n>>k;
	int val = n%k;
	cout<<min(abs(val), abs(val-k))<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <iomanip>
using namespace std;


int main() {
  int n;
  int h[30];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int ans = 0;

  int max_h[30];
  max_h[0] = 0;
  for (int i = 1; i < n; i++) {
    max_h[i] = max(max_h[i-1], h[i-1]);
  }

  for (int i = 0; i < n; i++) {
    if (h[i] >= max_h[i]) {
      ans++;
    }
  }

  cout << ans << endl;
}


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

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



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		// 自分の得意な言語で
		// Let's チャレンジ！！

		Scanner sc = new Scanner(System.in);

		String s = sc.next();

		String str = "";
		for (int i = 0; i < s.length(); i++) {
			str = str + "x";
		}

		System.out.println(str);

	}

}

Measured memory_bytes: 22612
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;

int main()
{
  int n;
  int sum = 0;
  cin >> n;
  int d[n];
  for(int i =0; i<n ;++i){
    cin >> d[i];
    sum += d[i];
  }
  sum = sum*sum;
  for(int i =0; i<n ;++i){
    sum -= d[i]*d[i];
  }
  sum /= 2;
  cout << sum << endl;
}

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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

constexpr llong mod = 1e9+7;
constexpr llong inf = mod * mod;

llong moduro(llong n) {
  if (n > 0) {
    return n % mod;
  }
  else {
    return n + (-n / mod + 1) * mod;
  }
}

int main() {
  llong N, K, zero = 0;
  vector<llong> A, plus, minus;

  cin >> N >> K;
  A.resize(N);
  for (auto &in: A) {
    cin >> in;
    if (in > 0) {
      plus.push_back(in);
    }
    else if (in < 0) {
      minus.push_back(in);
    }
    else {
      zero++;
    }
  }

  llong ans = 1;
  if (plus.size() == 0) {
    if (minus.size() < K) {
      ans = 0;
    }
    else if (K % 2 == 0) {
      sort(ALL(minus));
      for (int i = 0; i < K; ++i) {
        ans = moduro(ans * minus[i]);
      }
    }
    else if (zero > 0) {
      ans = 0;
    }
    else {
      sort(ALL(minus), greater<>());
      for (int i = 0; i < K; ++i) {
        ans = moduro(ans * minus[i]);
      }
    }
  }
  else if (minus.size() + plus.size() < K) {
    ans = 0;
  }
  else if (minus.size() + plus.size() == K) {
    if (minus.size() % 2 == 0) {
      for (auto m: minus) {
        ans = moduro(ans * m);
      }
      for (auto p: plus) {
        ans = moduro(ans * p);
      }
    }
    else {
      if (zero > 0) {
        ans = 0;
      }
      else {
        for (auto m: minus) {
          ans = moduro(ans * m);
        }
        for (auto p: plus) {
          ans = moduro(ans * p);
        }
      }
    }
  }
  else {
    sort(ALL(plus), greater<>());
    sort(ALL(minus));
    int pid = 0, mid = 0;
    for (int i = 0; i < K; ++i) {
      if (mid < int(minus.size()) - 1 && i < K - 1) {
        if (pid >= int(plus.size() - 1)) {
          ans = moduro(ans * moduro(minus[mid] * minus[mid + 1]));
          mid += 2;
          i += 1;
        }
        else {
          llong pp = plus[pid] * plus[pid + 1];
          llong mm = minus[mid] * minus[mid + 1];
          if (pp > mm) {
            ans = moduro(ans * moduro(pp));
            pid += 2;
          }
          else {
            ans = moduro(ans * moduro(mm));
            mid += 2;
          }
          i += 1;
        }
      }
      else {
        ans = moduro(ans * plus[pid++]);
      }
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6796
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double PI=acos(-1.0);
#define eps (1e-10)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    bool operator != (const Point &p) const{return !(fabs(x-p.x)<eps && fabs(y-p.y)<eps);}
    double arg(){return atan2(y,x);}
    double arg2(){double d=atan2(y,x);return d>=0?d:d+2.0*PI;}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
struct Circle{
    double r;
    Point p;
    Circle(){}
    Circle(Point p,double r):p(p),r(r){}
};
bool isIntersectCC(Circle c1,Circle c2){
    return (c1.p-c2.p).abs()<=c1.r+c2.r+eps;
}
pair<Point,Point> CrossPointsCC(Circle c1,Circle c2){
    assert(isIntersectCC(c1,c2));
    double d=(c1.p-c2.p).abs();
    double k=acos((d*d+c1.r*c1.r-c2.r*c2.r)/(c1.r*d*2));
    return make_pair(c1.p+(c2.p-c1.p)*Point(cos(k),sin(k))*(c1.r/d),c1.p+(c2.p-c1.p)*Point(cos(-k),sin(-k))*(c1.r/d));
}
int n;
Point p[51];
bool test(double r){
    Point c1,c2;
    rep(i,n)FOR(j,i+1,n){   
        if(!isIntersectCC(Circle(p[i],r),Circle(p[j],r))) return false;
        tie(c1,c2)=CrossPointsCC(Circle(p[i],r),Circle(p[j],r));
        bool flag=true;
        rep(k,n){
            if((c1-p[k]).abs()>=r+eps){
                flag=false;break;
            }
        }
        if(flag) return true;
        flag=true;
        rep(k,n){
            if((c2-p[k]).abs()>=r+eps){
                flag=false;break;
            }
        }
        if(flag) return true;
    }
    return false;
}
int main(){
    cin>>n;
    double xi,yi;
    rep(i,n) cin>>xi>>yi,p[i]=Point(xi,yi);
    double l=0,r=4000;
    rep(ii,70){
        double mid=(l+r)/2;
        if(test(mid)) r=mid;
        else l=mid;
    }
    cout<<setprecision(10)<<fixed<<r<<endl;
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int check(char *s,int n){
    int i;

    for(i=0;i<n/2;i++){
        if(s[i]==s[n-1-i]){

        }else{
            return 1;
        }
    }
    for(i=0;i<n/4;i++){
        if(s[i]==s[(n-1)/2-1-i]){

        }else{
            return 1;
        }
    }
    for(i=0;i<n/4;i++){
        if(s[(n+3)/2-1+i]==s[n-1-i]){

        }else{
            return 1;
        }
    }
    return 0;
}

int main(void){
    char s[100];
    scanf("%s",s);
    int s_len=strlen(s);

    int result=check(s,s_len);
    if(!result){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}


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

//operand, level
vector<pair<string, int> > v;

int main(){
while(1){//start	
	
	int n;
	cin >> n;
	if(n == 0) break;
	int max_level = 0;
	for(int i = 0; i < n; i++){
		string tmp;
		cin >> tmp;
		//count level and push
		int cnt = 0;
		for(int j = 0; j < (int)tmp.size(); j++){
			if(tmp[j] == '.') cnt++;
		}
		v.push_back(make_pair(string() + tmp[(int)tmp.size() - 1], cnt));
		max_level = max(max_level, cnt);
	}


	reverse(v.begin(), v.end());


	while(max_level > 0){
		//get head and tail, make que
		//for(int i = 0; i < (int)v.size(); i++) cout << v[i].first << " " << v[i].second << endl;
		//cout << "max_level = " << max_level << endl;
		//cout << "vec_size = " << v.size() << endl;
		int del_head = -1;
		int del_tail;
		int flag = 0;
		queue<int> que;
		string operand;
		for(int i = 0; i < (int)v.size(); i++){
			if(del_head == -1 and v[i].second == max_level){
				del_head = i;
				que.push(stoi(v[i].first));
				//cout << "ok 1 = " << i << endl;
			}
			else if(v[i].second == max_level){
				que.push(stoi(v[i].first));
				flag = 1;
				//cout << "ok 2 = " << i << endl;
			}
			else if(v[i].second == max_level - 1 and flag){
				operand = v[i].first;
				del_tail = i; //modified
				//cout << "ok 3 = " << i << endl; 
				break;
			}
		}
		//cout << "head = " << del_head << endl;
		//cout << "tail = " << del_tail << endl;
//NTpmDM02
		//cout << "TEST !" << endl;
		v.erase(v.begin() + del_head, v.begin() + del_tail);
		
		//cout << "erased_size = " << v.size() << endl;

		//make place_holder
		int place_holder;
		if(operand == "+") place_holder = 0;
		else if(operand == "*") place_holder = 1;

		while(que.size()){
			//cout << "que_size = " << que.size() << endl;
			int x = que.front();
			//cout << "x = " << x << endl;
			que.pop();
			if(operand == "+") place_holder += x;
			else if(operand == "*") place_holder *= x;
		}
		v[del_head] = make_pair(to_string(place_holder), max_level - 1);
		//cout << place_holder << endl;
		//max_level--;
		//get max_level
		max_level = 0;
		for(int i = 0; i < (int)v.size(); i++) max_level = max(max_level, v[i].second);
	}
	
	cout << v[0].first << endl;
	v.clear();
}//end

	return 0;
}



Measured memory_bytes: 3256
n = int(raw_input())
a = [int(_) for _ in raw_input().split()]

i = n - 1
while i >= 0:
    print a[i],
    i -= 2
if i == -1:
    i = 0
else:
    i = 1
while i < n - 2:
    print a[i],
    i += 2
if n != 1:
    print a[n - 2]


Measured memory_bytes: 21084
/*
@author: sharrad99
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define	PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pll pair<ll,ll>
#define vll vector<ll>
#define vbl vector<bool>
#define vpll vector<pll>
#define pb push_back
#define eb emplace_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define all(x) x.begin(),x.end()
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (a * b) / gcd(a, b)
#define mod 1000000007
#define INF 1000000000000000
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef tree<pll, null_type, less<pll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set_pll;
#define ook order_of_key
#define fbo find_by_order
/*  
	Query 1 - order_of_key(k) : Number of items strictly smaller than k.
	Query 2 - find_by_order(k) : K-th element in the set (counting from zero).
	less<ll> means Query 1 will return numbers strictly less than k.
	greater<ll> means Query 1 will return numbers strictly greater than k.
*/
ll powmod(ll x, ll n){
	ll res = 1;
	while(n){
		if(n & 1){
			res *= x;
			res %= mod;
		}
		x *= x;
		x %= mod;
		n >>= 1;
	}
	return res;
}
ll invmod(ll a){
	return powmod(a, mod - 2);
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll a, b;
	cin >> a >> b;
	cout << 6 - a - b;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	durs := make([]int, 0)
	for i := 0; i < 5; i++ {
		var t int
		fmt.Scan(&t)
		durs = append(durs, t)
	}

	minRem := 9
	minRemIdx := 0
	for i := 0; i < 5; i++ {
		r := durs[i] % 10
		if r < minRem && r != 0 {
			minRem = r
			minRemIdx = i
		}
	}

	time := 0
	for i := 0; i < 5; i++ {
		if i != minRemIdx {
			if durs[i] % 10 == 0 {
				time += durs[i]
			} else {
				time += (durs[i] / 10) * 10 + 10
			}
		} else {
			time += durs[i]
		}
	}
	fmt.Println(time)
}

Measured memory_bytes: 512
#ifdef DEBUG_IS_VALID
#define DEB 1
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include <bits/stdc++.h>
using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(long long i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(long long i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#define fi first
#define se second
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void solve();
int main(void) {
  std::cout << std::fixed << std::setprecision(15);
  solve();
	return 0;
}

using Int = long long;
using ll = long long;
using P = pair<Int,Int>;
using vi = vector<Int>;
using vvi = vector<vi>;
using vp = vector<P>;
using vvp = vector<vp>;

const Int INF = (1<<30)-10;

void solve(){
  Int N; cin >> N;
  vi a(N), s(2*N+1); rep(i, N) cin >> a[i];
  Int ok = 0, ng = accumulate(ALL(a), 0LL);
  // copy(a.begin(), a.end(), back_inserter(a));
  rep(i, N) a.pb(a[i]);
  rep(i, 2*N) s[i+1] = s[i] + a[i]; 
  while(abs(ok - ng) > 1){
    Int mid = (ok + ng) / 2;
    bool chk = false;
    rep(x, N){
      Int y, z;
      Int temp = s[x] + mid;
      // [x, y), [y, z), [z, x)
      y = Int(lower_bound(ALL(s), temp) - s.begin());
      if(y == 2*N + 1) continue;
      temp = s[y] + mid;
      z = Int(lower_bound(ALL(s), temp) - s.begin());
      if(z == 2*N + 1) continue;
      temp = s[x + N] - s[z];
      if(temp < mid) continue;
      chk = true;
      break;
    }
    if(chk) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}


Measured memory_bytes: 6108
#include <iostream>
#include <algorithm>
using namespace std;
const int N_MAX = 100;
int main (void) {
    int N;
    int s[N_MAX];
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> s[i];
        ans += s[i];
    }

    sort(s, s + N);

    if (ans % 10 == 0) {
        for (int i = 0; i < N; i++) {
            if (s[i] % 10 != 0) {
                cout << ans - s[i] << endl;
                return 0;
            }
        }
        cout << 0 << endl;
    } else {
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
//        DecimalFormat df = new DecimalFormat("0.00000000");

        final int N = Integer.parseInt(sc.next());
        final int K = Integer.parseInt(sc.next());
        int sum = 0;
        for (int i = 0; i < N; i++) {
            int x = Integer.parseInt(sc.next());
            sum += Math.min(x * 2, Math.abs(x - K) * 2);
        }
        out.println(sum);

        out.flush();
    }
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(long long int i=a;i<b;i++)
#define f(i,n) for(long long int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define vint vector<int>
#define vll vector<long long int>
#define pb(a) push_back(a);
#define bug(x) cout<<#x<<" = "<<x<<"\n";
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)

long int dp[101][100002];
const int M = 1000000007;

int main(){
	fastio;
	ll n,k; cin>>n>>k;
	vll a(n);
	f(i,n){cin>>a[i];}
	// memset(dp,0,sizeof(dp));
	vll pre(k+1);
	pre[0]=1;
	ll sum = 0;
	f(i,n+1){
		if(i!=0){sum+=a[i-1];	if(sum>k) sum=k;}
		f(j,k+1){
			// cout<<"i="<<i<<" j="<<j<<" sum="<<sum;
			if(j==0){
				dp[i][j]=1;
			}
			else if(i==0){// || sum<j){
				// cout<<" ~ ";
				dp[i][j]=0;
				// cout<<"("<<dp[i][j]<<") ";
			}
			else{
				dp[i][j] = pre[j]%M;
				// cout<<"("<<dp[i][j]<<") ";
				if(j-a[i-1]-1>=0){
					dp[i][j]+=(M-pre[j-a[i-1]-1])%M; dp[i][j]%=M;
				}
			}
			// cout<<dp[i][j]<<" ";
		}
		// cout<<"\nprinting pre\n";
		// cout<<pre[0]<<" ";
		// if(i>=1)pre[0] = dp[i-1][0];
		F(j,1,k+1){
			pre[j] = (pre[j-1]+dp[i][j])%M;
			// cout<<pre[j]<<" ";
		}
		// cout<<"\n";
	}
	cout<<dp[n][k]<<"\n";
	return 0;
}

Measured memory_bytes: 82912
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    cnt=0
    n=int(input())
    l=list(map(int,input().split()))
    lsort=sorted(l)
    for i in range(n):
        if l[i]!=lsort[i]:
            cnt+=1
    if cnt==0 or cnt==2:
        print('YES')
    else:
        print('NO')
resolve()

Measured memory_bytes: 3060
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <functional>
using namespace std;
using ll = long long;

ll n, k, a[200010];
vector<ll> neg, pos, z;
ll ncount(ll v) {
	ll count = 0;
	for (int i = 0; i < neg.size(); i++)
		//neg[i] * pos[x] <= v <=> pos[x] >= v / neg[i]
		count += pos.end() - lower_bound(pos.begin(), pos.end(), (v + neg[i] + 1) / neg[i]);
	return count;
}
void negative() {
	ll low = (ll)-1e18, upp = 0, cen = (low + upp) / 2, v;
	while (2 <= upp - low) {
		if (ncount(cen) < k)
			low = cen;
		else
			upp = cen;
		cen = (low + upp) / 2;
	}
	printf("%lld\n", upp);
}
ll pcount(ll v) {
	ll count = 0;
	for (int i = 0; i < pos.size(); i++)
		//pos[i]*pos[x] <= v <=> pos[x] <= v / pos[i]
		count += upper_bound(pos.begin(), pos.end(), v / pos[i]) - pos.begin() - (pos[i]*pos[i] <= v);
	for (int i = 0; i < neg.size(); i++)
		//pos[i]*pos[x] <= v <=> pos[x] <= v / pos[i]
		count += upper_bound(neg.begin(), neg.end(), v / neg[i]) - neg.begin() - (neg[i]*neg[i] <= v);
	return count / 2;
}
void positive() {
	for (int i = 0; i < neg.size(); i++)
		neg[i] = -neg[i];
	ll low = 1, upp = ((ll)1e18)+1ll, cen = (low + upp) / 2;
	while (2 <= upp - low) {
		if (pcount(cen) < k)
			low = cen;
		else
			upp = cen;
		cen = (low + upp) / 2;
	}
	printf("%lld\n", upp);
}
int main() {
	scanf("%lld %lld", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", a + i);
		if (a[i] < 0)
			neg.emplace_back(a[i]);
		else if (0 < a[i])
			pos.emplace_back(a[i]);
		else
			z.emplace_back(a[i]);
	}
	sort(neg.begin(), neg.end(), greater<>());
	sort(pos.begin(), pos.end());
	ll nc = ((ll)neg.size()) * pos.size();
	ll zc = ((ll)z.size()) * (neg.size() + pos.size()) + ((ll)z.size()) * (z.size() - 1) / 2;
	if (k <= nc)
		negative();
	else if (k <= nc + zc)
		printf("0\n");
	else
		k -= nc + zc, positive();
}

Measured memory_bytes: 3700
from heapq import heappop, heappush

n = int(input())
a = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    a[u - 1].append((v - 1, w))
    a[v - 1].append((u - 1, w))
d = [-1] * n
todo = [(0, 0)]
seen = set()
while todo:
    e, p = heappop(todo)
    if p in seen:
        continue
    seen.add(p)
    d[p] = e
    for pi, ei in a[p]:
        heappush(todo, (e + ei, pi))
for di in d:
    print(di % 2)


Measured memory_bytes: 52456
#include <bits/stdc++.h>
using namespace std;
int chk(vector<string>,int,int,int,int);
int main() {
  int H,W;
  cin >> H >> W;
  vector<string> S(H);
 
  for (int i = 0; i < H; i++) {
    cin >> S.at(i);
  }
  
  for (int i = 0; i < H; i++) {
    for(int j = 0; j < W; j++){
      if(S.at(i)[j] == '.'){
        cout << chk(S,i,j,H,W);      
      }else{
        cout << S.at(i)[j];
      }
    }
    cout << endl;
  }
}

int chk(vector<string> S, int y, int x,int H, int W){
  int cnt = 0;
  if(x > 0){
    if(y > 0 && S.at(y-1)[x-1] == '#') cnt++;
    if(y + 1 < H && S[y+1][x-1] == '#')cnt++;
    if(S[y][x-1] == '#')cnt++;
  }
  if(x + 1 < W){
    if(y > 0 && S.at(y-1)[x+1] == '#') cnt++;
    if(y + 1 < H && S[y+1][x+1] == '#')cnt++;
    if(S[y][x+1] == '#')cnt++;
  }
  if(y > 0 && S.at(y-1)[x] == '#') cnt++;
  if(y + 1 < H && S[y+1][x] == '#')cnt++;
  
  return cnt; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
multiset<int> st;
vector<int> vec;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, tmp;
	cin >> n;
	int bound = 1 << n;
	for (int i = 0; i < bound; ++i) {
		cin >> tmp;
		st.insert(-1 * tmp);
	}
	bool flag = true;
	vec.push_back(*st.begin());
	st.erase(st.begin());
	while (!st.empty() && flag) {
		vector<int> newv;
		for (int i = 0; i < vec.size() && flag; ++i) {
			auto ptr = st.upper_bound(vec[i]);
			if (ptr == st.end())
				flag = false;
			else {
				newv.push_back(*ptr);
				st.erase(ptr);
			}
		}
		for (int i = 0; i < newv.size(); ++i)
			vec.push_back(newv[i]);
		sort(vec.begin(), vec.end());
	}
	if (flag)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 13984
#include <iostream>
#include <cmath>
#include <cstring>
#define INF INT_MAX / 2
#define rep(i, s, n) for(int i = s; i < (int)n; ++i)

using namespace std;

int N, K;

int mypow(const int n, const int p) {
        int tmp = 1;
        rep(i, 0, p) tmp *= n;
        return tmp;
}

int main() {
        cin >> N >> K;
        int p = 0;

        while (N % mypow(K, p) != N) {
                ++p;
        }
        cout << p;
}


Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

totalA = sum(A)
while totalA > K:
    totalA -= A.pop()
ans = len(A)

totalB = 0
for i in range(M):
    totalB += B[i]
    while totalA + totalB > K:
        if not A:
            break
        totalA -= A.pop()
    if totalA + totalB <= K:
        ans = max(ans, len(A) + i + 1)

print(ans)


Measured memory_bytes: 40512
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	int ans=1,n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
	{
		if(ans<=k) ans*=2;
		else
		{
			if(ans>k) ans+=k;
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

int n, k;
int ans;

int main()
{
    cin.tie(0); ios_base::sync_with_stdio(false);
    cin >> n >> k;
    forn(i, n)
    {
        int x;
        cin >> x;
        if(x>=k) ans++;
    }
    cout << ans << endl;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define has(c,i) ((c).find(i) != end(c))
#define DBGDO(X) ({ if(1) cerr << "DBGDO: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, a, b, c, d;
	cin >> n >> a >> b >> c >> d;
	n--;

	bool ok = false;
	FOR(k,0,n+1) {
		ll xmin = a + k*c - (n-k)*d, xmax = a + k*d - (n-k)*c;
		if (xmin > xmax) swap(xmin,xmax);
	//	cerr << xmin << " " << xmax << endl;
		if (xmin <= b && b <= xmax) ok = true;
	}

	cout << (ok ? "YES" : "NO") << endl;
}



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

int main() {
    string S, T;
    cin >> S >> T;

    int cnt = 0;

    for (int i = 0; i < 3; i++)
    {
        if (S.at(i) == T.at(i)) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define endl "\n"
#define mod 1000000007
#define pb push_back
#define mp make_pair
using namespace std;

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

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	ll t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 3612
it = lambda: list(map(int, input().strip().split()))
INF = float('inf')


def solve():
    N = int(input())
    S = []
    C = []
    for _ in range(N):
        s, c = input().strip().split()
        S.append(s)
        C.append(int(c))
    
    vis = set()
    mem = dict()

    def dp(s, p):
        if (s, p) in mem:
            return mem[s, p]

        if s == s[::-1]:
            return 0

        if (s, p) in vis:
            return INF

        vis.add((s, p))

        ans = INF
        if p == 0:
            for i in range(N):
                if len(S[i]) >= len(s):
                    if S[i][::-1].startswith(s):
                        ans = min(ans, dp(S[i][:-len(s)], 1) + C[i])
                else:
                    if s.startswith(S[i][::-1]):
                        ans = min(ans, dp(s[len(S[i]):], 0) + C[i])
        else:
            for i in range(N):
                if len(S[i]) >= len(s):
                    if S[i].startswith(s[::-1]):
                        ans = min(ans, dp(S[i][len(s):], 0) + C[i])
                else:
                    if s[::-1].startswith(S[i]):
                        ans = min(ans, dp(s[:-len(S[i])], 1) + C[i])

        vis.discard((s, p))
        mem[s, p] = ans
        return ans
        
    ans = INF
    for i in range(N):
        ans = min(ans, dp(S[i], 0) + C[i])
    return -1 if ans == INF else ans


if __name__ == '__main__':
    ans = solve()
    print(ans)

Measured memory_bytes: 9316
#include <iostream>
#include <sstream>
#include <queue>
#include <map>
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <string>
#include <complex>
 
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstdio>
#include <cstring>
 
#define REP(i,e) for(int i=0;i<(int)(e);i++)
#define FOR(i,b,e) for(int i=(int)(b);i<(int)(e);i++)
#define ALL(c) (c).begin(), (c).end()
#define EACH(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define RALL(c) (c).rbegin(), (c).rend()
#define ALLA(a,n) ((a)+0), ((a)+n)
 
using namespace std;
 
typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<string> vstring;
typedef vector<double> vdouble;
 
template<class T>void pp(T v,int n){ REP(i,n)cout<<v[i]<< ' ' ; cout << endl; }
template<class T>void pp(T v){ EACH(it,v) cout << *it << ' ' ; cout << endl;  }
template<class T>T& ls(T& a,T b){ if(b<a) a=b; return a; }
template<class T>T& gs(T& a,T b){ if(b>a) a=b; return a; }
inline ll to_i(const string& s){ll n;sscanf(s.c_str(),"%lld",&n);return n;}
inline string to_s(ll n){char buf[32];sprintf(buf,"%lld",n);return string(buf);}

int popcount(int n) {
  int result = 0;
  while (n) {
    result += (n & 1);
    n >>= 1;
  }
  return result;
}

int main() {
  int n, m;
  while (cin >> n >> m && n && m) {
    vint v(m);
    vint p(m);
    REP(i,m) {
      int k; cin >> k;
      REP(j,k) {
        int t; cin >> t; t--;
        v[i] = v[i] | (1 << t);
      }
    }
    REP(i,m) {
      cin >> p[i];
    }

    int result = 0;
    REP(i,1<<n) {
      bool ok = true;
      REP(j,m) {
        int st = popcount(i & v[j]);
        if (st % 2 != p[j]) ok = false;
      }

      if (ok) result++;
    }

    cout << result << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector <int> a(n),b(n),c(n-1); 
	for (int i=0; i<n; i++) cin>>a[i];
	for (int i=0; i<n; i++) cin>>b[i];
	for (int i=0; i<n-1; i++) cin>>c[i];
	int ret=0;
	for (int i=0; i<n; i++) 
		ret+=b[a[i]-1];
	for (int i=1; i<n; i++) 
		if (a[i]==a[i-1]+1)
			ret+=c[a[i-1]-1];
	cout<<ret<<endl;
	return 0;
}


Measured memory_bytes: 256
// C++ program to print all primes smaller than or equal to 
// n using Sieve of Eratosthenes 
#include<stdio.h>
#include<math.h>
int z=0;
int arr[1500000];
int prime[1500000+1]; 
int heili(long long int c)
{
    for(int i=2;i<sqrt(c);i++)
    if(c%i==0)return 1;
    
    return 0;
}

void SieveOfEratosthenes(int n) 
{ 
	// Create a boolean array "prime[0..n]" and initialize 
	// all entries it as true. A value in prime[i] will 
	// finally be false if i is Not a prime, else true. 
	

	for (int p=2; p*p<=n; p++) 
	{ 
		// If prime[p] is not changed, then it is a prime 
		if (prime[p] == 0) 
		{ 
			// Update all multiples of p 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = 1; 
		} 
	} 


} 

// Driver Program to test above function 
int main() 
{ 
	int a,n = 1500000; 
	long long int c;
	int x=0;

	SieveOfEratosthenes(n); 
	//printf("%d",z);
	scanf("%d",&a);
	while(a--)
	{
	    scanf("%lld",&c);
	    if(c<=1500000&&prime[c]==0)x++;
	   
	    else if(c>1500000&&heili(c)==0)x++;
	    
	}
	printf("%d\n",x);
	return 0; 
} 



Measured memory_bytes: 8548
N,D=map(int,input().split())
xy=[map(int,input().split()) for _ in range(N)]
x,y=[list(i) for i in zip(*xy)]
a=0

for i in range(N):
  if ( x[i]*x[i] + y[i]*y[i] <= D*D):
    a=a+1
    
print(a)

Measured memory_bytes: 116752
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define INF 2000000000
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int h, n, i = 0;
	cin >> h >> n;
	vector<pair<int, int>>vec(n);
	rep(i, n) {
		cin >> vec[i].first >> vec[i].second;
	}
	vector<int>DP(100000000,0);//魔力をiとしDP[i]をダメージとする
	DP[0] = 0;
	while(1) {
		i++;
		rep(j, n) {
			if (i - vec[j].second >= 0) {
				DP[i] =max(DP[i],DP[i - vec[j].second] + vec[j].first);
				if (DP[i] >= h) {
					cout << i << endl;
					return 0;
				}
			}
		}
	}
}




Measured memory_bytes: 781568
r, g, b, n = gets.split.map(&:to_i)

ans = 0
(0..(n/r)).each do |rr|
  next if rr*r > n
  (0..(n/g)).each do |gg|
    next if rr*r + gg*g > n
    ans += 1 if ((n - rr*r - gg*g) % b).zero?
  end
end

puts ans

Measured memory_bytes: 1788