akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int compare_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){
    int n;
    scanf("%d",&n);
    int a[n],b[n],dif[n];
    int i,count = 0;
    long long sum = 0;
    for(i =0;i<n;i++) dif[i] = 0;
    for(i = 0;i<n;i++){
        scanf("%d",&a[i]);
    }
    for(i = 0;i<n;i++){
        scanf("%d",&b[i]);
        if(a[i] < b[i]){
            count++;
            sum += (b[i] - a[i]);
        }else dif[i] = a[i] - b[i];
    }
    qsort(dif,n,sizeof(int),compare_int);//降順整列
    i = 0;
    while(sum > 0 && i < n){
        if(dif[i] <= 0) break;
        sum -= dif[i];
        count++;
        i++;
    }
    if(sum > 0) count = -1;
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 1660
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010


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

  s.erase(unique(s.begin(),s.end()),s.end());

  printf("%d\n",(int)s.size()-1);
  
  return 0;
}


Measured memory_bytes: 1020
def length_of_lcs(x, y):
    n = len(y)
    #pre_row = [0] * (n + 1)
    cur_row = [0] * (n + 1)
    for x_c in x:
        prev_row = cur_row[:]
        for j, y_c in enumerate(y):
            if x_c == y_c:
                cur_row[j+1] = prev_row[j] + 1
            elif cur_row[j] > cur_row[j+1]:
                cur_row[j+1] = cur_row[j]

    return cur_row[n]


if __name__ == '__main__':
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(length_of_lcs(x, y))



Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	int h, a; cin >> h >> a;
	cout << (h + a - 1) / a;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>
#include<cmath>
#include <bits/stdc++.h>
using namespace std;

int main(){
	int A,B,C;
	int N;
	string S,T;
	vector<int> V;
	int ans = 0;
	cin>>N;
	
	
	switch(N%10){
		case 0:cout<<"pon"<<endl;break;
		case 1:cout<<"pon"<<endl;break;
		case 6:cout<<"pon"<<endl;break;
		case 8:cout<<"pon"<<endl;break;
		case 2:cout<<"hon"<<endl;break;
		case 4:cout<<"hon"<<endl;break;
		case 5:cout<<"hon"<<endl;break;
		case 7:cout<<"hon"<<endl;break;
		case 9:cout<<"hon"<<endl;break;
		case 3:cout<<"bon"<<endl;break;
	}
	
	
	
	
	
}

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

#define all(x) x.begin(),x.end()
#define pb push_back
#define ss second
#define ff first

int main(){
	int n;	cin>>n;
	string str;	cin>>str;
	stack<char> s;
	for(int i=0;i<str.size();i++){
		if(s.empty())	s.push(str[i]);
		else
			if(s.top() != str[i])	s.push(str[i]);
	}
	cout<<s.size()<<endl;
}


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

int main(){
	int a,b;
	cin >>a>>b;
	if((a+b)%2 ==0){
	cout << (a+b)/2.0<< endl;
	}
	else{
	cout<<(a+b)/2+1<< endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e17+9
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

ll w, h;
ll dp[110][110][10];

int main(){
	while (cin >> w >> h&&w + h){
		REP(i, 110)REP(j, 110)REP(k, 4)dp[i][j][k] = 0;
		REP(k, 4)dp[0][0][k] = 1;
		REP(i, h){
			REP(j, w){
				if (i >= 1){
					if (j != 0){
						dp[i][j][2] += dp[i - 1][j][3];
						dp[i][j][0] += dp[i - 1][j][2];
					}
					dp[i][j][0] += dp[i - 1][j][0];
				}
				if (j >= 1){
					if (i != 0){
						dp[i][j][1] += dp[i][j - 1][0];
						dp[i][j][3] += dp[i][j - 1][1];
					}
					dp[i][j][3] += dp[i][j - 1][3];
				}
				REP(k, 4)dp[i][j][k] %= 100000;
			}
		}
		int ans = 0;
		REP(i, 4){
			ans += dp[h - 1][w - 1][i];
		}
		cout << ans % 100000 << endl;

	}
}

Measured memory_bytes: 4040
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        n: usize,

    }

    let mut res: Vec<(String, i32, usize)> = vec![];
    for i in 0..n {
        input! {s: String, p: i32}
        res.push((s, -p, i + 1));
    }

    // res.sort_by(|a, b| b.1.cmp(&a.1));
    // res.sort_by(|a, b| a.0.cmp(&b.0));
    res.sort();

    for e in &res {
        println!("{}", e.2);
    }
}


Measured memory_bytes: 2160
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

#pragma GCC optimize("Ofast")

int main(){
    long long int A,B,K;
    cin >> A >> B >> K;
    long long int res=0;
    long long int num_A=A;
    long long int num_B=B;
    
    
    if(K<=num_A){
        num_A-=K;
    }
    else{
        K=K-num_A;
        num_A=0;
        if(K<=num_B){
            num_B=num_B-K;
        }
        else{
            num_B=0;
        }
    }
    cout << num_A << " " << num_B;
    }

