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

#ifdef DEBUG
    #include "debug.h"
    #define dump(...)                                                              \
        DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
                << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
                << endl                                                            \
                << "    ",                                                         \
            dump_func(__VA_ARGS__)
#else
    #define dump(...)
#endif


// http://beet-aizu.hatenablog.com/entry/2018/04/08/145516
template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}

//////////////////

#define int long long
 
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

#define YES puts("YES")
#define Yes puts("Yes")
#define NO  puts("NO")
#define No  puts("No")
#define ALL(v) (v).begin(), (v).end()
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
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 (a>b) { a=b; return 1; } return 0; }

/*
#define mod 1000000007 /*/
#define mod 998244353 //*/

typedef pair<int, int> P;
#define INF (1LL<<60)


void solve(){
    int R, C, K;
    cin >> R >> C >> K;
    auto dp = make_v<int>(R,C,4);
    auto v = make_v<int>(R,C);
    fill_v(dp,0);
    fill_v(v,0);
    rep(i,K){
        int r, c, vv;
        cin >> r >> c >> vv;
        r--; c--;
        v[r][c] = vv;
    }
    if(v[0][0]>0)
        dp[0][0][1] = v[0][0];
    rep(i,R)rep(j,C)rep(k,4){
        // 同じ行の移動
        if(j>=1){
            chmax(dp[i][j][k], dp[i][j-1][k]);
            if(k>=1 && v[i][j]>0)
                chmax(dp[i][j][k], dp[i][j-1][k-1] + v[i][j]);
        }
        // 違う行への移動
        if(i>=1){
            chmax(dp[i][j][0], max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]}));
        if(v[i][j]>0)
                  chmax(dp[i][j][1], max({dp[i-1][j][0],dp[i-1][j][1],dp[i-1][j][2],dp[i-1][j][3]}) + v[i][j]);
        }
    }
    int ans = 0;
    rep(k,4) chmax(ans, dp[R-1][C-1][k]);
    cout << ans << endl;
}


signed main(){
    cout << fixed << setprecision(18);
    cerr << fixed << setprecision(18);
    solve();
}


Measured memory_bytes: 706064
S = str(input())
N = len(S) + 1

ans = 0

con = 0
x = S[0]
i = 0
while x != "<":
  con += 1
  x = S[i]
  if x == ">":
    i += 1
  if i == N-1:
    x = "<"
ans += con * (con - 1) / 2

#print(i , N)
if i == N-1:
  ans += con
  print(int(ans))
  quit()
  
#print(i)
mae = 0
con = 1
x = "<"
i += 1
#print(i,N)
while i < N - 1:
  if S[i] == x:
    #print(i)
    con += 1
  else:
    ans += con * (con-1)/2
    if S[i] == ">":
      mae = con
    else:
      ans += max(con, mae)
      mae = 0
    con = 1
    x = S[i]
    #print(ans, i, con, mae)
  i += 1
#print(ans, con)
ans += con * (con-1)/2 
#print(ans)
ans += max(con, mae)

print(int(ans))

Measured memory_bytes: 42952
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::deque<int> a;
    for (int i = 0; i < n; i++) {
        int in;
        std::cin >> in;
        if (i % 2) a.push_front(in);
        else a.push_back(in);
    }

    if (n % 2) std::reverse(a.begin(), a.end());

    for (auto e : a) std::cout << e << " ";
    std::cout << std::endl;

    return 0;
}


Measured memory_bytes: 2944
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.nextLine());
		String s = sc.nextLine();
		sc.close();

		String[] spl = s.split(" ");
		int[] Wi = new int[spl.length];
		int sum1 = 0;
		int sum2 = 0;

		for(int i = 0;i < Wi.length;i++){
			Wi[i] = Integer.parseInt(spl[i]);
			sum1 += Wi[i];
		}

		int abs = sum1;

		for(int i = 0;i < Wi.length;i++){
			sum1 -= Wi[i];
			sum2 += Wi[i];
			if(abs > Math.abs(sum1 - sum2)){
				abs = Math.abs(sum1 - sum2);
			}
		}
		System.out.println(abs);
	}
}

Measured memory_bytes: 23892
#include <stdio.h>
#include <string.h>
int main()
{
    int n;
    int a[3];
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        int a=n/100;
        int b=n%100/10;
        int c=n%10;
        if(100*c+10*b+a==n)
            printf("Yes\n");
        else
            printf("No\n");

    }


    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL<<60;
#define all(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0; i<(n);++i)
#define FOR(i,k,n) for(int i=(k);i<(n);++i)

