akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

class CombinationCalculator {
    using ull = unsigned long long;
public:
    ull mod;
    std::vector<ull> fact;
    std::vector<ull> inv_fact;
    std::vector<ull> inv;

    /**
     *  組み合わせの数を求めるクラス
     *  @n_max: $ {}_n C_r $ における $ {}_n $ の最大値
     *  @mod:   組み合わせの数に対して取るMODの値
     */
    explicit CombinationCalculator(const ull& n_max, const ull& mod = (int)1e9 + 7):
        mod((mod != 0) ? mod : std::numeric_limits<uint>::max()),
        fact(n_max + 1, 0), inv_fact(n_max + 1, 0), inv(n_max + 1, 0) {
        std::fill(fact.begin(), fact.begin() + 2, 1);
        std::fill(inv_fact.begin(), inv_fact.begin() + 2, 1);
        std::fill(inv.begin(), inv.begin() + 2, 1);
        for(ull i = 2; i <= n_max; i++) {
            fact[i]     = (fact[i - 1] * i) % mod;
            inv[i]      = mod - inv[mod % i] * (mod / i) % mod;
            inv_fact[i] = inv_fact[i - 1] * inv[i] % mod;
        }
    }

    /**
     *  $ {}_n C_r $ を求める
     *  @Return: $ {}_n C_r $
     */
    ull run(const ull& n, const ull& r) const {
        return (n < r) ? 0 : fact[n] * (inv_fact[r] * inv_fact[n - r] % mod) % mod;
    }
};

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

    ll N, M;
    std::cin >> N >> M;

    CombinationCalculator c(max(N, M));

    if(1 < abs(N - M)) {
        std::cout << 0 << std::endl;
    }
    else {
        std::cout << (((c.fact[N] * c.fact[M]) % MOD) * ((N == M) ? 2 : 1)) % MOD << std::endl;
    }

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,x,n) for(ll i=x;i<n;i++) 
#define sort(v) sort(v.begin(),v.end());
const ll mod = 1E9+7;

int main()
{
   ll n,sum = 0;
   cin>>n;
   vector<ll> v(n);;
   map<ll,ll> m;
   loop(i,0,n){
      cin>>v[i];
      m[v[i]]++;
      sum+=v[i];
   }
   ll q;
   cin>>q;
   while(q--){
      ll x,y;
      cin>>x>>y;
      sum = sum - x*m[x] + m[x]*y;
      m[y] += m[x];
      m[x] = 0;
      cout<<sum<<endl;
   }
  
}

Measured memory_bytes: 9956
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

ll C, D;

ll f(ll x){
    ll res = x/C + x/D;
    return x- (res - x / lcm(C,D));
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll A, B; cin >> A >> B >> C >> D;
    cout << f(B) - f(A-1) << endstr;
    return 0;
}


Measured memory_bytes: 256
// Author: Jashan Bansal
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second	
#define mp make_pair
#define int long long
#define ll long long
#define pii pair<int,int>
#define all(arr) arr.begin(), arr.end()
#define sz(arr) ((long long)arr.size())
// const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
#define log1(x) cout << x << '\n'
#define log2(x,y) cout << x << " " << y <<'\n'
#define log3(x,y,z) cout << x <<" " << y <<" " << z << '\n'
#define logarr(arr,n) for(int __=0; __ < n; __++)	cout << arr[__] << " "; cout << '\n'

int powm(int a, int b) {
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}

const int mxN = 100005;
vector<int> adj[mxN];
int dp[mxN];
bool vis[mxN];

int dfs(int n){
    vis[n] = true;

    for(auto x: adj[n]){
        if(!vis[x]){
            int res = dfs(x)+1;
            dp[n] = max(dp[n], res);
        }
        else{
            int res = dp[x]+1;
            dp[n] = max(dp[n], res);   
        }
    }
    return dp[n];
}

void solve(){
    int n,m; cin >> n >> m;
    for(int i=0; i<m; i++){
        int x,y; 
        cin >> x >> y;
        adj[x].push_back(y);
    }

    int ans = INT_MIN;

    for(int i=1; i<=n; i++){
        if(!vis[i]){
            int res = dfs(i);
            ans = max(ans, res);
        }
    }
    cout << ans << endl;
}

signed main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
	return 0;
}	


Measured memory_bytes: 7808
#include <cstdio>
#include <cmath>
#include <iostream>
using namespace std;

int mod_inv(int x, int m) {
    long long a = 1, b = 0, c = 0, d = 1, p = x, q = m;
    while (q != 0) {
        long long c0 = c, d0 = d, r = p / q;
        c = (a - c * r) % m;
        d = (b - d * r) % x;
        a = c0; b = d0;
        int t = p - r * q; p = q; q = t;
    }
    return (a + m) % m;
}

int mod_pow(int x, int e, int m) {
    long long ans = 1, p = x % m;
    while (e > 0) {
        if (e % 2 != 0) ans = (ans * p) % m;
        p = (p * p) % m;
        e >>= 1;
    }
    return ans;
}

int fact[1000001], finv[1000001];

