akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int n,m,k,i,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,l[4],y,a,c,z,o[4][1140010],d,b;
stack<int> s;
struct P
{
    int x,y;
    long long z;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
string r[3];
vector<P> v[1000100];
//vector<long long> ;
bool sdf(long long a,long long b){return a>b;}

long long f(long long t,long long w)
{
    if(w>b) return -987654321000;
    if(t==4) return 0;
    long long i=0;
    for(long long h=0;h<=l[t];h++)
        i=max(i,f(t+1,w+h*(k+t))+o[t][h]);
    return i;
}

int main()
{
    scanf("%lld %lld",&a,&b);
    scanf("%lld %lld",&c,&d);
    k=c;
    l[0]=1;
    o[0][1]=d;
    for(int t=2;t<=a;t++)
    {
        scanf("%lld %lld",&c,&d);
        l[c-k]++;
        o[c-k][l[c-k]]=d;
    }
    for(int t=0;t<4;t++)
    {
        sort(o[t]+1,o[t]+l[t]+1,sdf);
        for(int w=1;w<=l[t];w++)
            o[t][w]=o[t][w-1]+o[t][w];
    }
    printf("%lld",f(0,0));
    return 0;
}

Measured memory_bytes: 30976
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=105;
int b[N],n,res;
int main(){
	scanf("%d",&n);
	fp(i,1,n-1)scanf("%d",&b[i]);
	b[0]=b[n]=233333;
	fp(i,1,n)res+=min(b[i],b[i-1]);
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6) 

def memorize(f):
    table = {}
    def func(*args):
        if not args in table:
            table[args] = f(*args)
        return table[args]
    return func

@memorize
def memDFS(n):
    if n==0:
        return 0
    else:
        res = n
        pow6 = 1
        while(pow6<=n):
            res = min(res, memDFS(n-pow6)+1)
            pow6 *= 6
        pow9 = 1
        while(pow9<=n):
            res = min(res, memDFS(n-pow9)+1)
            pow9 *= 9
        return res

N = int(input())
print(memDFS(N))

Measured memory_bytes: 237548
use std::io::{self, BufRead};

fn main() {
    let stdin = io::stdin();
    let s = stdin.lock().lines().next().unwrap().unwrap();

    let ans = match s.as_str() {
        "SUN" => 7,
        "MON" => 6,
        "TUE" => 5,
        "WED" => 4,
        "THU" => 3,
        "FRI" => 2,
        "SAT" => 1,
        _ => panic!(),
    };

    println!("{}", ans);
}


Measured memory_bytes: 4352
# coding: utf-8
# Your code here!
import fractions as f
MOD=10**9+7
fac=[i for i in range(10**6+1)]
inv=[0]*(10**6+1)
inv[1]=1
for i in range(2,10**6+1):
    inv[i]=MOD-inv[MOD%i]*(MOD//i)%MOD
#print(inv)
MOD=10**9+7
n=int(input())
a=list(map(int,input().split()))
cnt=a[0]
for i in range(n):
    cnt=(a[i]*cnt)//f.gcd(a[i],cnt)
ans=0
cnt=cnt%(10**9+7)
for i in range(n):
    ans+=inv[a[i]]*cnt
    ans=ans%(10**9+7)
    #print(ans)
print(ans)

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

int main(void){
    int N;
    cin >> N;
    vector<int> s(N);
    for(int i=0; i<N; i++){
        cin >> s.at(i);
    }
    int ans;
    for(int i=1; i <= N; i++){
      int temp=0;
      for(int j=0; j<N; j++){
        if(s.at(j) >= i){
            temp++;
        }
      }
      if(temp >= i){
         ans = i;
      }
    }
    cout << ans << endl;
    return 0;
}



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

#ifdef _DEBUG
#define debug(x) cerr << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#else
#define debug(x)
#endif

#define all(s) begin(s), end(s)
#define rall(s) rbegin(s), rend(s)
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = ((a)-1); i >= (b); i--)
#define pb push_back
#define sz(a) int((a).size())
#define put(a) ((cout) << (a) << (endl))
#define putf(a, n) ((cout) << (fixed) << (setprecision(n)) << (a) << (endl))

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL_INF = 1LL << 60;
static constexpr int I_INF = 1 << 28;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class T> static inline T gcd(T a, T b);
template <class T> static inline T lcm(T a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

int main(int argc, char* argv[]) {
  string s;
  cin >> s;

  int zero = 0, one = 0;
  for (char c : s) {
    if (c == '0') zero++;
    if (c == '1') one++;
  }

  ll ans = min(zero, one) * 2;
  put(ans);
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[i]);
  }
}

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 T gcd(T a, T b) { return __gcd(a, b); }

