akhauriyash/Code-Regression huggingface dataset:
#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<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
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
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=1000000007 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
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;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
//13:14~
int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	llint i,n,ans=0;cin>>n;
	vector<pair<llint,llint>>a(n);
	for(i=0;i<n;i++){cin>>a[i].fir>>a[i].sec;}
	SO(a);
	vector<pair<llint,llint>>ue(n+1),st(n+1);
	ue[0]=mp(-big,big);st[n]=mp(-big,big);
	for(i=0;i<n;i++){ue[i+1]=mp(max(ue[i].fir,a[i].fir),min(ue[i].sec,a[i].sec));}
	for(i=n-1;i>=0;i--){st[i]=mp(max(st[i+1].fir,a[i].fir),min(st[i+1].sec,a[i].sec));}
	for(i=0;i<n;i++){
		maxeq(ans,max(0LL,a[i].sec-a[i].fir+1)+max(0LL,min(st[i+1].sec,ue[i].sec)-max(st[i+1].fir,ue[i].fir)+1));
		if(i!=0){maxeq(ans,max(0LL,ue[i].sec-ue[i].fir+1)+max(0LL,st[i].sec-st[i].fir+1));}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 4992
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}

	Scanner sc = new Scanner(System.in);

		
	int dk(long k){
		int count =0;
		while(k>0){
			k /= 10;
			count++;
		}
		return count;
	}
	
	long[] magic(int d){
		long[] res= new long[d+1];
		
		long x = 9;
		long y = 10;
		for(int i = 0; i < d; i++){
			y*=10;
		}
		
		long r = y;
		for(int i =0 ;i<d+1;i++){
			r += x;
			res[i] = r;
			x *= 10;
		}
		return res;
	}
	
	int s(long i){
		return  (int)((i/1000000000000000L)%10+				
				(i/100000000000000L)%10+
				(i/10000000000000L)%10+
				(i/1000000000000L)%10+
				(i/100000000000L)%10+
				(i/10000000000L)%10+
				(i/1000000000L)%10+
				(i/100000000L)%10+
				(i/10000000L)%10+
				(i/1000000L)%10+
				(i/100000L)%10+
				(i/10000L)%10+
				(i/1000L)%10+
				(i/100L)%10+
				(i/10L)%10+
				(i/1L)%10);
	}

	
	boolean comp(long x, long y){
		return (s(x)*y < s(y)*x);
	}
	
	void run() {
		
		
		long k = sc.nextLong();
		LinkedList<String> c = new LinkedList<String>();
		
		for(int i = 1; i < 10 ;i++){
			c.addFirst(i+"");
		}
		for(int i = 1; i < 10 ;i++){
			c.addFirst(i+"9");
		}
		for(int d = 1; d<14; d++){
			long[] cand = magic(d);
			int x = d;
			for(; x > 0 ;x--){
				if(!comp(cand[x], cand[x-1])){
					break;
				}
			}
			
			int d9 = x+1;
			long m9 = 9;
			long p = 0;
			for(int i = 0 ; i < d9;i++){
				p+=m9;
				m9*=10;
			}
			int rem = d-x;
			int xx = 1;
			for(int i = 0 ; i < rem; i++){
				xx *= 10;
			}
			
			for(int y = xx ; y < xx*10;y++){
				c.addFirst((y + ""+p));
			}
		}
		
		
		long minX = Long.valueOf(c.get(0));
		long minS = s(minX);
		
		LinkedList<Long> ans = new LinkedList<Long>();
		
		for(String ss: c){
			long xx = Long.valueOf(ss);
			long sss = s(xx);
			
			
			if(xx*minS <= minX*sss){
				minX = xx;
				minS = sss;
				ans.addFirst(xx);
			}
		}
		
		for(Long v: ans){
			System.out.println(v);
			k--;
			if(k==0){
				break;
			}
		}
		
	}
}


Measured memory_bytes: 22736
#include <bits/stdc++.h>
#define endl '\n'
#define debug(X) cout << #X << " = " << X << endl
#define SZ(X) ((int)X.size())

using namespace std;

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	#ifdef UTP
	freopen("input.txt", "r", stdin);
	#endif
	int n; cin >> n;
	vector<int> a(n), ans(n);
	for (int i = 0; i < n; i++)
        cin >> a[i];
    for (int k = n - 1; k >= 0; k--) {
        int p = -1;
        for (int i = 0; i < SZ(a); i++)
            if (a[i] == i + 1) p = i;
        if (p == -1) { cout << -1 << endl; return 0; }
        a.erase(a.begin() + p);
        ans[k] = p + 1;
    }
    for (int i = 0; i < n; i++)
        cout << ans[i] << endl;
	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 Rrep(i, n) for (int i = ((int) n - 1); i >= 0; i--)
#define all(x)     (x).begin(), (x).end()
#define SZ(x)      ((int) (x).size())
#define INF 2e15
#define MOD 10e9 + 7

typedef vector <int> vint;
typedef long long    ll;



int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int x, y;
    cin >> x >> y;
    int ans = 0;
    if (x == 1) {
        ans += 300000;
    }
    else if (x == 2) {
        ans += 200000;
    }
    else if (x == 3) {
        ans += 100000;
    }

    if (y == 1) {
        ans += 300000;
    }
    else if (y == 2) {
        ans += 200000;
    }
    else if (y == 3) {
        ans += 100000;
    }

    if (x == 1 && y == 1) {
        ans += 400000;
    }
    cout << ans << endl;



    return 0;
}


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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<int,int> p;

ll H,W,A,B,C,h,w,Min,Max;