int main() {
    int n, a, b, c, d; cin >> n >> a >> b >> c >> d;
    const int M = (int)1e9 + 7;
    fact[0] = 1;
    finv[0] = 1;
    for (int i = 1; i <= n*n; i++) {
        fact[i] = ((long long)fact[i-1] * i) % M;
        finv[i] = mod_inv(fact[i], M);
    }
    long long dp[1001][1000] = {};
    dp[0][a] = 1;
    for (int m = c*a; m <= min(n, d*a); m += a)
        dp[m][a] = (long long)fact[m] * finv[m/a] % M * mod_pow(finv[a], m/a, M) % M;
    for (int k = a+1; k <= b; k++) {
        dp[0][k] = 1;
        for (int m = 1; m <= n; m++) {
            dp[m][k] = dp[m][k-1];
            for (int t = m - c*k; t >= max(0, m - d*k); t -= k) {
                dp[m][k] += dp[t][k-1] * fact[m] % M * finv[t] % M * finv[(m-t)/k] % M * mod_pow(finv[k], (m-t)/k, M) % M;
            }
            dp[m][k] %= M;
        }
    }
    cout << (dp[n][b] + M) % M << endl;
}


Measured memory_bytes: 15872
import collections
n, c = int(input()), collections.Counter(sorted(list(map(int,input().split()))))
ck, cv, match, ans = list(c.keys()), list(c.values()), [], 0
for i in range(len(c)):
    if cv[i] >= 2:
        match.append([ck[i],cv[i]])
match.sort(key=lambda x:x[0])
ans = match[-1][0]**2 if len(match) >= 1 and match[-1][1] >= 4 else match[-1][0]*match[-2][0] if len(match) >= 2 else 0
print(ans)

Measured memory_bytes: 18720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define all(x) x.begin(),x.end()
#define FIO ios_base::sync_with_stdio(false), cin.tie(NULL);
#define N
#define PI acos(-1)
int main(){
	FIO;
    int a,b,h,m; cin >> a >> b >> h >> m;
    int t = 60*h + m;
    ld a1 = 2.0*PI*t/720, a2 = 2.0*PI*t/60;
    ld ans = sqrt(a*a+b*b-2.0*a*b*cos(a1-a2));
    cout << fixed << setprecision(9) << ans << endl;
	return 0;
}

Measured memory_bytes: 4132
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using boost::multiprecision::cpp_int;
using namespace std;

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

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

typedef long long ll;
typedef pair<ll, ll> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  long double r;
  cin >> r;
  cout << setprecision(15);
  cout << 2 * r * 3.1415 << endl;
}


Measured memory_bytes: 3812
#include <iostream>
using namespace std;
int main(){
    int N,Y;
    cin >> N >> Y;
    for(int i = 0;i<=N;i++){
        for(int j = 0;j<=N-i;j++){
            int k = N - i - j ;
                if(i*10000+j*5000+k*1000==Y){
                    cout << i <<" "<< j << " "<< k << endl;
                    return 0;
                }
        }
    }
    cout <<"-1 -1 -1"<<endl;
    return 0;
}

Measured memory_bytes: 256
x, y = map(int, input().split())
d = {1:1, 3:1, 5:1, 7:1, 8:1, 10:1, 12:1, 4:2, 6:2, 9:2, 11:2, 2:3}
print("Yes" if d[x] == d[y] else "No")  


Measured memory_bytes: 2940
using System;

// 構造化プログラミング

public class ITP1_5_D
{
    public static void Main(string[] args)
    {
        //var exStdIn = new System.IO.StreamReader( "input.txt" );
        //System.Console.SetIn( exStdIn );

        int n = int.Parse(Console.ReadLine());
        Solve(n);
    }

    private static void Solve(int n)
    {
        for (int i = 1; i <= n; i++)
        {
            int x = i;
            if (x % 3 == 0)
            {
               Console.Write($" {i}");
               continue;
            }

            while (true)
            {
                if (x % 10 == 3)
                {
                    Console.Write($" {i}");
                    break;
                }
                x /= 10;
                if (x == 0)
                {
                    break;
                }
            }
        }
        Console.WriteLine();
    }
}



Measured memory_bytes: 17916
#include <iostream>
#include <algorithm>
#include <queue>
#define MAX_V 101
#define INF 10000000
using namespace std;

bool edge[MAX_V][MAX_V];
int dist[MAX_V];

void bfs(int start, int n) {
  queue<int> que;
  que.push(start);
  dist[start] = 0;
  int current;
  while (!que.empty()) {
    current = que.front();
    que.pop();
    for (int i = 1; i <= n; i++) {
      if (edge[current][i] && dist[i] == INF) {
	dist[i] = dist[current] + 1;
	que.push(i);
      }
    }
  }
}

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

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      edge[i][j] = false;
    }
  }
  for (int j = 0; j < n; j++) {
    int u, k;
    cin >> u >> k;
    for (int i = 0; i < k; i++) {
      int v;
      cin >> v;
      edge[u][v] = true;
    }
  }

  for (int i = 1; i <= n; i++) {
    dist[i] = INF;
  }

  bfs(1, n);

  for (int i = 1; i <= n; i++) {
    cout << i << ' ';
    if (dist[i] == INF) cout << -1 << endl;
    else cout << dist[i] << endl;
  }
}

