akhauriyash/Code-Regression huggingface dataset:
import sys
h,w,k=map(int,input().split())
mod=10**9+7
if w==1:
  print(1)
  sys.exit()
b=[]
for i in range(2**(w-1)):
  b.append(format(i,'0'+str(w-1)+'b'))
l=[]
for i in range(len(b)):
  ct=0
  for j in range(w-2):
    if b[i][j]!='1' or b[i][j+1]!='1':
      ct+=1
  if ct==w-2:
    l.append(b[i])

count=[[0,0,0] for i in range(w)]
for i in range(len(l)):
  if l[i][0]=='0':
    count[0][1]+=1
  if l[i][0]=='1':
    count[0][2]+=1
  if l[i][-1]=='1':
    count[-1][0]+=1
  if l[i][-1]=='0':
    count[-1][1]+=1
  for j in range(w-2):
    if l[i][j:j+2]=='10':
      count[j+1][0]+=1
    if l[i][j:j+2]=='00':
      count[j+1][1]+=1
    if l[i][j:j+2]=='01':
      count[j+1][2]+=1

dp=[[0 for i in range(w)] for j in range(h+1)]
dp[0][0]=1
for i in range(h+1):
  for j in range(w):
    dp[i][j]+=dp[i-1][j]*count[j][1]
    dp[i][j]%=mod
    if j-1>=0:
      dp[i][j]+=dp[i-1][j-1]*count[j-1][2]
      dp[i][j]%=mod
    if j+1<=w-1:
      dp[i][j]+=dp[i-1][j+1]*count[j+1][0]
      dp[i][j]%=mod