int main(){
  ll ans = INTMAX;
  cin >> H >> W;
  if(H>W)swap(H,W);
  rep(i,1,H){
    A = W*i;
    //縦に分割
    B = ((H-i)/2)*W;
    C = H*W-A-B;
    Min = min(A, min(B,C));
    Max = max(A, max(B,C));
    ans = min(ans, abs(Max-Min));

    //横に分割
    B = (W/2)*(H-i);
    C = H*W-A-B;
    Min = min(A, min(B,C));
    Max = max(A, max(B,C));
    ans = min(ans, abs(Max-Min));
  }
  rep(i,1,W){
    A = H*i;
    //縦に分割
    B = ((W-i)/2)*H;
    C = H*W-A-B;
    Min = min(A, min(B,C));
    Max = max(A, max(B,C));
    ans = min(ans, abs(Max-Min));

    //横に分割
    B = (H/2)*(W-i);
    C = H*W-A-B;
    Min = min(A, min(B,C));
    Max = max(A, max(B,C));
    ans = min(ans, abs(Max-Min));
  }
  cout << ans <<endl;
}


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

int main (){
        long long w;
        string S;
        cin >> S>>w;
        
        char c[S.length()];
        for(int i=0; i<S.length(); i++){
			 c[i] = S[i];
        }
        
        for(int i=0;i<S.length();i++){
        	if(i%w ==0 ){
        		cout << c[i];
        	}
        }

}


Measured memory_bytes: 256
n = int(input())
cards = [[ s+' '+str(n) for n in range(1,14)] for s in ['S','H','C','D']]
#リストcardsの要素｢s n｣の形
#sにはS,H,C,D、nには1~13の値を入れる
for i in range(n):
    a , num = input().split()
    if a == 'S':
        cards[0][int(num)-1] = 0
    elif a == 'H':
        cards[1][int(num)-1] = 0
    elif a == 'C':
        cards[2][int(num)-1] = 0
    elif a == 'D':
        cards[3][int(num)-1] = 0
for s in cards:
    for n in s:
        if n != 0:
            print(n)


Measured memory_bytes: 5604
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <functional>
#include <utility>
using namespace std;
typedef long long ll;
int main(){
  string x;
  cin >> x;

  int N = x.size();
  int ans = N;

  int cnt_S = 0;

  for(int i = 0;i < N;i++){
    if(x[i] == 'S')cnt_S++;
    else{
     if(cnt_S > 0)ans-=2,cnt_S--;
    } 
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>

using namespace std;

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

    int counter = A;

    while(counter <= B){
        if(counter % K == 0){
            cout << "OK" << endl;
            return 0;
        }
        counter++;
    }

    cout << "NG" << endl;
}   

Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

#include <limits.h>

using namespace std;

typedef long long ll;

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

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

int main(void) {
    string S;
    cin >> S;

    int n = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        int d = S[i] - '0';
        n = n * 10 + d;
    }
    // printf("n: %d\n", n);

    int acc = 0;
    for (int i = 0; i < (int) S.size(); i++) {
        int d = S[i] - '0';
        acc += d;
    }
    // printf("acc: %d\n", acc);

    if (n % acc == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;

int main(){
        int n,m,i,a;
        cin >> n >> m;
        vector<ll> dp(n+1);
        vector<bool> broken(n+1);
        dp.at(0) = 1;
        for(i=0;i<m;++i){
                cin >> a;
                broken.at(a) = true;
        }
        dp.at(1) = broken.at(1) ? 0 : 1;
        for(i=2;i<=n;++i){
                if(broken.at(i)) dp.at(i) = 0;
                else dp.at(i) = dp.at(i-2) + dp.at(i-1);
                dp.at(i) %= MOD;
        }
        cout << dp.at(n) << endl;
        return 0;
}

Measured memory_bytes: 3948
#[allow(unused_imports)]
use std::char::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

#[allow(unused_macros)]
macro_rules! debug {($($a:expr),*) => {println!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);}}
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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 ) * } } ; }
#[allow(unused_macros)]
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" ) } ; }

#[derive(PartialEq, PartialOrd)]
pub struct Total<T>(pub T);
impl<T: PartialEq> Eq for Total<T> {}
impl<T: PartialOrd> Ord for Total<T> { fn cmp(&self, other: &Total<T>) -> std::cmp::Ordering { self.0.partial_cmp(&other.0).unwrap() }}

#[allow(dead_code)]
const MAX:usize = 100006;
#[allow(dead_code)]
const INF_U32:u32 = 1 << 31;
#[allow(dead_code)]
const INF_I32:i32 = 1 << 30;
#[allow(dead_code)]
const INF_U64:u64 = 1 << 63;
#[allow(dead_code)]
const INF_I64:i64 = 1 << 62;


