akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = (n-1); i >= 0; i--)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
const ll INF = 1LL<<62;
const int IINF = 1000000000;
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>>;

typedef pair<int, int> P;

int main(){
    string S; cin >> S;
    
    vector<int> counter(26,0);
    if (S.size() < 26){
        rep(i,S.size()){
            counter[S[i]-'a']++;
        }

        char ans = 0;
        rep(i,26){
            if (counter[i] == 0){
                ans = 'a' + i;
                break;
            }
        }
        cout << S + ans << endl;
    }
    else{
        string t = S;
        sort(t.rbegin(), t.rend());

        // 辞書順で最後であった場合
        // zyx....cbaの場合
        if (S == t){
            cout << -1 << endl;
            return 0;
        }

        t = S;
        next_permutation(t.begin(), t.end());

        string ans = "";
        rep(i,S.size()){
            ans += t[i];
            if (t[i] > S[i]){
                break;
            }
        }
        cout << ans << endl;
    }
}

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

int n, a[209]; vector<int>X;

bool isperm() {
	for (int i = 0; i < n; i++) { if (a[i] != i) return false; }
	return true;
}
void shuffle(int p) {
	for (int i = p; i < n; i++) swap(a[i], a[i - p]);
}
bool perm(int p, int q) {
	if (q >= 1 && p < q) return true;
	if (q == 0 && p > q) return true;
	return false;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i];
	while (true) {
		if (isperm() == true) break;
		if (perm(a[n - 1], a[0]) == false) { X.push_back(n - 1); shuffle(n - 1); }
		else { X.push_back(1); shuffle(1); }
	}
	cout << X.size() << endl;
	for (int i = 0; i < X.size(); i++)cout << X[i] << endl;
	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
  int p = 700;
  if(s[0] == 'o') p+=100;
  if(s[1] == 'o') p+=100;
  if(s[2] == 'o') p+=100;
  cout << p << endl;
  return 0;
}

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

typedef long long lli;

/*
                 v
  1,2,Fizz,..,x,x+1,...
 */
lli getIndex(lli x) {
  lli idx = 0;
  for (lli t = 1, k = 1; ; t *= 10, ++k) {
    lli begin = t;
    lli end = min(x + 1, t * 10);
    lli c = (end - 1) / 3 - (begin - 1) / 3;
    lli d = (end - 1) / 5 - (begin - 1) / 5;
    lli e = (end - 1) / 15 - (begin - 1) / 15;
    lli num = (end - begin) - (c + d - e);
    idx += k * num + 4 * (c + d);
    if (end == x + 1) break;
  }
  return idx;
}

int main() {
  for(lli s; cin >> s; ) {
    lli l = 0, r = 1000000000000000000LL;
    while (l - r) {
      lli x = (l + r) / 2;
      lli idx = getIndex(x);
      if (idx < s) {
        l = x + 1;
      } else {
        r = x;
      }
    }
    lli x = l - 1;
    lli idx = getIndex(x);
    ++x;
    string res;
    while (res.size() < 100) {
      if (x % 15 == 0) {
        res += "FizzBuzz";
      } else if (x % 3 == 0) {
        res += "Fizz";
      } else if (x % 5 == 0) {
        res += "Buzz";
      } else {
        stringstream ss;
        ss << x;
        res += ss.str();
      }
      ++x;
    }
    cout << res.substr(s - idx - 1, 20) << endl;
  }
  return 0;
}

Measured memory_bytes: 1220
#include<iostream>
#include<array>
#include<numeric>

using namespace std;

// 二つの列車がすれ違う時刻
// v1 * t = 全長 - v2 * t
// (v1 + v2) * t = 全長
// t = 全長/ (v1 + v2)

// 二つの列車がすれ違う場所
// x = v1 * t

