akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する

void solve(int n) {
    vector<int> w(n);
    rep(i, 0, n) cin >> w[i];
    vector<vector<int> > dp(n, vector<int>(n, 0));
    for (int i = 0; i + 1 < n; i++) {
        if (abs(w[i + 1] - w[i]) <= 1) {
            dp[i][i + 1] = 2;
        } else {
            dp[i][i + 1] = 0;
        }
    }
    for (int d = 2; d < n; d++) {
        for (int i = 0; i + d < n; i++) {
            int j = i + d;
            if (abs(w[j] - w[i]) <= 1 && dp[i + 1][j - 1] == j - i - 1) {
                dp[i][j] = j - i + 1;
            } else {
                for (int k = i; k < j; k++) {
                    dp[i][j] = max(dp[i][j], dp[i][k] + dp[k + 1][j]);
                }
            }

        }
    }
    cout << dp[0][n-1] << endl;
//    if (n % 2 == 0) {
//        cout << dp[0][n - 1] << endl;
//    } else {
//        int ans = max(dp[0][n-2],dp[1][n-1]);
//        cout << ans << endl;
//
//    }
//    for(int i = 0; i < n; i++){
//
//    }

}

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

    while (true) {
        int n;
        cin >> n;
        if (n == 0) break;
        solve(n);

    }


    return 0;
}



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

using namespace std;

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

int n, k;
vector<int> vec[500];

int main() {
    scanf("%d",&n);
    for (k=1;k*(k-1)/2<n;k++);
    if (k*(k-1)/2==n) {
        printf("Yes\n%d\n",k);
        int i, j, p = 1;
        for (i=0;i<k;i++) {
            for (j=i+1;j<k;j++) {
                vec[i].push_back(p);
                vec[j].push_back(p);
                p++;
            }
        }
        for (i=0;i<k;i++) {
            printf("%d ",vec[i].size());
            for (int &v : vec[i]) printf("%d ",v);
            printf("\n");
        }
    }
    else printf("No\n");

    return 0;
}


Measured memory_bytes: 2304
//Catchharsh
    #include<bits/stdc++.h>
    #define ll long long int 
    #define ld long double
    #define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define F first
    #define S second
    #define pb push_back
    #define endl '\n'
    const ll MOD = 1e9+7;
    const ll INF = 1011111111;
    const ll LLINF = 1000111000111000111LL;
    const ld EPS = 1e-10;
    const ld PI = 3.14159265358979323;
    using namespace std;
    ll power (int x,int n)
    {
        if(n==0)
        return 1;
        else if(n%2==0)
        return power((x*x),n/2);
        else
        return x*power((x*x),(n-1)/2); 
    }
    vector<ll> seve;
    void  seveprime()
    {
      int prime[1000000]={0};
      for(int i=2;i*i<1000000;i++)
       {
        if(prime[i]==0)
         {
      	  for(int j=i*2;j<=1000000;j+=i)
           prime[j]=1;
         }
       }
       for(int i=2;i<=1000000;i++)
       {
       	if(prime[i]==0)
       		seve.pb(i);
       }
    }
    int main()
    {   
         IOS;
         int n,m,i,j,k;
         cin>>n;
        // int dp[n]; 
         int dp1[n],dp2[n],dp3[n];
         int a[n],b[n],c[n];
         for(i=0;i<n;i++)
         	cin>>a[i]>>b[i]>>c[i];
         dp1[0]=a[0];dp2[0]=b[0];dp3[0]=c[0];
         for(i=1;i<n;i++)
         {
         	dp1[i]=a[i]+max(dp2[i-1],dp3[i-1]);
         	dp2[i]=b[i]+max(dp1[i-1],dp3[i-1]);
         	dp3[i]=c[i]+max(dp1[i-1],dp2[i-1]);
         }
         cout<<max({dp1[n-1],dp2[n-1],dp3[n-1]});
         
    }

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
template <typename T>
struct FenwickTree {  
  int n;
  vector<T> data;

  FenwickTree (int sz, T init = 0) {
    n = sz;
    data.assign(n + 1, init);
  }
  //1-indexed
  void add(int k, T x) {
    for (int i = k; i <= n; i += i & -i) data[i] += x; 
  }

  // [0, k + 1)
  T sum (int k) {
    T res = 0;
    for (int i = k; i > 0; i -= i & -i) res += data[i];
    return res;
  }
  // [l, r);
  T get (int l, int r) {
    T res = 0;
    return sum(r - 1) - sum(l - 1);
  }

  T lower_bound(T v) {
    if (v <= 0) return 0;
    T l = 0, r = 1;
    while (r < n) r <<= 1;
    for (; r > 0; r >>= 1) {
      if (l + r <= n && data[l + r] < v) {
        v -= data[l + r];
        l += r;
      }
    }
    return l + 1;
  }
};
int main() {
  int n, q;
  cin >> n >> q;
  FenwickTree<ll> bit(n);
  rep(i,n) {
    int a;
    cin >> a;
    bit.add(i + 1, a);
  }

  while (q--) {
    int f;
    cin >> f;
    if (f) {
      int l, r;
      cin >> l >> r;
      cout << bit.get(l + 1, r + 1) << "\n";
    } else {
      int p, x;
      cin >> p >> x;
      bit.add(p + 1, x);
    }
  }
  return 0; 
}


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

