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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define l_l pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    // for (ll i = 2; i <= pow(num, 0.5); i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}

ll modinv(ll a, ll m) {
  ll b = m, u = 1, v = 0;
  while (b) {
    ll t = a / b;
    a -= t * b;
    swap(a, b);
    u -= t * v;
    swap(u, v);
  }
  u %= m;
  if (u < 0) {
    u += m;
  }
  return u;
}

ll ncr(int n, int k) {
  ll ans = 1;
  for (ll i = n; i > (n - k); i--) {
    ans *= i;
    ans %= MOD;
  }
  for (ll i = k; i >= 2; i--) {
    ans = ans * modinv(i, MOD) % MOD;
  }
  return ans;
}

int main() {
  ll N, M;
  scanf("%lld %lld", &N, &M);

  ll ans = 1;

  auto m = prime_factor(M);

  auto ite = m.begin();
  for (; ite != end(m); ite++) {
    ll key = (*ite).first;
    ll val = (*ite).second;
    // cout << key << ":" << val << endl;

    ans *= ncr(val + N - 1, val);
    ans %= MOD;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3700
#include <algorithm>
#include <deque>
#include <iostream>
#include <tuple>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

// 移動の重みが0か1だから、01BFSかな？
// でもそうすると、意味のないキューが増えそうだから、
// 基本0コストで移動するのを優先して、移動できる場所がなかったらワープに挑戦するようにしよう
// 嘘解放っぽいので、真面目にやる

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

int main() {
    int H, W;
    cin >> H >> W;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    --ch, --cw, --dh, --dw;
    vector<string> S(H);
    repeat(i, H) cin >> S[i];
    auto grid = vectors(-1, H, W);
    deque<tuple<int, int, int>> que;
    que.emplace_back(0, ch, cw);
    grid[ch][cw] = 0;
    while (!que.empty()) {
        int d = get<0>(que.back());
        int x = get<1>(que.back());
        int y = get<2>(que.back());
        que.pop_back();
        // コスト0移動
        repeat(i, 4) {
            int nx = x + dx[i], ny = y + dy[i];
            if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
            if (S[nx][ny] == '#') continue;
            if (grid[nx][ny] == -1 || grid[nx][ny] > d) {
                grid[nx][ny] = d;
                que.emplace_back(d, nx, ny);
            }
        }
        // コスト1移動
        repeat_from(nx, x - 2, x + 3) {
            repeat_from(ny, y - 2, y + 3) {
                if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue;
                if (S[nx][ny] == '#') continue;
                if (grid[nx][ny] == -1 || grid[nx][ny] > d + 1) {
                    grid[nx][ny] = d + 1;
                    que.emplace_front(d + 1, nx, ny);
                }
            }
        }
    }

    cout << grid[dh][dw] << endl;
    return 0;
}

Measured memory_bytes: 9580
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;

int main()
{
  long long a,b,c,d;
  cin >> a >> b >> c >> d;
  long long sum =0;
  if(d>a)
    sum+=a, d-=a;
  else 
    sum+=d, d=0;
  
    if(d>b)
      d-=b;
    else
      d=0;
   
   if(d<=c)
     sum-=d;
   cout<<sum;
  return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <stdlib.h>

int n;
int list[100][100];
int lengthlist[100];

void search(int x, int length){
  int i;
  
  length++;
  lengthlist[x] = length;
  
  for(i=0; i<n ; i++){
    if( list[x][i] == 1 ){
      if( lengthlist[i] <= length && lengthlist[i] >= 0 ){
        continue;
      }
      search(i, length);
    }
  }
}

int main(){

  int i,j;
  int l;
  int k;
  int u;
  int tmp;
  
  scanf("%d", &n);
  for(l=0; l<n; l++){
    scanf("%d%d", &u, &k);
    
    for( j=0; j<k; j++){
      scanf("%d", &tmp);
      list[u-1][tmp-1] = 1;
    }
  }
  for(l=0; l<n; l++){
    lengthlist[l] = -1;
  }
  search(0, -1);

  for(j=0 ; j<n ; j++){
    printf("%d %d\n", j+1, lengthlist[j]);
  }

  return 0;
}



Measured memory_bytes: 2096
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner stdn = new Scanner(System.in);
		int h = 0;
		int m = 0;
		int s2 = 0;
		int S = 0;
		S = stdn.nextInt();
		
		h = S/3600;
		m = (S-(h*3600))/60;
		s2= (S-(h*3600))-(m * 60); 
		System.out.println(h + ":" + m + ":" +s2);
	}
}

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

using namespace std;

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

#define F first
#define S second

const int MAXN = 50 + 3;

int n, a[MAXN], b[MAXN];
bool vis[MAXN];

void dfs(int v, ll x){
	if (vis[v]) return;
	vis[v] = true;
	for (int w = 1; w < MAXN; w++)
		if (x >> w & 1)
			dfs(v%w, x);
}

bool check(int a, int b, ll x){
	memset(vis, 0, sizeof(vis));
	dfs(a, x);
	return vis[b];
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) cin >> b[i];

	ll ans = 0;
	ll ignored = 0;
	for (int w = MAXN-1; w; w--){
		bool ok = true;
		ans |= 1ll<<w;
		ans -= 1;
		for (int i = 0; i < n; i++)
			if (!check(a[i], b[i], ans))
				ok = false;
		
		ans++;
		if (ok)
			ans ^= 1ll<<w;
	}
	for (int i = 0; i < n; i++)
		if (!check(a[i], b[i], ans)){
			cout << "-1\n";
			return 0;
		}
	cout << ans << endl;
	return 0;
}


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