Measured memory_bytes: 3076
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
 
using namespace std;
 
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
 
const int INF=1<<29;
const double EPS=1e-9;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int dp[45] = {0};
int fib(int n) {
	if (dp[n] != 0) return dp[n];
	if (n == 0 || n == 1) return 1;
	return dp[n] = fib(n - 1) + fib(n - 2);
}

int main(int argc, char const *argv[]) {
	int n;
	cin >> n;
	int ans = fib(n);
	cout << ans << endl;
	return 0;
}

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

int main() {
  int A, B, i, count=0;
  cin >> A >> B;
  B++;
  for (int i = A; i<B; i++){
    if((i%10==i/10000) && ((i/10) % 10)== ((i/1000)%10)){
      count++;
    }
  }
  cout << count << endl;
}

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

using namespace std;

typedef long long ll;

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

  sort(vs.begin(), vs.end());

  vector<ll> ans;
  
  for (int i = n - 1; i > 0; i--)
  {
	if (vs[i] == vs[i - 1])
	{
	  ans.push_back(vs[i]);
	  i--;
	}
	if (ans.size() == 2) break;
  }
  if (ans.size() == 2)
  {
	cout << ans[0] * ans[1] << endl;
  }
  else
  {
	cout << 0 << endl;
  }
}


Measured memory_bytes: 1024
#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;
typedef vector<int> vi;

int main(){
  int n,k;
  cin >> n >> k;
  vi a(n);
  rep(i,n) cin >> a[i];
  sort(a.begin(),a.end());
  
  int g=gcd(a[0],a[1]);
  for(int i=2;i<n;i++) g=gcd(g,a[i]);
  
  string ans="IMPOSSIBLE";
  if(k<=a[n-1] and k%g==0) ans="POSSIBLE";
  cout << ans;
  return 0;
}

Measured memory_bytes: 3676
/*//////////////////////////////////////*/
/*/  NULLCT$ (｀･ω･´) <<"Be accept!!"  /*/
/*//////////////////////////////////////*/
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(counter, limit) for (int counter = 0; counter < limit; counter++)
typedef long long ll; using namespace std;
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
bool primenum(int a) { if (a == 1) { return false; }if (a == 2) { return true; }if (a % 2 == 0) { return false; }for (int i = 3; i < sqrt(a) + 1; i += 2) { if (a != i) { if (a % i == 0) { return false; } } }return true; }
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

  int n,m;
  cin>>n>>m;
  int sum=0;
  vector<int> a(n);
  rep(i,n){
    cin>>a[i];
    sum+=a[i];
  }
  int ans=0;
  for(int i=0;i < n;i++){
    if(!(a[i] < sum*(1.0/(4.0*m)))){
      ans++;
    }
  }

  if(ans >= m){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }

return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using static System.Math;

class P
{
    static void Main()
    {
        int[] nzw = Console.ReadLine().Split().Select(int.Parse).ToArray();
        int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if(a.Length != 1) Console.WriteLine(Max(Abs(nzw[2] - a.Last()), Abs(a[a.Length - 2] - a[a.Length - 1])));
        else Console.WriteLine(Abs(nzw[2] - a.Last()));
    }
}

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

int dx4[] = {0, 0, +1, -1};
int dy4[] = {+1, -1, 0, 0};
const int mx=1000;
 
char ch[mx][mx];
int visit[mx][mx],dis[mx][mx];
int n,m;
 
void bfs(){
  queue<pair<int,int>>q;
  for(int i=0;i<n;++i){
      for(int j=0;j<m;++j){
          if(ch[i][j]=='#'){
              q.push(make_pair(i,j));
              visit[i][j]=1;
          }
      }
  }
  while(!q.empty()){
    pair<int,int> p=q.front();
    q.pop();
    for(int i=0;i<4;++i){
      int u=p.first+dx4[i];
      int v=p.second+dy4[i];
      if(u>=0 && u<n && v>=0 && v<m && ch[u][v]=='.' && visit[u][v]==0){
        dis[u][v]=dis[p.first][p.second]+1;
        visit[u][v]=1;
        q.push(make_pair(u,v));
      }
    }
  }
}

int main(){
    cin>>n>>m;
    for(int i=0;i<n;++i){
        for(int j=0;j<m;++j){
            cin>>ch[i][j];
            visit[i][j]=0;
            dis[i][j]=0;
        }
    }
    bfs();
    int ans=0;
    for(int i=0;i<n;++i)for(int j=0;j<m;++j)if(ans<dis[i][j])ans=dis[i][j];
    cout<<ans<<endl;
}

Measured memory_bytes: 17168
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}
fn main() {
    input!{
        n: usize,
    }
    println!("{}",
        (1..=n).into_iter().filter(|i| !(i % 3 == 0 || i % 5 == 0)).sum::<usize>()
    );
}