template <class T> inline T lcm(T a, T b) { return (a * b) / gcd(a, b); }

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 512
/*
                                                              _        ___    
                                                             //      /        
----__----------------)__----__------__--_/_----__---)__-----/------/___------
  /   ) /   / /   /  /   ) /   )   /   ) /    /   ) /   )   /      /    )     
_(___(_(___/_(___(__/_____(___(___/___/_(_ __(___/_/_______/______(____/______
          /                      /                                            
      (_ /                      /                                             */
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define double long double
#define repo(i, begin, end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define ll long long
#define bug(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<"  ";
#define fastr ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define rrep(i,a,b) for(int i = (a-1); i >= b; i--) 
#define fi first
#define se second
#define tit(v,i,c) get<c>(v[i])
#define mt make_tuple 
#define pb push_back
#define eb emplace_back
#define mp make_pair
double jk=0.004;
#define power(x,y) pow(x,y)+jk
#define endl "\n"
const long long mod=1e9+7;
const long long N=1000000000;
const int val=1000005;
int in(){
int n;cin>>n;
return n;}
void _do_(){
	int a,b;cin>>a>>b;
	cout<<a*b<<endl;

	



















	

}
signed main(){
fastr
int tc;
//cin>>tc;
tc=1;
while(tc--)_do_();
cerr<<"Time elapsed:";
cerr<<1000*clock()/CLOCKS_PER_SEC<<" ms ";
return 0;}

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int backUp = N;
        int ans = 0;
        while(N!=0){
            ans += N%10;
            N = N/10;
        }
        String t="Yes";
        if(backUp%ans!=0) t="No";
        System.out.println(t);
    }
}

Measured memory_bytes: 20052
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef double db; //
typedef string str; //
//
typedef pair<int,int> pi;
typedef pair<ll,ll> pl; //
typedef pair<db,db> pd; //
//
typedef vector<int> vi; 
typedef vector<ll> vl; //
typedef vector<db> vd; //
typedef vector<str> vs; //
typedef vector<pi> vpi;
typedef vector<pl> vpl; //
typedef vector<pd> vpd; //
 
typedef tree<pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
 
#define mp make_pair
#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() //
#define rsz resize
#define ins insert //
#define ft front() //
#define bk back()
#define pf push_front //
#define pb push_back
#define eb emplace_back //
#define lb lower_bound //
#define ub upper_bound //
 
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(a,x) for (auto& a: x)
 
const int MOD = 1e9+7; // 998244353;
const int MX = 2e5+5; //
const ll INF = 1e18; //
const ld PI = acos((ld)-1);
const int xd[4] = {1,0,-1,0}, yd[4] = {0,1,0,-1}; //
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); //
//
template<class T> bool ckmin(T& a, const T& b) { 
	return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { //
	return a < b ? a = b, 1 : 0; } //
constexpr int pct(int x) { return __builtin_popcount(x); } //
constexpr int bits(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) //
constexpr int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 //
// IGNORE
int fstTrue(function<bool(int)> f, int lo, int hi) {
	hi ++; assert(lo <= hi); // assuming f is increasing
	while (lo < hi) { // find first index such that f is true 
		int mid = (lo+hi)/2; 
		f(mid) ? hi = mid : lo = mid+1; 
	} 
	return lo;
}
template<class T> void remDup(vector<T>& v) { 
	sort(all(v)); v.erase(unique(all(v)),end(v)); }
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
 
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
// IGNORE
//
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int N;
	cin >> N;
	string c;
	cin >> c;
	int w = 0;
	int r = N - 1;
	int cnt = 0;
	while(r > w){
		while(r > w && c[w] == 'R')
			w++;
		while(r > w && c[r] == 'W')
			r--;
		if(r == w)
			break;
		cnt++;
		w++;
		r--;
	}
	cout << cnt << endl;
}


Measured memory_bytes: 3772
def main():
    n,t = map(int,input().split())
    a = list(map(int,input().split()))
    b = [0]*n
    ma = a[0]
    mi = a[0]

    for i in range(1,n):
        if a[i] > ma:
            ma = a[i]
            b[i] = ma-mi
        if a[i] < mi:
            ma = a[i]
            mi = a[i]
    print(b.count(max(b)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 62704
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b != c) {
    cout << "Yes" << endl;
  }
  else if (a != b && a == c) {
    cout << "Yes" << endl;
  }
  else if (a != c && b == c) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}

Measured memory_bytes: 256
from itertools import permutations
n = list(range(1, int(input())+1))
p = tuple(map(int,input().split()))
q = tuple(map(int,input().split()))
# p = ''.join(a)
# q = ''.join(b)
pp , qq = 0, 0
for i, j in enumerate(permutations(n)):
    if j == p:
        pp = i+1
    if j == q:
        qq = i+1
    if pp and qq:
        break
print(abs(pp-qq))

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

struct StPoint
{
  StPoint() :
    m_nTime(0), m_nPntX(0), m_nPntY(0)
  { }

  int m_nTime;
  int m_nPntX;
  int m_nPntY;
};

void fnInput(vector<StPoint>& rvoPoint)
{
  StPoint oPoint;
  int nSiz;
  cin >> nSiz;

  rvoPoint.resize(nSiz + 1, oPoint);
  for (int i = 0; i < nSiz; i++)
    cin >> rvoPoint[i + 1].m_nTime >> rvoPoint[i + 1].m_nPntX >> rvoPoint[i + 1].m_nPntY;
}

int fnTravel(const vector<StPoint>& cnrvoPoint)
{
  for (int i = 0; i < cnrvoPoint.size() - 1; i++)
  {
    int nTime = cnrvoPoint[i + 1].m_nTime - cnrvoPoint[i].m_nTime;
    int nDist = abs(cnrvoPoint[i + 1].m_nPntX - cnrvoPoint[i].m_nPntX)
              + abs(cnrvoPoint[i + 1].m_nPntY - cnrvoPoint[i].m_nPntY);

    if (nTime < nDist)           return 0;
    if (nTime % 2 != nDist % 2)  return 0;
  }
  return 1;
}