int main(){
    ll n, m;
    cin >> n >> m;
    priority_queue<ll> q;
    rep(i, n){
        ll a;
        cin >> a;
        q.push(a);
    }
    rep(i, m){
        ll a = q.top(); q.pop();
        a = (a/2)/1;
        q.push(a);
    }
    ll ans = 0;
    rep(i, n){
        ll a = q.top(); q.pop();
        ans += a;

    }
    cout << ans << endl;
}

Measured memory_bytes: 1400
def N():
    return int(input())
def L():
    return list(map(int,input().split()))
def NL(n):
    return [list(map(int,input().split())) for _ in range(n)]
import math
from queue import deque
n,x,y = L()
g = [[] for _ in range(n)]
for i in range(n):
    if (i == x-1):
        if (i == 0):
            g[i] = [1,y-1]
        elif (i == n-1):
            g[i] = [i-1,y-1]
        else:
            g[i] = [i-1,i+1,y-1]
    elif (i == y-1):
        if (i == 0):
            g[i] = [1,x-1]
        elif (i == n-1):
            g[i] = [i-1,x-1]
        else:
            g[i] = [i-1,i+1,x-1]
    else:
        if (i == 0):
            g[i] = [1]
        elif (i == n-1):
            g[i] = [i-1]
        else:
            g[i] = [i-1,i+1]
#print(g)
dis = [[0]*n for i in range(n)]
#print(dis)
ans = [0]*(n-1)
for i in range(n):
    q = deque()
    cnt = 1
    q.append(g[i])
    while q:
        d = []
        while q: 
            d += q.popleft()
        for j in d:
            if i != j and (dis[i][j] == 0 or dis[i][j] > cnt):
                dis[i][j] = cnt
                q.append(g[j])
                ans[cnt-1] += 1
        cnt += 1
for a in ans:
    print(int(a/2))


Measured memory_bytes: 108504
#include <iostream>

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
int arr[101];
ll dp[101][100001];

ll solve(int N,int K){
    if(K<0){
        return 0;
    }
    if(K==0){
        return 1;
    }
    if(N==1){
        if(K<=arr[0]){
            return 1;
        }
        else{
            return 0;
        }
    }
    if(dp[N][K]!=-1){
        return dp[N][K];
    }
    ll ways=(mod+solve(N,K-1)-solve(N-1,K-1-arr[N-1])+solve(N-1,K))%mod;
    dp[N][K]=ways;
    return ways%(mod);
}
int main(){
    int N,K;
    cin>>N>>K;
    memset(dp,-1,sizeof(dp));
    for(int i=0;i<N;i++){
        cin>>arr[i];
    }
    cout<<solve(N,K);
}






Measured memory_bytes: 83968
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;
    string s,t;

    cin >> n;
    cin >> s >> t;

    for(int i = 0;i < n;i++){
        cout << s[i] << t[i];
    }

    cout << endl;


    return 0;
}

Measured memory_bytes: 256
//Coded by Dy.
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using std :: cerr;
#define re register
typedef long long ll;
ll n;
int main() {
	scanf("%lld", &n);
	for(re ll i = (ll)sqrt(n); i >= 0; --i) {
		if(n % i == 0) {
			printf("%lld\n", (n / i - 1) + (i - 1));
			return 0;
		}
	}
}

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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
#define rep(i,n) for (int i=0; i < int(n); i++)


// 素集合データ構造
struct UnionFind
{
  // par[i]：データiが属する木の親の番号。i == par[i]のとき、データiは木の根ノードである
  vector<ll> par;
  // sizes[i]：根ノードiの木に含まれるデータの数。iが根ノードでない場合は無意味な値となる
  vector<ll> sizes;

  UnionFind(ll n) : par(n), sizes(n, 1) {
    // 最初は全てのデータiがグループiに存在するものとして初期化
    rep(i,n) par[i] = i;
  }

  // データxが属する木の根を得る
  ll find(ll x) {
    if (x == par[x]) return x;
    return par[x] = find(par[x]);  // 根を張り替えながら再帰的に根ノードを探す
  }

  // 2つのデータx, yが属する木をマージする
  void unite(ll x, ll y) {
    // データの根ノードを得る
    x = find(x);
    y = find(y);

    // 既に同じ木に属しているならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるように連結する
    par[y] = x;
    sizes[x] += sizes[y];
    // sizes[y] = 0;  // sizes[y]は無意味な値となるので0を入れておいてもよい
  }

  // 2つのデータx, yが属する木が同じならtrueを返す
  bool same(ll x, ll y) {
    return find(x) == find(y);
  }

  // データxが含まれる木の大きさを返す
  ll size(ll x) {
    return sizes[find(x)];
  }
};

// 頂点a, bをつなぐコストcostの（無向）辺
struct Edge
{
  ll a, b, cost;

  // コストの大小で順序定義
  bool operator<(const Edge& o) const {
    return cost < o.cost;
  }
};

// 頂点数と辺集合の組として定義したグラフ
struct Graph
{
  ll n;  // 頂点数
  vector<Edge> es;  // 辺集合

  // クラスカル法で無向最小全域木のコストの和を計算する
  // グラフが非連結のときは最小全域森のコストの和となる
  ll kruskal() {
    // コストが小さい順にソート
    sort(es.begin(), es.end());

    UnionFind uf(n);
    ll min_cost = 0;

    rep(ei, es.size()) {
      Edge& e = es[ei];
      if (!uf.same(e.a, e.b)) {
        // 辺を追加しても閉路ができないなら、その辺を採用する
        min_cost += e.cost;
        uf.unite(e.a, e.b);
      }
    }

    return min_cost;
  }
};