Measured memory_bytes: 256
#include <algorithm>
// #include <cstdlib>
#include <cstring>
#include <cstdio>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
// #include <bitset>
const int oo=2139063143;
const int N=310;
const int P=1000000007;
using namespace std;
typedef long long LL;
typedef double db;
#define pritnf printf
//char buf[1<<22],*p1=buf,*p2=buf,obuf[1<<22],*O=obuf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
template <typename T>
inline void sc (T &x)
{
    x=0; static int p; p=1; static char c; c=getchar();
    while (!isdigit(c)) { if (c=='-') p=-1; c=getchar(); }
    while ( isdigit(c)) { x=(x<<1)+(x<<3)+(c-48); c=getchar(); }
    x*=p;
}
template <typename T>
inline void print (T x)
{
	if (x< 0) putchar('-'),x=-x;
	if (x>=10) print(x/10);
	putchar(x%10+'0');
}
template <typename T>
inline void pr (T x) { print(x),putchar('\n'); }
int del(int x) { return x>=P?x-P:x; }
void add(int &x,int y) { x=del(x+y); }
int f[N][N][N];
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
vector <pii> v[N];
int main ()
{
	// freopen (".in","r",stdin);
	// freopen (".out","w",stdout);
	int n,m; sc(n),sc(m);
	while (m--)
	{
		int l,r,x; sc(l),sc(r),sc(x);
		v[r].pb (mp(l,x));
	}
	f[1][0][0]=1;
	for (int i=1; i<=n; i++)
	{
		for (pii g:v[i])
		{
			int l=g.fi,x=g.se;
			for (int j=0; j< i; j++)
			{
				for (int k=0; k< (j?j:1); k++)
				{
					int h=(j>=l)+(k>=l)+1;
					if (h!=x) f[i][j][k]=0;
				}
			}
		}
		for (int j=0; j< i; j++)
			for (int k=0; k< (j?j:1); k++) if (f[i][j][k])
			{
				int g=f[i][j][k];
				add(f[i+1][j][k],g);
				add(f[i+1][i][k],g);
				add(f[i+1][i][j],g);
			}
	}
	int ans=0;
	for (int j=0; j< n; j++)
		for (int k=0; k< (j?j:1); k++)
			add(ans,f[n][j][k]);
	pr(3LL*ans%P);

	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"


template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

typedef cc_hash_table<int, int, hash<int > > ht;


#define int long long 
#define  st first
#define  nd second

const int M = 998244353;
const int  maxn = 1000001;
const int  inf =  1e16;


void run_tests(){
  int n , k ; 
  cin >> n >> k ; 
  int v[k][2];
  for(int i = 0 ; i<k ; i++){
    cin >> v[i][0] >> v[i][1] ;
  }
  int a[n+2]={0};
  a[1]=1;
  for(int i = 1 ; i<=n ; i++){
     if(i!=2)
     a[i] = (a[i-1] + a[i])%M;
     dbg(a[i]);
     for(int j = 0 ; j<k ; j++){
       int l = min(i+v[j][0],n+1);
       int r = min(n+1,i+v[j][1]+1);

       a[l]= (a[l] + a[i])%M;
       a[r]= (((a[r] - a[i])%M) +M)%M;
     }
  }

  cout << a[n];

}
int32_t main(){

  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);

  int te=1 ; 
  //cin >> te ; 
  while(te--){
    run_tests();
  }
  
  }

  
  

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

vector <vector <int> > v[8];

#define N 40005
#define M 8

struct node {
	int nxt[M];
	int f; bool ok;
} nd[N];

int tot, rt;
int q[N], dp[N][45];

const int mod = 1e9 + 7;

void add(int &x, int y) {x += y; if (x >= mod) x -= mod;}

int insert(vector <int> &v) {
	int u = rt;
    for (int c : v) {
		if (!nd[u].nxt[c]) nd[u].nxt[c] = tot ++;
		u = nd[u].nxt[c];
    }
    nd[u].ok = 1;
	return u;
}
void getf() {
	int h = 0, t = 0;
	for (int c = 0; c < M; c ++) if (nd[rt].nxt[c]) q[t++] = nd[rt].nxt[c];
	while (h < t) {
		int u = q[h ++];
		for (int c = 0; c < M; c ++) {
			if (nd[u].nxt[c]) {
				q[t ++] = nd[u].nxt[c];
				nd[nd[u].nxt[c]].f = nd[nd[u].f].nxt[c];
			}
			else nd[u].nxt[c] = nd[nd[u].f].nxt[c];
		}
	}
	return;
}

int mul(int x, int y) {return 1ll * x * y % mod;}
int pw[45] = {1};