int main()
{
  vector<StPoint> voPoint;

  fnInput(voPoint);
  if (fnTravel(voPoint))  cout << "Yes" << endl;
  else                    cout << "No"  << endl;

  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

pair<int, int> dfs(vector<vector<int>> &g, int v, int par) {
    if (g[v].size() == 1 && g[v][0] == par) return make_pair(1, v);
    pair<int, int> ret;
    for (auto &e: g[v]) {
        if (e == par) continue;
        ret = max(ret, dfs(g, e, v));
    }
    ret.first++;
    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<vector<int>> g(n);
    for (int i = 0; i < n-1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    int v = dfs(g, 0, -1).second;
    int dia = dfs(g, v, -1).first;

    int t = dia % 3;
    if (t == 0 || t == 1) {
        cout << "First" << endl;
    } else {
        cout << "Second" << endl;
    }

    return 0;
}


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

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

   cout << max({a+b, a-b, a*b}) << endl;
}

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

CB = []
for i in range(M):
  b, c = map(int, input().split())
  CB.append([c, b])

D = [[a, 1] for a in A] + CB

D.sort()

ans = 0
while N > 0:
  c, b = D.pop()
  ans += min(N, b)*c
  N -= b

print(ans)

Measured memory_bytes: 92696
n, m, k = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
a, b = [0], [0]
_sum = 0

for i in range(n):
  a.append(a[i] + A[i])
for i in range(m):
  b.append(b[i] + B[i])
  
j = m
counts = [0]
for i in range(n + 1):
  if (a[i] > k):
    break
  while b[j] > k - a[i]:
    j -= 1
  counts.append(i + j)
  
print (max(counts))

Measured memory_bytes: 48808
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val ns = Vector.fill(n)(sc.nextInt())

    val value = ns.map(l(_))
    println(value.count(_ == true))

  }

  def l(x: Int, i: Int = 2): Boolean = {
    def ll(x: Int, c: Int, i: Int): Boolean = {
      x match {
        case 2 => true
        case _ if x % i == 0 => false
        case _ if i >= c => true
        case _ => ll(x, c, i + 1)
      }
    }
    ll(x, Math.ceil(Math.sqrt(x)).toInt, i)
  }

}



Measured memory_bytes: 58700
#!/usr/bin/env python
import sys
from collections import Counter
from itertools import permutations, combinations
from fractions import gcd
#from math import gcd
from math import ceil, floor
import bisect
sys.setrecursionlimit(10 ** 6)
inf = float("inf")

def input():
    return sys.stdin.readline()[:-1]

def main():
    N, Q = map(int, input().split())
    S = input()
    L = [None] * Q
    R = [None] * Q
    for i in range(Q):
        L[i], R[i] = map(int, input().split())

    s = [0] * (N+1)
    for i in range(N):
        if i+1 < N and S[i] == 'A' and S[i+1] == 'C':
            s[i+1] = s[i] + 1
        else:
            s[i+1] = s[i]
        
    for i in range(Q):
        print(s[R[i]-1] - s[L[i]-1])

if __name__ == '__main__':
    main()



Measured memory_bytes: 79704
// 01-BFS 解
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)

int main()
{
	fast();

	using P = pair<int, int>;

	// d[0] : うえ, d[1] : みぎ, d[2] : した, d[3] : ひだり
	int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
	int H, W, K;
	cin >> H >> W >> K;
	vector<string> grid(H);
	vector<vector<vector<P>>> d(H);

	int sx, sy, gx, gy;

	cin >> sx >> sy >> gx >> gy;
	sx--, sy--, gx--, gy--;

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

	for (int i = 0; i < H; i++) // init
	{
		d[i] = vector<vector<P>>(W, vector<P>(4, P(inf, inf)));
	}

	// (x, y), dir
	deque<pair<P, int>> que;
	for (int i = 0; i < 4; i++)
	{
		d[sx][sy][i] = P(1, 0);
		que.push_back({P(sx, sy), i});
	}

	while (!que.empty())
	{
		auto v = que.front();
		que.pop_front();
		int vx = v.first.first, vy = v.first.second, dir = v.second;

		for (int i = 0; i < 4; i++) // 向きを変える
		{
			if (i == dir)
				continue;
			P ncost = make_pair(d[vx][vy][dir].first + 1, 0);

			if (d[vx][vy][i] <= ncost)
				continue;

			d[vx][vy][i] = ncost;

			que.push_back({P(vx, vy), i});
		}

		// 直進する
		int nx = vx + dx[dir], ny = vy + dy[dir];

		if (nx < 0 || nx >= H || ny < 0 || ny >= W) // grid の外
			continue;
		if (grid[nx][ny] == '@') // 行き止まり
			continue;

		int df = d[vx][vy][dir].first, ds = d[vx][vy][dir].second;
		P ncost = make_pair(df + (ds + 1) / (K + 1), ds % K + 1);
		if (d[nx][ny][dir] <= ncost)
			continue;
		d[nx][ny][dir] = ncost;

		if (ds >= K)
			que.push_back({P(nx, ny), dir});
		else
			que.push_front({P(nx, ny), dir});
	}

	int min_cost = (*min_element(d[gx][gy].begin(), d[gx][gy].end())).first;

	cout << (min_cost == inf ? -1 : min_cost) << "\n";
}