int main() {

	while (true) {
		array<int, 10> l;
		int v1, v2;
		for (int& a : l) {
			cin >> a;
			cin.ignore();
		}
		cin >> v1;
		cin.ignore();
		cin >> v2;
		if (cin.eof()) {
			break;
		}
		double t = static_cast<double>(accumulate(l.begin(), l.end(), 0)) / (v1 + v2);
		double x = v1 * t;
		
		// 誤差により全長をオーバーする場合を考えて10に初期化
		int result = 10;
		int sum = 0;
		for (int i = 0; i < 10; ++i) {
			sum += l[i];
			if (x <= sum) {
				result = i + 1;
				break;
			}
		}
		cout << result << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
int main(){
    
    string s;
    cin>>s;
    int ans=11111111;
    for(int i=0;i<s.size()-2;i++){
        ans=min(ans,abs(753-stoi(s.substr(i,3))));
    }
    cout<<ans<<endl;
    
    

}





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

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

    int num = 0;

    for(int i = 0; i < S.size(); i++) {
        if( S.at(i) == '+') {
            num++;
        } else if (S.at(i) == '-') {
            num--;
        }
    }

    cout << num << endl;

    return 0;
}


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

int main() {
  int a;
int N, K;
  double ans, all;
  ans = 0;
  cin >> N >> K;
  rep(i, N){
    a = i+1;
    all = 1;
  rep(j, 10000000){

    if(a >= K){
    ans += all/(double)N;
      break;
    }
        a *= 2;
    all /=2;
  }
  }
  printf("%.20lf\n", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
using ll = long long;
const ll INF = 1e9 + 7;

void mii(ll &a, ll b) { 
	if (a > b) { 
		a = b; 
		return; 
	} 
	return; 
}

int main() {
	int n, k; cin >> n >> k;
	vector<ll> h(n); rep(i, 0, n) cin >> h[i];

	vector<ll> dp(n, INF);
	dp[0] = 0;
	rep(i, 0, n) {
		rep(j, 1, k + 1) {
			mii(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <bitset>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define fin(ans) cout<<(ans)<<endl
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
#define mp(p,q) make_pair(p,q)
#define pb(n) push_back(n)
#define Sort(a) sort(a.begin(),a.end())
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;}
const int INF = INT_MAX;
const long long LLINF = 1LL<<60;
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int n,d;
    cin>>n>>d;
    vvi v(n,vi (d));
    rep(i,n)rep(j,d)cin>>v[i][j];
    int ans=0;
    double tmp;
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            tmp=0;
            for(int k=0;k<d;k++){
                tmp+=(v[i][k]-v[j][k])*(v[i][k]-v[j][k]);
            }
            tmp=sqrt(tmp);
            if(ceil(tmp)==floor(tmp))ans++;
        }
    }
    fin(ans);
    
//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		String strLine ="";
		BufferedReader stdReader =
				new BufferedReader(new InputStreamReader(System.in));

		int MAX_DETASET  = 20;
		int cnt = 0;

		ArrayList<String> list = new ArrayList<String>();



		if((strLine = stdReader.readLine()) != null) {

		//??°????????????
		long intStrLine = Integer.parseInt(strLine);
		long k = intStrLine;

		for(long i = intStrLine -1; i > 0 ; i--){
			k = k * i;
		}

		System.out.println(k);


		}

	}

}

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

int main(){
  int a,b;
  
  cin>>a>>b;
  
  if(a%2==0||b%2==0){
    cout<<"Even"<<endl;
  }else{
    cout<<"Odd"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
int64_t H;
cin >> H ;
int64_t ttl=0;
int cnt=0;
while (H>0)
{
  H/=2;
  cnt++;
  ttl += pow(2, cnt-1);
}
cout << ttl << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;
const ll INF=1e15;
void input(ll *a,ll n){
    for(ll i=0;i<n;i++)
        cin>>a[i];
}
ll lcm(ll a,ll b)
{
    return (a*b)/__gcd(a,b);
}
bool isprime(ll n){
    if(n==1){
        return false;
    }
    if(n==2 || n==3){
        return true;
    }
    for(ll i=2;i<=sqrt(n);i++){
        if(n%i==0)
            return false;
    }
    return true;
}

//ll x[100001]={0};
//ll h[100001]={0};
//ll a[200001]={0};
//ll b[200001]={0};
//bool c[100001]={0};
//bool prime[100001]={0};
//ll prec[100011]={0};

void sieve(ll n,bool *a)
{
    for (ll p=2; p*p<=n; p++){
        if (!a[p]){
            for (ll i=p*p;i<=n;i+=p)
                a[i]=true;
        }
    }
}

ll fact(ll n){
    ll res=1;
    for(ll i=1;i<=n;i++)
        res*=i;
    return res;
}

ll distance(ll x1,ll y1,ll x2,ll y2){
    return (ll)ceil(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
}

void solve(){
    ll a,b,k;
    cin>>k>>a>>b;

    for(ll i=a;i<=b;i++){
        if(i%k==0){
            cout<<"OK";
            return;
        }
    }
    cout<<"NG";
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //sieve(100001,c);
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++){
        solve();
    }
}


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

int main() {
  string s;
  cin >> s;
  if(s=="AAA"||s=="BBB") {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
  return 0;
}

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

ll calc_cnt(ll a, ll num)
{
    ll cnt = 0;
    while(a%num == 0)
    {
        cnt++;
        a /= num;
    }
    return cnt;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    vector<ll> A(N);
    for(int i=0; i<N; i++)
    {
        double a;
        cin >> a;
        A[i] = a * 1000000000 + 0.5;
    }

    map<pair<ll, ll>, ll> cnt;
    for(int i=0; i<N; i++)
    {
        ll two = calc_cnt(A[i], 2);
        ll five = calc_cnt(A[i], 5);
        // cout << A[i] << ", " << two << ", " << five << endl;
        cnt[make_pair(two, five)]++;
    }

    ll ans = 0;
    for(const auto& [k, v] : cnt)
    {
        // cout << k.first << ',' << k.second << ',' << v << endl;
        for(const auto& [i, j] : cnt)
        {
            if(k.first + i.first < 18 || k.second + i.second < 18) continue;
            if(k.first == i.first && k.second == i.second) ans += v * (v-1);
            else ans += v*j;
        }
    }
    cout << ans / 2 << endl;


    return 0;
}


Measured memory_bytes: 4764
N=int(input())
A=list(map(int,input().split()))

import fractions
if N==2:
  print(max(A))
else:
  L=[0]*(N)
  R=[0]*(N)
  L[0]=A[0]
  R[N-1]=A[N-1]
  for i in range(1,N):
    L[i]=fractions.gcd(L[i-1],A[i])
  for i in range(1,N):
    R[N-1-i]=fractions.gcd(R[N-i],A[N-1-i])
  ans=0
  for i in range(1,N-1):
    x=fractions.gcd(L[i-1],R[i+1])
    ans=max(ans,x)

  print(max(ans,L[N-2],R[1]))


Measured memory_bytes: 14488
/* 
 Author:N_o_o_B 
 Created:November 24 2019 17:26:06
*/
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#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 ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    vector<string> a={"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    string s;
    cin >> s;
    int ind = find(all(a),s)-a.begin();
    cout << 7 - ind << endl;


    time_taken();
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
const long long INF = 1LL<<60;
const long long MOD = 1e9+7;
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void Yes(){cout<<"Yes"<<endl;}
void No(){cout<<"No"<<endl;}
void YN(bool b){cout<<(b?"Yes":"No")<<endl;}

int main(void){
  string inStr;
  cin >> inStr;
  map<char,int> count;
  for(char ch : inStr){
    if(count.count(ch)==0){
      count[ch] = 1;
    }
    else{
      count[ch]++;
    }
  }
  for (auto v : count){
    if (v.second!=2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}




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


int main(){
    double A,B,H,M;
    scanf("%lf %lf %lf %lf",&A,&B,&H,&M);

    double ax,ay,bx,by,pi,dis;
    pi =  atan(1.0) * 4.0;

    ax = A*sin((H/6+M/360)*pi);
    ay = sqrt(A*A-ax*ax);
    if(H>=3&&H<9)ay = -ay;
    
    bx = B*sin((M/30)*pi);
    by = sqrt(B*B-bx*bx);
    if(M>=15&&M<45)by =-by;

    dis = sqrt((ax-bx)*(ax-bx)+(ay-by)*(ay-by));

    printf("%.16f\n",dis);
    
    return 0;
}

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a + b < c) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
using System;
class Program{
	static void Main(){
		int[] s=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
		int[][] arr=new int[s[0]+1][];
		int m1=0,m2=0,ans=int.MaxValue;
		for(int i=1;i<=s[0];i++){
			arr[i]=Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
			m1+=arr[i][0];
			m2+=arr[i][1];
		}
		int[,,] dp=new int[s[0]+1,m1+1,m2+1];
		for(int i=0;i<=s[0];i++){
			for(int j=0;j<=m1;j++){
				for(int k=0;k<=m2;k++){dp[i,j,k]=9999;}
			}
			dp[i,0,0]=0;
		}
		for(int i=1;i<=s[0];i++){
			for(int j=1;j<=m1;j++){
				for(int k=1;k<=m2;k++){
					if(j>=arr[i][0]&&k>=arr[i][1]){dp[i,j,k]=Math.Min(dp[i-1,j-arr[i][0],k-arr[i][1]]+arr[i][2],dp[i-1,j,k]);}
					else{dp[i,j,k]=dp[i-1,j,k];}
				}
			}
		}
		for(int i=s[1],j=s[2];i<=m1&&j<=m2;i+=s[1],j+=s[2]){ans=Math.Min(ans,dp[s[0],i,j]);}
		ans=ans==9999?-1:ans;
		Console.WriteLine("{0}",ans);
	}
}

Measured memory_bytes: 22240
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,x,i,j;
    cin>>n>>x;
    int ara[n+1];
    ara[0]=x;
    for(i=1;i<=n;i++)
        cin>>ara[i];
    sort(ara,ara+n+1);
    int bra[n];
    for(i=1;i<=n;i++)
    {
        bra[i-1]=ara[i]-ara[i-1];
    }
    sort(bra,bra+n);
    for(i=bra[0];i>=1;i--)
    {
        int p=1;
        for(j=0;j<n;j++)
        {
            if(bra[j]%i !=0)
            {
                p=0;
                break;
            }
        }
        if(p==1)
        {
            cout<<i<<endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 4336
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <iomanip>
#include <vector>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <ctime>
#include <fstream>
#include <stdarg.h>
using namespace std;
const bool debug=false;
const bool INJUDGE=false;
#define FASTERCIN cin.tie(0);ios_base::sync_with_stdio(false)
typedef long long ll;
/*Time:
Status:
Type:
Author:*/
int dp[105][105][305];
int n,ww;
int w[105],v[105],ans;
int main(){
	cin>>n>>ww;
	for(int i=0;i<n;++i)cin>>w[i]>>v[i];
	for(int i=0;i<n;++i){
		for(int j=0;j<=i;++j){
			for(int h=0;h<=j*3;++h){
				dp[i+1][j][h]=max(dp[i+1][j][h],dp[i][j][h]);
				dp[i+1][j+1][h+w[i]-w[0]]=max(dp[i][j][h]+v[i],dp[i+1][j+1][h+w[i]-w[0]]);
			}
		}
	}
	for(int i=0;i<=n;++i){
		for(int j=0;j<=i*3;++j){
			ll cur=ll(w[0])*i+ll(j);
			if(cur<=ll(ww)){
				ans=max(ans,dp[n][i][j]);
			}
		}
	}
	cout<<ans<<endl;
	return 0;
};

Measured memory_bytes: 11008
l=[int(input()) for i in range(5)]
flag=False
k=int(input())
for i in range(len(l)):
    for j in range(i+1,len(l)):
        if(l[j]-l[i]<=k):
            flag=True
        else:
            flag=False
            break
    if(not flag):
        break
if(not flag):
    print(":(")
else:
    print('Yay!')

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

int main() {
  map<char, int> count_char;
  string word;
  cin >> word;
  for (auto charctor : word) {
    count_char[charctor]++;
  }
  bool is_beautiful = true;
  for (auto itr : count_char) {
    if (itr.second % 2 != 0) {
      is_beautiful = false;
    }
  }
  cout << (is_beautiful ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int w = Integer.parseInt(in.next());
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int ans = 0;

            if (a <= b && b <= (a + w)) {
                ans = 0;
            } else if ((a + w) < b) {
                ans = b - (a + w);
            } else {
                ans = a - (b + w);
            }
            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21716
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1000000009LL;
constexpr long long LINF = 1000100010001000100LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
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; }

const int MAX = 2100000;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

int main() { 
    COMinit();
    ll n, k; cin >> n >> k;

    ll res = 0;
    rep(i, min(k+1, n)){
         ll num = n - i;
        ll zero = COM(n, i);
        ll other = COM(n-1, i);
        //cout << "zero:" << zero << " other:" << other;
        res = (res + zero * other % MOD)% MOD;
    }
        //cout << " res:" << res << ln;
    cout << res << ln;
}

Measured memory_bytes: 49408
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;
 
#define pi 3.1415926535

int main()
{
  ll n;
  cin >> n;

  ll tmp1 = 0;
  cin >> tmp1;

  ll ans = 0, tmp2 = 0;
  for(int i = 1; i < n; i++){
    cin >> tmp2;
    if(tmp1 > tmp2){
      ans += tmp1 - tmp2;
    }
    else{
      tmp1 = tmp2;
    }
  }

  cout << ans << endl;
  return 0; 
}

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

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

    int M=1;
    int cnt=0;
    for(int i=0; i<N; i++) {
        if(pow(2, cnt) <= K) {
            M = 2 * M;
            cnt++;
        }
        else
        {
            M += K; 
        }
    }

    cout << M << endl;

}

Measured memory_bytes: 256
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"bits/stdc++.h"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

int32_t main()
{
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif
	IOS;

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

	string ans = "IMPOSSIBLE";

	if((b-a) % 2 == 0)
		ans = to_string((a+b)/2);
	cout << ans;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}

template<class T1, class T2> void chmin(T1 &a, T2 b) { if (a>b)a = b; }

template<class T1, class T2> void chmax(T1 &a, T2 b) { if (a<b)a = b; }
template<class T>
void Add(T &a, const T &b, const T &mod = 1000000007) {
	int val = ((a % mod) + (b % mod)) % mod;
	if (val < 0) { val += mod; }
	a = val;
}
////////////////////////////////////////

ll Gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return Gcd(y, x%y);
}
ll lcm(ll a, ll b) {
	ll g = Gcd(a, b);
	return a / g * b;
}
int main() {
	ll A, B; cin >>  A >> B;
	cout << lcm(A, B) << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())

h = [int(input()) for i in range(n)]
h.sort()

cand = [0]*(n-k+1)
cand[0] = h[k-1] - h[0]


for j in range(1,n-k+1):
    cand[j] = h[k+j-1] - h[j]

print(min(cand))

Measured memory_bytes: 11036
#include <iostream>

const int MAX_N = 21;

int f[2][1 << 21], a[MAX_N][MAX_N];
const int MOD = 1e9 + 7;

inline int add(int x, int v) { return x + v >= MOD ? x + v - MOD : x + v; }

int main() {
  int n;
  std::cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) std::cin >> a[i][j];
  const int max = 1 << n;
  f[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (a[i - 1][j]) {
        for (int s = 0; s < max; ++s) {
          if (s >> j & 1) {
            f[i & 1][s] = add(f[i & 1][s], f[(i - 1) & 1][s & ~(1 << j)]);
          }
        }
      }
    }
  }
  std::cout << f[n & 1][max - 1];
  return 0;
}

Measured memory_bytes: 16640
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():
    A = list(map(int,input().split()))
    for i in range(5):
        if A[i] == 0:
            ans = i + 1
            break
    print(ans)    
if __name__ == '__main__':
    main()

Measured memory_bytes: 9180
A=int(raw_input())
B=int(raw_input())
C=int(raw_input())
X=int(raw_input())
r=0
for a in range(A+1):
	for b in range(B+1):
		for c in range(C+1):
			if 500*a+100*b+50*c==X:
				r+=1
print r

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;

const int N = 1e3 + 10;
const int MOD = 1e9 + 7;

int n, m;
int a[N], b[N];
bool flag = false;
bool check[2][N * N];
vector<int> vta, vtb;

void add(int &x, int y) { x = (x + y) % MOD; }
void mul(int &x, int y) { x = x % MOD * (y % MOD) % MOD;}

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);

    cin >> n >> m;

    FOR(i, 1, n)    {
        cin >> a[i];
        if(check[0][a[i]]) flag = 1;
        check[0][a[i]] = 1;
    }
    FOR(i, 1, m)    {
        cin >> b[i];
        if(check[1][b[i]]) flag = 1;
        check[1][b[i]] = 1;
    }

    if(flag) return cout << "0", 0;

    int cnta = 0, cntb = 0, ans = 1;
    for(int i = n*m; i >= 1; --i)   {
        int cur = 0;
        if(check[0][i] && check[1][i]) cur = 1, cnta ++, cntb ++;
        else if(check[0][i])    {
            cur = cntb; cnta ++;
        } else if(check[1][i]) {
            cur = cnta; cntb ++;
        } else cur = cnta * cntb - (n * m - i);
        mul(ans, cur);
    }
    cout << ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*, const char*>> anys;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
#ifdef DEBUG
#define debug(...) pr(anys{__VA_ARGS__})
#define debugv(x) pr((x))
#else
#define debug(...)
#define debugv(x)
#endif

int main(){
	int N, M;
	cin >> N >> M;
	vector<int> A(M);
	for(int i=0; i<M; i++) cin >> A[i];

	ll sum = 0;
	for(int i=0; i<M; i++) sum += A[i];

	if(N >= sum){
		cout << N - sum << endl;
	} else {
		cout << -1 << endl;
	}


	return 0;
}


Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if (b - a == c - b) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

	}

}

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

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



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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

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

  int ans=0;
  vector<int> p;
  int num;

  if(a>k) ans+=k;
  else{
    ans+=a;
    k-=a;
    if(b<k){
      k-=b;
      if(c>k) ans-=k;
      else ans-=c;
    }
  }

  cout << ans << endl;
  

}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  char X,Y;cin >> X >> Y;
  if(X==Y)cout << '=' << endl;
  else if(X<Y) cout << '<' << endl;
  else cout << '>' << endl;
  return 0;
}


Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

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

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