print(dp[h][k-1]%mod)

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main(void)
{
    int n;
    cin >> n;
    vector<int> L(n);
    int total = 0;
    rep(i,n){
        int l; cin >> l;
        L[i] = l;
        total += l;
    }
    rep(i,n){
        int tmp_total = total - L[i];
        if (L[i] >= tmp_total){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = input()
    aa = []
    for _ in xrange(n):
        a = []
        for _ in xrange(input()):
            x, y = map(int, raw_input().split())
            a.append([x - 1, y])
        aa.append(a)
    best = 0
    for x in xrange(2 ** n):
        xx = [bool(x & (1 << i)) + 0 for i in xrange(n)]
        if all(all(xx[i] == f for i, f in a) for x, a in zip(xx, aa) if x):
            best = max(best, sum(xx))
    print best


main()


Measured memory_bytes: 34460
import sys
input = sys.stdin.readline
INF = 10**20
MOD = 10**9 + 7
from itertools import permutations

def main():
    n,m,r = map(int,input().split())
    dest = [int(i) - 1 for i in input().split()]
    dist = [[INF] * n for _ in range(n)]

    for _ in range(m):
        a,b,c = map(int,input().split())
        a -= 1
        b -= 1
        dist[a][b] = c
        dist[b][a] = c
    
    for k in range(n):
        for i in range(n):
            for j in range(n):
                dist[i][j] = min(dist[i][j] , dist[i][k] + dist[k][j])
    
    ans = INF
    for ptr in permutations(range(r)):
        tmp = 0
        for i in range(r - 1):
            tmp += dist[dest[ptr[i]]][dest[ptr[i + 1]]]
        ans = min (ans, tmp)
    
    print(ans)

if __name__=='__main__':
    main()

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX


int n,a[100000],ans[100000];

signed main() {
    cin >> n;
    rep(i,n) cin >> a[i],ans[0] += a[i];
    rep(i,n) if (i%2) ans[0] -= a[i]*2;
    rep11(i,n) ans[i] = a[i-1]*2 - ans[i-1];
    rep(i,n) cout << ans[i] << " ";
}


Measured memory_bytes: 2816
A,B,C,X,Y = map(int,input().split())

# あり得るのはすべてA,Bで買う．少ない方を満たすまで
import math
max_money = A*X + B*Y

# 次にAをすべて！ABで買ってみる
if X>Y:
    max_money = min(2*X*C,max_money)
else:
    max_money = min(max_money,2*X*C + (Y-X)*B)


# 次にBをすべて！ABで買ってみる
if Y>X:
    max_money = min(2*Y*C,max_money)
else:
    max_money = min(max_money,2*Y*C + (X-Y)*A)

print(max_money)


Measured memory_bytes: 62084
#include<bits/stdc++.h>
using namespace std;  
int main() {
  string s; cin >> s;
  int f = 0, z = 0;
  for(int i = 0; i < s.size(); ++i) s[i]-'0' ? ++f : ++z;
  cout << min(f, z) * 2;
}


Measured memory_bytes: 512
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
  int l,a,b,c,d;
	cin>>l>>a>>b>>c>>d;
	cout << l-max((a-1)/c+1,(b-1)/d+1) << endl;
}


Measured memory_bytes: 3216
#include<iostream>
#include<cstdlib>
#include<string>
#include<vector>
#include<map>
#include<unordered_map>
#include<queue>
#include<algorithm>
#include<iomanip>
#include<typeinfo>
#include<complex>
using namespace std;
using ll = long long int;
const int mod = 1e9 + 7;
#define rep(i, a, b) for(ll i = a;i < b; i++)
const long double PI = (acos(-1));

int main() {

	int x;
	cin >> x;

	if (x == 3 || x == 5 || x == 7) cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll n, k;
    cin >> n >> k;
    ll x = 0, y = 0;
    FOR(i,1,n){
        if (i % k == 0) y++;
        else if ((2 * i) % k == 0) x++;
    }
    ll ans = x * x * x + y * y * y;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
from collections import defaultdict
from heapq import heappop, heappush
input = sys.stdin.readline

##### リストの 二分木検索 #####
# bisect_left(lists, 3)
# bisect_right(lists, 3)

##### プライオリティキュー #####
# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

##### タプルリストのソート #####
# sorted(ans) #(a, b) -> 1st : aの昇順, 2nd : bの昇順
# sorted(SP, key=lambda x:(x[0],-x[1])) #(a, b) -> 1st : aの昇順, 2nd : bの降順
# sorted(SP, key=lambda x:(-x[0],x[1])) #(a, b) -> 1st : aの降順, 2nd : bの昇順
# sorted(SP, key=lambda x:(-x[0],-x[1])) #(a, b) -> 1st : aの降順, 2nd : bの降順

# sorted(SP, key=lambda x:(x[1])) #(a, b) -> 1st : bの昇順
# sorted(SP, key=lambda x:(-x[1])) #(a, b) -> 1st : bの降順

def main():

	N = int(input())
	# = list(input())
	#L,R = map(int, input().split(" "))
	#L = list(map(int, input().split(" ")))

	A = []
	a_max = 0
	for i in range(N):
		tmp = int(input())
		A.append(tmp)
		if a_max < tmp:
			a_max = tmp

	B = copy.deepcopy(A)
	B.sort()
	for i in A:
		if i == a_max:
			print(B[-2])
		else:
			print(a_max)



if __name__ == "__main__":
	main()


Measured memory_bytes: 14588
/**
                 MD.Faysal Hasan
                Comilla Univesity               **/

#include<bits/stdc++.h>
#include<algorithm>
#include<string>
#include <stdlib.h>
using namespace std;

typedef long long int         lli;
typedef long long             ll;
typedef unsigned long long    ull;
typedef long double           ldb;
const   ll   N = 2e5+5;

#define         rep(i,n)       for ( i=0 ; i<n ; i++ )
#define         rep1(i,n)      for ( i=1 ; i<=n ; i++ )
#define         sajo(str)      sort(str.begin(),str.end())
#define         rsajo(str)     reverse(str.begin(),str.end())
#define         pi             3.14159265359
#define         nel            printf("\n");
#define         gcd(a,b)       __gcd(a,b)
#define         lcm(a,b)       (a/gcd(a,b))*b
#define         yes            cout<<"Yes"<<"\n";
#define         no             cout<<"No"<<"\n";
#define         pb             push_back
#define         pii            pair< ll , ll >
#define         ppi            pair< pii , ll >
#define         mp(x,y)        make_pair(x,y)
#define         ff             first
#define         ss             second
#define         Faysal         ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int fact(ll n)
{
   if(n==0)
      return(1);
   return(n*fact(n-1));
}
int prm(ll n)
{
    ll j=0;
    while (n % 2 == 0){
        j++;
        n = n/2;}
    for (ll i = 3; i*i <= n ; i = i + 2){
        while (n % i == 0){
           j++;
        n = n/i;}
    }
    if (n > 2)
        j++;
    return j;
}

int main(){Faysal

    ll ans,cnt,sum,mx,mn,chk;

    ll n,q,a,b,x,y,i,j,k;

    cin>>n>>k;
    vector<ll>v(n);
    rep(i,n) cin>>v[i];
    sajo(v);
    rsajo(v);
    cnt=0;
    for(i=k;i<n;i++)
    {
        cnt+=v[i];
    }
    cout<<cnt<<endl;


    return 0;

}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

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

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

int dp[81][81][25610] = {0};
int A[81][81] = {0};
int B[81][81] = {0};
int C[81][81] = {0};

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

  int H, W;
  cin >> H >> W;

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

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

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      C[i][j] = abs(A[i][j] - B[i][j]);
    }
  }

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      for(int k = 0; k < 25600; k++){
        dp[i][j][k] = 0;
      }
    }
  }

  int offset = 12800;

  dp[0][0][offset + C[0][0]] = 1;
  dp[0][0][offset - C[0][0]] = 1;
    
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){

      for(int k = 0; k <= 25600; k++){

        if(dp[i][j][k] == 1){
          if(k - C[i+1][j] >= 0){
            dp[i+1][j][k-C[i+1][j]] = 1;
          }
          if(k + C[i+1][j] <= 25600){
            dp[i+1][j][k+C[i+1][j]] = 1;
          }

          if(k - C[i][j+1] >= 0){
            dp[i][j+1][k-C[i][j+1]] = 1;
          }
          if(k + C[i+1][j] <= 25600){
            dp[i][j+1][k+C[i][j+1]] = 1;
          }
        }
      }
    }
  }

  int ans = 1 << 30;
  for(int i = 0; i < 25600; i++){
    if(dp[H-1][W-1][i] == 1){
      chmin(ans, abs(i - offset));
    }
  }

  cout << ans << endl;


  return 0;
}


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

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

int par[234567];
int rnk[234567];