int main(){
    int H, W; cin >> H >> W;
    vector<vector<int>> A(H,vector<int>(W)),B(H,vector<int>(W)),C(H,vector<int>(W));
    REP(i,H)REP(j,W) cin >> A[i][j];
    REP(i,H)REP(j,W) cin >> B[i][j];
    REP(i,H)REP(j,W)C[i][j]=A[i][j]-B[i][j];
    vector<vector<bitset<25605>>> dp(H, vector<bitset<25605>>(W));
    dp[0][0].set(abs(C[0][0]));
    REP(i,H)REP(j,W)REP(k,25605){
        if(i+1<H && dp[i][j][k]) {
            dp[i+1][j].set(abs(k+C[i+1][j]));
            dp[i+1][j].set(abs(k-C[i+1][j]));
        }
        if(j+1<W && dp[i][j][k]) {
            dp[i][j+1].set(abs(k+C[i][j+1]));
            dp[i][j+1].set(abs(k-C[i][j+1]));
        }
    }
    int ans = 25605;
    REP(i,25605){
        if(dp[H-1][W-1][i]) {ans = i; break;}
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 20736
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Queue;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	
	//for(int i=0;i<N;i++) {}
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		int A=sc.nextInt();
		
		
		p(3*A*A);
		
		
	}
	

	
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	static String nextPermutation(String s) {
		ArrayList<Character> list=new ArrayList<>();
		for(int i=0;i<s.length();i++) {
			list.add(s.charAt(i));
		}
		int pivotPos=-1;
		char pivot=0;
		for(int i=list.size()-2;i>=0;i--) {
			if(list.get(i)<list.get(i+1)) {
				pivotPos=i;
				pivot=list.get(i);
				break;
			}
		}
		if(pivotPos==-1&&pivot==0) {
			return "Final";
		}
		int L=pivotPos+1,R=list.size()-1;
		
		
		
		int minPos=-1;
		char min =Character.MAX_VALUE;
		
		for(int i=R;i>=L;i--) {
			if(pivot<list.get(i)) {
				if(list.get(i)<min) {
					min=list.get(i);
					minPos=i;
				}
			}
		}
		
		Collections.swap(list, pivotPos, minPos);
		Collections.sort(list.subList(L, R+1));
		
		
		StringBuilder sb=new StringBuilder();
		for(int i=0;i<list.size();i++) {
			sb.append(list.get(i));
		}
		return sb.toString();
	}
}
	


Measured memory_bytes: 21844
using namespace std;
#define ll long long
#include<bits/stdc++.h>
int main()
{
	ll n;
	cin>>n;
	ll wa=0;ll ac=0;ll tle=0;ll re=0;
	for(ll i=0;i<n;i++)
	{
		string s;
		cin>>s;
		if(s=="AC")
		ac++;
		else if(s=="WA")
		wa++;
		else if(s=="TLE")
		tle++;
		else if(s=="RE")
		re++;
		
	}
	cout<<"AC"<<" "<<"x"<<" "<<ac<<endl;
	cout<<"WA"<<" "<<"x"<<" "<<wa<<endl;
	cout<<"TLE"<<" "<<"x"<<" "<<tle<<endl;
	cout<<"RE"<<" "<<"x"<<" "<<re<<endl;
	return 0;
	
}	

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

using namespace std;

typedef long long ll;

long long n;

int main() {
    cin >> n;
    for (ll i = 1; i <= 3500; i++)
    for (ll j = 1; j <= 3500; j++)
    {
        ll num = -n*i*j;
        ll den = n*j + n*i - 4*i*j;
        if (den == 0) continue;
        if (num % den != 0) continue;
        if (num / den <= 0) continue;
        cout << i << ' ' << j << ' ' << num / den << '\n';
        return 0;
    }
    return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

#define lf double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

#define INF 1e10

using namespace std;
using edge = tuple<int, int, int>;

int n, m, p;
vector<vi> adj;
vector<edge> edges;
vector<bool> seen;

void dfs(int v)
{
	seen[v] = true;
	for(auto u:adj[v]){
		if (seen[u]) continue;
		dfs(u);
	}
}

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>n>>m>>p;
	adj.resize(n+1);
	edges.resize(m);
	seen.resize(n+1);
	rep(i, m){
		int a, b, c; cin>>a>>b>>c;
		edges[i] = make_tuple(a, b, c-p);
		adj[a].pb(b);
	}

	set<int> Set;
	for(int v=1; v<=n; v++){
		fill(all(seen), false);
		dfs(v);
		if (seen[n]==true){
			Set.ins(v);
		}
	}

	bool loop = false;
	vll dist(n+1, -INF);
	dist[1] = 0;
	for(int i=1; i<=n; i++){
		for(int j=0; j<m; j++){
			int from, to, score;
			tie(from, to, score) = edges[j];
			if (dist[from]!=-INF && dist[to] < dist[from]+score){
				dist[to] = dist[from]+score;
				if (i==n && Set.find(to)!=Set.end()) loop = true;
			}
		}
	}
	if (loop){
		cout << "-1\n";
	}else{
		cout << max(0ll, dist[n]) << "\n";
	}

	return 0;
}

Measured memory_bytes: 640
var n,i,j,s:integer;
begin
	read(n);
	s:=1;
	for i:=2 to 32 do
	begin
		j:=i*i;
		while j<=n do
		begin
			if s<j then s:=j;
			j:=j*i;
		end
	end;
	writeln(s)
end.

Measured memory_bytes: 128
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int a[1010];
    rep(i, N) cin >> a[i];
    vector<int> v;
    rep(i, N) {
        int sum = 0;
        REP(j, i, N - 1) {
            sum += a[j];
            v.push_back(sum);
        }
    }
    int ans = 0;
    RREP(i, 50, 0) {
        vector<int> nx_v;
        rep(j, v.size()) {
            if (v[j] & (1LL << i)) nx_v.push_back(v[j]);
        }
        if(nx_v.size() < K) continue;
        ans += (1LL << i);
        v = nx_v;
    }
    cout << ans << endl;


    return 0;
}
// 010, 101, 010, 101


