akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>

using namespace std;

int main()
{
	int N, M;
	cin >> N >> M;
	// 電球M個に対するスイッチの配列
	vector<vector<int>> s(M);
	for (int i = 0; i < M; i++)
	{
		int k;
		cin >> k;
		for (int j = 0; j < k; j++)
		{
			int switchValue;
			cin >> switchValue;
			// switchの値から-1で配列のindexにする
			switchValue--;
			// 電球i番目におけるswitchの値の格納
			s[i].push_back(switchValue);
		}
	}
	// 余りの配列
	vector<int> p(M);
	for (int i = 0; i< M; i++)
	{
		cin >> p[i];
	}
	
	long answer = 0;
	
	// スイッチNの{0, 1, ..., n-1} の部分集合の全探索
	// bit全検索
	// 1<<Nは2の2のN乗
	for (int bit = 0; bit < (1<<N); bit++)
	{
		bool isLightOn = true;
		// 電球M個
		for (int i = 0; i < M; i++)
		{
			int onSwitchCount = 0;
			
			for (vector<int>::iterator it = s[i].begin(); it != s[i].end(); it++)
			{
				// 列挙にi番目の電球のスイッチの値(*it)が含まれるか
				// 2の(*it(switchの値))乗
				if (bit & (1<<*it)) {
					onSwitchCount++;
				}
			}
			// Onのスイッチの個数を2で割った余りが piに等しくない場合
			if (onSwitchCount % 2 != p[i])
			{
				// 点灯しない
				isLightOn = false;
			} 
		}
		
		// 全ての電球が点灯した
		if (isLightOn)
		{
			answer++;
		}
	}
	
	// 出力 (全ての電球が点灯するようなスイッチの on/off の状態の組み合わせ)
	cout << answer << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<bitset>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<ll , null_type, less< ll >, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define ld double
#define fi first
#define se second
#define pb push_back
#define pob pop_back
#define W while
#define fn(i,x) for(ll i=0;i<x;i++)
#define fs(i,s,x) for(int i=s;i<x;i++)
#define fr(i,x) for(int i=x;i>=0;i--)
#define fit(it,s) for(auto it=s.begin();it!=s.end();it++)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define srt(vec) sort(vec.begin(),vec.end())
#define mod 1000000007
#define MAX 100005
#define M 32
#define endl "\n"
using namespace std;
ll pow1(ll a,ll b){if(b==0) return 1; ll p=pow1(a,b/2);if(b%2) return ((p*p))*a;return (p*p);}
ll pow2(ll a,ll b){if(b==0) return 1; ll p=pow2(a,b/2);if(b%2) return (((p*p)%mod)*a)%mod;return (p*p)%mod;}
ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
int find1(int i,int dsu[]){if(dsu[i]==i) return i; dsu[i]=dsu[dsu[i]]; return find1(dsu[i],dsu);}
void union1(int i,int j,int dsu[]) {dsu[j]=find1(i,dsu);}
ll a[1000005];
double tree[4000020];


int main()
{
    int test;
    test=1;
    for(int z=0;z<test;z++)
    {
        int a,b,c;
        cin>>a>>b>>c;
        if(a==b||b==c||c==a)
        {
            if(a!=b||a!=c)
                cout<<"Yes"<<endl;
            else
                cout<<"No"<<endl;
        }
        else
            cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <stdio.h>
#include <queue>

using namespace std;

long long N;
int main() {
	cin >> N;
	vector<int> A;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		A.push_back(tmp);
	}
	sort(A.begin(), A.end());
	long long x=0, y=0;
	for (int i = A.size() - 1; i >0; i--) {
		if (x == 0 && A[i] == A[i - 1]) {
			x = A[i];
			i--;
		}
		else if (A[i] == A[i - 1]) {
			y = A[i];
			cout << x * y;
			return 0;
		}
	}
	cout << 0;
	return 0;
}

Measured memory_bytes: 892
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    n, d = map(int, input().split())
    #a, b = map(int, input().split())
    ans = 0
    for i in range(n):
        x, y = map(int, input().split())
        dist = abs(x)**2 + abs(y)**2
        if dist <= d**2:
            ans += 1
    print(ans)
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    #s = input()


Measured memory_bytes: 77372
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
int main(){
  string s;
  vector<string>vec;
  int k;
  cin>>s>>k;
  set<string>SET;
  int n=s.size();
  for(int i=1;i<=min(5,n);i++){
    for(int j=0;j+(i-1)<s.size();j++){
      SET.insert(s.substr(j,i));
    }
  }
  for(int i=0;i<k-1;i++)SET.erase(*begin(SET));
  cout<<*begin(SET)<<endl;
}

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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main(){
  int n;  cin>>n;
  vector<int>A(n),B(n);  fr(i,0,n) cin>>A[i];
  fr(i,0,n)
  B[A[i]-1] = i+1;
  cout<<B<<endl;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ft              first
#define sd              second
#define ll  		long long
#define pb              push_back
#define mkp           make_pair
#define pll             pair<ll,ll>
#define vll             vector<int>
#define mll             map<ll,ll>
#define pqg             priority_queue<ll>
#define pqs             priority_queue<ll,vll,greater<ll>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod          1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define MAXN   10000001
void online_judge()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
}

void ISO()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}


int main() {

	ISO();
	//online_judge();

	ll int N, X, T;
	cin >> N >> X >> T;
	ll ans = (N / X) * T;
	if (N % X == 0)
	{
		cout << ans << "\n";
	}
	else
	{
		cout << ans + T << "\n";
	}


	//cerr << "Time elapsed: " << clock() / 1000 << " ms" << endl;
	return 0;
}

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

int main() {
  int n, m, k, ans = 0;
  std::cin >> n >> m;
  int f[n][m] = {};
  for (int i = 0; i < n; i++) {
    std::cin >> k;
    for (int j = 0; j < k; j++) {
      int t;
      std::cin >> t;
      f[i][t - 1] = 1;
    }
  }
  for (int i = 0; i < m; i++) {
    bool flg = true;
    for (int j = 0; j < n; j++) {
      if (!f[j][i]) {
        flg = false;
        break;
      }
    }
    if (flg) {
      ans++;
    }
  }
  std::cout << ans << std::endl;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        n: usize,
        m: usize,
        hs: [i32; n],
        paths: [(usize, usize); m],
    }

    let xs = paths.iter().flat_map(|(a, b)|{
        if hs[*a-1] > hs[*b-1] { vec![*b] }
        else if hs[*a-1] == hs[*b-1] { vec![*a,*b] }
        else { vec![*a] }
    });

    println!("{:?}", n - xs.collect::<std::collections::HashSet<_>>().len());
}


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

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

    vector<int> a;
    bool ans=false;
    if(N*10000>=Y) {
        for(int i=0;i*10000<=Y;i++){
            for(int j=0;j<=N-i;j++){
                if(Y==i*10000+j*5000+(N-i-j)*1000){
                    a.push_back(i);
                    a.push_back(j);
                    a.push_back(N-i-j);
                    ans=true;
                    break;
                }

                else if(Y<i*10000+j*5000+(N-i-j)*1000) break;
            }
            if(ans) break;
        }
    }

    if(!ans) cout<<-1<<' '<<-1<<' '<<-1<<endl;
    else cout<<a.at(0)<<' '<<a.at(1)<<' '<<a.at(2)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
