akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>

#define mod 1000000007

using namespace std;
using ll = long long;

void solve() {
    int n;
    string s1, s2;
    ll ans = 1;
    cin >> n >> s1 >> s2;
    int state = 0;
    //1 = 前が縦長
    //2 = 前が横長
    for(int i = 0; i < n; i++){
        if(s1[i] == s2[i]){
            if(state == 0){
                ans *= 3;
            }else if(state == 1){
                ans *= 2;
            }else if(state == 2){
                ans *= 1;
            }
            state = 1;
        }else{
            if(state == 0){
                ans *= 6;
            }else if(state == 1){
                ans *= 2;
            }else if(state == 2){
                ans *= 3;
            }
            state = 2;
            i++;
        }
        ans = ans%mod;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

// Common memset settings
//memset(memo, -1, sizeof memo); // dp memoization with -1
//memset(arr, 0, sizeof arr); //clear array of integers




int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n;
	cin >> n;


	vector <int> arr(n);


	for(int i =0;i<n;i++)
		cin >> arr[i];


	int gcd = arr[0];

	for(int i =1;i<n;i++){
		gcd = __gcd(gcd, arr[i]);
	}

	cout << gcd;
	

	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }
 

ll N, M, Q;
vector<ll> A, B, C, D;

ll calc(vector<ll> &a)
{
	ll res{0};
	for (ll i = 0; i < Q; ++i)
		if (a[B[i]-1] - a[A[i]-1] == C[i]) res += D[i];
	return res;
}

void dfs(vector<ll> &a, ll &res)
{
	if ((ll)a.size() == N)
	{
		// std::cout << a << std::endl;
		res = max(res, calc(a));
		return;
	}

	ll ba = a.back();
	for (ll add = ba; add <= M; ++add)
	{
		a.push_back(add);
		dfs(a, res);
		a.pop_back();
	}
}

int main(int argc, char **argv)
{
	cin >> N >> M >> Q;
	A.resize(Q);
	B.resize(Q);
	C.resize(Q);
	D.resize(Q);

	for (ll i = 0; i < Q; ++i) cin >> A[i] >> B[i] >> C[i] >> D[i];
	vector<ll> a;
	ll res{0};
	for (ll i = 1; i <= M; ++i)
	{
		a.push_back(i);
		dfs(a, res);
		a.pop_back();
	}
	std::cout << res << std::endl;
}


Measured memory_bytes: 3600
/*
  AOJ 1327
  Title:One-Dimensional Cellular Automaton
  @kankichi573
*/
#include <stdio.h>
#include <string.h>
int a,b,c,m,n,t,s[50],s1[50];
int mat[50][50];
int mat2[50][50];

void matrix_mult(int matx[50][50],int maty[50][50],
		 int matz[50][50],int n,int m)
{
  int i,j,k;

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      matz[i][j]=0;

  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      for(k=0;k<n;k++)
	{
	  matz[i][j] += (matx[i][k]*maty[k][j]);
	  matz[i][j] %= m;
	}
}
void matrix_vector_mult(int mat[50][50],int vect[50],
			int vect1[50],int n,int m)
{
  int i,j;
  memset(vect1,0,sizeof(int)*n);
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      {
	vect1[i]+=mat[i][j]*vect[j];
	vect1[i] %= m;
      }
}
void make_matrix(int mat[50][50],int a,int b,int c,int n)
{
  int i,j;
  
  for(i=0;i<n;i++)
    for(j=0;j<n;j++)
      mat[i][j]=0;

  mat[0][0]=b;
  mat[0][1]=c;
  for(i=1;i<n-1;i++)
    {
      mat[i][i-1]=a;
      mat[i][i]=b;
      mat[i][i+1]=c;
    }
  mat[n-1][n-2]=a;
  mat[n-1][n-1]=b;
}

dump(int s[],int n)
{
  int i;
      
  for(i=0;i<n;i++)
    {
      printf("%d",s[i]);
      if(i<n-1)
	printf(" ");
      else
	printf("\n");
    }
}

dump_matrix(int mat[50][50],int n)
{
  int i,j;
      
  for(i=0;i<n;i++)
    {
      for(j=0;j<n;j++)
	printf("%d|",mat[i][j]);
      printf("\n");
    }
}

main()
{
  int i;
  while(scanf("%d %d %d %d %d %d",&n,&m,&a,&b,&c,&t) && (n||m||a||b||c||t))
    {
      make_matrix(mat,a,b,c,n);
      //dump_matrix(mat,n);

      for(i=0;i<n;i++)
	scanf("%d",&s[i]);
      
      while(t)
	{
	  if(t & 1)
	    {
	      matrix_vector_mult(mat,s,s1,n,m);
	      memcpy(s,s1,n*sizeof(int));
	    }

	  matrix_mult(mat,mat,mat2,n,m);
	  //dump_matrix(mat2,n);
	  memcpy(mat,mat2,sizeof(mat));
	  t >>= 1;
	}
      
      dump(s,n);
    }
  return(0);
}

Measured memory_bytes: 644
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a,b,c,e=0,f,g,h;
  cin>>a>>b>>c;
  vector<int> d(a);
  for(int i=0;i<a;i++)
    cin>>d.at(i);
  for(int i=0;i<a-1;i++){
    f=d.at(i);
    g=d.at(i+1);
    h=g-f;
    if(b*h<=c)
      e+=b*h;
    else
      e+=c;
  }
  cout<<e<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
const int inf = (1<<30);

int main() {
  int N, T; cin >> N >> T;
  vector<int> a(N);
  vector<int> cmax(N);
  int ans = 0;
  int profit = 0;
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
    cmax[i] = a[i];
  }
  for(int i = N-1; i >= 0; --i) {
    if(i+1 < N) chmax(cmax[i], cmax[i+1]);
  }

  for(int i = 0; i < N; ++i) {
    if(chmax(profit, cmax[i] - a[i])) ans = 0;
    if(profit == cmax[i] - a[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}


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

const int maxn = 600000;
static int dp[maxn];

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;

    int last = -1;
    for (int i = 2; i < N; i++) {
        dp[i] = dp[i - 1];
        if (s[i - 2] == '1' and s[i - 1] == '0' and s[i] == '1') {
            last = i - 2;
            for (int j = i - 2; j >= 0; j--) {
                if (s[j] == '0') break;
                int val = (j - 1 >= 0) ? dp[j - 1] : 0;
                dp[i] = max(dp[i], val + i - j - 1);
            }
        } else if (s[i] == '0') {
            last = -1;
        }
        // cerr << "i: " << i << " last: " << last << endl;

        /*
        cerr << "totyuu: " << endl;
        cerr << "i: " << i << " dp[i] " << dp[i] << endl;
        */

        if (last >= 0) {
            int val = (last - 1 >= 0) ? dp[last - 1] : 0;
            dp[i] = max(dp[i], val + i - last - 1);
        }
    }
    /*
    for (int i = 0; i < N; i++) {
        cerr << "i: " << i << " dp[i] " << dp[i] << endl;
    }
    */
    cout << dp[N - 1] << endl;

    return 0;
}

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

int main()
{
  int N;
  string S;
  cin >> N >> S;
  stack<char> s;
  for(int i = 0; i < (int)S.size(); ++i){
    if(s.empty()){
      if(S[i] == ')'){
        S.insert(0,"(");
        i++;
      }else{
        s.push(S[i]);
      }
    }else{
      if(S[i] == ')'){
        s.pop();
      }else{
        s.push(S[i]);
      }
    }
  }
  for(int i = 0; i < (int)s.size(); ++i) S += ")";
  cout << S << endl;
}

Measured memory_bytes: 256
count = 0
input_a = ""
input_m = ""
STDIN.each_line {|line|
  if count == 0 || count == 2
    count += 1
    next
  end

  if count == 1
    input_a = line
  end

  if count == 3
    input_m = line
  end
  count += 1
}


$input_a_list = input_a.split(" ")
$n = $input_a_list.length
input_m_list = input_m.split(" ")
$check = {}
$memo = {}
def solve i, m
  if i == $n
    return m == 0
  end

  if !$memo.has_key? (i + 1)
    $memo[i + 1] = {}
  end

  res1 = false
  if $memo[i + 1].has_key? (m)
    res1 = $memo[i + 1][m]
  else
    res1 = solve i + 1, m
    $memo[i + 1][m] = res1
  end

  input_a = $input_a_list[i].to_i
  res2 = false
  if (m - input_a) < 0
    return (res1 | res2)
  end

  if $memo[i + 1].has_key? (m - input_a)
    res2 = $memo[i + 1][m - input_a]
  else
    res2 = solve i + 1, m - input_a
    $memo[i + 1][m - input_a] = res2
  end

  return (res1 | res2)
end

input_m_list.each  {|num|
  if solve 0, num.to_i
    puts "yes"
  else
    puts "no"
  end
}



Measured memory_bytes: 7968
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using ll = long long;
using namespace std;


int main(){
    vector<int> vec;
    vector<int> time;
    int a;
    for (int i = 0; i < 5; i++) {
        cin >> a;
        int tmp;
        if(a%10 == 0)tmp = 10;
        else tmp = a%10;
        vec.push_back(tmp);
        for (int i = 0; i < 13; i++) {
            if(i*10 < a && a<= (i+1)*10){
                a = (i+1)*10;
                break;
            }
        }
        time.push_back(a);
    }
    sort(vec.begin(), vec.end());
    int ans = 0;
    for (int i = 0; i < 5; i++) {
        ans += time[i];
    }
    cout << ans -(10-vec[0]) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main(){
    int n;
    cin >> n;
    string s, res;
    cin >> s;
    int c = 0;
    int r = 0;
    for (int i = 0; i < n; i++) {
        c += (s[i] == '(' ? 1 : -1);
        r = max(r, -c);
    }
    res = string(r, '(') + s;
    c += r;
    while (c > 0) {
        c--;
        res.push_back(')');
    }
    cout << res << endl;
}


Measured memory_bytes: 3640
#include <cstdio>

int edge[300000],next[300000],first[300000];
int r[300000];
bool c[300000];
int i,m,n,p,t,x,y,sum_edge;
bool b;

inline void addedge(int x,int y)
{
	sum_edge++,edge[sum_edge]=y,next[sum_edge]=first[x],first[x]=sum_edge;
	return;
}

int main()
{
	scanf("%d%d",&n,&m);
	for (i=1;i<=m;i++)
	{
		scanf("%d%d",&x,&y);
		addedge(x,y),addedge(y,x);
	}
	c[1]=true;
	p=1,b=true;
	for (;b;)
	{
		b=false;
		for (i=first[p];i!=0;i=next[i])
			if (! c[edge[i]])
			{
				r[p]=edge[i],p=edge[i],b=true,c[p]=true;
				break;
			}
		t++;
	}
	p=1,b=true;
	for (;b;)
	{
		b=false;
		for (i=first[p];i!=0;i=next[i])
			if (! c[edge[i]])
			{
				r[edge[i]]=p,p=edge[i],b=true,c[p]=true;
				break;
			}
		t++;
	}
	printf("%d\n",t-1);
	for (i=p;i;i=r[i])
		printf("%d ",i);
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define SCANF(i) int i;scanf("%d",&i)
using namespace std;
using P = pair<int,int>;
const long long INF = 1LL << 60;
const int IINF=100000000;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

struct UnionFind{
    vector<int>par;
    UnionFind(int n) : par(n) {
        REP(i,n)par[i]=i;
    }
    int root(int x){
        if(par[x]==x)return x;
        return par[x]=root(par[x]);
    }
    void unite(int x,int y){
        int rx=root(x);int ry=root(y);
        if(rx==ry)return;
        par[rx]=ry;
    }
    bool same(int x,int y){
        int rx=root(x);int ry=root(y);
        return rx==ry;
    }
};
signed main () {
    int v,e;scanf("%d %d",&v,&e);
    priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>> que;
    REP(i,e){
        int a,b,c;scanf("%d %d %d",&a,&b,&c);
        que.push(make_tuple(c,b,a));
    }
    int ans=0;
    UnionFind tree(v);
    while(!que.empty()){
        tuple<int,int,int> tmp;tmp=que.top();que.pop();
        int cost=get<0>(tmp);int a=get<1>(tmp);int b=get<2>(tmp);
        if(!tree.same(a,b)){
            ans+=cost;
            tree.unite(a,b);
        }
    }
    printf("%d\n",ans);
}


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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;

template <typename T>
class SegTree
{
public:
    SegTree(const int n, const T &unity) : _unity(unity)
    {
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unity);
    }

    SegTree(const vector<T> &v, const T &unity) : _unity(unity)
    {
        int n = v.size();
        _n = 1 << __lg(2 * n - 1);
        _data.resize(2 * _n, unity);

        // 最下段に要素をセット
        for (int i = 0; i < n; i++) _data[i + n] = v[i];
        // セグメント木を構築
        for (int i = n - 1; i > 0; i--) _data[i] = f(_data[2 * i], _data[2 * i + 1]);
    }

    // k番目の値をxに更新する
    void update(int k, const T &x)
    {
        k += _n; // 葉の節点に変換
        _data[k] = x;
        while (k >>= 1) _data[k] = f(_data[2 * k], _data[2 * k + 1]);
    }

    // 区間[a, b)に対してクエリ処理した結果を返す
    T query(int a, int b)
    {
        T left = _unity, right = _unity;
        a += _n, b += _n; // 葉の節点に変換
        for (; a < b; a >>= 1, b >>= 1) {
            if (a & 1) left  = f(left, _data[a++]);
            if (b & 1) right = f(_data[--b], right);
        }
        return f(left, right);
    }

    const T &operator[](size_t i) const { return _data[i + _n]; }
    T &operator[](size_t i) { return _data[i + _n]; }

private:
    int _n;          // 要素数
    vector<T> _data; // データを格納する配列
    T _unity;        // 単位元

    // クエリ処理用の関数
    T f(const T &a, const T &b) { return a | b; }
};

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

    int n; cin >> n;
    string s; cin >> s;

    SegTree<int> st(n, 0);

    for (int i = 0; i < n; i++) {
        st.update(i, 1 << (s[i] - 'a'));
    }

    int q; cin >> q;
    while (q--) {
        int k; cin >> k;
        if (k == 1) {
            int i; cin >> i; i--;
            char c; cin >> c;
            st.update(i, 1 << (c - 'a'));
        } else {
            int l, r; cin >> l >> r; l--;
            int ans = __builtin_popcount(st.query(l, r));
            cout << ans << endl;
        }
    }
    return 0;
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  int r, d, x;
  cin >> r >> d >> x;

  re(i, 10) {
    x = r * x - d;
    cout << x << endl;
  }

  return 0;
}


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

void chmin(int &a,int b){if(a>b) a=b;}

int main(){
  string s;
  cin >> s;
  int ans=1e6;
  for(int i=0;i<s.length()-2;i++){
  	int a=abs(753-stoi(s.substr(i,3)));
    chmin(ans,a);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt(),b=sc.nextInt(),c=sc.nextInt(),cnt=0;
		for(int i=a; i<=b; i++) {
			if(c%i==0) {
				cnt++;
			}
		}
		System.out.println(cnt);
	}

}


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

int main()
{
	int n,k,l,m,q,p,a[205],b[205],i,j;
	string s;
	m=0;
	do{
		cin >> n;
		for(i=0; i<n; i++)
		{
			cin >> s;
			a[i]=s.size();
		}
		for(i=0; i<n-4; i++)
		{
			p=0;
			for(j=i; j<=n-4; j++)
			{
				p+=a[j];
				if(p>=5) break;
			}
			if(p==5)
			{
				p=0;
				for(k=j+1; k<=n-3; k++)
				{
					p+=a[k];
					if(p>=7) break;
				}
				if(p==7)
				{
					p=0;
					for(j=k+1; j<=n-2; j++)
					{
						p+=a[j];
						if(p>=5) break;
					}
					if(p==5)
			{
				p=0;
				for(k=j+1; k<=n-1; k++)
				{
					p+=a[k];
					if(p>=7) break;
				}
				if(p==7)
				{
					p=0;
					for(j=k+1; j<=n; j++)
					{
						p+=a[j];
						if(p>=7) break;
					}
					if(p==7) goto shilj;
				}
			}
				}
			}
		}
		
		shilj: b[m]=i+1;
		m++;
	}while(n!=0);
	for(i=0; i<m-1; i++)
		cout << b[i] << "\n";
}



Measured memory_bytes: 3164
N = int(input())
A = [int(x) for x in input().split()]

if 0 in A:
    out = 0
    for i in A:
        out += abs(i)
    print(out)
else:
    count = 0
    for i in A:
        if i < 0:
            count += 1
    
    if count%2 == 0:
        out = 0
        for i in A:
            out += abs(i)
        print(out)
    else:
        count = 10 ** 9
        for i in A:
            if abs(i) < count:
                count = abs(i)
        
        out = 0
        for i in A:
            out += abs(i)
        out = out - count*2
        
        print(out)

Measured memory_bytes: 14412
import           Data.Char
import qualified Data.ByteString.Char8 as B
import qualified Data.Vector.Unboxed   as U

main :: IO ()
main = do
  n <- readLn
  ps <- U.unfoldrN n (B.readInt . B.dropWhile isSpace) <$> B.getLine
  putStrLn $ if solve n ps then "YES" else "NO"

solve :: Int -> U.Vector Int -> Bool
solve n = (<= 2) . U.length . U.filter id . U.zipWith (/=) (U.fromList [1..n])

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

int main()
{
	string s;
	cin >> s;
	int a = 0;
	for (int i = 0; i < 3; i++)
	{
		for (int j = i+1; j < 4; j++)
		{
			if (s[i] == s[j]&& s[j] != '0')
			{
				a += 2;
				s[j] = '0';
			}
		}
	}
	if (a != 4)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  lol ans=0;
  int n;
  cin >>n;
  string s;
  map<string,int> mp;
  for(int i=0;i<n;i++){
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  for(auto it=mp.begin();it!=mp.end();it++){
    lol o=it->se;
    ans+=(o*(o-1))/2;
  }
  cout <<ans<<'\n';
  return (0);
}


Measured memory_bytes: 11264
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W;
  cin >> H >> W;
  vector<string> result(H * 2, string(" ", W));
  for (int64_t r = 0; r < H; ++r) {
    string s;
    cin >> s;
    for (int64_t c = 0; c < W; ++c) {
      result[r * 2][c] = s[c];
      result[r * 2 + 1][c] = s[c];
    }
  }
  for (auto a : result) {
    cout << a << endl;
  }
  return 0;
}


Measured memory_bytes: 3656
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {


    public static void main(String[] args) throws IOException {
        Scanner s = new Scanner(System.in);
        int h=s.nextInt(),w=s.nextInt();

        String word;
        while(h--!=0){
            word = s.next();
            System.out.println(word);
            System.out.println(word);
        }

    }
}



class Scanner
{
    StringTokenizer st;
    BufferedReader br;

    public Scanner(InputStream s){	br = new BufferedReader(new InputStreamReader(s));}

    public String next() throws IOException
    {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(br.readLine());
        return st.nextToken();
    }

    public int nextInt() throws IOException {return Integer.parseInt(next());}

    public long nextLong() throws IOException {return Long.parseLong(next());}

    public String nextLine() throws IOException {return br.readLine();}

    public double nextDouble() throws IOException
    {
        String x = next();
        StringBuilder sb = new StringBuilder("0");
        double res = 0, f = 1;
        boolean dec = false, neg = false;
        int start = 0;
        if(x.charAt(0) == '-')
        {
            neg = true;
            start++;
        }
        for(int i = start; i < x.length(); i++)
            if(x.charAt(i) == '.')
            {
                res = Long.parseLong(sb.toString());
                sb = new StringBuilder("0");
                dec = true;
            }
            else
            {
                sb.append(x.charAt(i));
                if(dec)
                    f *= 10;
            }
        res += Long.parseLong(sb.toString()) / f;
        return res * (neg?-1:1);
    }

    public boolean ready() throws IOException {return br.ready();}


}

Measured memory_bytes: 26520
N,M,K=map(int,input().split())
A,B=[0],[0]
A+=map(int,input().split())
B+=map(int,input().split())

for i in range(1,N+1):
    A[i]+=A[i-1]
for i in range(1,M+1):
    B[i]+=B[i-1]

ans,j=0,M
for i in range(N+1):
    if A[i]>K:
        break
    while j>0 and A[i]+B[j]>K:
        j-=1
    ans=max(ans,i+j)

print(ans)


Measured memory_bytes: 40808
from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *
from sys import stdin,stdout
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
import math
import math
import time
from queue import Queue
# PradeepGhosh_2017076

def seive(n):
	l=[True]
	l=l*(n+1)
	for i in range(2,int(sqrt(n))+1):
		if(l[i]==True):
			val=i*i
			while(val<len(l)):
				l[val]=False
				val+=i
	prime=[]
	for i in range(2,len(l)):
		if(l[i]==True):
			prime.append(i)
	return prime

def dp(l,i,n,val,ans):
	if(i>=n or val<0):
		return 1000000
	elif(val==0):
		return 0
	else:
		if(ans[i]==1000000):
			ans[i]=min(min(1+dp(l,i+1,n,val-l[i],ans),1+dp(l,i,n,val-l[i],ans)),dp(l,i+1,n,val,ans))
		return ans[i]
from queue import Queue
def factors(n):
	l=[]
	for i in range(1,int(sqrt(n))+1):
		if(n%i==0):
			if(n//i==i):
				l.append(i)
			else:
				l.append(i)
				l.append(n//i)
	return l
def check1(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v-=1
def check2(s,v,x):
	while(True):
		if(v not in s):
			return v
		else:
			v+=1

if __name__ == '__main__':
	# l=seive(1000000)
	# s=set(l)
	# t=int(input())
	# for i in range(t):
	# 	n=int(input())
	# 	if(n==2):
	# 		print(1)
	# 	else:
	# 		if(n in s):
	# 			n=n-1
	# 		j=n-1
	# 		while(j>0):
	# 			if(n%j==0):
	# 				break
	# 			j-=1
	# 		print(j)
	x=int(input())
	c=0
	ans=0
	while(ans!=360):
		ans+=x
		if(ans>360):
			ans-=360
		c+=1
	print(c)

Measured memory_bytes: 10676
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n : usize,
        vs:[i64;n],
        cs:[i64;n],
    }
    let mut res = 0;
    for i in 0..n {
        res += std::cmp::max(0, vs[i]-cs[i]);
    }
    println!("{}", res);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> (a);)
#define all(v) (v).begin(),(v).end()
#define trav(x,v) for(auto &x : v)
#define sz(v) int(v.size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

int main(){
	cin.sync_with_stdio(0);
	cin.tie(0);

	int n;
	cin >> n;

	vector<vi> gr(n);

	rep(_,1,n){
		int a,b;
		cin >> a >> b;
		--a, --b;
		gr[a].push_back(b);
		gr[b].push_back(a);
	}

	vector<vi> dist(n, vi(n, n));
	rep(i,0,n) dist[i][i] = 0;
	rep(i,0,n) trav(j, gr[i]) dist[i][j] = 1;

	rep(k,0,n) rep(i,0,n) rep(j,0,n)
		dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
	
	int rad = n;
	vi centre;

	rep(i,0,n){
		int mydist = 0;
		rep(j,0,n) mydist = max(mydist, dist[i][j]);
		if(rad > mydist){
			rad = mydist;
			centre.clear();
		}
		if(rad == mydist) centre.push_back(i);
	}
	if(sz(centre)==2) --rad;
	cout << rad+1 << ' ';
	auto solve = [&](){	
		vi tocentre(n);
		vi nums(rad);

		rep(i,0,n){
			int d = n;
			trav(c, centre) d = min(d, dist[i][c]);
			tocentre[i] = d;
		}

		rep(i,0,n){
			int d = tocentre[i];
			if(d == rad) continue;
			int cnt = sz(gr[i]);
			if(sz(centre)==1 && d==0) ;
			else --cnt;
			nums[d] = max(nums[d], cnt);
		}

		ll cur = sz(centre);
		rep(i,0,rad){
			cur *= nums[i];
		}
		return cur;
	};
	if(sz(centre)==1){
		ll ans = solve();
		trav(j, gr[centre[0]]){
			centre.push_back(j);
			ans = min(ans, solve());
			centre.pop_back();
		}
		cout << ans << endl;
	} else cout << solve() << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)

using namespace std;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;

int main()
{
  int n;
  cin>>n;
  vecint a(n), b(n);
  REP(i,n) cin>>a[i];
  REP(i,n) cin>>b[i];
  ll cnt = 0;
  while (true) {
    bool updated = false;
    REP(i,n) {
      int prv = (i+n-1)%n;
      int nxt = (i+1)%n;
      int s = b[prv] + b[nxt];
      if (b[i] > s) {
        if (b[i] - s >= a[i]) {
          int k = (b[i] - a[i]) / s;
          b[i] -= (b[prv] + b[nxt]) * k;
          cnt += k;
          updated = true;
        }
      }
    }
    if (!updated) break;
  }
  if (b == a) {
    cout<<cnt<<endl;
  } else {
    cout<<-1<<endl;
  }
  return 0;
}


Measured memory_bytes: 1792
from heapq import heappush, heappop

sX, sY, tX, tY = map(int, input().split())
N = int(input())

XYR = [tuple(map(int, input().split())) for _ in range(N)] + [(sX, sY, 0), (tX, tY, 0)]
S, T = N, N + 1
N += 2

edges = [[] for _ in range(N)]
for i, (x, y, r) in enumerate(XYR):
    for j, (u, v, w) in enumerate(XYR[i + 1:], start=i + 1):
        dist = max(0, ((x - u)**2 + (y - v)**2)**0.5 - (r + w))
        edges[i].append((j, dist))
        edges[j].append((i, dist))

minDist = [10**18] * N
minDist[S] = 0
que = [(0, S)]
while que:
    dist, now = heappop(que)
    if minDist[now] < dist:
        continue
    for to, cost in edges[now]:
        d = dist + cost
        if minDist[to] > d:
            minDist[to] = d
            heappush(que, (d, to))
print(minDist[T])


Measured memory_bytes: 128392
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

int main(){
	char s[100];
	cin >> s;
	if(strcmp("2019/04/30",s)<0){
		cout << "TBD" <<endl;
	}else{
		cout << "Heisei" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const long double PI = acos(-1.0);
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout << fixed << setprecision(10);
}
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
long long LCM(long long a, long long b) {
	long long g = GCD(a, b);
	return a / g * b;
}
int N, M;
string s, t;
signed main() {
	my_io();
	cin >> N >> M;//N=|s| M=|t|
	cin >> s;
	cin >> t;
	int gcd_ = GCD(N, M);
	int A = M/gcd_;
	int B = N/gcd_;
	
	string ss;
	for (int i = 0; i < N; i+=B) {
		ss.push_back(s[i]);
	}
	string tt;
	for (int i = 0; i < M; i += A) {
		tt.push_back(t[i]);
	}
	bool check = true;
	for (int i = 0; i < ss.size(); i++) {
		if (ss[i] != tt[i]) {
			check = false;
		}
	}
	if (check == false) {
		cout << -1 << endl;
	}
	else {
		cout << LCM(N, M) << endl;
	}
	return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll long int

int main(){
    int a,b,c;
    cin >> a >> b>> c;
    if(a<b)swap(a,b);
    if(a<c)swap(a,c);
    if(b<c)swap(b,c);

    cout << a*10+b+c << endl;
}

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

int n, m, p;
int a[100005], b[100005];
int flag[100005];
int main()
{
	scanf("%d %d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d %d", &a[i], &b[i]);
		flag[a[i]]++;
		flag[b[i]]++;
	}
	for(int i = 1; i <= 100000; i++)
	{
		if(flag[i] % 2 == 1) p = 1;
	}
	if(p == 1) printf("NO\n");
	else printf("YES\n");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define sort(a) sort((a).begin(),(a).end())
#define rev(a) reverse((a).begin(),(a).end())
using db = double;
using namespace std;
typedef long long ll;


int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n) {
    rep (j,d) {
      cin >> x[i][j];
    }
  }
  int cnt = 0;
  rep(i,n) {
    repl(j,i+1,n) {
      int sum = 0;
      rep(k,d) {
        sum += pow(x[i][k] - x[j][k], 2);
      }
      double dis;
      dis = sqrt(sum);
      if (floor(dis) == dis) cnt++;
    }
  }
  cout << cnt << endl;
}



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

char S[3];

int main()
{
    for(int i = 0; i < 3; i++)scanf(" %c",S + i);

    sort(S,S + 3);
    if(S[0] == 'a' && S[1] == 'b' && S[2] == 'c')printf("Yes\n");
    else printf("No\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 rep2(i, m, n) for (int i = m; i < (int)(n); i++)

int main() {
  int n;
  cin>>n;
  cout<<(n+1)/2<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define SMAX 100000
#define TMAX 50000

int main(){

  int i, j, temp, count, snum, tnum, left, right, mid;
  
  int sdata[SMAX];
  int tdata[TMAX];

  count = 0;
  

  //入力
  scanf("%d", &snum);

  for(i = 0; i < snum; i++){

    scanf("%d", &sdata[i]);

  }
 
  scanf("%d", &tnum);

  for(i = 0; i < tnum; i++){

    scanf("%d", &tdata[i]);

  }

  //検索
  for(i = 0; i < tnum; i++){

    left = 0;
    
    right = snum;

    while(left < right){

      mid = ((left + right) / 2);

      if(tdata[i] == sdata[mid]){

	count++;
	break;

      }

      else if(tdata[i] > sdata[mid]){

	left = mid + 1;

	while(sdata[left] == sdata[left + 1]){
	  
	  left++;

	}

      }

      else{

	right = mid;

	while(sdata[right] == sdata[right -1]){
	  
	  right--;
  
	}

      }

    }

  }
  
  printf("%d\n", count);

  return 0;

}

Measured memory_bytes: 1184
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	x := nextInt()
	fmt.Fprintf(out, "%d\n", 1-x)
}


Measured memory_bytes: 1808
import java.util.*;

// ABC 27-C
// http://abc027.contest.atcoder.jp/tasks/abc027_c
 
public class Main {
	
	public static void main (String[] args) throws java.lang.Exception {
		Scanner in = new Scanner(System.in);

		int a = in.nextInt();
		int b = in.nextInt();
		int c = in.nextInt();
		
		boolean answer = false;
		
		for (int i = 1; i <= Math.max(a, b); i++) {
			if ((i * a - c) % b == 0) {
				answer = true;
				break;
			}
		}
		System.out.println(answer ? "YES": "NO");
	}
}

Measured memory_bytes: 22868
#include <stdio.h>
#include<stdlib.h>
int cmp ( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
int main()
{
    int k,n,i,max,t;
    int a[200000];
    scanf("%d %d",&k,&n);
    for(i=0;i<n;i++)
        scanf("%d",&a[i]);
    qsort(a,n,sizeof(a[0]),cmp);
    max=a[1]-a[0];
    for(i=2;i<n;i++)
    {
        if(max<(a[i]-a[i-1]))
            max=a[i]-a[i-1];
    }
    t=k-a[n-1]+a[0];
    if(t>max)
        max=t;
    printf("%d",k-max);
}


Measured memory_bytes: 1404
INF = 10**9
import sys
from heapq import *
input = sys.stdin.readline

class Dijkstra:
    def __init__(self, adj):
        self.adj = adj
        self.dist = [INF] * len(adj)
        self.q = []

    def calc(self, start):
        self.dist[start] = 0
        heappush(self.q, (0, start))
        while len(self.q) != 0:
            prov_cost, src = heappop(self.q)
            if self.dist[src] < prov_cost:
                continue
            for dest, cost in self.adj[src]:
                if self.dist[dest] > self.dist[src] + cost:
                    self.dist[dest] = self.dist[src] + cost
                    heappush(self.q, (self.dist[dest], dest))
        return self.dist

def sep(): return map(int,input().split())
def solve():
    h,w = sep()
    x,y = sep()
    xnot ,ynot = sep()
    x-=1
    y-=1
    xnot-=1
    ynot-=1

    field = []
    for i in range(h):
        temp = input().rstrip()
        field.append(temp)

    edge = [[] for i in range(h*w)]
    for i in range(h):
        for j in range(w):
            if field[i][j] == "#":
                continue
            frm = i * w + j
            for dx in range(-2, 3):
                nx = i + dx
                if nx < 0 or nx > h - 1:
                    continue
                for dy in range(-2, 3):
                    if dx == 0 and dy == 0:
                        continue
                    ny = j + dy
                    if ny < 0 or ny > w - 1:
                        continue
                    if field[nx][ny] == "#":
                        continue
                    dist = abs(dx) + abs(dy)
                    if dist == 1:
                        edge[frm].append((nx*w + ny, 0))
                    else:
                        edge[frm].append((nx*w + ny, 1))


    # for i in range(n):
    #     for j in range(m):
    #         if(grid[i][j] == '#'):
    #             continue
    #         for ii in range(i-2,i+3):
    #             for jj in range(j-2,j+3):
    #                 if(ii==i and jj==j):
    #                     continue
    #                 if(0<=ii<n and 0<=jj<m and grid[ii][jj] == '.'):
    #                     if(abs(ii-i)+abs(jj-j) == 1):
    #                         g[i*m+j].append([ii*m+jj,0])
    #                     else:
    #                         g[i*m+j].append([ii*m+jj,1])
                        # print(i*m+j,ii*m+jj)
    # for i in range(n*m):
    #     print(g[i])

    # dist = [10**9]*(n*m)
    # print(x*m+y,xnot*m+ynot)
    d = Dijkstra(edge)
    dist = d.calc(x*w+y)
    # print(dist[xnot*m+ynot])
    # print(dist)
    if(dist[xnot*w+ynot] == 10**9):
        print(-1)
    else:
        print(dist[xnot*w+ynot])

solve()


Measured memory_bytes: 359408
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

void main() {
    int N, M; scanf("%d %d\n", &N, &M);
    int[] a = new int[M];
    foreach (i; 0 .. M) { scanf("%d\n", &a[i]); }
    int[] b = new int[M];
    int Calc() {
        auto G = new bool[][](M, M);
        foreach (i; 0 .. M) {
            foreach (j; i + 1 .. M) {
                if (abs(b[i] - b[j]) <= 1) {
                    G[i][j] = true;
                }
            }
        }
        int Ans = 0;
        int dfs(int x) {
            int ret = 0;
            foreach (i; 0 .. M) {
                if (G[x][i]) {
                    ret = max(ret, dfs(i));
                }
            }
            return ret + 1;
        }
        foreach (int i; 0 .. M) {
            Ans = max(Ans, dfs(i));
        }
        version(Debug) {
            foreach (i; 0 .. M) {
                writef("%3d: ", b[i]);
                foreach (j; 0 .. M) {
                    if (G[i][j]) {
                        writef("%3d", b[j]);
                    }
                }
                writeln;
            }
        }
        return Ans;
    }

    int[] Result(int[] zs) {
        auto x = iota(0, N, 1).array;
        foreach (z; zs) {
            swap(x[z - 1], x[z]);
        }
        return x;
    }

    int Ans = M;

    void dfs(int x, bool[] used, int[] index) {
        used[x] = true;
        bool flag = false;
        index ~= x;
        foreach (i; 0 .. M) {
            if (used[i]) continue;
            flag = true;
            dfs(i, used, index);
        }
        if (!flag) {
            //writeln(index);
            foreach (i; 0 .. M) {
                b[i] = a[ index[i] ];
            }
            if (Result(a) == Result(b)) {
                Ans = min(Ans, Calc);
            }
        }
        index.popBack;
        used[x] = false;
    }
    
    foreach (i; 0 .. M) {
        dfs(i, new bool[M], []);
    }

    Ans.writeln;
}

Measured memory_bytes: 2032
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
using namespace std;
typedef long long ll;
const int Maxn = 1e6 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
int n, ans;
arr to;
char s[Maxn], t[Maxn];
queue<int> q;
bool check()
{
	for (int i = 1; i <= n; i++)
		if (s[i] != t[i])
			return false;
	return true;
}
int main()
{
	rg int tmp;
	cin >> n >> s + 1 >> t + 1;
	if (check())
	{
		puts("0");
		return 0;
	}
	tmp = n;
	for (int i = n, j = n; i >= 1; i--)
	{
		while (j > 0 && s[j] != t[i])
			j--;
		if (!j)
		{
			puts("-1");
			exit(0);
		}
		if (!to[j])
			to[j] = i;
		if (j == i)
			j--;
	}
	for (int i = n; i >= 1; i--)
	{
		if (!to[i])
			continue;
		while (!q.empty() && q.front() - tmp > to[i])
			q.pop();
		q.push(i + ++tmp);
		ans = max(ans, q.size());
	}
	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 10240
#include<stdio.h>
#include<map>
int mkey(int k[3]){
  return k[0] * 1234+k[1]*5678+k[2]*9631;
}
int main(){
  int N;
  char str[30009];
  int S[30009];
  int i,j;
  int key[10000][3];
  int num_key,nk;
  int tmp[3];
  int used[10],prevnk[10];
  std::map<int,bool> map_key;
  scanf("%d%s",&N,str);
  for(i=0;i<N;i++){
    S[i] = str[i] - '0';
  }
  key[0][0] = S[0];
  key[0][1] = S[1];
  key[0][2] = S[2];
  map_key[mkey(key[0])] = true;
  num_key = 1;
  for(i=0;i<9;i++){
    used[i]=0;
    prevnk[i] = 0;
  }
  for(i=0;i<3;i++){
    used[S[i]]++;
  }
  for(i=3;i<N;i++){
    if(prevnk[S[i]] == num_key){
       continue;
     }
    used[S[i]]++;
    nk = num_key;
    prevnk[S[i]] = nk;
    for(j=0;j<nk;j++){
      tmp[0] = key[j][0];
      tmp[1] = key[j][1];
      tmp[2] = S[i];
      if(map_key[mkey(tmp)] == false){
        key[num_key][0] = tmp[0];
        key[num_key][1] = tmp[1];
        key[num_key][2] = tmp[2];
        map_key[mkey(tmp)] = true;
        num_key++;
      }
      tmp[0] = key[j][0];
      tmp[1] = key[j][2];
      tmp[2] = S[i];
      if(map_key[mkey(tmp)] == false){
        key[num_key][0] = tmp[0];
        key[num_key][1] = tmp[1];
        key[num_key][2] = tmp[2];
        map_key[mkey(tmp)] = true;
        num_key++;
      }
      tmp[0] = key[j][1];
      tmp[1] = key[j][2];
      tmp[2] = S[i];
      if(map_key[mkey(tmp)] == false){
        key[num_key][0] = tmp[0];
        key[num_key][1] = tmp[1];
        key[num_key][2] = tmp[2];
        map_key[mkey(tmp)] = true;
        num_key++;
      }
    }
  }
  printf("%d",num_key);
}

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

main(){
  int n, A[10000];
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> A[i];
  sort(A, A+n);
  int m = min(10, n); // tekito
  vector<int> ans;

  for (int i = 0; i < m; i++ ){
    for ( int j = 0; j < m; j++ ){
      if ( i == j ) continue;
      int left = A[i];
      int right = A[j];
      while(right){ right /= 10; left *= 10; }
      ans.push_back(left + A[j]);
    }
  }

  sort(ans.begin(), ans.end());
  cout << ans[2] << endl;
}

Measured memory_bytes: 1256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define int4(v, x, y, z) int v, x, y, z; scanf("%d%d%d%d", &v, &x, &y, &z)
#define int5(v, w, x, y, z) int v, w, x, y, z; scanf("%d%d%d%d%d", &v, &w, &x, &y, &z)
#define ll2(x, y) ll x, y; cin >> x >> y;
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << (x) << "\n"
#define debug2(x, y) cout << " --- " << (x) << " " << (y) << "\n"
#define debug3(x, y, z) cout << " --- " << (x) << " " << (y) << " " << (z) << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)


signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase >= 0;testcase++){
    int2(n, l);
    int a[n]; scn(n, a);

    bool fl = false;
    rep1(i, n){
      if(a[i - 1] + a[i] < l)continue;
      fl = true;
      puts("Possible");
      rep1(j, i)pri(j);
      for(j = n - 1;j > i;--j)pri(j);
      pri(i);
      break;
    }
    if(!fl)puts("Impossible");



/*/

//*/ break;
  }
  return 0;
}


Measured memory_bytes: 1280
import java.util.Scanner;

class Stack {
	private int top;
	private int[] a;
	
	Stack(){
		this.top=0;
		this.a=new int[200];
	}
	
	void push(int x){
		a[top++]=x;
	}
	
	int pop(){
		top--;
		return a[top];
	}
	
}

class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		Stack S=new Stack();
		
		while(scan.hasNext()){
			String str=scan.next();
			if(Character.isDigit(str.charAt(0))){
				S.push(Integer.parseInt(str));
			}
			else {
				int a=S.pop(); int b=S.pop();
				switch(str.charAt(0)){
					case '+':S.push(b+a);
							 break;
					case '-':S.push(b-a);
							 break;
					case '*':S.push(b*a);
							 break;
				}
			}
		}
		System.out.println(S.pop());
	}
}


Measured memory_bytes: 26212
class UnionFind(object):
    def __init__(self, n=1):
        self.par = [i for i in range(n)]
        self.rank = [0 for _ in range(n)]
        self.size = [1 for _ in range(n)]

    def find(self, x):
        """
        x が属するグループを探索
        """
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self, x, y):
        """
        x と y のグループを結合
        """
        x = self.find(x)
        y = self.find(y)
        if x != y:
            if self.rank[x] < self.rank[y]:
                x, y = y, x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
            self.par[y] = x
            self.size[x] += self.size[y]

    def is_same(self, x, y):
        """
        x と y が同じグループか否か
        """
        return self.find(x) == self.find(y)

    def get_size(self, x):
        """
        x が属するグループの要素数
        """
        x = self.find(x)
        return self.size[x]


n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]
uf = UnionFind(n)
b = []
for i in a:
    uf.union(i[0]-1,i[1]-1)
for i in range(n):
  b.append(uf.find(i))
print(len(list(set(b))))


Measured memory_bytes: 43040
import java.io.*;
public class Main{
	public static void main(String [] args) throws NumberFormatException, IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String[] st=br.readLine().split(" ");
		int a=Integer.parseInt(st[0]);
		int b=Integer.parseInt(st[1]);
		int c=Integer.parseInt(st[2]);
		System.out.println(a<b&&b<c?"Yes":"No");
	}}

Measured memory_bytes: 16892
import java.util.*;

// abc124b
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();

		int ts = sc.nextInt();

		int ans = 1;

		for (int i = 1; i < n; i++) {
			int tmp = sc.nextInt();
			if (tmp >= ts){
				ans++;
			if (tmp > ts) {
				ts = tmp;
			}

			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23380