type queue struct {
	x, y int
}

const inf = 100000

func bfs(sx, sy, H, W int, s []string) ([][]int, int) {
	if s[sy][sx] == '#' {
		return nil, 0
	}

	dist := make([][]int, H)
	for y := 0; y < H; y++ {
		dist[y] = make([]int, W)
		for x := 0; x < W; x++ {
			dist[y][x] = -1
		}
	}

	q := make([]queue, 0)
	q = append(q, queue{sx, sy})

	dx := []int{0, -1, 1, 0}
	dy := []int{-1, 0, 0, 1}

	ma := -1
	dist[sy][sx] = 0
	for len(q) != 0 {
		p := q[0]
		q = q[1:]
		for i := 0; i < 4; i++ {
			xx := p.x + dx[i]
			yy := p.y + dy[i]
			if xx < 0 || yy < 0 || xx >= W || yy >= H {
				continue
			}
			if s[yy][xx] == '.' && dist[yy][xx] == -1 {
				dist[yy][xx] = dist[p.y][p.x] + 1
				ma = max(ma, dist[yy][xx])
				q = append(q, queue{xx, yy})
			}
		}
	}
	return dist, ma
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W := getInt(), getInt()
	s := make([]string, H)
	for i := 0; i < H; i++ {
		s[i] = getString()
	}

	ans := 0
	for y := 0; y < H; y++ {
		for x := 0; x < W; x++ {
			_, ma := bfs(x, y, H, W, s)
			ans = max(ans, ma)
		}
	}
	out(ans)

}


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