Measured memory_bytes: 79196
#include <stdio.h>

char S[100100];

int main()
{
	scanf("%s", S);
	for (int i=1;S[i];i++) if (S[i-1] == S[i]){
		printf("%d %d\n", i, i+1);
		return 0;
	}
	for (int i=2;S[i];i++) if (S[i-2] == S[i]){
		printf("%d %d\n", i-1, i+1);
		return 0;
	}
	printf("-1 -1\n");

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define NIL -1
#define INF 1000000
#define WHITE -46
#define BLACK -96

int G[101][101];
int d[101];
int pi[101];
int color[101];
int n;

void prim(int);
void initializeSingleSource(int);

int main(){
  int i,j,t,e,g,a1,a2;

  scanf("%d",&n);

  for(i=0; i < n; i++){
    for(j=0; j < n; j++){
      G[i][j] = NIL;
    }
  }
  
  for(i=0; i < n; i++){
    scanf("%d",&e);
    scanf("%d",&g);
    for(j=0; j < g; j++){
      scanf("%d",&a1);
      scanf("%d",&a2);
      G[e][a1] = a2;
    }
  }

  prim(0);

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

  return 0;
}

void prim(int r){
  int i,u,v,s=0,mincost;
  
  initializeSingleSource(s);

  while(1){
    mincost = INF;
    for(i=0; i < n; i++){
      if(color[i] != BLACK && d[i] < mincost){
	mincost = d[i];
	u = i;
      }
    }
    if(mincost == INF){
      break;
    }
    color[u] = BLACK;
    for(v=0; v < n; v++){
      if(color[v] != BLACK && (d[u] + G[u][v]) < d[v] && G[u][v] != NIL){
	pi[v] = u;
	d[v] = d[u] + G[u][v];
      }
    }
  }
}
void initializeSingleSource(int s){
  int i;
  for(i=0; i < n; i++){
    d[i] = INF;
    pi[i] = NIL;
  }
  d[s] = 0;
}



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

int main() {
	int n[3];
	int f = 0, s = 0; //f > five, s > seven

	for (int i = 0; i < 3; ++i) {
		cin >> n[i];
		if (n[i] == 5) ++f;
		else if (n[i] == 7) ++s;
	}
	if (f == 2 && s == 1) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
<?php
$n = intval(fgets(STDIN));
$s = intval(fgets(STDIN));

function f($b, $n){
    if($n < $b)return $n;
    return f($b, intdiv($n, $b)) + $n % $b;
}
if($n == $s){
    echo $n+1,"\n";exit;
}
for($i = 2, $I = sqrt($n); $i <= $I; $i++){
    if(f($i, $n) == $s){
        echo $i,"\n";exit;
    }
}
$minB = 10**18;
for($p = 1, $P = sqrt($n); $p <= $P; $p++){
    $q = $s - $p;
    if(($n-$q) % $p != 0)continue;
    $b = ($n-$q)/$p;
    if($b >= 2 && f($b, $n) == $s){
        $minB = min($minB, $b);
    }
}
if($minB == 10**18){
    echo -1,"\n";
}else{
    printf("%d\n", $minB);
}

Measured memory_bytes: 4732
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
n, m, x = map(int, input().split())
cs = [0] * n
As = [[0] * m] * n

for i in range(n):
    cs[i], *As[i] = list(map(int, input().split()))

ans = 10 ** 8  # 十分に大きい初期値

for i in range(2 ** n):
    # 初期値
    amount = 0
    probs = [0] * m
    flags = bin(i)[2:].zfill(n)

    for j in range(n):
        c = cs[j]
        val = int(flags[j])
        amount += val * c
        for k in range(m):
            probs[k] += val * As[j][k]

    if (len(list(filter(lambda p: p < x, probs))) == 0):
        ans = min(ans, amount)


if (ans == 10 ** 8):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9164
package main

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

func main() {
	a, b := readInt(), readInt()
	if b%a == 0 {
		fmt.Println(a + b)
	} else {
		fmt.Println(b - a)
	}
}

// sort ------------------------------------------------------------

type xxx struct {
	x int
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].x < s[j].x }

// -----------------------------------------------------------------

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

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
}

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

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 640
N = int(input())
dic = {}
max_v = 0

for i in range(N):
    temp = input()
    if temp in dic:
        dic[temp] += 1
    else:
        dic[temp] = 1
    max_v = max(max_v, dic[temp])

keys = sorted(dic.keys())
for k in keys:
    if dic[k] == max_v:
        print(k)


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

int main(int argc, char const *argv[]) {
  int h, w;

  cin >> h >> w;

  while (!(h == 0 && w == 0)) {
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if ((i % 2 == 0 && j % 2 == 0) || (i % 2 == 1 && j % 2 == 1))
          cout << "#";
        else
          cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }

  return 0;
}


Measured memory_bytes: 3116
import bisect
n=int(input())
L=[]*n
L=list(map(int,input().split()))
L.sort()
cnt=0
for i in range(n-1):
    for j in range(i+1,n):
        ab=L[i]+L[j]
        num=bisect.bisect_left(L[j+1:],ab)
        cnt+=num
print(cnt)