using namespace std;
int x,a,b;
int main() {
	cin>>x>>a>>b;
	a=abs(x-a);
	b=abs(x-b);
	if(a>b){
		cout<<"B"<<endl;
	} else {
		cout<<"A"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    int n;
    while(cin >> n, n){
        map<int, int> m, ans;
        for (int wwww = 0; wwww < n; ++wwww) {
            int a, b, c, d, f; char e;
            scanf("%d/%d %d:%d %c %d ", &a, &b, &c, &d, &e, &f);
            int time = a*1000000+b*10000+c*60+d;

            if(e == 'I'){
                m[f] = time;
                if(!f){
                    for (auto &&i : m) {
                        i.second = time;
                    }
                }
            }else {
                if(f){
                    if(m.count(0)) ans[f] += time-m[f];
                    m.erase(f);
                }else {
                    for (auto &&i : m) {
                        ans[i.first] += time-i.second;
                        i.second = time;
                    }
                    m.erase(0);
                }
            }
        }
        int p = 0;
        for (auto &&j : ans) {
            if(j.first) p = max(p, j.second);
        }
        cout << p << "\n";
    }
    return 0;
}


Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }

const i64 MOD = 1e9 + 7;

int64_t powmod(int64_t a, int64_t p) {
    int64_t v = 1;
    for (int64_t b = a; p > 0; p >>= 1, b = (b * b) % MOD) {
        if (p & 1) v = (v * b) % MOD;
    }
    return v;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}


