akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define isFile 0
#define NAME "taskA"
#define scan 1
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

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

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pii> vpii;

#define mp make_pair
#define pb push_back
#define fr first
#define sc second

#define ins insert
#define all(v) v.begin(), v.end()
#define rep(i,a,n) for (int i=a;i<n;i++)
#define bit(n, i) (n >> i) & 1
#define bpc(x) __builtin_popcountll(x)
#define rev(a) reverse(all(a))
#define skip continue
#define read(a) for(auto &i : a) cin >> i
#define print(a) for(auto i : a) cout << i << ' '
#define unique(a) sort(all(a));    a.resize(unique(all(a)) - a.begin())

//                D  R  U   L
const int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
const int dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
const int day[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

void faster() {
    if (isFile) {
        freopen(NAME".in", "r", stdin);
        freopen(NAME".out", "w", stdout);
    }
    if (scan) {
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
    }
}

const ll  INF = 1e18;
const int inf = 2e9;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const ld  PI = acos(-1);
const ld  EPS = 3E-16;
const int ALPHA = 26;
const int N = (int)2e5 + 5;
const int M = 123;

ll cnt[N];

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }

    ll ans = 0;
    for(int i = 1; i <= n; i++)
        ans += cnt[i] * (cnt[i] - 1) / 2;

    for(int i = 0; i < n; i++) {
        int t = a[i];
        cout << max(0ll, ans - (cnt[t] * (cnt[t] - 1) / 2) + (cnt[t] - 1) * (cnt[t] - 2) / 2) << endl;
    }

}