int main(void){
	int n;
	cin >> n;
	double x1,x2,x3,y1,y2,y3;
	for(int i = 0 ; i < n ; i ++){
		cin>>x1>>y1>>x2>>y2>>x3>>y3;
		double a = x2 * x2 - x1 * x1 + y2 * y2 - y1 * y1;
		double b = x3 * x3 - x1 * x1 + y3 * y3 - y1 * y1;
		double c = 4 * (x2 - x1) * (y3 - y1) - 4 * (x3 - x1) * (y2 - y1);
		
		double x = (2 * (y3 - y1) * a - 2 * (y2 - y1) * b ) / c;
		double y = (-2 * (x3 - x1) * a + 2 * (x2 - x1) * b ) / c;
		double r = sqrt((x - x1) * (x - x1) + (y - y1) * (y - y1));
		
		printf("%.3lf %.3lf %.3lf\n",x,y,r);
		
	} 
	return 0;
}

Measured memory_bytes: 1244
#include <stdio.h>

int main() {
    int number_of_ball, number_of_people;
    int max_ball = 0;
    scanf("%d%d", &number_of_ball, &number_of_people);
    if ( number_of_people == 1 ) {
        printf("0\n");
        return 0;
    }
    max_ball = number_of_ball - number_of_people + 1;
    printf("%d\n", max_ball - 1);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;
typedef long long ll;
const int MAXN = 100500;

int arr[MAXN];
int cnt[2];
int n;

int main()
{                                                     
	ios_base::sync_with_stdio(0);
	
    cin >> n;

    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
        cnt[arr[i] % 2]++;
    }

    int ans = 1;

    for (int i = 0; i < n; i++)
        ans *= 3;

    ans -= (1 << cnt[0]);

    cout << ans << '\n';
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, _s, n) for(int i = _s, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
using namespace std;

#define repi(itr, ds) for(auto itr = ds.begin(); itr != ds.end(); itr++)
// 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 << "}\n   ";
  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

typedef long long int ll;

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  auto A = vector<int>(Q);
  auto cnt = vector<int>(N, 0);
  REP(i, Q) {
    cin >> A[i];
    A[i]--;
    cnt[A[i]]++;
  }

  REP(i, N) {
    if(K - Q + cnt[i] >= 1) {
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
 
long long x;
long double y;
 
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
 
    cin>>x>>y;
    cout << (long long)(x*y + 0.001) << endl;
 
    return 0;
}

Measured memory_bytes: 3708
package main

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

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

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	x := scanInts(5)
	for i := 0; i < 5; i++ {
		if x[i] == 0 {
			fmt.Fprintln(wr, i+1)
			return
		}
	}
}


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

void solve()
{
    int n,m,k,i,j,count=0,sum=0,maxi=0,mini=1e18,flag=0;
    
    int a,v,b,w;
    cin>>a>>v>>b>>w;
    int t;
    cin>>t;
    
    if(v==w && a!=b)
    {
        cout<<"NO";
        return;
    }
    if(a<b)
    {
        if(v<=w)
        {
            cout<<"NO";
            return;
        }
        double d=(1.0*(b-a))/(v-w);
        if(d<=t)
        {
            cout<<"YES";
            return;
        }
        else
        {
            cout<<"NO\n";
            return;
        }
    }
    else if(a>b)
    {
        if(v<=w)
        {
            cout<<"NO";
            return;
        }
        double d=(1.0*(a-b))/(v-w);
        if(d<=t)
        {
            cout<<"YES";
            return;
        }
        else
        {
            cout<<"NO\n";
            return;
        }
    }
    
    
    
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
   // cin>>t;
    while(t--)
    {
        solve();
    }
}

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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}

const int MAX_N = 300;
const int MAX_A = 300;
const ll MOD = 998244353;
int n;
int a[MAX_N];
ll dp[MAX_N+1][MAX_A*MAX_N+1];
ll dp2[MAX_N+1][MAX_A*MAX_N+1];