Measured memory_bytes: 6512
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
#include<list>
#include <numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
//const int mod=(int)998244353;
const llint big=(llint)(2.19e16)+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
using pli=pair<llint,int>;
using daic=priority_queue<pli,vector<pli>,greater<pli>>;
int main(void){
	int n,K,i;cin>>n>>K;
	int nn=n,kk=K;
	string s;cin>>s;
	deque<char> str;
	for(i=0;i<n;i++){str.pub(s[i]);}
	auto debag=str;
	bool ki=false;
	if(n%2==1){
		ki=true;
		if(str[0]=='A'){K--;}
		n--;
		str.pof();
	}
	while(K>=10&&str.size()>0){
		//AB 4
		//BA 2
		//AA 3
		//BB 3
		//(なんでこれが成立するのかよくわかってない)
		if(str[0]=='A'&&str[1]=='B'){
			if(!ki){K-=4;}else{K-=2;}str.pof();str.pof();}
		else if(str[0]=='A'&&str[1]=='A'){
			K-=3;str.pof();str.pof();}
		else if(str[0]=='B'&&str[1]=='B'){
			K-=3;str.pof();str.pof();}
		else if(str[0]=='B'&&str[1]=='A'){
			if(!ki){K-=2;}else{K-=4;}str.pof();str.pof();}
	}
	if(ki){str.puf('B');}
	int m=str.size();
	if(str.size()==0){K=0;}
	if(str.size()==1){K%=2;}
	while(K>0&&str.size()>0){
		int bas=0,mki=1;
		while(bas!=-1&&bas!=m){
			if(str[bas]=='A'){
				str[bas]='B';
				mki=-mki;
				bas+=mki;
			}else{
				str[bas]='A';
				bas+=mki;
			}
		}K--;
	}
	while(str.size()<nn){str.pub('B');str.pub('A');}
	string ans;
	for(auto it:str){ans.pub(it);}
	cout<<ans<<endl;
	RE;
}

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

int main() {
  double a,b,n;

  cin >> a >> b >> n;
  
  double check =0;

  int ans=0;

  if(n>=b-1) {
      check = b-1;
      double ax = a*check;
      double bb = ax/b;
      double cc = check/b;
      ans = floor(bb) - a*floor(cc);
      cout << ans << endl;
      return 0;
  }

  else{
      double ax = a*n;
      double bb = ax/b;
      double cc = n/b;
      ans = floor(bb) - a*floor(cc);
      cout << ans << endl;
      return 0;
  }



 







}

Measured memory_bytes: 3844
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
long long N;

int DFS(long long x){
  bool check3=false, check5=false, check7=false;
  long long y = x;
  int cnt = 0;
  while(y>0){
    if(y%10==3)  check3=true;
    if(y%10==5)  check5=true;
    if(y%10==7)  check7=true;
    y /= 10;
  }
  if(check3 && check5 && check7) cnt++;
  if((10*x+3)<=N) cnt+=DFS(10*x+3);
  if((10*x+5)<=N) cnt+=DFS(10*x+5);
  if((10*x+7)<=N) cnt+=DFS(10*x+7);
  return cnt;
}  
    