fn main() {
    input!{n:usize, v:[(i64,i64); n]};
    println!("{}", v.iter().map(|&(l,r)| r-l+1).sum::<i64>());
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;
const double TT = acos(-1);

signed main()
{
	IO_OP;
	
	cout << fixed << setprecision(10);
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	double ang1 = (h + m / 60) / 12 * 2 * TT, ang2 = m / 60 * 2 * TT;
	double ang = abs(ang1 - ang2);
	cout << sqrt(a*a + b*b - 2 * a * b * cos(ang)) << endl;
	
}





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

using namespace std;

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

  int N, M;
  cin >> N >> M;
  vector<int> A(M);

  for (int i = 0; i < M; i++) {
    cin >> A.at(i);
  }
  for (int i = 0; i < M; i++) {
    N -= A.at(i);
  }
  if (N < 0) {
    N = -1;
  }

  cout << N << endl;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#include <math.h> 
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll ch[200010];
	ll ma=inf;ll ans=0;
	for(ll i=0;i<n;i++){
		cin>>ch[i];
	}
	for(ll i=0;i<n;i++){
		ll now=ch[i];
		if(now<ma){
			ma=now;
			ans++;
		}
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5168
import std.stdio : readln, writeln;
import std.array : split;
import std.conv : to;
import std.typecons;
import std.algorithm : map;
import std.string : chomp;

char[Tuple!(int, int)] field;
int W, H;

void dfs(int x, int y, char f) {
  field[tuple(x, y)] = '.';
  foreach (dx; [-1, 1]) {
    int nx = x + dx;
    if (0 <= nx && nx < W
        && field[tuple(nx, y)] == f) dfs(nx, y, f);
  }
  foreach (dy; [-1, 1]) {
    int ny = y + dy;
    if (0 <= ny && ny < H
        && field[tuple(x, ny)] == f) dfs(x, ny, f);
  }
}

void main() {
  while (1) {
    auto input = map!(to!int)(split(chomp(readln()))[0 .. 2]);
    H = input[0], W = input[1];
    if (W == 0 && H == 0) break;

    field = field.init;
    foreach (int y; 0 .. H)
      foreach (int x, char f; readln()[0 .. W])
        field[tuple(x, y)] = f;

    int res = 0;
    foreach (xy; field.keys) {
      char f = field[tuple(xy[0], xy[1])];
      switch (f) {
      case '#': case '@': case '*':
        dfs(xy[0], xy[1], f);
        res++;
        break;
      default:
        break;
      }
    }
    writeln(res);
  }
}

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

using namespace std;
using ll=long long;

int t;
const int mod=1e9+7;

void add_self(int &a, int b){
    a+=b;
    if(a>=mod)a-=mod;
}

void sub_self(int &a, int b){
    a-=b;
    if(a<0)a+=mod;
}

void test_case(){
    int n,k;
    cin>>n>>k;
    vector<int>dp(k+1);
    dp[0]=1;
    for(int i=0; i<n; i++){
        int child;
        cin>>child;
        vector<int> cs(k+1);
        for(int candie=k-1; candie>=0; candie--){
            int l=candie+1, r=candie+child+1;
            // if(l>r)continue;
            add_self(cs[l],dp[candie]);
            if(r<=k)sub_self(cs[r],dp[candie]);
            // cout<<l<<" "<<r<<" "<<cs[l]<<" "<<cs[r]<<endl;
        }
        for(int i=0; i<=k; i++){
            if(i)add_self(cs[i],cs[i-1]);
            add_self(dp[i],cs[i]);
            // cout<<i<<" "<<cs[i]<<" "<<dp[i]<<endl;
        }
    }
    cout<<dp[k]<<endl;
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);

    t=1;
    while(t--){
        test_case();
    }

    return 0;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (1LL << 55)
#define MOD (1000 * 1000 * 1000 + 7)
#define maxn 1000111

typedef long long ll;
typedef long double ld;

vector<string> v;

int main(){
	int a, b, c;
	cin >> a >> b >> c;
	
	for(int i = 0; i < a; i++)
		v.pb("a");
	for(int i = 0; i < b; i++)
		v.pb("b");
	for(int i = 0; i < c; i++)
		v.pb("c");

	while(v.size() > 1){
		sort(v.begin(), v.end());
		v[0] += v.back();
		v.pop_back();
	}

	cout << v[0] << endl;
	return 0;
}

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

int h, w;
char p[102][103];
int label[102][102], labelNum;
vector<int> et[2][11000];

bool is_range(int y, int x) {
	return (0 <= y && y < h && 0 <= x && x < w);
}

void labeling() {
	int i, j, id = 0;
	bool used[102][102] = {false};
	
	rep(i, h) {
		rep(j, w) {
			if (used[i][j]) continue;
			//(i, j)????§???????????????????????????°?????????
			queue<P> que;
			que.push(P(i, j));
			while (!que.empty()) {
				int y = que.front().first;
				int x = que.front().second;
				que.pop();
				if (used[y][x]) continue;
				used[y][x] = true;
				label[y][x] = id;
				
				for (int dy = -1; dy <= 1; dy++) {
					for (int dx = -1; dx <= 1; dx++) {
						int ny = y + dy;
						int nx = x + dx;
						if (!is_range(ny, nx)) continue;
						if (p[y][x] == '.') {
							if (abs(dy) + abs(dx) != 1) continue;
							if (p[ny][nx] != '.') continue;
							que.push(P(ny, nx));
						}
						else {
							if (dy == 0 && dx == 0) continue;
							if (p[ny][nx] != '#') continue;
							que.push(P(ny, nx));
						}
					}
				}
			}
			id++;
		}
	}
	labelNum = id;
}

void make_graph(int type) {
	vector<vector<P> > pos;
	pos.resize(labelNum);
	
	int i, j;

	rep(i, h) rep(j, w) pos[label[i][j]].push_back(P(i, j));
	
	int dy[4] = {-1, 0, 1, 0};
	int dx[4] = {0, 1, 0, -1};
	bool used[11000] = {false};
	queue<int> que;
	
	que.push(0);
	used[0] = true;
	
	while (!que.empty()) {
		int id = que.front(); que.pop();
		
		rep(i, pos[id].size()) {
			rep(j, 4) {
				int y = pos[id][i].first + dy[j];
				int x = pos[id][i].second + dx[j];
				if (!is_range(y, x)) continue;
				if (used[label[y][x]]) continue;
				
				que.push(label[y][x]);
				used[label[y][x]] = true;
				et[type][id].push_back(label[y][x]);
			}
		}
	}
}

vector<int> dfs(int v, int type) {
	vector<int> ret;
	if (et[type][v].size() == 0) { ret.push_back(0); return ret; }
	
	vector<vector<int> > res;
	for (int i = 0; i < et[type][v].size(); i++) {
		res.push_back(dfs(et[type][v][i], type));
	}
	sort(res.begin(), res.end());
	
	for (int i = 0; i < res.size(); i++) {
		for (int j = 0; j < res[i].size(); j++) {
			ret.push_back(res[i][j]);
		}
	}
	ret.push_back(et[type][v].size());
	
	return ret;
}

bool _is_same(vector<int> a, vector<int> b) {
	if (a.size() != b.size()) return false;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] != b[i]) return false;
	}
	return true;
}