long long mod_pow(long long a, long long b)
{
  if (b == 0) return 1;
  long long ret = mod_pow(a, b/2);
  ret = ret * ret % MOD;
  if (b % 2 == 1) ret = a * ret % MOD;
  return ret;
}

int main()
{
#ifdef FASTIO
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif

  cin >> n;

  forn (i,n) cin >> a[i];


  dp[0][0] = dp2[0][0] = 1;

  ll total = 0;
  forn (i,n) {
    total += a[i];
    forn (j,MAX_N*MAX_A+1) {
      dp[i+1][j] = (dp[i+1][j] + 2LL*dp[i][j]) % MOD;
      dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j]) % MOD;
      if (j + a[i] <= MAX_N*MAX_A) {
        dp[i+1][j+a[i]] = (dp[i+1][j+a[i]] + dp[i][j]) % MOD;
        dp2[i+1][j+a[i]] = (dp2[i+1][j+a[i]] + dp2[i][j]) % MOD;
      }
    }
  }

  ll v1 = 0;
  for (int i = (total+1)/2; i <= MAX_N*MAX_A; i++) {
    v1 = (v1 + 3LL*dp[n][i]) % MOD;
  }

  ll v2 = 0;
  if ((total&1) == 0) {
    v2 = 3LL*dp2[n][total/2];
  }

  cout << (mod_pow(3LL,n) - v1 + v2 + MOD) % MOD << "\n";

  return 0;
}


Measured memory_bytes: 422912
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll e3 = 1 << 13;
const ll inf = 1ll << 60;
const ll mod = 2019;

ll find(int l, int r) {
  ll mi = 2018;
  ll rem_l = l % mod;
  ll rem_r = r % mod;
  for (int i = rem_l; i < rem_r; i++) {
    for (int j = i + 1; j <= rem_r; j++) {
      ll mul = i * j;
      mi = min(mi, mul % mod);
      if (mi == 0) {
        return mi;
      }
    }
  }
  return mi;
}
 
int main() {
  ll l, r;
  cin >> l >> r;
  ll quot_l = (l - 1) / mod;
  ll quot_r = (r + 1) / mod;
  ll quot_diff = quot_r - quot_l;

  if (quot_diff > 0) {
    cout << 0 << endl;
  } else {
    cout << find(l, r) << endl;;
  }

  return 0;
}

Measured memory_bytes: 256
import sys
#import numpy as np
import math
#from fractions import Fraction
#import itertools
#from collections import deque
#import heapq
#from fractions  import gcd
input=sys.stdin.readline
n=int(input())
def factorize(n):
    fct={}
    temp=n
    if temp<4:
        fct[temp]=1
    else:
        e=0
        while temp%2==0:
            temp=temp//2
            e+=1
        if e>0:
            fct[2]=e
    
    for b in range(3,int(n**0.5)+1,2):
        e=0
        while temp%b == 0:
            temp=temp//b
            e+=1
        if e>0:
            fct[b]=e
    if temp!=1:
        fct[temp]=1
    return fct

p=factorize(n)
ans=0
if n==1:
  print(0)
  exit()
for d in p.keys():
    e=p[d]
    i=1
    while True:
        if e-i>=0:
            ans+=1
            e-=i
            i+=1
            
        else:
            break
print(ans)