// 標準入力からグラフを読み込む
Graph input_graph(vector<pair<ll,ll> >x,vector<pair<ll,ll> >y) {
  Graph g;
  g.n=x.size();
  for(int i=1;i<x.size();i++){
    Edge e;
  e.a=x[i].S;
  e.b=x[i-1].S;
  e.cost=x[i].F-x[i-1].F;
    g.es.push_back(e);
  e.a=y[i].S;
  e.b=y[i-1].S;
  e.cost=y[i].F-y[i-1].F;
    g.es.push_back(e);
  }
  return g;
}

int main(){
  int n;cin>>n;
  vector<pair<ll,ll> >x(n);
  vector<pair<ll,ll> >y(n);
  for(int i=0;i<n;i++){
    cin>>x[i].F>>y[i].F;
    x[i].S=i;
    y[i].S=i;
  }
  sort(ALL(x));
  sort(ALL(y));
  Graph hoge = input_graph(x,y);
  cout<<hoge.kruskal()<<endl;
  return 0;
}


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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> svec(N);
    for (int i=0; i<N; i++) {
        cin >> svec.at(i);
    }

    sort(svec.begin(), svec.end());
    string ans;
    for (int i=0; i<N; i++) {
        ans += svec.at(i);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++){cin>>arr[i];}
    ll c=0,ans=0;
    for(ll i=1;i<n;i++)
    {
        if(arr[i]<=arr[i-1]){c++;}
        else if(arr[i]>arr[i-1]){c=0;}
        ans=max(ans,c);
    }
    cout<<ans;
    return 0;

}


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

string S;

int main()
{
	cin >> S;
	ll ans = 0;
	for (ll i = 0; i < (1ll << (S.size() - 1)); ++i) {
		string t;
		ll v = 0;
		for (ll j = 0, e = i; j < S.size(); ++j, e >>= 1) {
			t += S[j];
			if ((e & 1) || j == S.size() - 1) {
				v += stoll(t);
				t.clear();
			}
		}
		ans += v;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static int maxIndex(int[] array, boolean[] used) {
        int index = 0;
        int max = 0;
        for (int i = 0; i < array.length; i++) {
            if (!used[i] && max < array[i]) {
                index = i;
                max = array[i];
            }
        }
        return index;
    }

    public static void printScore(int[] array, boolean[] used) {
        int alice = 0;
        int bob = 0;
        boolean flag = true;
        int index = 0;
        for (int i = 0; i < array.length; i++) {
            index = maxIndex(array, used);
            used[index] = true;
            if (flag) {
                alice += array[index];
            } else {
                bob += array[index];
            }
            flag = !flag;
        }
        System.out.println(alice - bob);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] array = new int[N];
        for (int i = 0; i < N; i++) {
            array[i] = sc.nextInt();
        }
        boolean[] used = new boolean[N];
        printScore(array, used);
    }

}


Measured memory_bytes: 21716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

class ADuplexPrinting {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n; cin >> n;
      cout << (n+1)/2 << endl;
    }
};

signed main() {
  ADuplexPrinting solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

bool dbgflag = false;

struct edge {
  ll cost;
  ll to;
};

void dijkstra(int s, vector<ll>&d, vector<vector<edge>>&graph) {
  //for (int i = 0; i < d.size(); i++) d[i] = LLINF;
  priority_queue<pll, vector<pll>, greater<pll>> que;
  
  d[s] = 0;
  que.push(pll(0, s));

  while(!que.empty()) {
    pll p = que.top();
    que.pop();
    ll v = p.second;

    if (d[v] < p.first) continue;

    for (edge e: graph[v]) {
      if (d[e.to] <= d[v] + e.cost) continue;
      d[e.to] = d[v] + e.cost;
      que.push(pll(d[e.to], e.to));
    }
  }
  return;
}

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

  ll n, m;
  cin >> n >> m;
  
  vector<vector<edge>> roads(n);
  for (int i = 0; i < m; i++) {
    ll l, r, c;
    cin >> l >> r >> c;
    l--, r--;
    edge e;
    e.cost = c;
    e.to = r;
    roads[l].emplace_back(e);
  }
  for (int i = 1; i < n; i++) {
    edge e;
    e.cost = 0;
    e.to = i-1;
    roads[i].emplace_back(e);
  }

  vector<ll> dist(n, LLINF);

  dijkstra(0, dist, roads);

  cout << ((dist[n-1] == LLINF) ? -1 : dist[n-1]) << endl;
}


Measured memory_bytes: 9336
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 100000000

typedef  long long ll;

using namespace std;

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        a = a^b;
        b = a^b;
        a = a^b;
    }
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }
    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}



void solve(void){
    int n;
    cin >> n;
    int l[n];
    int m = -1;
    int sum = 0;
    rep(i,0,n){
        cin >> l[i];
        m = max(m,l[i]);
        sum += l[i];
    }
    if(sum-m > m) ys();
    else ns();
    
}

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

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

int main()
{
	int N; std::cin >> N;
	int sum = 0;
	std::vector<int> a(N);
	for(auto &x: a)
	{
		std::cin >> x;
		sum += x;
	}
	int X = sum/N + ((double)sum/N-sum/N>0.5 ? 1 : 0);
	int ans = 0;
	for(const auto &z: a) ans += (X-z)*(X-z);
	std::cout << ans << std::endl;
	return 0;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};

