akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mod7 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define queries ll t;cin>>t;while(t--)
using namespace std;


int main(){

    fast

	 string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int l = s.size(), i = 0;
    s += "0";
    int total = 0, carry = 0;
    while(i < l) {
        int c = (int)s[i] - 48 + carry;
        carry = 0;
        if(c == 0) {
            i++;
            continue;
        }
        if(c <= 4 || c == 5 && (int)s[i + 1] - 48 < 5) {
            total += c;
            i++;
            continue;
        }
        carry = 1;
        total += 10 - c;
        i++;
        while(i < l && (int)s[i] - 48 == 9) i++;
    }
 
    cout << total + carry << endl;
 
    return 0;
}

Measured memory_bytes: 1948
N = int(input())
S = [input() for _ in range(N)]

count = {'AC': 0, 'WA': 0, 'TLE': 0, 'RE': 0}
for res in S:
    count[res] += 1
        
for res in ['AC', 'WA', 'TLE', 'RE']:
    print('{} x {}'.format(res, count[res]))

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

using namespace std;

int main() 
{ 
  string s1, s2, s3;
    cerr<<"Enter the string 1:";
     cin>>s1;

      cerr<<"Enter the string 2: ";
        cin>>s2;
 
  s3= s2+s1;

  cout<<s3;
  
  
 
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
    int i,j,k;
    int count;
    int b,f,r,v;
    int a[4][3][10]={0};

    scanf("%d",&count);

    for(i=0;i<count;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        a[b-1][f-1][r-1] += v;
    }

    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",a[i][j][k]);
            }
            printf("\n");
        }
        if(i!=3){
            printf("####################\n");
        }
    }

    return 0;
}


Measured memory_bytes: 2744
#include <iostream>

using namespace std;

int main()
{
    int sum = 0;
    int x , y;
    cin >> x >> y;
    if(x == 1)
        sum += 3;
    if(x == 2)
        sum += 2;
    if(x == 3)
        sum += 1;
    if(y == 1)
        sum += 3;
    if(y == 2)
        sum += 2;
    if(y == 3)
        sum += 1;
    if(x == 1 && y == 1)
        sum += 4;
    if(sum == 0)
    {
        cout << 0;
        return 0;
    }
    cout << sum << "00000";
    return 0;
}


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

int N;
int first[12];
string build = "";

void dfs(int depth) {
  if (depth == N) {
    fill_n(first, N + 1, 2e9);
    int highest = -1;
    for (int i = 0; i < depth; ++i) {
      first[build[i] - 'a'] = min(first[build[i] - 'a'], i);
      highest = max(highest, build[i] - 'a');
    }
    for (int i = 0; i <= highest; ++i) {
      if (first[i] == int(2e9)) {
        return;
      }
    }
    int last = -1;
    for (int i = 0; i <= highest; ++i) {
      if (first[i] < last) {
        return;
      }
      last = first[i];
    }
    cout << build << '\n';
    return;
  }
  for (int i = 0; i <= depth; ++i) {
    build += char(i + 'a');
    dfs(depth + 1);
    build.pop_back();
  }
}

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

  cin >> N;
  dfs(0);
}

Measured memory_bytes: 1536
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <queue>
#include <functional>
#include <cassert>
#include <cmath>


#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b), i++)
#define NL << endl

using namespace std;
using ll = long long;
using ull = unsigned long long;

int main() {

	int a, b;

	cin >> a >> b;

	if (a + b == 15) cout << "+" NL;
	else if (a * b == 15) cout << "*" NL;
	else cout << "x"  NL;

	return 0;
}

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

using namespace std;

int a[300][300]={};

int main(){
	int h,w;
	char tmp;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin >> tmp;
			a[j][i]=tmp;
		}
	}
	int cost1=0;
	int ans =0;
	int cost[301][301];
	int dp[301][301]={};
	for(int k=0;k<(w-1);k++){
		for(int i=0;i<301;i++){
			for(int j=0;j<301;j++){
				cost[i][j]=0;
			}
		}
		for(int i=0;i<=h;i++){
			for(int j=0;j<=h;j++){
				if(i==0||j==0){
					dp[i][j]=0;
				}else{
					dp[i][j]=dp[i-1][j-1];
					if(a[k][i-1]==a[k+1][j-1]){
						dp[i][j]+=1;
					}
				}
			}
		}
		for(int i=1;i<=h;i++){
			for(int j=1;j<=h;j++){
				cost[i][j]=min(cost[i-1][j]+dp[i][j],cost[i][j-1]+dp[i][j]);
			}
		}
		ans += cost[h][h];
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  long long a, b, c, d;
  cin >> a >> b >> c >> d;
  
  long long A = a * c;
  long long B = a * d;
  long long C = b * c;
  long long D = b * d;

  vector<long long> N;
  N = {A, B, C, D};
  long long m ;
  for(int i = 0; i < 4; i++){
    if(i == 0) m = A;
    else m = max(m, N.at(i));
  }
  
  cout << m << endl;

  
  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
int fg(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}
signed main(){
  int a;
  cin>>a;
  vector <int>vec(200);
  rep(i,200){
    vec[i]=pow(i,5.0);
  }
  rep(j,200){
    rep(k,200){
      if(vec[j]-vec[k]==a){
        cout<<j<<" "<<k;
        goto A;
      }
      else if(vec[j]+vec[k]==a){
        cout<<j<<" "<<-k;
        goto A;
      }
    }
  }
  A:
  int ab=9;
}
    

Measured memory_bytes: 4076
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
// #define int ll
using namespace std;
const int INF (1 << 30);
const ll LLINF (1LL << 55LL);
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    string s;
    cin>>s;
    if(s=="Sunny") cout<<"Cloudy"<<endl;
    else if(s=="Cloudy") cout<<"Rainy"<<endl;
    else if(s=="Rainy") cout<<"Sunny"<<endl;
    return 0;
}

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