int main() {
    faster();
    int t = 1;
//    cin >> t;
    while(t--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3968
from itertools import product
inpl = lambda: list(map(int,input().split()))
H, W, K = inpl()
c = [input() for _ in range(H)]

ans = 0
for p in product(range(2),repeat=H):
    for q in product(range(2),repeat=W):
        num = 0
        for h in range(H):
            if p[h]:
                continue
            for w in range(W):
                if q[w]:
                    continue
                if c[h][w] == '#':
                    num += 1
                    if num > K:
                        break
            else:
                continue
            break
        else:
            if num == K:
                ans += 1
print(ans)


Measured memory_bytes: 68464
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func divFloor(a, b int) int {
	return (a + (b - 1)) / b
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()

	puts(divFloor(n, 1000)*1000 - n)
}


Measured memory_bytes: 1780
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;

int main()
{
  string s;
  int k;
  cin >> s;
  int i, j;
  k = s.length();
  int win = 0;
  for (i = 0; i < k; i++) {
    if (s[i] == 'o')
      win++;
  }
  int rest = 15 - k;
  if (rest + win >= 8)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stdio.h>
#include<cstring>
#include<math.h>
#include<map>
#include<bitset>
#include<iomanip>
#include<queue>
#include<functional>
#include<stack>
#include<tuple>
#include<cassert>
using namespace std;

#define rep(i, n) for (long long i = 0; i < (long long)(n); ++i)
using P = pair<long long, long long>;

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

int main() {
  long long x, y;
  cin >> x >> y;
  long long d;
  d = gcd(x, y);

  long long k = d;
  long long count = 0;
  for(long long i = 2; i * i <= k; i++) {
    if(d % i == 0) count++;
    while(d % i == 0) {
      d /= i;
    }
  }
  if(d != 1) count++;

  cout << count + 1 << endl; 

  return 0;
}

Measured memory_bytes: 3644
package main

import (
	"bufio"
	"fmt"
	"io"
	"math"
	"os"
	"strconv"
	"strings"

)


func main() {
	solve(os.Stdin, os.Stdout)
}

type ReaderEx struct {
	baseScanner *bufio.Scanner
	words       []string
	nextWordIdx func() int
	initWordIdx func(int)
}

func NewScannerEx(stdin io.Reader) *ReaderEx {
	var this ReaderEx
	var idx int
	var wordsCnt int
	this.baseScanner = bufio.NewScanner(stdin)
	this.baseScanner.Buffer(make([]byte, 0), 1E+11)
	this.nextWordIdx = func() int {
		cur := idx
		idx = (idx + 1) % wordsCnt
		return cur
	}
	this.initWordIdx = func(wc int) {
		idx = 0
		wordsCnt = wc
	}
	return &this
}

func (me *ReaderEx) Scan(doSplit bool) (isScanned bool) {
	isScanned = me.baseScanner.Scan()
	if doSplit {
		me.words = strings.Fields(me.baseScanner.Text())
	} else {
		me.words = []string{me.baseScanner.Text()}
	}
	me.initWordIdx(len(me.words))
	return
}

func (me *ReaderEx) nextBytes() []byte {
	return []byte(me.words[me.nextWordIdx()])
}
func (me *ReaderEx) nextString() string {
	return me.words[me.nextWordIdx()]
}

type StringArray []string

func (me *ReaderEx) nextStringArray() StringArray {
	return me.words[me.nextWordIdx():]
}

func (me StringArray) toStrings() []string {
	return me
}

func (me StringArray) toInts() []int {
	strValues := me.toStrings()
	values := make([]int, len(strValues))
	for i, v := range strValues {
		n, err := strconv.Atoi(v)
		if err != nil {
			panic(err)
		}
		values[i] = n
	}
	return values
}
func (me *ReaderEx) nextInt() int {
	n, err := strconv.Atoi(me.words[me.nextWordIdx()])

	defer func() {
		if err != nil {
			panic(fmt.Sprintf("getInt(%d)", n))
		}
	}()
	return n
}

func pow(x, y, mod int) (ans int) {

	ans = 1
	for bit := 1 << uint(math.Floor(math.Log2(float64(y)))); ; bit >>= 1 {
		if y&bit != 0 {
			ans *= x
			if mod > 0 {
				ans %= mod
			}
		}
		if bit <= 1 {
			return
		}
		ans *= ans
		if mod > 0 {
			ans %= mod
		}
	}
}

type factType struct {
	prime int
	count int
}

func fact(n int) (facts []*factType) {

	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			fa := factType{prime: i}
			for n%fa.prime == 0 {
				n /= fa.prime
				fa.count++
			}
			facts = append(facts, &fa)
		}
	}
	if n > 1 {
		facts = append(facts, &factType{prime: n, count: 1})
	}
	return facts
}
func dec2bin(n int) (ret []bool) {
	for bit := 1 << uint(math.Floor(math.Log2(float64(n)))); ; bit >>= 1 {
		ret = append(ret, n&bit != 0)

		if bit <= 1 {
			return
		}
	}

}

func abs(v int) int {
	if v < 0 {
		v = -v
	}
	return v
}

func b2i(b bool) (i int) {
	if b {
		i = 1
	} else {
		i = 0
	}
	return
}

func solve(stdin io.Reader, stdout io.Writer) {

	r := NewScannerEx(stdin)
	r.Scan(true)
	n := r.nextInt()
	type music struct {
		name  string
		time  int
		total int
	}
	musics := make([]*music, 0, n)
	total := 0
	for i := 0; i < n; i++ {
		r.Scan(true)
		cur := &music{name: r.nextString(), time: r.nextInt()}
		musics = append(musics, cur)
		total += cur.time
		cur.total = total
	}
	r.Scan(true)
	name := r.nextString()
	for _, cur := range musics {
		if strings.Compare(name, cur.name) == 0 {
			fmt.Fprintln(stdout, total-cur.total)
			break
		}
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i <(n); i++)
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using p = pair<int,int>;

int main(){
  int r;
  cin >> r;
  double ans;
  ans = 2*r*3.1415926;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3784
import sys
sys.setrecursionlimit(4100000)
import math
import itertools
INF = float('inf')
from heapq import heapify, heappop, heappush

def main():
    d,t,s = map(int, input().split())

    if d/s <= t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


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

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

	long long x, y;
	cin >> x >> y;
	int cnt = 0;
	while(x <= y) {
		x *= 2;
		cnt++;
	}
	cout << cnt << endl;
	return 0;
}


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

using namespace std;
int cnt[30001][10];// cnt[a][b] := a地点までに存在するbの個数
int ans[10][10][10];
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	string s;
	cin >> s;
	for(int i=0;i<n;i++){
		if(i!=0)for(int j=0;j<10;j++)cnt[i][j] = cnt[i-1][j];
		int now = s[i] -'0';
		cnt[i][now]++;
	}
	for(int i=1;i<n-1;i++){//真ん中の数を確定させて、その両端を調べる
		int mid = s[i] - '0';
		rep(a,10)rep(b,10){
			if(cnt[i-1][a]&&cnt[n-1][b]-cnt[i][b]){
				ans[a][mid][b]++;
			}
		}
	}
	int ret = 0;
	rep(a,10)rep(b,10)rep(c,10)if(ans[a][b][c])ret++;
	cout << ret << endl;
}

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

int main(){
  int n;cin>>n;
  char str[n+1];
  cin>>str;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    if(str[i]=='R')a++;
  }
  int ans=max(a,b);
  for(int i=0;i<n;i++){
    if(str[i]=='R')a--;
    if(str[i]=='W')b++;
    ans=min(ans,max(a,b));
  }
  cout<<ans<<endl;
}

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;