void init(int n){
    for(int i=0;i<n;i++){
        par[i] = i;
        rnk[i] = 0;
    }
}

int find(int x){
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
}

void unite(int x,int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    if(rnk[x] < rnk[y]) par[x] = y;
    else{
        par[y] = x;
        if(rnk[x] == rnk[y]) rnk[x]++;
    }
}

bool same(int x,int y){
    return find(x) == find(y);
}

int main(){

    int n,m;
    cin >> n >> m;
    int p[n+1];
  	init(n+1);
    for(int i=1;i<n+1;i++) cin >> p[i];
    REP(i,m){
        int x,y;
        cin >> x >> y;
        unite(p[x],p[y]);
    }

    int ans = 0;
    for(int i=1;i<n+1;i++){
        if(same(i,p[i])) ans++;
    }

    cout << ans;
 	return 0;
    
    
    
}


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

const int N = 6e5+7;
int n, a[N], k, tree[4*N];

#define m (l+r)/2
#define lson 2*node
#define rson 2*node+1

void update(int pos, int v, int l, int r, int node) {
    if (l == r) {
        tree[node] = v;
        return;
    }
    if (pos <= m) update(pos, v, l, m, lson);
    else update(pos, v, m+1, r, rson);
    tree[node] = max(tree[lson], tree[rson]);
}

int query(int ql, int qr, int l, int r, int node) {
    if (ql <= l && qr >= r) return tree[node];
    int ans = 0;
    if (ql <= m) ans = max(ans, query(ql, qr, l, m, lson));
    if (qr > m) ans = max(ans, query(ql, qr, m + 1, r, rson));
    return ans;
}

int main()
{
    cin >> n >> k;
    rep(i, n) cin >> a[i+1];
    int ans = 0;
    for (int i=1; i<=n; ++i) {
        int res = query(max(a[i] - k, 0), a[i] + k, 0, N, 1) + 1;
        ans = max(ans, res);
        update(a[i], res, 0, N, 1);
    }
    cout << ans << endl;
    return 0;
}

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

int linear(void);

int i,j=0,n,q,*s,*t,aaa;

int main(){

  int cnt=0;
  
  scanf("%d",&n);
  s = malloc(sizeof(int)*(n+1));
  for(i=0;i<n;i++)scanf("%d",&s[i]);

  scanf("%d",&q); 
  t = malloc(sizeof(int)*(q+1));
  for(i=0;i<q;i++)scanf("%d",&t[i]);

  
for(i=0;i<q;i++){
  aaa=linear();
  if(aaa!=-1)cnt++;
  //printf("linear:%d\n",aaa);
 }

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

 free(s);
 free(t);
 return 0;
}


int linear(void){

  s[n]=t[i];
  for(j=0;s[j]!=t[i];j++){
    //printf("s:%d t:%d j:%d n:%d\n",s[j],t[i],j,n);
  }
  
   if(j==n) return -1;
    
  return j;

}



Measured memory_bytes: 2104
n = int(input())
result = [[0 for _ in range(n)] for _ in range(n)]
for _ in range(n):
  inp = list(map(int, input().split()))
  u, k = inp[0], inp[1]
  v = inp[2:]
  if k != 0:
    for vv in v:
      result[u-1][vv-1] = 1

result = list(result)
for i in range(n):
  print(*result[i])


Measured memory_bytes: 6388
#include<stdio.h>