int main() {
    int N;
    cin >> N;
    vector<i64> x(N), d(N);
    cin >> x;
    for(int i = 0; i < N - 1; i++) {
        d[i] = (x[i + 1] - x[i]) % MOD;
    }
    i64 ans = 0, s = 0;
    for(int k = 0; k < N - 1; k++) {
        s += invmod(k + 1);
        ans = (ans + (s * d[k]) % MOD) % MOD;
    }
    for(int i = 1; i < N; i++) {
        ans = (ans * i) % MOD;
    }
    cout << ans << endl;
    return 0;
}



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

ll kaijo(ll a){
  if (a == 1) return 1;
  return kaijo(a-1) * a % 1000000007;
}

int main() {
  ll D, M;
  cin >> D >> M;
  if (abs(D-M) > 1) {
    cout << 0 << endl;
    return 0;
  }
  
  ll p = 1;
  if (D == M) p = 2;
  cout << p * kaijo(D) * kaijo(M) % 1000000007 << endl;
}

Measured memory_bytes: 1792
#include<iostream>
using namespace std;
int main(){
	int n,k,x[100];
	cin >> n >> k;
	int i;
	int sum = 0;
	for(i=0;i<n;i++){
		cin >> x[i];
		if(x[i]<k-x[i]){
			sum+=x[i] * 2;
		}else{
			sum+=(k-x[i])*2;
		}
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3592
#from collections import deque,defaultdict
from sys import stdin
input = stdin.readline
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

from random import randint
import time

def score(t):
    last = [-1]*26
    sm = 0
    for i in range(d):
        tt = t[i]
        sm += s[i][tt]
        last[tt] = i
        for j in range(26):
            sm -= c[j]*(i-last[j])
    return sm

t1 = time.time()
d = inn()
c = inl()
s = []
for i in range(d):
    s.append(inl())
t = []
for i in range(d):
    t.append(randint(0,25))

cnt = 0
mx = -BIG
mxt = []
while True:
    cnt += 1
    if cnt==100:
        t2 = time.time()
        if t2>t1+1.8:
            break
        cnt = 0
    v = score(t)
    if v>mx:
        mx = v
        mxt = t
    dd = randint(0,d-1)
    while True:
        qq = randint(0,25)
        if qq!=t[dd]:
            break
    t[dd] = qq
    #ddprint(f"{i=} {v=} {len(mxt)}")

for i in range(d):
    print(mxt[i]+1)


Measured memory_bytes: 81428
from collections import defaultdict
import heapq
import sys

input = sys.stdin.readline

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(N)]

ab_dict=defaultdict(list)
for a, b in ab:
    ab_dict[a].append(-b)

ans = 0
hq = []
heapq.heapify(hq)
    
for i in range(1, M+1):
    [heapq.heappush(hq, num) for num in ab_dict[i]]
    if hq == []:continue
    ans -= heapq.heappop(hq)
    
print(ans)


Measured memory_bytes: 50376
const main = (standardInput) => {
    const lengthList = standardInput.split(' ');
    const a = Number.parseInt(lengthList[0]);
    const b = Number.parseInt(lengthList[1]);
    const c = Number.parseInt(lengthList[2]);

    if(a<b && b < c){
      console.log("Yes");
    }else{
      console.log("No");
    }
}

main(require('fs').readFileSync('/dev/stdin', 'UTF-8'));



Measured memory_bytes: 17140
let input = readLine()!.split(separator: " ").map { Int($0)! }
let N = input[0]
let M = input[1]

struct UndirectedPath: Equatable {
    let node0: Int
    let node1: Int

    init(_ node0: Int, _ node1: Int) {
        self.node0 = node0
        self.node1 = node1
    }
}
func ==(lhs: UndirectedPath, rhs: UndirectedPath) -> Bool {
    return lhs.node0 == rhs.node0 && lhs.node1 == rhs.node1
      || lhs.node0 == rhs.node1 && lhs.node1 == rhs.node0
}

var paths = [UndirectedPath]()
for _ in stride(from: 0, to: M, by: 1) {
    let path = readLine()!.split(separator: " ").map { Int($0)! }
    paths.append(UndirectedPath(path[0], path[1]))
}

func depthFirstSearch(_ visitedNodes: [Int] = [1]) -> Int {
    guard visitedNodes.count < N else {
        return 1
    }

    var numberOfHamiltonianPath = 0
    for node in stride(from: 1, through: N, by: 1) {
        guard !visitedNodes.contains(node) else { continue }

        if paths.contains(UndirectedPath(visitedNodes.last!, node)) {
            numberOfHamiltonianPath += depthFirstSearch(visitedNodes + [node])
        }
    }

    return numberOfHamiltonianPath
}


print(depthFirstSearch())


Measured memory_bytes: 8268
import java.util.*;
import java.util.Date;
import java.text.SimpleDateFormat;
public class Main{
  public static void main(String args[]){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();
  int b = sc.nextInt();
  int c = sc.nextInt();
  int t = b/a;
  if(t>=c){
    System.out.println(c);
  }else{
    System.out.println(t);
  }
  
  }
}

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

#define db(x) cerr << #x ": " << (x) << '\n';

#define int long long

using namespace std;

typedef long long ll;

const int oo = 1e18;



int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll N, K;
    cin >> N >> K;

    cout << min(N%K,K-N%K) << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<vector>
#include<climits>

#define MAX 100000
#define INF INT_MAX
#define NO 0
#define WENT 1

using namespace std;

void Dijkstra(void);

int V, E, r;
vector< vector<pair<int,int> > >  v;
vector<int> cost, visited;


int main() {
  int s, t, d;

  cin >> V >> E >> r;
  v.resize(V);

  for(int i=0; i<E; i++) {
    cin >> s >>t >> d;
    v[s].push_back(make_pair(t,d)); //s番目〜t番目のコストはd                                                                                                                                               
  }

  //cout << 'a' << endl;                                                                                                                                                                                    
  Dijkstra();

  //cout << "b" << endl;                                                                                                                                                                                    

  for(int i=0; i<V; i++) {
    if(visited[i] == WENT) cout << cost[i] << endl;
    else cout << "INF" << endl;
  }

  return 0;
}

void Dijkstra(){
  int x, y, z;
  priority_queue< pair<int,int> , vector< pair<int,int> >, greater< pair<int, int> > > p;//greaterで小さい順に取り出せる                                                                                    

  cost.resize(V);
  visited.resize(V);

  for(int i=0;i<V;i++){
    cost[i]=INF;
    visited[i] = NO;
  }
  cost[r] = 0;   //startのコストを０に                                                                                                                                                                      

  p.push(make_pair(0,r));//startのrはコスト０                                                                                                                                                               

  while(!p.empty()) {
    x=p.top().second; //topの二番目の要素(pair<int,int>の後半の要素)                                                                                                                                        
    p.pop();

    visited[x] = WENT;

    for(int i=0; i<v[x].size(); i++) {
      y = v[x][i].first;
      z = v[x][i].second;//y：edge先のノード、z：x~yへのコスト                                                                                                                                              

      if(visited[y] == NO) //まだxがyになったことがなければ                                                                                                                                                 
        if(cost[y] > cost[x] + z) {//元々yに行くためのコストが、今来たコストよりでかければ                                                                                                                  
          cost[y] = cost[x] + z;
          p.push(make_pair(cost[y],y));
        }
    }
  }
}




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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	string S=in<string>();
	
	if(S=="Sunny"){
		out("Cloudy");
	}
	else if(S=="Cloudy"){
		out("Rainy");
	}
	else out("Sunny");
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
//~ int const MOD = 1e9 + 7;
int const MOD = 998244353;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  int n;
  cin >> n;
  string s; cin >> s;
  for (char &c : s) {
    int d = c - 'A';
    d += n;
    d %= 26;
    c = 'A' + d;
  }
  kek(s);
  
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();        
        String t = "Good";
        for(int i=0;i<3;i++){if(s.charAt(i)==s.charAt(i+1)){t="Bad";break;
                                                 }
                            }        
		System.out.println(t);
	}
}