int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
struct state{
  int d[5][5];
  void cpy(const state& s){
    for(int i=0;i<4;i++)
      for(int j=0;j<4;j++)
	d[i][j] = s.d[i][j];
  }
  

  void sim(){
    
    bool f = false;

    bool fl[5][5][4] = {};
    
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	if( d[i][j] > 4 ){
	  d[i][j] = 0;
	  f = true;
	  for(int k=0;k<4;k++)
	    fl[i][j][k] = 1;
	}
      }
    }


    do{
      f = false;
      bool nf[5][5][4] = {};
    
      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  for(int k=0;k<4;k++){
	
	    if( fl[i][j][k] == 1 ){
	      f = true;
	      if( d[i][j] > 0 ){
		d[i][j]++;
		fl[i][j][k] = 0;
	      } else {
		fl[i][j][k] = 0;  
		if( i + dx[k] >= 4 || j + dy[k] >= 4 ||
		    i + dx[k] < 0 || j + dy[k] < 0 ) continue;
		nf[i+dx[k]][j+dy[k]][k] = 1;		
	      }
	    }
	  }
	}
      }

      for(int i=0;i<4;i++)
	for(int j=0;j<4;j++)
	  for(int k=0;k<4;k++)
	    fl[i][j][k] = nf[i][j][k];


      for(int i=0;i<4;i++){
	for(int j=0;j<4;j++){
	  if( d[i][j] > 4 ){
	    d[i][j] = 0;
	    f = true;
	    for(int k=0;k<4;k++)
	      fl[i][j][k] = 1;
	  }
	}
      }

    }while(f);


  }

  bool check(){
    for(int i=0;i<4;i++)
      for(int j=0;j<4;j++)
	if( d[i][j] > 0 ) return false;
    return true;
  }

  void view(){
    cout << "view" << endl;
    for(int i=0;i<4;i++){
      for(int j=0;j<4;j++){
	cout << d[j][i];
      }
      cout << endl;
    }
  }

};

