akhauriyash/Code-Regression huggingface dataset:
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	k <- readInt
	[ a, b ] <- readInts
	putStrLn $ which "OK" "NG" $ not $ null $ filter ( ( == 0 ) . ( `mod` k ) ) [ a .. b ]

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
/*
template<class... T>
ostream& operator<<(ostream& os, tuple<T...>& t) {
	for (size_t i = 0; i < tuple_size< tuple<T...> >::value; ++i) {
		if (i) os << " ";
		os << get<0>(t);
	}
	return os;
}
*/
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
    int n, m;
    while ( cin >> n >> m, n || m ) {
        vector<int> a(n), b(m); cin >> a >> b;
        int sa = 0, sb = 0;
        REP(i, n) sa += a[i];
        REP(i, m) sb += b[i];
        int tgt = sb - sa;
        int a0 = -1, a1 = -1, a2 = 1e9;
        REP(i, n) REP(j, m) {
            if (2*(a[i]-b[j]) == -tgt && a[i]+b[j] < a2) {
                a0 = a[i], a1 = b[j], a2 = a[i]+b[j];
            }
        }
        if (a0 < 0) cout << -1 << endl;
        else cout << a0 << " " << a1 << endl;
    }
}

Measured memory_bytes: 3144
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;


int main(){
	
	int NumberOfInput;
	int InputArray[2];
	int Remainder;

	for (int i = 0; i < 2; ++i){		
		cin >> InputArray[i];
	}
	
	while (InputArray[0] != InputArray[1]){
		if (InputArray[0] < InputArray[1]){
			InputArray[1] = InputArray[1] - InputArray[0];
		}
		else{
			InputArray[0] = InputArray[0] - InputArray[1];
		}
	}

	cout << InputArray[0]<<endl;

	return 0;
}

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