Measured memory_bytes: 21712
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

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

bool n_zero[10], f[10];
int coe[10], cnt, c;

void dfs(int n, int s) {
  if (n == cnt) {
    if (!s) c++;
    return;
  }

  rep(i,10){
    if (f[i] || (!i && n_zero[n])) continue;

    f[i] = 1;
    dfs(n + 1, s + i * coe[n]);
    f[i] = 0;
  }

}

int main(){  
  int n;

  while (cin >> n, n) {
    string str;
    vector<int> index(26, -1);
    cnt=0,c=0;
   

    fill_n((bool*) n_zero,sizeof(n_zero)/sizeof(bool),0);
    fill_n((bool*) coe,sizeof(coe)/sizeof(bool),0);
    fill_n((bool*) f,sizeof(f)/sizeof(bool),0);


    rep(i,n){
      cin >> str;

      rep(j,str.size()){  
        int ch = str[j] - 'A';
        if (index[ch] == -1) {
          index[ch] = cnt; cnt++;
        }

        if (str.size() > 1 && !j) n_zero[index[ch]] = 1;

        if (i != n - 1) coe[index[ch]] += pow(10, str.size() - 1 - j);
        else coe[index[ch]] -= pow(10, str.size() - 1 - j);
      }
    }

    dfs(0, 0);

    cout << c << endl;
  }

  return 0;
}

