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

using namespace std;

int main(){
    int H, W;
    cin >> H >> W;

    string S[H];
    for (int i = 0; i < H; i++) cin >> S[i];

    int res = 0;
    int cnt = 0;
    int up, down, left, right;
    int pre_j = 0;
    int pre_i = 0;
    int presum_j = 0;
    int presum_i[W] = {0};
    bool skiped_j = false;
    bool skiped_i = false;

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            int sumj = 0;
            int sumi = 0;


            if (S[i][j] == '.'){

                skiped_j = (pre_j+1 != j);
                skiped_i = (pre_i+1 != i);

                if (S[i][j-1] != '.' || j == 0){
                    for (int k = j-1; k >= 0; k--)
                        if (S[i][k] == '.') sumj++;
                        else break;

                    for (int k = j+1; k < W; k++)
                        if (S[i][k] == '.') sumj++;
                        else break;
                    presum_j = sumj;
                }
                else sumj = presum_j;

                if (i == 0 || S[i-1][j] != '.'){
                    for (int k = i-1; k >= 0; k--)
                        if (S[k][j] == '.') sumi++;
                        else break;

                    for (int k = i+1; k < H; k++)
                        if (S[k][j] == '.') sumi++;
                        else break;

                    presum_i[j] = sumi;
                }
                else sumi = presum_i[j];

            }
            pre_j = j;
            pre_i = i;
            res = max(res, sumi + sumj);
            cnt = 0;
        }
    }

    cout << res+1 << endl;
}


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


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,s=0;
    cin>>n;
    vector<int>x(n),y(n),h(n);
    rep(i,n)cin>>x[i]>>y[i]>>h[i];
    
    while(h[s]==0)s++;
    
    rep(i,101)rep(j,101){
        int H=abs(x[s]-i)+abs(y[s]-j)+h[s];
        rep(k,n){
            if(h[k]!=max(H-abs(x[k]-i)-abs(y[k]-j),0))break;
            if(k+1==n){
                cout<<i<<' '<<j<<' '<<H<<endl;
                return 0;
            }
        }
    }
    
    return 0;
}


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

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int n, k;
	cin >> n >> k;
	vector<pair<int, int>> p(n);
	for(int i=0; i<n; i++){
		cin >> p[i].second >> p[i].first;
	}
	sort(p.begin(), p.end(), greater<pair<int, int>>());
	ll c=0;
	set<int> s;
	priority_queue<ll, vector<ll>, greater<ll>> q;
	for(int i=0; i<k; i++){
		int j=s.size();
		c+=p[i].first;
		s.insert(p[i].second);
		if(j==s.size()){
			q.push(p[i].first);
		}
	}
	ll m=c+(ll)s.size()*(ll)s.size();
	for(int i=k; i<n; i++){
		if(q.empty()){
			break;
		}
		int j=s.size();
		s.insert(p[i].second);
		if(j!=s.size()){
			c+=p[i].first;
			c-=q.top();
			q.pop();
			m=max(m, c+(ll)(j+1)*(ll)(j+1));
		}
	}
	cout << m << endl;

	return 0;
}

Measured memory_bytes: 4348
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define per(i, n) for(ll i=((ll)(n))-1; i>=0; i--)
#define perf(i, n) for(ll i=((ll)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll n; cin >> n;
    vi a = {2, 1};
    for(ll i=2; i<=n; i++) a.push_back(a[i-1]+a[i-2]);
    cout << a[n] << endl;
}

Measured memory_bytes: 256
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c=0,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN(s);
  REP(i,s.size()){
    if(s[i]=='+') c++;
    else c--;
  }
  OUT(c);
}

Measured memory_bytes: 256
import java.util.*;
class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int b = sc.nextInt();
int c = 2*b;
if(c>a){
System.out.println(0);
}
else{
System.out.println(a-c);
}
}
}

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

const int64_t mod=1000000007;
int main(){
  int64_t n,a=1,b=1,c=1;
  cin >> n;
  for(int i=0;i<n;i++){
    a*=10;a%=mod;
    b*=9;b%=mod;
    c*=8;c%=mod;
  }
  cout << (mod*3+a-b-b+c)%mod << endl;
  return 0;
}

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

using namespace std;
using namespace __gnu_pbds; 
  
#define ll long long
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
	enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
	ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
	*this << "[";
	for (auto it = d.b; it != d.e; ++it)
		*this << ", " + 2 * (it == d.b) << *it;
	ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

const int MOD = (int)1e9 + 7;
const int MX = (int)1e5 + 10;

void add_self(int &x, int y, int md = MOD){x += y; if(x >= md) x -= md;}
void sub_self(int &x, int y, int md = MOD){x -= y; if(x < 0) x += md;}
void mul_self(int &x, int y, int md = MOD){x = x * 1LL * y % md;}
inline int mul(int x, int y, int md = MOD){return x * 1LL * y % md;}
inline int add(int x, int y, int md = MOD){x += y; if(x >= md) x -= md; return x;}
inline int sub(int x, int y, int md = MOD){x -= y; if(x < 0) x += md; return x;}