int main() {
	int i, j;
	
	while (cin >> h >> w) {
		if (!h) break;
		rep(i, h + 2) rep(j, w + 2) p[i][j] = '.';
		rep(i, h) rep(j, w) cin >> p[i + 1][j + 1];
		h += 2;
		w += 2;
		labeling();
		make_graph(0);
		
		cin >> h >> w;
		rep(i, h + 2) rep(j, w + 2) p[i][j] = '.';
		rep(i, h) rep(j, w) cin >> p[i + 1][j + 1];
		h += 2;
		w += 2;
		labeling();
		make_graph(1);
		
		vector<int> list[2];
		list[0] = dfs(0, 0);
		list[1] = dfs(0, 1);
		if (_is_same(list[0], list[1])) { cout << "yes" << endl; }
		else { cout << "no" << endl; }
		
		rep(i, 11000) et[0][i].clear();
		rep(i, 11000) et[1][i].clear();
	}
	return 0;
}

Measured memory_bytes: 3896
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	for(char c : n){
		if(c == '1')
			cout << 9;
		else if(c == '9')
			cout << 1;
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
	int h,w,r,c;
	while(cin >> h >> w >> r >> c &&h!=0){
		vector<vector<int> > p(h+1,vector<int>(w));
		vector<vector<int> > q(h,vector<int>(w+1));
		for(int i=0;i<2*h+1;i++){
			if(i%2==0){
				for(int j=0;j<w;j++){
					cin >> p[i/2][j];
				}
			}else{
				for(int j=0;j<w+1;j++){
					cin >> q[i/2][j];
				}
			}
		}
	
		vector<vector<int> > b(h+2,vector<int>(w+2));
		for(int i=0;i<w+2;i++){
			b[0][i] = 1;
		}
		for(int i=0;i<w+2;i++){
			b[h+1][i] = 1;
		}
		for(int i=0;i<h+2;i++){
			b[i][0] = 1;
		}
		for(int i=0;i<h+2;i++){
			b[i][w+1] = 1;
		}
		queue<pair<int,int> > que;
		if(h==1){
			for(int i=1;i<=w;i++){
				que.push(MP(1,i));
			}
		}else if(w==1){
			for(int i=1;i<=h;i++){
				que.push(MP(i,1));
			}
		}else{
			que.push(MP(1,1));
			que.push(MP(1,w));
			que.push(MP(h,1));
			que.push(MP(h,w));
		}
		while(!que.empty()){
			pair<int,int> t = que.front();
			que.pop();
			int d = t.first;
			int e = t.second;
			//cout << d << " " << e << endl;
			if(b[d][e]==0){
				bool a1=0,a2=0;
				if(b[d-1][e]==1){
					if(p[d-1][e-1]==0){
						a1=1;
					}else{
						a2=1;
					}
				}
				if(b[d+1][e]==1){
					if(p[d][e-1]==0){
						a1=1;
					}else{
						a2=1;
					}
				}
				if(b[d][e-1]==1){
					if(q[d-1][e-1]==0){
						a1=1;
					}else{
						a2=1;
					}	
				}
				if(b[d][e+1]==1){
					if(q[d-1][e]==0){
						a1=1;
					}else{
						a2=1;
					}
				}
				if(a1==1&&a2==1){
					b[d][e] = 1;
					que.push(MP(d-1,e));
					que.push(MP(d+1,e));
					que.push(MP(d,e-1));
					que.push(MP(d,e+1));	
				}
			}
		}
		bool flag = 0;
		if(b[r-1][c]==1){
			if(p[r-1][c-1]==0){
				flag=1;
			}
		}
		if(b[r+1][c]==1){
			if(p[r][c-1]==0){
				flag=1;
			}
		}
		if(b[r][c-1]==1){
			if(q[r-1][c-1]==0){
				flag=1;
			}
		}
		if(b[r][c+1]==1){
			if(q[r-1][c]==0){
				flag=1;
			}
		}
		if(flag){
			cout << "Yes" << endl;
		}else{
			cout << "No" << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 5804
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
#define pb push_back
#define mpr make_pair
#define pii pair<int, int>
#define pll pair<ll, ll>
#define ll long long
#define ld long double
#define all(arr) arr.begin(), arr.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define fo(i, l, r) for (int i = l; i <= r; i++)
#define INF 1000000001
#define inf1 1000000000000000001
#define mod 1000000007
#define pie 3.14159265358979323846264338327950L
#define N 100005
#define mid(l, r) l + (r - l) / 2
#define vec vector<int>
#define vecl vector<ll>
#define umap unordered_map<ll,ll>
#define yes cout << "YES" << endl;
#define no cout << "NO" << endl;
#define endl "\n"
using namespace std;

int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};  
int ddx[8]={1,1,0,-1,-1,-1,0,1},ddy[8]={0,1,1,1,0,-1,-1,-1};
ll gcd(ll a,ll b){ if(!a)return b;return gcd(b%a,a);}
ll lcm(ll a, ll b) { return (a*b)/ gcd(a,b);}


int n;
vector<ld> arr(N);
double dp[3009][3009];



void test_case() {

    cin>>n;

    rep(i,n) {
        cin>>arr[i];
    }

    memset(dp,0,sizeof(dp));
    dp[1][1] = arr[0];
    dp[1][0] = 1 - arr[0];

    for(int i=2; i<=n; i++) {
        for(int j=0; j<=i; j++) {
            
            dp[i][j]+= dp[i-1][j] * (1 - arr[i-1]);
            if(j-1>=0)
                dp[i][j]+= dp[i-1][j-1] * (arr[i-1]);
        }
    }

    ld ans = 0;
    
    ll mi = (n+2)/2;

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





}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout<<fixed<<setprecision(20);

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


    int t = 1;
    //cin >> t;
    while(t--)
    {   
        test_case();
    }
}


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

using namespace std;

int frommcxi(string mcxi) {
    
    int d = 1;
    int n = 0;
    char pre;
    for (int i = mcxi.size() - 1; i >= 0; --i) {
        char c = mcxi[i];
        switch(mcxi[i]){
            case 'm': d = 1000;
            break;
            case 'c': d = 100;
            break;
            case 'x': d = 10;
            break;
            case 'i': d = 1;
            break;
        }
        if (c == 'm' || c == 'c' || c == 'x' || c == 'i') {
            if (i == 0) n += d;
            else {
                int num = mcxi[i - 1] - '0';
                if (num <= 9 && num >= 2) n += d * num;
                else n += d;
            }
        }
        pre = mcxi[i];
    }
    return n;
}

string tomcxi(int n) {
    int m = n / 1000;
    n -= m * 1000;
    int c = n / 100;
    n -= c * 100;
    int x = n / 10;
    int i = n - x * 10;

    string mcxi = ""; 
    if (m != 0) mcxi += (m != 1 ? to_string(m) : "") + "m";
    if (c != 0) mcxi += (c != 1 ? to_string(c) : "") + "c";
    if (x != 0) mcxi += (x != 1 ? to_string(x) : "") + "x";
    if (i != 0) mcxi += (i != 1 ? to_string(i) : "") + "i";
    return mcxi;
}

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        string mcxi1;
        string mcxi2;
        cin >> mcxi1 >> mcxi2;
        //cout << mcxi1 << " -> "<< frommcxi(mcxi1) <<endl;
        cout << tomcxi(frommcxi(mcxi1) + frommcxi(mcxi2)) << endl;
    }
}