Measured memory_bytes: 1256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    internal class QuestionD
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            long n = long.Parse(Console.ReadLine());

            var primeFactors = PrimeFactors.PrimeFactorsImpl(n);

            var a = primeFactors.GroupBy(v => v)
                .Select(x => new { Factor = x.Key, Count = x.Count() });
            string result = a.Select(v => {
                var i = 1;
                var count = v.Count;
                while (true) {
                    count -= i;
                    if (count > i) {
                        i++;
                    } else {
                        break;
                    }
                }
                return i;
            }).Sum().ToString();

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }

    internal class PrimeFactors
    {
        /// <summary>
        /// 素因数分解。
        /// 出展：https://qiita.com/y_miyoshi/items/da814d96e8890224aad3
        /// </summary>
        public static IEnumerable<long> PrimeFactorsImpl(long n)
        {
            long i = 2;
            long tmp = n;

            while (i * i <= n) //※1
            {
                if (tmp % i == 0) {
                    tmp /= i;
                    yield return i;
                } else {
                    i++;
                }
            }
            if (tmp != 1) yield return tmp;//最後の素数も返す
        }
    }
}

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

#define int long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), (x).end())
#define bit(n) (1LL << (n))
#define dump(x) cerr << #x " = " << (x) << endl
using vint=vector<int>;
using vvint=vector<vint>;
using pint=pair<int, int>;
using vpint=vector<pint>;
template<typename T> using priority_queue_rev=priority_queue<T, vector<T>, greater<T>>;
constexpr double pi = 3.1415926535897932384626433832795028;
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T1, typename T2> bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> bool chmin(T1 &a, const T2 &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

int A, B, C, D;
int f(int x) {
    return x - x / C - x / D + x / lcm(C, D);
}
signed main() {
    cin >> A >> B >> C >> D;
    cout << f(B) - f(A - 1) << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,t;
    cin >> n;
    t = n;
    int sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }
    
    if (t % sum == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    


}


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;
using P = pair<int, int>;
const int INF = 1 << 30;
 
int main() {
	int n, k;
	cin >> n >> k;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	sort(h.begin(), h.end());
	int ans = INF;
	for (int i = 0; i+k-1 < n; i++)
	{
		ans = min(ans, h[i+k-1]-h[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
n = int(input())
a = list(map(int,input().split()))
a.sort()
flag = 0

for j in range(len(a)):
  if a[j-1] == a[j]:
    print('NO')
    flag = 0
    break
  else:
    flag = 1
    pass
  
if flag == 1:
  print('YES')
  


Measured memory_bytes: 25936
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
const int MOD=(int)1e9+7;
using namespace std;
int main(){
    string s;
    cin>>s;
    if(s=="abc"||s=="acb"||s=="bac"||s=="bca"||s=="cab"||s=="cba"){
        cout<<"Yes"<<endl;
    }    
    else cout<<"No"<<endl;
}

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

using namespace std;

using ll = int64_t;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = 2147483647;
constexpr ll L_INF = 9223372036854775807LL;

//===




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

	Vl x(N), y(N), u(N), v(N);

	for (int i = 0; i < N; ++i) {
		cin >> x[i] >> y[i];
		u[i] = x[i] + y[i];
		v[i] = x[i] - y[i];
	}

	bool is_odd = (u[0] % 2 + 2) % 2 == 1;
	for (int i = 1; i < N; ++i) {
		if (is_odd) {
			if ((u[i] % 2 + 2) % 2 == 0) {
				cout << -1 << endl;
				return 0;
			}
		}
		else {
			if ((u[i] % 2 + 2) % 2 == 1) {
				cout << -1 << endl;
				return 0;
			}
		}
	}



	int m = 31;
	if (!is_odd) ++m;
	Vl d(m);
	d[0] = 1;
	for (int i = 0; i < 30; ++i) {
		d[i + 1] = d[i] * 2;
	}
	if (!is_odd) d[31] = 1;

	cout << m << endl;
	for (int i = 0; i < m - 1; ++i) {
		cout << d[i] << " ";
	}
	cout << d[m - 1] << endl;



	if (!is_odd) {
		for (int i = 0; i < N; ++i) {
			--u[i]; --v[i];
		}
	}

	ll ma = d[30] * 2;

	for (int i = 0; i < N; ++i) {
		string mnp;
		ll au, av;
		au = (u[i] + ma - 1) / 2;
		av = (v[i] + ma - 1) / 2;
		for (int j = 0; j < 31; ++j) {
			bool bu, bv;
			bu = au & (1 << j);
			bv = av & (1 << j);
			if (!bu && !bv) mnp += 'L';
			else if (bu && bv) mnp += 'R';
			else if (!bu && bv) mnp += 'D';
			else if (bu && !bv) mnp += 'U';
		}
		if (!is_odd) mnp += 'R';

		cout << mnp << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] num = new int[11];
    num[sc.nextInt()]++;
    num[sc.nextInt()]++;
    num[sc.nextInt()]++;
    String ans = "NO";
    if((num[5] == 2) && (num[7] == 1)) ans = "YES";
    System.out.println(ans);
  }
}

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

using namespace std;

typedef long long ll;

map<string, vector<string>> G;
map<string, bool> V;
set<string> vis;

void init(){
  G.clear();
  V.clear();
  vis.clear();
}
void add_edge(string u, string v){
  V[u] |= true;
  V[v] |= false;
  G[u].push_back(v);
}
int dfs(string v, string p=""){
  if (vis.count(v)) return 0;
  vis.insert(v);
  int r = 0;
  for (auto& u : G[v]){
    if (u == p) continue;
    r += dfs(u, v);
  }
  r += !V[v];
  return r;
}

char S[65535];

int main()
{
  int test_case = 0;
  int n;
  while (cin >> n, n){
    init();
    string topl;
    for (int i = 0; i < n; i++){
      scanf("%s", S);
      char *tp = strtok(S, ":");
      string label = tp;
      if (!i) topl = label;
      while (tp = strtok(0, ",.")){
        add_edge(label, string(tp));
      }
    }
    printf("%d\n", dfs(topl));
  }
  return 0;
}

Measured memory_bytes: 1524
//I am so vegetable
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define PB push_back
#define IN insert
#define ER erase
#define CT count
#define EP empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const double eps = 1e-6;
const double pi = 3.141593;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, int MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, int mod = MOD) { return qpow(x, mod - 2) % mod; }
ll m_m(ll a){ return (a%MOD+MOD)%MOD; }

const int N = 2e5+5;
int a[N];
int main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
	int n;cin>>n;
    map<int,int>pos;
    _for(i,1,n+1){
        int x;cin>>x;
        a[i] = x+i;
        ++pos[i-x];
    }
    ll sssssss = 0;
    _for(i,1,n+1){
        sssssss += pos[a[i]];
    }
    cout<<sssssss;
	return 0;
}


Measured memory_bytes: 21280
#include <cstdio>
#include <algorithm>
using namespace std;

int main(){
	int array[50];
	int w,n,a,b;

	for(int i=0 ; i<50 ; i++){
		array[i] = i;
	}
	
	scanf("%d", &w);
	scanf("%d", &n);
	for(int i=0 ; i<n ; i++){
		scanf("%d,%d", &a, &b);
		swap( array[a] , array[b] );
	}
	for(int i=1 ; i<=w ; i++){
		printf("%d\n", array[i]);
	}
}

Measured memory_bytes: 0
import sys
input = sys.stdin.readline
n = int(input())
chk = []
for i in range(n-1):
  c = [int(i) for i in input().split()]
  chk.append(c)
  
if n == 1:
  print(0)
  exit()
  
for i in range(n-2):
  ans = chk[i][1]
  ans += chk[i][0]
  for j in range(i,n-2):
    if chk[j+1][1] > ans:
      ans = chk[j+1][1]+chk[j+1][0]
    else:
      p = (ans-chk[j+1][1]-1)//chk[j+1][2]+1
      #print(ans,p)
      ans = p*chk[j+1][2]+chk[j+1][1]+chk[j+1][0]
  print(ans)
print(chk[n-2][0]+chk[n-2][1])
print(0)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int sum=0;
  sum+=max(A,B);
  int high=max(A,B);
  int low=min(A,B);
  high-=1;
  sum+=max(high,low);
  cout<<sum<<endl;
}

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