pub fn read<T: FromStr>() -> T {
  let stdin = stdin();
  let stdin = stdin.lock();
  let token: String = stdin
    .bytes()
    .map(|c| c.expect("failed to read char") as char)
    .skip_while(|c| c.is_whitespace())
    .take_while(|c| !c.is_whitespace())
    .collect();
  token.parse().ok().expect("failed to parse token")
}

fn main() {
  let mut meal = vec![];
  for _ in 0..5 {
    let a = read::<i32>();
    meal.push(a);
  }

  let mut max_res = 0;
  let mut ans = 0;
  for i in meal {
    max_res = max(max_res, (10 - i % 10) % 10);
    ans += i + (10 - i % 10) % 10;
  }

  println!("{}", ans - max_res);

}



Measured memory_bytes: 4352
#include "bits/stdc++.h"
using namespace std;
#include "atcoder/all"
using namespace atcoder;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)n; ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;



signed main(){
	int N, M;
	cin >> N >> M;
	vector<int>a(N), b(M);
	cin >> a >> b;
	auto c = convolution(a, b);
	REP(i,c.size())cout << c[i] << " \n"[i+1 == c.size()];
}

Measured memory_bytes: 27264
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	int AmodB = A % B;
	for (int i = 0; i < B; i++)
	{
		int imodB = i % B;
		if ((AmodB*imodB)%B==C)
		{
			cout << "YES";
			return 0;
		}
	}
	cout << "NO";
	return 0;
}


Measured memory_bytes: 256
A,B,C,D = map(int,input().split())

Takahashi = A
Aoki = C

while True:
    Aoki = Aoki - B
    if Aoki <= 0:
        break

    Takahashi = Takahashi - D
    if Takahashi <= 0:
        break

if Takahashi <= 0:
    print('No')
else:
    print('Yes')


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