Measured memory_bytes: 3120
#include <stdio.h>
#include <vector>
using namespace std;

int N; char S[100100];

int main()
{
	scanf ("%s",S+1);
	while (S[N+1]) N++;

	if (S[N] == '1' || S[1] == '0'){
		puts("-1");
		return 0;
	}

	for (int i=1;i<N;i++) if (S[i] != S[N-i]){
		puts("-1");
		return 0;
	}

	vector<int> last;
	last.push_back(1);
	for (int i=2;i<=N;i++){
		if (S[i] == '1'){
			for (auto &x : last) printf ("%d %d\n",x,i);
			last.clear();
		}
		last.push_back(i);
	}
	printf ("%d %d\n",N-1,N);

	return 0;
}

Measured memory_bytes: 2040
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var all = 0;
            var prev = 0;
            for (var i = 0; i < A.Length; i++)
            {
                all += Math.Abs(A[i] - prev);
                prev = A[i];
            }
            all += Math.Abs(prev);

            var tmp = new int[N + 2];
            for (var i = 0; i < A.Length; i++)
            {
                tmp[i + 1] = A[i];
            }
            for (var i = 1; i < tmp.Length - 1; i++)
            {
                var sub = Math.Abs(tmp[i] - tmp[i - 1]) + Math.Abs(tmp[i + 1] - tmp[i]);
                var add = Math.Abs(tmp[i + 1] - tmp[i - 1]);
                Console.WriteLine(all - sub + add);
            }
        }
    }
}


Measured memory_bytes: 27612
N, P = map(int, input().split())
A = list(map(int, input().split()))
DP = []
for _ in range(N) :
    DP.append([0,0])
    
DP[0][0] += 1
DP[0][A[0]%2] += 1
for i in range(1,N) :
    for j in range(2) :
        DP[i][ (A[i]+j)%2 ] += DP[i-1][j]
        DP[i][j] += DP[i-1][j]
        
print(DP[N-1][P])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int n;
  cin >> n;
  if(n<1200)cout << "ABC" << endl;
  else if(n<2800) cout << "ARC" << endl;
  else cout << "AGC" << endl;
}


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

int main(){

    int a,b,c,d;
    cin >> a >> b >>c >> d;
    int l=a+b;
    int r=c+d;
    if(l>r){
        cout << "Left" <<endl;
    }else if(l<r){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if(a+b == 4)
    {
        cout <<2 << endl;
    }
    else if(a + b == 5)
    {
        cout << 1 << endl;
    }
    else if(a + b == 3)
    {
    cout << 3 << endl;
    }
    return 0;


}


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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  for(int i=0;i<s.length();i++){
    if(s[i]!='1'){
      if(k-1<i){
        cout << 1 << endl;
        return 0;
      }
      cout << s[i] << endl;
      return 0;
    }
  }
  cout << 1 << endl;
  return 0;
}


Measured memory_bytes: 256
a = input().split()
n = int(a[0])
x = int(a[1])
l = input().split()
d = 0
c = 1
for i in range(n):
  d = d + int(l[0])
  l.pop(0)
  if d > x:
    break
  c += 1  
print(c)
  