int main(){
  cin >> N;
  cout << DFS(0);
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
using namespace std;

void Factorization(int v){
	int k = 2;
	while (v != 1 && k <= sqrt((double) v)){
		if (v % k == 0){
			v = v / k;
			if(v == 1){
				cout<<" "<<k;
				return;
			}
			Factorization(k);
			k = 2;
		}
		else
			k++;
	}
	cout<<" "<<v;
}

int main(){
	int n;
	cin>>n;
	cout<<n<<":";
	Factorization(n);
	cout<<endl;
	return 0;
}

Measured memory_bytes: 3092
'use strict'
function Main(input) {
	const a = parseInt(input.slice(0,2));
	const b = parseInt(input.slice(2,4));
  	let ans = "";
  	let has_monthpotential_a = false;
    let has_monthpotential_b = false;
  	if(a > 0 && a <= 12){
    	has_monthpotential_a = true;
    }
    if(b > 0 && b <= 12){
    	has_monthpotential_b = true;
    }
	if((has_monthpotential_a === true) && (has_monthpotential_b === false)){
	    ans = "MMYY";
    } else if((has_monthpotential_a === false) && (has_monthpotential_b === true)){
      	ans = "YYMM";
    } else if((has_monthpotential_a === true) && (has_monthpotential_b === true)){
        ans = "AMBIGUOUS";
    } else if((has_monthpotential_a === false) && (has_monthpotential_b === false)){
        ans = "NA";
    }
    
    console.log('%s', ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 9420
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr long double EPS = 1e-8;

long long int N, M, K, L, R, H, W;
//int N, M, K, L, R, H, W;


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

	cin >> N;
	vector<long long int>v(N);
	for (auto &i : v)cin >> i;
	M = (N & 1) + 1;
	if (N == 2) {
		cout << max(v[0], v[1]) << endl;
		return 0;
	}
	vector<vector<long long int>>dp(N, vector<long long int>(M + 1, -MOD * MOD));
	if (N & 1) {
		dp[0][2] = v[0];
		dp[1][1] = v[1];
		dp[2][0] = v[2];
		dp[2][2] = v[0] + v[2];
	}
	else {
		dp[0][1] = v[0];
		dp[1][0] = v[1];
		dp[2][1] = v[0] + v[2];
	}
	long long int ans = -MOD * MOD;
	for (int i = 3; i < N; i++) {
		for (int j = 0; j <= M; j++) {
			for (int k = 0; k <= j; k++) {
				int a = i - 2 - (j - k);
				if (a < 0)continue;
				dp[i][k] = max(dp[i][k], dp[a][j] + v[i]);
		//			cout << i << " " << k << " " << dp[i][k] << endl;
			}
		}
	}
	for (int i = N - 3; i < N; i++) {
		//cout << i << " " << M - N + i + 1 << endl;
		if (M - N + i + 1 >= 0) {
			for (int j = 0; j <= M - N + i + 1; j++) {
				if (i == N - 1 && j == M && j == 2)continue;
				if (i == N - 3 && j == 0 && M == 2)continue;
				ans = max(ans, dp[i][j]);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 15580
s = input()
n = int(input())
ans = "zzzzz"
anslist = set()
for i in range(0,5):
    for j in range(0,5):
        if i < j <= len(s):
            if i != 0:
                anslist.add(s[-j:-i])
            else:
                anslist.add(s[-j:])
for i in range(len(s)-5):
    if s[i:i+5] < ans:
        ans = s[i:i+5]
for i in range(1, 6):
    anslist.add(ans[0:i])
anslist = list(anslist)
anslist.sort()
print(anslist[n-1])

Measured memory_bytes: 3064
H, W, K = map(int, input().split())
L = []
for _ in range(H):
    s = input()
    row = []
    for j in range(len(s)):
        row.append(s[j])

    L.append(row)
# print(L)

ans = [[0] * W for _ in range(H)]
# ans[0][1] = 1
# print(ans[0][1])

color = 1
count = 0
for i in range(H):
    if '#' not in L[i]:
        for j in range(W):
            ans[i][j] = -1
        continue
    else:
        idx = 0
        while idx < W:
            count += 1
            # print(ans[i][idx])
            if L[i][idx] == '.':
                # print(ans[i][idx])
                ans[i][idx] = color

                # print(ans, i, idx)
                idx += 1
            else:
                # print(ans[i][idx])
                ans[i][idx] = color
                # print(ans, i, idx)
                if ('#' in L[i][idx + 1:]):
                    color += 1
                idx += 1
    color += 1

new_ans = []
count = 0
for v in ans:
    if -1 in v:
        count += 1
        continue

    if count != 0 and -1 not in v:
        new_ans.append(v)
        while count > 0:
            new_ans.append(v)
            count -= 1

    elif count == 0 and -1 not in v:
        new_ans.append(v)


if count != 0:
    while count > 0:
        new_ans.append(new_ans[-1])
        count -= 1


for i in new_ans:
    print(*i)


Measured memory_bytes: 13376
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
typedef long long ll;
const int mod=1e9+7;
ll a[maxn],dp[maxn];
int main()
{
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		ll w;
		cin>>w;
		a[w]=1;
	}
	dp[0]=1;dp[1]=a[1]?0:1;
	for(int i=2;i<=n;i++)
	{
		if(!a[i])
		{
			dp[i]=(dp[i]+dp[i-1])%mod;
			dp[i]=(dp[i]+dp[i-2])%mod;
		}
	}
	cout<<dp[n]%mod;
	return 0;
}

Measured memory_bytes: 1792
import sys
from collections import defaultdict

N = int(input())

memo = defaultdict(int)

for i in range(N):
    tmp = input()
    memo[tmp] += 1
    if i==0:
        last = tmp[-1]
        continue
    if memo[tmp]==2:
        print("No")
        sys.exit()
    else:
        if last != tmp[0]:
            print("No")
            sys.exit()
        last = tmp[-1]
else:
    print("Yes")

Measured memory_bytes: 9464
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
int intlog(int a, int k){
  int ans = 0;
  while(a%k==0){
    a /= k;
    ans++;
  }
  return ans;
}
int main(){
  int N, M; set<int> A; set<int> prm;
  cin >> N >> M;
  int index_2 = 0;
  RPT(i,0,N){
    int a; cin >> a;
    if(i==0) { A.insert(a/2); index_2=intlog(a/2,2); continue; }
    if( index_2!=intlog(a/2,2) ){ cout << 0 << endl; return 0; }
    A.insert(a/2);
  }
  FOR(i,2,100005){
    int flg = 1;
    for(auto x : prm){
      if(i%x==0){flg = 0; break;}
      if(x*x>i) break;
    }
    if(flg) prm.insert(i);
  }
  map<int,int> Xmin;ll Tmin=1;
  for(auto b : A){
    int a = b;
    for(auto x: prm){
      int cnt = intlog(a,x);
      if( cnt != 0){
        RPT(j,0,cnt) a /= x;
      }
      if(Xmin[x]<cnt) {RPT(ii,0,cnt-Xmin[x])Tmin*=x;Xmin[x] = cnt;}
      if(a == 1) break;
    }//cout << a  << " "<<b << endl;
    if(a != 1) {prm.insert(a); if(Xmin[a]<1) {RPT(ii,0,1-Xmin[a])Tmin*=a;Xmin[a] = 1;} }
  }//cout << Tmin << "=";for(auto x : prm){ if(Xmin[x]!=0) cout << x << "^" << Xmin[x] << " ";}cout << endl;
  if(Tmin>M || Tmin < 0) {cout << 0 << endl; return 0;}
  ll l_ = 0, r_ = ( (Tmin+M-1)/2/Tmin + 20);
  while(r_-l_>1){
    ll mid_ = (l_ + r_) / 2;
    if( Tmin*(2*mid_+1) > M ) r_ = mid_;
    else l_ = mid_;
  }
  cout << (l_+1) << endl;
  return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <climits>
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define in insert
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define f first
#define s second
#define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
#define int ll
#define sz(x) (ll)x.size()
#define all(x) (x.begin(),x.end())
using namespace std;

 
const ll INF = 1e12;
const ll N =(1e3+5); // TODO : change value as per problem
const ll MOD = 1e9+7;

char a[N][N],b[N][N];
void solve(){
	int n,m;
	cin>>n>>m;	
	for(int i =1;i<=n;i++)
		for(int j = 1;j<=m;j++)
			cin >> a[i][j];
	for(int i = 1;i<=(2*n);i++){
		for(int j = 1;j <=m;j++){
			b[i][j] = a[(i + 1)>>1ll][j];
		}
	}
	for(int i =1;i<=(2*n);i++){
		for(int j =1;j<=m;j++){
			cout<<b[i][j];
		}
		cout<<endl;
	}
}
signed main(){
 
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
     // freopen(".in","r",stdin);freopen(".out","w",stdout);
    
     ll tt=1;   
     // cin >> tt;
    while(tt--){    
        solve();
    }    
}

Measured memory_bytes: 3868
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	int cou = 0;
	x -= z;
	while (1) {
		x = x - y - z;
		if (x < 0) {
			break;
		}
		cou++;
	}
	cout << cou << endl;
}

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

using namespace std;

int main() {
  int64_t H, W;
  cin >> H >> W;
  if (W == 1 || H == 1) {
    cout << 1 << endl;
  } else if (W % 2 == 0 || H % 2 == 0) {
    cout << (W * H / 2) << endl;
  } else {
    int64_t majority = (W + 1) / 2;
    int64_t minority = majority - 1;
    int64_t majo_line = (H + 1) / 2;
    int64_t mino_line = majo_line - 1;
    cout << (majority * majo_line + minority * mino_line) << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int flag = 0;
	for(int i = 1; i <= n; i++){
		int t,x,y;
		cin>>t>>x>>y;
		if(x+y > t) flag = 1;
		if((t-x-y)%2 == 1) flag = 1;
	}
	if(flag) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if(N <= 1){
			System.out.println(1);
			return;
        }
        long dp[] = new long[N];
        dp[0] = 1;
        dp[1] = 1;
        System.out.println(fib(dp, N));
    }
    private static long fib(long[] dp, int n){
        long fib1 = dp[n-1] != 0 ? dp[n-1] : fib(dp, n-1);
        long fib2 = dp[n-2] != 0 ? dp[n-2] : fib(dp, n-2);
        dp[n-1] = fib1;
        dp[n-2] = fib2;
        return fib1 + fib2;
    }
}


Measured memory_bytes: 26200
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>

using namespace std;

int sumdigit(int x) {
	int sum = 0;
	while (x > 0) {
		sum += x % 10;
		x /= 10;
	}

	return sum;
}

int main() {

	int n;
	cin >> n;

	int ans = 1000000;

	for (int i = 1; i < n; i++) {
		int a = i;
		int b = n - i;

		int sum2 = sumdigit(a) + sumdigit(b);

		ans = min(ans, sum2);

	}

	cout << ans << endl;

return 0;
}




Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>
int main(void)
{
  signed long long int a;
  signed long long int total=100;
  int count=0;
  scanf("%lld",&a);
  while(total <= a)
  {
     total = total * 1.01;
     count++;
     /**
     printf("%ld\n",total);
     **/
     if(total >= a)
     {
       printf("%d",count);
       break;
     }
  }
 
  return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		long n = Long.parseLong(sc.next());

		int c = 'a';

		StringBuilder sb = new StringBuilder();
		while (n != 0) {
			long remainder = (n - 1) % 26;
			sb.append((char) (c + remainder));

			n = (n - remainder + 1) / 26;
		}

		System.out.println(sb.reverse());
	}

}


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

int main() {
  ll l, r;
  cin >> l >> r;
  r = min(r, l+4038);
  int ans = 2018;
  for (ll i = l; i <= r; i++) {
    for (ll j = i+1; j <= r; j++) {
      int x = i*j%2019;
      ans = min(ans, x);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main()
{
	bool flag1 = false;
	string s;
	cin >> s;
	if (s.size() != 26) {
		for (char i = 'a'; i <= 'z'; i++) {
			flag1 = false;
			for (int j = 0; j < s.size(); j++) {
				if (s[j] == i)flag1 = true;
			}
			if (flag1 == false) {
				s += i;
				cout << s << endl;
				return 0;
			}
		}
	}
	else if(s=="zyxwvutsrqponmlkjihgfedcba"){
		cout << "-1" << endl;
		return 0;
	}
	else {
		for (int i = 25; i > 0; i--) {
			if (s[i-1] < s[i]) {
				for (int j = 25; j >= i;j--) {
					if (s[j] > s[i - 1]) {
						cout << s.substr(0, i - 1) << s[j] << endl;
						return 0;
					}
				}
			}
		}
	}
    return 0;
}

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

int dx[2][6] = {{1,0,1,0,-1,-1},{1,1,0,-1,-1,0}};
int dy[2][6] = {{0,1,1,-1,0,1},{0,-1,-1,-1,0,1}};
int w,h,map[100][100];

void dfs(int x,int y){
  if(x<0||x>=h||y<0||y>=w||map[x][y]!=0) return;
  else{
    map[x][y] = -1;
    for(int i=0;i<6;i++) dfs(x+dx[x%2][i],y+dy[x%2][i]);
    return;
  }
}

int main(){
  scanf("%d %d",&w,&h);
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      scanf("%d",&map[i][j]);
    }
  }
  for(int i=0;i<h;i++) dfs(i,0);
  for(int i=0;i<h;i++) dfs(i,w-1);
  for(int i=0;i<w;i++) dfs(0,i);
  for(int i=0;i<w;i++) dfs(h-1,i);
  int ans = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(map[i][j]>0){
        for(int k=0;k<6;k++){
          if(i+dx[i%2][k]<0||i+dx[i%2][k]>=h||j+dy[i%2][k]<0||j+dy[i%2][k]>=w||map[i+dx[i%2][k]][j+dy[i%2][k]]<0){
            ans++;
          }
        }
      }
    }
  }
  printf("%d\n",ans);
  return 0;
}

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

using namespace std;

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

    vector<bool> isAC(n, false);
    vector<int> cntWA(n, 0);
    for (int i = 0; i < m; ++i) {
        int p;
        string s;
        cin >> p >> s;
        p--;

        if (s == "AC") {
            isAC[p] = true;
        } else if (isAC[p] == false) {
            cntWA[p]++;
        }
    }

    int ac = 0, wa = 0;
    for (int i = 0; i < n; ++i) {
        if (isAC[i] == true) {
            ac++;
            wa += cntWA[i];
        }
    }

    cout << ac << " " << wa << endl;
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <algorithm>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ass 1e18
#define MOD 1000000007
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define debug(x) cout << #x << ": " << x << endl;
#define debug2(x,y) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<< endl;
#define debug3(x,y,z) cout<<#x<<": "<< x<< ", "<< #y<< ": "<< y<<" "<<#z<<" : "<<z<< endl;
using namespace std;
typedef long long int ll;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
vector<ll>v[101];
ll dp[3000000],n;

ll dfs(ll x,ll bit)
{
	ll tmp,i,sum=0;
	if(dp[bit]!=-1)
		return dp[bit];
	if(x==n)
		return 1;
	for(i=0;i<v[x].size();i++)
	{
		tmp=1<<v[x][i];
		if(!(tmp&bit))
			sum=(sum+dfs(x+1,tmp|bit)%MOD)%MOD;
	}	
	dp[bit]=sum;
	return dp[bit];
}

int main()
{
	ll i,a,b,j;
	boost
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++)
	{
		for(j=0;j<n;j++)
		{
			cin>>a;
			if(a==1)
				v[i].pb(j);
		}
	}
	cout<<dfs(0,0);
	return 0;
}


Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long i,j,t,a,b,n,temp;
    t=1;
    // cin>>t;
    while(t--)
    {
       cin>>i>>a>>b;
       a=b-a;
       if(a>i)cout<<"dangerous";
       else if(a<=0)cout<<"delicious";
       else cout<<"safe";
    }
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    string S;
    long long K,i,n;
    cin>>S>>K;
    n=S.length();
    for(i=0;i<n&&i<K;i++){
        if(S[i]!='1'){
            cout<<S[i]<<endl;
            return 0;
        }
    }
    cout<<'1'<<endl;
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	int c1,c2,c3;
	int m[11]={0};
	int sum;
	while(~scanf("%d %d %d",&c1,&c2,&c3)){
		for(int i=1;i<11;i++) m[i]=0;
		m[c1]=m[c2]=m[c3]=1;
		sum=0;
		for(int i=1;i<11;i++){
			if(m[i]!=1&&c1+c2+i<=20){
				sum++;
			}
		}
		if(sum>3){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	return 0;
}

Measured memory_bytes: 0
// 有點不耐煩會破壞偉大的計劃

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 1e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e14 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9, PI = acos(-1);
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug() {
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main() {
//    freopen(".in", "r", stdin);
//    freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, x; cin >> n >> x;

    vector<long long> a(n);

    for(long long i = 0; i < n; i++) {
        cin >> a[i];
    }

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

    long long ans = 0, last = 0;

    for(long long i = 0; i < n; i++) {
        if(x >= a[i]) {
            ans++;
            x -= a[i];
            last = 1;
        }
        else {
            last = 0;
        }
    }

    cout << max(0ll, ans - (x > 0 && last));

    return 0;
}


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

using namespace std;

int main()
{
	int n, m;
	int num = 0;
	int count = 0;
	cin >> n >> m;
	vector<vector<int>> item = vector<vector<int>>(n,vector<int>(m+1,0));
	
	for (int i = 0; i < n;i++)
	{
		cin >> item[i][0];
		for (int j = 0;j < item[i][0];j++)
		{
			cin >> item[i][j+1];
		}
	}
	vector<int> ans(m,0);
	for(int i = 0;i < n;i++)
	{
		for (int j = 0;j < item[i][0];j++)
		{
			ans[item[i][j + 1]-1]++;
		}
	}
	for (int i : ans)
	{
		if (i == n)
		{
			count++;
		}
	}

	cout << count << endl;

	return 0;
}

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

using ll = long long;
using ld = long double;

int main() {

  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i <= n; i++) {
    bool ok = true;
    int x;
    cin >> x;
    ok &= (i & 1);
    ok &= (x & 1);
    ans += ok;
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
using lint         = long long;
constexpr lint inf = 1LL << 60;
constexpr lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<lint> a(n);
    lint x = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    for (int i = 2; i < n; ++i) {
        x ^= a[i];
    }
    function<lint(lint, lint, lint)> dfs = [&](lint a, lint b, lint x) {
        if (((a & 1) ^ (b & 1)) != (x & 1))
            return inf;
        if (a == 1 || a == 0) {
            if ((a ^ b) == x)
                return 0LL;
            else
                return inf;
        }
        lint c = inf, d = inf;
        if (a != 0)
            c = dfs((a - 1) >> 1, (b + 1) >> 1, x >> 1) * 2 + 1;
        d = dfs((a) >> 1, (b) >> 1, x >> 1) * 2;
        return min({inf, c, d});
    };
    lint ret = dfs(a[0], a[1], x);
    if (ret == inf)
        cout << -1 << "\n";
    else
        cout << ret << "\n";
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,sum=1,mn;
    cin>>n>>mn;
    for(int i=2;i<=n;i++)
    {
        int num;
        cin>>num;
        if(num<=mn)
        {
            ++sum;
            mn=num;
        }
    }
    cout<<sum<<endl;
}


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

int main() {
  int N, K, s;
  cin >> N >> K;
  s = 0;
  
  for (int i = 0; i < N; i++) {
    int x, a;
    cin >> x;
    a = K - x;
    
    if (a <= x) {
      s += a;
    }
    
    else {
      s += x;
    }
    
  }
  
  cout << s * 2 << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
tp = []
L = []
for i in range(M):
    tp = [i] + list(map(int, input().split())) + [0]
    L.append(tp)
L.sort(key=lambda x: (x[1], x[2]))
c = 1
d = 0
for i in range(M):
    if d == L[i][1]:
        c += 1
        L[i][3] = c
    else:
        L[i][3] = 1
        c = 1
        d = L[i][1]
L.sort()
[print(str(L[i][1]).zfill(6) + str(L[i][3]).zfill(6)) for i in range(M)]


Measured memory_bytes: 40452
#include<stdio.h>

int main(void)
{
	int h,w,i,j,temp=1,s=0,t=0,t2;
	scanf("%d%d",&h,&w);
	char a[h][w+1];
	char ans[h][w];
	int d_hor[w];
	int d_ver[h];
	for(i=0;i<h;i++)
		scanf("%s",a[i]);
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(a[i][j]=='.')
				temp*=1;
			else
				temp*=0;
		}
		if(temp==1)
			d_ver[i]=1;
		else
			d_ver[i]=0;
		temp=1;
	}
	for(i=0;i<w;i++){
		for(j=0;j<h;j++){
			if(a[j][i]=='.')
				temp*=1;
			else
				temp*=0;
		}
		if(temp==1)
			d_hor[i]=1;
		else
			d_hor[i]=0;
		temp=1;
	}
	for(i=0;i<h;i++){
		if(d_ver[i]!=1){
			for(j=0;j<w;j++){
				if(d_hor[j]!=1){
					ans[s][t]=a[i][j];
					t++;
				}
			}
			t2=t;
			t=0;
			s++;
		}
	}
	for(i=0;i<s;i++){
		for(j=0;j<t2;j++)
			printf("%c",ans[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <algorithm>
#include <queue>
using namespace std;
int main() {
	int N;
	char c;
	scanf("%d", &N);
	bool adjmat[N][N];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			scanf(" %c", &c);
			if (c == '0') adjmat[i][j] = false;
			else adjmat[i][j] = true;
		}
	}
	int sp[N];
	fill_n(sp, N, -1);
	sp[0] = 0;
	queue<int> bfs;
	bfs.push(0);
	while (!bfs.empty()) {
		int x = bfs.front();
		bfs.pop();
		for (int i = 0; i < N; ++i) {
			if (adjmat[x][i]) {
				if (sp[i] == -1) {
					sp[i] = (sp[x] + 1) % 2;
					bfs.push(i);
				} else if (sp[i] % 2 == sp[x] % 2) {
					printf("-1");
					return 0;
				}
			}
		}
	}
	int FW[N][N];
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (adjmat[i][j]) FW[i][j] = 1;
			else FW[i][j] = 10000;
		}
	}
	for (int k = 0; k < N; ++k) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) FW[i][j] = min(FW[i][j], FW[i][k] + FW[k][j]);
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = 0; j < N; ++j) {
			if (i == j) continue;
			ans = max(ans, FW[i][j]);
		}
	}
	printf("%d", ans + 1);
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}
const int dy[4] = {-1, 0, 0, 1};
const int dx[4] = {0, -1, 1, 0};
int A[100010];