int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int ans = 0;
    cin >> N;
    vector<pii> v[N];
    for(int i=0; i<N; i++)
    {
        int x;
        cin >> x;
        for(int j=0; j<x; j++)
        {
            int y, z;
            cin >> y >> z;
            y--;
            v[i].PB({y, z});
        }
    }
    for(int i=(1<<(N))-1; i>=0; i--)
    {
        int temp = i;
        int arr[N];
        int ct = 0;
        for(int j=0; j<N; j++)
        {
            arr[j] = temp%2;
            temp/=2;
            ct+=arr[j];
            //cout << arr[j] << " ";
        }
        bool ok = true;
        for(int j=0; j<N; j++)
        {
            int dishonest = 0;
            int honest = arr[j];
            for(int k=0; k<v[j].size(); k++)
            {
                int person = v[j][k].f;
                int honest2 = v[j][k].s;
                if(honest)
                {
                    if(arr[person] != honest2)
                    {
                        ok = false;
                    }
                }
                else
                {
                    dishonest++;
                }
            }
        }

        if(ok)
        {
            ans = max(ans, ct);
        }
    }

    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main (){
	int n;
	char a;
	int book=0;
	cin>>n;
	while(n--){
		cin>>a;
		if(a=='Y'){
			book=1;
		}
	}
	if(book==1){
		cout<<"Four"<<endl;
	}
	else{
		cout<<"Three"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 256
n=int(input())
num_list=[]
for a in range(n):
    a=int(input())
    num_list.append(a)
new_list=sorted(num_list)
p=new_list[-1]
q=new_list[-2]
for x in range(n):
    if num_list[x]==p:
        print(q)
    else:
        print(p)

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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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


#if 1
//-------------
// DUMPマクロ
// https://www.creativ.xyz/dump-cpp-652/

// vector
template <typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
// pair
template <typename T, typename U>
ostream& operator<<(ostream& os, pair<T, U>& pair_var) {
	os << "(" << pair_var.first << ", " << pair_var.second << ")";
	return os;
}
// vector
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	os << "{";
	for (int i = 0; i < vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
	}
	os << "}";
	return os;
}
// map
template <typename T, typename U>
ostream& operator<<(ostream& os, map<T, U>& map_var) {
	os << "{";
	repi(itr, map_var) {
		os << *itr;
		itr++;
		if (itr != map_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}
// set
template <typename T>
ostream& operator<<(ostream& os, set<T>& set_var) {
	os << "{";
	repi(itr, set_var) {
		os << *itr;
		itr++;
		if (itr != set_var.end()) os << ", ";
		itr--;
	}
	os << "}";
	return os;
}

#define DUMPOUT cerr

void dump_func() {
	DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head&& head, Tail&& ... tail) {
	DUMPOUT << head;
	if (sizeof...(Tail) > 0) {
		DUMPOUT << ", ";
	}
	dump_func(std::move(tail)...);
}
#ifdef _DEBUG
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif
#endif



signed main() {

	int N, M, L;
	cin >> N >> M >> L;
	vector<vector<int>> d(N, vector<int>(N,INF));

	rep(i, M) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		d[a][b] = c;
		d[b][a] = c;
	}

	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
			}
		}
	}

	vector<vector<int>> one(N, vector<int>(N, INF));
	rep(i, N) rep(j, N) {
		if (d[i][j] <= L) one[i][j] = 1;
	}
	for (int k = 0; k < N; k++) {
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				one[i][j] = min(one[i][j], one[i][k] + one[k][j]);
			}
		}
	}


	int Q;
	cin >> Q;
	rep(i, Q) {
		int s, t;
		cin >> s >> t;
		s--; t--;

		if (one[s][t] == INF) cout << -1 << endl;
		else {
			cout << one[s][t]-1 << endl;
		}
	}
	
	
	return 0;
}


Measured memory_bytes: 1920
def trans(s)
  s.split('').map { |c|
    case c
      when 'A' then 'T'
      when 'T' then 'A'
      when 'G' then 'C'
      when 'C' then 'G'
    else 'X'
    end
    }.join
end

b = readline.chop
puts trans(b)

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

using namespace std;

int MAX = 999999999;
int MIN = 1000000009;
int N = 1000009;

int n;
vector<int> arr_a, arr_b, perm;
bool equal_a()
{
  for (int i = 0; i < n; i++)
  {
    if (perm[i] != arr_a[i])
      return false;
  }
  return true;
}
bool equal_b()
{
  for (int i = 0; i < n; i++)
  {
    if (perm[i] != arr_b[i])
      return false;
  }
  return true;
}
int main()
{

  cin >> n;
  arr_a.resize(n);
  arr_b.resize(n);
  for (int i = 1; i <= n; i++)
  {
    cin >> arr_a[i - 1];
    perm.push_back(i);
  }
  for (int i = 1; i <= n; i++)
  {
    cin >> arr_b[i - 1];
  }
  int ind = 0;
  int a = 0, b = 0;
  do
  {
    ind++;
    if (equal_a())
    {
      a = ind;
    }
    if (equal_b())
    {
      b = ind;
    }
  } while (next_permutation(perm.begin(), perm.end()));
  cout << abs(a - b) << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        long h=scan.nextInt();
        int n=scan.nextInt();
      	int []arr=new int[n];
      for (int i=0;i<n;i++){
      arr[i]=scan.nextInt();
        h-=arr[i];       
      }
      if (h<=0){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
      
        }
    }


Measured memory_bytes: 50112
#include<cstdio>

constexpr unsigned int ans[55] = { 11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381 };

int main() {
	unsigned int n;
	scanf("%u", &n);
	while (--n)
		printf("%u ", ans[n]);
	printf("%u\n", ans[0]);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
const int mod = 998244353;

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n) {
    if (n & 1) res = res * x % mod;
    x = x * x % mod;
    n /= 2;
  }
  return res;
}

vl fac(3e6, 1);
vl invfac(fac.size(), 1);

ll bin(int n, int k) {
  if (k < 0 || k > n) return 0;
  return fac[n] * invfac[k] % mod * invfac[n - k] % mod;
}

int main() {
  std::ios::sync_with_stdio(false); std::cin.tie(0);
  for (int i = 2; i < (int)fac.size(); ++i) {
    fac[i] = fac[i - 1] * i % mod;
    invfac[i] = mpow(fac[i], mod - 2);
  }
  int n, m;
  cin >> n >> m;
  ll res = 0;
  for (int k = m % 2; k <= m; k += 2) {
    int a = (m - k) / 2;
    res = (res + (bin(n - 1 + m + a, n - 1) - (n - k) * bin(n - 1 + a - 1, n - 1) - k * bin(n - 1 + a, n - 1)) % mod * bin(n, k)) % mod;
  }
  cout << (res % mod + mod) % mod << endl;
  return 0;
}