Measured memory_bytes: 3060
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N;
  std::cin >> N;
  switch (N) {
  case 1:
    std::cout << "Hello World" << std::endl;
    break;
  case 2:
    i64 A, B;
    std::cin >> A >> B;
    std::cout << (A + B) << std::endl;
    break;
  }
  return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/connected_components.hpp>

using namespace std;

using edge_t = std::pair<int, int>;
using graph_t =
    boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;

int calc(int const n, const graph_t& graph, const std::vector<edge_t>& edges) {
  int ret = 0;
  for (const auto& e : edges) {
    graph_t g = graph;
    boost::remove_edge(e.first, e.second, g);
    std::vector<int> component(n);
    if (boost::connected_components(g, &component[0]) > 1) {
      ret++;
    };
  }
  return ret;
}

int main() {
  int n, m;
  std::cin >> n >> m;
  std::vector<edge_t> edges(m);
  for (auto& e : edges) {
    std::cin >> e.first >> e.second;
    e.first--;
    e.second--;
  }
  const graph_t graph(edges.begin(), edges.end(), n);
  std::cout << calc(n, graph, edges) << std::endl;
  return 0;
}


Measured memory_bytes: 256
ans :: (Int,[Int]) -> (Int,[Int])
ans (n,[]) = (n,[])
ans (n,x@(xh:[])) = (n,x)
ans (n,x@(xh:xs)) = 
  let m = minimum xs
      h = takeWhile (> m) xs
      r = drop 1 $ dropWhile (> m) xs
  in
    if xh <= m -- no exchange
    then
      let (tn,tx) = ans (n,xs)
      in (tn,(xh:tx))
    else
      let el = h ++ (xh:r)
          (tn,tx) = ans (n, el)
      in (tn+1,(m:tx))