int main() {
  ll N;
  string S;
  ll Mod = 1000000000 + 7;
  cin >> N >> S;
  ll a[26];
  for (int i = 0; i < 26; i++) {
    a[i] = 1;
  }
  for (int i = 0; i < N; i++) {
    a[S[i] - 'a']++;
  }
  ll ans = 1;
  for (int i = 0; i < 26; i++) {
    ans *= a[i];
    ans %= Mod;
  }
  cout << (ans - 1) % Mod << endl;
  return 0;
}

Measured memory_bytes: 512
def prime_factor(n):
    ret, p = [], 2

    while p*p <= n:
        if n % p != 0:
            p += 1
            continue

        exp_v = 0
        while n%p == 0:
            exp_v += 1
            n //= p
        ret.append( [p, exp_v] )

        p += 1

    if n != 1: ret.append( [n, 1] )

    return ret

n = int(input())
L = prime_factor(n)

print(str(n) + ":", end = "")
print( "".join([ (" " + str(k)) * v for (k, v) in L]) )



Measured memory_bytes: 5608
n,m = map(int,input().split())
a = []
b = []
c = []
for i in range(n):
  a.append([int(j) for j in input().split()])
for k in range(m):
  b.append(int(input()))
for x in range(n):
  z = 0
  for y in range(m):
    z += a[x][y] * b[y]
  c.append(z)