Measured memory_bytes: 2128
<?php
  $n = fgets(STDIN);
  $m = [];
  for($i=1; $i<10; $i++){
    for($j=1; $j<10; $j++){
    	$m[] = $i*$j;
    }
  }
  if(in_array($n,$m)){
    echo "Yes\n";
  } else {
    echo "No\n";
  }
?>


Measured memory_bytes: 4984
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <cstdio>
#include <numeric>
#include <iomanip>

using namespace std;

using ll = long long;

int main()
{
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll num = 0;
    while(A >= B)
    {
        B = B*2;
        num++;
    }
    while(B >= C)
    {
        C = C*2;
        num++;
    }

    cout << (num <= K ? "Yes" : "No" ) << endl; 
    
    return 0;
}

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

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

using namespace std;

typedef long long ll;

int main(){
	int n,nc;
	cin >> n >> nc;
	int d[nc][nc];
	for(int i = 0; i < nc; i++){
		for(int j = 0; j < nc; j++)cin >> d[i][j];
	}
	int c[3][nc];
	fill(c[0],c[3],0);
	for(int i = 0; i < n; i++){
		int col;
		for(int j = 0; j < n; j++){
			cin >> col;
			c[(i+j)%3][col-1]++;
		}
	}
	ll ans = INF;
	for(int i = 0; i < nc; i++){
		ll pre=0;
		for(int j = 0; j < nc; j++)pre+=d[j][i]*c[0][j];
		for(int j = 0; j < nc; j++){
			if(i == j)continue;
			ll pre1=0;
			for(int k = 0; k < nc; k++)pre1+=d[k][j]*c[1][k];
			for(int k = 0; k < nc; k++){
				if(k == i || k == j)continue;
				ll pre2=0;
				for(int l = 0; l < nc; l++)pre2+=d[l][k]*c[2][l];
				ans = min(ans, pre+pre1+pre2);
			}
		}
	}
	cout << ans << endl;			
    return 0;
}

Measured memory_bytes: 256
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
#import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase

#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()

show_flg=False
#show_flg=True

s=input()
f=list(map(int,list(s)))
show(s,f)

for i in range(2**3):
    t=s[0]
    for j in range(3):
        if i>>j&1:
            t+='+'+s[j+1]
        else:
            t+='-'+s[j+1]
    show(eval(t),t)
    if eval(t)==7:
        print(t+'=7')
        exit()




Measured memory_bytes: 38684
#include <iostream>
#include <vector>

using namespace std;
const int MAXN = 51;

int n, m;
bool visited[MAXN];
vector<int> graph[MAXN];
int a[MAXN], b[MAXN];

void dfs(int cur, int removed) {
  visited[cur] = true;
  for (int i=0;i<graph[cur].size();i++) {
    int next = graph[cur][i];
    if (!visited[next] && !(next == a[removed] && cur == b[removed]) && !(next == b[removed] && cur == a[removed])) {
      dfs(next, removed);
    }
  }
}


bool check(int x) {
  for (int i=0;i<MAXN;i++) {
    visited[i] = false;
  }
  dfs(0, x);
  for (int i=0;i<n;i++) {
    if (!visited[i]) {
      return true;
    }
  }
  return false;
}

