akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
	cin>>s;
	int len=s.size();
	for(int i=0;i<=len;i++)
	{
		if(s[i]=='C')
		{
			for(int j=i;j<=len;j++)
			{
				if(s[j]=='F')
				{
					cout<<"Yes"<<endl;
					return 0;
				}
			}
		}
		
	}
	cout<<"No"<<endl;
	
	
	
	return 0;
}

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, m;
	cin >>n >>m;
	vector<vector<pii>> r(n);
	rep(i, m){
		int a, b, d;
		cin >> a >>b >>d;
		r[a-1].emplace_back(b-1, d);
		r[b-1].emplace_back(a-1, -d);
	}
	const int INF= 1<<28;
	VI dd(n, INF);
	bool ok=true;
	auto dfs = [&](auto dfs, int s, int p){
		if(!ok) return;
		for(auto v : r[s]) if(v.first != p){
			if(dd[v.first]==INF){
				dd[v.first] = dd[s] + v.second;
				dfs(dfs, v.first, s);
			} else if(dd[v.first] != dd[s] + v.second){
				ok = false; return;
			}
		}
	};
	
	rep(i, n) if(dd[i] == INF){
		dd[i] = 0;
		dfs( dfs, i, -1);
		if(!ok){
			puts("No"); return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 11648
N=int(input())
l=[]
for i in range(5):
    l.append(int(input()))
m=min(l)
k=[]
if m<N:
    if N%m!=0:#6 2
        b=N//m
        print(b+5)
    else:
        b=N//m
        print(b+5-1)
else:
    print(5)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
using namespace std;

typedef long long ll;

int main(void) {
	int N;
	cin >> N;
	map<string, int> mp;
	for (int i = 0; i < N; i++)
	{
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	ll ans = 0;
	for (auto& p : mp)
	{
		int s = p.second;
		ans += (ll)s * (s - 1) / 2;
	}


	cout << ans << endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;

int main(){
    int N,M;
    cin >> N >> M;
    char a[N][N];
    char b[M][M];
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            cin >> a[i][j];
        }
    }
    for(int i=0;i<M;i++){
        for(int j=0;j<M;j++){
            cin >> b[i][j];
        }
    }
    for(int i=0;i<=N-M;i++){
        for(int j=0;j<=N-M;j++){
            int count=0;
            for(int u=0;u<M;u++){
                for(int v=0;v<M;v++){
                    if(a[i+u][j+v]==b[u][v]) count++;
                    if(count==M*M){
                        puts("Yes");
                        return 0;
                    }
                }
            }
        }
    }
    puts("No");
    return 0;
}

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


int main(){
    string s;cin>>s;
    ll countb = 0;
    ll ans = 0;
    int n = s.size();
    for(int i = 0;i<n;i++){
        if(s[i]=='W') {
            ans+=countb;
        }
        
        else {
            countb++;
        }


    }
    cout<<ans<<endl;

}


Measured memory_bytes: 3756
#!/usr/bin/env python3

#    下  右  上  左
dy = [1, 0, -1, 0]
dx = [0, 1, 0, -1]

H, W = map(int, input().split())

grid = []
for i in range(H):
    grid.append(input())

# print(grid)

ans = True

for i in range(H):
    for j in range(W):
        if grid[i][j] == '#':
            cnt = 0
            # print(i, j, sep='-', end='=')
            for k in range(4):
                y = i + dy[k]
                x = j + dx[k]
                if x >= 0 and y >= 0 and x < W and y < H:
                    # print(y, x, grid[y][x], sep='-', end=' ')
                    if grid[y][x] == '#':
                        cnt += 1
            # print(cnt)
            if cnt == 0:
                ans = False
                break
    else:
        continue
    break

if ans is True:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
/*
AuThOr GaRyMr
技巧:
1.区别对待大数据&小数据！
2.Dp难推时算贡献！
3.long long (尤其乘法)！
4.long long INF 要大
5.Dp on trees: 换根法，每次清空当前的节点和换到的子节点
6.long double | 输出浮点数
7.注意特判!(prince and princess)
8.是否可以记录两个值之间的关系 CSPday2 meal
9.括号-》数组or栈
10.是否可以先构造
11.网络流奇偶构图
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int main(){
	int a,b;
	cin>>a>>b;
	if(a!=1&&b!=1){
		cout<<1;
	} 
	if(a!=2&&b!=2){
		cout<<2;
	} 
	if(a!=3&&b!=3){
		cout<<3;
	} 
	return 0;
}


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

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

int main() {
  ll N;
  cin >> N;
  FOR(i, 2, 55556) {
    if (isprime(i) == true && i % 5 == 1) {
      cout << i << " ";
      N--;
    }
    if (N == 0) {
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#define MOD 1000000007LL
typedef long long ll;
using namespace std;
ll pow(ll m, ll n){
  if(n==1){
    return m;
  }
  ll a=pow(m,n/2);
  a =a*a%MOD;
  if(n%2==1){
    a=a*m%MOD;
  }
  return a;
}

int main(){
  ll m,n;
  cin >> m >>n;
  cout<< pow(m,n)<<endl;
  return 0;
}



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

#ifdef DEBUG
#include "../include/debug.hpp"
#else
#define debug(...) 42
#define rdfile(...) 42
#endif

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // rdfile("_input.txt");

    string s;
    cin >> s;

    if (s <= "2019/04/30") {
        cout << "Heisei" << endl;
    } else {
        cout << "TBD" << endl;
    }

    return 0;
}

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

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if ((A.at(A.size() - 1) == B.at(0)) && (B.at(B.size() - 1) == C.at(0))) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

struct factorials{
	vector<vector<long long>> arr;
	long long modpow(long long a, long long b, const long long &mod){
		if(b == 0) return 1 % mod;
		long long ret = modpow(a, b / 2, mod);
		ret = (ret * ret) % mod;
		if(b % 2) ret = (ret * a) % mod;
		return ret;
	}
	factorials(long long n, const long long &mod) : arr(n + 1, vector<long long>(2)){
		arr[0][0] = arr[0][1] = 1;
		for(long long i = 1; i <= n; i++){
			arr[i][0] = (arr[i - 1][0] * i) % mod;
			arr[i][1] = modpow(arr[i][0], mod - 2, mod);
		}
	}
	long long binomial(long long n, long long r, const long long &mod){
		return ((arr[n][0] * arr[n - r][1]) % mod * arr[r][1]) % mod;
	}
};

const long long mod = 998244353;
long long n, m, k;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> m >> k;
	factorials fac(n, mod);
	long long sum = 0;
	for(long long i = 0; i < n; i++)
		if(i >= n - 1 - k){
			long long bin = fac.binomial(n - 1, i, mod);
			sum = (sum + ((bin * m) % mod * fac.modpow(m - 1, i, mod)) % mod) % mod;
		}
	cout << sum << "\n";
	return 0;
}

Measured memory_bytes: 14240
S = str(input())
check = 1
for i in range(len(S)):
    if i%2==0 and S[i]=='L':
        check = 0
        break
    elif i%2==1 and S[i]=='R':
        check = 0
        break
if check == 1:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 61908
#include <iostream>
#include <string>
#include <map>
using namespace std;
#define C
#ifdef C
int main(void)
{
	map<int, int> arr;

	int N;
	cin >> N;
	int int_in;

	for (size_t i = 0; i < N; i++)
	{
		cin >> int_in;
		arr[int_in]++;
	}
	map<int, int>::iterator end_arr;
	end_arr = arr.end();

	int max = 1;
	int dis;
	int index;
	for (auto a : arr) {
		dis = a.second;
		index = a.first;
		if (arr.find(index - 1) != end_arr)
			dis += arr[index -1];
		if (arr.find(index + 1) != end_arr)
			dis += arr[index + 1];

		if (max < dis)
			max = dis;
	}
	cout << max << endl;
	return 0;
}

#endif

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

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

    vector<int> d(n);
    for(int i=0; i<n; i++){
        cin >> d[i];
    }

    int total = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            total += d[i] * d[j];
        }
    }

    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<cstdio>
#include<cstring>
#include<queue>
#include<deque>
#include<stack>
#include<ctime>
#include<cmath>
#include<complex>
#include<cstdlib>
#include<iomanip>
#include<utility>
#include<cctype>
#include<bitset>
#include<list>
using namespace std;
 
int n;
int a[100005];
int sum[100005];
 
int main(){
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) sum[i]=sum[i-1]+abs(a[i]-a[i-1]);
	cout<<abs(a[2])+abs(a[n])+sum[n]-sum[2]<<endl;
	for(int i=2;i<n;i++) cout<<abs(a[1])+abs(a[n])+abs(a[i+1]-a[i-1])+sum[i-1]-sum[1]+sum[n]-sum[i+1]<<endl;
	cout<<abs(a[1])+abs(a[n-1])+sum[n-1]-sum[1]<<endl;
	return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
#include <utility>

#define rep(i,n)	for(int i = 0;i < n;i++)
#define rep2(i,n)	for(int i = 1;i <= n;i++)
#define each(i,x)	for(auto & i : x)

using namespace std;

int main()
{
	const int mod = 100000;
	int n,m;
	cin >> n >> m;
	vector<int> table(n);
	rep2(i,n-1)
	{
		cin >> table[i];
	}
	for(int i = 1;i < n;i++)
	{
		table[i] += table[i-1];
	}
	int s = 0;
	int p = 0;
	rep(i,m)
	{
		int a;
		cin >> a;
		s += abs(table[p+a] - table[p]);
		p += a;
		s %= mod;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 1524
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

def calc(ans):
    ret = 0
    L = [0] * D
    for d, t in enumerate(ans):
        ret += S[d][t]
        for c, l in zip(C, L):
            ret -= c * (d - l)
    return ret

mx = -10**18
ans = 0
for i in range(26):
    res = calc([i] * D)
    if mx < res:
        mx = res
        ans = i

print(*([ans + 1] * D), sep='\n')

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

#define F first
#define S second
#define pb push_back
#define all(x) x.begin(), x.end()
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")


using namespace std;

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

const int N = 200000 + 10;
const ll MOD = 1000000000 + 7;
const ll INF = 1000000010;
const ll LOG = 25;

int32_t main(){
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll n;
	cin >> n;
	cout <<(n - 2) * 180;












	return 0;
}


Measured memory_bytes: 3636
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var なおちゃん = Console.ReadLine();
			var キングofうんこ = Console.ReadLine();

			for (int i = 0; i < なおちゃん.Length; i++)
			{
				if (なおちゃん == キングofうんこ) // ←重要
				{
					Console.WriteLine("Yes");
					return;
				}
				なおちゃん = $"{new string(なおちゃん.Skip(1).ToArray())}{なおちゃん.First()}";
			}
			Console.WriteLine("No");
		}
	}
}


Measured memory_bytes: 13268
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <stack>
using namespace std;

template< typename T >
struct Edge {
  int from, to;
  T cost;
  Edge() {}
  Edge(int f, int t) : from(f), to(t), cost(1) {}
  Edge(int f, int t, T c) : from(f), to(t), cost(c) {}
  friend bool operator < (const Edge& lhs, const Edge& rhs) { return lhs.cost < rhs.cost; };
  friend bool operator > (const Edge& lhs, const Edge& rhs) { return rhs < lhs; };
  friend bool operator <= (const Edge& lhs, const Edge& rhs) { return !(lhs > rhs); };
  friend bool operator >= (const Edge& lhs, const Edge& rhs) { return !(lhs < rhs); };
};

template< typename T >
using Edges = std::vector< Edge< T > >;
template< typename T >
using Graph = std::vector< Edges< T > >;


struct Memo { int i, v; };
vector<int> dp(300000,1<<30); // 長さiの最小値
vector<int> la(300000);
vector<int> ans(300000);
stack<Memo> memo;

void dfs(int s, int par, Graph<int>& g) { 
  auto it = upper_bound(dp.begin(),dp.end(),la[s]-1);
  int id = distance(dp.begin(),it);
  memo.push({id, dp[id]});
  dp[id] = la[s];
  ans[s] = distance(dp.begin(), lower_bound(dp.begin(),dp.end(),(1<<30)))-1;
  for (auto &e: g[s]) {
    if (e.to == par) continue;
    dfs(e.to, s, g);
  }
  Memo m = memo.top(); memo.pop();
  dp[m.i] = m.v;
}

int main() {
  int n; cin >> n;
  Graph<int> g(n);
  for (int i = 0; i < n; ++i) {
    cin >> la[i];
  }
  for (int i = 0; i < n-1; ++i) {
    int u, v; cin >> u >> v;
    --u; --v;
    g[u].emplace_back(u,v);
    g[v].emplace_back(v,u);
  }
  dp[0] = 0;
  dfs(0, -1, g);
  for (int i = 0; i < n; ++i) {
    cout << ans[i] << endl;
  }
}


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

vector<string>D;

int solve(int n, int m, bool b){
        int num=b;
        for (int i = m; i < D.size(); i++) {
                if (D[i].size() <= n) {
                        return num;
                }
                if (D[i][n] == '+') {
                        if (b) {
                                num *= solve(n + 1, i + 1, 0);
                        } else {
                                num += solve(n + 1, i + 1, 0);
                        }
                } else if(D[i][n] == '*') {
                        if (b) {
                                num *= solve(n + 1, i + 1, 1);
                        } else {
                                num += solve(n + 1, i + 1, 1);
                        }
                } else if(D[i][n] == '.') {
                        continue;
                } else {
                        if (b) {
                                num *= D[i][n] - '0';
                        } else {
                                num += D[i][n] - '0';
                        }
                }
        }
        return num;
}

int main(){
        int N;
        while (cin>>N, N) {
                D=vector<string>(N);
                for (int i = 0; i < N; i++) {
                        cin>>D[i];
                }
                cout<<solve(0, 0, 0)<<endl;
        }
 }

Measured memory_bytes: 3088
import sys
input = lambda: sys.stdin.readline().rstrip()


from heapq import heappop, heappush, heapify
X,Y,Z,K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

sum_list = []
seen_list = set()
ans = []

heappush(sum_list, (-(A[0]+B[0]+C[0]), 0, 0, 0))
seen_list.add((0, 0, 0))

for _ in range(K):
    s, i, j, k = heappop(sum_list)
    
    ans.append(-s)

    if i+1 < len(A) and (i+1, j, k) not in seen_list:
        heappush(sum_list, (-(A[i+1]+B[j]+C[k]), i+1, j, k))
        seen_list.add((i+1, j, k))

    if j+1 < len(B) and (i, j+1, k) not in seen_list:
        heappush(sum_list, (-(A[i]+B[j+1]+C[k]), i, j+1, k))
        seen_list.add((i, j+1, k))

    if k+1 < len(C) and (i, j, k+1) not in seen_list:
        heappush(sum_list, (-(A[i]+B[j]+C[k+1]), i, j, k+1))
        seen_list.add((i, j, k+1))

for i in range(0, K):
    print(ans[i])


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

#define foreach(i, v) for(__typeof((v).begin()) i = (v).begin(); i != (v).end(); ++ i)

using namespace std;
typedef long long ll;

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

int dist[60][60];
int h,w;
int sy,sx;
std::vector<string> mp(60);

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int h,w;cin>>h>>w;


  int white=0;
  for(int y=0;y<h;y++){
    cin>>mp[y];
    white += count(mp[y].begin(), mp[y].end(), '.');
  }

  queue<int> q;
  q.push(0);
  q.push(0);
  dist[0][0]=1;
  while(q.size()){
    int y = q.front();q.pop();
    int x = q.front();q.pop();
    for(int i=0;i<4;i++){
      int ny= y + dy[i];
      int nx= x + dx[i];
      if(!(0<=ny&&ny<h&&0<=nx&&nx<w))continue;
      if(mp[ny][nx]=='#')continue;
      if(dist[ny][nx] && dist[ny][nx]<=dist[y][x]+1)continue;
      q.push(ny);
      q.push(nx);
      dist[ny][nx] = dist[y][x]+1;
    }
  }

  if(!dist[h-1][w-1])cout<<-1<<endl;
  else cout<<white-dist[h-1][w-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp make_pair
#define pr(num) cout << num << "\n"
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 100100
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;


int main(void) {
    ll N, A;
    cin >> N >> A;
    ll x[55];
    ll i, j, k;
    for(i=0; i<N; i++) {
        cin >> x[i];
    }
    
    
    ll dp[N+5][N*A+5][N+5];
    memset(dp, 0, sizeof(dp));
    
    dp[0][0][0]=1;
    for(i=1; i<=N; i++) {
        for(j=0; j<=N*A; j++) {
            for(k=1; k<=i; k++) {
                if(j+x[i-1]<=N*A)
                    dp[i][j+x[i-1]][k]+=dp[i-1][j][k-1];
                dp[i][j][k-1]+=dp[i-1][j][k-1];
            }
        }
    }
    
    
    ll ans=0;
    for(k=1; k<=N; k++) {
        ans+=dp[N][k*A][k];
    }
    
    pr(ans);
}













Measured memory_bytes: 59392
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<int> marked(n * n);
  vector<int> ans(n * n);
  for (int i = 1; i <= n; i++) {
    int x;
    cin >> x;
    --x;
    marked[x] = ans[x] = i;
  }
  for (int i = n * n - 1, j = n * n - 1; i >= 0; i--) {
    if (marked[i] == 0) continue;
    int need = n - marked[i];
    for (; j > i && need > 0; j--) {
      if (ans[j] == 0) ans[j] = marked[i], need--;
    }
    if (need > 0) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0, j = 0; i < n * n; i++) {
    if (marked[i] == 0) continue;
    int need = marked[i] - 1;
    for (;j < i && need > 0; j++) {
      if (ans[j] == 0) ans[j] = marked[i], need--;
    }
    if (need > 0) {
      cout << "No\n";
      return 0;
    }
  }
  for (int i = 0; i < n * n; i++) if (ans[i] == 0) {
    cout << "No\n";
    return 0;
  }
  cout << "Yes\n";
  for (int i = 0; i < n * n; i++) {
    if (i > 0) cout << " ";
    cout << ans[i];
  }
  cout << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    rep(i, s.size())
    {
        s[i] = (s[i] - 'A' + n) % 26 + 'A';
    }
    cout << s << endl;

    return 0;
}


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

#define NMAX 21

vector <tuple <int, int, int> > sol;

int main()
{
    ios::sync_with_stdio(false);

    int l;
    // ifstream cin("code.in");
    cin >> l;

    int k = 1;
    while ((1 << k) - 1 < l) {
        k++;
    }

    for (int i = 1; i < k; i++) {
        sol.emplace_back(i, i + 1, 0);
        sol.emplace_back(i, i + 1, 1 << (i - 1));
    }

    int sum = (1 << (k - 1));
    for (int i = k - 1; i >= 1; i--) {
        if ((l & (1 << (i - 1))) == 0)
            continue;
        sol.emplace_back(i, k, sum);
        sum += (1 << (i - 1));
    }

    cout << k << " " << sol.size() << "\n";
    for (const tuple <int, int, int>& x : sol) {
        cout << get<0>(x) << " " << get<1>(x) << " " << get<2>(x) << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
        int n;

        while (cin >> n) {
                int ans = 0;
                if (n <= 9) {
                        for (int a = 0; a <= n; a++)
                                for (int b = 0; b <= n; b++)
                                        for (int c = 0; c <= n; c++)
                                                for (int d = 0; d <= n; d++)
                                                        if (a + b + c + d == n)
                                                                ans++;
                }
                else {
                        for (int a = 0; a <= 9; a++)
                                for (int b = 0; b <= 9; b++)
                                        for (int c = 0; c <= 9; c++)
                                                for (int d = 0; d <= 9; d++)
                                                        if (a + b + c + d == n)
                                                                ans++;

                }
                cout << ans << endl;
        }

        return 0;
}

Measured memory_bytes: 1160
from collections import defaultdict


def solve():
    _ = int(input())
    A = list(map(int, input().split()))
    
    counter = defaultdict(int)
    for ai in A:
        counter[ai] += 1
    
    first, second = 0, 0
    for key, val in counter.items():
        if 4 <= val:
            if first < key:
                first, second = key, key
            elif second < key:
                second = key
        elif 2 <= val:
            if first < key:
                first, second = key, first
            elif second < key:
                second = key
    ans = first * second
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 18600
N, X, Y = map(int, input().split())
ans = [0] * N
for i in range(1,N):
    for j in range(i+1,N+1):
        ans[min(j - i, abs(i - X) + 1 + abs(Y - j))] += 1
        # print(ans)
for i in range(1,N):
    print(ans[i])


Measured memory_bytes: 3444
#include <iostream>

using namespace std;

int main()
{
    int N, K;
    string S;

    cin >> N;
    cin >> S;
    cin >> K;

    char target = S[K-1];

    for (int i = 0; i < N; i++)
    {
        if (target == S[i])
        {
            cout << target;
        }
        else
        {
            cout << "*";
        }
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(){
    
    int w, h, x, y, r;

    cin >> w >> h >> x >> y >> r;

    if(x<0 || y<0){
        cout << "No" << endl;
    }else{
        if(x+r <= w && y+r <= h){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }

    return 0;
}



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


int main()
{
	string s;
	cin>>s;
	if(s[0]=='S')
	{
		if(s[1]=='A') printf("1");
		else  printf("7");
	}
	if(s[0]=='M') printf("6");
	if(s[0]=='T'&&s[1]=='U') printf("5");
	if(s[0]=='W') printf("4");
	if(s[0]=='T'&&s[1]=='H') printf("3");
	if(s[0]=='F') printf("2");
	//if(s[0]=='S') printf("1");
	return 0;
 } 
 //SUN, MON, TUE, WED, THU, FRI, or SAT.

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

int main() {
	string s;
	int q, t, f;
	char c;
	cin >> s;
	cin >> q;

	bool is_rev = false;  //文字列が反転しているか否かを表す
	rep(i,q) {
		cin >> t;
		if (t == 1) {
			is_rev = !is_rev;
		}
		else {
			cin >> f >> c;
			//cout << f << c;
			if ( ( (f == 1) && (is_rev == false) ) || ( (f == 2) && (is_rev == true) ) ) {
				s.insert(s.begin(), c);
			}
			else {
				s += c;
			}
		}
	}

	if (is_rev == true) {
		reverse(s.begin(), s.end());
	}
	cout << s << endl;
	
	return 0;
}


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

const ll mod = 998244353;
class SegmentTree {
private:
    int n;
    vector<ll> node, lazy;
public:
    SegmentTree(int N) {
        n = 1;
        while (n < N) n *= 2;
        node.resize(2 * n - 1, 0);
        lazy.resize(2 * n - 1, 0);
    }

    void update(int i, int l, int r) {
        if (lazy[i] == 0) return;
        node[i] += lazy[i];
        node[i] %= mod;
        if (r - l > 1) {
            lazy[2 * i + 1] += lazy[i] / 2;
            lazy[2 * i + 2] += lazy[i] / 2;
        }
        lazy[i] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return;
        
        if (a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            update(k, l, r);
        } else {
            add(a, b, x, 2 * k + 1, l, (l + r) / 2);
            add(a, b, x, 2 * k + 2, (l + r) / 2, r);
            node[k] = (node[2 * k + 1] + node[2 * k + 2]) % mod;
        }
    }

    ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
        if (r < 0) r = n;
        update(k, l, r);
        if (b <= l || r <= a) return 0;        
        if (a <= l && r <= b) return node[k] % mod;

        ll sum_l = query(a, b, 2 * k + 1, l, (l + r) / 2);
        ll sum_r = query(a, b, 2 * k + 2, (l + r) / 2, r);
        return (sum_l + sum_r) % mod;
    }

};

int main() {
    int N, K;
    cin >> N >> K;
    int L[K], R[K];
    for (int i = 0; i < K; i++) {
        cin >> L[i] >> R[i];
    }

    SegmentTree st(N + 1);
    st.add(1, 2, 1);
    
    for (int i = 1; i < N; i++) {
        ll x = st.query(i, i + 1);
        for (int j = 0; j < K; j++) {
            int l = i + L[j];
            int r = i + R[j] + 1;
            st.add(min(l, N + 1), min(r, N + 1), x);
        }
    }

    cout << st.query(N, N + 1) << "\n";

    return 0;
}

Measured memory_bytes: 11452
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            new Program().Solve();
        }

        void Solve()
        {
            var tmp = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            long n = tmp[0];
            long m = tmp[1];

            long ans = 0;

            if (n == 1 && m == 1)
            {
                ans = 1;
            }
            else if (n == 1)
            {
                ans = m - 2;
            }
            else if (m == 1)
            {
                ans = n - 2;
            }
            else //m>=2,n>=2
            {
                ans = (n - 2) * (m - 2);
            }


            Console.WriteLine(ans);

        }
    }
}


Measured memory_bytes: 11348
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int x,n;cin>>x>>n;
  if(n==0){
    cout<<x<<endl;
    return 0;
  }
  vector<int>hoge(n);rep(i,n)cin>>hoge[i];
  sort(hoge.begin(),hoge.end());
  int ans,shake=0,huga=200;
  rep(i,200){
    if(i==hoge[shake]){
      shake++;
      continue;
    }
    if(huga>abs(i-x)){
      huga=abs(i-x);
      ans=i;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3656
#include<stdio.h>

#include<stdlib.h>


#include<string.h>


int main(void){


char num_str[1002];


int num;


long sum=0;


int i;


char tmp;


while(1)


{


fgets(num_str,sizeof(num_str),stdin);


if(num_str[0]=='0')break;


for(i=0;i<strlen(num_str)-1; i++)


{


tmp=num_str[i];


num=atoi(&tmp);


sum=sum+num;


}


printf("%ld\n",sum);


sum=0;


memset(num_str,1002,0);


}


return 0;


}

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

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

    if(b - a <= 0){
        cout << "delicious" << endl;
    }
    else if(b - a > x){
        cout << "dangerous" << endl;
    }
    else{
        cout << "safe" << endl;
    }

    return 0;
}

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

#define REP(i, x) for (int i = 0; i < (x); i++)
#define RREP(i, x) for (int i = (x) - 1; i >= 0; i--)

using ll = long long;

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

    const int MAXN = 5010;

    static ll a[MAXN];

    REP (i, N) {
        cin >> a[i];
    }
    sort(a, a + N);

    int M = 0;
    REP (i, N) {
        if (a[i] < K) M++;
    }
    int nes = N - M;    // 必要なもの

    static int dp[5010][10010];
    const int INF = (1 << 28);

    REP (i, 5010) REP (j, 10010) dp[i][j] = INF;
    dp[0][0] = 1;
    REP (i, M) {
        REP (j, 2 * K) {
            dp[i + 1][j] = dp[i][j];
            if (j - a[i] >= 0) {
                dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - a[i]]);
            }
        }
    }
    
    /*
    cerr << "first" << endl;
    REP (i, M + 1) {
        REP (j, 2 * K) {
            cerr << "(" << i << ", " << j << ") " << dp[i][j] << endl;
        }
    }
    */

    REP (i, 2 * K) {
        dp[M][i] = (i >= K and dp[M][i] < INF ? i : INF);
    }

    RREP (i, M) {
        int x = INF;
        REP (j, K) {
            if (dp[i][j] >= INF) continue;
            x = min(x, dp[i + 1][j + a[i]]);
        }
        if (x - a[i] < K) nes++;

        REP (j, 2 * K) {
            dp[i][j] = dp[i + 1][j];
            if (j + a[i] < 2 * K) {
                dp[i][j] = min(dp[i][j], dp[i + 1][j + a[i]]);
            }
        }
    }

    /*
    cerr << "second" << endl;
    REP (i, M + 1) {
        REP (j, 2 * K) {
            cerr << "(" << i << ", " << j << ") " << dp[i][j] << endl;
        }
    }
    */

    cout << N - nes << endl;

    return 0;
}

Measured memory_bytes: 196224
#include <bits/stdc++.h>
using namespace std;
const int maxN = 2 * 1e5 + 7;
vector<int> adj[maxN];
bool mark[maxN];
int dfs(int u){
  mark[u] = true;
  int k = 0;
  for(int m : adj[u])
    if(!mark[m])
      k += dfs(m) + 1;
  return k;
}
int main(){
  // freopen("input.txt", "r", stdin);
  int n, m, x, y;
  cin >> n >> m;
  while(m--){
    scanf("%d %d", &x, &y);
    adj[x].emplace_back(y);
    adj[y].emplace_back(x);
  }
  int ans = 0;
  for(int i = 1; i <= n; i++){
    if(!mark[i]){
      ans = max(ans, dfs(i));
    }
  }
  if(ans + 1 == n)
    cout << n << '\n';
  else
    cout << ans + 1 << '\n';
  return 0;
}

Measured memory_bytes: 24192
#include <map>
#include <list>
#include <cmath>
#include <queue>
#include <cstring>
#include <iostream>
#include <algorithm>
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
int x,y;
int main()
{
	cin>>x>>y;
	if (x%y==0)
	   cout<<-1<<endl;
	else
	   cout<<x<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL
#define endl "\n"

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll H, W;
  cin >> H >> W;
  vector<string> s(H);
  for(int i = 0; i < H; i++){
    cin >> s.at(i);
  }
  vvll dp(H, vll(W, INF));
  if(s.at(0).at(0) == '#') dp.at(0).at(0) = 1;
  else dp.at(0).at(0) = 0;

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(i-1 >= 0){
        ll d = ((s.at(i-1).at(j) == '.' && s.at(i).at(j) == '#')? 1LL: 0LL);
        chmin(dp.at(i).at(j), dp.at(i-1).at(j) + d);
      }
      if(j-1 >= 0){
        ll d = ((s.at(i).at(j-1) == '.' && s.at(i).at(j) == '#')? 1LL: 0LL);
        chmin(dp.at(i).at(j), dp.at(i).at(j-1) + d);
      }
    }
  }
  cout << dp.at(H-1).at(W-1) << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <math.h>