for i in c:
  print(i)
 

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

int main(){
  int N;
  cin >>N;
  
  vector<int> A(N);
  rep(i,0,N) cin >>A.at(i);
  
  int ans = 0;
  while(true){
    rep(i,0,N){
      if(A.at(i)%2!=0){
        cout <<ans<< endl;
        return 0;
      }else  A.at(i) /= 2;
    }
    ans++;
  }
}

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

#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop,~))(__VA_ARGS__)
#define loop(n) rep2(_loop_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i = (int)(begin), i##_end = (int)(end); i < i##_end; ++i)
#define repN(a) repX a
#define repX(a0,a1,a2,x,...) x

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

	ll a[100] = {2, 1};
	rep(i, 2, N + 1){
		a[i] = a[i - 1] + a[i - 2];
	}
	printf("%lld\n", a[N]);
	return 0;
}


Measured memory_bytes: 256
N, W_max = map(int, raw_input().split())

value  = []
weight = []

for i in range(N):
	x,y = map(int,raw_input().split())
	value.append(x)
	weight.append(y)
	
dp = [[0 for i in range(W_max+1)] for j in range(N+1)]


for i in range(0,N):
	for w in range(W_max+1):
		if w >= weight[i]:
			dp[i+1][w] = max(dp[i][w-weight[i]] + value[i], dp[i][w])
		else:
			dp[i+1][w] = dp[i][w]

print dp[N][W_max]



Measured memory_bytes: 34820
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NK = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, K) = (NK[0], NK[1]);
        var S = ReadLine();

        static IEnumerable<(T element, int length)> RunLengthEncoding<T>(IEnumerable<T> collection)
        {
            var isFirst = true;
            var prevElement = default(T);
            var length = 0;

            foreach (var element in collection)
            {
                if (!isFirst && !EqualityComparer<T>.Default.Equals(prevElement, element))
                {
                    yield return (prevElement, length);
                    length = 0;
                }
                else
                    isFirst = false;

                length++;
                prevElement = element;
            }
            if (!isFirst)
                yield return (prevElement, length);
        }

        var stack = new Stack<(char c, int l)>(RunLengthEncoding(S));

        for (int i = 0; i < K; i++)
        {
            if (3 <= stack.Count)
            {
                var (c, l1) = stack.Pop();
                var (_, l2) = stack.Pop();
                var (_, l3) = stack.Pop();

                stack.Push((c, l1 + l2 + l3));
            }
            else if (2 <= stack.Count)
            {
                var (c, l1) = stack.Pop();
                var (_, l2) = stack.Pop();

                stack.Push((c, l1 + l2));
            }
            else
                break;
        }

        var ans = stack.Select(t => t.l - 1).Where(x => 0 < x).Sum();

        WriteLine(ans);
    }
}


Measured memory_bytes: 30680
import sys
import numpy as np
input = sys.stdin.readline
H,W,K= map(int,input().split())
C = [input().strip() for i in range(H)]
C = [list(map(lambda x : 0 if x == '.' else 1, c)) for c in C]

m = lambda x : 0 if x == '0' else 1
ans = 0
for h in range(2**H):
    for w in range(2**W):
        hb = list(bin(h)[2:])
        hb = [0]*(H-len(hb))+hb
        hp = list( i for i,x in enumerate(hb) if x == '1')
        wb = list(bin(w)[2:])
        wb = [0]*(W-len(wb))+wb
        wp = list( i for i,x in enumerate(wb) if x == '1')
        k = 0
        for i in range(H):
            for j in range(W):
                if i in hp:
                    continue
                if j in wp:
                    continue
                k += C[i][j]
        if k == K:
            ans += 1
print(ans)








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

int main(){
int N,T,A;
  cin>>N>>T>>A;
  
  vector<int>H(N);
  for(int i=0; i<N; i++){
   cin>>H[i];  }
  
  vector<double>st(N);
  int ans=0;
  for(int i=0; i<N; i++){
   st[i]=abs(A-(T-H[i]*0.006));
   if(st[i]<st[ans]){ans=i;}
  }

  cout<<ans+1<<endl;
  
}