main = do
  n <- getLine
  i <- getLine
  let n' = read n :: Int
      i' = map read $ words i :: [Int]
      (on,ol)  = ans (0,i')
  putStrLn $ unwords $ map show ol
  print on

Measured memory_bytes: 4004
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <cctype>
#include <string>
#include <map>
#include <set>
#include <math.h>
#include <cmath>
#define ll long long

using namespace std;

int main(){

  int N, K ,Q, A;
  cin >> N >> K >>Q;

  map<int,int>m;
  for (int i = 0; i < N; i++) {
    m[i] = K;
  }

  vector<int> vec(Q);
  for (int q = 0; q < Q; q++) {
    cin >> A;
    m[A-1]++;
  }


  for(auto i = m.begin(); i != m.end(); i++) {
    i->second -= Q;
  }

  for(auto i = m.begin(); i != m.end(); i++) {
    if(i->second > 0){
      cout << "Yes" << endl;
    } else {
      cout << "No" << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

using namespace std;

#define INF (100000000)

typedef pair<int, int> P;

int main() {
    int N,M;
    cin >> N >> M;

    vector<int> D;
    vector<P> DPAIR(M);
    for(int i=0; i<M; ++i) DPAIR[i]=P(i,0);
    for(int i=0; i<N; ++i) {
        int temp;
        cin >> temp;
        D.push_back(temp-1);
        ++DPAIR[temp-1].second;
    }

    vector<int> DD[M];

    for(int i=0; i<M; ++i) {
        DD[i].resize(N);
        DD[i][0]=(D[0]==i?1:0);
        for(int j=1; j<N; ++j) {
            DD[i][j]=DD[i][j-1]+(D[j]==i?1:0);
        }
    }

    string ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    string istr=ALPHA.substr(0,M);
    vector<int> indx(M+1);
    map<string,P> mp;

    for(int c=1; c<=M; ++c) {
        indx[c]=M;
        for(int i=0; i<c; ++i) indx[i]=i;
        --indx[c-1];
        while(indx[0]<M-c || c==M) {
            int now=c-1;
            while(indx[0]!=M-c || c==M) {
                if(indx[now+1]-indx[now]>1) {
                    ++indx[now];
                    break;
                } else if(indx[now]-indx[now-1]>1) {
                    ++indx[now-1];
                    for(int i=now; i<c; ++i) indx[i]=indx[i-1]+1;
                    break;
                } else {
                    --now;
                }
            }

            // main
            int cnt=INF;
            int len;
            string str="";
            for(int j=0; j<c; ++j) {
                str.push_back(istr[indx[j]]);
            }
            for(int i=0; i<c; ++i) { // most back position's index
                string s=str;
                s.erase(s.begin()+i);
                if(s=="") {
                    cnt=min(cnt,DPAIR[indx[i]].second-DD[indx[i]][DPAIR[indx[i]].second-1]);
                    len=DPAIR[indx[i]].second;
                } else {
                    int fst=mp[s].first;
                    int snd=mp[s].second;
                    cnt=min(cnt,fst+DPAIR[indx[i]].second-DD[indx[i]][snd+DPAIR[indx[i]].second-1]+DD[indx[i]][snd-1]);
                    len=snd+DPAIR[indx[i]].second;
                }
            }
            
            mp[str]=make_pair(cnt,len);
            if(c==M) break;
        }
    }

    cout << mp[istr].first << endl;
    return 0;
}


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



int main(){
    string cmd, str;
    unordered_set<string> s;
    int N;
    cin >> N;
    for(int i = 0; i < N; ++i){
        cin >> cmd;
        cin >> str;
        if(cmd == "insert"){
            s.insert(str);
        }else if(cmd == "find"){
            if(s.count(str) != 0){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
}

Measured memory_bytes: 32228
h,w = map(int, input().split())
m = [input() for _ in range(h)]
seen = [[0]*w for _ in range(h)]
dxy =[(1,0),(0,1),(-1,0),(0,-1)]
cnt = 0
for i in range(h):
  for j in range(w):
    if not seen[i][j]:
      bcnt,wcnt = 0,0
      q = [(i,j)]
      while q:
        y,x = q.pop()
        if seen[y][x]:
          continue
        if m[y][x] == "#":
          bcnt += 1
        else:
          wcnt += 1
        seen[y][x] = 1
        for dx,dy in dxy:
          if 0<=x+dx<w and 0<=y+dy<h and not seen[y+dy][x+dx] and m[y+dy][x+dx] != m[y][x]:
            q.append((y+dy,x+dx))
      cnt += bcnt*wcnt
print(cnt)

Measured memory_bytes: 19520
n = gets.to_i
cities = []
n.times do
  x, y = gets.split.map(&:to_i)
  cities << [x, y]
end

def distance(a, b)
  Math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)
end

total_distance = 
  cities.permutation.to_a.map do |perm|
    (0...n - 1).inject(0) { |d, i| d + distance(perm[i], perm[i + 1]) }
  end

puts total_distance.inject(:+) / total_distance.size


Measured memory_bytes: 9084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    string s;
    cin >> s;
    if(s =="ABC"){
        cout <<"ARC"<<endl;
    }
else{
    cout << "ABC"<<endl;
}
}

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

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "]"; return os; }


// import here

int main(){
    LL n;
    cin >> n;
    vector<LL> a(n), b(n);
    for(LL i = 0; i < n; ++i){
        cin >> a[i];
    }
    for(LL i = 0; i < n; ++i){
        cin >> b[i];
    }
    vector<LL> c(n);
    for(LL i = 0; i < n; ++i){
        c[i] = a[i] - b[i];
    }
    sort(c.begin(), c.end());
    LL cnt = 0;
    LL cur = 0;
    LL total = 0;
    while(c[cur] < 0){
        total += c[cur];
        ++cur;
        while(total < 0){
            if(cnt + cur > n) break;
            ++cnt;
            total += c[n-cnt];
        }
    }
    if(cnt + cur > n){
        cout << "-1" << endl;
    }else{
        cout << cnt + cur << endl;
    }
    return 0;
}



Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,i,j,k,ans,x,y;
    cin>>n;
    ans=0;
    for (i=1;i<=n;i++)
    {
    	for (j=1;j<=n;j++)
    	{
    		for (k=1;k<=n;k++)
    		{
    			x=__gcd(k,j);
    			y=__gcd(x,i);
    			ans+=y;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include <vector>
#include <math.h>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;




        int main() {
            string s;
            cin >> s;
            long long n = 0;
            long long a[2][2019] = {0};
            for (int i = 0; i < s.size(); ++i) {
                for (int j = 0; j < 2019; ++j) {
                    a[(i + 1) % 2][(j * 10 + s[i] - '0') % 2019] = a[i % 2][j];
                }
                a[(i + 1) % 2][s[i] - '0']++;
                n += a[(i + 1) % 2][0];
            }
    cout << n;
    return 0;

}

Measured memory_bytes: 3368
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+3;
string s[105],p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r;
    cin>>n>>m;
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        //cout<<s[i]<<"\n"<<s[i]<<"\n";
    }
    for(i=0;i<n;i++)
    {
        cout<<s[i]<<"\n"<<s[i]<<"\n";
    }
    return 0;
}



Measured memory_bytes: 256
//package Test;

import java.util.*;

public class Main {

    static class Solution {

        void solve(int s){

        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[n];
        int[] c = new int[n];
        int[] d = new int[n];
        for(int i = 0; i < n; i++) {
            int x = scanner.nextInt();
            int y = scanner.nextInt();
            a[i] = x + y;
            b[i] = x - y;
            c[i] = y - x;
            d[i] = -y - x;
        }
        Arrays.sort(a);
        Arrays.sort(b);
        Arrays.sort(c);
        Arrays.sort(d);
        System.out.println(Math.max(Math.max(a[n-1] - a[0], b[n-1] - b[0]), Math.max(c[n-1] - c[0], d[n-1] - d[0])));
        // Solution solution = new Solution();
        // solution.solve(s);

    }
}


Measured memory_bytes: 64944
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[105];
ll dp[105][5];

ll dfs(int pos,int state,bool lead,bool limit)
{
    if(pos==-1) 
		if (state == 0) return 1;
		else return 0;
    if(!limit && !lead && dp[pos][state]!=-1) return dp[pos][state];
    if (state < 0)
    	return 0;
    int up=limit?a[pos]:9;
    ll ans=0;
    for(int i=0;i<=up;i++) {
    	if (i)
        	ans+=dfs(pos-1,state-1,lead && i==0,limit && i==a[pos]);
        else
        	ans+=dfs(pos-1,state,lead && i==0,limit && i==a[pos]);
    }
    if(!limit && !lead) dp[pos][state]=ans;
    return ans;
}

ll solve(string s, int k)
{
 	int pos = s.size();
	for (int i = 0; i < pos; i++) {
		a[i] = s[pos - i - 1] - '0';
	}
    return dfs(pos-1,k,true,true);//刚开始最高位都是有限制并且有前导零的，显然比最高位还要高的一位视为0嘛
}

int main()
{
	string s; int k;
	cin >> s >> k;
	memset(dp,-1,sizeof(dp));
	cout << solve(s, k);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <math.h>
#include <time.h>
using namespace std;
const long long mod = 1000000007;
#define ll long long
#define P pair<int, int>
#define dump(x)                             \
    if (dbg) {                              \
        cout << #x << " = " << (x) << endl; \
    }
bool dbg = false;
long long gcd(long long a, long long b){
   if (a % b == 0)
   {
       return(b);
   }
   else
   {
       return(gcd(b, a % b));
   }
}
long long lcm(long long a, long long b){
   return (a / gcd(a, b))* b;
}
//---------------------------------------------------------------------------------------------------
/*ここからいじる*/
//---------------------------------------------------------------------------------------------------
int n, x, y;
vector<int>ans(2020);
void solve(){
    for(int i = 0; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            int tmp;
            if(i < x && j <= x){//あ→あ
                ans.at(j - i)++;
            }
            else if(i >= y && j > y){//い→い
                ans.at(j - i)++;
            }
            else if(i <= x && j >= y){//あ→い
                ans.at(j - i - (y - x) + 1)++;
            }
            else if(i <= x && j >= x && j <= y){//あ→う
                tmp = min(j - i, y - j + 1 + (x - i));
                ans.at(tmp)++;
            }
            else if(i >= x && i <= y && j >= y){//う→い
                tmp = min(j - i, i - x + 1 + (j - y));
                ans.at(tmp)++;
            }
            else{//う→う
                tmp = min(j - i, i - x + 1 + (y - j));
                ans.at(tmp)++;
            }
        }
    }
}
int main(){
    cin >> n >> x >> y;
    x--;
    y--;
    solve();
    for(int i = 0; i < n - 1; i++){
        cout << ans.at(i + 1) << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
#define MAXLEN 20000
 
int garea,gareas[(MAXLEN/2)+1],gcnt,gend;
 
 
int getArea( char *inputs, int start, int end )
{
    int i;
    int ravine,water;
    
    gareas[gcnt]=ravine=water=0;
    for( i=start; i!=end; i++ ) {
        if( '\\'== *(inputs+i) ) {
           	water+=(ravine*2);
            ravine++;
            water++;
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
        	ravine--;
        } else {
	     	water+=ravine;
        }       
    }
	gareas[gcnt]+=water;
    
    return gareas[gcnt];
}
  
int checkRavine( char *inputs, int start )
{
    int i;
    int ravine, minh, tmpi;
    
    ravine=0;
    tmpi=minh=MAXLEN;
    for( i=start; i<=gend && '\0'!=*(inputs+i); i++ ) {
        if( 0 <= ravine && '\\'== *(inputs+i) ) {
            ravine++;
        } else if( 0 != ravine && '/' == *(inputs+i) ) {
            ravine--;
            if( ravine < minh ) {
        		minh=ravine;
        		tmpi=i;
            }
            if( 0 == ravine ) {
            	garea+=getArea( inputs, start, i+1 );
            	gcnt++;
			    gend=MAXLEN;           	
                return i-start;
            }
        }
    }
	gend=tmpi;
    return 0;
}
 
 
void getAreas( char *inputs )
{
    int i,next;
     
    next=0;
    for( i=0; i<=gend && '\0'!=inputs[i]; i++ ) {
    	if( '_' !=inputs[i] && '/' !=inputs[i] ) {
	        next=checkRavine( inputs, i );
	        i+=next;
        }
    }
 
    return;
}
 
int main( void ) 
{
    char inputs[MAXLEN+1];
    int i;
 
    scanf( "%s", inputs );
    garea=gcnt=0;
    gend=MAXLEN;
    getAreas( inputs );
     
    printf( "%d\n", garea );
    
    if( gcnt ) {
        printf( "%d ", gcnt );
        for( i=0; i<gcnt; i++ ) {
            printf( "%d", gareas[i] );
            if( i < gcnt-1 ) {
            	printf( " " );  
            }
        }
        printf( "\n" );
       
    } else {
        printf( "0\n" );
    }
     
    return 0;
}

Measured memory_bytes: 576
#include <stdio.h>

struct Card {
    int value;
    char type;
};
typedef struct Card card_t;


void swap(card_t A[], int a, int b)
{
    card_t t = A[a];
    A[a] = A[b];
    A[b] = t;
}

void bubbleSort(card_t A[], int n)
{
    int i, j;
    for (i=1; i<n; i++) {
        for (j=i; j>0; j--) {
            if (A[j-1].value > A[j].value) {
                swap(A, j-1, j);
            }
        }
    }
}

void selectionSort(card_t A[], int n)
{
    int i, j, min;
    for (i=0; i<n; i++) {
        min = i;
        for (j=i; j<n; j++) {
            if (A[j].value < A[min].value) {
                min = j;
            }
        }
        swap(A, i, min);       
    }
}

int main()
{
    int i;
    int N;
    card_t A[40], B[40];
    
    scanf("%d", &N); 
    getchar(); //??????
    for (i=0; i<N; i++) {
        scanf("%c", &A[i].type);
        scanf("%d", &A[i].value);
        getchar(); // ??????
        B[i] = A[i];
    }
    
    bubbleSort(A, N);
    selectionSort(B, N);
    
    // bubbleSort
    for (i=0; i<N-1; i++) {
        printf("%c", A[i].type);
        printf("%d ", A[i].value);
    }
    printf("%c", A[i].type);
    printf("%d\n", A[i].value);
    puts("Stable");
    
    
    // selectionSort
    int isStable = 1;
    for (i=0; i<N-1; i++) {
        printf("%c", B[i].type);
        printf("%d ", B[i].value);
        if (A[i].type != B[i].type) {
            isStable = 0;
        }
    }
    printf("%c", B[i].type);
    printf("%d\n", B[i].value);
    puts(isStable? "Stable" : "Not stable");
    
    return 0;
}

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

using namespace std; 
 
#define int long long
#define M 1000000007 
 
signed main(){
	
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
	
//	int t;
//	cin >> t;
//	while(t--){
		int n;
		cin >> n;
		cout << n*n*n << endl;
//	}
}
 

Measured memory_bytes: 3636