int main() {
    int N,T;
    int t[200000];
    cin >> N >> T;
    for(int i=0; i<N; ++i) cin >> t[i];

    long long X = 0;
    for(int i=0; i+1<N; ++i) {
        X += min(t[i+1] - t[i], T);
    }
    X += T;
    cout << X << endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    ll N; cin >> N;
    ll ans = 0;
    if(N % 2 == 0) {
        ll baisuu = 5;
        while(N / baisuu != 0) {
            ans += (N / baisuu) / 2;
            baisuu *= 5;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3536
fun main(args : Array<String>) {
        var clazz: Int = 0

        val x: Int = readLine()?.toInt() ?: 0

        when {
            (400 <= x) && (x <= 599) -> {
                clazz = 8
            }
            (600 <= x) && (x <= 799) -> {
                clazz = 7
            }
            (800 <= x) && (x <= 999) -> {
                clazz = 6
            }
            (1000 <= x) && (x <= 1199) -> {
                clazz = 5
            }
            (1200 <= x) && (x <= 1399) -> {
                clazz = 4
            }
            (1400 <= x) && (x <= 1599) -> {
                clazz = 3
            }
            (1600 <= x) && (x <= 1799) -> {
                clazz = 2
            }
            (1800 <= x) && (x <=1999) -> {
                clazz = 1
            }
        }

        println(clazz)
    }

Measured memory_bytes: 34392
#include <iostream>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;
const int maxn=3e5+50;
int str[maxn];
long long int man[maxn];
long long int minn[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    memset(str,0,sizeof(str));
    memset(man,0,sizeof(man));
    memset(minn,0,sizeof(minn));
    for(int i=0;i<3*n;i++)
        scanf("%d",&str[i]);
    priority_queue<int,vector<int>,greater<int> > p1;
    priority_queue<int,vector<int>,less<int> >p2;
    long long ans=0;
    for(int i=0;i<3*n;i++)
    {
        p1.push(str[i]);ans+=str[i];
        while (p1.size()>n)
        {
          ans-=p1.top();
          p1.pop();
        }
        man[i]=ans;
    }
    ans=0;
    for(int i=3*n-1;i>=0;i--)
    {
          p2.push(str[i]);ans+=str[i];
      while (p2.size()>n)
        {
          ans-=p2.top();
          p2.pop();
        }
        minn[i]=ans;
    }
    ans=-1e17;
    for(int i=n-1;i<2*n;i++)
    {
        ans=max(ans,man[i]-minn[i+1]);
    }
    cout<<ans<<endl;
   // printf("%lld\n",ans);
    return 0;
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define A first
#define B second
#define MOD 1000000007

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

int mulmd(ll a, ll b){
    ll ret = (a * b) % MOD;
    return (int)ret;
}

inline int power(ll x, ll y, int p)
{
    ll res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = mulmd(res, x);
        y = y >> 1;
        x = mulmd(x, x);
    }
    return (int)res;
}

int submd(ll a, ll b){
    ll ret = a - b;
    if(ret < 0){
        ret += MOD;
    }
    return (int)ret;
}

int addmd(ll a, ll b){
    ll ret = (a + b) % MOD;
    return (int)ret;
}

int invPow(ll a){
    return power(a, MOD - 2, MOD);
}

const int N = 1e5 + 5;

int arr[N];
map<ii, int> mp;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll h, w, n;
    cin >> h >> w >> n;
    vii a(n);
    set<ii> st;
    for(int i = 0; i < n; i++) {
        cin >> a[i].A >> a[i].B;
        st.insert(a[i]);
    }

    vector<ll> ans(10, 0);
    for(int i = 0; i < n; i++){
        ii tp = a[i];
        for(int j = -2; j <= 0; j++){
            for(int k = -2; k <= 0; k++){
                mp[{tp.A + j, tp.B + k}] += 1;
            }
        }
    }
    ll occ = 0;
    for(auto i: mp){
        if(i.A.A >= 1 && i.A.A + 2 <= h && i.A.B >= 1 && i.A.B + 2 <= w) ans[i.B] += 1;
    }
    //debug(occ);
    for(int i = 1; i <= 9; i++) occ += ans[i];
    ll total = (h - 2 )*(w - 2);
    ll blank = total - occ;
    ans[0] = blank;
    for(int i = 0; i < 10; i++){
        cout << ans[i] << "\n";
    }
}

/**
    Check out for boundary cases, (n = 1 or n = 0)
    check for integer overflow

**/



Measured memory_bytes: 61952
#include <iostream>
#include <tuple>
#include <utility>
#include <vector>

// Returns the maximum and second maximum values
std::pair<int, int> max_values(const std::vector<int>& a) {
  int max1 = 0;
  int max2 = 0;

  for (auto&& ai : a) {
    if (ai > max1) {
      max2 = max1;
      max1 = ai;
    } else if (ai > max2) {
      max2 = ai;
    }
  }

  return {max1, max2};
}
int main() {
  int n;
  std::cin >> n;

  std::vector<int> a(n);
  for (auto&& ai : a) std::cin >> ai;

  int max1, max2;
  std::tie(max1, max2) = max_values(a);

  for (auto&& ai : a) std::cout << (ai == max1 ? max2 : max1) << '\n';
  std::cout << std::flush;
}

Measured memory_bytes: 2432
using System;
class c
{
    static void Main()
    {
        var xy = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
        int add = 1;
        if (xy[0] * xy[1] > 0)
        {
            if (Math.Abs(xy[0]) < Math.Abs(xy[1])) add = xy[0] > 0 ? 0 : 2;
            else add = xy[0] > 0 ? 2 : 0;
        }
        else if (xy[0] == 0 && xy[1] > 0 || xy[1] == 0 && xy[0] < 0) add = 0;
        Console.WriteLine(Math.Abs(Math.Abs(xy[0]) - Math.Abs(xy[1])) + add);
    }
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a, b, c, k; cin >> a >> b >> c >> k;
  int ans;
  if (a >= k){ans=k;}
  else if (a<k && a+b>=k){ans=a;}
  else {ans=2*a+b-k;}
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {
  int N; cin >> N;
  bool ans = false;
  int zoro = 0;
  rep(i,N){
    int d1, d2;
    cin >> d1 >> d2;
    if (d1 == d2) zoro++;
    else zoro = 0;
    if (zoro >= 3) ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;

	return 0;
}



Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

int main(){
    fast;
    ll l, r, d;
    cin >> l >> r >> d;
    ll ans = r/d - l/d;
    if(l%d == 0){
        ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
using namespace std;
typedef long long ll;
#define rep(i,k) for(i=0;i<k;i++)
#define P pair<ll,ll>
ll mod = 1000000007;
P p[200005];
ll n, m, c[11], i, j, h, w, k, l, z, a[10] = {1,1,2,3,5,8,13,21,34,55}, b[1005];
ll dp[105][10] = {};


ll mae(ll ww, ll jj) {
	if (jj == 1)return 0;
	return a[jj - 2] * a[ww - jj];
}
ll shita(ll ww, ll jj) {
	return a[jj - 1] * a[ww - jj];
}
ll ato(ll ww, ll jj) {
	if (jj == ww)return 0;
	return a[jj - 1] * a[ww - jj-1];
}



int main() {
	cin >> h >> w>>k;
	dp[0][1] = 1;
	for (i = 1; i <= h; i++) {
		rep(j, w + 2)c[j] = 0;
		
		for (j = 1; j <= w; j++) {
			dp[i][j] += dp[i-1][j - 1] * mae(w, j) + dp[i-1][j] * shita(w, j) + dp[i-1][j + 1] * ato(w, j);
			dp[i][j] %= mod;
//			cout << dp[i][j] << " ";
		}
//		cout << "\n";
	}
	cout << dp[h][k];
	return 0;
	
}

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

int main() {
    int x, k, q, r[100000], t, y;
    cin >> x >> k;
    for(int i = 0; i < k; i++) cin >> r[i];
    cin >> q;
    int a{0}, b{x}, c{0}, s{0}, u{0}, v{-1};
    auto f = [](int m, int z, int n) { return max(m, min(n, z)); };
    while(q--) {
        cin >> t >> y;
        for(; u < k && r[u] <= t; s = r[u++], v *= -1) {
            c = f(-b, c + (r[u] - s) * v, x - a);
            a = f(a, 0 - c, b);
            b = f(a, x - c, b);
        }
        cout << f(0, f(a, y, b) + c + (t - s) * v, x) << endl;
    }
    return 0;
}


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

int main(){
    int a, b, k;
    int i, j;
    cin>>a>>b>>k;
    if(b-a+1>=2*k){
        for(i=a; i<=a+k-1; i++){
            cout<<i<<endl;
        }
        for(i=b-k+1; i<=b; i++){
            cout<<i<<endl;
        }
    }
    else{
        for(i=a; i<=b; i++){
            cout<<i<<endl;
        }
    }

    return 0;
}

Measured memory_bytes: 256
/*input
aa
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=500005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
int cnt[3];
int main()
{
	IOS;
	string s;
	cin>>s;
	for(char c:s) cnt[c-'a']++; 
	sort(cnt,cnt+3);
	if(cnt[2]-cnt[0]<=1) cout<<"YES\n";
	else cout<<"NO\n";
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
using P = pair<LL, LL>;

int main(){
    LL H, W, N;
    cin >> H >> W >> N;
    map<P, LL>  Map;
    for(int i = 0;i < N;i++){
        int ai, bi;
        cin >> ai >> bi;
        for(int i = ai-2;i <= ai;i++){
            for(int j = bi-2;j <= bi;j++){
                if(i < 1 || i > H || j < 1 || j > W)    continue;
                if(i+2 > H) continue;
                if(j+2 > W) continue;
                P p = P(i, j);
                if(!Map[p]) Map[p] = 1;
                else    Map[p]++;
            }
        }
    }
    vector<LL>  ans(10, 0);
    ans[0] = (H-2)*(W-2);
    for(auto& iter : Map){
        ans[iter.second]++;
        ans[0]--;
    }
    for(auto& iter : ans)   cout << iter << endl;
}

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

using namespace std;

typedef long long ll;

const int N = 1e5 + 10;

int n, m, d;
double ans;

int main() {
	#ifdef LOCAL
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
	#endif

	cin >> n >> m >> d;

	ans = (double)(m - 1) * 2.0 * (n - d) / n / n;
	if (d == 0) ans /= 2;

	cout << fixed << setprecision(15) << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
int main() {
	int a, b, c, d;
	int cnt = 0;
	cin >> a >> b >> c >> d;
	if (a > c) {
		for (int i = a; i <b; i++) {
			if (i >= c&&i < d) {
				//cout << i << endl;
				cnt++;
			}
		}
	}
	else {
		for (int i = c; i < d; i++) {
			if (i >= a&&i < b) {
				cnt++;
				//cout << i << endl;
			}
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstring>
#include <queue>
#define pb push_back
#define ll long long
#define pi 3.1415926
using namespace std;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<long long,int> pli;
typedef pair<int,long long> pil;
const int INF=1000000007;
const int MOD=1000000007;
const int nmax=201234;

int n;
ll res;
char s[nmax];

int main()
{
    scanf("%d",&n);
    scanf("%s",s);
    if(s[0]=='B'){
        int cnt=1;
        int flg=0;
        res=1;
        for(int i=1; i<2*n; ++i)
        {
            if(s[i]==s[i-1])
                flg^=1;
            if(flg==1){
                res=res*cnt%MOD;
                if(cnt==0)
                    break;
                --cnt;
            }
            else{
                ++cnt;
            }
        }
        if(cnt!=0)
            res=0;
        else if(res!=0)
            for(int i=2;i<=n;++i)
                res=res*i%MOD;
    }
    printf("%lld\n",res);
    return 0;
}
//    ios::sync_with_stdio(false);
//    cin.tie(0);
//    cout.tie(0);


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

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using ld = long double;

template <typename T>
int sz(T &x) {
  return (int)(x.size());
}

const int inf = 1'000'000'007;

int ans[10001];

void solve() {
  int n;
  cin >> n;

  auto f = [](int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
  };

  for (int x = 1; x <= n; ++x) {
    if (f(0, 0, 0) > n) {
      break;
    }
    for (int y = 1; y <= n; ++y) {
      if (f(x, y, 0) > n) {
        break;
      }
      for (int z = 1; z <= n; ++z) {
        if (f(x, y, z) > n) {
          break;
        }
        ans[f(x, y, z)]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << ans[i] << "\n";
  }
}

int main() {
  #ifndef LOCAL58
    // don't forget to remove if interactive
    ios_base :: sync_with_stdio(false);
    cin.tie(nullptr);
  #endif

  int t;
  t = 1;
  while(t--) {
    solve();
  }

  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define pi M_PI
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int mod(int x, int y){
    return x % y + (x % y < 0 ? y : 0);
}

int main() {
    int n;
    string station = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
    int m = station.length();
    map<char, int> mp;
    REP(i,m){
        mp[station[i]] = i;
    }
    while (cin >> n && n){
        VI k(n);
        REP(i,n) cin >> k[i];
        string s;
        cin >> s;
        REP(i,s.length()){
            int x = mp[s[i]];
            s[i] = station[mod(x-k[i%n], m)];
        }
        cout << s << endl;
    }

    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define itn long long

typedef long long ll;
typedef pair<ll,ll> p;


int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  
  int count5 = 0;
  int count7 = 0;
  if(a == 5) count5++;
  if(a == 7) count7++;
  
  if(b == 5) count5++;
  if(b == 7) count7++;

  if(c == 5) count5++;
  if(c == 7) count7++;
  
  if(count5 == 2 && count7 == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAXNUM 100001

char judge[MAXNUM] = {'\0'};
int animal[MAXNUM] = {-1};
int N = 0;

void solve(int i);

int main(void)
{
    int i;

    scanf("%d", &N);
    scanf("%s", judge);

    animal[0] = 0; //S:0, W:1
    animal[N - 1] = 1;
    for (i = 0; i < N; i++)
        solve(i);
    if (animal[0] == 0 && animal[N - 1] == 1)
    {
        for (i = 0; i < N; i++)
        {
            if (animal[i])
                printf("W");
            else
                printf("S");
        }
        return 0;
    }

    animal[0] = 0; //S:0, W:1
    animal[N - 1] = 0;
    for (i = 0; i < N; i++)
        solve(i);
    if (animal[0] == 0 && animal[N - 1] == 0)
    {
        for (i = 0; i < N; i++)
        {
            if (animal[i])
                printf("W");
            else
                printf("S");
        }
        return 0;
    }

    animal[0] = 1; //S:0, W:1
    animal[N - 1] = 0;
    for (i = 0; i < N; i++)
        solve(i);
    if (animal[0] == 1 && animal[N - 1] == 0)
    {
        for (i = 0; i < N; i++)
        {
            if (animal[i])
                printf("W");
            else
                printf("S");
        }
        return 0;
    }

    animal[0] = 1; //S:0, W:1
    animal[N - 1] = 1;
    for (i = 0; i < N; i++)
        solve(i);
    if (animal[0] == 1 && animal[N - 1] == 1)
    {
        for (i = 0; i < N; i++)
        {
            if (animal[i])
                printf("W");
            else
                printf("S");
        }
        return 0;
    }

    printf("-1");
    return 0;
}

void solve(int i)
{
    if (judge[i] == 'o')
    {
        if (i == 0)
        {
            if (animal[i])
                animal[i + 1] = !animal[N - 1];
            else
                animal[i + 1] = animal[N - 1];
        }
        else if (i == N - 1)
        {
            if (animal[i])
                animal[0] = !animal[N - 2];
            else
                animal[0] = animal[N - 2];
        }
        else
        {
            if (animal[i])
                animal[i + 1] = !animal[i - 1];
            else
                animal[i + 1] = animal[i - 1];
        }
    }
    else
    {
        if (i == 0)
        {
            if (animal[i])
                animal[i + 1] = animal[N - 1];
            else
                animal[i + 1] = !animal[N - 1];
        }
        else if (i == N - 1)
        {
            if (animal[i])
                animal[0] = animal[N - 2];
            else
                animal[0] = !animal[N - 2];
        }
        else
        {
            if (animal[i])
                animal[i + 1] = animal[i - 1];
            else
                animal[i + 1] = !animal[i - 1];
        }
    }
}

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

using namespace std;

int main(){
    long long int x=1;
    scanf("%lld",&x);
    long long int ans=1;
    for(long long int j=2;j<=x;j++){
        long long int ret=j;
        while(ret<=x){
          ret*=j;
          if(ret<=x){
              ans=max(ans,ret);
          }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if (a%2!=0&&a==b&&b==c) {
		cout << 0;
	}ei(a == b && b == c) {
		cout << -1;
	}
	else {
		while (true) {
			if (a % 2 == 0 && b % 2 == 0 && c % 2 == 0) {
				int a1 = a / 2, b1 = b / 2, c1 = c / 2;
				a = 0; b = 0; c = 0;
				a = b1 + c1;
				b = a1 + c1;
				c = a1 + b1;
				ans++;
			}
			else {
				cout << ans;
				return 0;
			}
		}
	}

	return 0;
}

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



int main() {

	int a, b, c;
	cin >> a >> b >> c;
	bool ans = false;
	for (int i = 1; i < b; i++) {
		if (a * i % b == c) {
			ans = true;
		}
	}

	if (ans) {
		cout << "YES" << endl;
	}
	
	else {
		cout << "NO" << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a += b;
	if(a>MOD){
		a -= MOD;
	}
}

int n;
ll s[225],dp[225][100100];

int main(void){
	int n,x,i,j;
	ll ans=0ll;
	cin >> n >> x;
	for(i=0; i<n; ++i){
		cin >> s[i];
	}
	sort(s,s+n);
	dp[n][x] = 1ll;
	for(i=n; i>0; --i){
		for(j=0; j<=x; ++j){
			add_mod(dp[i-1][j%s[i-1]],dp[i][j]);
		}
		for(j=0; j<=x; ++j){
			mul_mod(dp[i][j],i-1);
			add_mod(dp[i-1][j],dp[i][j]);
		}
	}
	for(j=0; j<=x; ++j){
		mul_mod(dp[0][j],j);
		add_mod(ans,dp[0][j]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 157952
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
int main()
{
    int N, R;
    cin >> N >> R;
    if (N < 10)
        cout << R + 100 * (10 - N);
    else
        cout << R;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
char ch;
int read(){int n=0,p=1;for(ch=getchar();ch<'0' || '9'<ch;ch=getchar())if(ch=='-') p=-1;for(;'0'<=ch && ch<='9';ch=getchar()) n=n*10+ch-'0';return n*p;}
const int N=3005,mo=1e9+7;
int n,m;
ll f[N][N],g[N][N];
void upd(ll &x,ll y){x=(x+y)%mo;}
int main()
{
	n=read(),m=read();
	g[0][0]=1;
	fo(i,1,n) f[0][i]=1;
	fo(i,1,m)
		fo(j,0,n)
		{
			upd(f[i][j],(j==n && n==1?0:f[i-1][j])+f[i-1][j+1]+(j>0?f[i-1][j-1]:0));
			upd(g[i][j],g[i-1][j]+(j>0?g[i-1][j-1]:0)+g[i-1][j+1]);
			if(0<j && j<n) upd(g[i][j],g[i-1][j]);
			if(1<j && j<n) upd(f[i][j],f[i-1][j]);
			if(j==1) upd(g[i][j],f[i-1][j]);
			if(j==0) upd(g[i][j],f[i][j]),f[i][0]=0;
		}
	ll ans=0;
	fo(i,0,n) ans=(ans+g[m][i])%mo;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 141184
#include<iostream>
using namespace std;
#include<cstdio>
#include<cmath>

struct Point{ double x, y; };

Point set_p(double a, double b)
{
    Point p;
    p.x = a; p.y = b;
    return p;
}

struct Vector{ double vx, vy; };

Vector set_v(const Point &p1, const Point &p2)
{
    Vector v;
    v.vx = p2.x - p1.x;
    v.vy = p2.y - p1.y;
    return v;
}

double inpro(const Vector &v1, const Vector &v2)
{
    return (v1.vx * v2.vx) + (v1.vy * v2.vy);
}

double det2(const Vector &v1, const Vector &v2)
{
	return (v1.vx * v2.vy) - (v1.vy * v2.vx);
}

int main()
{
    int q;
    scanf("%d", &q);
    double x0, y0, x1, y1, x2, y2, x3, y3;
    for(int i = 0; i < q; i++){
        scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x0, &y0, &x1, &y1, &x2, &y2, &x3, &y3);
        Vector V01 = set_v(set_p(x0, y0), set_p(x1, y1));
        Vector V23 = set_v(set_p(x2, y2), set_p(x3, y3));
        if(det2(V01, V23) == 0){ printf("2\n"); }
        else if(inpro(V01, V23) == 0){ printf("1\n"); }
        else{ printf("0\n"); }
    }
    return 0;
}

Measured memory_bytes: 1208
while True:
    r,c = map(int, input().split())
    if (r|c)==0: break

    num = [0]*c
    for i in range(r):
        instr = input()
        for j in range(c):
            num[j] = num[j]*2+int(instr[2*j])

    maxx = -1
    for i in range(1 << r):
        answer = 0
        for j in range(c):
            oksenbei = bin(num[j]^i).count("1")
            answer += oksenbei if oksenbei*2//r >= 1 else r-oksenbei
        if maxx < answer:
            maxx = answer

    print(maxx)

Measured memory_bytes: 7904
import bisect
h,w,n = map(int,input().split())
a = []
for i in range(n):
    x,y = map(int,input().split())
    x-=1
    y-=1
    a.append([x,y])
kabe = [[] for i in range(w)]
for i,j in a:
    kabe[j].append(i)
for i in range(w):
    kabe[i].sort()
ans = float("inf")
to = 0
for i in range(w):
    mo = bisect.bisect_right(kabe[i], to)
    if mo < len(kabe[i]):
        ans = min(ans,kabe[i][mo])
    else:
        ans = min(ans,h)
    if i == w-1:
        break
    c = set(kabe[i+1])
    to += 1
    while to in c:
        to+=1
    if to >h:
        break
print(ans)

Measured memory_bytes: 99928
n = int(input())
items = [int(x) for x in input().split()]
 
flg = True
for item in items:
  if item % 2 == 0:
    if item % 3 == 0 or item % 5 == 0:
      flg = True
    else:
      flg = False
      break
 
if flg:
  print('APPROVED')
else:
  print('DENIED')

Measured memory_bytes: 3060
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if(n == 1) {
			System.out.println("Hello World");
		}else {
			int a = sc.nextInt(), b = sc.nextInt();
			System.out.println(a+b);
		}
	}
}

Measured memory_bytes: 21972
def main():

    K, N = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted(A)
    max_dist = A[0] + (K - A[-1])
    for i in range(N - 1):
        if max_dist < A[i + 1] - A[i]:
            max_dist = A[i + 1] - A[i]
    print(K - max_dist)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26420
#include<iostream>
#include<cmath>
#include<algorithm>
typedef long long ll;
using namespace std;

int main(){
  ll n,a,c=0;
  cin>>n;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i==0){
      ll b=n/i;
      c++;
      if(c==1){a=b+i;}
      else{
        a=min(a,b+i);
      }
    }
  }
  cout<<a-2<<endl;
}

Measured memory_bytes: 256
let lcs x y =
  let m = String.length x in
  let n = String.length y in
  let dp = Array.make_matrix (m+1) (n+1) 0 in
  let rec doit i j =
    if i > m then dp.(m).(n)
    else if j > n then doit (i + 1) 1
    else begin
      dp.(i).(j) <- if x.[i-1] = y.[j-1] then dp.(i-1).(j-1) + 1 else if dp.(i-1).(j) > dp.(i).(j-1) then dp.(i-1).(j) else dp.(i).(j-1);
      doit i (j + 1)
    end in
  doit 1 1

let () =
  let q = read_int () in
  let rec doit i =
    if i < q then begin
      let x = read_line () in
      let y = read_line () in
      Printf.printf "%d\n" (lcs x y);
      doit (i + 1)
    end in
  doit 0

Measured memory_bytes: 18548
#/usr/bin/env python3

from collections import Counter
a = Counter()
for _ in range(3):
    m,n = map(int, input().split())
    a[m]  += 1
    a[n] += 1
    if a[m] > 2 or a[n] > 2:
        print("NO")
        exit(0)
print("YES")



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

int main() {
  int64_t MOD = 1000000000 + 7;
  int N, M;
  cin >> N >> M;
  vector<int64_t> S(N);
  vector<int64_t> T(M);
  for(int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  for(int i = 0; i < M; i++) {
    cin >> T.at(i);
  }
  vector<vector<int64_t>> data(N + 1, vector<int64_t> (M + 1, 0));
  for(int i = 0; i <= N; i++) {
    data.at(i).at(0) = 1;
  }
  for(int i = 0; i <= M; i++) {
    data.at(0).at(i) = 1;
  }
  for(int i = 1; i <= N; i++) {
    for(int j = 1; j <= M; j++) {
      if(S.at(i - 1) == T.at(j - 1)) {
        data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j);
        data.at(i).at(j) %= MOD;
      }
      else {
        data.at(i).at(j) = data.at(i).at(j - 1) + data.at(i - 1).at(j) - data.at(i - 1).at(j - 1);
        data.at(i).at(j) += MOD;
        data.at(i).at(j) %= MOD;
      }
    }
  }
  cout << data.at(N).at(M) << endl;
}

Measured memory_bytes: 34612
#include <stdio.h>

int island[14][14] = {};

void count(int y, int x){
  if(island[y][x]){
    island[y][x] = 0;
    count(y + 1, x);
    count(y - 1, x);
    count(y, x + 1);
    count(y, x - 1);
  }
  return;
}

int main(){
  int i, j;
  char str[12];
  while(1){
    int c = 0;
    for(i = 1;i < 13;i++){
      if(scanf("%s", str) == EOF) return 0;
     for(j = 0;j < 12;j++){
       if(str[j] == '1')
	 island[i][j + 1] = 1;
     }
    }

    for(i = 1;i < 13;i++){
      for(j = 1;j < 13;j++){
	if(island[i][j]){
	  c++;
	  count(i, j);
	}
      }
    }
  
    printf("%d\n", c);
  }
}

Measured memory_bytes: 544
def main():
    n = int(input())
    a = list(map(int, input().split()))
    plus = [None]*n
    minus = [None]*n
    for i, ai in enumerate(a, 1):
        plus[i-1] = i+ai
        minus[i-1] = i-ai
    plus.sort()
    minus.sort()
    ans = 0
    j = 0
    i = 0
    while i < n:
        pi = plus[i]
        p_num = 1
        m_num = 1
        while j < n-1 and minus[j] < pi:
            j += 1
        mi = minus[j]
        if mi == pi:
            while j < n-1 and mi == minus[j+1]:
                m_num += 1
                j += 1
            while i < n-1 and pi == plus[i+1]:
                p_num += 1
                i += 1
            ans += p_num*m_num
        i += 1
        
    print(ans)
    

if __name__ == "__main__":
    main()

Measured memory_bytes: 99404
#include<stdio.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#define rep(i,n) for(int i=0;i<(lint)(n);i++)
#define REP(i,n) for(int i=1;i<=(lint)(n);i++)
typedef long long lint;
typedef unsigned long long ulint;
const int mod=1000000007;
int k,n=-1,cnt=13;
char c[15];
lint fact[2000010],inv[2000010];
int main(){
	while(true){
		*c=getchar_unlocked();
		if(*c=='\n')break;
		k*=10;
		k+=*c-'0';
	}
	while(getchar_unlocked()!=-1)n++;
	fact[0]=1;
	for(int i=1;i<=n+k;i++)fact[i]=fact[i-1]*i%mod;
	inv[n+k]=1;
	lint now=fact[n+k];
	int b=mod-2;
	while(b){
		if(b&1){
			inv[n+k]*=now;
			inv[n+k]%=mod;
		}
		b>>=1;
		now*=now;
		now%=mod;
	}
	for(int i=n+k-1;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
	lint ans=1;now=1;
	for(int i=1;i<=k;i++){
		now*=25;
		now%=mod;
		ans+=fact[n+k]*inv[n+k-i]%mod*inv[i]%mod*now;
		ans%=mod;
	}
	*(c+14)='\n';
	while(ans){
		*(c+cnt)=ans%10+'0';
		ans/=10;
		cnt--;
	}
	fwrite(c+cnt+1,1,14-cnt,stdout);
	return 0;
}

Measured memory_bytes: 32712
d = int(input())
nums = list(map(int, input().split(' ')))

crashed = []
i = 1
output = -1

# 1つだけの場合
if len(nums) == 1:
  if nums[0] == 1:
    output = 0
  print(output)
# 2つ以上の場合
else:
  crash_count = 0
  for n in nums:
    if n == i:
      crashed.append(n)
      i += 1
    else:
      crash_count += 1
  success = True
  pre = 0
  if len(crashed) == 0:
    print(-1)
  else:
    for n in crashed:
      if n == pre + 1:
        pre = n
      else:
        success = False
        break
    if success:
      print(crash_count)
    else:
      print(-1)

Measured memory_bytes: 26140
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <iterator>

using namespace std;

typedef long long ll;
#define mems(p) memset(p,-1,sizeof(p))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define nl "\n"

void fast()
{ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);}


int main() {
	string s;
  cin >> s;
  for (int i = 0; i < s.length(); ++i) {
  	if (s[i] == '?') s[i] = 'D';
  }
  cout << s << nl;
}

Measured memory_bytes: 3716
// READ & UNDERSTAND
// ll, int overflow, array bounds
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN

#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

ll INF=LLONG_MAX;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	int tt = (a+d-1)/d;
	int aa = (c+b-1)/b;
	if(tt>=aa)cout << "Yes" << endl;
	else cout << "No" << endl;
}	


Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <cassert>

#include <vector>
#include <algorithm>

using namespace std;

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

void Main()
{
	int H, W;
	cin >> H >> W;
	vector<vector<char>> D(2 * H, vector<char>(W));

	rep(i, H)
	{
		rep(j, W)
		{
			cin >> D[2*i][j];
			D[2*i+1][j] = D[2*i][j];
		}
	}

	rep(i, 2*H)
	{
		rep(j, W)
		{
			cout << D[i][j];
		}
		cout << endl;
	}
}

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

	Main();
	return 0;
}

Measured memory_bytes: 3676
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define mod 998244353
#define int long long
#define inf 200000000000
const int maxnodes=1005;
#define ll long long
#define N 101
#define EPS 0.01
#define ld long double

int32_t main()
{
    IOS;

    int k,x;
    cin >> k >> x;
    for(int i = x - k + 1;i <= x + k - 1;i++)
        cout << i << " ";
}   

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main(int argc, char **argv)
{
	int a,b,c,d = 0;
	cin >> a >> b >> c;
	for(int i = b;i <= c; i++){
		if(i % a == 0){
			d = 1;
			}}
		
		
		if(d == 1){
			cout << "OK";
			}
		else{
			cout << "NG";
		}
		
     return 0;
}

Measured memory_bytes: 3600
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a[3],i,s,cnt;
	cnt=0;
	cin>>s;
	for(i=2;i>=0;i--){
		a[i]=s%10;
		s=s/10;
	}
	for(i=0;i<3;i++){
		if(a[i]==1) cnt=cnt+1;
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
// Author : Nachiket Kanore
// Institute : PICT, Pune

/* It does not matter how slowly you go as long as you do not stop.*/

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define endl '\n'
#define rep(x,s,e) for(int x=s;x<=(e);x++)
#define repn for(int x=0;x<n;x++)
#define rep1n for(int x=1;x<=n;x++)
#define rep1m for(int y=1;y<=m;y++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define precise(x) cout << fixed << setprecision(x)
#define bits(x) __builtin_popcount(x)
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}


template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define see(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define see(x...)
#endif

const int inf = 1e18;
const int N = 1005;


int32_t main(){
    FAST;

    string s;   cin >> s;
    sort(all(s));
    if(s == "abc")
        cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}




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

#define FOR(i, a, b) for(int i = a; i<b; ++i)
#define FR(a, b) for(int i = a; i>=b;--i)
#define _upgrade cin.tie(0); ios_base::sync_with_stdio(0)
#define pb push_back
#define mp make_pair
#define INF 1e9+2137
#define all(x) (x).begin(), (x).end()

using namespace std;

typedef long long ll;
typedef double db;
typedef unsigned long long ull;
typedef pair<int, int> iPair;

const int MAX = 3e3+1;
const int M = 1e9+7;

int n;
double tab[MAX], dp[MAX][MAX];
int main()
{
    _upgrade;
    cin>>n;
    FOR(i, 0, n)
        cin>>tab[i];

    dp[0][0] = 1;
    FOR(i, 1, n+1)
        dp[i][0] = (1-tab[i-1])*dp[i-1][0];

    FOR(i, 1, n+1)
        FOR(j, 1, i+1)
            dp[i][j] = dp[i-1][j]*(1-tab[i-1]) + dp[i-1][j-1]*tab[i-1];
   /* FOR(i, 0, n+1)
    {
        FOR(j, 0, n+1)
            cout<<dp[i][j]<<" ";
        cout<<"\n";
    }*/
    double res = 0;
    FOR(i, n/2+1, n+1)
        res += dp[n][i];
    cout<<setprecision(9)<<res;
}


Measured memory_bytes: 68992
N, A, B = map(int, input().split())
score = 0
for i in range(N+1):
    i_1 = i % 10
    i_10 = i % 100 // 10
    i_100 = i % 1000 // 100
    i_1000 = i % 10000 // 1000
    i_10000 = i // 10000
    sum_i = i_1 + i_10 + i_100 + i_1000 + i_10000
    if A <= sum_i <= B:
        score += i
print(score)


Measured memory_bytes: 3060
#!/usr/bin/env python

n = int(input())
a = list(map(int, input().split()))

s = []
tmp = 1 
for i in range(n-1):
    if a[i] == a[i+1]:
        tmp += 1
        if i == n-2:
            s.append(tmp)
    else:
        if tmp != 1:
            s.append(tmp)
        tmp = 1 

ans = 0 
for i in s:
    ans += i//2

print(ans)


Measured memory_bytes: 9188
#include <bits/stdc++.h>
#define int long long
#define gcd            __gcd
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x,y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int power(int x, int y, int p)
{
    int res = 1;
    x = x % p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
int modi(int a, int m)
{
    return power(a, m - 2, m);
}
int32_t main()
{
    nitin;
    vector<int>v(7);
    for(int i=0;i<7;i++){
        cin>>v[i];
    }
    int t=v[1];
    int x=v[3];
    int y=v[4];
    int z=v[0];
    int op2=0;
    int op1=(z/2)*4+t*2+(x/2)*4+(y/2)*4+6*(z%2 && y%2 && x%2);
    x--;
    y--;
    z--;
    if(x>=0 && y>=0 && z>=0)
    {
        op2=(6+(z/2)*4+t*2+(x/2)*4+(y/2)*4);
    }
    cout<<max(op1,op2)/2<<endl;
    return 0;
}

Measured memory_bytes: 3660
/*
 ID: bradyawn
 PROG: contest
 LANG: C++11
 */

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <fstream>
#include <vector>
#include <deque>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <utility>
#include <set>
#include <unordered_set>
#include <ctime>
#include <queue>
#include <stack>
#include <bitset>
#include <random>
#include <cstring>
#include <complex>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int,int> i2;
typedef pair<ll,ll> ll2;

const ll mod = 1e9+7;

int cntA[100001]; //A's  prefix
int cntC[100001]; //C's  prefix
int cntQ[100001]; //?'s  prefix
ll  pow3[100001]; //3 ^ i modded

int getA(int a, int b)
{
    if (a > b) return 0;
    return cntA[b]-cntA[a-1];
}

int getC(int a, int b)
{
    if (a > b) return 0;
    return cntC[b]-cntC[a-1];
}

int getQ(int a, int b)
{
    if (a > b) return 0;
    return cntQ[b]-cntQ[a-1];
}

ll exp3(int cur)
{
    if (cur < 0) cur = 0;
    return pow3[cur];
}

int n;
string s;

int main()
{
    //ifstream inf("");
    //ofstream outf("");
    //cout << setprecision(10);
    ios::sync_with_stdio(0); cin.tie(0);
    
    cin >> s;
    n = s.size();
    s = 'S'+s;

    pow3[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        cntA[i] = cntA[i-1] + (s[i] == 'A');
        cntC[i] = cntC[i-1] + (s[i] == 'C');
        cntQ[i] = cntQ[i-1] + (s[i] == '?');
        pow3[i] = pow3[i-1]*3%mod;
    }
    
    ll ret = 0;
    
    for (int i = 1; i <= n; i++)
    {
        if (s[i] != 'B' && s[i] != '?') continue;
        
        ll A = getA(1, i);
        ll C = getC(i+1, n);
        ll prevQ = getQ(1, i-1); //flag
        ll nxtQ = getQ(i+1, n); //flag
        
        //sum of a's across all possible
        ll x = A*exp3(prevQ) + prevQ*exp3(prevQ-1);
        
        //sum of c's across all possible
        ll y = C*exp3(nxtQ) + nxtQ*exp3(nxtQ-1);
        
        ret += (x%mod) * (y%mod) % mod;
        ret %= mod;
    }
    
    cout << ret << '\n';
    
    return 0;
    
}




Measured memory_bytes: 2284