int main(){
  string S;
  cin >> S;
  int ans;
  if(S[0]=='S'){
    if(S[1]=='S'){
      if(S[2]=='S'){
        //SSS
        ans=0;
      }else{
        //SSR
        ans=1;
      }
    }else{
      if(S[2]=='S'){
        //SRS
        ans=1;
      }else{
        //SRR
        ans=2;
      }
    }
  }else{
    if(S[1]=='S'){
      if(S[2]=='S'){
        //RSS
        ans=1;
      }else{
        //RSR
        ans=1;
      }
    }else{
      if(S[2]=='S'){
        //RRS
        ans=2;
      }else{
        //RRR
        ans=3;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();

		int[] a = new int[5];
		String march = "MARCH";
		for (int i = 0; i < n; i++) {
			String s = sc.next();
			int idx = march.indexOf(s.charAt(0));
			if (idx != -1)
				a[idx]++;
		}

		long ret = 0;
		for (int i = 0; i < 3; i++) {
			for (int j = i + 1; j < 4; j++) {
				long k2 = a[i] * a[j];
				for (int k = j + 1; k < 5; k++) {
					ret += k2 * a[k];
				}

			}
		}

		System.out.println(ret);
	}
}


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

int main(void)

{	
	int i;
	int lon;
	char w[150];
	int kaisu[26]={0},count=0;
	scanf("%s",w);
	
	lon=strlen(w);
	for(i=0;i<=lon-1;i++){
		if(w[i]=='a'){
			kaisu[0]++;
		} else if(w[i]=='b'){
			kaisu[1]++;
		} else if(w[i]=='c'){
			kaisu[2]++;
		} else if(w[i]=='d'){
			kaisu[3]++;
		} else if(w[i]=='e'){
			kaisu[4]++;
		} else if(w[i]=='f'){
			kaisu[5]++;
		} else if(w[i]=='g'){
			kaisu[6]++;
		} else if(w[i]=='h'){
			kaisu[7]++;
		} else if(w[i]=='i'){
			kaisu[8]++;
		} else if(w[i]=='j'){
			kaisu[9]++;
		} else if(w[i]=='k'){
			kaisu[10]++;
		} else if(w[i]=='l'){
			kaisu[11]++;
		} else if(w[i]=='m'){
			kaisu[12]++;
		} else if(w[i]=='n'){
			kaisu[13]++;
		}  else if(w[i]=='o'){
			kaisu[14]++;
		} else if(w[i]=='p'){
			kaisu[15]++;
		} else if(w[i]=='q'){
			kaisu[16]++;
		} else if(w[i]=='r'){
			kaisu[17]++;
		} else if(w[i]=='s'){
			kaisu[18]++;
		} else if(w[i]=='t'){
			kaisu[19]++;
		} else if(w[i]=='u'){
			kaisu[20]++;
		} else if(w[i]=='v'){
			kaisu[21]++;
		} else if(w[i]=='w'){
			kaisu[22]++;
		} else if(w[i]=='x'){
			kaisu[23]++;
		} else if(w[i]=='y'){
			kaisu[24]++;
		} else{
			kaisu[25]++;
		}
	}
	
	for(i=0;i<=25;i++){
		if(kaisu[i]%2!=0){
			count++;
			}
		}
	if(count==0){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())
a = list(map(int, input().split()))

a.sort()

def gcd(a, b): 
    while b: 
        a, b = b, a % b 
    return a 


if a[len(a)-1]<K:
    print("IMPOSSIBLE")
else:
    now = a[0]
    for i in range(len(a)-1):
        now = gcd(a[i+1], now)
    if K%now == 0:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")




Measured memory_bytes: 14224
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

n, m = map(int, input().split())
G = [[] for _ in range(n)]
for _ in range(m):
  l, r, d = map(int, input().split())
  l -= 1
  r -= 1
  G[l].append((r, d))
  G[r].append((l, -d))
dist = [float("inf")]*n
def dfs(v):
  for nv, d in G[v]:
    if dist[nv] == float("inf"):
      dist[nv] = dist[v]+d
      if not dfs(nv):
        return False
    else:
      if dist[nv] != dist[v]+d:
        return False
  return True
for i in range(n):
  if dist[i] == float("inf"):
    dist[i] = 0
    if not dfs(i):
      print("No")
      break
else:
  print("Yes")

Measured memory_bytes: 128900
import java.util.*;

class Main{
	
	
	
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		
		System.out.print(a*b);
		System.out.print(" ");
		System.out.print((a+b)*2);
		System.out.println("");
		
	}
}
		

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

int main() {
    int64_t n;
    cin >> n;
    int64_t m = sqrt(n) + 1;

    int64_t ans;
    for (int64_t i = m; i > 0; i--) {
        if (n % i == 0) {
            ans = i - 1 + n / i - 1;
            break;
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
d =int(input())
c = list(map(int, input().split())) 
s = []
t = []

d_l = []
score = 0
soft = 0

for i in range(d):
    s.append(0)
    s[i] = list(map(int, input().split()))

for i in range(26):
    d_l.append(0)
    
for i in range(d):
    t_max = max(s[i])
    t = s[i].index(t_max)
    print(t + 1)
    
    

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll L,R; cin>>L>>R;
	if(R>=2019+L) {
		cout<<0<<"\n";
		return 0;
	}
	ll ret=INT_MAX;
	for (ll i=L; i<=R; i++)
		for (ll j=i+1; j<=R; j++)
			ret=min(ret,(i*j)%2019);
	cout<<ret<<"\n";
	return 0;
}

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

#define ll  long long
#define PII pair<ll,ll>
#define VI  vector<ll>
#define VB  vector<bool>
#define VC vector<char>
#define VVI vector<vector<ll>>
#define VVC vector<vector<char>>
#define VS  vector<string>
#define VP  vector<PII>
#define lf(i,a,b) for(ll i=a;i<=b;i++)
#define lr(i,a,b) for(ll i=a;i>=b;i--)
#define lfl(i,v) for(ll i=0;i<v.size();i++)
#define lrl(i,v) for(ll i=(ll)(v.size())-1;i>=0;i--)
#define chk2(a,b) cout<<"check :  "<<a<<" "<<b<<endl
#define chk3(a,b,c) cout<<"check :  "<<a<<" "<<b<<" "<<c<<endl
#define chk4(a,b,c,d) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<endl
#define chk5(a,b,c,d,e) cout<<"check :  "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<e<<endl
#define l_b(v,k)  lower_bound(v.begin(),v.end(),k)-v.begin()
#define u_b(v,k)  upper_bound(v.begin(),v.end(),k)-v.begin()
#define mod 1000000007
#define sort(v) sort(v.begin(),v.end())
#define p_b push_back
#define p_f push_front
#define m_p make_pair
#define fir first
#define sec second
#define sz size()
#define maxn 1<<17
ll n;
ll dp[maxn];
ll dpsmm[maxn];
ll valor[maxn];
VVI sub(maxn);
VVI mat;


void calcula(){

    for(int bitmask = 1;bitmask < (1 << n);bitmask++){
        for(int i = 0;i<n;i++){
            if(!(bitmask & (1 << i))) continue;
            for(int j = i+1;j<n;j++){
                if(!(bitmask & (1 << j))) continue;
                valor[bitmask] += mat[i][j];
            }
        }
    }

}


void fill_sub(ll ind,ll bm,ll subm)
    {   if(ind==n)
        {   if(__builtin_popcount(subm) == 0) return;
            sub[bm].p_b(subm);return ;
        }
        fill_sub(ind+1,bm,subm);
        fill_sub(ind+1,bm^(1<<ind),subm^(1<<ind));
        fill_sub(ind+1,bm^(1<<ind),subm);
    }
ll smm(ll bm)
    {   VI v1;
        if(dpsmm[bm]!=-1)
            return dpsmm[bm];
        lf(i,0,n-1)
        {   if(bm&(1<<i))
            {   v1.p_b(i);
            }
        }
        ll len=v1.size();
        ll sum=0;
        lfl(i,v1)
            lf(j,i+1,len-1)
                sum+=mat[v1[i]][v1[j]];
        return dpsmm[bm]=sum;
    }
ll fun(ll bm)
    {   if(bm==0)
        {   return 0;
        }   
        if(dp[bm]!=-1)
            return dp[bm];
        //cout<<bm<<endl;
        ll maxi=0;
        lfl(i,sub[bm])
        {   maxi=max(maxi,valor[sub[bm][i]]+fun(bm^sub[bm][i]));
        }
        return dp[bm]=maxi;
    }
int main() 
{   cin>>n;
    mat=VVI(n,VI(n,0));
    lf(i,0,n-1)
        lf(j,0,n-1)
            cin>>mat[i][j];
    memset(dp,-1,sizeof(dp));
    memset(dpsmm,-1,sizeof(dpsmm));
    fill_sub(0,0,0);
    calcula();
    cout<<fun((1<<n)-1);
}

Measured memory_bytes: 344056
#define _USE_MATH_DEFINES
#include <iostream>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
//#include <tuple>

#define INF INT_MAX>>1 
#define SIZE 100010
#define MOD 1000000007
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define rep2(i, from, to) for(int i=(from); i<(int)(to); i++)
#define all(obj) (obj).begin(), (obj).end()
#define lpair pair<ll, ll>
#define vint vector<ll>
#define vinput(name) for(int i=0; i<(int)(name.size()); i++) cin >> name[i];
#define voutput(name) for(int i=0; i<(int)(name.size()); i++) cout << name[i] << endl;
typedef long long ll;

using namespace std;

ll ans = 0;

int main(void){
	string s; cin >> s;
	rep(i, s.length()-1){
		if(s[i] != s[i+1]){
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int main(void){
    
    int x, y, t;
    
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0){
            break;
        }
        if(x > y){
            t = x;
            x = y;
            y = t;
        }
    cout << x << " " << y << endl;
    }
    return 0;
}



Measured memory_bytes: 3048
#include<cstdio>
#include<cstring>
#include<algorithm>
#define MAXN 100
using namespace std;
int a[MAXN+5];
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	int cnt=0;
	for(int i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			cnt++;
			i++;
			continue;
		}
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, n) for(int i = 1; i <= (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<62);
const double inf=pow(10,10);
const ld pi=acosl(1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};

bool check(pair<ll,ll>a,pair<ll,ll>b){
	return (a.first>b.first&&a.second>b.second);
}

bool fun(pair<ll,ll>b,pair<ll,ll>a){
	if(a.first==b.first)return a.second>b.second;
	else return a.first<b.first;
}

int main(){
	ll N;
	cin>>N;
	map<string,ll>mp;
	rep(i,N){
		string s;cin>>s;
		mp[s]++;
	}
	ll ma=0;
	for(auto&&i:mp)ma=max(ma,i.second);
	vector<string>ans;
	for(auto&&i:mp)if(ma==i.second)ans.push_back(i.first);
	sort(all(ans));
	for(auto&&i:ans)cout<<i<<endl;
	
}


Measured memory_bytes: 26996
#include <bits/stdc++.h>
using namespace std;
#define L pos*2+1
#define R pos*2+2
const int N=2e5+5;
int n,m,l,r;
long long a[N],seg[N*4],laz[N*4],dp[N],ans;
vector <pair<int,int> > v[N];
void push (int pos)
{
    if (laz[pos])
    {
        if (R<N*4)
        {
            laz[R]+=laz[pos];
            laz[L]+=laz[pos];
        }
        seg[pos]+=laz[pos];
        laz[pos]=0;
    }
}
void update (int st,int en,int pos,long long val)
{
    push(pos);
    if (st>r||en<l)
        return;
    if (st>=l&&en<=r)
    {
        laz[pos]+=val;
        push(pos);
        return;
    }
    int mid= (st+en)/2;
    update(st,mid,L,val);
    update(mid+1,en,R,val);
    seg[pos]=max(seg[L],seg[R]);
}
long long query (int st,int en,int pos)
{
    if (st>r||en<l)
        return 0;
    if (st>=l&&en<=r)
        return seg[pos];
    int mid= (st+en)/2;
    return max(query(st,mid,L),query(mid+1,en,R));
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=0;i<m;i++)
    {
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        a[x]+=z;
        a[y+1]-=z;
        v[y].push_back({x,z});
    }
    for (int i=1;i<=n;i++)
        a[i]+=a[i-1];
    for (int i=1;i<=n;i++)
    {
        l=0;
        r=i-1;
        dp[i]=a[i]+query(0,n,0);
        l=i;
        r=i;
        update(0,n,0,dp[i]-a[i]);
        ans=max(ans,dp[i]);
        for (int j=0;j<v[i].size();j++)
        {
            l=v[i][j].first;
            r=i;
            update(0,n,0,v[i][j].second);
        }
    }
    l=0,r=n;
    printf("%lld",query(0,n,0));
    return 0;
}


Measured memory_bytes: 27168
#include <bits/stdc++.h>
 #define rep(i,a,b) for (int i=a;i<b;i++)
 #define rep2(i,a,b) for (int i=a;i>=b;i--)
 #define mod 1000000007
 #define INF  1e9+5
 #define f first
 #define se second
 #define endl '\n'
 #define ll long long
 #define ii pair <int,int>
 #define pll pair <ll,ll>
 #define vi vector <int>
 #define vl vector <ll>
 #define vvi vector < vi >
 #define vii vector < ii >
 #define vvii vector < vii >
 #define vll vector < ll >
 #define mi map<int,int>
 #define mll map<ll,ll>
 #define mci map<char,int>
 #define msi map<string,int>
 #define vb  vector <bool>
 #define pb push_back
 #define mk make_pair
 #define sz(a) a.size()
 #define all(a) a.begin(),a.end()
 #define rall(a) a.rbegin(),a.rend()
 #define int long long int
 #define Anurag_Gupta ios_base::sync_with_stdio(false);
#define IIIT_ALLD    cin.tie(NULL);cout.tie(NULL);
using namespace std;
vi fact(1000007);
inline int mdpower(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res%mod*a%mod)%mod;
        b/=2;
        a = (a%mod*a%mod)%mod;
    }
    return res;
}
inline int power(int a,int b)
{
    int res =1;
    while(b)
    {
        if(b&1) res = (res*a);
        b/=2;
        a = a*a;
    }
    return res;
}

inline void factorial()
{
    fact[0]=1;
    for(int i=1;i<1000007;i++)
        fact[i] = (fact[i-1]%mod*i%mod)%mod;
}

inline int inverse(int a)
{
    return mdpower(a,mod-2);
}
int n;
int arr[100005][3];
int dp[100005][3];
 signed main()
 {
     Anurag_Gupta
     IIIT_ALLD
     
     // #ifndef ONLINE_JUDGE
     //     freopen("input.txt","r",stdin);
     //     freopen("output.txt","w",stdout);
     // #endif

         cin>>n;
         for(int i=1;i<=n;i++)
         {
         	for(int j=0;j<3;j++)
         		cin>>arr[i][j];
         }

         dp[0][0]=dp[0][1]=dp[0][2]=0;
         dp[1][0]=arr[1][0];
         dp[1][1]=arr[1][1];
         dp[1][2]=arr[1][2];

         for(int i=2;i<=n;i++)
         {
         	for(int j=0;j<3;j++)
         	{
         		if(j==0)
         		{
         			dp[i][j]=arr[i][j]+max(dp[i-1][1],dp[i-1][2]);
         		}
         		else if(j==1)
         		{
         			dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][2]);
         		}
         		else
         		{
         			dp[i][j]=arr[i][j]+max(dp[i-1][0],dp[i-1][1]);
         		}
         	}
         }

         cout<<max(dp[n][0],max(dp[n][1],dp[n][2]));
 }