int main(int argc, char *argv[]){
    int n; cin >> n;
    rep(i, n) cin >> A[i + 1];
    int pre = 0;
    int c = 0;
    rep(i, n){
        c += abs(A[i + 1] - A[i]);
        // pre = A[i + 1];
    }
    c += abs(A[n]);
    rfor(i, 1, n + 1){
        int t = c + abs(A[i+1] - A[i-1]) - abs(A[i] - A[i-1]) - abs(A[i+1] - A[i]);
        cout << t << endl;
    }
    return 0;
}

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

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

    if (A == B && B == C) cout << "No" << endl;
    else if (A == B || A == C || B == C){
            if (A != B || A != C || B != C){
                cout << "Yes" << endl;
            }
    }
    else cout << "No" << endl;
}

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define ms(a, x) memset(a, x, sizeof(a))
#define F first
#define S second
#define all(x) (x).begin(),(x).end()

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 0x3f3f3f3f;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... Args> void rd(Args&... args) {((cin >> args), ...);}
template<typename... Args> void write(Args... args) { ((cout << args << " "), ...); cout<<endl;}

vector<int> a,ans;
const int N=2e5+5;
vector<int> G[N];
vector<int> lis;
void dfs(int u,int fa){
    int flag;
    int pos=lower_bound(all(lis),a[u])-lis.begin();
    if(pos==lis.size()) lis.push_back(a[u]),flag=-1;
    else flag=lis[pos],lis[pos]=a[u];
    ans[u]=lis.size();
    for(auto it:G[u]){
        if(it==fa) continue;
        dfs(it,u);
    }
    if(flag==-1) lis.pop_back();
    else lis[pos]=flag;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    a=ans=vector<int>(n+1);
    for1(i,n) cin>>a[i];
    forn(i,n-1){
        int x,y;
        cin>>x>>y;
        G[x].push_back(y);
        G[y].push_back(x);
    }
    dfs(1,-1);
    for1(i,n) cout<<ans[i]<<endl;
    return 0;
}