int main() {
    v[1] = {{1}};
    for (int i = 1; i < 45; i ++) pw[i] = 1ll * pw[i-1] * 10 % mod;
    for (int i = 2; i < 8; i ++) {
        for (int j = 1; j < i; j ++) {
            for (auto x : v[i-j]) {
                v[i].push_back(x);
                v[i].back().push_back(j);
            }
        }
		v[i].push_back({i});
    }
	tot = 0;
	rt = tot ++;
    int n, x, y, z;
    scanf("%d %d %d %d", &n, &x, &y, &z);
    for (auto a : v[x]) {
        for (auto b : v[y]) {
            for (auto c : v[z]) {
                vector <int> A;
                A.resize(a.size() + b.size() + c.size());
                copy(a.begin(), a.end(), A.begin());
                copy(b.begin(), b.end(), A.begin() + a.size());
                copy(c.begin(), c.end(), A.begin() + a.size() + b.size());
                insert(A);
            }
        }
    }
    getf();
    dp[rt][0] = 1;
    int ans = 0;
    for (int i = 0; i < n; i ++) {
		for (int k = 0; k < tot; k ++) if (!nd[k].ok) {
            int &val = dp[k][i];
			if (!val) continue;
            for (int d = 1; d <= 10; d ++) {
                int dd = d >= 8 ? 0 : d;
                int id = nd[k].nxt[dd];
                add(dp[id][i+1], val);
            }
		}
        for (int k = 0; k < tot; k ++) if (nd[k].ok) {
            add(ans, mul(dp[k][i+1], pw[n-i-1]));
        }
    }
    printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 11084
#include <iostream>
using namespace std;
int main() {
    int a,b,c,d,e,k;
    cin >> a >> b >> c >> d >> e >> k;
    int count = 0;

    

    if((e - a) <= k){
        cout << "Yay!";
    }else{
        cout << ":(";
    }
}

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

int main()
{
	char D[65536];
	char s[] = "AIZUNYAN";
	scanf("%s", &D);
	int len = strlen(D);
	
	for (int i = 0; i < len - 7; i++){
		int num[100] = {0};
		for (int j = 0; j < 8; j++){
			num[D[i + j]]++;
		}
		
		if (
		num['A'] == 2 && num['I'] == 1 && 
		num['D'] == 1 && num['U'] == 1 &&
		num['N'] == 2 && num['Y'] == 1
		){
			for (int j = 0; j < 8; j++){
				D[i + j] = s[j];
			}
			i += 7;
		}
	}
	
	printf("%s\n", D);
	
	return 0;
}

Measured memory_bytes: 956
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int ans;

template <typename T>
class UnionFind{
    public:
        int n;
        vector<T> p, rank, cnt;

        UnionFind(int n)
            : n(n), p(n+1, -1), rank(n+1), cnt(n+1){
                for(int i = 0; i <= n; i++){
                    cnt[i] = 1;
                }
            }

        int find(int v){
            if(p[v] == -1){
                return v;
            }
            p[v] = find(p[v]);
            return p[v];
        }

        bool unite(int u, int v){
            u = find(u);
            v = find(v);

            if(u == v){
                return false;
            }

            if(rank[u] < rank[v]){
                swap(u, v);
            }

            if(rank[u] == rank[v]){
                rank[u]++;
            }

            p[v] = u;

            ans += cnt[u] * (cnt[u] - 1) / 2;
            ans += cnt[v] * (cnt[v] - 1) / 2;
            cnt[u] += cnt[v];
            ans -= cnt[u] * (cnt[u] - 1) / 2;
            cnt[v] = 0;

            return true;
        }
};

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

    int n, m;
    cin >> n >> m;

    vector<int> a(m), b(m);
    rep(i, m) cin >> a[i] >> b[i];

    ans = n * (n - 1) / 2;
    UnionFind<int> uf(n);
    vector<int> va(m);
    for(int i = m - 1; i >= 0; i--){
        va[i] = ans;
        uf.unite(a[i], b[i]);
    }

    rep(i, m){
        cout << va[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 6016
/******** JUST GIVE IT A TRY,COULD'NT SOLVED YOU LEARNED SOMETHING NEW 
AND IF SOLVED IT MEANS YOU GREW *********/
    
//author RKN
 
#include<bits/stdc++.h>
using namespace std;
 
#define ll long long 
#define pr pair<ll,ll>
#define pb push_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define N 200001
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);  
/*///////////////////////////////////////////////////////////////
DYNAMIC PROGRAMMING
///////////////////////////////////////////////////////////////*/

int main()
{
        int n;
        cin>>n;
        int arr[n];
        for(int i=0;i<n;i++)
        cin>>arr[i];
        vector<int>dp(n+1);
        fill(all(dp),1e9);
        dp[0]=0;
        for(int i=1;i<n;i++)
        {
            if(i-1>=0)
            dp[i]=min(dp[i],dp[i-1]+abs(arr[i]-arr[i-1]));
            if(i-2>=0)
            dp[i]=min(dp[i],dp[i-2]+abs(arr[i]-arr[i-2]));
        }
        cout<<dp[n-1]<<"\n";
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
#include <queue>

using namespace std;

int main(){
	
	long long int INF = 10000000000000000;
	
	long long int sum[16][10];
	
	for(int i = 0; i < 15; i++){
		for(int j = 0; j < 10; j++){
			sum[i][j] = 0;
		}
	}
	sum[1][1] = 1;
	
	for(int dig = 1; dig < 15; dig++){
		for(int i = 2; i < 10; i++){
			sum[dig][i] = sum[dig][i - 1];
			if(i != 4 && i != 6){
				sum[dig][i] += sum[dig][1];
			}
		}
		sum[dig + 1][1] = sum[dig][9] + sum[dig][1];
	}
	
	for(int i = 0; i < 15; i++){
		sum[i][4] = INF;
		sum[i][6] = INF;
	}
	
	long long int n;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		
		int dig_start;
		
		for(int i = 1; i < 15; i++){
			if(n < sum[i][1]){
				dig_start = i - 1;
				break;
			}
		}
		
		for(int i = dig_start; i >= 1; i--){
			for(int j = 9; j >= 0; j--){
				if(n >= sum[i][j]){
					cout << j;
					n -= sum[i][j];
					break;
				}
				if(j == 0){
					cout << 0;
				}
			}
		}
		cout << endl;
		
	}
	
	return 0;
}

Measured memory_bytes: 2976
#include <stdio.h>

int main() {
  int i, j, k;

  scanf("%d %d %d", &i, &j, &k);

  if (i == 1 && j == 0 && k == 0){
    printf("Close\n");
  } else if (i == 0 && j == 1 && k == 0) {
    printf("Close\n");
  } else if (i == 1 && j == 1 && k == 0) {
    printf("Open\n");
  } else if (i == 0 && j == 0 && k == 1) {
    printf("Open\n");
  } else if (i == 0 && j == 0 && k == 0) {
    printf("Close\n");
  } else {
    printf("Close\n");
  }
  
  return 0;
}



Measured memory_bytes: 2608
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n,k;
    cin>>n>>k;
    vi x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    int zpos=n;
    for(int i=0;i<n;i++)
    {
        if(x[i]>=0)
        {
            zpos=i;
            break;
        }
    }
    int ans=0x3f3f3f3f;
    if(zpos>=k) ans=-x[zpos-k];
    for(int i=zpos;i<n;i++)
    {
        int cc=i-zpos+1;
        cc=k-cc;
        if(cc<0||cc>zpos) continue;
        int d1=cc?-x[zpos-cc]:0,d2=x[i];
        //dbg(i,d1,d2,cc);
        ans=min(ans,min(d1+2*d2,2*d1+d2));
    }
    print(ans);
}

Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] A = Enumerable.Range(0, n).Select(a => int.Parse(Console.ReadLine())).ToArray();

            Console.WriteLine(GetLIS(A));
        }

        static int GetLIS(int[] A)
        {
            int n = A.Length, length = 1;
            List<int> L = new List<int>();
            L.Add(A[0]);

            for (int i = 1; i < n; i++)
            {
                int cur = A[i];

                if (L[length - 1] < cur)
                {
                    L.Add(cur);
                    length++;
                }
                else
                {
                    int index = LowerBound(L, cur);
                    L[index] = cur;
                }
            }
            return length;
        }

        static int LowerBound(List<int> arr, int value)
        {
            int low = 0, high = arr.Count;
            int mid;

            while (low < high)
            {
                mid = ((high - low) >> 1) + low;        // (low + high) / 2
                if (arr[mid] < value) low = mid + 1;
                else high = mid;
            }
            return low;
        }
    }
}

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