Measured memory_bytes: 63628
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void)
{
    string s;
    cin >>s;

    if(s[2] == s[3] && s[4] == s[5]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

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

int main(){
	while(1){
		int n; cin >>n;
		if(n==1)break;
		vector<int> v;
		vector<bool> p(300000,true);
		p[0]=p[1]=false;
		for(int i=2;i<300000;i++){
			if(i%7!=1 && i%7!=6){
				continue;
			}
			if(!p[i])continue;
			for(int k=2*i;k<300000;k+=i){
				p[k]=false;
			}
		}
		for(int i=0;i<300000;i++){
			if(i%7!=1 && i%7!=6) continue;
			if(p[i])v.push_back(i);
		}
		cout << n << ":";
		for(int i=0;i<v.size();i++){
			if(n%v[i]==0){
				cout << " "<< v[i];
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 3400
sa = [i for i in input()]
sb = [i for i in input()]
sc = [i for i in input()]
d = {"a":sa, "b":sb, "c":sc}
turn = "a"
while(True):
    if len(d[turn]) == 0:
        break
    turn = d[turn].pop(0)
print(turn.upper())

Measured memory_bytes: 3060
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine
  val ans = StdIn.readLine.split(" ").map(_.toInt)
    .sortWith( _ > _ )
    .zipWithIndex.map(e => if ((e._2 & 1) == 0) e._1 else -e._1)
    .sum

  println(ans)
}


Measured memory_bytes: 25516
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
bool mir(string s) {
	if (s.size() % 2 == 1)return false;
	for (int i = 0; i < s.size() / 2; i++){
		if (s[i] == 'b'&&s[s.size() - i - 1] == 'd');
		else if (s[i] == 'd'&&s[s.size() - i - 1] == 'b');
		else if (s[i] == 'p'&&s[s.size() - i - 1] == 'q');
		else if (s[i] == 'q'&&s[s.size() - i - 1] == 'p');
		else return false;
	}
	return true;
}
int main() {
	string s; cin >> s; if (mir(s))cout << "Yes\n"; else cout << "No\n";
}

Measured memory_bytes: 512
def ascan; gets.split.map(&:to_i); end

s = gets
l = s.size
N = s.to_i
ans = 0
3.upto(l) do |i|
    [7,5,3].repeated_permutation(i) do |e|
        next unless e.include?(7) && e.include?(5) && e.include?(3)
        ans += 1 if e.reduce(0){|s,e| s*10+e } <= N
    end
end

p ans

Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int,int> P;

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  //fact 階乗　iface 階乗の逆数
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
    ll n,m,k;
    cin >> n >> m >> k;
    mint ans = 0;
    combination c(200005);
    rep(i,k+1){
        ans += (mint)m*mint(m-1).pow(n-1-i)*c(n-1,i).x;
    }
    cout << ans.x << endl;
}

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

int main(){
	int n,k;cin>>n>>k;
	vector<int>height(n,0);
	for(int i=0;i<n;i++){
		cin>>height[i];
	}
	int dp[n];
	dp[0] = 0;
	//dp[1] = abs(height[1]-height[0]);
	for(int i=1;i<n;i++){
		dp[i] = INT_MAX;
		for(int j=1;j<=min(i,k);j++){
		dp[i] = min(dp[i],abs(height[i]-height[i-j])+dp[i-j]);
	}
	//cout<<dp[i]<<" ";
	}
	cout<<dp[n-1];
}


Measured memory_bytes: 1024
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    N, D = map(int, readline().split())

    x = 2 * D + 1

    print((N + x - 1) // x)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61764
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

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

vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    sort(ret.begin(), ret.end(), greater<long long>());
    return ret;
}


int main(){
    long long a, b, k;
    cin >> a >> b >> k;

    vector<long long> ret = divisor(gcd(a, b));

    cout << ret[k-1] << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<ll> >;//ll or Edge
using Edge=pair<int,ll>;
//const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// g++ -o a a.cpp -Wall -lm -std=c++17
int main(){
    ll n,k;cin>>n>>k;
    string S;cin>>S;
    S+='2';
    vector<ll>list;
    if(S[0]=='0')list.push_back(0);
    ll cnt=0;
    rep(i,n){
        cnt++;
        if(S[i]!=S[i+1]){list.push_back(cnt);cnt=0;}
    }
    if(S[n-2]=='0')list.push_back(0);
    ll m=list.size();
    VI sum(m+1);
    sum[0]=0;
    rep(i,m){
        sum[i+1]=sum[i]+list[i];
    }
    ll ans=0;
    for(ll left=0;left<=(ll)sum.size();left+=2){
        ll right=left+k*2+1;
        if(right>=(ll)sum.size())right=(ll)sum.size()-1;
        if(right<=left)continue;
        ans=max(ans,sum[right]-sum[left]);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 5108
import math
import itertools
N = int(input())
P = list(map(int,input().split()))
p = ""
for i in range(N):
  p += str(P[i])
Q = list(map(int,input().split()))
q = ""
for i in range(N):
  q += str(Q[i])

s = ""
for i in range(1,N+1):
  s += str(i)
l = [''.join(v) for v in itertools.permutations(s)]

print(abs(l.index(p)-l.index(q)))

Measured memory_bytes: 6068
S = str(input())

if S == "MON":
  print(6)
elif S== "TUE":
  print(5)
elif S== "WED":
  print(4)
elif S== "THU":
  print(3)
elif S== "FRI":
  print(2)
elif S== "SAT":
  print(1)
elif S== "SUN":
  print(7)

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

using namespace std;

int solve(){
    int n;
    cin>>n;
    if(n>=30) cout<<"Yes";
    else cout<<"No";
    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  //cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

LL N, A, B;
vector<int> v;

bool check(int n) {
    LL t = n;
    for(int i = 0; i < v.size(); ++i) {
        if(v[i] > t * B) {
            n -= (v[i] - t * B) / (A - B);
            if((v[i] - t * B) % (A - B) != 0) --n;
            if(n < 0) return false;
        }
    }
    return true;
}

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

    cin >> N >> A >> B;
    for(int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        v.pb(a);
    }

    int l, r;
    l = 0, r = 1000000000;
    while(abs(r - l) > 1) {
        int mid = (r + l) / 2;

        if(check(mid)) r = mid;
        else l = mid;
    }
    cout << r << endl;
    return 0;
}



Measured memory_bytes: 3812
#include<iostream>
using namespace std;
long long int a[100000];
int main()
{
	long long int h, n, sum = 0;
	cin >> h >> n;
	for (int i = 0; i < n; i++) {
		scanf("%lld", &a[i]);
		sum += a[i];
	}
	cout << ((sum >= h) ? "Yes" : "No");
}

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

int main() {
	ll n;
	string s;
	cin >> n >> s;
	vector<ll> left(n + 1, 0);//[0,i)のWの数
	vector<ll> right(n + 1, 0);//[i,n-1]のRの数
	for (ll i = 1; i <= n; ++i) {
		left[i] = left[i - 1] + (s[i - 1] == 'W');
		right[n - i] = right[n - i + 1] + (s[n - i] == 'R');
	}
	ll ans = 1e10;
	for (ll i = 0; i <= n; ++i) {
		ans = min(ans, max(left[i], right[i]));
	}
	cout << ans << endl;
}


Measured memory_bytes: 6788
//HowManyWays.cpp
#include<iostream>
using namespace std;

int main()
{
    int n,x,i,j,k,count;
    while(n!=0)
    {    
        cin>>n>>x;
        if (n!=0)
        {
            count=0;
            for ( i = 1; i <= n-2; i++)
            {
                for ( j = i+1; j <= n-1; j++)
                {
                    for ( k = j+1; k <= n; k++)
                    {
                        if (i+j+k==x) count++;
                    }
                }
            }
            cout<<count<<endl;
        }
    }
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)

using namespace std;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  a[0]--;
  rep(i, n-1) if (a[i] < a[i+1]) a[i+1]--;
  cout << (is_sorted(a.begin(), a.end()) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  int pa=a.size();
  int pb=b.size();
  int pc=c.size();
  if(a.at(pa-1)==b.at(0) && b.at(pb-1)==c.at(0))
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,i,j,ans=0;
  cin >> n;
  for(i=1;i<=n;i=i+2){
    int count=0;
    for(j=1;j<=i;j++){
      if(i%j==0){
        count++;
      }
    }
    if(count==8){
      ans++;
    }
  }
  cout << ans << endl;
}


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

int main (int, char**) {
    int64_t N, K;
    std::cin >> N >> K;
    int64_t sum = 0;
    int64_t max_sum = 0;
    int64_t min_sum = 0;
    for (int i=K; i<N+2; i++) {
        sum += (N - i) * i + i + 1;
        sum %= 1000000007;
    //std::cout << (N - i) * i + i + 1 << std::endl;
    }
    std::cout << sum << std::endl;
    return 0;
}

Measured memory_bytes: 3584
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

int main()
{
    ll n,a,b;
    cin >> n >> a >> b ;
    ll c=a+b;
    ll d=n/c;
    ll ans=0;
    ans+=d*a;
    ll r=n-d*c;
    ans+=min(r,a);
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector<vector<int>> mat;
//typedef unsigned int uint;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int N;
int a[3010];
int dp[3010][3010];
bool flag[3010][3010];

int dfs(int l, int r, int p)
{
	if (flag[l][r])return dp[l][r];
	flag[l][r] = true;
	if (l == r)return dp[l][r] = a[l] * (p == 0 ? 1 : -1);
	if (p == 0)
		return dp[l][r] = max(a[l] + dfs(l + 1, r, p ^ 1), a[r] + dfs(l, r - 1, p ^ 1));
	else
		return dp[l][r] = min(dfs(l + 1, r, p ^ 1) - a[l], dfs(l, r - 1, p ^ 1) - a[r]);
}

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

	cin >> N;
	rep(i, 0, N)cin >> a[i];

	cout << dfs(0,N-1,0) << endl;

	return 0;
}

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

using namespace std;

const int N=100005;

int m,n,Q;
struct func{
	int a,b,w,t,k;
	int g(int x){
		if(x<=a)return w;
		if(x<=b)return w+x-a;
		return w+b-a;
	}
	void expand(int dt){
		t+=dt;w+=dt*k;k=-k;
		if(w+b-a<=0)a=b=m,w=0;else if(w<0)a-=w,w=0;
		if(w>=m)a=b=m,w=m;else if(w+b-a>m)b-=w+b-a-m;
	}
}f[N];
bool operator<(const int&a,const func&b){return a<b.t;}

int main(){
	scanf("%d%d",&m,&n);
	f[0]=(func){0,m,0,0,-1};
	for(int i=1,t;i<=n;i++)f[i]=f[i-1],scanf("%d",&t),f[i].expand(t-f[i].t);
	scanf("%d",&Q);
	for(int t,a,p,r;Q--;){
		scanf("%d%d",&t,&a);
		p=upper_bound(f,f+n+1,t)-f-1;
		r=f[p].g(a)+(t-f[p].t)*f[p].k;
		if(r<0)r=0;if(r>m)r=m;
		printf("%d\n",r);
	}
	return 0;
}

Measured memory_bytes: 3200
/*
    Washief Hossain Mugdho
    17 September 2020
    Educational DP Grid1
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
#define mx 1000000007
using namespace std;

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif

    int h, w;
    char c;
    cin >> h >> w;
    int memo[h + 1][w + 1];
    ms(memo, 0);
    memo[0][1] = 1;
    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            cin >> c;
            if (c == '#')
                memo[i + 1][j + 1] = 0;
            else
                memo[i + 1][j + 1] = (memo[i][j + 1] + memo[i + 1][j]) % mx;
        }

    cout << memo[h][w] << endl;
}


Measured memory_bytes: 7480
#include <iostream>

constexpr int MAX_N = 10;
constexpr int MAX_D = 10;
int X[MAX_N][MAX_D];

int main() {
  int N, D;
  std::cin >> N >> D;
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < D; ++j) {
      std::cin >> X[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < N; ++i) {
    for (int j = i + 1; j < N; ++j) {
      int sum = 0;
      for (int k = 0; k < D; ++k) {
        sum += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
      }
      for (int x = 1; x * x <= sum; ++x) {
        if (x * x == sum) {
          ++ans;
          break;
        }
      }
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a.at(i);
  int cnt=0;
  int alice=0;
  int bob=0;
  sort(a.rbegin(),a.rend());
  rep(i,n){
    if(cnt%2==0){
      alice+=a.at(i);
    }else{
      bob+=a.at(i);
    }
  cnt++;
  cnt%=2;
  }
  cout << alice-bob << "\n";
  
}  

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

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

  vector<ll> H(N);

  rep(i,N){
    cin >> H[i];
  }

  ll max = H[0];

  bool ok = true;

  REP(i,N-1){
    if (max < H[i]) {
      max = H[i];
    }

    if (max - H[i] >= 2) {
      ok = false;
    }
  }

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



}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
  stack<int> st;
  while (true)
  {
    string in;
    cin >> in;
    if (in == "")
    {
      break;
    }
    if (in == "+" or in == "-" or in == "*")
    {
      int a, b;
      b = st.top();
      st.pop();
      a = st.top();
      st.pop();
      if (in == "+")
      {
        st.push(a + b);
      }
      if (in == "-")
      {
        st.push(a - b);
      }
      if (in == "*")
      {
        st.push(a * b);
      }
    }
    else
    {
      st.push(stoi(in));
    }
  }
  cout << st.top() << endl;

  return 0;
}



Measured memory_bytes: 3184
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>

#define INF 1000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(int32 i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int32 i = (b) - 1; i >= (a); --i)
#define bitget(a,b) (((a) >> (b)) & 1)
#define vint vector<int>
#define ALL(x) (x).begin(),(x).end()
#define C(x) cout << #x << " : " << x << endl
#define scanf scanf_s

using int32 = int_fast32_t;
using int64 = int_fast64_t;
using uint32 = uint_fast32_t;
using uint64 = uint_fast64_t;

using namespace std;



int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	int32 sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int32 d = tx - sx + ty - sy;
	rep(i, 0, tx - sx) {
		cout << 'R';
	}
	rep(i, 0, ty - sy) {
		cout << 'U';
	}
	rep(i, 0, tx - sx) {
		cout << 'L';
	}
	rep(i, 0, ty - sy) {
		cout << 'D';
	}
	cout << 'D';
	rep(i, 0, tx - sx+1) {
		cout << 'R';
	}
	rep(i, 0, ty - sy+1) {
		cout << 'U';
	}
	cout << "LU";
	rep(i, 0, tx - sx+1) {
		cout << 'L';
	}
	rep(i, 0, ty - sy+1) {
		cout << 'D';
	}
	cout << 'R' << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

end_frg = 0
ans = 'No'

if sum(a) == 0:
    ans = 'Yes'

elif a.count(0) == n/3 and len(set(a)) == 2:
    ans = 'Yes'

elif len(set(a)) == 3:
    [a0, a1, a2] = set(a)
    if bin(a0 ^ a1 ^ a2) == bin(0):
        if a.count(a0)==a.count(a1)==a.count(a2):
            ans = 'Yes'

print(ans)


Measured memory_bytes: 60784
#include <bits//stdc++.h>
using namespace std;
int main(void){
    int a,b,c,i,j,k;
    cin>>a;
    c=0;
    int line[a];
    for(i=0;i<a;i++){
    cin>>line[i];
    c=c+line[i];
    }
    int mini=c;
    int f=0;
    
    for(i=0;i<a;i++){
        f=f+line[i];
        int tmp;
        c=c-line[i];
        if(f<c)
        tmp=c-f;
        else
        tmp=f-c;
        if(mini>tmp)
        mini=tmp;
    }
    cout<<mini<<endl;
}


Measured memory_bytes: 256
# AOJ 0092 Square Searching
# Python3 2018.6.21 bal4u

cin = [[''] for r in range(1002)]
dp =  [[0 for c in range(1002)] for r in range(1002)]
while 1:
	n = int(input())
	if n == 0: break
	for r in range(n):
		cin[r] = input()
	ans = 0
	for r in range(n):
		for c in range(n):
			if cin[r][c] == '*': dp[r][c] = 0
			else :
				t = dp[r-1][c-1]
				if t > 0 and dp[r  ][c-1] < t: t = dp[r  ][c-1];
				if t > 0 and dp[r-1][c  ] < t: t = dp[r-1][c  ];
				t += 1
				dp[r][c] = t
				if t > ans: ans = t
	print(ans)



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

using namespace std;

typedef long long ll;

const ll mod = 1e9+7;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    vector <vector <ll>> dp(n, vector <ll> (n));
    for (int i=0; i<n; ++i)
        dp[0][i] = 1;

    for (int i=1; i<n; ++i)
    {
        for (int j=0; j<=i; ++j)
        {
            if (s[i-1] == '<' && j != 0)
                dp[i][j] = dp[i-1][j-1];
            if (s[i-1] == '>' && j != 0)
                dp[i][j] = dp[i-1][n-1] - dp[i-1][j-1] + mod;
            else if (s[i-1] == '>')
                dp[i][j] = dp[i-1][n-1];
        }
        for (int j=1; j<n; ++j)
        {
            dp[i][j] += dp[i][j-1];
            dp[i][j] %= mod;
        }
    }
    cout << dp[n-1][n-1];

    return 0;
}

Measured memory_bytes: 70656
#include <bits/stdc++.h>
using namespace std;
#define elif else if
typedef long long ll;
typedef unsigned long long ull;
#define DEBUG(x) cout << (x) << endl
#define TGET(a, b) get<b>(a)

int is_prime(ll n)
{
    double n_sqrt;
    if (n == 2 || n == 3)
    {
        return 1;
    }
    if (n <= 1 || n % 6 != 1 && n % 6 != 5)
    {
        return 0;
    }
    n_sqrt = double(sqrt((double)n));
    for (int i = 5; i <= n_sqrt; i += 6)
    {
        if (n % i == 0 | n % (i + 2) == 0)
        {
            return 0;
        }
    }
    return 1;
}
int main()
{
    int rgb[3] = {0};
    int n;
    scanf("%d", &n);
    string a;
    cin >> a;
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (a[i] == 'R')
        {
            ans += rgb[1] * rgb[2];
            rgb[0] += 1;
        }
        elif (a[i] == 'G')
        {
            ans += rgb[0] * rgb[2];
            rgb[1] += 1;
        }
        else
        {
            ans += rgb[0] * rgb[1];
            rgb[2] += 1;
        }
    }
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 2; j < n; j += 2)
        {
            int k = (i + j) / 2;
            if (a[i] != a[j] && a[i] != a[k] && a[j] != a[k])
            {
                ans -= 1;
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    cout << fixed << setprecision(10);
    
    int N; cin >> N;
    string S; cin >> S;

    // i桁目で使用した数を入れて消す
    vector<set<int>> al(3);

    ll ans = 0;
    rep(i, N-2) {
        int k1 = S[i] - '0';
        // すでに使用していればcontinue
        if (al[0].count(k1)) continue;
        al[0].insert(k1);
        repr(j, i+1, N-1) {
            int k2 = S[j] - '0';
            if (al[1].count(k1 * 10 + k2)) continue;
            al[1].insert(k1 * 10 + k2);
            repr(k, j+1, N) {
                int k3 = S[k] - '0';
                if (al[2].count(k1*100 + k2*10 + k3)) continue;
                al[2].insert(k1*100 + k2*10 + k3);
                // cout << k1 << " " << k2 << " " << k3 << endl;
                ans += 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>

#define rep(i, x, n) for (int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 60;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<long long> A(N);
    rep(i, 0, N)
    {
        cin >> A[i];
    }
    map<long long, long long> ma;
    long long sum = 0;
    ma[sum]++;
    rep(i, 0, N)
    {
        sum += A[i];
        ma[sum % M]++;
    }
    long long res = 0;
    for (map<long long, long long>::iterator it = ma.begin(); it != ma.end(); ++it)
    {
        res += it->second * (it->second - 1) / 2;
    }
    cout << res << endl;
}

Measured memory_bytes: 4992
main = getContents >>= main' . map (map read . words) . lines
    where
        main' ([x] : xs)
            | x /= 0 = return xs' >>= putStrLn . edit . solve >> main' xxs'
            | otherwise = return ()
            where
                (xs', xxs') = splitAt x xs

edit :: (Int, Int) -> String
edit (a, b) = show a ++ " " ++ show b

solve :: [[Int]] -> (Int, Int)
solve = foldl ff (0, 0)
    where
        ff (a, b) [x, y]
            | x > y = (a + x + y, b)
            | x < y = (a, b + x + y)
            | otherwise = (a + x, b + y)

Measured memory_bytes: 8232
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <stdio.h>
#include <string.h>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x && x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS * max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x * x + y * y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;


ll gcd(ll x, ll y)
{
	if (x == 0) return y;
	if (y == 0) return x;

	ll t;

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

// 最小公倍数
ll lcm(ll x, ll y)
{
	return x / gcd(x, y)*y;
}


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


	ll gc = gcd(n, m);
	ll l = lcm(n, m);

	ll ans = l;
	for (ll i=0;i<l;i+=l/gc)
	{
		if (i % (l / n) == 0 && i % (l / m) == 0)
		{
			if (s[i / (l / n)] != t[i / (l / m)])
			{
				ans = -1;
			}
		}
	}

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


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
#define watch1(x) cout<<(#x)<<" = "<<(x)<<"\n"
#define watch2(x , y) cout<<(#x)<<" = "<<(x)<<"  "<<(#y)<<" = "<<(y)<<"\n"
#define AC_ISA ACCEPTED--
#define CFT int ACCEPTED = 1
#define MYT int ACCEPTED = 1000
#define write_to_file() freopen("output.txt" , "w" , stdout)
#define GeoOutputFix(VV) cout<<fixed<<setprecision(VV)
typedef long long lld;
typedef pair<lld, lld> dd;
typedef complex<long double> point;
#define X real()
#define Y imag()
#define dist(a , b) sqrt(pow(a.X - b.X , 2) + pow(a.Y- b.Y , 2))
int dr[] = {1 , 1 , 1 , 0 , 0 , -1 , -1 , -1};
int dc[] = {-1 , 0 , 1 , -1 , 1 , -1 , 0 , 1};
int ddr[] = {1 , 0 , 0 , -1};
int ddc[] = {0 , -1 , 1 , 0};
int SD(){int i ;scanf("%d", &i);return i;}
lld SLL(){lld i;scanf("%lld", &i);return i;}
char SC(){char i;scanf("%c", &i);return i;}
const double PI = acos(-1);
const int AKA = 1e6+6 , N = 1e3 + 3;
int vis[AKA];
int main ()
{
    //write_to_file();
    string s;
    cin>>s;
    int ans = 0 , cnt = 0;
    for(int i = 0 ; s[i] ; ++i)
    {
        if(s[i] == 'A' || s[i] == 'G' || s[i] == 'T' || s[i] == 'C')
            ++cnt;
        else
            ans = max(ans, cnt) , cnt = 0;
    }
    ans = max(cnt , ans);
    printf("%d", ans);
}
/*

                                       ███████████████████████████
                                       ███████▀▀▀░░░░░░░▀▀▀███████
                                       ████▀░░░░░░░░░░░░░░░░░▀████
                                       ███│░░░░░░░░░░░░░░░░░░░│███
                                       ██▌│░░░░░░░░░░░░░░░░░░░│▐██
                                       ██░└┐░░░░░░░░░░░░░░░░░┌┘░██
                                       ██░░└┐░░░░░░░░░░░░░░░┌┘░░██
                                       ██░░┌┘▄▄▄▄▄░░░░░▄▄▄▄▄└┐░░██
                                       ██▌░│██████▌░░░▐██████│░▐██
                                       ███░│▐███▀▀░░▄░░▀▀███▌│░███
                                       ██▀─┘░░░░░░░▐█▌░░░░░░░└─▀██
                                       ██▄░░░▄▄▄▓░░▀█▀░░▓▄▄▄░░░▄██
                                       ████▄─┘██▌░░░░░░░▐██└─▄████
                                       █████░░▐█─┬┬┬┬┬┬┬─█▌░░█████
                                       ████▌░░░▀┬┼┼┼┼┼┼┼┬▀░░░▐████
                                       █████▄░░░└┴┴┴┴┴┴┴┘░░░▄█████
                                       ███████▄░░░░░░░░░░░▄███████
                                       ██████████▄▄▄▄▄▄▄██████████
                                       ███████████████████████████
                             ▂▃▄▅▆▇█▓▒░Ahmed_Salah(Screaming Eagle)░▒▓█▇▆▅▄▃    */


Measured memory_bytes: 256