Measured memory_bytes: 256
N,M=list(map(int, input().split()))
A=[list(input()) for _ in range(N)]
B=[list(input()) for _ in range(M)]
K=N-M+1

for i in range(K):
  for j in range(K):
    # print(i,i+M,j,j+M)
    if all(all(A[k+i][l+j] == B[k][l] for l in range(M)) for k in range(M)):
      print('Yes')
      exit()
else:
  print('No')

Measured memory_bytes: 70208
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,x,ans=0,c=0;
    cin>>n>>x;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    for(int i=0;i<n;i++){
        if(i==n-1&&x>a[i]){break;}
        else if(x>a[i]){x-=a[i];ans++;}
        else if(x==a[i]){ans++;break;}
        else{break;}
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<set>
#include<algorithm>
#include<utility>
#include<map>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1001001001;

ll pow_mod(ll p, ll n, ll m) {
	if (n == 0) return 1;
	else if (n == 1) return p % m;
	else if (n % 2 == 1) return p * pow_mod(p, n - 1, m) % m;
	else {
		ll tmp = pow_mod(p, n / 2, m);
		return (tmp * tmp) % m;
	}
}

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

ll com_mod(ll n, ll k, ll m) {
	if (k == 0) return 1;
	else {
		ll x = 1;
		ll y = 1;
		for (ll i = 0; i < k; i++) {
			x = (x * (n - i)) % m;
			y = (y * (i + 1)) % m;
		}
		ll res = (x * pow_mod(y, m - 2, m)) % m;
		return res;
	}
}

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

Measured memory_bytes: 3584
fun main(args: Array<String>) {
    val (A, B) = readInputLine().split(" ").map { (it.toInt() - 2 + 13) % 13 }
    
    if (A > B) {
        println("Alice")
    } else if (A < B) {
        println("Bob")
    } else {
        println("Draw")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 37844
#include <iostream>
#include <cctype>
#include <string>
#include <vector>
using namespace std;

int main() {
  
  	string w,s;
  	cin>>w;
  	int count=0;
	while(cin>>s){
      for(int i=0;i<s.size();i++){
      	string t=s;
        t.at(i)=tolower(s.at(i));
        s=t;
      }	
      if(w==s){
        	count++;
        }
    }
  cout<<count<<endl;
}	


Measured memory_bytes: 3184
1x1=1
1x2=2
1x3=3
1x4=4
1x5=5
1x6=6
1x7=7
1x8=8
1x9=9
2x1=2
2x2=4
2x3=6
2x4=8
2x5=10
2x6=12
2x7=14
2x8=16
2x9=18
3x1=3
3x2=6
3x3=9
3x4=12
3x5=15
3x6=18
3x7=21
3x8=24
3x9=27
4x1=4
4x2=8
4x3=12
4x4=16
4x5=20
4x6=24
4x7=28
4x8=32
4x9=36
5x1=5
5x2=10
5x3=15
5x4=20
5x5=25
5x6=30
5x7=35
5x8=40
5x9=45
6x1=6
6x2=12
6x3=18
6x4=24
6x5=30
6x6=36
6x7=42
6x8=48
6x9=54
7x1=7
7x2=14
7x3=21
7x4=28
7x5=35
7x6=42
7x7=49
7x8=56
7x9=63
8x1=8
8x2=16
8x3=24
8x4=32
8x5=40
8x6=48
8x7=56
8x8=64
8x9=72
9x1=9
9x2=18
9x3=27
9x4=36
9x5=45
9x6=54
9x7=63
9x8=72
9x9=81

Measured memory_bytes: 6388
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

signed main (){
    int n,C;
    cin>>n>>C;
    vector<int> v(200010,0);
    vector<int> s(n),t(n),c(n);
    rep(i,0,n){
        cin>>s[i]>>t[i]>>c[i];
    }
    rep(i,1,C+1){
        vector<int> temp(200010,0);
        rep(j,0,n)if(c[j]==i){
            temp[s[j]*2-1]++;
            temp[t[j]*2]--;
        }
        rep(j,1,200010){
            temp[j]+=temp[j-1];
            v[j]+=(temp[j]>0);
        }
    }
    int ans=v[0];
    rep(i,1,200010){
        ans=max(ans,v[i]);
    }
    cout<<ans<<endl;

}
/*
1-2
0.5-2

010
01110
00111
000000111
*/


Measured memory_bytes: 5760