#include <set>
#include <bitset>
#include <stack>
#include <cmath>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

typedef vector<ll> vecll;
typedef vector<ld> vecld;
typedef vector<bool> vecbl;
typedef vector<vector<ll> > matll;
typedef vector<vector<ld> > matld;
typedef vector<vector<bool> > matbl;
#define mp make_pair;

const ll prime = 1000000000 + 7;
const ld PI = 2 * acos(0.0);

/*
cout << fixed << setprecision(10);
*/

bool my_comp(pll a, pll b) {
	if (a.first != b.first) {
		return a.first < b.first;
	}

	return a.second < b.second;
}

// nのk乗(mod p = prime)
ll power(ll n, ll k) {
	ll p = prime;
	if (k == 1) {
		return n;
	}
	ll m = n * n;
	m %= p;
	if (k % 2 == 0) {
		return power(m, k / 2);
	}
	m = power(m, k / 2);
	m *= n;
	m %= p;
	return m;
}

// nCk(mod p = prime)
ll com(ll n, ll k) {
	// nCk
	ll p = prime;

	ll ans = 1;
	for (ll i = 1; i <= n; i++)
	{
		ans *= i;
		ans %= p;
	}

	for (ll i = 2; i <= k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	for (ll i = 2; i <= n-k; i++)
	{
		ans *= power(i, p - 2);
		ans %= p;
	}

	return ans;
}


int main() {

	ll a, b, n, x, y;
	cin >> a >> b >> n;

	x = min(b - 1, n);
	y = (ll)((a * x) / b);
	cout << y << endl;

	return 0;
}


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

using namespace std;

typedef long long ll;

int main() {
        ios::sync_with_stdio(false);
        cin.tie(0);
        int a, b, x;
        cin >> a >> b;
        x = max(a * 25 / 2 + a % 2, 10 * b);
        if (2 * x / 25 == a && x / 10 == b)
                cout << x << "\n";
        else
                cout << "-1\n";
        return 0;
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline

class UnionFind:
    def __init__(self, N):
        # negative value: represents the root of a tree; its absolute value is the size of the tree
        # positive value: the parent's index
        self.vertices = [-1 for _ in range(N)]
        self.rank = [0] * N
        
    def find(self, v):
        if self.vertices[v] < 0: # v is a root
            return v
        else:
            # path compression: reconnect v to the root
            self.vertices[v] = self.find(self.vertices[v])
            return self.vertices[v]
        
    def union(self, u, v):
        s1 = self.find(u) # the root of the tree including vertex u
        s2 = self.find(v) # the root of the tree including vertex v
        
        if s1 == s2: # u and v is in the same tree
            return False
        
        if self.rank[s1] > self.rank[s2]: # the tree including u is taller
            self.vertices[s1] += self.vertices[s2] # update the size of the bigger tree
            self.vertices[s2] = s1
        else: # the tree including v is taller
            self.vertices[s2] += self.vertices[s1] # update the size of the bigger tree
            self.vertices[s1] = s2
            if self.rank[s1] == self.rank[s2]:
                self.rank[s2] += 1
        return True
        
    def is_connected(self, u, v):
        return self.find(u) == self.find(v)
    
    def size(self, v):
        return -self.vertices[self.find(v)]

N, M, K = map(int, input().split())
uf_fr = UnionFind(N)
n_friends = [0] * N
for _ in range(M):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    n_friends[a] += 1
    n_friends[b] += 1
    uf_fr.union(a, b)
ans = [uf_fr.size(i) - 1 - n_friends[i] for i in range(N)]
for _ in range(K):
    a, b = map(int, input().split())
    a -= 1; b -= 1
    if uf_fr.is_connected(a, b):
        ans[a] -= 1; ans[b] -= 1
print(*ans)

Measured memory_bytes: 11820
import math
n=int(input())
p=[int(c) for c in input().split()]
q=[int(c) for c in input().split()]

l=0
num=list(range(1,n+1))
for i in range(n):
  l+=(num.index(p[i]))*(math.factorial(n-i-1))
  num.remove(p[i])
  
a=l+1

num=list(range(1,n+1))
r=0
for i in range(n):
  r+=(num.index(q[i]))*(math.factorial(n-i-1))
  num.remove(q[i])
  
b=r+1

print(str(abs(a-b)))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B;
  cin>>A>>B;
  bool nazo =false;
  int d=A*B;
  for(int i=1;i<4;i++){
  	if((d*i)%2 == 1){
    nazo=true;
    }
  }
  if(nazo){
  cout<<"Yes";
  }
  else{
  cout<<"No";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e3 + 10;
const int INF = 0x3f3f3f3f;
vector<int>G[maxn];
int n, k;
bool vis[maxn];
int dis[maxn], u[maxn], v[maxn];
int BFS(int u1, int u2, int t)
{
    queue<int>q;
    memset(vis, 0, sizeof(vis));
    memset(dis, INF, sizeof(dis));
    q.push(u1), vis[u1] = 1, dis[u1] = 0;
    if(t == 2)q.push(u2), vis[u2] = 1, dis[u2] = 0;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(int i = 0; i < G[u].size(); i++)
        {
            int v = G[u][i];
            if(vis[v])continue;
            vis[v] = 1;
            dis[v] = dis[u] + 1;
            q.push(v);
        }
    }
    int ans = 0;
    for(int i = 1; i <= n; i++)if(dis[i] > k / 2)ans++;
    return ans;
}
int main()
{
    cin >> n >> k;
    for(int i = 1; i < n; i++)
    {
        cin >> u[i] >> v[i];
        G[u[i]].push_back(v[i]);
        G[v[i]].push_back(u[i]);
    }
    int ans = n;
    if(k & 1)//直径长度为奇数，枚举每条边，离这条边的两个顶点距离在k/2以内的点均符合要求
    {
        for(int i = 1; i < n; i++)
            ans = min(ans, BFS(u[i], v[i], 2));
    }
    else
    {
        for(int i = 1; i <= n; i++)
            ans = min(ans, BFS(i, 0, 1));
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void) {
	int n, d, x, a[100], ans = 0;
	scanf("%d %d", &n, &d);
	scanf("%d", &x);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	for (int i = 0; i < n; i++) {
		ans += (d + a[i] - 1) / a[i];
	}
	printf("%d\n", ans + x);
}


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

class Program
{

    bool[] visit;
    int[] c;
    bool[] d;
    new Dictionary<int, int>[] g;
    void Run()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int m = sc.NextInt();
        g = new Dictionary<int, int>[n];
        for (int i = 0; i < n; i++) g[i] = new Dictionary<int, int>();
        for (int i = 0; i < m; i++)
        {
            int l = sc.NextInt() - 1;
            int r = sc.NextInt() - 1;
            int d = sc.NextInt();
            g[l].Add(r, d);
            g[r].Add(l, -d);
        }

        visit = new bool[n];
        c = new int[n];
        d = new bool[n];

        for (int i = 0; i < n; i++)
        {
            if (visit[i]) continue;
            if (!Search(i))
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }

    bool Search(int init)
    {
        c[init] = 0;
        var q = new Queue<int>();
        q.Enqueue(init);

        while (q.Count > 0)
        {
            int v = q.Dequeue();
            if (visit[v]) continue;
            visit[v] = true;
            foreach (var node in g[v])
            {
                if (d[node.Key])
                {
                    if (c[node.Key] - c[v] != node.Value) return false;
                }
                else
                {
                    c[node.Key] = c[v] + node.Value;
                    d[node.Key] = true;
                }
                q.Enqueue(node.Key);
            }
        }
        return true;
    }

    static void Main(string[] args)
    {
        new Program().Run();
    }

    static long Gcd(long a, long b)
    {
        if (a < b) return Gcd(b, a);
        if (b == 0) return a;
        return Gcd(b, a % b);
    }
}

class Scanner
{
    int index = -1;
    string[] buf;

    public Scanner()
    {
    }

    public int NextInt()
    {
        CheckNext();
        return int.Parse(buf[index++]);
    }

    public long NextLong()
    {
        CheckNext();
        return long.Parse(buf[index++]);
    }

    public double NextDouble()
    {
        CheckNext();
        return double.Parse(buf[index++]);
    }

    public string NextString()
    {
        CheckNext();
        return buf[index++];
    }

    private void CheckNext()
    {
        if (index >= 0 && index < buf.Length) return;

        buf = Console.ReadLine().Split(' ');
        index = 0;
    }
}



Measured memory_bytes: 53336
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(long long x){
  char f[20];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int N;
int M;
int main(){
  long long res=0;
  rd(N);
  rd(M);
  if(N > M){
    swap(N, M);
  }
  if(N==1){
    if(M==1){
      res = 1;
    }
    else{
      res = M - 2;
    }
  }
  else{
    res = (long long)(N-2) * (M-2);
  }
  wt_L(res);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// int N, M;
// {
//   ll res = 0;
//   rd(N,M);
//   if(N > M) swap(N, M);
// 
//   if(N==1){
//     if(M==1) res = 1;
//     else     res = M - 2;
//   } else {
//     res = (ll)(N-2) * (M-2);
//   }
// 
//   wt(res);
// }


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

int n, k, a[1000];

int main()
{
    cin >> n >> k;
    rep(i, n) cin >> a[i];
    int sum = 0;
    rep(i, n) sum += a[i];

    vector<int> g(0);
    for(int i = 1; i * i <= sum; i++)
    {
        if(sum % i == 0)
        {
            g.emplace_back(i);
            g.emplace_back(sum / i);
        }
    }
    sort(g.begin(), g.end(), greater<int>());

    int res = 0;
    for(auto x : g)
    {
        int b[n];
        rep(i, n) b[i] = a[i] % x;
        sort(b, b + n, greater<int>());
        int sum = 0;
        rep(i, n) sum += b[i];
        int tmp = 0;
        rep(i, sum / x) tmp += b[i];
        sum -= tmp;
        if(sum <= k)
        {
            cout << x << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi acos(-1.0)
#define pb push_back
#define vi vector<int>
#define mapii map<int , int>
#define mapci map<char, int>
#define mapsi map<string,int>
#define FOR(i,n) for(int i = 0;i<n;i++)
#define CP(n) cout<<"Case "<<n<<": "
#define fr freopen("input.txt","r",stdin)
#define fw freopen("output.txt","w",stdout)
#define MAX 1000007
#define all(x)(x.begin(),x.end())
#define debug(x,c) cout<<x<<": "<<c<<" ";
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
int main()
{
	int n,x,t;
	cin>>n>>x>>t;
	cout<<(n/x + ((n%x)?1:0))*t<<endl;
	return 0;
}


Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
# define N 20
#define endl "\n"
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
    IO;
    int sh, sm, eh, em, k;
    cin>>sh>>sm>>eh>>em>>k;

    int t = eh*60+em-sh*60-sm-k;

    cout<<t<<endl;
}

Measured memory_bytes: 3624
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: usize = scan(tokens);
    let x: usize = scan(tokens);
    if k * 500 >= x {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 100000;
vector<int> G[N];
int n,k;

int sz[N],dp[N],ed[N];
int dfs(int x, int p)
{
    int ret = 0;

    sz[x] = 1;
    for(int nx:G[x])if(nx!=p)
    {
        ret = max(ret,dfs(nx,x));
        sz[x] += sz[nx];
    }
    if(sz[x]==1) dp[x] = -1;

    int ct = 0;
    for(int nx:G[x])if(nx!=p)
    {
        dp[x] = max(dp[x],dp[nx]);
        ed[x] = max(ed[x],ed[nx]);
        ct += (sz[nx]>=k);
    }
    ed[x] = max(ed[x],ct);

    vector<int> gain;
    for(int nx:G[x])if(nx!=p)
    {
        int tmp = ct - (sz[nx]>=k);
        dp[x] = max(dp[x],ed[nx]+tmp);
        ed[x] = max(ed[x],ed[nx]+tmp);

        gain.pb(ed[nx]-(sz[nx]>=k));
    }

    sort(all(gain),greater<int>());
    if(gain.size()>=2) dp[x] = max(dp[x],ct+gain[0]+gain[1]);

    ret = max(ret,dp[x]+(n-sz[x]>=k));
    return ret;
}

int main()
{
    cin >>n >>k;
    rep(i,n-1)
    {
        int u,v;
        cin >>u >>v;
        --u; --v;
        G[u].pb(v);
        G[v].pb(u);
    }

    cout << dfs(0,-1) << endl;
    return 0;
}

Measured memory_bytes: 18880
#include <iostream>
#include <stdio.h>
using namespace std;
int main() {
    int a,b;
    int min,max;
    string s;

    cin >> a >> b;
    if(a > b){
        min = b;
        max = a;
    }
    else{
        min = a;
        max = b;
    } 

    for(int i=0;i<max;i++){
        printf("%d",min);
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 256