int res = 10;
int solve(state &s,int c){
  // s.view();
  if( s.check() ) return c;
  if( c == 5 || c > res ) {
    return -1;
  }
  for(int i=0;i<4;i++){
    for(int j=0;j<4;j++){
      state nex; nex.cpy( s );
      nex.d[i][j]++;
      nex.sim();
      int ret = solve( nex, c + 1 );
      if( ret > -1 ) res = min( res, ret );
    }
  }
  return res;
}


int main(){
  state s;
  for(int i=0;i<4;i++)
    for(int j=0;j<4;j++)
      cin >> s.d[j][i];
  int res = solve(s,0);
  if( res > 5 ) cout << -1 << endl;
  else cout << res << endl;
}

Measured memory_bytes: 1164
import java.io.*;

public class Main{
    public static void main(String[] args){
        int n = 0;
        String line;
        int i = 0;
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        try {
            line = reader.readLine();
            n = Integer.parseInt(line);
            int[] number;
            number = new int[100];
            line = reader.readLine();
            String[] data = line.split(" ",n);
            for(i = n-1; i >= 0; i--){
                if(i == 0){
                    System.out.println(data[i]);
                    break;
                }
                System.out.print(data[i] + " ");
            }

            
        } catch (NumberFormatException e) {
            System.out.println(e);
        } catch (IOException e) {
            System.out.println(e);
        }
    }
}


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

