akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
 
#define INF (1LL<<62)
 
using namespace std;
 
typedef long long ll;
 
ll g[101][101],n,m;
 
ll rec(set<int> S,int mx){
   
  if(mx<0)return 0;
 
  ll res=0;
  set<int>::iterator it=S.begin();
  for(;it!=S.end();it++){
    set<int>::iterator j=S.begin();
    ll t=INF;
    for(;j!=S.end();j++){
      if(it==j)continue;
      t=min(t,g[*it][*j]);
    }
    res+=t;
  }
   
  if(mx>=n-1)return res;
 
  int id=-1;
  ll cost=0;
  for(int v=mx+1;v<n;v++){
    if(S.count(v))continue;
 
    bool fg=true;
    set<int>::iterator it=S.begin();
    for(;it!=S.end();it++){
      fg&=(g[v][*it]<INF);
    }
    if(!fg)continue;
    
    set<int>T=S;
    T.insert(v);
    cost=max(cost,rec(T,v));
  }
   
  return max(res,cost);
}
 
int main(void){
 
  fill(g[0],g[101],INF);
  for(int i=0;i<101;i++)g[i][i]=0;
 
  cin >> n >> m;
 
  for(int i=0;i<m;i++){
    ll a,b,f;
    cin >> a >> b >>f;
    g[a-1][b-1]=g[b-1][a-1]=f;
  }
   
  ll ans=0;
 
  for(int i=0;i<n;i++){
    for(int j=i+1;j<n;j++){
      if(g[i][j]<INF){
    set<int>S;
    S.insert(i);
    S.insert(j);
    ans=max(ans,rec(S,max(i,j)));
      }
    }
  }
 
  cout << ans << endl;
   
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<long double, long double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
//const int MOD = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    int n, m, k; cin >> n >> m >> k;
    COMinit();
    ll ans = 0;
    for (int i = k; i >= 0; i--){
        ll pl = (COM(n-1,i) * m) % MOD;
        pl *= modpow(m-1,n-1-i,MOD);
        pl %= MOD;
        ans += pl;
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 15512
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    n = I()
    p = LI()

    ans = len([i for i in range(n - 2) if p[i] < p[i+1] < p[i+2] or p[i] > p[i+1] > p[i+2]])
    print(ans)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 10112
use proconio::fastout;
use whiteread::parse_line;

const MOD: usize = 1_000_000_007;

const MAX: usize = 250_000;

struct ComCalculator {
    fac: Vec<usize>,
    finv: Vec<usize>,
}

impl ComCalculator {
    fn new(n: usize) -> Self {
        let mut fac = Vec::with_capacity(n);
        let mut finv = Vec::with_capacity(n);
        let mut inv = Vec::with_capacity(n);

        fac.push(1);
        fac.push(1);
        finv.push(1);
        finv.push(1);
        inv.push(0); // dummy data
        inv.push(1);
        for i in 2..n {
            fac.push((fac[i - 1] * i) % MOD);
            inv.push(MOD - (inv[MOD % i] * (MOD / i) % MOD));
            finv.push((finv[i - 1] * inv[i]) % MOD);
        }

        Self { fac, finv }
    }

    fn calc(&self, n: usize, k: usize) -> usize {
        if n < k {
            return 0;
        }

        return (self.fac[n] * (self.finv[k] * self.finv[n - k] % MOD)) % MOD;
    }
}

fn path(a: usize, b: usize, com: &ComCalculator) -> usize {
    com.calc(a + b, a)
}

#[fastout]
fn main() {
    let (h, w, a, b): (usize, usize, usize, usize) = parse_line().unwrap();

    let com = ComCalculator::new(MAX);
    let mut ret = path(h - 1, w - 1, &com);
    for i in 0..a {
        ret = (MOD - (path(b - 1, h - a + i, &com) * path(w - b - 1, a - i - 1, &com) % MOD) + ret)
            % MOD;
    }
    println!("{}", ret);
}


Measured memory_bytes: 7812
#include<stdio.h>
#include<math.h>
#include<iostream>
using namespace std;

int main() {
	int a;
	int fcount = 0;
	int scount = 0;
	while (fcount < 3 && scount < 2) {
		cin >> a;
		if (a == 5) {
			fcount++;
		}
		if (a == 7) {
			scount++;
		}
		if (fcount == 2 && scount == 1) {
				cout << "YES";
				return 0;
		}
	}

	cout << "NO";
	return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#define ll long long
#define ull unsigned long long
using namespace std;

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

	ll n, w;
	cin >> n >> w;
	vector<ll> V(n);
	vector<ll> W(n);
	for (ll i = 0; i < n; i++){
		cin >> V.at(i) >> W.at(i);
	}

	vector<vector<ll>> DP(n, vector<ll>(w + 1, -1));
	for (ll i = 0; i < n; i++){
		DP.at(i).at(0) = 0;
	}

	for (ll i = V.at(0); i <= w; i++){
		DP.at(0).at(i) = W.at(0);
	}

	for (ll i = 1; i < n; i++){
		for (ll j = 0; j <= w; j++){
			DP.at(i).at(j) = DP.at(i - 1).at(j);
		}
		for (ll j = V.at(i); j <= w; j++){
			DP.at(i).at(j) = max(DP.at(i).at(j), DP.at(i - 1).at(j - V.at(i)) + W.at(i));
		}
	}

	ll ans = 0;
	for (ll x : DP.back()){
		ans = max(ans, x);
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 79488
/*
 * ID: ITP1_5_A 
 * Problem: draw rectangles
 */

#include <stdio.h>

int main(void)
{
    int height, width;
    int i, j;

    while (1) {
        scanf("%d %d", &height, &width);
        if (height == 0 && width == 0)
            return 0;

        for (i = 0; i < height; i++) {
            for (j = 0; j < width; j++)
                putchar('#');
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2104
import Foundation

extension String {
    
    func toStrList() -> [String] {
        return self.map{String($0)}
    }
    
    func toIntList() -> [Int] {
        return self.map{Int(String($0))!}
    }
    
    func toSepDoubleList() -> [Double]{
        return self.split(separator: " ").map{Double($0)!}
    }

    func toSepIntList() -> [Int] {
        return self.split(separator: " ").map{Int($0)!}
    }

    func toSepStrList() -> [String] {
        return self.split(separator: " ").map{String($0)}
    }
    
    func zFill(n:Int) -> String {
        return String(format: "%0\(n)d", Int(self)!)
    }
    
    func count(c:Character) -> Int{
        var result = 0

        for e in self{
            if e == c{
                result += 1
            }
        }
        return result
    }

    func counter() -> Dictionary<Character, Int>{
        var result:[Character:Int] = [:]
        
        for c in self{
            guard let _ = result.index(forKey: c) else {
                result[c] = 1
                continue
            }
            result[c]! += 1
        }
        return result
    }
}

extension Int {
    func toBin() -> String {
        return String(self, radix: 2)
    }
    
    func toNBin(_ radix:Int) -> String{
        return String(self, radix: radix)
    }
    
    func toD() -> Double {
        return Double(self)
    }
}

extension Double {
    func toI() -> Int {
        return Int(self)
    }
}

extension Array where Element: Equatable{
    func count(n:Self.Element) -> Int{
        var result = 0
        for e in self{
            if e == n{
                result += 1
            }
        }
        return result
    }
}

extension Array {
    func dump(){
        for x in 0..<self.count-1{
            print(self[x], terminator: " ")
        }
        print(self.last!)
    }
}

func pow(_ base:Int,_ exp:Int) -> Int{
    let d = pow(base.toD(), exp.toD())
    return Int(d)
}

func distance(p1:CGPoint, p2:CGPoint) -> Double {
    let diffp = CGPoint(x:p1.x - p2.x, y:p1.y - p2.y)
    return Double(sqrt(diffp.x*diffp.x + diffp.y * diffp.y))
}

func distance(p1:[Double], p2:[Double]) -> Double{
    let diff = [p1[0] - p2[0], p1[1] - p2[1]]
    return sqrt(diff[0] * diff[0] + diff[1] * diff[1])
    
}

func lotate(theta:Double, point:[Double]) -> [Double] {
    let matrix = [
        [cos(theta), -sin(theta)],
        [sin(theta), cos(theta)]
    ]
    let x = point[0]
    let y = point[1]
    
    let rx = matrix[0][0]*x + matrix[0][1]*y
    let ry = matrix[1][0]*x + matrix[1][1]*y
    
    return [rx, ry]
}




func a() -> String{
    let x = Int(readLine()!)!
    if x >= 30{
        return "Yes"
    } else {
        return "No"
    }
}

print(a())

Measured memory_bytes: 13056
import core.bitop, std.algorithm, std.ascii, std.bigint, std.conv, std.math,
    std.functional, std.numeric, std.range, std.stdio, std.string, std.random,
    std.typecons, std.container, std.format;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    long N, M;
    scan(N, M);
    auto A = aryread();
    long t = A.sum();
    long cnt;
    foreach (i; 0 .. N)
    {
        if (t <= 4 * M * A[i])
            cnt++;
    }
    writeln(cnt < M ? "No" : "Yes");
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  long long n,i,j,k,c[100010]={},l;
  scanf("%lld",&n);
  for(i=1;i<n;i++){
    for(j=1;j<n;j++){
      for(k=1;k<n;k++){
	l=i*i+j*j+k*k+i*j+j*k+k*i;
	if(l>n)break;
	c[l]++;	
      }
    }
  }
  for(i=0;i<n;i++)printf("%lld\n",c[i+1]);
  return 0;
}


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

int main()
{
  char s[200],t[200];
  scanf("%s", s);
  scanf("%s", t);

  int l=strlen(s);
  int i,j,k,m;
  k=0;
  for(i=0;i<l;i++)
  {
    m=i;
    for(j=0;j<l;)
    {
      if(m==l) m-=l;
      if(s[m++]==t[j++]) k++;
      else break;
    }
    if(k==l) break;
    else k=0;
  }
  if(k!=l) printf("No\n");
  else printf("Yes\n");
  return 0;

}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;

    int count=0;

    while(a>=b)
    {
        b=b*2;
        count++;
    }
    while(b>=c)
    {
        c*=2;
        count++;
    }
    if(count > k)
        cout<<"No\n";
    else 
        cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 3620
import types



_atcoder_code = """
# Python port of AtCoder Library.

__version__ = '0.0.1'
"""

atcoder = types.ModuleType('atcoder')
exec(_atcoder_code, atcoder.__dict__)

_atcoder_dsu_code = """
import typing


class DSU:
    '''
    Implement (union by size) + (path compression)
    Reference:
    Zvi Galil and Giuseppe F. Italiano,
    Data structures and algorithms for disjoint set union problems
    '''

    def __init__(self, n: int = 0):
        self._n = n
        self.parent_or_size = [-1] * n

    def merge(self, a: int, b: int) -> int:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        x = self.leader(a)
        y = self.leader(b)

        if x == y:
            return x

        if -self.parent_or_size[x] < -self.parent_or_size[y]:
            x, y = y, x

        self.parent_or_size[x] += self.parent_or_size[y]
        self.parent_or_size[y] = x

        return x

    def same(self, a: int, b: int) -> bool:
        assert 0 <= a < self._n
        assert 0 <= b < self._n

        return self.leader(a) == self.leader(b)

    def leader(self, a: int) -> int:
        assert 0 <= a < self._n

        if self.parent_or_size[a] < 0:
            return a

        self.parent_or_size[a] = self.leader(self.parent_or_size[a])
        return self.parent_or_size[a]

    def size(self, a: int) -> int:
        assert 0 <= a < self._n

        return -self.parent_or_size[self.leader(a)]

    def groups(self) -> typing.List[typing.List[int]]:
        leader_buf = [self.leader(i) for i in range(self._n)]

        result = [[] for _ in range(self._n)]
        for i in range(self._n):
            result[leader_buf[i]].append(i)

        return list(filter(lambda r: r, result))
"""

atcoder.dsu = types.ModuleType('atcoder.dsu')
exec(_atcoder_dsu_code, atcoder.dsu.__dict__)
DSU = atcoder.dsu.DSU

import sys
input = sys.stdin.readline
# from atcoder.dsu import DSU

def main():
    N, M = map(int, sys.stdin.readline().split())
    dsu = DSU(N)
    for _ in range(M):
        A, B = map(int, sys.stdin.readline().split())
        dsu.merge(A-1, B-1)
    print(len(dsu.groups()) - 1)

if __name__ == '__main__':
    main()


Measured memory_bytes: 97732
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long 
#define INF 1e9
#define LINF 1e18
 
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<int, P> Pi;
typedef pair<P, P> PP;
 
const int MOD = 1e9 + 7;
const int dy[] = { 0, 0, 1, -1 };
const int dx[] = { 1, -1, 0, 0 };
 
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

vector<int> vec;

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

    int n, k;
    string s;
    cin >> n >> k;
    cin >> s;
    char before = s[0];
    int cnt = (before == '1') ? 1 : -1;
    for(int i = 1; i < n; ++i) {
        if(before == '1') {
            if(s[i] == before) ++cnt;
            else {
                vec.push_back(cnt);
                cnt = -1;
                before = '0';
            }
        }
        else {
            if(s[i] == before) --cnt;
            else {
                vec.push_back(cnt);
                cnt = 1;
                before = '1';
            }
        }
    }
    vec.push_back(cnt);
    int l = 0, r = 0, zero = 0;
    int res = 0, tmp = 0;
    while(r < vec.size()) {
        chmax(res, vec[r]);
        if(vec[r] > 0) tmp += vec[r];
        if(vec[r] < 0) {
            tmp -= vec[r];
            ++zero;
        }
        ++r;
        while(zero > k) {
            if(vec[l] > 0) tmp -= vec[l];
            if(vec[l] < 0) {
                tmp += vec[l];
                --zero;
            }
            ++l;
        }
        chmax(res, tmp);
    }
    cout << res << endl;
    return 0;
}


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

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

using namespace std;


int main()
{
	int n,m;
	cin>>n>>m;
	if(n>=m){
		rep(i,n) cout<<m;
		cout<<endl;
	}else{
		rep(i,m) cout<<n;
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 256
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error('\n↑入力 ↓出力');
  Main();
});
function makeClone(obj){return (obj instanceof Set) ? new Set(Array.from(obj)) : JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw 'ArrayIndexOutOfBoundsException ‚There is no more input';}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error('debug:' + require('util').inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(' ');case 4:return i.split(' ').map(Number);case 6:return i.split('');case 7:return i.split('').map(Number);case 8:return i.join(' ');case 9:return i.join('\n');case 0:return i.join('');default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var D = one[0];
  var T = one[1];
  var S = one[2];
  if(D / S <= T){
    myout("Yes");
  }else{
    myout("No");
  }
}


Measured memory_bytes: 30016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <map>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;
using ll=long long;



using edge=struct{int to;ll cost;};
vector<edge> tree[100100];
int tree_num[100100];
ll depth[100100];

//x現在の頂点、y=xのおや、現在の距離がd
void dfs(int x,int y, ll d){
    depth[x]=d;
    for(int i=0;i<tree_num[x];++i){
        if(tree[x][i].to==y){
          continue;
        }
        dfs(tree[x][i].to,x,d+tree[x][i].cost);
      }
    }

    
int main(){
  long long N;
  cin>>N;
  
  int a,b;
  ll c;
  for(int i=0;i<N-1;i++){
    cin>>a>>b>>c;
    tree[a-1].push_back({b-1,c});
    tree[b-1].push_back({a-1,c});
    tree_num[a-1]+=1;
    tree_num[b-1]+=1;
  }



  long long Q,K;
  cin>>Q>>K;
  dfs(K-1,-1,0);
  
  long long x,y;
  for(long long i=0;i<Q;++i){
    cin>>x>>y;
    cout<<(depth[x-1]+depth[y-1])<<"\n";
  }
return 0;
}


Measured memory_bytes: 17792
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL div(LL a,LL b){
  return mul(a,power(b,mod-2));
}


int invfact[100005];
int fact[100005];

LL factset(int a){//aまでの階乗%mod表を作成
	fact[0]=1;
  fact[1]=1;
  FORQ(i,2,a){
    fact[i]=mul(fact[i-1],i);
  }
}

void cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
	invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
	if(n<r)return 0;
	return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL  prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}

int main(){
	int n,a[111111]={};
	cin>>n;
	int l=0,r=0,m;
	FOR(i,0,n+1){
		cin>>m;
		//cout<<"m"<<m<<" ";
		if(a[m]==0)a[m]=i+1;
		else {
			l=a[m];
			r=i+1;
			//cout<<l<<" "<<r<<endl;
			break;
		}
		//cout<<a[m];
	}
	m=n-r+l;
	//cout<<"m"<<m<<endl;
	cmbset(n+1);
	FORQ(i,1,n+1){
		//cout<<cmb(n+1,i)<<" "<<cmb(m,i-1)<<endl;
		int ans=(cmb(n+1,i)+mod-cmb(m,i-1))%mod;
		cout<<ans<<endl;
	}

    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
#include <string>
using namespace std;
int main()
{
	char f[3][3];
	string s;
	while(cin >> s)
	{
		for(int i=0;i<9;i++)
		{
			f[i/3][i%3]=s[i];
		}
		for(int i=0;i<3;i++)
		{
			if(f[i][0]==f[i][1]&&f[i][1]==f[i][2])
			{
				if(f[i][0]=='o')
				{
					cout << 'o' << endl;
					goto end;
				}
				else if(f[i][0]=='x')
				{
					cout << 'x' << endl;
					goto end;
				}
				else
				{}
			}
			else if(f[0][i]==f[1][i]&&f[1][i]==f[2][i])
			{
				if(f[0][i]=='o')
				{
					cout << 'o' << endl;
					goto end;
				}
				else if(f[1][i]=='x')
				{
					cout << 'x' << endl;
					goto end;
				}
				else
				{}
			}
		}
		if(f[0][0]==f[1][1]&&f[1][1]==f[2][2])
		{
			if(f[0][0]=='o')
			{
				cout << 'o' << endl;
			}
			else if(f[0][0]=='x')
			{
				cout << 'x' << endl;
			}
			else
			{}
		}
		else if(f[0][2]==f[1][1]&&f[1][1]==f[2][0])
		{
			if(f[0][2]=='o')
			{
				cout << 'o' << endl;
			}
			else if(f[0][2]=='x')
			{
				cout << 'x' << endl;
			}
			else
			{}
		}
		else
		{
			cout << 'd' << endl;
		}
		end: ;
	}
	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
using namespace std;
int main(){
	int N;
	cin >> N;
	int X=0;
	
	for(int i=1; i<46298; i++){
		X=i*1.08;
		if(X==N){
			cout << i << endl;
			return 0;
		}
		if(X>N){
			cout << ":(" << endl;
			return 0;
		}
	}
	return 0;
} 

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

int c[20],st[20];
int a[20][20];
int main(){
    int n,m,x;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>c[i];
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    int ans=0x3f3f3f3f;
    for(int i=0;i<=(1<<n)-1;i++){
        memset(st,0,sizeof st);
        int cnt=0;
        bool ok=1;
        for(int j=0;j<n;j++)
        {
            if(i&(1<<j)){
                    cnt+=c[j];
                    for(int k=0;k<m;k++) st[k]+=a[j][k];
            }
        }
        for(int j=0;j<m;j++) if(st[j]<x) ok=0;
        if(ok) ans=min(ans,cnt);
    }
    if(ans>1200000) cout<<"-1";
    else cout<<ans;
}


Measured memory_bytes: 3600
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0266
{
    class Program
    {
        static void Main(string[] args)
        {
            const char DESERT = 'D';

            Dictionary<char, char[]> map = new Dictionary<char, char[]>();
            map.Add('A', new char[] { 'X', 'Y' });
            map.Add('B', new char[] { 'Y', 'X' });
            map.Add('W', new char[] { 'B', 'Y' });
            map.Add('X', new char[] { DESERT, 'Z' });
            map.Add('Y', new char[] { 'X', DESERT });
            map.Add('Z', new char[] { 'W', 'B' });

            while (true)
            {
                string p = RSt();
                if (p == "#") break;

                char cur = 'A';
                for (int i = 0; i < p.Length; i++)
                {
                    cur = map[cur][int.Parse(p[i].ToString())];
                    if(cur == DESERT)
                    {
                        break;
                    }
                }
                Console.WriteLine(cur == 'B' ? "Yes" : "No");
            }
        }
        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RArSt(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RArInt(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RArLong(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RArDouble(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }
}



Measured memory_bytes: 18028
h, w, d = map(int,input().split())
a = [list(map(int, input().split())) for i in range(h)]
q = int(input())
query = [list(map(int, input().split())) for i in range(q)]

res = [[0] for i in range(d)]
memo = {} 
for i in range(h):
    for j in range(w):
        memo[a[i][j]] = (i, j)
res[0].append(0)
for i in range(1, w * h + 1):
    if i - d not in memo:
        res[i % d].append(0)
    else:
        wi, hi = memo[i]
        wii, hii = memo[i - d]
        diff = abs(wi - wii) + abs(hi - hii)
        res[i % d].append(diff)
        res[i % d][-1] += res[i % d][-2]

for l, r in query:
    mod = l % d
    l = l // d
    r = r // d
    print(res[mod][r + 1] - res[mod][l + 1])

Measured memory_bytes: 94812
#include<bits/stdc++.h>
using namespace std;
void pre(){}
void solve(){
    int x,y,z;cin>>x>>y>>z;
    cout<<z<<" "<<x<<" "<<y<<"\n";
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    pre();
    long long int num = 1;
    //cin>>num;
    for(long long int i=0;i<num;i++){
       	solve();
    }   
}


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

int main() {

  int a;
  cin >> a;
  vector<int> t(a);
  rep(i,a) cin >> t[i];
  int sum = 0;
  
  rep(i,a) {
    for(int j = i+1; j<a; j++) {
      sum += t[i] * t[j];
    }
  }
  
  cout << sum << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char s[100];
int main(){
	int n;
	scanf("%s", s);
	for(int i = 0;i < 19;i++){
		if(s[i] == ',') s[i] = ' ';			
}
	printf("%s", s);
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<algorithm>
#include<stdint.h>
#include<vector>
#include<deque>
#include<stack>
#include<string>
#include<cstring>
#include<time.h>
#include<array>
#include<iomanip>
#include<list>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<random>
#include<bitset>
#include <queue>
#include <map>


using namespace std;
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
using ldouble = long double;


//BDD,ZDD,kdtree, bdtree,bicalc, bolonoy, doloney,chinesemod,segmenttree,daikusutora, saidairyuu, 2bugurahu, heirokenshutu, topologicalsort, kyourenketuseibun


#define PRI(s) cout << s << endl
#define PRIY PRI("Yes")
#define PRIN PRI("No")

int main() {
	int a;
	cin >> a;
	PRI(3 * a * a);
	return 0;
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<bitset>

int n,m;
int bin_sum[15];
int p[15];

using namespace std;

void solve(){
    int cnt=0;
    for(int i=0;i<pow(2, n); i++){
        for(int j=0;j<m;j++){
            if(bitset<32>(i & bin_sum[j]).count()%2!=p[j]){
                break;
            }
            if(j==m-1){
                cnt++;
            }
        }
    }
    cout << cnt << endl;
}

int main(){
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int k;
        cin >> k;
        for(int j=0;j<k;j++){
            int tmp;
            cin >> tmp;
            bin_sum[i] += pow(2,tmp-1);
        }
    }
    for(int i=0;i<m;i++){
        cin >> p[i];
    }
    solve();
}


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

int main(void) {
    int n, k;
    cin >> n >> k;

    int A[n];
    for (int i = 0; i < n; ++i)
        cin >> A[i];
    vector<int> kek(n, INT_MAX);
    kek[0] = 0;

    for (int i = 1; i < n; ++i)
    for (int j = 1; j <= k; ++j)
        if (i - j >= 0)
            kek[i] = min(kek[i], kek[i - j] + abs(A[i - j] - A[i]));

    cout << kek.back() << endl;
}


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

int main() {
    int n;  cin >> n;
    int odd = (n+1)/2;
    double ans = (double)odd/n;
    printf("%.10f\n", ans);
}

Measured memory_bytes: 256
using AtCoderBeginnerContest153.Questions;
using AtCoderBeginnerContest153.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest153.Questions
{
    public class QuestionC : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            var nk = inputStream.ReadIntArray();
            var n = nk[0];
            var k = nk[1];
            var h = inputStream.ReadLongArray();

            yield return h.OrderByDescending(i => i).Skip(k).Sum();
        }
    }
}


namespace AtCoderBeginnerContest153
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionC();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest153.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest153.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

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

int main(){
  int a[6],c[5]={0};
  int i,count=0;
  char x;
  while(cin>>a[0]){
    if(a[0]==1)a[5]+=14;
    for(i=1;i<5;i++){
      cin>>x>>a[i];
      if(a[i]==1)a[5]=14;
    }
    
    c[0]=c[1]=c[2]=c[3]=c[4]=0;
    sort(&a[0],&a[5]);
			
    for(i=0;i<5;i++)
      if(a[i]==a[i+1])c[0]++; else break;
    for(i=i+1;i<5;i++)
      if(a[i]==a[i+1])c[1]++; else break;
    for(i=i+1;i<5;i++)
      if(a[i]==a[i+1])c[2]++; else break;
    for(i=i+1;i<5;i++)
      if(a[i]==a[i+1])c[3]++; else break;
    
    if(c[0]==0&&c[1]==0&&c[2]==0&&c[3]==0){
      for(i=0;i<4;i++)
	if(a[i]+1==a[i+1]){
	  count++;
	}else {
	  break;
	}
      if(count==4)c[4]=1;
      count=0;
      
      if(c[4]!=1){
	for(i=1;i<6;i++)
	  if(a[i]+1==a[i+1]){
	    count++;
	  }else {
	    break;
	  }
	if(count==4)c[4]=1;
	count=0;
      }
    }
    sort(c,c+4,greater<int>());
    if(c[0]==2&&c[1]==1)cout<<"full house";
    else if(c[0]==1&&c[1]==1)cout<<"two pair";
    else if(c[0]==1)cout<<"one pair";
    else if(c[0]==2)cout<<"three card";
    else if(c[0]==3)cout<<"four card";
    else if(c[0]==4)cout<<"five card";
    else if(c[4]==1)cout<<"straight";
    else cout<<"null";
    cout<<endl;
    a[5]=0;
  }  
}

Measured memory_bytes: 1176
from sys import stdin


def get_result(data):
    N, K = data[0]
    A = data[1]
    e_val = [(1 + val) / 2 for val in A]

    # 累積和を算出 (最初は0)
    e_cumsum = [0]
    for i in range(N):
      e_cumsum.append(e_cumsum[i] + e_val[i])

    # 隣接するK個の部分和を取得
    e_sum_k = []
    for i in range(N+1-K):
      e_sum_k.append(e_cumsum[i+K] - e_cumsum[i])

    return max(e_sum_k)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [list(map(int, val.split(' '))) for val in raw_data]
    result = get_result(data)
    print(result)


Measured memory_bytes: 29008
'use strict';
function main(input) {
  let a = Number(input.trim().split('\n'));
  const Five = Math.floor(a / 500);
  const five = Math.floor((a % 500) / 5);
  
  console.log(1000 * Five + 5 * five);
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func main() {
	scanner.Split(bufio.ScanWords)

	n := nextInt()
	fmt.Println((n * (1 + n)) / 2)
}


Measured memory_bytes: 640
//#pragma GCC target("avx2")
#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    int h, w, m;
    cin >> h >> w >> m;

    int MAX = 3e5 + 5;
    vector<int> vh(m), vw(m);
    vector<int> cnt_h(MAX, 0), cnt_w(MAX, 0);
    REP(i, m) {
        cin >> vh[i] >> vw[i];
        cnt_h[vh[i]]++;
        cnt_w[vw[i]]++;
    }

    int max_cnt_h = *max_element(ALL(cnt_h)), max_cnt_w = *max_element(ALL(cnt_w));

    int ch = 0;
    REP(i, MAX) if(cnt_h[i] == max_cnt_h)ch++;

    int cw = 0;
    REP(i, MAX) if(cnt_w[i] == max_cnt_w)cw++;

    ll cc = ll(ch) * cw;

    REP(i, m) {
        if (cnt_h[vh[i]] == max_cnt_h && cnt_w[vw[i]] == max_cnt_w) cc--;
    }

    if (cc > 0) print(max_cnt_h + max_cnt_w);
    else print(max_cnt_h + max_cnt_w - 1);
}


Measured memory_bytes: 7896
#include <iostream>
#include <string>
#include <list>

using namespace std;

int main() {
	int n, q, query, t, x, s;

	cin >> n >> q;

	list<int> L[n];
	list<int>::iterator itr;

	for (int i = 0; i < q; i++) {
		cin >> query;

		if (query == 0) {
			cin >> t >> x;
			L[t].insert(L[t].end(), x);
		}
		else if (query == 1) {
			cin >> t;
			for (itr = L[t].begin(); itr != L[t].end(); itr++) {
				if (itr == L[t].begin())
					cout << *itr;
				else
					cout << " " << *itr;
			}
			cout << endl;
		}
		else {
			cin >> s >> t;
			L[t].splice(L[t].end(), L[s]);
		}	
	}
}




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

int main(){
    int n,m,l;
    cin>>n>>m>>l;
    
    int a[100][100];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++) cin>>a[i][j];
    
    int b[100][100];
    for(int i=0;i<m;i++)
        for(int j=0;j<l;j++) cin>>b[i][j];
    
    long long c[100][100] = {};
    for(int i=0;i<n;i++)
        for(int j=0;j<l;j++)
            for(int k=0;k<m;k++) c[i][j] += a[i][k] * b[k][j];
    
    for(int i=0;i<n;i++){
        for(int j=0;j<l;j++){
            if(j) cout<<" ";
            cout<<c[i][j];
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3244
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] s = new int[N];
		int sum = 0;
		for (int i = 0; i < N; i++) {
			s[i] = sc.nextInt();
			sum += s[i];
		}
		if (sum % 10 == 0) {
			Arrays.sort(s);
			for (int i = 0; i < N; i++) {
				if (s[i] % 10 != 0) {
					sum -= s[i];
					System.out.println(String.valueOf(sum));
					return;
				}
			}
			System.out.println("0");
		} else{
			System.out.println(String.valueOf(sum));
		}
	}
}


Measured memory_bytes: 23764
#include <stdio.h>

int main(){
    int a,b,c,d,p,x,y;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    scanf("%d",&d);
    scanf("%d",&p);
    x=a*p;
    if(p<=c){
	y=b;
    }
    else {
	y=(p-c)*d+b;
    }
    if(x>y){
	x=y;
    }
    printf("%d\n",x);
    return 0;
}

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

int main(){
    int al[26] = {}, num[10] = {};
    string s;   cin >> s;
    for(char c : s){
        if(isdigit(c))  num[c-'0']++;
        else            al[c-'a']++;
    }
    int comp = 0;
    int cur = 0;
    while(cur < 26){
        if(al[cur] == 0){
            cur++;
            continue;
        }
        int next = cur;
        while(al[next] && next < 26){
            next++;
        }
        if(next-cur > 3){
            comp+= 3;
            while(cur < next){
                al[cur++]--;
            }
            cur = 0;
        }else{
            cur = next;
        }
    }
    cur = 0;
    while(cur < 10){
        if(num[cur] == 0){
            cur++;
            continue;
        }
        int next = cur;
        while(num[next] && next < 10){
            next++;
        }
        if(next-cur > 3){
            comp+= 3;
            while(cur < next){
                num[cur++]--;
            }
            cur = 0;
        }else{
            cur = next;
        }
    }
    for(int i = 0; i < 26; i++) comp += al[i];
    for(int i = 0; i < 10; i++) comp += num[i];
    cout << comp << endl;
    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

int a, b;

bool isPrime(int a) {
    if(a == 1) return false;
    for(int i = 2; i*i <= a; ++i) {
        if(a%i == 0) return false;
    }
    return true;
}

set<int> getPrimes(int x) {
    set<int> ret;
    for(int i = 1; i*i <= x; ++i) {
        if(x%i == 0) {
            if(isPrime(i))
                ret.insert(i);
            if(isPrime(x/i))
                ret.insert(x/i);
        }
    }
    return ret;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> a >> b;

    set<int> ap = getPrimes(a), bp = getPrimes(b);
    
    int ans = 1;
    for(int app : ap) {
        if(bp.count(app)) ans++;
    }

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


Measured memory_bytes: 256
# 深さ優先探索による迷路の最短距離計算


import sys
import copy
import queue

# 再帰上限
sys.setrecursionlimit(10 ** 6)


# 最短距離メモ
# 0#4#
# 123
# 23#のような最終結果のためのメモ
# スタートからの最短距離が格納

def answer_sheet(meiro):
    return copy.deepcopy(meiro)


# 【周りの点の取得）
# 座標が与えられると、上下左右の4点を得る。
# 境界を超えた場合はカットされる。
def get_around_point(point, h, w):
    around_points = []

    for ij in [(-1,0),(0,1),(1,0),(0,-1)]:
        i,j=ij
        new_i = point[0] + i
        new_j = point[1] + j
        if 0 <= new_i < h and 0 <= new_j < w:
            around_points.append([new_i, new_j])
    return around_points


# ある点が道かどうかを判別する
def walkable(point, meiro):
    i = point[0]
    j = point[1]
    if meiro[i][j] == ".":
        return True
    return False


# ある点が行ったことあるかどうか
def never_had_been(point, sheet):
    if sheet[point[0]][point[1]] == ".":
        return True
    else:
        return False


# キューに、ある点の周りの行ったことのない道を追加し、シートに距離を記入
def add_load_2_queue(point, h, w, meiro, sheet, que):
    around_points = get_around_point(point, h, w)
    for around_point in around_points:
        if walkable(around_point, meiro) and never_had_been(around_point, sheet):
            que.put(around_point)
            sheet[around_point[0]][around_point[1]] = sheet[point[0]][point[1]] + 1
    return sheet, que


# ポイントが与えられたとき、その周りの道をキューに追加し、シートに記入、次のキューを取り出し同様の処理を行う。キューがなくなるまで続け、シートを返す。
def step(point, h, w, meiro, sheet, que):
    sheet, que = add_load_2_queue(point, h, w, meiro, sheet, que)
    if que.empty():
        return sheet
    next_point = que.get()
    return step(next_point, h, w, meiro, sheet, que)


# シートは、行けない場所の場合は"#"が含まれているため-1に変換
def hash2minus(sheet):
    new_sheet = []
    for gyou in sheet:
        new_gyou = []
        for item in gyou:
            if item == "#":
                new_gyou.append(-1)
            else:
                new_gyou.append(item)
        new_sheet.append(new_gyou)
    return new_sheet


# -------メイン関数---------
# スタートを決めた場合の、各場所までの最短距離を表すシートを出力
# 行けない場所の場合は-1
# 入力
# start 開始座標のリスト(例：[1,2])
# h 迷路の高さ
# w 迷路の幅
# meiro 迷路の文字列リスト
def min_dis(start, h, w, meiro):
    sheet = answer_sheet(meiro)
    que = queue.Queue()
    sheet[start[0]][start[1]] = 0
    return hash2minus(step(start, h, w, meiro, sheet, que))


import numpy as np

h, w = [int(i) for i in input().split()]
meiro = []

for i in range(h):
    meiro.append(list(input()))

ans = 0
for i in range(h):
    for j in range(w):
        if meiro[i][j] == ".":
            ans = max(ans, np.max(np.array(min_dis([i,j], h, w, meiro))))

print(ans)


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

int main() {
  int N, A;
  cin >> N >> A; //Nは支払う金額、Aは1円玉の枚数

  if (A >= N % 500) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
import sys
input = sys.stdin.readline

N = int(input())
s_li = []
for _ in range(N):
    s_li.append(input().strip())

last_is_A = 0
first_is_B = 0
both_conditions_are_true = 0
AB_counter = 0
for i in s_li:
    if i[-1] == 'A': last_is_A += 1
    if i[0] == 'B': first_is_B += 1
    if i[-1] == 'A' and i[0] == 'B': both_conditions_are_true += 1
    AB_counter += i.count('AB')

if both_conditions_are_true == last_is_A == first_is_B == 0:
    print(AB_counter + min(last_is_A, first_is_B, N-1))
elif both_conditions_are_true == last_is_A == first_is_B:
    print(AB_counter + min(last_is_A, first_is_B, N-1, both_conditions_are_true-1))
else:
    print(AB_counter + min(last_is_A, first_is_B, N-1))


Measured memory_bytes: 3700
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
#include <numeric>
#include <chrono>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
//#define mod 998244353
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef tuple<ll,ll,ll> tll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ull> vull;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=250;
//templete
int main() {
	int A,B,K;
	cin>>A>>B>>K;
	int k=0;
	for(int i=max(A,B);i>=1;i--){
		if(A%i==0 && B%i==0)
			k++;
		if(k==K){
			cout<<i<<endl;
			return 0;
		}
	}
    return 0;
}

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

vector<vector<bool>> tfmap(11, vector<bool>(11, false));
vector<vector<string>> wlmap(11, vector<string>(11, ""));


int s(int n,int i,int j){
	if(i==j){
		if(j == n){
			int temp = 0;
			for(int k = 1;k<n;k++){
				if(wlmap[i][k] == "w") temp++;
			}
			if(temp == (n-1)/2) return 1;
			else return 0;
		}
		else{
			return s(n,i,j+1);
		}
	}
	else if(j == n+1){
		int temp = 0;
		for(int k = 0;k<=n;k++){
			if(k==i) continue;
			if(wlmap[i][k] == "w") temp++;
		}
		if(temp == (n-1)/2) return s(n,i+1,1);
		else return 0;
	}
	else{
		if(tfmap[i][j]) return s(n,i,j+1);
		else{
			int temp = 0;
			tfmap[i][j] = true;
			tfmap[j][i] = true;
			wlmap[i][j] = "w";
			wlmap[j][i] = "l";
			temp += s(n,i,j+1);
			wlmap[i][j] = "l";
			wlmap[j][i] = "w";
			temp += s(n,i,j+1);
			tfmap[i][j] = false;
			tfmap[j][i] = false;
			return temp;
		}
	}
}

int main(){
	int n, m;
	while(true){
		cin >> n;
		if(n == 0) break;
		cin >> m;
		for(int i = 0;i<10;i++){
			for(int j = 0;j<10;j++){
				tfmap[i][j] = false;
				wlmap[i][j] = "";
			}
		}
		for(int i = 0;i<m;i++){
			int x, y;
			cin >> x >> y;
			tfmap[x][y] = true;
			tfmap[y][x] = true;
			wlmap[x][y] = "w";
			wlmap[y][x] = "l";
		}
		cout << s(n,1,2) << endl;
	}
	return 0;
}


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

ll N;
int ans[32];

void put_c() {
  if (N == 0) {
    cout << 0 << endl;
    return ;
  }
  bool f = false;
  for (int i = 31; i >= 0; --i) {
    if (f || ans[i]) {
      cout << ans[i];
      f = true;
    }
  }
  cout << endl;
}

int main() {
  cin >> N;
  
  ll tmp = 0;
  rep(i, 16) tmp += (int)pow(2, 2*i);
  for (int i = 31; i >= 0; --i) {
    if (tmp - (ll)pow(2, i) >= N) {
      tmp -= (ll)pow(2, i);
      if (i%2) ans[i] = 1;
    }
    else if (!(i%2)) ans[i] = 1;
  }
  put_c();
  return 0;
}

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

#define int long long int
#define REP(i, n) for (int i(0); i < n; ++i)
#define REQ(i, a, b) for (int i(a); i <= b; ++i)


int32_t main(){
	int a,b;
	cin >> a >> b;
	cout<<(a/__gcd(a,b))*b;
}

Measured memory_bytes: 256
from math import factorial
mod = 10 ** 9 + 7
n = int(input())
inp = list(input())
if inp[0] == 'W' or inp[-1] == 'W':
    print(0)
    exit(0)
arr = ['L']
swap_dict = {'L': 'R', 'R': 'L'}
for i in range(1, 2 * n):
    arr.append(arr[i - 1] if inp[i] != inp[i - 1] else swap_dict[arr[i - 1]])
if arr.count('L') != arr.count('R'):
    print(0)
    exit(0)
cnt_tmp = 0
cnt_swap = 1
for a in arr:
    if a == 'L':
        cnt_tmp += 1
    else:
        cnt_swap = (cnt_swap * cnt_tmp) % mod
        cnt_tmp -= 1
print(cnt_swap * factorial(n) % mod)

Measured memory_bytes: 7232
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int) n; i++)
using ll = long long;
template <class T>
using vt = std::vector<T>;
using vvi = std::vector<vt<int>>;

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

  std::cout << (s == "ARC" ? "ABC" : "ARC") << '\n';
  return 0;
}


Measured memory_bytes: 3624