void solve() {
  int cnt = 0;
  for (int i=0;i<m;i++) {
    if (check(i)) {
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main() {
  cin >> n >> m;
  for (int i=0;i<m;i++) {
    cin >> a[i] >> b[i];
    a[i]--;b[i]--;
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }
  solve();
}


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

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string a,b;
    cin >> a >> b;
    int x = stoi(a+b);
    for(int i=1; i <=1000; ++i){
        if( i*i == x){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cmath>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define rep1(i,n) for(int i=1;i<=(n);++i)
#define all(c) (c).begin(),(c).end()
#define fs first
#define sc second
#define pb push_back
#define show(x) cout << #x << " " << x << endl
void renew(string& x,string y){
	if(x.size()<y.size()){
		x=y;
		return;
	}else if(x.size()>y.size()){
		return;
	}else{
		if(x<y) x=y;
	}
}
int main(){
	while(true){
		int W,H;
		cin>>W>>H;
		if(H==0) break;
		string s[70];
		rep(i,H) cin>>s[i];
		string dp[70][70];
		rep(i,H) rep(j,W){
			if(!isdigit(s[i][j])) continue;
			string val;
			if(s[i][j]!='0') val=string(1,s[i][j]);
			if(i!=0&&dp[i-1][j].size()>0) renew(val,dp[i-1][j]+s[i][j]);
			if(j!=0&&dp[i][j-1].size()>0) renew(val,dp[i][j-1]+s[i][j]);
			dp[i][j]=val;
		}
		string ans;
		rep(i,H) rep(j,W) renew(ans,dp[i][j]);
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1380
#include<iostream>
using namespace std;
static const int MAX=100;
static const int INFTY=(1<<21);
static const int WHITE=0;
static const int GRAY =1;
static const int BLACK=2;

int n,M[MAX][MAX];

int prim(){
  int u,minv;
  int d[MAX],p[MAX],color[MAX];

  for(int i=0;i<n;i++){
    d[i]=INFTY;
    p[i]=-1;
    color[i]=WHITE;
  }
  d[0]=0;

  while(1){
    minv=INFTY;
    u=-1;
    for(int i=0;i<n;i++){
      if(minv>d[i]&&color[i]!=BLACK){
	u=i;
	minv=d[i];
      }
    }
    if(u==-1) break;
    color[u]=BLACK;
    for(int v=0;v<n;v++){
      if(color[v]!=BLACK&&M[u][v]!=INFTY){
	if(d[v]>M[u][v]){
	  d[v]=M[u][v];
	  p[v]=u;
	  color[v]=GRAY;
	}
      }
    }
  }
      int sum=0;
      for(int i=0;i<n;i++){
	if(p[i]!=-1) sum+=M[i][p[i]];
      }
      return sum; 
}

int main(){
  cin >> n;

  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      int e; cin >> e;
      M[i][j]=(e==-1) ? INFTY:e;
    }
  }

  cout<<prim()<<endl;

  return 0;
}

Measured memory_bytes: 3104
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
//template<class T = ll> T in(){T x; cin >> x; return (x);}

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

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

  rep(i,N+1)rep(j,M+1){
    if(((i*j)+((N-i)*(M-j)))== K || ((i*j)+((N-i)*(M-j)))== ((N*M)-K)){
      cout <<"Yes" << endl;
      return 0;
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007
sys.setrecursionlimit(1000000)

#A
def A():
    n = I()
    if n == 1:
        print("Hello World")
    else:
        a,b = IR(2)
        print(a+b)
    return

#B
def B():
    n,t = LI()
    a = LIR(n)
    a.sort(key = lambda x:x[1])
    ans = float("inf")
    for i,j in a:
        if j > t:break
        ans = min(i,ans)
    if ans == float("inf"):
        print("TLE")
    else:
        print(ans)
    return

#C
def C():
    n = I()
    a = LIR(n)
    if n == 1:
        print(*a[0])
        quit()
    for cy in range(101):
        for cx in range(101):
            for i in range(n):
                x,y,h = a[i]
                if h > 0:
                    H = abs(x-cx)+abs(y-cy)+h
                    break
            f = True
            for i in range(n):
                x,y,h = a[i]
                if max(H-abs(x-cx)-abs(y-cy),0) != h:
                    f = False
                    break
            if f:
                print(cx,cy,H)
                quit()
#D
def D():
    def factorize(n):
        if n == 1:
            return [1]
        if n<4:
            return [1,n]
        l = [1,n]
        m = n
        z = 2
        while z**2 <= n:
            if m%z == 0:
                l.append(z)
                if m//z != z:
                    l.append(m//z)
            z += 1
        l = list(set(l))
        l.sort()
        return l

    n,m = LI()
    l = factorize(m)
    for i in l[::-1]:
        if n*i <= m:
            print(i)
            quit()

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == "__main__":
    B()


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

const ll INF = 1e18;

int main(){
  ll N, M, L; cin >> N >> M >> L;
  vector< vector<ll> > g(N, vector<ll>(N, INF) );
  vector< vector<ll> > bl(N, vector<ll>(N, INF) );
  
  for(ll i = 0; i < N; i++){
    g[i][i] = 0;
    bl[i][i] = 0;
  }
  
  for(ll i = 0; i < M; i++){
    ll A, B, C; cin >> A >> B >> C;
    A--; B--;
    g[A][B] = min(g[A][B], C);
    g[B][A] = min(g[B][A], C);
  }
  
  for(ll k = 0; k < N; k++){
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
      }
    }
  }
  
 for(ll i = 0; i < N; i++){
    for(ll j = 0; j < N; j++){
      if(i == j) continue;
      if(g[i][j] <= L) bl[i][j] = min(bl[i][j], 1LL);
    }
  }
  
  for(ll k = 0; k < N; k++){
    for(ll i = 0; i < N; i++){
      for(ll j = 0; j < N; j++){
        bl[i][j] = min(bl[i][j], bl[i][k] + bl[k][j]);
      }
    }
  }
  
  ll Q; cin >> Q;
  
  for(ll i = 0; i < Q; i++){
    ll s, t; cin >> s >> t;
    s--; t--;
    if(bl[t][s] < INF) cout << bl[t][s] - 1 << endl;
    else cout << -1 << endl;
  }
}

Measured memory_bytes: 1920
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int h, w, n;
  cin >> h >> w >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int idx = 0;
  vector<vector<int> > grid(h, vector<int>(w));
  rep(i, h) {
    if (i%2) {
      for (int j = w-1; j >= 0; j--) {
        grid[i][j] = idx+1;
        a[idx]--;
        if (!a[idx])
          idx++;
      }
    } else {
      rep(j, w) {
        grid[i][j] = idx+1;
        a[idx]--;
        if (!a[idx])
          idx++;
      }
    }
  }
  rep(i, h) rep(j, w)
    printf("%d%c", grid[i][j], j<w-1?' ':'\n');
  return 0;
}

Measured memory_bytes: 384
require 'pp'
require 'prime'

class Fractional
    attr_reader :memo

    def initialize
        @memo = {}
    end

    def calc(n)
        return @memo[n] if @memo[n]
 
        if n <= 1
            @memo[n] = 1
        else
            @memo[n] = (n * calc(n - 1))
        end
    end
end

def comb(n, r)
    return n if r == 0
    p = n.downto(n - r + 1).inject {|sum, x| sum *= x }
    r = 1.upto(r).inject {|sum, x| sum *= x }
    p / (r == 0 ? 1 : r)
end

n = gets.chomp!.to_i

frac = Fractional.new
x = frac.calc(n)

memo = {}
y = Prime.instance.prime_division(x).map {|e, n| [e, n] }

count = 0

# 3つにわける
z3 = y.group_by{|x, y| 
    if y >= 4
        1
    elsif y >= 2
        0
    else
        -1
    end
}.map {|x, y|
    [x, y.count]
}.to_h

if !((z3[1] || 0) >= 2 && (z3[0] || 0) >= 1)
    count += 0
else
    a = comb(z3[1], 2)
    b = comb(z3[0] + z3[1] - 2, 1)
    count += a * b
end

#puts count

# 2つにわける
z2_1 = y.group_by{|x, y|
    if y >= 24
        1
    elsif y >= 2
        0
    else
        -1
    end
}.map {|x,y| [x, y.count] }.to_h

if !((z2_1[1] || 0) >= 1 && (z2_1[0] || 0) >= 1)
    count += 0
else
    a = comb(z2_1[1], 1)
    b = comb(z2_1[0] + z2_1[1] - 1, 1)
    count += a * b
end

#puts count

# 2つにわける
z2_2 = y.group_by{|x, y|
    if y >= 14
        1
    elsif y >= 4
        0
    else
        -1
    end
}.map {|x,y| [x, y.count] }.to_h

if !((z2_2[1] || 0) >= 1 && (z2_2[0] || 0) >= 1)
    count += 0
else
    a = comb(z2_2[1], 1)
    b = comb(z2_2[0] + z2_2[1] - 1, 1)
    count += a * b
end

#puts count

# 1つにわける
z2_2 = y.group_by{|x, y|
    if y >= 74
        1
    else
        0
    end
}.map {|x,y| [x, y.count] }.to_h

if !((z2_2[1] || 0) >= 1)
    count += 0
else
    a = comb(z2_2[1], 1)
    count += a
end

puts count


Measured memory_bytes: 2428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static int modP = 1000000007;

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			int rn = (int)Math.sqrt(n);
			out.println(rn*rn);

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
#pragma GCC diagnostic ignored "-Wunused-result"
#define int long long
using namespace std;

#define fin(i,n) for (int i = 0; i < n; i++)
#define fin2(i,a,b) for (int i = a; i < b; i++)
#define ford(i,n) for (int i = n-1; i >= 0; i--)
#define ford2(i,a,b) for (int i = a-1; i >= b; i--)
 
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define mod 1000000007
#define PI 3.1415926535897932384626
#define EXP1 2.718281828459045
#define BIG 1000000000000000000

#define sl(n) scanf("%lld", &n)
#define sll(n,m) scanf("%lld %lld", &n, &m)
#define slll(n,m,k) scanf("%lld %lld %lld", &n, &m, &k)
#define sllll(n,m,k,o) scanf("%lld %lld %lld %lld", &n, &m, &k, &o)
#define sd(n) scanf("%lf", &n)
#define sdd(n,m) scanf("%lf %lf", &n, &m)
#define sddd(n,m,k) scanf("%lf %lf %lf", &n, &m, &k)
#define sc(c) scanf(" %c", &c)
#define ss(s) scanf("%s", s)
#define sal(t,n) fin(iz,n) { scanf("%lld", &t[iz]); }
#define sad(t,n) fin(iz,n) { scanf("%lf", &t[iz]); }
#define gl(t) scanf(" %[^\n]", t);

#define pc(n) printf("%c\n", n)
#define ps(s) printf("%s\n", s)
#define pss(s) printf("%s\n", s.c_str())
#define pl(n) printf("%lld\n", n)
#define pll(n,m) printf("%lld %lld\n", n, m)
#define plll(n,m,k) printf("%lld %lld %lld\n", n, m, k)
#define pd(n) printf("%lf\n", n)
#define pdd(n,m) printf("%lf %lf\n", n, m)
#define pal(t,n) fin(rz,n) { printf("%lld ", t[rz]); } printf("\n")
#define pad(t,n) fin(rz,n) { printf("%lf ", t[rz]); } printf("\n")

#define chmin(x, v) x = min(x, v)
#define chmax(x, v) x = max(x, v)
 
#define OK ps("OK")
#define OK1 ps("OK1")
#define OK2 ps("OK2")

#define ll int
#define vl vector<ll>
#define vvl vector<vl>
#define vvvl vector<vvl>

#define dll pair<ll, ll>
#define vdll vector<dll>
#define vvdll vector<vdll>

#define vb vector<bool>
#define vvb vector<vb>
#define vd vector<double>
#define vvd vector<vd>
#define vc vector<char>
#define vvc vector<vc>

#define all(v) v.begin(), v.end()
#define vlen(v) (int)(v.size())
#define pb push_back
#define fi first
#define se second

const int bm = 3005;
int a[bm];
int dp[2][bm][bm];

int gdp(int j, int g, int d)
{
    if (dp[max(0LL,j)][g][d] == BIG) {
        if (g == d) dp[max(0LL,j)][g][d] = j*a[g];
        else {
            int r1 = gdp(-j, g+1, d) + j*a[g];
            int r2 = gdp(-j, g, d-1) + j*a[d];
            dp[max(0LL,j)][g][d] = j*max(j*r1, j*r2);
        }
    }
    return dp[max(0LL,j)][g][d];
}

signed main()
{
    int n;
    sl(n);
    sal(a, n);
    fill_n(&dp[0][0][0], 2*bm*bm, BIG);
    pl(gdp(1, 0, n-1));
}

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

class DisjointSet {
public:
    vector<int> p;

    DisjointSet() {}
    DisjointSet(int size) {
        p.resize(size, 0);
        for (int i = 0; i < size; i++) {
            makeSet(i);
        }
    }

    void makeSet(int x) {
        p[x] = x;
    }

    int findset(int x) {
        if (p[x] != x) {
            p[x] = findset(p[x]);
        }
        return p[x];
    }

    bool same(int x, int y) {
        if (findset(x) == findset(y)) {
            return true;
        }
        else {
            return false;
        }
    }

    void unite(int x, int y) {
        link(findset(x), findset(y));
    }

    void link(int x, int y) {
        p[y] = x;
    }

};

class Edge {
public:
    int m_s, m_t, m_w;
    Edge() {}
    Edge(int s, int t, int w) {
        m_s = s;
        m_t = t;
        m_w = w;
    }
    bool operator < (const Edge &e) const {
        return m_w < e.m_w;
    }
};

vector<Edge> K;

int kruskal(int n, vector<Edge> edges) {
    int total_wgt = 0;
    sort(edges.begin(), edges.end());

    DisjointSet ds = DisjointSet(n + 1);

    for (int i = 0; i < edges.size(); i++) {
        Edge e = edges[i];
        if (ds.same(e.m_s, e.m_t) == false) {
            K.push_back(e);
            total_wgt += e.m_w;
            ds.unite(e.m_s, e.m_t);
        }
    }
    return total_wgt;
}

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

    vector<Edge> edges;
    for (int i = 0; i < m; i++) {
        int s, t, w;
        cin >> s >> t >> w;
        edges.push_back(Edge(s, t, w));
    }

    cout << kruskal(n, edges) << endl;

    return 0;
}



Measured memory_bytes: 5452
#include <bits/stdc++.h>
#define MAX (ll)(3e3 + 7)
#define INF (ll)(5e5 + 7)
#define MOD (ll)(1e9 + 7)

using namespace std;
using ll = long long;
using cd = complex<double>;

ll dp[MAX][MAX][4], ar[MAX][MAX];
pair<ll, ll> cr[2] = {{1, 0}, {0, 1}};
ll n, m, k;

bool ch (ll x, ll y) {
	return x >= 1 && y >= 1 && x <= n && y <= m;
}

int main () {
	cin >> n >> m >> k;
	for (ll i = 0; i < k; i++) {
		ll x, y;
		cin >> x >> y;
		cin >> ar[x][y];
	}
	for (ll i = 0; i <= n; i++) {
		for (ll j = 0; j <= m; j++) {
			for (ll k = 0; k < 4; k++) {
				ll vv = dp[i][j][k];
				dp[i + 1][j][1] = max (vv + ar[i + 1][j], dp[i + 1][j][1]);
				dp[i][j + 1][k] = max (vv, dp[i][j + 1][k]);
				if (k < 3) {
					dp[i][j + 1][k + 1] = max (dp[i][j + 1][k + 1], vv + ar[i][j + 1]);
				}
			}
		}
	}
	ll ma = 0;
	for (ll i = 0; i < 4; i++) {
		ma = max (dp[n][m][i], ma);
	}
	cout << ma << "\n";
}

Measured memory_bytes: 355984
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  int N;
  cin>>N;
  vector<int>b(N),t(N);
  for(int i=0;i<N;i++){
    cin>>b[i];
  }
  t=b;
  vector<int>ans;
  for(int i=0;i<N;i++){//N回まわす
     int s=t.size(); 
     for(int j=s-1;j>=0;j--){
       if(t[j]==j+1){
        ans.push_back(t[j]);
        t.erase(t.begin()+j);
        break;
       }
    }
  }
  reverse(ans.begin(),ans.end());
  if(t.empty()){
    for(int i=0;i<N;i++){
      cout<<ans[i]<<endl;
    }
  }
  else{cout<<-1<<endl;}
  return 0;  
}

Measured memory_bytes: 3600
X,Y,A,B,C = map(int,input().split())
p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
ans = sum(p[:X]) + sum(q[:Y])
x = X-1
y = Y-1
m = min(p[x],q[y])
n = 1
while len(r)>0 and r[0] > m:
    if n == 1:
        if p[x] > q[y]:
            ans += r[0] - q[y]
            y -= 1
        else:
            ans += r[0] - p[x]
            x -= 1
    else:
        ans += r[0] - m
        if x<0:
            y -= 1
        else:
            x -= 1
    r.pop(0)
    if y >= 0 and x >= 0:
        m = min(p[x],q[y])
    elif x >= 0 and y<0:
        m = p[x]
        n = 0
    elif y >= 0 and x<0:
        m = q[y]
        n = 0
    else:
        m = 10 ** 9 + 1
        n = 0
print(ans)

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

namespace AtCoder.ABC
{
	class QuestionA
	{
		public static void Main(string[] args)
		{
			var s = Console.ReadLine();

			var answer = "";

			for(int i = 0; i < s.Length; i++) {
				if(s[i] == 'A') {
					answer += "T";
				} else if(s[i] == 'T') {
					answer += "A";
				} else if (s[i] == 'C') {
					answer += "G";
				} else if (s[i] == 'G') {
					answer += "C";
				}
			}

			Console.WriteLine(answer);
		}
	}
}


Measured memory_bytes: 25696
#include<stdio.h>
 
int main()
{
  int t[4][3][10]={0};
  int b,f,r,v,i,j,k,n;
  scanf("%d",&n);
  for(i=0;i<n;i++){
  scanf("%d%d%d%d",&b,&f,&r,&v);
t[b-1][f-1][r-1]=t[b-1][f-1][r-1]+v;

      
    
  }
  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
	printf(" %d",t[i][j][k]);
      }
      printf("\n");
    }
    if(i!=3)printf("####################\n");
  }
  return 0;
}