int main(){
	int a,b;
	
	scanf("%d %d",&a,&b);
	
	if((a + b) % 3 == 0 || a % 3 == 0 || b % 3 == 0){
		printf("Possible\n");
	} else {
		printf("Impossible\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	int n;
	cin >> n;

	long long sum = 0;
	for (int i = 1; i <= n; ++i) {
		if (i % 3 != 0 && i % 5 != 0) {
			sum += i;
		}
	}

	cout << sum << "\n";

	return 0;

}

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

int main(){
    int n;
    cin >> n;
    vector<int> x(n), y(n), h(n);
    int k = 0;
    rep(i, n){
        cin >> x[i] >> y[i] >> h[i];
        if(h[i] > 0){
            k = i;
        }
    }
    int ans1, ans2, ans3;
    bool flag = false;
    rep(cx, 101){
        rep(cy, 101){
            ans1 = cx;
            ans2 = cy;
            ans3 = h[k] + abs(x[k] - cx) + abs(y[k] - cy);
            flag = true;
            rep(i, n){
                if(h[i] != max(ans3 - abs(x[i] - cx) - abs(y[i] - cy), 0)){
                    flag = false;
                    break;
                }
            }
            if(flag) break;
        }
        if(flag) break;
    }
    printf("%d %d %d\n", ans1, ans2, ans3);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cnt;
int main(){
	int n;
	cin>>n;
	int a[n];
	int ans=1e9;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=-100;i<=100;i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;

const int INF = 1<<29;
const double EPS = 1e-8;
typedef vector<int> vec;
typedef pair<int,int> P;
typedef pair<int,P> iP;

//char field[1000][1000];

int main(){
    while(1){
        int x,y;
        scanf("%d%d",&x,&y);
        if(!x)break;

        P start,goal;
        vector<P> pos[5];
        for(int i=0;i<y;i++){
            for(int j=0;j<x;j++){
                char temp; cin >> temp;
                if(temp=='S'){
                    start = P(i,j);
                }else if(temp=='G'){
                    goal = P(i,j);
                }else if(temp!='.'){
                    int type = temp - '1';
                    pos[type].push_back(P(i,j));
                }
            }
        }

        int min_type, min_d = INF;
        for(int s_type=0;s_type<5;s_type++){
            int g_type = s_type!=0 ? s_type-1 : 4;
            int d[6][1000];
            for(int i=0;i<6;i++)fill(d[i], d[i]+1000, INF);
            //cout << s_type << " " << g_type << endl;

            priority_queue<iP, vector<iP>, greater<iP> > que;
            d[s_type][0] = 0;
            que.push( iP(0,P(s_type, 0)) );
            while(que.size()){
                iP p = que.top(); que.pop();
                int dist = p.first;
                int type = (p.second).first;
                int index = (p.second).second;
                //printf("dist=%d type=%d index=%d\n",dist,type,index);
                if(d[type][index] < dist) continue;
                if(type==5){
                    if(min_d>dist){
                        min_d = dist;
                        min_type = s_type;
                    }
                    break;
                }

                P from;
                if(dist==0){
                    from = start;
                }else{
                    from = pos[type][index];
                }

                if(type==g_type){
                    int dist_to = dist + abs(goal.first - from.first) + abs(goal.second - from.second);
                    if(d[5][0] > dist_to){
                        d[5][0] = dist_to;
                        que.push(iP(dist_to,P(5,0)));
                    }
                }else{
                    int t_next = type!=4 ? type+1 : 0;
                    for(int i=0;i<pos[t_next].size();i++){
                        int dist_to = dist + abs(pos[t_next][i].first - from.first) + abs(pos[t_next][i].second  - from.second);
                        if(d[t_next][i] > dist_to){
                            d[t_next][i] = dist_to;
                            que.push(iP(dist_to,P(t_next,i)));
                        }
                    }
                }
            }
        }
        if(min_d!=INF)cout << min_type+1 << " " << min_d << endl;
        else cout << "NA" << endl;
    }

    return 0;
}

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

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))


//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

int main(){

    int N;
    cin >> N;
    int ans;
    for(int i = 1; i < 10; i++) {
        if(N <= i * 111){
            ans = i * 111;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
	int n;
	int n1, n2, n3;
	cin >> n;
	n1 = n / 1000;
	n = n - n1 * 1000;
	n2 = n / 100;
	n = n - n2 * 100;
	n3 = n / 10;
	n = n - n3 * 10;

	if (n2 == n3 && (n1 == n2 || n3 == n))cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=3e5+50;
int n,H,W,ans;
struct P {
	int x,y;
	friend inline bool operator <(const P &a,const P &b) {return a.x<b.x || (a.x==b.x && a.y<b.y);}
} a[N];
struct data {
	int l,r,mx;
	data(int l=0,int r=0,int mx=0) : l(l),r(r),mx(mx) {}
};
struct node {
	int mx,tag;
} tr[N<<2];
inline void init(int k,int l,int r) {
	tr[k].mx=-1e9; tr[k].tag=0;
	if(l==r) return; int mid=(l+r)>>1;
	init(k<<1,l,mid);
	init(k<<1|1,mid+1,r);
}
inline void upt(int k) {
	tr[k].mx=max(tr[k<<1].mx,tr[k<<1|1].mx)+tr[k].tag;
}
inline void inc(int k,int l,int r,int p,int L,int R,int z) {
	if(l==r) {
		tr[k].mx=2*R-2*L+2*z;
		return;
	} int mid=(l+r)>>1;
	if(p<=mid) inc(k<<1,l,mid,p,L,R,z);
	else inc(k<<1|1,mid+1,r,p,L,R,z);
	upt(k);
}
inline void add(int k,int l,int r,int L,int R,int val) {
	if(L<=l && r<=R) {tr[k].tag+=val; tr[k].mx+=val; return;}
	int mid=(l+r)>>1;
	if(R<=mid) add(k<<1,l,mid,L,R,val);
	else if(L>mid) add(k<<1|1,mid+1,r,L,R,val);
	else add(k<<1,l,mid,L,R,val), add(k<<1|1,mid+1,r,L,R,val);
	upt(k);
}
inline void solve() {
	sort(a+1,a+n+1);
	stack <data> stkl,stkr;
	init(1,1,n);
	for(int i=n;i>=1;i--) {
		ans=max(ans,tr[1].mx-2*a[i].x);
		if(a[i].y<=W/2) {
			int nowr=i;
			while(stkl.size() && stkl.top().mx<=a[i].y) {
				add(1,1,n,stkl.top().l,stkl.top().r,-2*(a[i].y-stkl.top().mx));
				nowr=stkl.top().r, stkl.pop();
			} 
			if(nowr>i) stkl.push(data(i+1,nowr,a[i].y));
		} else {
			int nowr=i;
			while(stkr.size() && stkr.top().mx>=a[i].y) {
				add(1,1,n,stkr.top().l,stkr.top().r,-2*(stkr.top().mx-a[i].y));
				nowr=stkr.top().r, stkr.pop();
			} 
			if(nowr>i) stkr.push(data(i+1,nowr,a[i].y));
		}
		inc(1,1,n,i,0,W,a[i].x);
		stkl.push(data(i,i,0));
		stkr.push(data(i,i,W));
	}
}
int main() {
	H=rd(), W=rd(), n=rd();
	for(int i=1;i<=n;i++) 
		a[i].x=rd(), a[i].y=rd();
	a[++n].x=0, a[n].y=0;
	a[++n].x=H, a[n].y=W;
	solve();
	for(int i=1;i<=n;i++)
		a[i].x=H-a[i].x, a[i].y=W-a[i].y;
	solve();
	swap(H,W);
	for(int i=1;i<=n;i++) swap(a[i].x,a[i].y);
	solve();
	for(int i=1;i<=n;i++)
		a[i].x=H-a[i].x, a[i].y=W-a[i].y;
	solve();
	cout<<ans<<'\n';
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void)
{
  int n;
  cin >> n;
  REP(i, n) {
    double xa, ya, ra, xb, yb, rb;
    cin >> xa >> ya >> ra >> xb >> yb >> rb;
    double d = sqrt((xa-xb)*(xa-xb) + (ya-yb)*(ya-yb));
    //cout << xa << " " << ya << " " << ra << " " << xb << " " << yb << " " << rb << endl;
    if(abs(ra-rb) <= d && d <= ra+rb) cout << 1 << endl;
    else if(ra+rb < d) cout << 0 << endl;
    else if(ra > rb && d < ra-rb) cout << 2 << endl;
    else if(rb > ra && d < rb-ra) cout << -2 << endl;
    else assert(false);
  }

  return 0;
}

Measured memory_bytes: 3160
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

    int n;
    cin >> n;

    ll arr[n];
    for(int i = 0; i < n; i++) cin >> arr[i];

    ll total = 0, p = 0;

    for(int i = 0; i < n; i++){
        total += (arr[i] % MOD) * (p % MOD);
        total %= MOD;
        p += arr[i];
    }

    cout << total;
}


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

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    bool ok = false;
    if (a == 5) {
        if (b == 5) {
            if (c == 7) {
                ok = true;
            }
        } else if (b == 7) {
            if (c == 5) {
                ok = true;
            }
        }
    } else if (a == 7) {
        if (b == 5) {
            if (c == 5) {
                ok = true;
            }
        }
    }

    cout << (ok ? "YES" : "NO") << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <algorithm>

using namespace std;

int main(){
    int array[3];
    for(int i=0;i<3;++i){
      
        cin>>array[i];
    }
    
    //std::sort(array,array+3);
    for(int i=0;i<3;++i){
        for(int j=0;j<i;++j){
            if(array[i]<array[j])
                swap(array[i],array[j]);
        }
    }
   
      cout<<array[0]<<" "<<array[1]<<" "<<array[2]<<endl;
    
    
    
}


Measured memory_bytes: 3088
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <random>
#include <fstream>
#include <time.h>
// #define int long long
#define debug(x) cerr << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  string ans;
  if(s[5] == '0' && s[6] <= '4') {
    ans = "Heisei";
  } else {
    ans = "TBD";
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
# C attention
n = int(input())
s = input()

w = [0]*n # i までのWの数
e = [0]*n # i から n までのEの数
for i in range(n):
    if s[i] == 'W':
        w[i] = w[i-1] + 1 if i > 0 else 1
    else:
        w[i] = w[i-1] if i > 0 else 0
    
    if s[-i-1] == 'E':
        e[-i-1] = e[-i] + 1 if i < n else 1
    else:
        e[-i-1] = e[-i] if i < n else 0


ans = int(1e6)
for i in range(n):
    if i == 0: a = e[1]
    elif i == n-1: a = w[-2]
    else: a = w[i-1] + e[i+1]
    ans = min(ans, a)
print(ans)

Measured memory_bytes: 17636
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
const int max_n = 1e5;
const ll mod = 1e9+7;
int main(){
  ll n; cin >> n;
  vector<ll> v(n);
  rep(i,0,n){
    cin >> v[i];
    v[i] *= 2;
  }
  ll offset = 0;
  rep(i,0,n) offset = v[i] - offset;
  ll x = offset / 2;
  ll cur = x;
  rep(i,0,n){
    cout << cur << " ";
    cur = v[i] - cur;
  }
  return 0;

}


Measured memory_bytes: 2048
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
#define rep(i,j,n) for(int i=(j);i<=((int)n);++i)
#define rev(i,n,j) for(int i=(n);i>=((int)j);--i)
typedef long long int ll;
#define int long long int
const ll INFL=0x3f3f3f3f3f3f3f3fLL;
const int INF=0x3f3f3f3f;
const int mod=1000000007;
#define endl "\n"
#define mem(a,val) memset(a,val,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define present(container, element) (container.find(element) != container.end())
#define pb push_back
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define readmat(a, n, m) int a[n + 5][m + 5] = {}; rep(i, 1, n) {rep(j, 1, m) cin >> a[i][j];}
#define printmat(a, n, m) rep (i, 1, n) {rep (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define printarr(a, n) rep(i, 1, n) cout << a[i] << " "; cout << endl;
typedef std::map< int,int> mii;
typedef std::vector< int > vi;
typedef std::vector< vi > vvi;
typedef std::pair< int,int > ii;
using namespace std;
#define cerr cout
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);}
const int N = 1e6+5, M = N;
vector <int>g[N];

void solve()
{
	int n,m;
	cin>>n>>m;
	int a[n+5];
	int b[m+5];
	int k;
	cin>>k;
	int dp1[n+5]={0};
	int dp2[m+5]={0};
	int z=0;
	for(int i = 1; i <=n; ++i) 
	{
		cin>>a[i];
		dp1[i]=dp1[i-1]+a[i];
	}

	for(int i = 1; i <=m; ++i) 
	{
		cin>>b[i];
		dp2[i]=dp2[i-1]+b[i];
	}

	int ans=0;
	for(int i = 0; i <=n; ++i) 
	{
		int z=dp1[i];
		int l=k-z;
		int pos=upper_bound(dp2,dp2+m+1,l)-dp2;
		pos--;
		if (pos>=0)
		ans=max(ans,i+pos);
	}

	cout<<ans<<endl;

	
}



signed main()
{
  FAST;
#ifdef LOCAL
    freopen("C:\\Users\\hp\\Documents\\input.txt", "r", stdin);
    freopen("C:\\Users\\hp\\Documents\\output.txt", "w", stdout);
    std::chrono::time_point<std::chrono::high_resolution_clock> start, end;
    start = std::chrono::high_resolution_clock::now();
#endif

solve();

#ifdef LOCAL
    end = std::chrono::high_resolution_clock::now();
    ll elapsed_time = std::chrono::duration_cast<std::chrono::milliseconds>(end-start).count();
    cout<<endl;
    cout << "\nElapsed Time: " << elapsed_time << "ms\n";
#endif

return 0;

}

// vector string set map first second continue break return upper_bound lower_bound length void sort
// stack queue pop size erase empty insert
// #Hala BBCF



Measured memory_bytes: 33344
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init)                                          \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T> using VEC = std::vector<T>;
template <class T> using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail> void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T> ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec)
    os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m)
    os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int main() {
  int n;
  cin>>n;
  int d,x;
  cin>>d>>x;
  LL sum =x;
  REP(i,0,n){
    int a;
    cin>>a;
    sum+=(d+a-1)/a;
  }
  cout<<max(sum,0LL)<<endl;

  return 0;
}