Measured memory_bytes: 51804
#include <stdio.h>
int main() {
    int n, i;
    int dataa[100];
    int data[100];
    scanf("%d", &n);
    for(i = 0; i < n; i++) scanf("%d", &dataa[i]);
    for(i = 0; i < n; i++) {
        data[i] = dataa[n - i - 1];
        if(i > 0) {
            printf(" ");
        }
        printf("%d", data[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 1756
k = int(input())
a = (1 + k) * k // 2
three = (3+3*(k//3)) * (k // 3) // 2
five = (5+5*(k//5)) * (k // 5) // 2
fifteen = (15+15*(k//15)) * (k // 15) // 2
print(a-three-five+fifteen)

Measured memory_bytes: 9188
#include<stdio.h>
#include<stdlib.h>
#define N 100
#define INF 1000000
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int a[N][N];

typedef struct node{
	int id;
	int cost;
}node;

void swap(node h[],int x,int y){
	node temp=h[x];
	h[x]=h[y];
	h[y]=temp;
	return;
}


void heapsort(node heap[],int num){

	for(int i=num-1;i>0;i--){
		if(i%2==0){
			if(heap[i].cost < heap[i/2-1].cost)swap(heap,i,i/2-1);
		}
    else {
			if(heap[i].cost < heap[i/2].cost)swap(heap,i,i/2);
		}
	}

	return;

}

int update_heap(node heap[],int num){
	int u=heap[0].id;
	swap(heap,0,num-1);
	num--;

	for(int i=0;i<num;i++){
		heap[i].cost=MIN(heap[i].cost,a[u][heap[i].id]);
	}

	return num;
}




int main(){
	int i,j,n;
	int num=0;/*heapの要素の個数*/
	int ans=0;
	node heap[N];


	scanf("%d",&n);


	/*隣接行列の読み込み*/
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			scanf("%d",&a[i][j]);
			if(a[i][j]==-1)a[i][j]=INF;
		}
	}

	/*0以外の頂点をinsert*/
	for(i=1;i<n;i++){
		heap[num].cost=a[0][i];
		heap[num++].id=i;
	}

	/*heapを昇順にソート*/
	heapsort(heap,num);

	while(num!=0){
		ans+=heap[0].cost;
		num=update_heap(heap,num);
		heapsort(heap,num);
	}

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

	return 0;
}



Measured memory_bytes: 2040
s = input()
n = len(s)
i = 0
j = 0
ans = 0
while i < n:
    if s[i] == "A":
        j += 1
        i += 1
    elif i + 1 < n and s[i:i + 2] == "BC":
        ans += j
        i += 2
    else:
        j = 0
        i += 1
print(ans)


Measured memory_bytes: 40304
#include<cmath>
#include<cstdio>
#include<vector>
#include<numeric>

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

using namespace std;

const double EPS=1e-8;

const int M_MAX=1100,N_MAX=1100;

// minimize cx s.t. Ax<=b
enum{SOLVABLE,UNBOUNDED,INFEASIBLE};
int simplex(int m,int n,const double A_in[M_MAX][N_MAX],const double *b,const double *c,double *x){
	static double A[M_MAX+1][N_MAX+M_MAX+1];
	rep(j,n+m+1) A[0][j]=(j<n?c[j]:0);
	rep(i,m) rep(j,n+m) A[i+1][j]=(j<n?A_in[i][j]:i==j-n?1:0);
	rep(i,m) A[i+1][n+m]=b[i];

	int bas[M_MAX+1];
	rep(i,m) bas[i+1]=n+i;
	n+=m;

	while(1){
		int p,q;
		for(q=0;q<=n;q++) if(A[0][q]<-EPS) break;
		for(p=1;p<=m;p++) if(A[p][q]> EPS) break;
		for(int i=p+1;i<=m;i++) if(A[i][q]>EPS){
			double ri=A[i][n]/A[i][q],rp=A[p][n]/A[p][q];
			if(ri<rp-EPS || abs(ri-rp)<EPS && bas[i]<bas[p]) p=i;
		}
		if(q>n) break;
		if(p>m) return UNBOUNDED;

		// pivoting
		rep(i,m+1) if(i!=p) rep(j,n+1) if(j!=q) A[i][j]-=A[p][j]*A[i][q]/A[p][q];
		rep(i,m+1) if(i!=p) A[i][q]=0;
		rep(j,n+1) if(j!=q) A[p][j]/=A[p][q];
		A[p][q]=1;

		bas[p]=q;
	}

	n-=m;
	rep(i,n) x[i]=0;
	for(int i=1;i<=m;i++) if(bas[i]<n) x[bas[i]]=A[i][n+m];

	return SOLVABLE;
}

struct edge{ int v,cost,id; };

int main(){
	int n,m; scanf("%d%d",&n,&m);
	vector<edge> G[100];
	rep(i,m){
		int u,v,cost; scanf("%d%d%d",&u,&v,&cost);
		G[u].push_back((edge){v,cost,i});
	}

	int d[100]={};
	rep(u,n) rep(i,G[u].size()) {
		int v=G[u][i].v,cost=G[u][i].cost;
		d[v]=max(d[v],d[u]+cost);
	}

	static double A[M_MAX][N_MAX],b[M_MAX],c[N_MAX],x[N_MAX];
	rep(i,n){
		A[i][i]=1;
		b[i]=d[n-1]-d[i];
	}
	rep(u,n) rep(k,G[u].size()) {
		int v=G[u][k].v,cost=G[u][k].cost,i=G[u][k].id;
		A[n+i][n+i]=1;
		A[n+i][u]=1;
		A[n+i][v]=-1;
		b[n+i]=d[v]-d[u]-cost;
	}
	rep(i,m) c[n+i]=-1;

	simplex(n+m,n+m,A,b,c,x);

	printf("%.0f\n",-inner_product(c,c+n+m,x,0.0)+EPS);

	return 0;
}

Measured memory_bytes: 28884
#include<cstdio>
#include<complex>
#include<vector>
#include<algorithm>

#define pb push_back
#define sz size()
using namespace std;

typedef complex<double> P;

namespace std{
  bool operator<(const P &a,const P &b){
    return real(a)==real(b)?imag(a)<imag(b):real(a)<real(b);
  }
}

double cross(P x,P y){return imag(conj(x)*y);}

vector<P> convex_hull(vector<P> v){
  int n = v.sz, k = 0;
  sort(v.begin(),v.end());
  vector<P> r(2*n);
  for(int i=0;i<n;i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= 0)k--;
    r[k++] = v[i];
  }
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-1]) <= 0)k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

int main(){
  int n;
  vector<P> v;
  P tmp;

  while(scanf("%d",&n),n){
    v.clear();
    for(int i=0;i<n;i++){
      scanf("%lf,%lf",&real(tmp),&imag(tmp));
      v.pb(tmp);
    }

    printf("%d\n",n-(int)convex_hull(v).sz);
  }
}

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

int main() {
	int N;
	int ch;
	int nei;
	int cnt = 0;
	int i;

	scanf("%d", &N);

	cnt = 0;
	getchar();
	for(i = 0; i < N; i++) {
		ch = getchar();
		if(nei != ch) {
			cnt++;
			nei = ch;
		}
	}

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

Measured memory_bytes: 128
#include<iostream>

using namespace std;

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

  string c="";
  for(int i=s.size()-1;i>=0;i--){
    c+=s[i];
  }

  if(c==s) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
li=[0]*n
d=[0]*n
total=0
for i in range(0,n):
  total+=w[i]
  li[i]=total

for j in range(0,n):
  if li[j]>=li[n-1]-li[j]:
    d[j]=li[j]*2-li[n-1]
  else:
    d[j]=li[n-1]-2*li[j]
    
print(min(d))    

  
  

Measured memory_bytes: 3064
n = int(input())
a = list(map(int, input().split()))
lcm = a[0]

def gcd(a, b):
    if a > b:
        a, b = b, a
    while b > 0:
        a, b = b, a % b
    return a

for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
mod = 10**9 + 7
ans = 0
for i in range(n):
    ans += lcm // a[i]
print(ans % mod)


Measured memory_bytes: 4084
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}

int N,M;


int main(){
  int N,K;
  cin >> N >> K;
  if(N < K) cout << 1 << endl;
  else if(N % K == 0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
void *wmem;
char memarr[96000000];
template<class T> inline void walloc1d(T **arr, int x, void **mem = &wmem){
  static int skip[16] = {0, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1};
  (*mem) = (void*)( ((char*)(*mem)) + skip[((unsigned long long)(*mem)) & 15] );
  (*arr)=(T*)(*mem);
  (*mem)=((*arr)+x);
}
template<class T1> void sortA_L(int N, T1 a[], void *mem = wmem){
  sort(a, a+N);
}
template<class T1, class T2> void sortA_L(int N, T1 a[], T2 b[], void *mem = wmem){
  int i;
  pair<T1, T2> *arr;
  walloc1d(&arr, N, &mem);
  for(i=(0);i<(N);i++){
    arr[i].first = a[i];
    arr[i].second = b[i];
  }
  sort(arr, arr+N);
  for(i=(0);i<(N);i++){
    a[i] = arr[i].first;
    b[i] = arr[i].second;
  }
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void rd(long long &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  int s=0;
  int m=0;
  char f[10];
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
template<class S, class T> inline S chmin(S &a, T b){
  if(a>b){
    a=b;
  }
  return a;
}
int N;
long long X[100000];
long long L[100000];
int main(){
  int i;
  wmem = memarr;
  int res = 0;
  long long mn = -4611686016279904256LL;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(X[Lj4PdHRW]);
      rd(L[Lj4PdHRW]);
    }
  }
  for(i=(0);i<(N);i++){
    X[i] -= L[i];
  }
  for(i=(0);i<(N);i++){
    L[i] = X[i] + 2 * L[i];
  }
  sortA_L(N, X, L);
  for(i=(0);i<(N);i++){
    if(X[i] >= mn){
      res++;
      mn = L[i];
      continue;
    }
    chmin(mn, L[i]);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20200119-1

// --- original code ---
// int N; ll X[1d5], L[1d5];
// {
//   int res = 0;
//   ll mn = -ll_inf;
//   rd(N,(X,L)(N));
//   rep(i,N) X[i] -= L[i];
//   rep(i,N) L[i] = X[i] + 2 * L[i];
//   sortA(N, X, L);
//   rep(i,N){
//     if(X[i] >= mn) res++, mn = L[i], continue;
//     mn <?= L[i];
//   }
//   wt(res);
// }


Measured memory_bytes: 4352
n = int(input())
p = list(map(int,input().split()))

c = 0

for i in range(n) :
  if p[i] != i+1 :
    c += 1
    if c>2 :
      break

if (c==0 or c==2) :
  print('YES')
else :
  print('NO')

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
#define NIL -1
const double PI  = acos(-1.0);
const int INF = 1e9 + 7;
//-------------------------------------------


char c[55][55];
int dx[4] = { 0, 1 , -1 , 0};
int dy[4] = { -1, 0, 0, 1};

int main(){

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

    int h , w;
    bool flag = true;

    cin >> h >> w;

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

    REP(i, h){
        REP(j, w){
            if( c[i][j] == '#'){
                bool found = false;

                REP(k, 4){
                    int nx = j + dx[k];
                    int ny = i + dy[k];

                    if( c[ny][nx] == '#'){
                        found = true;
                        break;
                    }
                }

                if( !found){
                    flag = false;
                }

                /*if (c[i][j + 1] == '.' && c[i][j - 1] == '.' && c[i - 1][j] == '.' &&c[i + 1][j] == '.'){
                    flag = false;
                    break;
                }
                */
            }
        }
    }

    /*
    if (flag == 0){ cout << "No" << endl;}
    else { cout << "Yes" << endl;}*/

    cout << (flag ? "Yes": "No" )<< endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,K,Q;
    cin >> N >> K >> Q;
    vector<int>member(N,K-Q);
    rep(i,Q){
        int A;
        cin >> A;--A;
        member[A]++;
    }
    rep(i,N){
        if(member[i]>0)cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  cout << (a + b + c < 22 ? "win" : "bust") << endl;
  return 0;
}

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

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

int n;
int a[N], b[N];

int main() {
	// #define TASK "test"
 //  #ifndef ONLINE_JUDGE
	// 	freopen(TASK".inp", "r", stdin); 
	// 	freopen(TASK".out", "w", stdout);
	// #endif
	ios_base :: sync_with_stdio(false); cin.tie(NULL);
	cin >> n;
	int cnt = 0;
	int d = 0, d2 = 0, d4 = 0;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		if (a[i] % 4 == 0) d4++;
		else if (a[i] % 2 == 0) d2++;
	}
	d = n - d2 - d4;
	if (d4 >= d) cout << "Yes";
	else if (d4 == d - 1) {
		if (d2 == 0) cout << "Yes";
		else cout << "No";
	} else cout << "No";
	return 0;
}

Measured memory_bytes: 640
s = input()

cond1 = s[0] == "A"
cond2 = s[2 : len(s) - 1].count("C") == 1
cond3 = (s[1 : len(s) -1].replace("C", "c") + s[-1]).islower()
if  all((cond1, cond2, cond3)):
  print("AC")
else:
  print("WA")

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;
int main() {
	int n, m;
	cin >> n >> m;
	int k;
	vector<vector<int>>s(m);
	for (int i = 0; i < m; i++) {
		cin >> k;
		s[i].resize(k);
		for (int j = 0; j < k; j++) {
			cin >> s[i][j];
			s[i][j]--;
		}
	}
	vector<int>p(m);
	for (int i = 0; i < m; i++) {
		cin >> p[i];
	}
	
	int ans = 0;
	for (int bit = 0; bit < (1 << n); bit++) {
		bool ok = true;
		for (int j = 0; j < m; j++) {
			int count = 0;
			for (auto id : s[j]) {
				if (bit & (1 << id)) {
					count++;
				}
			}
			if (count % 2 != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			ans++;
		}
	}
	cout << ans << endl;
}

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

int x, y;

int main(){
  cin >> x >> y;
  for(int i=  0; i <= x; i++){
    int tmp = x - i;
    if(2 * i + 4 * tmp == y)
      return cout << "Yes" << endl, 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define f first
#define s second
#define pr(x) cout<<x<<endl;
#define pr2(x,y) cout<<x<<" "<<y<<endl;
#define pr3(x,y,z) cout<<x<<" "<<y<<endl;
#define prv(v) for(auto x:v) cout<<x<<" ";
#define ffs fflush(stdout);
#define int ll
using namespace std;
 
const ll N =(2e5+5);
const ll MOD = 1e9+7;
const ll INF = LLONG_MAX;
const ll LOG = 29;
#define PI 3.141592653589793238 
 
 
long long binpow(long long a, long long b) {
    a%=MOD;    
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res * a)%MOD;
        a = (a * a)%MOD;
 
        
        b >>= 1;
    }
    res%=MOD;
    return res;
}
vll adj[N];
bool vis[N];
ll cnt = 0;

void dfs(ll u){
    vis[u]=true;
    for(auto v:adj[u]){
        if(!vis[v])
            dfs(v);
    }
    cnt++;
}

void solve(){

    ll n,m;
    cin>> n >> m;
    ll src = -1;
    for(int i =1;i<=m;i++){
        ll u,v;
        cin>> u >> v;
        if(src==-1)src=  u;
        adj[u].pb(v);
    
        adj[v].pb(u);
    
    }

    for(int i =1;i<=n;i++){
        ll d = adj[i].size()*1ll;
        if(d % 2!=0){
            cout<<"NO\n";
            return;
        }
    }
    cout<<"YES\n";
}
 
 
signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     
    ll t=1;
    while(t--){
        solve();
    }    
}


Measured memory_bytes: 8448
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//
void print(vector<int> vec){
  int n = SZ(vec) ;
  REP(i,n){
    cout << vec.at(i) <<" " ;
  }
  cout <<endl ;
}
  


//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n ;
  cin >> n ;
  vector<int> a(n) ;
  REP(i,n){
    cin >> a.at(i) ;
  }
  deque<int> deq ;
  vector<int> ans ;
  REP(i,n){
    if(i%2==0){
      deq.push_front(a.at(i)) ;
    }
    else{
      deq.push_back(a.at(i)) ;
    }
  }
  if(n%2==0){
    REP(i,n){
      ans.push_back(deq.back()) ;
      deq.pop_back() ;
    }
  }
  else{
    REP(i,n){
      ans.push_back(deq.front()) ;
      deq.pop_front() ;
      }
  }
  print(ans) ;      
    
      
  
  
  return 0 ;
}




Measured memory_bytes: 5496
from math import gcd

def lcm(a, b):
    _a = a
    while a % b != 0:
        a += _a
    return a


#def gcd(a, b):
 #   if a % b == 0:
  #      return a
   # return gcd(b, a % b)


N, M = map(int, input().split())
#N = max(_N, _M)
#M = min(_N, _M)
S = input()
T = input()
L = N * M // gcd(N, M)
#print(L)
s_now = 0
t_now = 0
while True:
    if S[s_now] != T[t_now]:
        print(-1)
        break
    s_now += L//M
    t_now += L//N
    if s_now >= N or t_now >= M:
        print(L)
        break
#print(L//M, L//N)
#print(N//gcd(N, M), M//gcd(N, M))




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

#define LL long long

LL a, b, c;

int main()
{
	scanf("%lld %lld %lld", &a, &b, &c);
	LL t = c - a - b;
	if(t < 0) puts("No");
	else if(4ll * a * b < t * t) puts("Yes");
		else puts("No");
	return 0;
}


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

int main(){
  int n, k;
  cin >> n >> k;
  vector<double> vec(n);
  vector<double> ta(n+1);
  rep(i,n){
    double pi;
    cin >> pi;
    vec.at(i) = (pi + 1) / 2;
  }
  double sum = 0;
  rep(i,n){
    ta.at(i+1) = ta.at(i) + vec.at(i);
  }
  double ans = 0;
  double index;
  REP(i,k,n+1){
    index = ta.at(i) - ta.at(i-k);
    ans = max(ans, index);
    /*cout << ans << endl;
    cout << endl;*/
  }
  printf("%.10f", ans);
  return 0;
}


Measured memory_bytes: 6372
#include<bits/stdc++.h>
using namespace std;
int n,y,ans,ic,uc,hc;
int main(){
    cin>>n>>y;


    for(int i=0;i<n+1;i++){
        if(1000*i>y||i>n)break;
        for(int u=0;u<n+1;u++){
            if(1000*i+5000*u>y||i+u>n)break;
            for(int h=0;h<n+1;h++){
                if(1000*i+5000*u+10000*h>y||i+u+h>n)break;
                if(1000*i+5000*u+10000*h==y&&i+u+h==n){
                    ic=h;
                    uc=u;
                    hc=i;
                    ans=1;
                    break;
                }
            }if(ans)break;
        }if(ans)break;
    }

    for(int i=0;i<1000000000*100000000;i++){
        int aho;
      aho++;
    }








    if(ans==1){
        cout<<ic<<" "<<uc<<" "<<hc<<endl;
    }else{
        cout<<"-1 -1 -1"<<endl;
    }
}


Measured memory_bytes: 384
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

n=gets.to_i
a=get_i
ans=0
60.times do|i|
  cnt=0
  n.times do|j|
    if a[j][i]==1
      cnt+=1
    end
  end
  ans+=2**i*cnt*(n-cnt)
  ans%=10**9+7
end
puts ans

Measured memory_bytes: 40332
void main() {
	auto N = ri, A = ri;
	writeln(N*N-A);
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.conv;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}

Measured memory_bytes: 256
fn read_line() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim_right().to_owned()
}

fn str_to_ints(s: String) -> std::vec::Vec<i64> {
    let mut ret = std::vec::Vec::new();
    let ws = s.split_whitespace();
    for w in ws {
        ret.push(w.parse().unwrap());
    }
    ret
}

fn read_ints() -> std::vec::Vec<i64> {
    str_to_ints(read_line())
}

fn main() {
    let nk = read_ints();
    let n = nk[0];
    let k = nk[1];
    let a_s = read_ints();

    let mut bits_count = [0; 63];
    for a in a_s {
        for i in 0..63 {
            bits_count[i] += a >> i & 1;
        }
    }
    let mut k_bits = [0; 63];
    for i in 0..63 {
        k_bits[i] += k >> i & 1;
    }

    let mut ret: i64 = 0;
    let mut b_decided = false;

    for i in (0..63).rev() {
        if b_decided {
            if bits_count[i] >= n - bits_count[i] {
                ret += (1 << i) * (bits_count[i]);
            } else {
                ret += (1 << i) * (n - bits_count[i]);
            }
        } else {
            if k_bits[i] == 0 {
                ret += (1 << i) * (bits_count[i]);
            } else if bits_count[i] >= n - bits_count[i] {
                ret += (1 << i) * (bits_count[i]);
                b_decided = true;
            } else {
                ret += (1 << i) * (n - bits_count[i]);
            }
        }
    }

    println!("{}", ret);
}

Measured memory_bytes: 8444