Measured memory_bytes: 2112
import sys, math
n = int(input())
s = int(input())

def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n//b) + n % b

if s == n:
    print(n + 1)
    sys.exit()

sqrt_n = math.floor(math.sqrt(n))
for b in range(2, sqrt_n + 1):
    if f(b, n) == s:
        print(b)
        sys.exit()
for p in range(1, sqrt_n + 1):
    p_sum= sqrt_n + 1 - p
    b = int( (n -s)/p_sum ) + 1
    if b >= 2 and f(b, n) == s:
        print(b)
        sys.exit()
print('-1')

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  vector<bool> used(N);
  multiset<int> B;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    B.insert(A[i]);
  }
  int ans = 0;
  while (!B.empty()) {
    int M = *B.rbegin();
    B.erase(B.find(M));

    auto it = B.find((1 << ((int)log2(M)) + 1) - M);
    if (it != B.end()) {
      ans++;
      B.erase(it);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "YES" << endl
#define pyes cout << "Yes" << endl
#define POK cout << "OK" << endl
#define PNO cout << "NO" << endl
#define pno cout << "No" << endl
#define PNG cout << "NG" << endl
#define ret return 0

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  string s;
  cin >> s;
  int ssize = s.size();
  if (ssize % 2 != 0) {
    pno;
    ret;
  }
  rep(i, ssize / 2) {
    if (s[2 * i] != 'h' or s[2 * i + 1] != 'i') {
      pno;
      ret;
    }
  }
  pyes;
  ret;
}


Measured memory_bytes: 3660
#include <iostream>
#include <cstdlib>

using namespace std;

struct member {
    int n;
    int count;
} mem;

struct member med3(struct member x, struct member y, struct member z) {
    if (x.count < y.count) {
        if (y.count < z.count) {
            return y;
        } else if (z.count < x.count) {
            return x;
        } else {
            return z;
        }
    } else {
        if (z.count < y.count) {
            return y;
        } else if (x.count < z.count) {
            return x; 
        } else {
            return z;
        }
    }
}

void quick_sort(struct member *a, int left, int right)
{
    if (left < right) {
        int i = left, j = right;
        struct member tmp;
        struct member pivot = med3(a[i], a[i + (j - i) / 2], a[j]);
        while (1) {
            while (a[i].count < pivot.count) {
                i++;
            }
            while (pivot.count < a[j].count) {
                j--;
            }
            if (i >= j) { 
                break;
            }
            tmp = a[i]; a[i] = a[j]; a[j] = tmp;
            i++;
            j--;
        }
        quick_sort(a, left, i - 1);  /* 分割した左を再帰的にソート */
        quick_sort(a, j + 1, right); /* 分割した右を再帰的にソート */
    }
}


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

    struct member *a = new struct member[n + 1];
    for (int i = 1; i <= n; i++) {
        cin >> a[i].count;
        a[i].n = i;
    }

    quick_sort(a, 1, n);

    cout << a[1].n;
    for (int i = 2; i <= n; i++) {
        cout << " " << a[i].n;
    }
    cout << endl;
    
    return 0;
}


Measured memory_bytes: 1536