void pre(){
}	


void solve(){
	int n, x, t;
	cin >> n >> x >> t;
	int res = (n + x - 1) / x * t;
	cout << res << "\n";
	return;
}

int main(){

	cin.tie(0); cout.tie(0);
	ios_base::sync_with_stdio(0);

	// freopen("input.in", "r", stdin);
	// freopen("output.out", "w", stdout);

	int t;
	t = 1;
	// cin >> t;
	// pre();
	for(int i = 1; i <= t; ++i){
		// cout << "Case #" << i << ": ";
		solve();
		// cout << '\n';
		// cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#define rep(i,n) for(int i=0;i<n;++i)
#define pi pair<int,int>

const long INF = 10101010;

using namespace std;

int h, w, add, ans, B[101][101], di[4][2] = { { 0,1 },{ 1,0 },{ -1,0 },{ 0,-1 } };
char A[101][101];
queue <pi> q; pi st, go;

int main() {
	cin >> h >> w;
	rep(i, h) rep(j, w) {
		cin >> A[i][j];
		if (A[i][j] == '#') add++;
		B[i][j] = INF;
	}
	B[0][0] = 0;
	add = h * w - add - 1;

	st.first = 0; st.second = 0;
	go.first = h - 1; go.second = w - 1;
	
	q.push(st);
	while (!q.empty()) {
		pi x = q.front();
		q.pop();
		rep(i, 4) {
			int X = x.first + di[i][0], Y = x.second + di[i][1];
			if (X >= 0 && Y >= 0 && X < h && Y < w) {
				if (A[X][Y] != '#' && B[X][Y] == INF) {
					q.push(pair<int, int>(X, Y));
					B[X][Y] = B[x.first][x.second] + 1;
				}
			}
		}
	}

	if (B[h - 1][w - 1] == INF) cout << -1 << endl;
	else cout << add - B[h - 1][w - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef unsigned long long u64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  int now = 0;
  for (int i = 0; i < h; ++i) {
    string s;
    cin >> s;
    for (int j = 0; j < now; ++j) {
      if (s[j] == '#') {cout << "Impossible" << endl; return 0;}
    }
    while (true) {
      if (s[now] == '.' || now == w) break;
      now++;
    }
    now--;
    for (int j = now+1; j < w; ++j) {
      if (s[j] == '#') {cout << "Impossible" << endl; return 0;}
    }
  }
  if (now != w-1) cout << "Impossible" << endl;
  else cout << "Possible" << endl;
  return 0;
}


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

int main(){
  int r,g,b,sum;
  scanf("%d",&r);
  scanf("%d",&g);
  scanf("%d",&b);
  sum = r*100+g*10+b;
  if(sum%4==0){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {
	string S;
	cin >> S;
	int n = (int)S.size();

	int ini = 0;
	for (int i = 0; i < n; i++) {
		if (S[i] == 'A') {
			ini = i;
			break;
		}
	}

	int fin = 0;
	for (int i = n-1; i >= 0; i--) {
		if (S[i] == 'Z') {
			fin = i;
			break;
		}
	}

	cout << fin - ini + 1 << endl;
}

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

const ll mod=1000000007;

int main() {
  int n;
  cin >> n;
  if(n%10==3)cout<<"bon"<<endl;
  else if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon"<<endl;
  else cout<<"hon"<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  string S, T;
  cin >> S >> T;
  int S_size = S.size();
  int T_size = T.size();
  debug(S, T);
  if (T_size > S_size) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }
  int cnt = 0;
  debug(S_size - T_size);
  for (int i = S_size - T_size; i >= 0; i--) {
    bool break_flag = 0;
    for (int j = 0; j < T_size; j++) {
      if (S[i + j] != T[j] && S[i + j] != '?') {
        break_flag = 1;
        break;
      }
    }
    if (!break_flag) {
      for (int j = 0; j < T_size; j++) {
        S[i + j] = T[j];
      }
      for (int j = 0; j < S_size; j++) {
        if (S[j] == '?') S[j] = 'a';
      }
      debug(S);
      cout << S << endl;
      return 0;
    } else {
      // if (S[i] == '?') S[i] = 'a';
      cnt++;
    }
    debug(S);
  }
  for (int i = 0; i < S_size; i++) {
    if (S[i] == '?') S[i] = 'a';
  }
  if (cnt == S_size - T_size + 1)
    cout << "UNRESTORABLE" << endl;
  else
    cout << S << endl;
  return 0;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, K;
  cin >> N >> K;

  int r = K;
  int d = 1;
  
  while(N >= r){
    r = r * K;
    ++d;
  }
    
  cout << d;

  
  return 0;
}

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

int main(){
 string s;
 cin >> s;
  int counter = 0;
  if (s[0] == '1') counter ++;
  if (s[1] == '1') counter ++;
  if (s[2] == '1') counter ++;
  cout << counter << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int sx,sy,tx,ty;
	cin>>sx>>sy>>tx>>ty;
	int dx=tx-sx;
	int dy=ty-sy;
	cout<<string(dy,'U')<<string(dx,'R');
	cout<<string(dy,'D')<<string(dx,'L');
	cout<<"L"<<string(dy+1,'U')<<string(dx+1,'R')<<'D';
	cout<<'R'<<string(dy+1,'D')<<string(dx+1,'L')<<'U';
	return 0;
}



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

#define trace(...) __f( #__VA_ARGS__ , __VA_ARGS__ )
template <typename Arg1>
void __f( const char* name , Arg1&& arg1 ) {
        cerr << name << " : " << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void __f( const char* na , Arg1&& arg1 , Args&&... args ) {
        const char* c = strchr( na + 1 , ',' );
        cerr.write( na , c - na ) << " : " << arg1 << " , ";
        __f( c + 1 , args... );
}
#define endl "\n"
#define all(V) V.begin(),V.end()
#define Unique(V) sort(all(V)),V.erase(unique(all(V)),V.end())
#define IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int LL;
typedef pair <int,int> pii;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const long long INF = 1e18;
const int N = 1e5 + 5;

int cnt[ N ];

int main( ) {
        IO;
        #ifdef LOCAL
            //freopen( "input.txt" , "r" , stdin );
        #endif // LOCAL
        int n , m;
        cin >> n >> m;
        for( int i = 1; i <= m; i++ ) {
                int l , r;
                cin >> l >> r;
                cnt[r+1]--;
                cnt[l]++;
        }
        for( int i = 1; i <= 1e5; i++ ) cnt[i] += cnt[i-1];
        int ans = 0;
        for( int i = 1; i <= 1e5; i++ ) ans += ( cnt[i] == m );
        cout << ans << endl;
        return 0;
}










Measured memory_bytes: 640
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

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

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")


P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}



int main(){
  
  string s;cin>>s;
  if(s == "MON")cout << 6 << endl;
  if(s == "TUE")cout << 5 << endl;
  if(s == "WED")cout << 4 << endl;
  if(s == "THU")cout << 3 << endl;
  if(s == "FRI")cout << 2 << endl;
  if(s == "SAT")cout << 1 << endl;
  if(s == "SUN")cout << 7 << endl;
  

}


Measured memory_bytes: 256
#include <iostream>
//#include <set>
//#include <map>
//#include <iomanip>
#include <algorithm>
//#include <numeric>
//#include <queue>
//#include <stack>
//#include <math.h>
#include <vector>
//#include <string>
//#include <list>
//#include <deque>
//#include <unordered_map>
typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
#define NIL 200000

int main() {
    int n;
    vector<LL> money;
    cin >> n;
    money.push_back(1);
    LL tmp=1;
    while(true){
        tmp*=6;
        if(tmp<=n){
            money.push_back(tmp);
        }else{
            break;
        }
    }
    tmp=1;
    while(true){
        tmp*=9;
        if(tmp<=n){
            money.push_back(tmp);
        }else{
            break;
        }
    }
    sort(money.begin(), money.end());
    int ms = money.size();
    vector<vector<LL>> dp(money.size(), vector<LL>(n+1, NIL));
    for(int i=0; i<ms; i++){
        dp[i][0]=0;
    }
    tmp=0;
    while(true){
        LL tmp2=tmp+money[0];
        if(tmp2<=n){
            dp[0][tmp2] = dp[0][tmp]+1;
            tmp+=money[0];
        }else{
            break;
        }
    }
    for(int i=1; i<ms; i++){
        for(int j=1; j<=n; j++){
            if(j<money[i]){
                dp[i][j] = dp[i-1][j];
            }else{
                dp[i][j] = min(min(dp[i][j-money[i]]+1, dp[i-1][j]), dp[i-1][j-money[i]]+1);
            }
        }
    }

    //for(int i=0; i<=n; i++){
    //    cout << dp[1][i] << endl;
    //}

    cout << dp[ms-1][n] << endl;


    return 0;
}

Measured memory_bytes: 10368
sub f{
	my$i=pop;
	$u[$i]=$u[$i]!=$i?f($u[$i]):$i
}
($N,$M)=glob<>;
@p=glob<>;
@u=0..$N;
for(<>){
	($x,$y)=split;
	$x=f$x;
	$y=f$y;
	$u[$x]=$y
}
print~~grep f($_)==f($p[$_-1]),1..$N


Measured memory_bytes: 31112
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <numeric>
#define ll long long
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
using namespace std;



int main() {
	ll R;
	double ans;
	cin >> R;
	ans = (double)R * 2.0 * 3.14;
	cout << ans<<endl;
	return 0;
}

Measured memory_bytes: 3776
from sys import exit
import copy
#import numpy as np
#from collections import deque


d, = map(int, input().split())
c= list(map(int, input().split()))
s=[list(map(int, input().split())) for _ in range(d)]
#  t=[int(input()) for _ in range(d)]

sche=[0 for _ in range(d)]
last=[0 for _ in range(26)]

score=0
for day in range(1,d+1):
    idx=day-1
    d_tmp=float("inf")*(-1)
    i_tmp=0
    for t in range(26):    
        delta=0
        l_tmp=copy.copy(last)
        delta+=s[idx][t]
        l_tmp[t]=day
        for l in range(26):
            delta-=c[l]*(day-l_tmp[l])
        if delta>=d_tmp:
            d_tmp=delta
            i_tmp=t
    sche[idx]=i_tmp+1
    score+=d_tmp
    last[i_tmp]=day
    # print(score)
    # print(i_tmp+1)

for i in sche:
    print(i)

# print(score)






Measured memory_bytes: 9628
def dig(n):

    s = str(n)

    ret = 0

    for i in s:
        ret += int(i)

    return ret

N = int(input())

ans = float("inf")

for i in range(N // 2):
    i += 1
    j = N - i

    ans = min(ans, dig(i) + dig(j))

print (ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/


int main(){
    int n, y; cin >> n >> y;
    vector<int> x(n);
    rep(i, n) cin >> x[i];
    int _gcd= abs(x[0] - y);
    _rep(i, 1, n){
        _gcd = gcd(abs(x[i] - x[i - 1]), _gcd);
    }
    cout << _gcd << endl;
}

Measured memory_bytes: 640
#!/usr/bin/env python3
import sys


def solve(N: int, h: "List[int]"):
    dp = [0] * N
    for i in range(1, N):
        if i == 1:
            dp[1] = abs(h[1] - h[0])
        else:
            dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]),
                        dp[i-2] + abs(h[i] - h[i-2]))
    print(dp[-1])


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    h = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, h)


if __name__ == '__main__':
    main()


Measured memory_bytes: 52640
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl
template<typename T>
T ncr(T left, T right) {
	right = min(left - right, right);
	T ans = 1;
	for (T i = 1; i <= right; i++) {
		ans = ans * (left - right + i) / i;
	}
	return ans;
}

const lli MOD = 1000000007;
const lli LIMIT = 1'0'000'000'000'000'000 * 5;
const int tenfive = 100000;

bool solved = false;
vector<int> ans;

void solve(list<int> li,vector<int> vnum){
	if (li.size() == 0) {
		ans = vnum;
		solved = true;
		return;
	}
	{
		int i = 1;
		int del = -1;
		for (auto it = li.begin(); it != li.end(); it++, i++) {
			if (solved) {
				return;
			}
			if (*it > i) {
				vnum = vector<int>();
				return;
			}
			if (*it == i) {
				del = i-1;
			}
		}
		if (del == -1)
			return;
		auto cv = vnum;
		cv.push_back(del+1);
		auto cl = li;
		cl.erase(std::next(cl.begin(), del));
		solve(cl, cv);
	}
	return;
}

int main() {
	int N;
	cin >> N;
	bool cannot = false;
	list<int> v;
	int stk;
	for (int i = 0; i < N; i++) {
		cin >> stk;
		v.push_back(stk);
	}
	solve(v, vector<int>());
	if (solved) {
		reverse(ans.begin(), ans.end());
		for (int x : ans) {
			cout << x << endl;
		}
		return 0;
	}
	else {
		cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 500;
int n, sx = 0, sy = 0;
int x, y, t, tt, st = 0;

int main()
{
  //  freopen("in.txt","r",stdin);
    cin>>n;
    bool flag = true;
    for(int i=0;i<n;i++) {
        scanf("%d%d%d",&tt, &x, &y);
        int d = abs(x - sx) + abs(y - sy);
        t = tt - st;
        if(t < d)flag = false;
        else {
            if( (t - d) % 2 )flag = false;
        }
        sx = x, sy = y, st = tt;
    }

    if(flag)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int e;
	string s;
	cin >> s;
	if (s <= "2019/04/30") {
		cout << "Heisei" << "\n";
	}
	else {
		cout << "TBD" << "\n";
	}
	std::cin >> e;
}

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

using namespace std;
 
int main(void) {
  int n;
  cin >> n;
  
  vector<int> x(n);
  for (int i = 0;i < n;i++) {
    cin >> x[i];
  }
  
  int first = *(min_element(x.begin(), x.end()));
  int last = *(max_element(x.begin(), x.end()));
  
  int cost = 0, min_cost = 999999999;

  for (int i = first;i <= last;i++) {
    cost = 0;
    for (int j = 0;j < n;j++) {
      cost += (i - x[j]) * (i - x[j]);
    }
    min_cost = min(cost, min_cost);
  }
  
  cout << min_cost << endl;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().rstrip()

if s.count('RRR') == 1:
    print(3)
elif s.count('RR') == 1:
    print(2)
elif s.count('R') == 0:
    print(0)
else:
    print(1)

Measured memory_bytes: 9104
/****************************
*  Developer : joshi08
*  Date  :  27-06-2020
*  Year  :  2020
****************************/

#include <bits/stdc++.h>

#define lli long long int
#define mod 1000000007
#define fi first
#define se second
#define ii pair<lli, lli>
#define mp make_pair
#define endl '\n'
const double PI = 3.141592653589793238460;
lli gcd(lli a, lli b) { if (a == 0) return b; return gcd(b % a, a);}
lli max(lli a, lli b) {if (a > b) return a; else return b;}
lli min(lli a, lli b) {if (a < b) return a; else return b;}
lli power(lli a, lli n){ lli res = 1; while(n){ if(n%2==0){ a *= a; n /= 2; } else{ res *= a; n--; } } return res; }

using namespace std;

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

	lli a;
	cin>>a;
	cout<<a+(a*a)+(a*a*a);

    return 0;
}



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

typedef long long int LLI;

int main()
{
    LLI n;
    cin>>n;
    if(n==1) cout<<"1";
    else if(n==2) cout<<"3";
    else{
        LLI p[42];
        p[0]=1;
        int i;
        for(i=1;i<=41;++i) p[i]=2*p[i-1];
        map<LLI,int>mp;
        for(i=1;i<=41;++i) mp[p[i]]=1;
        LLI ans;
        if(mp[n]) ans=ceil(log10(n)/log10(2))+1;
        else ans=ceil(log10(n)/log10(2));
        ans=p[ans]-1;
        cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int[] A = new int[N];
		int wa = 0;
		for(int i = 0; i < N; i++) {
			A[i] = sc.nextInt();
			wa += A[i];
		}
		sc.close();
		Arrays.sort(A);
		double nov = (double)wa / (4 * M);
		int ok = 0;
		for(int i = N - 1; i >= 0; i--) {
			ok += A[i] >= nov ? 1 : 0;
			// System.out.println(ok + " " + A[i] + " " + nov);
		}
		System.out.println(ok >= M ? "Yes" : "No");
	}
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = (ll)1e9 + 7;

int main()
{
  int N; scanf("%d", &N);
  vector<int> T(N + 1), X(N + 1), Y(N + 1);
  for (int i = 1; i <= N; ++i) {
    scanf("%d %d %d", &T[i], &X[i], &Y[i]);
  }
  bool ok = true;
  for (int i = 1; i <= N; ++i) {
    int diff = abs(X[i] - X[i - 1]) + abs(Y[i] - Y[i - 1]);
    int t = T[i] - T[i - 1];
    if (diff > t) {
      ok = false;
      break;
    }
    if ((diff - t) & 1) {
      ok = false;
      break;
    }
  }
  printf("%s\n", ok ? "Yes" :"No");
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  string s;
  cin >> s;
  int ans = 0;
  for(int i=0;i<n-2;i++){
    if(s.at(i) == 'A'){
      if(s.at(i+1) == 'B'){
        if(s.at(i+2) == 'C'){
          ans++;
        }
        else continue;
      }
      else continue;
    }
  }
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
const Main = () => {
    const line = require('fs').readFileSync('/dev/stdin', 'utf8');
    const [SS, WW] = line.split(' ');
    const S = parseInt(SS, 10);
    const W = parseInt(WW, 10);
    if (S <= W) {
        console.log('unsafe');
    } else {
        console.log('safe');
    }
}

Main();


Measured memory_bytes: 29528
import numpy as np
N = int(input())
list = list(map(int,input().split()))
mean = np.mean(list)

# print(mean)
minabs = 1000
min = 0
for i,data in enumerate(list):
    if abs(data - mean) < minabs:
        minabs = abs(data - mean)
        min = i

print(min)


Measured memory_bytes: 12484
mod = 10**9+7


def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]
    dp = [[0 for _ in range(W)] for _ in range(H)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if i != 0 or j != 0:
                if a[i][j] == ".":
                    dp[i][j] = dp[i - 1][j] + dp[i][j - 1]
                    dp[i][j] %= mod
    print(dp[-1][-1])


if __name__ == "__main__":
    main()


Measured memory_bytes: 44636
Module Program
  Sub Main
    Dim s = GetInts()
    Dim a=s(0),b=s(1)
    Dim ans=If(a<=b,a,a-1)
    Console.WriteLine(ans)
  End Sub
  
  '/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
  Function Gets() As String()
    Gets = Console.ReadLine().Split(" "c)
  End Function
  Function GetInts() As Integer()
    Dim s = Gets(), r(UBound(s)) As Integer
    For i As Integer=0 To UBound(s): r(i)=s(i): Next i
    GetInts = r
  End Function
End Module

Measured memory_bytes: 20304
#include<iostream>
#include<string>
#include<algorithm>
#define N 3

using namespace std;

struct DATA{
  int ok;
  int count;
};

int Atoi(const string c);

int main(){
  int i, n, hour, minute, _minute, isOK, ans;
  string s, t, u, _str, str[N]={"lunch", "dinner", "midnight"};
  DATA data[N];

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<N; ++i){
      data[i].ok = 0;
      data[i].count = 0;
    }

    for(i=0; i<n; ++i){
      cin >> _str >> u;
      copy(_str.begin(), _str.begin()+2, back_inserter(s));
      copy(_str.begin()+3, _str.end(), back_inserter(t));
      hour = Atoi(s);
      minute = Atoi(t);
      _minute = Atoi(u);
      s.clear();
      t.clear();

      if(_minute < minute) _minute += 60;
      if(_minute - minute <= 8) isOK = 1;
      else isOK = 0;

      if(hour > 10 && hour < 15){
	data[0].ok += isOK;
	++data[0].count;
      }else if(hour > 17 && hour < 21){
	data[1].ok += isOK;
	++data[1].count;
      }else if((hour > 20 && hour < 24) || (hour > -1 && hour < 3)){
	data[2].ok += isOK;
	++data[2].count;
      }
    }

    for(i=0; i<N; ++i){
      cout << str[i] << " ";
      if(data[i].count == 0){
	cout << "no guest" << endl;
      }else{
	ans = 100 * data[i].ok / data[i].count;
	cout << ans << endl;
      }
    }
  }

  return 0;
}

int Atoi(const string c){
  int i, x=0, digit=1;
  for(i=c.size()-1; i>=0; --i){
    x = x + (c[i]-48)*digit;
    digit *= 10;
  }
  return x;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    if (sz(s) > k) {
        s = s.substr(0, k) + "...";
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3600
def get_line():
  return input().split(' ')

class element:
  def __init__(self, P, Y, idx):
    self.P = P
    self.Y = Y
    self.idx = idx
  def __lt__(self, other):
    return self.Y < other.Y

N, M = map(int, get_line())
els = [0] * M
for i in range(M):
  p, y = map(int, get_line())
  els[i] = element(p, y, i)

p_map = [[] for _ in range(N)]

for e in els:
  p_map[e.P - 1].append(e)

ans = [0] * M

for mp in p_map:
  cnt = 1
  for e in sorted(mp):
    ans[e.idx] = "{:06d}{:06d}".format(e.P, cnt)
    cnt = cnt + 1

for e in ans:
  print(e)


Measured memory_bytes: 50180
#include <iostream>
using namespace std;
int main(void){
    int n, a[100] = {0}; //100個
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    cout << a[n-1];
    for(int i = 1; i < n; i++){
        int j = (n-1) - i;
        
        cout << " " << a[j];
    }
    cout << endl;
}


Measured memory_bytes: 3080
n = int(input())
a = []
b = []

for x in input().split():
	a.append(int(x))

for x in input().split():
	b.append(int(x))

score = []

for i in range(n):
	s_score = sum(a[:i+1])+sum(b[i:])
	score.append(s_score)
print(max(score))


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

typedef long long ll;

int N;
vector<ll> A;
ll ans, max_a;

void calcu(void) {
	ll k = 0;
	for (int i = 0; i < N; ++i)
		k += A[i] / N;
	ans += k;
	max_a = -1LL;
	for (int i = 0; i < N; ++i) {
		A[i] = (A[i] % N) + (k - A[i] / N);
		max_a = max(max_a, A[i]);
	}
}

int main(void) {
	cin >> N;

	A.resize(N);
	max_a = -1LL;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		max_a = max(max_a, A[i]);
	}

	ans = 0LL;
	while (max_a > N - 1)
		calcu();

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#include <bitset>
using namespace std;
const int INF=1<<30;

typedef pair<int,int> P;

long long mod_pow(long long x,long long n,long long mod){
	if(n==0) return 1;
	long long res = mod_pow(x*x%mod,n/2,mod);
	if(n&1) res=res*x%mod;
	return res;
}

int main(){
	
	int n,k;
	long long ans=0;
	vector<int> c(30);  
	cin>>n>>k;
	
	string s;
	for(int i=0;i<n;i++){
		cin>>s;
		c[s[0]-'A']++;
	}
	
	
	
	while(1){
		sort(c.begin(),c.end(),greater<int>());
		int count=0;
		for(int i=0;i<27;i++){
			if(c[i]>0){
				count++;
				c[i]--;
			}
			if(count>=k)
				break;
		}
		if(count>=k)
			ans++;
		else
			break;
		
	}
	
	cout<<ans<<endl;
	

}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

bool P=true,S=true;

class SOE{
public:
    int n;
    vector<int> table;
    SOE(int n_in):n{n_in}{
        table.assign(n+1,0);
        for(int i=2;i*i<=n;i++){
            if(table[i]) continue;
            for(int j=i*i;j<=n;j+=i){
                if(table[j]==0) table[j]=i;
            }
        }
    }

    void pr_fac(int num,vector<int>& v){
        if(num>n){
            cout<<"error"<<endl;
            return;
        }
        int p;
        queue<int> que;
        while(num>1){
            p=table[num];
            if(p==0) p=num;
            que.push(p);
            num/=p;
            if(v[p]>0) P=false;
            //cout<<p<<endl; 適当な処理
        }
        while(!(que.empty())){
            int a=que.front();
            que.pop();
            v[a]++;
        }
    }
};

int gcd(int a,int b){
    int temp;
    while(b){
        temp=b;
        b=a%b;
        a=temp;
    }
    return a;
}

int main(){
    int n; cin>>n;
    SOE f(1000000);
    vector<int> a(n,0),cnt(1000001,0);
    rep(i,n) cin>>a[i];
    rep(i,n) f.pr_fac(a[i],cnt);
    int g=a[0];
    rep(i,n) g=gcd(g,a[i]);
    if(g!=1) S=false;
    if(P) cout<<"pairwise coprime"<<endl;
    else if(S) cout<<"setwise coprime"<<endl;
    else cout<<"not coprime"<<endl;
}

Measured memory_bytes: 14804
#include<bits/stdc++.h>
using namespace std;
int main()
{int cnt=0;
 string s,t;
 cin>>s>>t;
 for(int i=0; i<s.size(); i++){
   if(s[i]!=t[i]){
     cnt++;
   }
 }
 cout<<cnt<<endl;
}
   

Measured memory_bytes: 3900
#include<stdio.h>
int main(){
  int n,i;
  long long a[100010],b[100010],s=0;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%lld %lld",&a[i],&b[i]);
  while(n--){
    a[n]=(a[n]+s)%b[n];
    s+=(b[n]-a[n])%b[n];
  }
  printf("%lld\n",s);
  return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n) 
{ v = vector<T>(n); for (lli i=0; i<n; ++i) cin >> v[i]; }
template<class T, class U> void read_n(vector<pair<T, U>>& v, size_t n)
{ v = vector<pair<T, U>>(n); 
  for (lli i=0; i<n; ++i) cin >> v[i].first >> v[i].second; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n[4];
lli ptn[4] = { 1, 4, 7, 9 };
int main() {
  for (lli i=0; i<4; ++i) cin >> n[i];
  sort(begin(n), end(n));
  bool res = equal(begin(n), end(n), begin(ptn));
  cout << (res ? "YES" : "NO" ) << endl;
  return 0;
}


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

int main(){
    int h, w;
    char c[100][100];
    cin >> h >> w;

    rep(i,h)
        rep(j,w) cin >> c[i][j];
    
    rep(i,h){
        rep(j,w) cout << c[i][j];
        cout << endl;
        rep(j,w) cout << c[i][j];
        cout << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,b) for(ll i=a ; i<b; i++)
int main()
{ ll n,k5; cin>>n>>k5; ll a[n],inf=1000000009; f(i,0,n) { cin>>a[i]; } ll dp[n];
f(k1,0,n) { dp[k1]=inf;}    
dp[0]=0; dp[1]=abs(a[1]-a[0]); 
 if(n>k5+1) {  f(j,2,k5+1) { f(k,0,j) { dp[j]=min(dp[j],dp[k]+abs(a[j]-a[k]));    } } }
f(j2,k5+1,n) { f(k3,j2-k5,j2){ dp[j2]=min(dp[j2],dp[k3]+abs(a[k3]-a[j2])); } } 
cout<<dp[n-1]; 


}

Measured memory_bytes: 5196
import java.util.*;
import java.lang.*;
public class Main
{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			int n = sc.nextInt();
			double d = sc.nextInt();
			int c=0;
			for(int i=0;i<n;i++)
			{
				long x = sc.nextInt();
				long y = sc.nextInt();
				double d1 = Math.sqrt((x*x) + (y*y));
				if(d1<=d) c++;
			}
			System.out.println(c);
	}
}


Measured memory_bytes: 59208
#include <bits/stdc++.h>
using namespace std;
int g[200005];
int f(int x) {
  return g[x] == x ? x : g[x] = f(g[x]);
}
int main() {
  for (int i = 1; i <= 200000; i++) {
    g[i] = i;
  }
  int n, m, k, x;
  scanf("%d %d", &n, &m);
  for (int i = 1; i <= n; i++) {
    scanf("%d", &k);
    for (int j = 1; j <= k; j++) {
      scanf("%d", &x);
      int y = f(100000 + x);
      int z = f(i);
      if (y != z) {
        g[y] = z;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    if (f(i) != f(1)) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ldb >;
#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;




int main() 
{

 fast();
  
 
  ll n,d;
  cin>>n>>d;
  vec adj[n];
  ldb x;
  f(i,0,n)
  {
    f(j,0,d)
    {
      cin>>x;
      adj[i].pb(x);

    }
  }
  ll c=0;
  for(ll i=0;i<n;i++)
  {
    
    f(j,0,n)
    {
      ldb di=0;
        f(k,0,d)
        {
          di+=(((adj[i][k]-adj[j][k])*(adj[i][k]-adj[j][k])));
        }
        if(j<=i)
          continue;
        if((int)sqrt(di)*(int)sqrt(di)==(int)di)
          c++;
    }
  } 
  cout<<c;

  


    




    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
//  
// #include <bits/stdc++.h>
// using namespace std;
// using ll = long long;
// using ldb = long double;
// using pa = pair < ll, ll >;
// using vec = vector < ll >;
// #define pb push_back
// #define po pop_back
// #define mp make_pair
// #define mt make_tuple
// #define F  first
// #define S  second
// #define f(i,x,n) for(ll i=x;i<n;i++) 
// #define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))
// #define all(c) c.begin(),c.end()
// #define str string
// #define edl "\n"
// #define add insert
// #define cot continue
// #define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
// const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
// const double PI = acos(-1);
// const ll LINF = LLONG_MAX;




// int main() 
// {

//  fast();
  
//   #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt","w",stdout);
//   #endif
  
//   ll l,r;
//   cin>>l>>r;
//   f(i,l,r)
//   {

//   }


  


    




//     cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
//     return 0;
// }


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define repback(i, n, k) for (int i=int(n); i >= (int)(k); --i)

typedef long long ll;

int main() {
	int n, m;
	cin >> n;
	vector<int> h(n); //配列
	for(int i = 0; i < n; i++){
		cin >> h[i];
	}
	for(int i = 0; i < n; i++){
		if(i == 0) continue;
		if(h[i-1] > h[i]){
			puts("No");
			return 0;
		}if(h[i-1] < h[i]){
			h[i]--;
		}
	}
    puts("Yes");
    return 0;	
}

Measured memory_bytes: 640
from math import log2
N, M = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル

#print(log2(10**9)) -> 29.8 < 30 = vmaxとみなせる
for i in range( 2, N + 1 + 30 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

Divs = {}

i = 2
while i * i <= M:
  first_time = True
  while M % i == 0:
    if first_time:
      Divs[i] = 1
      first_time = False
    else:
      Divs[i] = Divs[i] + 1
    M = M // i
  i += 1

if M > 1:
  Divs[M] = 1

ans = 1
for k,v in Divs.items():
  ans = ans * cmb(v+N-1,v,mod) % mod


print(ans)
#print(Divs)

Measured memory_bytes: 15020
fun calc(op: Char, x: Int, y: Int) = when (op) {
    '+' -> x + y
    else -> x - y
}

fun main(args: Array<String>) {
    val (a, b, c, d) = readLine()!!.map { it - '0' }
    val ops = charArrayOf('+', '-')
    for (op1 in ops) {
        val ab = calc(op1, a, b)
        for (op2 in ops) {
            val abc = calc(op2, ab, c)
            for (op3 in ops) {
                val abcd = calc(op3, abc, d)
                if (abcd == 7) {
                    println("$a$op1$b$op2$c$op3$d=7")
                    return
                }
            }
        }
    }
}


Measured memory_bytes: 33728
// 参考: https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8

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")
    };
}

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! 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)*}
    };
}

fn main() {
    input! {x: f64};
    let mut count = 0;
    let mut now_money = 100.0;
    while now_money < x {
        count += 1;
        let next: i64 = (now_money * 1.01) as i64;
        now_money = next as f64;
    }

    println!("{}", count);
}


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

int main(){
  int n, m;
  cin >> n >> m;
  string a[n], b[m];
  for(int i = 0; i < n; i++) cin >> a[i];
  for(int i = 0; i < m; i++) cin >> b[i];
  for(int i = 0; i < n-m+1; i++){
    for(int j = 0; j < n-m+1; j++){
       bool flag = true;
      for(int k = 0; k < m; k++){
        for(int l = 0; l < m; l++){
          if(a[i+k][j+l] != b[k][l]) flag = false;
        }
      }
      if(flag) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256