int main()
{

  ios::sync_with_stdio(0);
  cin.tie(0);
  int a;
  cin>>a;
  cout<<a+a*a+a*a*a;


  return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;

bool a[1000010];
int b[1000010]={0};

int main(){
	for(ll i=0;i<1000010;i++){
		a[i]=false;
	}
	a[1]=true;
	for(ll i=1;i<1000010;i++){
		if(a[i]){
			if(2*i<1000010) a[2*i]=true;
			if(3*i<1000010) a[3*i]=true;
			if(5*i<1000010) a[5*i]=true;
		}
	}
	/*
	rep(i,100){
		if(a[i]){
			cout<<i<<" ";
		}
	}
	cout<<endl;
	*/
	for(ll i=1;i<1000010;i++){
		//if(i==0) continue;
		b[i]=b[i-1];
		if(a[i]) b[i]++;
	}
	ll m,n;
	while(cin>>m,m){
		cin>>n;
		if(a[m]) cout<<b[n]-b[m]+1<<endl;
		else cout<<b[n]-b[m]<<endl;
	}
	return 0;
}
		

Measured memory_bytes: 6044
import java.util.*;


import java.io.*;

public class Main {
	private static void solve(){
		//Implement solution here.
		String s = next();
		boolean result = true;
		char[] ca = s.toCharArray();
		for(int i = 0; i < ca.length; i++) {
			if(i % 2 == 0) {
				if(ca[i] == 'L') {
					result = false;
					break;
				}
			} else {
				if(ca[i] == 'R') {
					result = false;
					break;
				}
			}
		}
		System.out.println(result ? "Yes" : "No");
	}

	//Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		} 
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = pow(10, 9) + 7; //10e9 + 7
ll gcd(ll a, ll b){//greatest common divider 最大公約数を求める
  if(b==0) return a;
  return gcd(b, a%b);
}

ll Fact(ll n){//Factorial 階乗を求める関数
  ll ans = 1;
  for(ll i=1; i<=n; i++){
    ans *= i;
    ans %= mod;
  }
  return ans; 
}


int main() {
  ll N;
  cin >> N;
  cout << Fact(N) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cout;
using std::cerr;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	int n, a, b, c; scanf("%d%d%d%d", &n, &a, &b, &c);
	std::vector<std::string> s(n);
	for(int i = 0; i < n; i++) cin >> s[i];

	std::vector<char> ans;
	auto solve = [&](auto&& solve, int i, std::vector<int> A) -> void {
		if(A[0] < 0 or A[1] < 0 or A[2] < 0) return;
		if(i == n) {
			printf("Yes\n");
			for(auto c: ans) printf("%c\n", c);
			exit(0);
		}
		
		int x = s[i][0] - 'A', y = s[i][1] - 'A';
		A[x]--; A[y]++;
		ans.push_back(s[i][1]);
		solve(solve, i + 1, A);
		ans.pop_back();
		A[x]++; A[y]--;
		A[x]++; A[y]--;
		ans.push_back(s[i][0]);
		solve(solve, i + 1, A);
		ans.pop_back();
		A[x]--; A[y]++;
	};
	solve(solve, 0, {a, b, c});
	
	printf("No\n");
	return 0;
}


Measured memory_bytes: 24212
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a, b, c, d;
	cin>>a>>b>>c>>d;
	int turn = 1;
	bool ok = false;
	while(a > 0 && c > 0){
		if(turn == 1){
			turn = 1 - turn;
			c -= b;
			if(c <= 0)
			{
				ok = true;
				break;
			}
		}
		else{
			turn = 1 - turn;
			a -= d;
			if(a <= 0)
				break;
		}
	}
	if(ok)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
		
	return 0;
}

Measured memory_bytes: 3636
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	int x, y;
	cin >> x >> y;
	string ans = "No";
	int tmp;
	for (int i = 0; i <= x; i++) {
		tmp = i * 2 + (x - i) * 4;
		if (tmp == y) ans = "Yes";
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

int c[3][3];
int main() {
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      cin >> c[i][j];
    }
  }

  bool e = false;
  for(int a1 = 0; a1 <= min(min(c[0][0],c[0][1]),c[0][2]); a1++) {
    int b1 = c[0][0] - a1;
    int b2 = c[0][1] - a1;
    int b3 = c[0][2] - a1;
    int a21 = c[1][0] - b1;
    int a22 = c[1][1] - b2;
    int a23 = c[1][2] - b3;
    int a31 = c[2][0] - b1;
    int a32 = c[2][1] - b2;
    int a33 = c[2][2] - b3;
    if(a21 == a22 && a21 == a23 && a31 == a32 && a31 == a33) e = true;
  }

  if(e) {
    cout << "Yes" << endl;
  }
  else cout << "No" << endl;

  
}


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