Measured memory_bytes: 27192
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
const long long INF = 1LL << 60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;
const ll MOD=1000000007;

int main(){
    int n, m; cin >> n >> m;
    ll dp[100100];
    rep(i, 100101) dp[i]=0;
    rep(i, m){
        ll b; cin >> b;
        dp[b]=-1;
    }

    dp[0]=1;

    reps(i, 0, n+1){
        if(dp[i]==-1){
            continue;
        }
        if(dp[i+1]!=-1){
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(dp[i+2]!=-1){
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    out(dp[n]);
}

Measured memory_bytes: 4396
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const int sz=1e3+100;
 
int main()
{
    Khela
    llu a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    while(cin>>n)
    {
        llu p=((n+1ll)*n)/2;
        p-=n;
        cout<<p<<endl;
    }





}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int h, a;
    cin >> h >> a;
    if(h % a != 0) cout << (h / a) + 1 << endl;
    else cout << h / a << endl;
    return 0;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main() {
    int A1,A2,A3;
    cin>>A1>>A2>>A3;
    cout<<max(abs(A2-A3),max(abs(A1-A2),abs(A1-A3)));
    return 0;
}

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

using namespace std;

int main() {
	while (1) {
		int m, f, r;
		cin >> m >> f >> r;

		if (m == -1 && f == -1 && r == -1) {
			break;
		}

		if (m == -1 || f == -1) {
			printf("F\n");
			continue;
		}

		int total = m + f;

		if (total >= 80) {
			printf("A\n");
		}
		else if (total >= 65) {
			printf("B\n");
		}
		else if (total >= 50) {
			printf("C\n");
		}
		else if (total >= 30) {
			if (r >= 50) {
				printf("C\n");
			}
			else {
				printf("D\n");
			}
		}
		else {
			printf("F\n");
		}
	}

	return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n;cin>>n;
    if (n%2)
    {
        cout << 0 << endl;
    }
    else
    {
        n /= 2;
        ll ans = 0;
        rep(i,30)
        {
            ll tmp_n = n;
            rep(j,i+1)
            {
                tmp_n /= 5;
            }
            ans += tmp_n;
        }
        cout << ans << endl;
    }
    
    
    
}




Measured memory_bytes: 256