Measured memory_bytes: 256
if __name__ == '__main__':
    n, m,x = map(int, input().split())
    a = [int(i) for i in input().split()]
    count1=0
    count2=0
    for i in a:
        if i < x:
            count1+=1
        elif i>x:
            count2+=1

    print(min(count1,count2))


Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<ctime>
#include<map>
#include<bitset>
#include<set>
#include<assert.h>
#include<chrono>
#include<random>
#define LL long long
#define mp(x,y) make_pair(x,y)
#define pll pair<long long,long long>
#define pii pair<int,int>
#define SZ(x) ((int)x.size())
using namespace std;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
inline LL read()
{
	LL f=1,x=0;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
int stack[20];
template<typename T>inline void write(T x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
template<typename T>inline void pr1(T x){write(x);putchar(' ');}
template<typename T>inline void pr2(T x){write(x);putchar('\n');}
template<typename T>inline void chkmin(T &x,T y){x=x<y?x:y;}
template<typename T>inline void chkmax(T &x,T y){x=x>y?x:y;}
const int MAXN=1005;
const int mod=1e9+7;
LL pr[MAXN],plen,n,K;
LL mul(LL x, LL y, LL mo) {
    x %= mo; y %= mo;
    LL z = (long double) x * y / mo; z = x * y - z * mo;
    if(z < 0) z += mo; else if(z > mo) z -= mo;
    return z;
}
LL pow_mod(LL a,LL b,LL mod)
{
	LL ret=1;
	for(;b;b>>=1,a=mul(a,a,mod))if(b&1)ret=mul(ret,a,mod);
	return ret;
}
namespace Prime
{
	bool Miller_rabin(LL n)
	{
		if(n==2)return 1;
		if(n<2||!(n%2))return 0;
		LL S=n-1,t=0;while(!S&1)S>>=1,++t;
		for(int i=1;i<=20;i++)
		{
			LL x=pow_mod(rand()%(n-1)+1,S,n);
			for(int j=1;j<=t;j++)
			{
				LL y=mul(x,x,n);
				if(y==1&&x!=1&&x!=n-1)return 0;
				x=y;
			}if(x!=1)return 0;
		}return 1;
	}
	LL gcd(LL a,LL b){return a==0?b:gcd(b%a,a);}
	LL try_split(LL n,LL c)
	{
		LL i=1,k=2,x=rand()%n,y=x;
		while(1)
		{
			i++;x=(mul(x,x,n)+c)%n;
			LL d=gcd(abs(x-y),n);
			if(d!=1&&d!=n)return d;
			if(x==y)return n;
			if(i==k)y=x,k<<=1;
		}
	}
	LL p1[MAXN],p2[MAXN],id;
	void Pollard_rho(LL n)
	{
		if(n==1)return ;
		if(Miller_rabin(n))pr[++plen]=n;
		else
		{
			LL d=try_split(n,rand()%n);
			Pollard_rho(d);Pollard_rho(n/d);
		}
	}
}
LL prime[MAXN],mxlim[MAXN],len;
void ad(LL &x,LL y){x+=y;if(x>=mod)x-=mod;}
void dl(LL &x,LL y){x-=y;if(x<0)x+=mod;}
LL ans;
void dfs(int k,LL cho,LL val)
{
	if(k==len+1)
	{
		if((cho&1)&&!(n&1))return ;
		if(!(cho&1))
		{
			val%=mod;if(val<0)val+=mod;
			LL sum=mul(mul(pow_mod(K,(cho+1)/2,mod),val,mod),cho/2,mod);
			ad(ans,sum);
		}
		else
		{
			val%=mod;if(val<0)val+=mod;
			LL sum=mul(mul(pow_mod(K,(cho+1)/2,mod),val,mod),cho,mod);
			ad(ans,sum);
		}return ;
	}LL mu=1;
	for(int i=0;i<=mxlim[k];i++)
		dfs(k+1,cho*mu,(i==mxlim[k])?val:val*(1-prime[k])),mu*=prime[k];
}
int main()
{
	n=read();K=read();K%=mod;plen=0;
	Prime::Pollard_rho(n);
	sort(pr+1,pr+1+plen);len=0;
	for(int i=1,nxt;i<=plen;i=nxt+1)
	{
		nxt=i;while(nxt+1<=plen&&pr[nxt+1]==pr[i])++nxt;
		prime[++len]=pr[i];mxlim[len]=nxt-i+1;
	}ans=0;
	dfs(1,1,1);
	pr2(ans);
	return 0;
}



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

int selectionSort(int A[100], int n)
{
	int c, i, j, m, minj; // ????????£??\????´?????????¨??????

	for(i=0; i < n; i++){
		minj=i;
		for(j = i; j < n; j++){ 
			if(A[j] < A[minj]){
				minj = j;
			}
		}
		if (minj != i){
		m = A[i];
		 	A[i] = A[minj];
		 	A[minj]=m;
			A[n+1]++;
		}
	}
	c = A[n+1];
	return c;
}

int main (void)
{
	int n, A[100]={0}, i, c;
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		scanf("%d", &A[i]);
	}
	
	c = selectionSort(A,n);
	
	for(i=0; i<n; i++){
		printf("%d", A[i]);
		if(i != n-1) printf(" ");
		if(i == n-1) printf("\n");
	}
	
	printf("%d\n", c);
	
  return 0;
}

Measured memory_bytes: 1032
import java.io.*;
import java.util.*;
import java.lang.*;

public class Main {
    static class FastReader
        {
            BufferedReader br;
            StringTokenizer st;

            public FastReader()
            {
                br = new BufferedReader(new
                        InputStreamReader(System.in));
            }

            String next()
            {
                while (st == null || !st.hasMoreElements())
                {
                    try
                    {
                        st = new StringTokenizer(br.readLine());
                    }
                    catch (IOException e)
                    {
                        e.printStackTrace();
                    }
                }
                return st.nextToken();
            }

            int nextInt()
            {
                return Integer.parseInt(next());
            }

            long nextLong()
            {
                return Long.parseLong(next());
            }

            double nextDouble()
            {
                return Double.parseDouble(next());
            }

            String nextLine()
            {
                String str = "";
                try
                {
                    str = br.readLine();
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
                return str;
            }
        }
    public static void main(String[] args) {
        FastReader ob = new FastReader();
        int s =ob.nextInt();
        int w=ob.nextInt();
        if(w>=s){
            System.out.println("unsafe");
        }
        else{
            System.out.println("safe");
        }
    }
}

Measured memory_bytes: 32608
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define inf LLONG_MAX
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    vvll card(3, vll(3));
    rep(i, 3) rep(j, 3) {
        cin >> card[i][j];
    }
    ll n; cin >> n;
    vll b(n);
    rep(i, n) cin >> b[i];
    vector<vector<bool>> ok(3, vector<bool>(3, false));
    rep(k, n) {
        rep(i, 3) rep(j, 3) {
            if (card[i][j] == b[k]) ok[i][j] = true;
        }
    }
    
    bool isok = false;
    rep(i, 3) {
        isok |= (ok[i][0] && ok[i][1] && ok[i][2]);
    }
    rep(j, 3) {
        isok |= (ok[0][j] && ok[1][j] && ok[2][j]);
    }

    isok |= (ok[0][0] && ok[1][1] && ok[2][2]);
    isok |= (ok[2][0] && ok[1][1] && ok[0][2]);

    cout << (isok ? "Yes" : "No") << endl;
    return 0;
}

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

int main() {
	int n, d; cin >> n >> d;
	two_sat ts(n);
	int x[n], y[n];
	for(int i = 0; i < n; ++i) {
		cin >> x[i] >> y[i];
	}
	// (x, y) := (true, false)
	// not (x and y) <=> (not x) or (not y)
	for(int i = 0; i < n; ++i) {
		for(int j = i + 1; j < n; ++j) {
			if(abs(x[i] - x[j]) < d) {
				ts.add_clause(i, false, j, false);
			}
			if(abs(x[i] - y[j]) < d) {
				ts.add_clause(i, false, j, true);
			}
			if(abs(y[i] - x[j]) < d) {
				ts.add_clause(i, true, j, false);
			}
			if(abs(y[i] - y[j]) < d) {
				ts.add_clause(i, true, j, true);
			}
		}
	}
	if(ts.satisfiable()) {
		cout << "Yes" << '\n';
		auto v = ts.answer();
		for(int i = 0; i < n; ++i) {
			cout << (v[i] ? x[i] : y[i]) << '\n';
		}
	} else {
		cout << "No" << '\n';
	}
	return 0;
}


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

int main(){
    int a, b, K;
    cin >> a >> b >> K;
    vector<int> t;
    for(int i = 1; i <= b; i++){
        if(a % i == 0 && b % i == 0){
            t.push_back(i);
        }
    }
    cout << t[ t.size() - K ] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

const int mod =998244353;
vi fac(4000);
int prev2[2001][2001] = {0};
long long inv(long long a, long long b = mod){
 return 1<a ? b - inv(b%a,a)*b/a : 1;
}
int choose(int a, int b){
    if(b > a)return 0;
    assert(a <= 2000);
    int ans = fac[a] * inv(fac[b]);
    ans %= mod;
    ans *= inv(fac[a- b]);
    ans %= mod;
    return ans;
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);

    string s;cin >> s;
    int n = s.length();
    int r = 0, g = 0;
    prev2[0][0] = 1;
    FOR(i, n){

        if(s[i] == '0')r += 2;
        else if(s[i] == '1')r += 1, g += 1;
        else g += 2;

        //prev2ious length was i
        for(int reds = 0; reds <= i; reds++){
            int greens = i - reds;
            if(g > greens){
                prev2[greens + 1][reds] += prev2[greens][reds];
                prev2[greens + 1][reds] %= mod; 
            }
            if(r > reds){
                prev2[greens][reds + 1] += prev2[greens][reds];
                prev2[greens][reds + 1] %= mod; 
            }
        }
    }
    fac[0] =1;
    FOR1(i, 2000)fac[i] = fac[i-1]*i, fac[i] %= mod;
    int ans= 0;
    for(int reds = 0; reds <= n; reds++){
        int greens = n - reds;
        ans += prev2[greens][reds] * choose(n, r - reds);
        ans %= mod;
    }
    cout << ans;
}





Measured memory_bytes: 31232
/*
    ( ´-ω･)︻┻┳══━一一一一一一一				(× _ ×)
	
	Stay Low. Go Fast
	Kill First. Die Last
	One Shot. One Kill
	No Luck. Pure Skill 
*/

#include<bits/stdc++.h>
using namespace std;

/*************************** MACROS **************************/
#define ld long double
#define ll long long  
#define ull unsigned long long
#define loop(i,x,y) for(ll i=x;i<y;i++)
#define rloop(i,x,y) for(ll i=x;i>=y;i--)
#define vll vector<ll>
#define pb push_back
#define S second
#define F first
#define B begin()
#define E end()
#define W(x) while(x--)
#define pll pair< ll,ll >
#define vpll vector< pll >
#define qll queue<ll>
#define dqll deque<ll>
#define qpll queue<pll>
#define dqpll deque<pll>
#define pqll priority_queue<ll>
#define pqpll priority_queue<pll>
#define Line cout<<"\n**************************\n\n";

/*************************** CONST ******************************/

const ll MOD = 1000000007;
const ll MOD1 = 998244353;
const ll MIN_LL = -1e18;
const ll MAX_LL = 1e18;
const int MAX_INT = 1e9;
const int MIN_INT = -1e9;
const ld pie = 3.1415926535;
 
/************************** POW UTIL *****************************/
 
ll fpow(ll n,ll p){;ll m=1;while(p){if(p%2)m*=n;p>>=1;n*=n;}return m;}
ll mfpow(ll n,ll p,ll M){ll m=1;n%=M;while(p){if(p%2)m=(m*n)%M;n=(n*n)%M;p>>=1;}return m%M;}
 
/************************* PRINT UTIL *****************************/

template<class T> inline ostream& operator<<(ostream& o,vector<T> v){for(auto i:v)o<<i<<" ";return o;};
template<class T> inline ostream& operator<<(ostream& o,set<T> s){for(auto i:s)o<<i<<" ";return o;}
template<class T> inline ostream& operator<<(ostream& o,multiset<T> s){for(auto i:s)cout<<i<<" ";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,pair<T1,T2> p){o<<p.F<<" "<<p.S<<"\n";return o;}
template<class T1,class T2> inline ostream& operator<<(ostream& o,map<T1,T2> m){for(auto p:m)o<<p.F<<" "<<p.S<<"\n";return o;}

/*************************** VARIABLES **************************/

const vll days={31,28,31,30,31,30,31,31,30,31,30,31};
 
bool br,br1,br2; 
char ch,ch1,ch2;
 

ll n,m,k,x,y,z,mini,maxi,l,r,sum,t,w;
pll p,p1,p2;

string s,s1,s2;

set<ll> st,st1,st2;
multiset<ll> mst; 

map<ll,ll> mp;

/**************************** FXNS ****************************/

void solve()
{

	cin>>x>>y;

	cout<<x*y<<endl;

}
 
/*************************** MAIN ****************************/
 
int main(){
 
 
	// #ifndef ONLINE_JUDGE
	        // freopen("input.txt", "rt", stdin);
	        // freopen("output.txt", "wt", stdout);
	// #endif
 
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);

	solve();
 
	return 0;
}


Measured memory_bytes: 3620