const int empty = 2147483647;

struct BigSegmentTree {
  typedef int T;
  T value;
  int lpos, rpos;
  BigSegmentTree *lch, *rch;
  
  BigSegmentTree(int n) :
    lpos(0), rpos(n), value(empty), lch(nullptr), rch(nullptr) {
    n = 1;
    while (n < rpos) { n *= 2; }
    rpos = n;
  }
  BigSegmentTree(int l, int r) :
    lpos(l), rpos(r), value(empty), lch(nullptr), rch(nullptr) {;}

  T merge(T x, T y) {
    return (x < y ? x : y);
  }

  void update(int pos, T a) {
    if (rpos - lpos <= 1) { 
      value = a; 
      return;
    }
    int mid = (lpos + rpos) / 2;
    if (pos < mid) {
      if (!lch) lch = new BigSegmentTree(lpos, mid);
      lch->update(pos, a);
    } else {
      if (!rch) rch = new BigSegmentTree(mid, rpos);
      rch->update(pos, a);
    }
    T lv = lch ? lch->value:empty, rv = rch ? rch->value:empty;
    value = merge(lv, rv);
  }

  // merge([a, b))
  T query(int a, int b) {
//    printf("[%d,%d), [%d,%d)\n", a,b, lpos, rpos);
    if (rpos <= a || b <= lpos) {
      return empty;
    } else if (a <= lpos && rpos <= b) {
      return value;
    } else {
      T vl = lch ? lch->query(a, b) : empty;
      T vr = rch ? rch->query(a, b) : empty;
      return merge(vl, vr);
    }
  }
};