//dp[i][j] = maximum fun upto day i when she choses jth activity on day i;


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

int main(){
	string s; cin >> s;
	int n; cin >> n;
	for(int i=0; i<n; i++){
		string com; cin >> com;
		if(com == "print"){
			int a, b; cin >> a >> b;
			cout << s.substr(a,b-a+1) << endl;
		}
		if(com == "reverse"){
			int a, b; cin >> a >> b;
			reverse(s.begin()+a,s.begin()+b+1);
		}
		if(com == "replace"){
			int a, b; cin >> a >> b;
			string word; cin >> word;
			s.replace(a,b-a+1,word);
		}
	}
	return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

ll N,M,L,K,A,H;
bool reitou[111];
ll d[111][111];

int main(){

	while(cin >> N >> M >> L >> K >> A >> H,N+M+L+K+A+H){

		REP(i,111)reitou[i] = false;
		REP(i,111)REP(j,111){
			if(i != j)d[i][j] = INF;
			else d[i][j] = 0;
		}

		reitou[A] = true;
		reitou[H] = true;

		REP(i,L){
			int tmp;cin >> tmp;
			reitou[tmp] = true;
		}

		REP(i,K){
			int a,b,c;cin >> a >> b >> c;
			d[a][b] = c;
			d[b][a] = c;
		}

		REP(k,111)REP(i,111)REP(j,111){
			d[i][j] = min(d[i][k]+d[k][j],d[i][j]);
		}

		REP(i,111){
			REP(j,111){
				if(d[i][j] <= M && reitou[i] && reitou[j])continue;
				d[i][j] = INF;
			}
		}

		REP(k,111)REP(i,111)REP(j,111){
			d[i][j] = min(d[i][k]+d[k][j],d[i][j]);
		}

		if(d[A][H] == INF){
			cout << "Help!" << endl;
		}
		else{
			if(d[A][H] > M)cout << 2 * d[A][H] - M << endl;
			else cout << d[A][H] << endl;
		}

	}
	return 0;
}



Measured memory_bytes: 3180
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<ctime>
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<bitset>
#include<utility>
#include<string>

using namespace std;

int bun[10]={1,2,4,8,16,32,64,128,256,512};

main(){
  int n;
  int i,j,temp;
  int t;
  while(cin >> n){
    int c[15]={0};
    for(i=9;n!=0;i--){
      if(bun[i]<=n){
	n-=bun[i];
	c[i]=1;
      }
    }
    t=0;
    for(i=0;i<10;i++){
      if(c[i]==1){
	if(t==1){
	  cout << ' ';
	}
	cout << bun[i];
	t=1;
      }
    }
    puts("");
  }
}

Measured memory_bytes: 0
#include <fstream>
#include <vector>
#include <algorithm>
#include <iostream>

// BE CAREFUL WITH HASH TABLE & UNORDERED MAP
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;

#define MOD 1000000007
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define F0R(i,b) FOR(i,0,b)
#define RFO(i,a,b) for (int i = (b-1); i >= (a); i--)
#define RF0(i,b) RFO(i,0,b)
#define lli long long int
#define llm __LONG_LONG_MAX__
#define pii pair<int,int>
#define add(a,b) ((int) (((lli) (a) + (b))%MOD))
#define mul(a,b) ((int) (((lli) (a) * (b))%MOD))
#define PB emplace_back
#define F first
#define S second

// ifstream cin ("cinput.in");
// ofstream cout ("coutput.out");

int N, K, a;
vector<int> neg;
vector<int> pos;

// Helper Functions

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> N >> K;
    F0R(i,N) {
        cin >> a;
        if (a >= 0) pos.PB(a);
        else neg.PB(-a);
    }
    sort(neg.begin(), neg.end());
    sort(pos.begin(), pos.end());
    lli ans = 1, pind = -1, nind = -1, abp, abn;
    if (K == N || (neg.size() == N && K&1)) {
        F0R(i,K) {
            abp = 1e9+1; abn = 1e9+1;
            if (pind+1 < pos.size()) abp = pos[pind+1];
            if (nind+1 < neg.size()) abn = neg[nind+1];
            // cout << abp << ' ' << abn << '\n';
            if (abp < abn) {
                ans = mul(ans, abp);
                pind++;
            } else {
                ans = mul(ans, MOD-abn);
                nind++;
            }
        }
    } else {
        reverse(neg.begin(), neg.end());
        reverse(pos.begin(), pos.end());
        if (K&1) {ans = mul(ans, pos.front()); pind++;}
        F0R(i,K/2) {
            abp = -1; abn = -1;
            if (pind+2 < pos.size()) abp = (lli) pos[pind+1] * pos[pind+2];
            if (nind+2 < neg.size()) abn = (lli) neg[nind+1] * neg[nind+2];
            if (abp > abn) {
                ans = mul(ans, (int) (abp%MOD));
                pind += 2;
            } else {
                ans = mul(ans, (int) (abn%MOD));
                nind += 2;
            }
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 4296
#include <iostream>
#include <numeric>
#include <cmath>
#include <queue>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {

	ll R, C;
	cin >> R >> C ;
	ll cell[60][60];
	ll dx[4] = { -1,0,1,0 };
	ll dy[4] = { 0,1,0,-1 };
	ll w = 0;
	rep(i, 60) {
		rep(j, 60) {
			cell[i][j] = -2;
		}
	}

	rep(i, R) {
		string S;
		cin >> S;
		rep(j, C) {
			if (S.at(j) == '.') {
			cell[i][j] = -1;
			w++;
			}
		}
	}
	queue<pair<ll, ll>> q;
	cell[0][0] = 1;
	q.push(make_pair(0, 0));
	while (!q.empty()) {
		ll py = q.front().first;
		ll px = q.front().second;

		q.pop();
		rep(i, 4) {
			if (py + dy[i] < 0 || py + dy[i] >= R || px + dx[i] < 0 || px + dx[i] >= C)continue;
			if (cell[py + dy[i]][px + dx[i]] != -1)continue;

			cell[py + dy[i]][px + dx[i]] = cell[py][px] + 1;
			q.push(make_pair(py + dy[i], px + dx[i]));
		}
	}
	if (cell[R-1][C-1] == -1)cout << -1 << endl;
	else {
		cout << w-cell[R-1][C-1] << endl;
	}
	
}


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

class AroundOne
{
    static void Main(string[] args)
    {
        var first = int.Parse(Console.ReadLine());
        var second = int.Parse(Console.ReadLine());


        Console.WriteLine( 6 - first -second);
    }
}

Measured memory_bytes: 11092
use std::io;
use std::collections::HashMap;
use std::mem;

fn read_line() -> String{
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s
}

fn read_ints() -> Vec<i32>{
    let s = read_line();
    let split:Vec<&str> = s.trim().split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

fn main(){
    let temp = read_ints();
    let n = temp[0];
    let m = temp[1];
    
    let mut from1 = HashMap::new();
    let mut fromn = HashMap::new();
    
    for _i in 0..m{
        let temp = read_ints();
        let mut a = temp[0];
        let mut b = temp[1];
        
        if a>b{
            mem::swap(&mut a,&mut b);
        }
        
        if a == 1{
            
            match fromn.get(&b){
                Some(_) => {println!("POSSIBLE");return;},
                None    => {from1.insert(b,true);}
            }
        }
        
        if b == n{
            match from1.get(&a){
                Some(_) => {println!("POSSIBLE");return;},
                None    => {fromn.insert(a,true);}
            }
        }
    }
    println!("IMPOSSIBLE");
}


Measured memory_bytes: 10916
import sys
readline = sys.stdin.readline

N,K = map(int,readline().split())
H = list(map(int,readline().split()))

INF = 10 ** 10
dp = [INF] * N
dp[0] = 0

for i in range(N - 1):
  for j in range(1, K + 1):
    if i + j >= N:
      break
    if dp[i + j] > dp[i] + abs(H[i + j] - H[i]):
      dp[i + j] = dp[i] + abs(H[i + j] - H[i])
      
print(dp[N - 1])

Measured memory_bytes: 84572
H, W, M = map(int, input().split())
boms = [tuple(map(int, input().split())) for _ in range(M)]
# boms = [list(map(int, input().split())) for _ in range(M)]

hBom = [0]*H
wBom = [0]*W

# 各行、各列の爆破対象をカウント
for h, w in boms:
    hBom[h-1] += 1
    wBom[w-1] += 1

# 爆破対象の最大数と最大になる行と列の番号を調べる
maxHBom = max(hBom)
maxWBom = max(wBom)
maxHBomIndex = [index for index, h in enumerate(hBom) if h == maxHBom]
maxWBomIndex = [index for index, w in enumerate(wBom) if w == maxWBom]

# 爆破対象が最大になる行と列の組み合わせについて、
# 爆弾を配置する場所が爆破対象であるかないかで場合分け
boms = set(boms)
for h in maxHBomIndex:
    for w in maxWBomIndex:
        if (h+1, w+1) not in boms:
            print(maxHBom + maxWBom)
            exit()
else:
    print(maxHBom + maxWBom - 1)


Measured memory_bytes: 90200
n = int(input())
goal_nums = list(map(int, (input().split())))

ans_nums = [0]*n
start_i = 0
goal_i = 0
count = 0

while goal_nums != ans_nums:
    #水のあげ始めを決定
    for i in range(n):
        if goal_nums[i] != ans_nums[i]:
            start_i = i
            break
    #水のあげ終わりを決定
    for j in range(start_i, n):
        if goal_nums[j] == ans_nums[j]:
            goal_i = j
            break
        if j == n-1:
                goal_i = n

    #指定箇所に水を上げる
    for k in range(start_i, goal_i):
        ans_nums[k] += 1
    count += 1

print(count)


Measured memory_bytes: 3064