using namespace std;

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

	vector<int> list;
	for (int i = 1; i <= 100; i++)
	{
		if (A % i == 0 && B % i == 0)
		{
			list.push_back(i);
		}
	}

	reverse(list.begin(), list.end());

	cout << list[K - 1] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define INF int(1e9)
#define REP(i, n) for(ll i = 0; i < (ll)(n); i++)
#define REPR(i, n) for(ll i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

string X;

void solve() {
    stack<char> s;
    REP(i, X.size()) {
        if (X[i] == 'S') s.push(X[i]);
        if (X[i] == 'T' && (s.empty() || s.top() == 'T')) s.push('T');
        if (X[i] == 'T' && s.top() == 'S') s.pop();
    }
    cout << s.size() << endl;
}

int main() {
    cin >> X;
    solve();
    return 0;
}

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
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 n;
int main() {
    cin >> n;
    int cnt = 0;
    for(int i = 0; i <= n; ++i) {
        if(i % 2 != 0) {
            int ycnt = 0;
            for(int j = 1; j <= sqrt(i)+1; ++j) {
                if(i % j == 0) ycnt += 2;
            }
            if(ycnt == 8) cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-10;
const bool debug = 0;
//------------------------------//

int H, N;
int x[41234], y[41234];
int dp[41234][1<<4];

int main() {
	cin >> H >> N;
	
	set<pii> ss; // x, y
	REP(i, N) {
		scanf("%d %d", x + i, y + i);
		ss.insert(pii(x[i], y[i]));
	}
	
	memset(dp, -1, sizeof(dp));
	
	dp[0][0] = 0;
	
	REP(i, H - 1) {
		REP(j, 1<<4) {
			if (dp[i][j] == -1) continue;
			int ng = j;
			REP(k, 4) {
				ng |= (ss.find(pii(k, i)) != ss.end()) << k;
				ng |= (ss.find(pii(k, i + 1)) != ss.end()) << k;
			}
			
			int ok = 15 ^ ng;
			
			chmax(dp[i + 1][0], dp[i][j]);
			if ((ok & 3) == 3) chmax(dp[i + 1][3], dp[i][j] + 1);
			if ((ok & 6) == 6) chmax(dp[i + 1][6], dp[i][j] + 1);
			if ((ok & 12) == 12) chmax(dp[i + 1][12], dp[i][j] + 1);
			if ((ok & 15) == 15) chmax(dp[i + 1][15], dp[i][j] + 2);
		}
	}
	
	int ans = 0;
	REP(i, 1<<4) chmax(ans, dp[H - 1][i]);
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>
#include <numeric>

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi >;
using vl = vector<ll>;
using vvl = vector<vl >;
using pairi = pair<int, int>;
using pairl = pair<ll, ll>;

static const ll MAX = 200000;
static const ll waz = 76543217;

#define TR ","
#define TS " "
#define rep(i,N) for(ll i=0;i<(ll)N;++i)
#define rpt(i,a,b) for(ll i=a;i<(ll)b;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll x, ll y) {
    return x / gcd(x, y) * y;
}

void printVector(const vector<ll>& vec) {
    for (ll value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

int top, S[1000];

void push(int x) {
    S[++top] = x;
}

int pop() {
    --top;
    return S[top + 1];
}

int main()
{
    IO;

    int a, b;
    top = 0;
    char s[100];

    while (1) {
        cin >> s;
        if (cin.eof()) break;
        if (s[0] == '+') {
            a = pop();
            b = pop();
            push(a + b);
        }
        else if (s[0] == '-') {
            b = pop();
            a = pop();
            push(a - b);
        }
        else if (s[0] == '*') {
            a = pop();
            b = pop();
            push(a * b);
        }
        else {
            push(atoi(s));
        }
    }
    cout << pop() << endl;
}


Measured memory_bytes: 3216
#include<bits/stdc++.h>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef long long ll;
typedef pair<ll,ll> P;
const int INF=INT_MAX / 3;
const ll LINF=LLONG_MAX / 3LL;
#define CONST 1000000007
#define EPS (1e-8)
#define PB push_back
#define MP make_pair
#define sz(a) ((int)(a).size())
#define reps(i,n,m) for(int i=(n);i<int(m);i++)
#define rep(i,n) reps(i,0,n)
#define SORT(a) sort((a).begin(),(a).end())
ll mod(ll a,ll m){return (a%m+m)%m;}
int dx[9]={0,1,0,-1,1,1,-1,-1,0},dy[9]={1,0,-1,0,1,-1,1,-1,0};
ll n,m, k;
int count(char c) {
  if (c=='a') return 0;
  return ('z' - c)+1;
}
int main(){
  string s;
  cin>>s;
  cin>>k;
  n=sz(s);
  rep(i, n-1){
    if (count(s[i])<=k) {
      k-=count(s[i]);
      s[i]='a';
    }
  }
  s[n-1] = (((s[n-1]-'a')%26)+k)%26 + 'a';
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 640
from math import floor, sqrt, ceil


def f(b, n):
    if b < 2:
        return 0

    if n < b:
        return n

    return f(b, floor(n / b)) + n % b


n = int(input())
s = int(input())

if n == s:
    print(n + 1)
    exit()

for b in range(2, floor(sqrt(n)) + 1):
    if f(b, n) == s:
        print(b)
        exit()

for p in range(1, ceil(sqrt(n)))[::-1]:
    b = (n - s) / p + 1
    if b.is_integer():
        b = int(b)
        if f(b, n) == s:
            print(b)
            exit()

print(-1)


Measured memory_bytes: 3064
#include <stdio.h>
int main() {
	int a, b, c, d;
	char p[2] = { '+','-' };
	scanf("%d", &a);
	d = a % 10; a /= 10;
	c = a % 10; a /= 10;
	b = a % 10; a /= 10;
	for (int i = 0; i < 2; i++)
	{
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 2; k++)
			{
				if (a + b + c + d - 2 * ((i % 2)*b + (j % 2)*c + (k % 2)*d) == 7) {
					printf("%d%c%d%c%d%c%d=7", a, p[i], b, p[j], c, p[k], d);
					return 0;
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Threading.Tasks;
 
namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(s => int.Parse(s));
            Console.WriteLine(input.ElementAt(0) + input.ElementAt(1) >= input.ElementAt(2)?"Yes":"No");
        }
    }
}

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

string a, b, c;
int n;

int main() {
  int ans = 0;
  cin >> n >> a >> b >> c;
  for(int i = 0; i < n; ++i) {
    if(a[i] == b[i] && b[i] == c[i])
      continue;
    else if(a[i] == b[i] || b[i] == c[i] || c[i] == a[i])
      ++ans;
    else
      ans += 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a;
    int i = 0;
    int j = 0;
    int k;

    scanf("%d",&a);
    int b[a];
   
    while(a-- > 0){
	scanf("%d",&b[i++]);
    }
    while(i-- > 0){
	while(b[i]%2 == 0){
		b[i] = b[i]/2;
                j++;
	}
    }
    k = j;
    while(j-- > 0){
	for(int d=0;d<i;d++){
		b[d] = b[d]*3;
                if(b[d] > 1000000000)break;
	}
    }
    k = k - (j+1);
    printf("%d\n",k);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define ArraySizeOf(array)     (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define _GLIBCXX_DEBUG
int INF = 1e9 + 7;
unsigned NthDayOfWeekToDay(unsigned n, unsigned dow, unsigned dow1)
{
    unsigned day;
    if (dow < dow1) dow += 7;
    day = dow - dow1;
    day += 7 * n - 6;
    return day;
}
unsigned DayToWeekNumber(unsigned day)
{
    return (day - 1) / 7 + 1;
}
unsigned AnotherDayOfWeek(unsigned day, unsigned day0, unsigned dow0)
{
    return (dow0 + 35 + day - day0) % 7;
}
using namespace std;
signed main() {
  int K,X; cin>>K>>X;
  for(int i=X-K+1;i<X+K;i++){
    if(i!=X-K+1)cout<<" ";
    cout<<i<<endl;
  }
  cout<<endl;
}

Measured memory_bytes: 3568
#include<stdio.h>
int main(void)
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==1 &&b==0 &&c==0)
		printf("Close\n");
	else if(a==0 &&b==1 &&c==0)
		printf("Close\n");
	else if(a==1 &&b==1 &&c==0)
		printf("Open\n");
	else if(a==0 &&b==0 &&c==1)
		printf("Open\n");
	else if(a==0 &&b==0 &&c==0)
		printf("Close\n");
	return 0;
}

Measured memory_bytes: 1012
def gcd(a,b):
    if(b==0):
        return a
    else:
        return gcd(b,a%b)

a,b=map(int,input().split())
x=gcd(a,b)
if(x==1):
    print(1)
    exit()
s=[]
i=2
while(i*i<=x):
    if(x%i==0):
        s.append(i)
        x/=i
    else:
        i+=1
s.append(x)
print(len(set(s))+1)

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

using namespace std;
const int N = 2e5 + 10;
int H , W , n;

int x[N] , y[N] , first[N] , res;
map<int,int> ban[N];

int main(){
	scanf("%d%d%d",&H,&W,&n);
	for (int i = 1;i <= n;i++){
		scanf("%d%d",x+i,y+i);		
		ban[x[i]][y[i]] = 1;
	}
	
	for (int i = 1;i <= W;i++) first[i] = H + 1;
	
	first[1] = 1;
	
	for (int i = 2;i <= W;i++){
		int now = first[i - 1] + 1;
		
		while (ban[now][i]) now++;
		if (now >= H + 1) break;
		first[i] = now;
	}
	
//	for (int i = 1;i <= W;i++) printf("[%d %d]\n",i,first[i]);
	
	int res = H;
	for (int i = 1;i <= n;i++){
		if (x[i] >= y[i] + 1 && first[y[i]] <= x[i]){
			res = min(res , x[i] - 1);
		}
	}
	cout<<res;
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> pic(2*H, vector<char>(W));
  for (int i = 0; i <= 2*H-2; i += 2) {
    for (int j = 0; j < W; j++) {
      cin >> pic[i][j];
    }
    pic[i+1] = pic[i];
  }
  for (int i = 0; i < 2*H; i++) {
    for (int j = 0; j < W; j++) {
      if (j == W-1) {
        cout << pic[i][j] << endl;
      }
      else {
        cout << pic[i][j];
      }
    }
  }
}


Measured memory_bytes: 384
#!/usr/bin/python3

import os
import sys


def main():
    W, D, N = read_ints()
    M = [tuple(read_ints()) for _ in range(N)]
    ans = solve(W, D, N, M)
    if ans is None:
        print('No')
    else:
        print(ans)


def solve(W, D, N, M):
    INF = 999
    H = [[INF] * W for _ in range(D)]

    hmap = {}
    for h in range(-210, 101):
        hmap[h] = set()

    for x, y, z in M:
        x -= 1
        y -= 1
        hmap[z].add((x, y))
        H[y][x] = z

    for h in range(100, -210, -1):
        for x, y in hmap[h]:
            if H[y][x] == INF:
                H[y][x] = h
            elif H[y][x] > h:
                continue

            for dx, dy in ((1, 0), (-1, 0), (0, 1), (0, -1)):
                nx = x + dx
                ny = y + dy
                if nx < 0 or nx >= W or ny < 0 or ny >= D:
                    continue
                if H[ny][nx] < h - 1:
                    return None
                if H[ny][nx] == INF:
                    hmap[h - 1].add((nx, ny))

    return sum([sum(r) for r in H])


###############################################################################

DEBUG = 'DEBUG' in os.environ


def inp():
    return sys.stdin.readline().rstrip()


def read_int():
    return int(inp())


def read_ints():
    return [int(e) for e in inp().split()]


def dprint(*value, sep=' ', end='\n'):
    if DEBUG:
        print(*value, sep=sep, end=end)


if __name__ == '__main__':
    main()



Measured memory_bytes: 6012
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N, reset[200009];
vector<int> V[200009];
vector<ll> ans[200009];
vector<ll> ans0[200009];
ll inv2=(MOD+1)/2;

void dfs(int q){
    reset[q]=-1;
    for(auto u:V[q]){
        dfs(u);
        if(ans[q].size()<ans[u].size()){
            swap(ans[q],ans[u]);
            swap(ans0[q],ans0[u]);
            swap(reset[q],reset[u]);
        }
        int z=ans[q].size()-ans[u].size();
        while(reset[u]>=0){
            ans0[u][reset[u]]=(MOD+1-ans[u][reset[u]])%MOD;
            --reset[u];
        }
        while(reset[q]>=z){
            ans0[q][reset[q]]=(MOD+1-ans[q][reset[q]])%MOD;
            --reset[q];
        }
        rep(i,ans[u].size()){
            ans[q][z+i]=(ans0[q][z+i]*ans[u][i]+ans0[u][i]*ans[q][z+i])%MOD;
            (ans0[q][z+i]*=ans0[u][i])%=MOD;
        }
    }
    ans[q].push_back(inv2);
    ans0[q].push_back(inv2);
    reset[q]=ans[q].size()-2;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep1(i,N){
        int p; cin>>p;
        V[p].push_back(i);
    }
    dfs(0);
    rep1(i,ans[0].size()-1) (ans[0][0]+=ans[0][i])%=MOD;
    rep(i,N+1) (ans[0][0]*=2)%=MOD;
    cout1(ans[0][0]);
}

Measured memory_bytes: 43492
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> b(n);
	rep(i, 1, n) {
		cin >> b[i];
	}
	vector<int> a(n+1);
	a[1] = b[1];a[n] = b[n-1];
	rep(i, 2, b.size()) {
		a[i] = min(b[i - 1], b[i]);
	}
	int ans = 0;
	rep(i, 0, a.size()) ans += a[i];
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main(){
    long long int A, B, K;
    cin>>A>>B;
    if((A+B)%2==0){
        K=(A+B)/2;
        cout<<K<<endl;
    }
    else{
        cout<<"IMPOSSIBLE"<<endl;
    }
    return 0;
}


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

typedef int64_t Int;
#define all(x) (x).begin(), (x).end()
 
const double EPS = 1e-10;
const Int INF = 1e18;
const int inf = 1e9;
const Int mod = 1e9+7;

bool print_space_enable = false;
void print() { 
    cout << '\n'; 
    print_space_enable = false;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    if (print_space_enable) cout << " ";
    cout << fixed << setprecision(15) << head;
    print_space_enable = true;
    print(std::forward<Tail>(tail)...);
}

template<typename T>
void print(vector<T> v) {
    for (size_t i = 0; i < v.size(); i++) {
        if (i > 0) std::cout << " ";
        std::cout << v[i];
    }
    std::cout << std::endl;
}

Int a, b, c, d;

Int f(Int x) {
    return x - (x / c + x / d - x / lcm(c, d));
}

int main() {
    cin >> a >> b >> c >> d;
    print(f(b) - f(a - 1));
    return 0;
}


Measured memory_bytes: 3608
import java.io.*;
import java.util.*;
 
class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        char[] c_array=br.readLine().toCharArray();
        for(char c:c_array){
            if('a'<=c&&c<='z'){ System.out.printf("%c",c-'a'+'A'); }
            else if('A'<=c&&c<='Z'){ System.out.printf("%c",c-'A'+'a'); }
            else System.out.print(c);
        }System.out.println();
    }
}
 

Measured memory_bytes: 26704
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
        if(a==25){
            System.out.println("Christmas");
        }
        if(a==24){
            System.out.println("Christmas Eve");
        }
        if(a==23){
            System.out.println("Christmas Eve Eve");
        }
        if(a==22){
            System.out.println("Christmas Eve Eve Eve");
        }
	}
}

Measured memory_bytes: 21716
import sys
input = sys.stdin.readline
N,K = [int(i) for i in input().split()]
P = 0
score = 0
count = 0
for n in range(1,N+1) :
    score = n
    while score < K :
        score*=2
        count+=1
    P += (1/N) * (1/2) ** count
    score = 0
    count = 0
print(P)

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <cmath>
#include <vector>
#include <queue>
#include <limits>
#include <algorithm>
#include <string>
#include <cstring>
#include <map>

using namespace std;
typedef long long ll;
const int MOD = 1000000007;
#define MAX_N (510)

struct output_format
{
	int row0, col0, row1, col1;
};

int main()
{
	int H, W;
	scanf("%d%d", &H, &W);

	int a[MAX_N][MAX_N];
	for (int row = 1; row <= H; row++) {
		for (int col = 1; col <= W; col++) {
			scanf("%d", &a[row][col]);
		}
	}

	queue<pair<int, int>> route;
	for (int row = 1; row <= H; row++) {
		if (row % 2 == 1) {
			for (int col = 1; col <= W; col++) {
				route.push(make_pair(row, col));
			}
		} else {
			for (int col = W; col >= 1; col--) {
				route.push(make_pair(row, col));
			}
		}
	}

	queue<struct output_format> outputs;

	while (!route.empty()) {
		pair<int, int> now = route.front(); route.pop();
		if (a[now.first][now.second] % 2 == 0)
			continue;

		pair<int, int> next = now;
		if (now.first % 2 == 1) {
			next.second++;
			if (next.second > W) {
				next.first++;
				next.second = W;
			}
		} else {
			next.second--;
			if (next.second < 1) {
				next.first++;
				next.second = 1;
			}
		}
		if (next.first > H)
			break;
		a[now.first][now.second]--;
		a[next.first][next.second]++;

		struct output_format move;
		move.row0 = now.first;
		move.col0 = now.second;
		move.row1 = next.first;
		move.col1 = next.second;
		outputs.push(move);
	}

	printf("%zd\n", outputs.size());
	while (!outputs.empty()) {
		struct output_format move = outputs.front(); outputs.pop();
		printf("%d %d %d %d\n", move.row0, move.col0, move.row1, move.col1);
	}

	return 0;
}


Measured memory_bytes: 5248