Measured memory_bytes: 47104
//“Failure is unimportant. It takes courage to make a fool of yourself.”
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
#define int long long int
#define P 1000000007
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 1000
#define PI 3.14159265359
#define inf LLONG_MAX
using namespace __gnu_pbds;
using namespace std;


signed main() {
    teevra_gati

    
    ll n;
    cin>>n;
    vl a(n),b(n),c(n),dpa(n),dpb(n),dpc(n);
    f(i,0,n) cin>>a[i]>>b[i]>>c[i];
    dpa[0]=a[0];
    dpb[0]=b[0];
    dpc[0]=c[0];
    f(i,1,n){
        dpa[i] = a[i] + max(dpb[i-1],dpc[i-1]);
        dpb[i] = b[i] + max(dpa[i-1],dpc[i-1]);
        dpc[i] = c[i] + max(dpa[i-1],dpb[i-1]);
    }
    cout<<max({dpa[n-1],dpb[n-1],dpc[n-1]});
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>


int main(){
  int k;
  int arr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

  scanf("%d", &k);
  printf("%d\n", arr[k-1]);

  return 0;
}

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

int main() {
  int N, S;
  S = 0;
  cin >> N;
  vector<int> d(N);
  for(int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  for(int i = 0; i < N; i++) {
    for(int j = i + 1; j < N; j++) {
      S += d.at(i) * d.at(j);
    }
  }
  cout << S << endl;
}

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

main(){
  double a, b,x;
  int x1,x2;
  
  cin >> a >> b;
  x = (a+b)/2;
  x1= (a+b)/2;
  x2 =(x-x1)*2+x1;
  cout << x2;
  
}

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

int main() {
  int n;
  cin >> n;
  vector<int64_t> vec(n+1);
  int64_t sum=0;
  bool b=true;
  rep(i,n+1){
    cin >> vec[i];
    sum+=vec[i];
  }
  int64_t now=1;
  int64_t ans=1;
  if(vec[0]>1)b=false;
  else if(vec[0]==1&&n!=0)b=false;
  else if(vec[0]==1) ans=1;
  else{
    rep(i,n){
      if(vec[i+1]>2*now) b=false;
      now=min(sum,2*now);
      ans+=now;
      sum-=vec[i+1];
      now-=vec[i+1];
      
    }
  }
  if(b==true) cout << ans << endl;
  else cout << -1 << endl;
    

}

Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}


int n,k;

main(){
  cin>>n>>k;

  cout<<n-k+1<<endl;
}


Measured memory_bytes: 256
s=input()

a=s.count(s[0])
b=s.count(s[1])
c=s.count(s[2])
d=s.count(s[3])

if(a==2):
  if(b==2):
    if(c==2):
      if(d==2):
        print("Yes")
      else:
        print("No")
    else:
      print("No")
  else:
  	print("No")

else:
  print("No")

Measured memory_bytes: 3060
LIMIT = 10000000
  
isPrime = [True for _ in range(LIMIT)]
 
isPrime[0] = isPrime[1] = False
  
for i in range(2, int(LIMIT ** 0.5)+1):
  if isPrime[i]:
    for j in range(i * i, LIMIT, i):
      isPrime[j] = False
  
try:
    while True:
        n = int(input())
 
        count = 0
        if n >= 2:
            count = 1
 
        for i in range(3, n+1, 2):
            if isPrime[i]:
                count += 1
 
        print(count)
except EOFError:
  pass


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

int main(){
  int n, count = 0;
  cin >> n;
  for (int i = 1; i <= n; i++)
  {
    if (to_string(i).length() % 2 != 0)
    {
      count += 1;
    }
    
  }
  cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007
typedef vector<ll> Array;
typedef vector<Array> matrix;
typedef tuple<int,int,int> tiii;
#define mt make_tuple

int main(){
  string s; cin >> s;
  int k; cin >> k;
  
  rep(i,s.size()){
    if(s[i] != 'a' && 'z' - s[i] + 1 <= k)  k -= 'z' - s[i] + 1,s[i] = 'a';
  }
  if(k > 0)
    s[s.size() - 1] = s[s.size()-1] + (k%26);
  if(s[s.size()] > 'z') s[s.size()] -= 'z' + 'a';
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<algorithm>
using namespace std;
int a[100005];
int main()
{
    int n,flag=0;
    long long p,q;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&a[i]);
    sort(a,a+n);
    for(int i=n-1;i>0;)
    {
        if(a[i]==a[i-1]&&flag==0)
        {
            p=a[i];
            flag=1;
            i=i-2;
        }
        else if(a[i]==a[i-1]&&flag==1)
        {
            q=a[i];
            flag=2;
            break;
        }
        else if(a[i]!=a[i-1])
            i--;
    }
    if(flag!=2)
        printf("0\n");
    else
        printf("%lld\n",p*q);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define drep(i,cc,n) for(int i=(cc);i<=(n);++i)
#define rep(i,n) drep(i,0,(n)-1)
#define drrep(i,cc,n) for(int i=(cc);i>=(n);--i)
#define rrep(i,n) drrep(i,0,(n)-1)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,v.size())if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define arrprint(v,n) rep(i,n)if(i==0)cout << v[i];else cout << " " << v[i]; cout << endl;
#define matprint(v,n,m) rep(i,n){rep(j,m){cout << v[i][j] << " ";}cout << endl;}
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
using namespace std;
const int mod=1000000007;
const int INF=1001001001;
using ll = long long;
using P = pair<int,int>;
template<typename T>
using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>; //小さいものから取り出す

int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(i%2 == 0 && a%2 == 1)ans++;
    }

    cout << ans << endl;
//  printf("%.10f\n",ans);

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define de(x) cout<<#x<<"="<<x<<endl
#define dd(x) cout<<#x<<"="<<x<<" "
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define repd(i,a,b) for(int i=a;i>=(b);--i)
#define repp(i,a,b,t) for(int i=a;i<(b);i+=t)
#define mt(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp(u,v) make_pair(u,v)
#define sz(a) (int)a.size()
#define pb push_back
#define PI acos(-1.0)
#define qc std::ios::sync_with_stdio(false)
#define all(a) a.begin(),a.end()
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef double db;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;

const ll mod = 1000000007;
const int N = 1e5+6;
const int M = 2e6+6;
const double eps = 1e-6;
const int inf = 0x3f3f3f3f;

bool eq(const db &a, const db &b) { return fabs(a - b) < eps; }
bool ls(const db &a, const db &b) { return a + eps < b; }
bool le(const db &a, const db &b) { return eq(a, b) || ls(a, b); }
ll gcd(ll a,ll b) { return a==0?b:gcd(b%a,a); };
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
ll kpow(ll a,ll b) {ll res=1;a%=mod; if(b<0) return 1; for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll read(){
    ll x=0,f=1;char ch=getchar();
    while (ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//inv[1]=1;
//for(int i=2;i<=n;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
int n;
int a[N], pos[N];
int main() {
    scanf("%d",&n);
    rep(i, 0, n) scanf("%d",a+i), pos[a[i]]=i;
    ll ret = 0;
    multiset<int> s{-1,-1,n,n};
    repd(i, n, 1) {
        int cur = pos[i];
        ll r1 = *s.lower_bound(cur);
        ll r2 = *next(s.lower_bound(cur));
        ll l2 = *prev(s.lower_bound(cur));
        ll l1 = *prev(s.lower_bound(cur), 2);
        ret += ((l2-l1) * (r1-cur) + (r2-r1) * (cur-l2)) * i;
        s.insert(cur);
    }
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }

ll gcd(ll x, ll y) {
  return y ? gcd(y, x%y) : x;
}

vector<pair<ll, int>> factorization(ll n) {
  vector<pair<ll, int>> res;
  for (ll i = 2; i*i <= n; ++i) {
    if (n%i) continue;  // i で割り切れない時は無視
    res.emplace_back(i, 0);  // i について初期化
    while(n%i == 0) {  // i で割り切れる間カウント
      n /= i;
      res.back().second++;
    }
  }
  if (n != 1) res.emplace_back(n, 1);  // n が素数の時
  return res;
}

int main() {
  ll A, B;  cin >> A >> B;
  
  ll g = gcd(A, B);
  vector<pair<ll, int>> f = factorization(g);
  int ans = f.size() + 1;
  print(ans);
  return 0;
}

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

n = int(input())
edge = [[] for _ in range(n)]
e = []
for i in range(n - 1):
    a, b = map(int, input().split())
    edge[a - 1].append(b - 1)
    edge[b - 1].append(a - 1)
c = list(map(int, input().split()))
c.sort(reverse=True)

num = 0
def point(x, prev, turn=0):
    global num
    if turn > n:
        return
    dp[x] = c[num]
    num += 1
    for i in edge[x]:
        if dp[i] != 0:
            continue
        if i == prev:
            continue
        else:
            point(i, x, turn + 1)
    return

for i in range(n):
    if len(edge[i]) > 1:
        continue
    else:
        dp = [0] * n
        point(i, -1)
        break

ans = sum(c) - max(c)

print(ans)
print(" ".join(map(str, dp)))


Measured memory_bytes: 54872
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let a = read_vec::<usize>();
    let mut count = vec![0i64; n + 1];
    for &num in &a {
        count[num] += 1;
    }
    debug!(count);
    let mut sum = 0;
    for i in 1..n + 1 {
        sum += count[i] * (count[i] - 1) / 2;
    }
    debug!(sum);

    for i in 0..n {
        let k = a[i];
        let mut temp = sum - count[k] * (count[k] - 1) / 2;
        temp += (count[k] - 1) * (count[k] - 2) / 2;
        println!("{}", temp);
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001;
const int INFLL=1001001001001001001ll;
const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

int N;
int A[111111];

signed main(){
    cin>>N;
    rep(i,N)cin>>A[i];

    map<int,int>cnt;
    rep(i,N)cnt[A[i]]++;
    if(cnt.size()>2){
        puts("No");
        return 0;
    }

    if(cnt.size()==1){
        int x=cnt.begin()->fi;
        if(x<=N/2){
            puts("Yes");
            return 0;
        }
        if(x==N-1){
            puts("Yes");
            return 0;
        }
        puts("No");
        return 0;
    }

    if(cnt.begin()->fi+1!=cnt.rbegin()->fi){
        puts("No");
        return 0;
    }

    int n=N-cnt.begin()->se;
    int y=cnt.rbegin()->fi;
    if(cnt.begin()->se+1<=y&&y<=n/2+cnt.begin()->se){
        puts("Yes");
    }
    else{
        puts("No");
    }
    return 0;
}


Measured memory_bytes: 7296
import math

K=int(input())
ans=0
for i in range(1,K+1,1):
    for j in range(1,K+1,1):
        a = math.gcd(i,j)
        for k in range(1,K+1,1):
            b = math.gcd(a,k)
            ans += b

print(ans) 

Measured memory_bytes: 9156
import sys                        
import copy                       
from collections import deque     
                                  
def get_read_func(fileobject):    
    if fileobject == None :       
        return raw_input          
    else:                         
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    N = int(input_raw[0])
    now_t = 0
    now_x = 0
    now_y = 0
    is_ok_plan = True
    for i in range(N):
        input_raw = read_func().strip().split()
        [t, x, y] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2])]
        dist = abs(x - now_x) + abs(y - now_y)
        T = t - now_t
        if (dist <= T and dist % 2 == T % 2) == False:
            is_ok_plan = False
        now_t = t
        now_x = x
        now_y = y


    if is_ok_plan:
        print "Yes"
    else:
        print "No"

if __name__ == '__main__':
    main()


Measured memory_bytes: 6000
#include<bits/stdc++.h>
using namespace std;
signed main(){
	int a[200001],c[200002],n,k;
	cin>>n>>k;
	for(register int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(register int j=1;j<=k;j++){
		memset(c,0,sizeof(c));
		for(register int i=1;i<=n;i++){
			++c[max(1,i-a[i])];
			--c[min(n+1,i+a[i]+1)];
		}
		register int s=0,f=1;
		for(register int i=1;i<=n;i++){
			a[i]=s+=c[i];
			if(a[i]<n)f=0;
		}
		if(f){
			break;
		}
	}
	for(register int i=1;i<=n;i++){
		printf("%d ",a[i]);
	}
	return 0;
}


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

template<class T> void chmin(T& a, T b) {
//      cout << "a= " << a << ",b= " << b << endl;
        if (b < a) a = b;
        return;
}

int main()
{
        ll INF = 1LL << 60;
        int N, K; cin >> N >> K;
        vector<int> h(N, 0);
        for (int i = 0; i < N; ++i) {
                cin >> h[i];
        }
        vector<ll> dp(N, INF);
        dp[0] = 0;
        for (int i = 0; i < N; ++i) {
                for (int j = 1; j <= K; ++j) {
                        if (i-j < 0) continue;
                        chmin(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
                }
        }
//      for (int i = 0; i < N; ++i) cout << dp[i] << endl;
        cout << dp[N-1] << endl;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,x=0;string s;cin>>a>>b>>s;
  for(int i=0;i<=a+b;i++){
    if(i==a){
      if(s.at(i)!='-'){
        x++;
        break;
      }
    }
    else{
      if(s.at(i)!='0'&&s.at(i)!='1'&&s.at(i)!='2'&&s.at(i)!='3'&&s.at(i)!='4'
         &&s.at(i)!='5'&&s.at(i)!='6'&&s.at(i)!='7'&&s.at(i)!='8'&&s.at(i)!='9'){
        x++;
        break;
      }
    }
  }
  if(x>0)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<double> rec(n);
    double sum = 0;
    for(int i = 0; i < n; i++){
        cin >> rec.at(i);
        sum += (1/(rec.at(i)));
    }
    cout << (1/sum) <<endl;
}

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


int main(void) {
    int n, num, num_of_prime;
    int i, j;
    int flag;
    
    scanf("%d", &n);
    
    num_of_prime = 0;
    for(i=0; i<n; i++) {
        scanf("%d", &num);
        
        flag = 0;
        if(num == 2) flag = 1;
        else if(num > 2 && num%2!=0) {
            flag = 1;
            for(j=3; j<=(int)sqrt(num); j+=2) {
                if(num%j==0)  {
                    flag = 0;
                    break;
                }
            }
        }
        if(flag == 1) num_of_prime++;
        
    }
    
    printf("%d\n", num_of_prime);
    
    return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int a,p;
  cin>>a>>p;
  cout<<(a*3+p)/2<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,t;
  getline(cin,s);
  getline(cin,t);
  int a=s.size();
  if((a+1)==((int)t.size()))
  {
    if(strncmp(s.c_str(),t.c_str(),a)==0)
    {
      printf("Yes\n");
    }
    else{
      printf("No\n");
    }
  }
  else
  {
    printf("No\n");
  }
    return 0;
}


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

#define endl "\n"
#define int long long int
#define mod 1000000007
#define vi vector<int>
#define pint pair<int,int>
#define vint vector<vector<int>>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

const int N = 1e6+5;
int A[N], B[N], P[N], ans[N];

int mat[1005][1005];
pint edges[N];
unordered_map<int, set<int>> m;

bool compare(vi a, vi b)
{
    return a[0] < b[0];
}

int mypow(int a, int x)
{
    if(a<=1 || x==1) return a;
    if(x==0) return 1;

    int temp = mypow(a,x/2);
    if(x%2==0) return ((temp%mod) * (temp%mod))%mod;
    else return (a%mod * ((temp%mod) * (temp%mod))%mod)%mod;
}

int count_bits(int n)
{
    int cnt = 0;
    while(n)
    {
        n = n & (n-1);
        cnt++;
    }return cnt;
}

void bfs(int src, int n)
{
    unordered_map<int, bool> visited;
    for(int i=0;i<n;i++) visited[i] = false;
    queue<int> q;
    q.push(src);
    visited[src] = true;

    while(!q.empty())
    {
        int curr = q.front();
        q.pop();
        B[curr] -= min(B[curr], A[src]);
        //cout<<curr<<" "<<endl;

        for(auto neigh: m[curr])
        {
            if(visited[neigh] == false)
            {
                //cout<<neigh<<endl;
                q.push(neigh);
                visited[neigh] = true;
                m[src].erase(neigh);
                m[neigh].erase(src);
            }
        }
    }
}

/*void void_solve(int n)
{

}*/

int int_solve(int n, int x, int t)
{
    int ans = 0;
    if(n%x == 0) ans = n/x;
    else ans = n/x + 1;
    ans *= t;
    return ans;
}

/*string string_solve(int n)
{

}*/

bool bool_solve(string s)
{
    int sum = 0;
    int i;
    for(i=0;i<s.length();i++) sum += (s[i] - '0');
    return !(sum % 9);
}

int32_t main()
{
    //code
	IOS;

    int t,n,m,a,b,x,y,i,j,z;
    //cin>>t;
    //cin>>n;
    string s;
    cin>>s;
    if(bool_solve(s)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

	return 0;
}


Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
template <typename T> using vec = vector<T>;

int main()
{
    int n;
    cin >> n;
    int a,b;
    int cnt = 0;
    while (cin >> a >> b)
    {
        if (a==b)
        {
            cnt++;
        }
        else
        {
            cnt = 0;
        }
        if (cnt == 3)
        {
            cout << "Yes" << endl;
            return 0;
        }
        
        
    }
    cout << "No" << endl;

}

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

using namespace std;
using ll = long long;

int main(){
    static const double pi = 3.141592653589793;
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    double hd = h * 30 + m * 0.5;
    double md = 6 * m;
    double ans = pow(a * a + b * b - 2 * a * b * cos(pi * abs(hd - md) / 180), 0.5);
    cout << setprecision(11) << ans << endl;
}

Measured memory_bytes: 4284
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    long M = 1_000_000_007;
    char[] s = scanner.next().toCharArray();
    long[][] dp = new long[s.length + 1][13];
    int[] map = {0, 4, 8, 12, 3, 7, 11, 2, 6, 10, 1, 5, 9};

    dp[0][0] = 1;
    for (int i = 1; i <= s.length; i++) {
      char ch = s[i - 1];
      for (int j = 0; j < 13; j++) {
        if (ch == '?') {
          for (int k = 0; k < 10; k++) {
            int l = j - k;
            if (l < 0) l += 13;
            dp[i][j] += dp[i - 1][map[l]];
            if (dp[i][j] >= M) dp[i][j] -= M;
          }
        } else {
          int l = j - (ch - '0');
          if (l < 0) l += 13;
          dp[i][j] = dp[i - 1][map[l]];
        }
      }
    }
    System.out.println(dp[s.length][5]);
  }
}


Measured memory_bytes: 39672
n = int(input())
W = list(map(int,input().split()))

s1 = 0
s2 = sum(W)
dif = s2 - s1
dif2 = 0

for i in range(n):
    s1 = s1 + W[i]
    s2 = s2 - W[i]
    if s2 - s1 >= 0 and dif <= 0:
        dif = -1 * dif
        dif2 = s2 - s1
        break
    elif s2 - s1 <= 0 and dif >= 0:
        dif2 = s1 - s2
        break
    else:
        dif = s2 - s1

if dif < dif2:
    print(dif)
else:
    print(dif2)


Measured memory_bytes: 3064
#include<stdio.h>
  
int main(){
  int n[4]={};
  //0=<nx=<9
  for(int i=0; i<4; i++){
    scanf("%d", &n[i]);
  }
  int a[4]={1,4,7,9};

  for(int i=0; i<4; i++){
    for(int j=0; j<4; j++){
      if(n[i]==a[j]){
        a[j]=10;
      }
    }
  }

  if(a[0]+a[1]+a[2]+a[3]==40){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}

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

int main() {
    string S;
    cin >> S;
    if((S.at(0) == S.at(1) && S.at(2) == S.at(3) && S.at(0) != S.at(2)) ||
       (S.at(0) == S.at(2) && S.at(1) == S.at(3) && S.at(0) != S.at(1)) ||
       (S.at(0) == S.at(3) && S.at(1) == S.at(2) && S.at(0) != S.at(1))) {
        cout << "Yes" << endl;
    }else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  string num;
  cin >> num;
  if (num[0] == num[2]) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
import bisect
from itertools import combinations

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))
    ans = 0
    for l in combinations(L, 2):
        a = l[0]
        b = l[1]
        x = bisect.bisect_left(L, a + b)
        y = bisect.bisect(L, b - a)
        if b - a < a :
            ans += x - y - 2
        else:
            ans += x - y - 1
    print(ans // 3)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9316
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
int main(void)
{
	int v;
	int a[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
	char w[102];
	std::cin >> w;
	int n = strlen(w);
	for(int i=0;i<n;i++)
	{
		v = int(w[i]) - int('a');
		a[v]++;
	}
	for(int i=0;i<26;i++)
	{
		if(a[i] % 2)
		{
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
touhyou = defaultdict(int)
for _ in range(N):
    s = input()
    touhyou[s] +=1
touhyou1=dict(sorted(touhyou.items(),key = lambda x: x[1],reverse = True))
maxn=max(touhyou1.values())
ans=[]
for key,val in zip(touhyou1.keys(),touhyou1.values()):
    if val == maxn:
        ans.append(key)

ans=sorted(ans)

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 66524
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int row = sc.nextInt();
		int column = sc.nextInt();
		int row_result = 0;
		int column_result = 0;
		int[][] nums = new int[row + 1][column+ 1];

		for(int i = 0; i < row; i++) {
			for(int j = 0; j < column; j++) {
				nums[i][j] = sc.nextInt();
			}
		}

		for(int i = 0; i < row; i ++) {
			for(int j = 0; j < column; j++) {
				 row_result += nums[i][j];
			}
			 nums[i][column] = row_result;
			 row_result = 0;
		}

		for(int i = 0; i < column; i++) {
			for(int j = 0; j < row; j ++) {
				column_result += nums[j][i];
			}
			nums[row][i] = column_result;
			column_result = 0;
		}

		int total_result = 0;

		for(int i = 0; i < row; i++) {
			total_result += nums[i][column];
		}

		nums[row][column] = total_result;

		 for(int i = 0; i <= row ; i++) {
			 for(int j = 0; j <= column; j++) {
				 if(j != column) {
					 System.out.print(nums[i][j] + " ");
				 }else {
					 System.out.println(nums[i][j]);
				 }
			 }
		 }
	}
}



Measured memory_bytes: 41576
import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B

main :: IO ()
main = readLine >>= putStrLn . solve

solve :: [Int] -> String
solve [a, b, c]
    | (a < c && c < b) || (b < c && c < a) = "Yes"
    | otherwise = "No"

readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine

Measured memory_bytes: 380
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb(a) push_back(a)
using ll = long long;
using namespace std;

int main(){
    char tmp, cnt = 0;
    int n = 0, waru = 0;
    int arr[10];
    while(cin >> tmp){
        waru += tmp - 48;
        arr[cnt] = tmp - 48;
        cnt++;
    }
  cnt--;
  	int j = 0;
    while(cnt >= 0){
        int ten = 1;
        REP(i, cnt){
            ten *= 10;
        }
        n += arr[j] * ten;
        cnt--;
      	j++;
    }
    if(n % waru == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
tmp=input().split(" ")
n = int(tmp[0])
k = int(tmp[1])

s=input()

def sumrange(arr, l, r):
    #print("sumrange:", l, r, arr[r] - arr[l-1])
    return arr[r] - arr[l-1]

prev="1"
counts=[0]
count=0
prev_count=0
for c in s:
    if c == prev:
        count+=1
    else:
        counts.append(prev_count + count)
        prev=c
        prev_count += count
        count=1
else:
    counts.append(prev_count + count)

#print(counts)

w = k * 2 + 1
#print(w)

max_score=0
for i in range(0, len(counts)-1, 2):
    if(i + 1 >= len(counts)):
        break
    l = i+1
    r = min(l + w - 1, len(counts)-1)
    score = sumrange(counts, l, r)
    max_score = max(max_score, score)

print(max_score)

Measured memory_bytes: 7160
#include <iostream>

using namespace std;

int n, m, ans, table[9][9];

int chack(){
	for(int i=0; i<n; i++){
		int tmp=0;
		for(int j=0; j<n; j++) tmp += table[i][j];
		if(tmp) return 0;
	}
	return 1;
}


void dfs(int y, int x){
	if(x < n-1) x++;
	else if(y < n-1){
		x=0;
		y++;
	} else{
		ans += chack();
		return;
	}

	if(x==0 && 0<y){
		int tmp =0;
		for(int i=0; i<n; i++) tmp += table[y-1][i];
		if(tmp) return;
	}

	if(table[y][x] == 0 && y != x){
		table[y][x] = 1;
		table[x][y] = -1;
		dfs(y, x);

		table[y][x] = -1;
		table[x][y] = 1;
		dfs(y, x);

		table[y][x] = table[x][y] = 0;
	} else dfs(y, x);
}


int main(void) {
	while(1) {
		cin >> n;
		if(!n) break;
		fill(table[0], table[8], 0);
		cin >> m;
		for(int i=0; i<m; i++){
			int x, y; cin >> x >> y;
			x--; y--;
			table[x][y] = 1;
			table[y][x] = -1;
		}

		ans = 0;
		dfs(0, 0);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 3076
#include<iostream>
using namespace std;
int main(void)
{
	int n, i;
	cin >> n;
	for (i = n; i <=2000000000; i++)
	{
		if (i % 2 == 0 && i%n == 0)
		{
			cout << i << endl;
			break;
		}
	}
}

Measured memory_bytes: 256