int main() {
  int n, q;
  cin >> n >> q;
  BigSegmentTree seg(n);

  for (int i = 0; i < q; i++) {
    int com, x, y;
    cin >> com >> x >> y;
    if (com == 0) {
      seg.update(x, y);
    } else {
      cout << seg.query(x, y + 1) << endl;
    }
  }
}

Measured memory_bytes: 6696
#include <bits/stdc++.h>
//#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(v) sort(v.begin(),v.end())
#define ERASE(v) v.erase(unique(v.begin(),v.end()),v.end())
#define POSL(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define POSU(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////



int main(){fastio
    ll a,b;cin>>a>>b;
    rep(i,1,3){
        if(i==a)continue;
        if(i==b)continue;
        cout<<i<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
h,w = map(int,input().split())
c = [0] * h
ans = [0] * (h * 2)
for i in range(h):
    c[i] = list(input().split())
    ans[i*2] = c[i]

for i in range(h * 2):
    if i % 2 == 1:
        ans[i] = c[int(i/2)][:]

for i in range(len(ans)):
    temp = "".join(ans[i])
    print(temp)


Measured memory_bytes: 3060
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int dp[11][101010];
int n, m, q;
vector<int> G[101010];
int c[101010], v, d;

int main() {
	for (int i = 0; i <= 10; i++)for (int j = 0; j < 101010; j++) {
		dp[i][j] = -1;
	}
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		G[x].emplace_back(y);
		G[y].emplace_back(x);
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> v >> d >> c[i];
		v--;
		dp[d][v] = i;
	}
	for (int i = 10; i > 0; i--) {
		for (int j = 0; j < n; j++) {
			if (dp[i][j] != -1) {
				dp[i - 1][j] = max(dp[i - 1][j], dp[i][j]);
				for (int k = 0; k < G[j].size(); k++) {
					dp[i - 1][G[j][k]] = max(dp[i - 1][G[j][k]], dp[i][j]);
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		cout << (dp[0][i] == -1 ? 0 : c[dp[0][i]]) << endl;
	}
	//system("pause");
}

Measured memory_bytes: 11256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner keyboard = new Scanner(System.in);
		
		int[] A = new int[10];
        for(int i=1; i<10; i++) {
			A[i] = keyboard.nextInt();
		}

		int N = keyboard.nextInt();
		int[] B = new int[N+1];
		
		for(int j=1; j<N+1; j++) {
			B[j] = keyboard.nextInt();
		}
		
		int[] A2 = new int[10];
		for(int a=1; a<10; a++) {
			for(int b=1; b<N+1; b++) {
			    if(A[a]==B[b]) { 
                    A2[a] =1; }
		    }
		}
		
		String ans = "No";
		if (A2[1]==1 && A2[2]==1 && A2[3]==1 ) {
		    ans = "Yes";
	    }else if (A2[4]==1 && A2[5]==1 && A2[6]==1 ) {
		    ans = "Yes";
		}else if (A2[7]==1 && A2[8]==1 && A2[9]==1 ) {
		    ans = "Yes";
		}else if (A2[1]==1 && A2[4]==1 && A2[7]==1 ) {
		    ans = "Yes";
		}else if (A2[2]==1 && A2[5]==1 && A2[8]==1 ) {
		    ans = "Yes";
		}else if (A2[3]==1 && A2[6]==1 && A2[9]==1 ) {
		    ans = "Yes";
		}else if (A2[1]==1 && A2[5]==1 && A2[9]==1 ) {
		    ans = "Yes";
		}else if (A2[3]==1 && A2[5]==1 && A2[7]==1 ) {
		    ans = "Yes";
		}
		
		System.out.println(ans);
		keyboard.close();
	}
}


Measured memory_bytes: 35728
#include <bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;++i)
#define fod(i,a,b) for(int i=a;i>=b;--i)
#define N 5005
using namespace std;
int st[N],ans[N];
bool query(int x,int y)
{
	cout<<"? "<<x<<" "<<y<<endl;
	char ch[5];
    scanf("%s",ch+1);
    return (ch[1]=='Y');
}
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	if(a<=b) cout<<"Impossible"<<endl;
	else
	{
		int top=0;
		fo(i,0,a+b-1)
		{
			if(!top) st[++top]=i;
			else 
			{	
				if(!query(st[top],i)) st[top--]=0;
				else st[++top]=i;
			}
		}
		fo(i,0,a+b-1) ans[i]=query(st[top],i);
		cout<<"! ";
		fo(i,0,a+b-1) cout<<ans[i];
		cout<<endl;
	}
	return 0;	
}

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

int main()
{
	long long a,neg=0,sum=0,min=0;
	cin >> a;
	long long arr[a+10];
	for(long long i=1;i<=a;i++)
	{
		cin >> arr[i];
		if(arr[i]<0)
		{
			neg++;
		}
	}
	if(neg%2==0)
	{
		for(long long i=1;i<=a;i++)
		{
			if(arr[i]<0)
			{
				arr[i]=arr[i]*-1;
			}
		}
		for(long long i=1;i<=a;i++)
		{
			sum+=arr[i];
		}
	}
	else if(neg%2==1)
	{
		min = 9999999999;
		for(long long i=1;i<=a;i++)
		{
			if(arr[i]<0)
			{
				arr[i]=arr[i]*-1;
			}
		}
		
		for(long long i=1;i<=a;i++)
		{
			if(arr[i]<=min)
			{
				min=arr[i];
			}
		}
		
		for(long long i=1;i<=a;i++)
		{
			sum+=arr[i];
		}
		sum=sum-2*min;
	}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c;
           cin>>a>>b>>c;
           map<int,int> cnt;
           cnt[a]++;cnt[b]++;cnt[c]++;
           cout<<cnt.size()<<endl;
}

Measured memory_bytes: 3592
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val H, W = sc.nextInt()
  val alphabet = 'A'.to('Z')
  val squares = Array.fill(H)(Array.fill(W)(sc.next()))
  for (i <- 0.until(H); j <- 0.until(W)) {
    if (squares(i)(j) == "snuke") println(alphabet(j).toString + (i + 1))
  }
}