/*
long Lucas(long n){
    if (n == 0) return 2;
    else if (n == 1) return 1;
    else return (Lucas(n-1) + Lucas(n-2));
}
*/

int main(){
    int N;
    cin >> N;
    vector<long> v(N+1); 
    v.at(0) = 2;
    v.at(1) = 1;
    // cout << Lucas(N) << endl;
    for (int i = 2; i < N+1; i++){
        v.at(i) = v.at(i-1) + v.at(i-2);
    }
    cout << v.at(N) << endl;
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m;
ll ans;
ii a[N];
int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i].first >> a[i].second;
    }
    sort(a, a + n);
    for (int i = 0; i < n; ++i) {
        int d = min(m, a[i].second);
        m -= d;
        ans += 1LL * a[i].first * d;
        if (!m)
            break;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4424
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = INT32_MAX;
const long long int Mod = 1000000007;
const long long int mod = 100000;//10^5
using ll = long long int; //long long int は64bit
using ci = const int; using vi = vector<int>; using Vi = vector<long long int>; using pii = pair<int,int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
//       cin.tie(0);ios::sync_with_stdio(false);
void cinit(){cin.tie(0);ios::sync_with_stdio(false);}
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////

ll mai(ll x){
	ll ans = 4;
	rep(i,x)ans*=2;
	return ans-3;
}

ll n,x;
ll memo[51]={0};

ll cal(ll lv,ll nu){
	if(nu == mai(lv)){
		if(memo[lv]!=0){return memo[lv];}
		else return memo[lv] = cal(lv-1,mai(lv-1))*2 + 1;
	}else{
		nu-=1;
		if(nu<=0)return 0;
		if(mai(lv-1)<nu){
			return cal(lv-1,mai(lv-1)) + cal(lv-1,nu-mai(lv-1)-1) + 1;
		}else{
			return cal(lv-1,nu);
		}
	}
}

int main(){
	cin>>n>>x;
	memo[0]=1;
	cout<<cal(n,x)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<sstream>
using namespace std;
#define ll long long
#define ld long double
 
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fb(i,a,b) for(ll i=a;i>=b;i--)
 
#define mp make_pair
#define pb push_back
 
#define ft first
#define sd second
 
 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
 
#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
 
const ll N = 100005;
const ll M = 1000000007;
 
int main(){
 //ll t;
 //cin>>t;
 //while(t--){
 	ll n,m;
 	cin>>n>>m;
 	if(m==n){
 		cout<<"Yes";
	 }
	 else{
	 	cout<<"No";
	 }
}
//}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MM = 1000000000;
const int MOD = MM + 7;
const int MAX = 510000;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
const ll INF = 1LL << 60;


int main() {
    int n; cin >> n;
    vector<bool> b(1000001);
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) if(a[i] == 1) cnt++;
    if(cnt == 1) {
        cout << 1 << endl;
        return 0;
    }
    if(cnt > 1) {
        cout << 0 << endl;
        return 0;
    }
    rep(i, n) {
        int x = 2;
        while(a[i]*x <= 1000000) {
            b[a[i]*x] = 1;
            x++;
        }
    }
    vector<int> d(1000001);
    rep(i, n) d[a[i]]++;
    rep(i, 1000001) if(d[i] > 1) b[i] = 1;
    int ans = 0;
    rep(i, n) if(!b[a[i]]) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 8016
#include <stdio.h>
#include <stdlib.h>
void count(int N, int M){
    if(!(N+M)) return;
    int i, j, k;
    int h[1500];
    int w[1500];
    long s_cnt = 0;
    int *h_cnt;
    int *w_cnt;
    for(i = 0; i < N; i++) scanf("%d", &h[i]);
    for(i = 0; i < M; i++) scanf("%d", &w[i]);
    h_cnt = (int *)calloc(1000 * N, sizeof(int));
    w_cnt = (int *)calloc(1000 * M, sizeof(int));
    //????????????
    for(i = 0; i < N; i++){
        for(j = 0; j < N-i; j++){
            int size = 0;
            for(k = 0; k < i+1; k++) size += h[j+k];
            (*(h_cnt+size))++;
        }
    }
    //?¨?
    for(i = 0; i < M; i++){
        for(j = 0; j < M-i; j++){
            //????¨????
            int size = 0;
            for(k = 0; k < i+1; k++) size += w[j+k];
            (*(w_cnt+size))++;
        }
    }
    int min = (N > M) ? M : N;
    for(i = 0; i < min * 1000; i++){
        s_cnt += ((*(h_cnt + i)) * (*(w_cnt + i)));
    }
    printf("%d\n", s_cnt);
    free(h_cnt);
    free(w_cnt);
}

int main(){
    int N, M;
    while(scanf("%d %d", &N, &M) != EOF) count(N, M);
    return 0;
}

Measured memory_bytes: 10604
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

int f(char c){
    if('a'<=c and c<='z')return 26+(c-'a');
    else return (c-'A');
}

char rf(int n){
    if(n<26)return ('A'+n);
    else return ('a'+(n-26));
}

bool solve(){
    string s;cin>>s;
    if(s.size()==26){
        set<char>set;
        set.insert('z'+1);
        ll n=s.size();
        for(int i=n-1;i>=0;i--){
            if(*lower_bound(all(set),s[i])=='z'+1){
                set.insert(s[i]);
                s.pop_back();
            }else{
                char c=s[i];
                s.pop_back();
                s.push_back(*lower_bound(all(set),c));
                cout<<s<<endl;
                return false;
            }
        }
        cout<<-1<<endl;
        return false;
    }
    set<char>set;
    rep(i,26)set.insert('a'+i);
    rep(i,s.size())set.erase(s[i]);
    s.push_back(*set.begin());
    cout<<s<<endl;

    
    return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
	return solve();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>//by btng_smith666 juruo
using namespace std;
int a[11],n,ans;
void dfs(int tmp,int maxn)//dfs 大法好！ 
{//两个函数量：tmp 临时变量，maxn 最大值 
	if(tmp>n)//如果 tmp>n 就可以出答案了 
	{
		for(int i=1;i<=n;i++)
			cout<<char(a[i]+96);//关于 ASCII 码珂以去百度找一下对照表，这里的 96 就是 'a'-1 ，注意这里要把这个数转为字符 
		cout<<endl;//再次强调 AT 的题要换行 
		return ;//结束程序 
	}
	for(int i=1;i<=maxn;i++)
		a[tmp]=i,dfs(tmp+1,maxn);//把 a[tmp] 赋值成 i ，搜索每位相同的情况 
	a[tmp]=maxn+1;//再赋值成 最大值 +1 
	dfs(tmp+1,maxn+1);//继续搜索另一种每位不同的情况 
}
int main()
{
	cin>>n;
	if(n==1)//如果 n=1 就只能是 a  
	{
		cout<<'a';
		return 0;
	}
	dfs(1,0);//从 1 开始 dfs 
	return 0;
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=100000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<int,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
//void swap(ll a,ll b){
//	ll d;
//	d=a;
//	a=b;
//	b=d;
//	return;
//}
ll mypow(ll x,int m){
	if(m==0)return 1;
	if(m%2==0){
		int x2=mypow(x,m/2);
		return x2*x2;
	}else{
		int x2=mypow(x,m/2);
		return x2*x2*x;
	}
}
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
//    	cout<<b<<endl;
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll ans=0;
ll total=0;
int m;
ll d[200003],c[200003];

int main() {
	cin>>m;
	rep(i,0,m){
		cin>>d[i]>>c[i];
		ans+=c[i];
		total+=d[i]*c[i];
		while(total>9){
			ans+=total/10;
			total=total%10+total/10;
		}
	}
	cout<<ans-1<<endl;
		return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define f(n) for(int i=0;i<n;i++)
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define MOD 1000000007
#define endl "\n"
//#define int long long
#define ll long long
#define vi vector <int>
#define vvi vector <vector<int> >
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>=b;i--)
#define init(i,k) memset(i,k,sizeof i)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define maxe *max_element
#define mine *min_element
#define pow2(n) (1LL << (n))
#define sz(a) (int)a.size()
#define MOD 1000000007
#define PI 3.14159265359
inline ll add(ll a, ll b){ return ((a%MOD)+(b%MOD))%MOD;}
inline ll mul(ll a, ll b){ return ((a%MOD)*(b%MOD))%MOD;}
inline ll sub(ll a, ll b){ return ((a%MOD)-(b%MOD)+MOD)%MOD;}
int power(int x, unsigned int y, int p=MOD)  
{  
    if(y==0)
    {
        return 1;
    }
    int ans=power(x,y/2,p);
    if(y%2)
    {
        int z=((((ans*ans)%p)*x)%p);
        return z;
    }
    else
    {
        int z=(ans*ans)%p;
        return z;
    }
} 


int solve()
{
    int n;
    cin>>n;
    vector<vector<int> > v(n,vector<int> (3));
    f(n)
    {
        for(int j=0;j<3;j++)
        {
            cin>>v[i][j];
        }
    }
    vector<vector<int> > dp(n+1,vector<int>(3,0));
    for(int i=1;i<=n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+v[i-1][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+v[i-1][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+v[i-1][2];
    }
    return max(dp[n][0],max(dp[n][1],dp[n][2]));
}
/********************************************/
signed main()
{   
    speed
    int t=1;
    //cin>>t;
    while(t--)
    {
        cout<<solve()<<endl;
    }
    return 0;
}


Measured memory_bytes: 14268
H,W=map(int,input().split())
dotlist = [['' for x in range(W)] for y in range(2*H)]

for i in range(H):
  tmp = input()
  for j in range(W):
    dotlist[2*i][j] = tmp[j]
    dotlist[2*i+1][j] = tmp[j]
for n in range(2*H):
  tmp = ''
  for m in range(W):
    tmp += dotlist[n][m]
  print(tmp)

Measured memory_bytes: 3188
n, m = map(int, input().split())
was = [0 for _ in range(n)]
counting = [-1 for _ in range(n)] #-1 未提出　0 間違い中 1 正解済み
for _ in range(m):
  result = input().split()
  p = int(result[0])
  s = result[1]
  if s == "WA" and counting[p-1] <= 0:
    was[p-1] += 1
  elif s == "AC" and counting[p-1] <= 0:
    counting[p-1] = 1

ac_count = 0
wa_count = 0
for i in range(n):
  if counting[i] == 1:
    ac_count += 1
    wa_count += was[i]

ret = str(ac_count) + " " + str(wa_count)
print(ret)

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

#define rep(i,s,n) for (int i = (ll)s; i < (ll)n; i++)
#define rrep(i,n,e) for (int i = (ll)n-1; i >= (ll)e; i--)
#define ll long long
#define ld long double
#define pb push_back
#define eb emplace_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define llbidx(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y) // 二要素間の距離
// #define M_PI 3.14159265358979323846 // CFでは定義しておく必要あり
#define deg2rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad2deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)
#define Find(set, element) set.find(element) != set.end()
#define Decimal(x) cout << fixed << setprecision(10) << x << endl; // 小数点を10桁まで表示
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << "\n";
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define endl "\n"
// gcj print用
#define Case(x) printf("Case #%d: ", x);

typedef pair<int, int> PI;
typedef pair<ll, ll> PLL;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<int>>> vvvl;
typedef vector<PI> vpi;
typedef vector<vector<PI>> vvpi;
typedef vector<vector<vector<PI>>> vvvpi;
typedef vector<PLL> vpl;
typedef vector<vector<PLL>> vvpl;
typedef vector<vector<vector<PLL>>> vvvpl;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

int POWINT(int x, int n) {
  int ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

ll POWLL(ll x, int n) {
  ll ret = 1;
  while (n > 0) {
    if (n & 1) ret *= x;
    x *= x;
    n >>= 1;
  }
  return ret;
};

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

void print() {
  cout << endl;
};

template <class T>
void print(vector<T> &vec) {
  for (auto& a : vec) {
    cout << a;
    if (&a != &vec.back()) cout << " ";
  }
  cout << endl;
};

template <class T>
void print(vector<T> &vec, ll k){
   ll n = vec.size();
   k = min(k, n);
   rep(i, 0, k-1) cout << vec[i] << " ";
   cout << vec[k-1] << endl;
};

template <class T>
void print(vector<vector<T>> &df) {
  for (auto& vec : df) {
    print(vec);
  }
};

template<class T, class U>
void print(pair<T,U> &p){
  cout << p.first << " " << p.second << "\n";
};

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

  int a, b; cin >> a >> b;
  cout << a * b << endl;

  return 0;
};


Measured memory_bytes: 3648
n = int(input())
t = 0
x = 0
y = 0
for _ in range(n):
	nt, nx, ny = map(int,input().split())
	sa = nt-t
	t = nt
	kyori = abs(nx-x) + abs(ny-y)
	x = nx
	y = ny
	if kyori > sa or (sa-kyori) % 2 == 1:
		print("No")
		exit()
print("Yes")

Measured memory_bytes: 9144
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) std::cout << x << '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define sz(x) ((int)(x).size())
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
const int dx[4] = { 1, 0, -1,  0 };
const int dy[4] = { 0, 1,  0, -1 };
const int INF = (int)1e9;
const ll  inf = (ll)1e18;
const int mod = 1000000007;
const int MAX_N = 100010;
const double PI = acos(-1);

class mint {
private:
	long long x;

public:
	mint(long long x = 0)
		: x((x % mod + mod) % mod) {}

	mint operator-() const {
		return mint(-x);
	}

	mint& operator+=(const mint& a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}

	mint& operator-=(const mint& a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}

	mint& operator*=(const mint& a) {
		(x *= a.x) %= mod;
		return *this;
	}

	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}

	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}

	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(long long t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint inv() const {
		return pow(mod - 2);
	}

	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}

	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend std::ostream& operator<<(std::ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint comb(int n, int a) {
	mint x = 1, y = 1;
	rep(i, a) {
		x *= n - i;
		y *= i + 1;
	}
	return x / y;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	/*------------------------------*/

	int n, a, b;
	cin >> n >> a >> b;

	mint ans = mint(2).pow(n) - 1;
	ans -= comb(n, a);
	ans -= comb(n, b);

	out(ans);

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<functional>
#include<random>
#include<iostream>
using namespace std;


int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	if ((B - A) % 2 == 0) {
		cout << (B - A) / 2;
		return 0;
	}
	else {
		long long M = (A - 1) + 1 + (B - A - 1) / 2;
		long long P = (N - B) + 1 + (B - A - 1) / 2;
		if (M < P) { cout << M; }
		else { cout << P; }
	}
}

Measured memory_bytes: 256
#include <cstdio>
#define MAXN 100010
using namespace std;

int n,x,a[MAXN];

inline int gcd(int a,int b){return !b?a:gcd(b,a%b);}
inline int abs(int a){return a<0?-a:a;}

inline void read(int &x)
{
	x=0;char ch=getchar();bool f=false;
	while (ch<'0'||ch>'9'){if (ch=='-') f=true;ch=getchar();}
	while (ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+ch-'0',ch=getchar();
	if (f) x=-x;return ;
}

int main()
{
	read(n);read(x);
	for (int i=1;i<=n;i++){read(a[i]);a[i]=abs(a[i]-x);}
	for (int i=2;i<=n;i++) a[i]=gcd(a[i],a[i-1]);
	printf("%d\n",a[n]);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<map>
#include<numeric>
#include<queue>
#include<string>
#include<sstream>

using namespace std;


int main(void) {

  string str[10] = {"", ".,!? ", "abc", "def", "ghi", "jkl", "mno", "pqrs", "tuv", "wxyz"};
  int n;
  cin >> n;
  for(int i=0; i<n; i++){
    string s;
    cin >> s;
    int cnt = 0;
    string ans = "";
    for(int j=0; j<s.size(); j++){
      if( s[j] == '0' && cnt != 0){
        // cerr << cnt << endl;
        ans += str[ s[j-1]-'0' ][ ( (cnt-1) % str[ s[j-1]-'0' ].size() ) ];
        cnt = 0;
      }else if( s[j] != '0' ) cnt++;
    }
    cout << ans << endl;
  }

  return 0;
}










//

Measured memory_bytes: 3156
N,M = map(int,input().split())

aset = set()
bset = set()

for i in range(M):
  a,b  = map(int,input().split())
  if a == 1:
    aset.add(b)
  elif b == N:
    bset.add(a)

for i in bset:
  if i in aset:
    print("POSSIBLE")
    exit()
print("IMPOSSIBLE")
    
  

Measured memory_bytes: 58072
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
//typedef vector<unsigned int>vec;
typedef vector<ll>vec;
typedef vector<vec> mat;
typedef vector<vector<int>> Graph;

const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
//const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
//const ll MOD = 998244353;
const double PI = acos(-1.0);
const double EPS = 1e-10;

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; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    
    cout << N/2 - (N%2 == 0) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lowbit(x) ((x)&(-x))
#define mem(i, a) memset(i, a, sizeof(i))
#define sqr(x) ((x)*(x))
#define ls(x) (x << 1)
#define rs(x) (x << 1 | 1)
typedef long long ll;
const double eps = 1e-8;
const double pi = acos(-1.0);
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 7;
using namespace std;
int judge(ll n, ll k){
    if(k == 1) return 1;
    while(n % k == 0) n /= k;
    return n % k == 1;
}
int main(void){
#ifdef ljxtt
freopen("data.in", "r", stdin);
#endif
    ll n, m, ans = 0;
    cin >> n;
    m = n - 1;
    for(ll i = 1; i * i <= m; i++){
        if(m % i != 0) continue;
        if(i != 1) ans++;
        if(i != m / i) ans++;
    }
    for(ll i = 1; i * i <= n; i++){
        if(n % i != 0) continue;
        if(i != 1) ans += judge(n, i);
        if(i != n / i) ans += judge(n, n / i); 
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int d,n;
  int S;
  S=0;
  while(cin >> d) {
    n = 600 / d;
    for(int i=1;i<n;i++) {
      S += d * (i * d)*(i * d);
        }
    cout << S << endl;
    S=0;
  }

}

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

using namespace std;

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

int main(){
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	cout << (a-c)*(b-d) << endl;

	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

pub trait InputValue {
    fn parse(s: &str) -> Self;
}

pub fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

pub fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

pub fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn value(cake: (i64, i64, i64), p: usize) -> i64 {
    let p: i64 = p as i64;
    let one = (p & 1) * 2 - 1;
    let two = ((p & 2) * 2 - 2) / 2;
    let fur = ((p & 4) * 2 - 4) / 4;
    cake.0 * one + cake.1 * two + cake.2 * fur
}

fn main() {
    let (n, m): (usize, usize) = read();
    let mut cakes: Vec<(i64, i64, i64)> = readn(n);

    let mut best = 0;
    for p in 0..1<<3 {
        cakes.sort_by(|&a, &b| value(b, p).cmp(&value(a, p)));

        let mut sum1 = 0;
        let mut sum2 = 0;
        let mut sum4 = 0;
        for i in 0..m {
            sum1 += cakes[i].0;
            sum2 += cakes[i].1;
            sum4 += cakes[i].2;
        }
        let abs = sum1.abs() + sum2.abs() + sum4.abs();
        best = max(best, abs);
    }
    println!("{}", best);
}


Measured memory_bytes: 4352
#pragma GCC optimize("Ofast")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <random>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;

typedef
tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> orderedSet;

#define pb push_back
#define F first
#define S second
#define all(a) (a).begin(), (a).end()

#define for1(i0, l0, r0) for (int i0 = l0; i0 < r0; ++i0)
#define for2(i0, l0, r0) for (int i0 = l0; i0 <= r0; ++i0)
#define forn(i0, n0) for (int i0 = 0; i0 < n0; ++i0)
#define forn1(i0, n0) for (int i0 = 1; i0 < n0; ++i0)
#define forr(i0, n0) for (int i0 = n0; i0 >= 0; --i0)
#define forr1(i0, r0, l0) for (int i0 = r0; i0 > l0; --i0)
#define forr2(i0, r0, l0) for (int i0 = r0; i0 >= l0; --i0)

#define Sort(a) sort(all(a))
#define Reverse(a) reverse(all(a))
#define relaxMax(a, b) a = max(a, b)
#define relaxMin(a, b) a = min(a, b)

typedef long double ld;
#define ui unsigned int
#define ull unsigned long long

typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef pair<string, string> pss;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;

typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<pdd> vpdd;

typedef vector<vi> vvi;
typedef vector<vd> vvd;
typedef vector<vll> vvll;
typedef vector<vb> vvb;

#define vpss vector<pss>
#define vvs vector<vs>
#define vvpii vector<vpii>
#define vvpll vector<vpll>
#define vpt vector<pt>
#define vvvi vector<vvi>
#define vsi vector<set<int>>
#define ss second
#define ff first

#define printvi(arr) for (int x0 : arr) cout << x0 << ' '; cout << '\n';
#define printvll(arr) for (ll x0 : arr) cout << x0 << ' '; cout << '\n';
#define printpair(pair0) cout << pair0.F << ' ' << pair0.S << '\n';
#define printvp(arr) for (auto pair0 : arr) printpair(pair0);
#define initArray(arr, N0, X0) memset(arr, X0, N0 * sizeof(int))
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void init() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cout.precision(16);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
}

void solve() {
    string a, b, c;
    cin >> a >> b >> c;
    vs s = {a, b, c};
    int curr = 0;
    while (true){
        if (s[curr].length() == 0){
            cout << (char) (curr + 'A') << '\n';
            return;
        }
        char chr = s[curr][0];
        s[curr] = s[curr].substr(1);
        curr = chr - 'a';
    }
}

bool multitest = false;

int main() {
    init();
    int t = 1;
    if (multitest) cin >> t;
    forn(i, t) solve();
}

Measured memory_bytes: 3616
START = 0
END = 1


def main():
    N, C = map(int, input().split())
    active = [0] * (C+1)
    seq = []
    for _ in range(N):
        s, t, c = map(int, input().split())
        seq += [(s, START, c), (t, END, c)]
    seq.sort()
    ans = 0
    para = 0
    for i in range(len(seq)):
        time, op, channel = seq[i]
        if op == START:
            if active[channel] == 0:
                para += 1
            active[channel] += 1
        else:
            active[channel] -= 1
            if active[channel] == 0:
                para -= 1
        ans = max(ans, para)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 79448
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Math.*;

public class Main {
    BufferedReader rd;

    Main() throws IOException {
        rd = new BufferedReader(new InputStreamReader(System.in));
        compute();
    }

    private void compute() throws IOException {
        long[] a = longarr();
        long n = min(a[0], a[1]);
        long m = max(a[0], a[1]);

        long down = 0;
        if(n > 2 && m > 2) {
            down += (n - 2) * (m - 2);
        }
        if(n == 1) {
            if(m > 1) {
                down = m - 2;
            } else {
                down = 1;
            }
        }
        out(down);
    }

    private long[] longarr() throws IOException {
        return longarr(rd.readLine());
    }

    private long[] longarr(String s) {
        String[] q = split(s);
        int n = q.length;
        long[] a = new long[n];
        for(int i=0;i<n;i++) {
            a[i] = Long.parseLong(q[i]);
        }
        return a;
    }

    private String[] split(String s) {
        if(s == null) {
            return new String[0];
        }
        int n = s.length();
        int start = -1;
        int end = 0;
        int sp = 0;
        boolean lastWhitespace = true;
        for(int i=0;i<n;i++) {
            char c = s.charAt(i);
            if(isWhitespace(c)) {
                lastWhitespace = true;
            } else {
                if(lastWhitespace) {
                    sp++;
                }
                if(start == -1) {
                    start = i;
                }
                end = i;
                lastWhitespace = false;
            }
        }
        if(start == -1) {
            return new String[0];
        }
        String[] res = new String[sp];
        int last = start;
        int x = 0;
        lastWhitespace = true;
        for(int i=start;i<=end;i++) {
            char c = s.charAt(i);
            boolean w = isWhitespace(c);
            if(w && !lastWhitespace) {
                res[x++] = s.substring(last,i);
            } else if(!w && lastWhitespace) {
                last = i;
            }
            lastWhitespace = w;
        }
        res[x] = s.substring(last,end+1);
        return res;
    }

    private boolean isWhitespace(char c) {
        return c==' ' || c=='\t';
    }

    private static void out(Object x) {
        System.out.println(x);
    }

    public static void main(String[] args) throws IOException {
        new Main();
    }
}


Measured memory_bytes: 25044
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <sstream>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <cstdlib>
#include <cmath>

typedef long long ll;

#define reps(i, s, e) for (ll i = s; i < e; ++i)
#define rep(i, n) reps(i, 0, n)
#define rreps(i, s, e) for (ll i = e-1; i >= s; --i)
#define rrep(i, n) rreps(i, 0, n)

// const ll LL_INF = 1LL<<60;

template <class T> inline void chmin(T& a, T b) {if (a > b) {a = b;}}
template <class T> inline void chmax(T& a, T b) {if (a < b) {a = b;}}

using namespace std;

int a, b, n;
bool arr[16][16];
ll dp[16][16];

int main() {
    while (true) {
        scanf("%d %d", &a, &b);
        if (a == 0 && b == 0) break;

        fill(arr[0], arr[16], true);
        fill(dp[0], dp[16], 0LL);
        dp[0][0] = 1;

        scanf("%d", &n);
        rep(i, n) {
            int x, y;
            scanf("%d %d", &x, &y);
            arr[x-1][y-1] = false;
        }

        reps(i, 1, a) {
            if (arr[i][0]) dp[i][0] = 1;
            else break;
            } 
        reps(j, 1, b) {
            if (arr[0][j]) dp[0][j] = 1;
            else break;
        }
        
        reps(i, 1, a) reps(j, 1, b) {
            if (arr[i][j]) dp[i][j] = dp[i-1][j] + dp[i][j-1];
        }
        printf("%lld\n", dp[a-1][b-1]);
    }
}


Measured memory_bytes: 3172
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <cstdlib>

using namespace std;

int main()
{
    int N, K;
    scanf("%d %d\n", &N, &K);
    int pos[N];
    int neg[N];
    //n_pos ... number of elements
    int n_pos = 0;
    int n_neg = 0;

    for (int i = 0; i < N; i++)
    {
        int tmp;
        cin >> tmp;
        if (tmp < 0)
        {
            neg[n_neg] = tmp;
            n_neg++;
        }
        else
        {
            pos[n_pos] = tmp;
            n_pos++;
        }
    }

    //negを降順にする
    for (int i = 0; i < n_neg / 2; i++)
    {
        swap(neg[i], neg[n_neg - i - 1]);
    }

    long long ans = numeric_limits<long>::max();

    //iは何回、正のろうそくを回収するか
    //負のろうそくは K-i 回回収することになる。
    for (int i = 0; i <= K; i++)
    {
        if (i <= n_pos && (K - i) <= n_neg)
        {
            int tmp;
            if (i == 0)
            {
                tmp = -neg[K - i - 1];
            }
            else if (i == K)
            {
                tmp = pos[K - 1];
            }
            else
            {
                tmp = pos[i - 1] - neg[K - i - 1] + min(pos[i - 1], -neg[K - i - 1]);
            }
            //ans更新
            if (tmp < ans)
            {
                ans = tmp;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.Queue;
import java.util.ArrayDeque;
 
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
 
        int K = sc.nextInt();
        Queue<Long> q = new ArrayDeque<Long>();

        for(int i=1; i<=9; i++){
            q.add((long)i);
        }
        for(int i=1; i<=K; i++){
            long x = q.poll();
            if(x%10!=0){
                q.add(10 * x + x % 10 - 1);
            }
            q.add(10 * x + x % 10);
            if(x%10!=9){
                q.add(10 * x + x % 10 + 1);
            }
            if(i==K){
                System.out.println(x);
            }
        }
    }
}

Measured memory_bytes: 31572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PipedInputStream;
import java.util.*;

public class Main {
    private static final int MOD = (int) Math.pow(10, 9);
    private static final int[][] DIRS = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};

    public static void main(String[] args) {
        FastReader sc = new FastReader();
        char a = sc.next().charAt(0);
        char b = sc.next().charAt(0);
        char c = sc.next().charAt(0);
        print(""+a+b+c);
        System.exit(0);
    }

    static  private void print(String s) {
        System.out.println(s);
    }

    static private int log2(int x) {
        return (int)(Math.log(x) / Math.log(2));
    }

    static private long gcd(long m, long n) {
        if (m < n) { return gcd(n, m); }
        if (m % n == 0) { return n; }
        return gcd(n, m%n);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try{
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
import java.util.*;

public class Main
{
  public static void main(String[] args)
  {
    Scanner in = new Scanner(System.in);
    int n = in.nextInt();
    int m = in.nextInt();
    int[][] sc = new int[m][2];
    for(int i=0; i<m; i++){
      sc[i][0] = in.nextInt();
      sc[i][1] = in.nextInt();
    }
    System.out.println(judge(sc, n, m));
  }

  static int judge(int[][] sc, int n, int m){
    if(n==2 || n==3){
      for(int[] condition: sc){
        if(condition[0] == 1 && condition[1] == 0 ) return -1;
      }
    }
    for(int i=0; i<sc.length; i++){
      int j = 0;
      while(j < m){
        if(i != j && sc[i][0] == sc[j][0] && sc[i][1] != sc[j][1]) return -1;
        j++;
      }
    }

    StringBuilder buf = new StringBuilder();
    int i = 0;
    while(i<n){
    buf.append("x");
    i++;
    }
    String[] x = buf.toString().split("");
    for(int j=0; j<m; j++){
      x[sc[j][0]-1] = Integer.toString(sc[j][1]);
    }
    for(int j=0; j<x.length; j++){
      if(x[j].equals("x")){
        x[j]="0";
      }
    }
    if(x[0]=="0" && x.length != 1){
      x[0] = "1";
    }
    String minNum = String.join("", x);
    return Integer.parseInt(minNum);
  }
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1e9;
int N,A,B;
string s;

void solve(){
    for(int i=0;i<s.size();i++){
        if (A+B<=0) {
            cout << "No" <<endl;
            continue;
        }
        if(s[i]=='a'){
            if(A>0)A--;
            else B--;
            cout << "Yes" << endl;
        }
        else if(s[i]=='b'){
            if(B>0){
                B--;
                cout << "Yes" << endl;
            }
            else{
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
}

int main() {
    cin >> N >> A >> B;
    cin >> s;
    solve();
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>

using namespace std;

int main() {
    double vt;
    while(cin >> vt) {
        double t = vt / 9.8;
        double h = 4.9 * t*t;
        cout << ceil((h+5)/5) << endl;
    }
    return 0;
}

Measured memory_bytes: 0
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    String str = scan.nextLine();
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == 'R' && i%2==1){
        System.out.println("No");
        return;
      }else if(str.charAt(i) == 'L' && i%2==0){
        System.out.println("No");
        return;
      }
    }
    System.out.println("Yes");
  }
 }

Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

struct node
{
    char key;
    int rt;
}link1[200005],link2[200005];
    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    string s;
    cin>>s;

    int zf=0; //0正1反
    string sf,se;
    int q;
    cin>>q;
    while (q--)
    {
        int t,f;
        string c;
        cin>>t;

        if (t==1)
        {
            zf=!zf;
        }
        else 
        {
            cin>>f>>c;
            if (f==1)
            {
                if (zf)
                    se+=c;
                else sf+=c;
            }
            else
            {
                if (zf)
                    sf+=c;
                else se+=c;
            }
        }
    }

    reverse(INS(sf));
    s=sf+s+se;
    if (zf)
    {
        for (int i=s.size()-1;i>=0;i--)
            cout<<s[i];
    }
    else 
        for (auto i:s)
            cout<<i;
    

    return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include<algorithm>
 
using namespace std;
 
int main()
{
    int n,k,nn;
    int x[1000];
    int y[1000];
    int z[1000];
    cin>>n>>k;
 
    for(int i=0;i<k;i++){
        cin>>x[i];
        cin>>y[i];
    }
    for(int i=0;i<k;i++){
    if(n-x[i]<x[i])
        x[i]=n-x[i]+1;
    if(n-y[i]<y[i])
        y[i]=n-y[i]+1;
 
    if(x[i]>y[i])
        z[i]=y[i]%3;
    if(y[i]>x[i])
        z[i]=x[i]%3;
    if(x[i]==y[i])
        z[i]=x[i]%3;
    if(z[i]==0)
        z[i]=3;
    cout<<z[i]<<endl;
    }
    return 0;
}
 

Measured memory_bytes: 1172