Measured memory_bytes: 56556
h, w, d = map(int, input().split())

cols = [[0]*w for i in range(h)]
if d % 2 == 1:
    for i in range(h):
        for j in range(w):
            cols[i][j] = "RY"[(i+j)%2]
else:
    arr = [[0]*(4*d) for i in range(4*d)]
    for i in range(d):
        for j in range(d):
            arr[i+d][j] = arr[i][j+d] = 2
    for i in range(d):
        for j in range(d):
            if abs(i) + abs(j) <= d//2-2:
                arr[i][j] = arr[i+d][j+d] = 1
                arr[i+d][j] = arr[i][j+d] = 3
            if abs(d-1-j) + abs(d-1-i) <= d//2-1:
                arr[i][j] = arr[i+d][j+d] = 1
                arr[i+d][j] = arr[i][j+d] = 3
            if abs(d-1-j) + abs(i) <= d//2-2:
                arr[i][j] = arr[i+d][j+d] = 3
                arr[i+d][j] = arr[i][j+d] = 1
            if abs(j) + abs(d-1-i) <= d//2-1:
                arr[i][j] = arr[i+d][j+d] = 3
                arr[i+d][j] = arr[i][j+d] = 1
    for i in range(h):
        for j in range(w):
            cols[i][j] = "RGBY"[int(arr[i%(2*d)][j%(2*d)])]
print("\n".join("".join(e) for e in cols))



Measured memory_bytes: 172424
#include<queue>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#define ll long long
#define inf 1000000000LL
#define mod 1000000007
using namespace std;
int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}
int vis[105];
int main()
{
    int a=read(),c=read(),b=read();
    int ans=a%c,tmp,x=1,st=b%c,flag=0;
    while(true){
        tmp=(ans*x)%c;
        x++;
        if(st==tmp){
            flag=1;break;
        }
        if(vis[tmp]) break;
        vis[tmp]++;
    }
    if(flag) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;

int main(){
    int ans = 0;
    REP(i, 3){
        char s;
        cin >> s;
        if(s == '1') ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int x[N] ;
  
  int sum=0;
  
  for(int i=0;i<N;i++){
    cin >> x[i];
    if(x[i] <= K/2 ){
      sum += 2*x[i];
    }else{
      sum += 2*(K-x[i]);
    }
  }
  
  cout << sum << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main (void)
{
	int N, H[100];
	int sum = 1;
	int i, j;
	
	scanf("%d",&N);
	
	for(i = 0; i < N; i++){
		scanf("%d",&H[i]);
	}
	
	for(i = 1; i < N; i++){
		for(j = 0; j <= i-1; j++){
			if(H[i] < H[j]){
				break;
			}
			if(j == i-1){
				sum += 1;
			}
		}
	}
	
	printf("%d\n",sum);
	
	return 0;
}

Measured memory_bytes: 128