akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
//typedef pair<int, int> pii;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

#define ma 100010

vector<VI> to(ma);
vector<pair<int, int> >ans, in;
VI cost;
int N;
VI out(ma);
VI si(ma);


void bfs() {
	queue<int> Q;
	int co = 0;
	Q.push(0);
	int cnt = 0;
	while (!Q.empty()) {
		//cout << "K" << endl;
		//cout << cnt << endl;
		if (out[Q.front()] == LLINF) {
			out[Q.front()] = cost[co];
			cnt++;
			co++;
		}
		if (cnt == N)return;
		
		int i = 0;
		while (i < to[Q.front()].size()) {
			if(out[to[Q.front()][i]]==LLINF)Q.push(to[Q.front()][i]);
			i++;
		}
		Q.pop();
	}
}




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

	cin >> N;
	REP(i, N) {
		out[i] = LLINF;
	}
	REP(i, N-1) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		to[a].push_back(b);
		to[b].push_back(a);
		in.push_back(make_pair(a, b));
	}

	REP(i, N) {
		int a;
		cin >> a;
		cost.push_back(a);
	}
	rSORT(cost);
	
	REP(i, N) {
		si[i] = to[i].size();
	}

	REP(i, N) {
		int a = si[i], b = i;
		ans.push_back(make_pair(a, b));
	}
	rSORT(ans);
	REP(i, N) {
		//cout << ans[i].first<<" "<<ans[i].second << endl;
	}
	//cout << endl;

	REP(i, N) {
		//out[ans[i].second] = cost[i];
	}

	bfs();

	int sum = 0;
	REP(i, N - 1) {
		sum += min(out[in[i].first], out[in[i].second]);
	}

	cout << sum << endl;
	FOR(i,0, N-1) {
		//cout << to[i][0] << endl;
		cout << out[i] <<" ";
	}
	cout << out[N - 1] << endl;
	return 0;
}



Measured memory_bytes: 5248
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD = 1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

signed main(){
	string s,t;
	int cs[2][100001] = {},ct[2][100001] = {};
	int q;
	cin >> s >> t >> q;
	for(int i = 0;i < s.length();i++){
		cs[0][i + 1] = cs[0][i];
		cs[1][i + 1] = cs[1][i];
		cs[s[i] - 'A'][i + 1]++;
	}
	for(int i = 0;i < t.length();i++){
		ct[0][i + 1] = ct[0][i];
		ct[1][i + 1] = ct[1][i];
		ct[t[i] - 'A'][i + 1]++;
	}
	for(int i = 0;i < q;i++){
		int a,b,c,d;
		cin >> a >> b >> c >> d;
		int sc = (cs[0][b] - cs[0][a - 1]) - (cs[1][b] - cs[1][a - 1]);
		int tc = (ct[0][d] - ct[0][c - 1]) - (ct[1][d] - ct[1][c - 1]);
		if((sc + 300000) % 3 == (tc + 300000) % 3) YES();
		else NO();
	}
	return 0;
}

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

int main() {

	ll r, d, x; cin >> r >> d >> x;
	ll prev = x;
	for (ll i = 0; i < 10; i++) {
		ll now = r * prev - d;
		cout << now << endl;
		prev = now;
	}
	return 0;
}

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

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

  if( ((a == b) && (a != c)) ||
      ((a == c) && (a != b)) ||
      ((b == c) && (a != c)) )
      cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}

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

int main()
{
	int N, st = 0;
	bool res = true;
	string S;
	cin >> N;
	while (N--) {
		cin >> S;
		if (S == "A") {
			st++;
		}
		else {
			st--;
		}
		if (st < 0) {
			res = false;
		}
	}
	if (st == 0 && res) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 3156
#include <iostream>
#include <sstream>
#include <string>
#include <cmath>
#include <array>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <utility>
#include <iomanip>
#include <numeric>
#include <climits>
#include <algorithm>
#include <cstdint>
using namespace std;

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

    if (b + c >= a)
        cout << abs(a-(b+c));
    else
        cout << "0";
}

Measured memory_bytes: 3588
a,b,c,d = map(int,input().split())

i = 0
while True:
    if i%2 != 0:
        if a-d>0:
            a -= d
        else:
            print("No")
            break
    else:
        if c-b>0:
            c -= b
        else:
            print("Yes")
            break
    i += 1

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

struct Node{
	string data;
	Node *next;
};

bool smaller(string a, string b){
	int x = a.length();
	for(int i = 0; i < x; i++){
		if(a[i] < b[i]) return true;
		if(b[i] < a[i]) return false;
	}
	return true;
}

Node* insert(Node *head, Node *curr){
	if(head == NULL){
		head = curr;
		return head;
	}
	string b = curr->data;
	Node *n = head;
	Node *prev = NULL;
	while(n != NULL){
		string a = n->data;
		if(smaller(a, b)){
			prev = n;
			n = n->next;
		}
		else{
			if(prev == NULL) head = curr;
			else prev->next = curr;
			curr->next = n;
			return head;
		}
	}
	prev->next = curr;
	return head;
}

int main() {
	int n, l;
	cin >> n >> l;
	Node *s = new Node;
	s = NULL;
	for(int i = 0; i < n; i++){
		string input;
		cin >> input;
		Node *p = new Node;
		p->data = input;
		p->next = NULL;
		s = insert(s, p);
	}
	while(s != NULL){
		cout << s->data;
		s = s->next;
	}
	cout << endl;
}

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

int const N = 100001;
int n, v[N];
map<int,int> ev, od;

int main(){
    scanf("%d", &n);
    for(int i = 1; i<=n; i++){
         scanf("%d", v+i);
         if(i & 1)++od[v[i]];
         else ++ev[v[i]];
    }
    int an = 0, mx = 0;
    vector<pair<int,int> >ev0; 
    for(int i = 1; i<=N; ++i){
        ev0.push_back({n/2-ev[i], i});
    }
    sort(all(ev0));
    reverse(all(ev0));
    vector<pair<int,int> >od0;
    for(int i = 1; i<=N; ++i){
        od0.push_back({n/2-od[i], i});
    }
    sort(all(od0));
    reverse(all(od0));
    int x = -1, y = -1;
    while(true){
        pair<int,int> ad = ev0.back();
        pair<int,int> ad1 = od0.back();
        if(ad.second != ad1.second){
            x = ad.second, y = ad1.second;
            an += ad.first;
            an += ad1.first;
            break;
        }
        else{
             // first ev, second od 
            od0.pop_back();
            int m = ad.first + od0.back().first;
            ev0.pop_back();
            //first od , second ev
            int mm = ad1.first + ev0.back().first;
            an += min(m,mm);
            break;
        } 
    }
    printf("%d\n",an);
} 


Measured memory_bytes: 11636
#include <iostream>

using namespace std;

int main()
{
    int N, Y;
    cin >> N >> Y;
    
    for(int i = 0; i <= N; ++i)
    {
        for(int j = 0; j <= N; ++j)
        {
            int k = N - i - j;
            if(k < 0) break;
            if(10000*i + 5000*j + 1000*k == Y)
            {
                cout << i << ' ' << j << ' ' << k << '\n';
                return 0;
            }
        }
    }
        
    cout << "-1 -1 -1\n";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;

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

    vector<int> t(N);   
    for (int i = 0; i < N; i++) {
        cin >> t[i];
    }
    sort(t.begin(), t.end());

    int ans = 1, cnt = 0;
    int st = t[0];    
    for (int i = 0; i < N; i++) {
        cnt++;
        if (cnt > C||t[i]-st>K) {
            ans++;
            st = t[i];
            cnt = 1;
            
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
s=str(input())
flag=0
for i in range(1,len(s)):
  s=s[:len(s)-2]
  for j in range(len(s)//2):
    if s[j]!=s[len(s)//2+j]:
      flag=1
      break
  if flag==0:
    print(len(s))
    exit()
  else:
    flag=0
    continue

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

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

using namespace std;

int main(){
	int n,c,k; scanf("%d%d%d",&n,&c,&k);
	vector<int> T(n);
	rep(i,n) scanf("%d",&T[i]);

	sort(T.begin(),T.end());

	int ans=0;
	queue<int> Q;
	rep(i,n) Q.emplace(T[i]);
	while(!Q.empty()){
		int t=Q.front()+k;
		rep(i,c){
			if(Q.empty() || t<Q.front()) break;
			Q.pop();
		}
		ans++;
	}
	printf("%d\n",ans);

	return 0;
}


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

long double dp[3000][3000];

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


    long double p[n];

    for(int i=0; i<n;i++)
    {
        cin >> p[i];
    }

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

            // cout << dp[i][j] << " ";
        }
        // cout << endl;
    }

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

    long double res = 0.0;
    
    for(int i = n; i>n/2 ; i--){
        res += dp[n][i];
    }
    cout << fixed << setprecision(10) << res << endl;
    return 0;
}

Measured memory_bytes: 139136
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a, b;
  cin >> a >> b;

  cout << max(0, a - 2 * b) << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
    ll N, M; cin >> N >> M;
    F0R(i, M) {
        ll X; cin >> X; N -= X;
    }

    if (N < 0) {
        cout << -1 << nl;
    } else cout << N << nl;
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343



Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
 
#define rep(i, a, n) for(int i=a; i<n; i++)
#define ll long long
#define all(x) begin(x), end(x)
#define toInt(x) (x - '0')
#define pll pair<ll, ll>
#define MAXN 200 + 5
const long long INF = 1LL << 60;
const int inf = 1 << 30;

void printVec(std::vector<int> &vec) {
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
 
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 l;
  cin >> l;
  long double ans = 0;

  long double x = l / 3.;
  cout << fixed << setprecision(10) <<  x * x * x << endl;
}
     


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
pair<int,int> pii;

int main()
{
    ll ans=0,n;
    scanf("%lld",&n);
    ans=n/500*1000;
    ans+=n%500/5*5;
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 256
/**    epsileer 18 August 2019  17:34:45  **/    
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double LD;
typedef pair<LL,LL> PII;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define TEST int t = 1; while(t--) solve()

void solve(){
    int n; cin>>n;
    LD ans = 0.0;
    for(int i=0;i<n;i++){
        LD x; cin>>x;
        ans += (1.0/x);
    }
    cout<<(1.0/ans);
}

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); TEST;
return 0;
}

Measured memory_bytes: 256
//  Created by liszt on 2019/07/31.
#include<bits/stdc++.h>
using namespace std;

int main(){
    //input
    int n,omax=0,emax=0,om,em,i,a,b;
    vector<int> o(100001,0);
    vector<int> e(100001,0);
    cin>>n;
    
    for(i=0;i<n/2;i++){
        cin>>a>>b;
        o[b]++; e[a]++;
        if(o[b]>omax){omax=o[b];om=b;}
        if(e[a]>emax){emax=e[a];em=a;}
    }
    
    sort(o.rbegin(),o.rend());
    sort(e.rbegin(),e.rend());

    if(om!=em){
        cout<<n-o[0]-e[0]<<endl;
    }else{
        cout<<min(n-o[0]-e[1],n-o[1]-e[0])<<endl;
    }
    return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <vector>

using namespace std;
using int64 = long long;

int main() {
    string s;
    cin >> s;
    for (int i=0; i<s.size(); i++) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


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

using namespace std;
using ll = long long;

int gcd(int a, int b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main(void) {
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      for (int k = 1; k <= n; k++) {
        ans += gcd(k, gcd(i, j));
      }
    }
  }
  cout << ans << endl;
  return 0;
}


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

long long N, A[1 << 18];

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

	long double ret = A[0];
	for (int i = 1; i < N; i++) ret = 0.5L * (ret + 1.0L * A[i]);
	printf("%.12Lf\n", ret);
	return 0;
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    N, C = map(int, input().split())

    left = []
    right = []
    left_append = left.append
    right_append = right.append
    for _ in range(N):
        x, v = map(int, input().split())
        left_append([x, v])
        right_append([C - x, v])

    tmp1 = max(0, left[0][1] - left[0][0])
    left_value = [0, tmp1]
    tmp2 = max(0, left[0][1] - 2 * left[0][0])
    left_value_back = [0, tmp2]
    left_value_append = left_value.append
    left_value_back_append = left_value_back.append
    for i in range(1, N):
        left[i][1] += left[i - 1][1]
        tmp1 = max(tmp1 ,left[i][1] - left[i][0])
        left_value_append(tmp1)
        tmp2 = max(tmp2 ,left[i][1] - 2 * left[i][0])
        left_value_back_append(tmp2)

    tmp1 = max(0, right[N - 1][1] - right[N - 1][0])
    right_value = [0, tmp1]
    tmp2 = max(0, right[N- 1][1] - 2 * right[N - 1][0])
    right_value_bakc = [0, tmp2]
    right_value_append = right_value.append
    right_value_bakc_append = right_value_bakc.append
    for i in range(N- 2, -1, -1):
        right[i][1] += right[i + 1][1]
        tmp1 = max(tmp1, right[i][1] - right[i][0])
        right_value_append(tmp1)
        tmp2 = max(tmp2, right[i][1] - 2 * right[i][0])
        right_value_bakc_append(tmp2)

    # print (left)
    # print (left_value)
    # print (left_value_back)
    # print ()
    # print (right)
    # print (right_value)
    # print (right_value_bakc)

    ans = 0
    for i in range(N + 1):
        tmp = max(left_value[i], right_value[N - i])
        tmp = max(tmp, left_value_back[i] + right_value[N - i], left_value[i] + right_value_bakc[N - i])
        ans = max(ans, tmp)

    print (ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 50604
N = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if p[i] == i+1:
        ans += 1
        p[i],p[i+1] = p[i+1],p[i]
if p[N-1] == N:
    ans += 1
print(ans)

Measured memory_bytes: 14008
import java.util.Scanner;

class Main{




	public static void main(String[] args) {





		Scanner sc = new Scanner(System.in);			//文字の入力
		String a = sc.next();
		
		int anum = 0;
		for(int i = 0;i < a.length();i++){
			if(a.charAt(i) == 'A'){
				anum = i;
				break;
			}
		}
		
		int znum = 0;
		for(int i = a.length()-1;i >= 0;i--){
			if(a.charAt(i) == 'Z'){
				znum = i;
				break;
			}
		}
		
		System.out.println(znum-anum+1);


	}
}


class Pair implements Comparable{
	Character from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 27160
#include <bits/stdc++.h>
#define loop2(i, s, n, a) for (int i = int(s); i < int(n); i += a)
#define loop(i, s, n) loop2(i, s, n, 1)
#define rep(i, n) loop(i, 0, n)

#define pb push_back
#define all(in) in.begin(),in.end()

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

int main(){
    ll x, y, z, k; cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    rep(i,x) cin >> a[i];
    rep(i,y) cin >> b[i];
    rep(i,z) cin >> c[i];

    vector<ll> ans1(x*y);
    rep(i,x) rep(j,y) ans1[i*y+j] = a[i] + b[j];
    sort(all(ans1), greater<ll>());

    ll s = min(3000ll, x*y);
    vector<ll> ans2(s);
    rep(i,s) ans2[i] = ans1[i];

    sort(all(c),greater<ll>());

    vector<ll> ans3(s*z);
    rep(i,s) rep(j,z) ans3[i*z+j] = ans2[i] + c[j];
    sort(all(ans3), greater<ll>());

    rep(i,k) cout << ans3[i] << endl;
}

Measured memory_bytes: 34604
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;

const long long N = 1e3 + 17;
ll cnt, ans, lnt = N, sum, n, l1, b[N][N], a[N];
pair<ll,ll>pr[N];
vector<ll>v,v2,v3;
map<ll,ll>mp;
bool used[N], t1, t2;
vector<string>sv;

int main()
{
    double m, a[N], mx = N, x, y;
    cin >> n;
    cin >> x >> y;
    for(ll i = 0; i < n; i ++)
    {
        cin >> a[i];
        if(abs(x - a[i] * 0.006 - y) < mx)
           {
               mx = abs(x - a[i] * 0.006 - y);
               m = i + 1;
           }
    }
    cout << m;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int l[220]={};
int main()
{
	cin>>n;
	for(int i=1;i<=2*n;i++)
	 {
	 	cin>>l[i];
	 }
	 sort(l+1,l+2*n+1);
	 int anss=0;
	 for(int i=1;i<=2*n;i++)
	 if(i%2!=0)
	 {
	  anss+=l[i];
     }
	cout<<anss<<endl;
	return 0;
}

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

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 1;
	for (int i = 1; i < n; i++) {
		if (a[i] != a[i-1]) {ans++;}
	}
	cout << ans;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;

typedef long long ll;
typedef vector<long long> vi;
typedef pair<long long, long long> ii;
typedef vector<pair<long long, long long>> vii;
typedef stringstream ss;
ll mil() { return numeric_limits<long long>::min(); }
ll mal() { return numeric_limits<long long>::max(); }

#define R3(i, a, b) for (long long i = (a); i < (b); ++i)
#define R2(i, b) for (long long i = 0; i < (b); ++i)
#define R1(b) for (long long i = 0; i < (b); ++i)
#define RR(i, a, b) for (long long i = a; i > b; --i)
#define PB(x) push_back(x)
#define MP(x, y) make_pair(x, y)

// build: ctrl + f9

// run: shift + f10
// debug: shift + f9
// sanitize: shift + f11

int main(int argc, char **argv)
{
    /*freopen("../../input.txt", "r", stdin);
    freopen("../../output.txt", "w", stdout);*/

    ll S, W;

    cin >> S >> W;

    cout << ((W >= S) ? "unsafe" : "safe") << endl;
}

Measured memory_bytes: 3632
object Main extends App {
  for(line <- io.Source.stdin.getLines()) {
    val numAry = line.split(' ').map { _.toString() }
    val coffee = numAry(0)
    println(if ((coffee.length == 6) && (coffee(2) == coffee(3)) && (coffee(4) == coffee(5))) "Yes" else "No");
  }
}


Measured memory_bytes: 27460
#include <iostream>
#include <vector>

int main(void){
	int N, K, d = 0, cnt = 0, a = 0;
	std::cin >> N >> K;
	std::vector<int> sunuke(N, 0);

	for(int i = 0; i < K; i++){
		std::cin >> d;
		for(int j = 0; j < d; j++){
			std::cin >> a;
			sunuke[a-1]++;
		}
	}
	for(int i = 0; i < N; i++)
		if(sunuke[i] == 0)
		       cnt++;
	std::cout << cnt << std::endl;
	return 0;
}


Measured memory_bytes: 3608
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
#define int long long
#define pb push_back
#define fi first
#define se second
#define fr(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define IO ios :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define pii pair<int,int>
#define sz(x) (int)x.size()
const int mod = 1e9 + 7;
const int mod1 = 998244353;
typedef long double f80;

#ifndef LOCAL
#pragma GCC optimize ("O2")
#define endl '\n'
#endif

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

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rand(int l, int r){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

ll pwr(ll a,ll b, ll mod){
    a %= mod;
    int ans = 1;
    while(b){
        if(b & 1) ans = (ans * a) % mod;
        a = (a * a) % mod;
        b >>= 1;
    }
    return ans;
}

string to_string(string s) {
  return '"' + s + '"';
}

string to_string(const char* s) {
  return to_string((string) s);
}

string to_string(bool b) {
  return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 1e5 + 5;
int lg2[N], a[N];
void solve(){
	int n, m;
	cin >> n >> m;
	fr(i, 1, n){
		cin >> a[i];
	}
	int ans = 1;
	for(int i = 1; i * i <= m; i++){
		if(m % i == 0){
			if(m >= i * n){
				ans = max(ans, i);
			}
			if(m >= (m / i) * n){
				ans = max(ans, m / i);
			}
		}
	}
	cout << ans;
}
signed main(){
    IO;
    #ifdef LOCAL
        freopen("inp.txt","r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    cout << setprecision(10) << fixed;
    int t = 1;
    // cin >> t;
    fr(tt, 1, t){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iostream>
#define debug(msg, ...) printf("(%s #%d) " msg, __FUNCTION__, __LINE__, __VA_ARGS__);
#define sqr(x) ((x) * (x))
using namespace std;
typedef double db;
int n;
bitset < 1005 > use;
db x[1005], y[1005], r[1005], g[1005][1005], dis[1005];
inline db dist(int i, int j) {
	return sqrt(sqr(x[i] - x[j]) + sqr(y[i] - y[j]));
}
int main() {
	scanf("%lf%lf%lf%lf%d", x + 1, y + 1, x + 2, y + 2, &n);
	n += 2; swap(x[2], x[n]); swap(y[2], y[n]);
	for (int i = 2; i < n; ++i)
		scanf("%lf%lf%lf", x + i, y + i, r + i);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j)
			g[i][j] = max(0.0, dist(i, j) - r[i] - r[j]);
	for (int i = 2; i <= n; ++i) dis[i] = 1e100;
	for (;;) {
		int u = -1;
		for (int i = 1; i <= n; ++i)	
			if (!use[i] && (u == -1 || dis[i] < dis[u])) u = i;
		if (u == -1) break; use[u] = 1;
		for (int i = 1; i <= n; ++i)
			dis[i] = min(dis[i], dis[u] + g[u][i]);
	} printf("%.11lf\n", dis[n]);
	return 0;
}


Measured memory_bytes: 8192
a=map(int, raw_input().split())

if (min(a)<a[0]<max(a)):
    print min(a),a[0],max(a)
elif (min(a)<a[1]<max(a)):
    print min(a),a[1],max(a) 
else:
    print min(a),a[2],max(a) 

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

int main() {
  long long A,B,C,D;
  cin >> A >> B >> C >> D;
  long long tmp;
  if(C<D){
    tmp=C;
    C=D;
    D=tmp;
  }
  long long Cl=C,Dl=D;
  long long r;
  r = Cl % Dl;
  while(r!=0){
    Cl = Dl;
    Dl = r;
    r = Cl % Dl;
  }
  long long sc=C/Dl*D;
  cout << B-A-B/C+(A-1)/C-B/D+(A-1)/D+B/sc-(A-1)/sc+1;
}

Measured memory_bytes: 256
# AOJ 0583: Common Divisors
# Python3 2018.6.30 bal4u

def gcd(a, b):
	while b != 0:
		r = a % b
		a, b = b, r
	return a

n = int(input())
a = list(map(int, input().split()))
g = gcd(a[0], a[1])
for i in range(2, len(a)): g = gcd(g, a[i])
for x in range(1, g+1, 1+(g&1)):
	if g%x == 0: print(x)


Measured memory_bytes: 5600
#include<iostream>
int main() {
  int a,b,d,e;
  while(1){
    std::cin>>a>>b>>e;
    e+=a+b;
    if(e==0)break;
    int p[e];
    for(a=0;a<e;a++)p[a]=2;
    std::cin>>d;
    int s[4][d];
    for(a=0;a<d;a++)std::cin>>s[0][a]>>s[1][a]>>s[2][a]>>s[3][a];
    for(a=0;a<d;a++)
      if(s[3][a]==1)p[s[0][a]-1]=1,p[s[1][a]-1]=1,p[s[2][a]-1]=1;
    for(a=0;a<d;a++){
      if(p[s[0][a]-1]*p[s[1][a]-1]*p[s[2][a]-1]==2){
	if(p[s[0][a]-1]==p[s[1][a]-1])
	  p[s[2][a]-1]=0;
	else if(p[s[1][a]-1]==1)
	  p[s[0][a]-1]=0;
	else
	  p[s[1][a]-1]=0;
      }
    }
    for(a=0;a<e;a++)std::cout<<p[a]<<"\n";
  }
}

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

int main() {

 int n=0;

 cin >> n;

 int hour = n/3600;

 int min = n/60 - hour*60;

 int sec = n - hour*3600 - min*60;

 cout << hour << ":" << min << ":" << sec << endl;

}


Measured memory_bytes: 3096
S = input()
Q = int(input())
T = 0
s = ""
for i in range(Q):
    q = list(input().split())
    if q[0] == "1":
        T = (T+1) % 2
    elif (T == 0 and q[1] == "1") or (T == 1 and q[1] == "2"):
        s += q[2]
    else:
        S += q[2]
if T == 0:
    S = s[::-1] + S
    print(S)
else:
    S = S[::-1] + s
    print(S)

Measured memory_bytes: 9832
main = do
 s<- getLine
 putStrLn $ reverse $ f $ reverse s
f []= []
f (x:xs)
        |x=='0' ="0" ++ (f xs)
        |x=='1' ="1" ++ (f xs)
        |x=='B' && (dropWhile (\y -> y == 'B') xs)==[] = []
        |otherwise = f ((takeWhile (\y -> y == 'B') xs) ++ (tail (dropWhile (\y -> y == 'B') xs)))


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

typedef long long int ll;
typedef vector<int> vi;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double ld;

#define pvec(v) for(auto e: v) cout << e << " ";
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i, a, b) for(int i = (a); i<(b); ++i)
#define pb push_back
#define INF 1000000005
#define MOD 1000000007
#define all(v) v.begin(), v.end()

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

ll power(ll x, ll y, ll p = MOD){  
  ll res = 1LL; 
  x = x % p;
  if (x == 0) return 0;
  while (y > 0){
    if (y & 1LL)  
      res = (res*x) % p;
    y = y>>1LL; 
    x = (x*x) % p;  
  }  
  return res;  
}  

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

	vector<pii> inp;
	int a, b;
	for(int i = 0; i < n; ++i) {
		cin >> a >> b;
		inp.push_back({a, b});
	}

	bool f = false;
	for(int i = 0; i < n - 2; ++i) {
		if(
			inp[i].first == inp[i].second && 
			inp[i + 1].first == inp[i + 1].second && 
			inp[i + 2].first == inp[i + 2].second

		) {
			f = true;
			break;
		}
	}

	f ? cout << "Yes\n" : cout << "No\n";
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double EPS = 1e-8;

template<typename T> T chmax(T& a, const T& b){return a = (a > b ? a : b);}
template<typename T> T chmin(T& a, const T& b){return a = (a < b ? a : b);}

#define DEBUG_MODE
#ifdef DEBUG_MODE
#define dump(x) cout << #x << " : " << x << " "
#define dumpL(x) cout << #x << " : " << x << '\n'
#define LINE cout << "line : " << __LINE__ << " "
#define LINEL cout << "line : " << __LINE__ << '\n'
#define dumpV(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << " "
#define dumpVL(v) cout << #v << " : ["; for(auto& t : v) cout << t << ", "; cout<<"]" << endl
#define STOP assert(false)
#else
#define dump(x) 
#define dumpL(x) 
#define LINE 
#define LINEL 
#define dumpV(v) 
#define dumpVL(v) 
#define STOP assert(false)
#endif
#define mp make_pair
 
namespace std {
template<class S, class T>
ostream &operator <<(ostream& out, const pair<S, T>& a) {
    out << '(' << a.fi << ", " << a.se << ')';
    return out;
}
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    int m = 2*n-1;
    if(x == 1 || x == m) {
        cout << "No" << '\n';
        return 0;
    }
    deque<int> d;
    d.push_back(x);
    set<int> st;
    rep(i, m) st.insert(i+1);
    st.erase(x);
    REP(i, 1, n) {
        if(i&1) {
            d.push_back(x-i);
            d.push_front(x+i);
        }
        else {
            d.push_back(x+i);
            d.push_front(x-i);
        }
        st.erase(x+i);
        st.erase(x-i);
    }
    rep(i, m) {
        if(d[i] <= 0 || d[i] > m) {
            d[i] = *st.begin();
            st.erase(st.begin());
        }
    }
    
    
    cout << "Yes" << '\n';
    rep(i, m) cout << d[i] << (i+1 == m ? '\n' : ' ');
   
    return 0;
}

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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a > d || b < c){
        cout << 0 << "\n";
    }else if(a <= c && c <= b && b <= d){
        cout << b-c << "\n";
    }else if (c <= a && a <= d && d <= b){
        cout << d-a << "\n";
    }else if (a <= c && c <= d && d <= b){
        cout << d-c << "\n";
    }else if (c <= a && a <= b && b <= d){
        cout << b-a << "\n";
    }
    return 0;
}

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

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

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

    int N, Q;
    cin >> N >> Q;
    vector<int> A(N), X(Q), sum(N + 1), sum2(N + 1);
    REP(i, N) cin >> A[i];
    REP(i, Q) cin >> X[i];

    sum2[0] = A[0];
    sum2[1] = A[1];
    REP(i, N) {
        sum[i + 1] = sum[i] + A[i];
        if (i - 2 >= 0) {
            sum2[i] = sum2[i - 2] + A[i];
        }
    }

    REP(q, Q) {
        int x = X[q];
        int ok = N - 1;
        int ng = 0;
        while (ok - ng > 1) {
            int mid = (ok + ng) / 2;

            int upper = N - 1 - mid + 1;
            int lower = mid - static_cast<int>(lower_bound(A.begin(), A.end(), x - (A[mid] - x)) - A.begin()) + 1;
            if (upper <= lower) {
                ok = mid;
            } else {
                ng = mid;
            }
        }

        int res = sum[N] - sum[ok];
        int next = N - 1 - (N - ok) * 2;
        if (next >= 0) res += sum2[next];
        cout << res << endl;
    }

    return 0;
}


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

using namespace std;

const int MaxN = 3e2 + 3;
const int INF = 1e9;

int a[MaxN][MaxN];
int f[MaxN];
int cnt[MaxN];
bool used[MaxN];

int n, m;
int ans;

set<pair<int, int> > s;

int main()
{
//    freopen("input.txt", "r", stdin);
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;
    ans = INF;
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= m; ++j)
            cin >> a[i][j];
        cnt[a[i][1]]++;
        f[i] = 1;
    }
    for(int i = 1; i <= m; ++i)
        s.insert(make_pair(-cnt[i], i));

    while(!s.empty())
    {
        ans = min(ans, -(*s.begin()).first);
        int x = (*s.begin()).second;
        used[x] = true;
        s.erase(s.begin());
        if(s.empty())
            break;
        for(int i = 1; i <= n; ++i)
            if(used[a[i][f[i]]])
            {
                while(used[a[i][f[i]]])
                    ++f[i];
                s.erase(make_pair(-cnt[a[i][f[i]]], a[i][f[i]]));
                ++cnt[a[i][f[i]]];
                s.insert(make_pair(-cnt[a[i][f[i]]], a[i][f[i]]));
            }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main{
	static final double EPS = 1e-8;
	
	void run(){
		Scanner in = new Scanner(System.in);
		double W = in.nextDouble(), H = in.nextDouble();
		int N = in.nextInt();
		double[] as = new double[N], ps = new double[N], qs = new double[N];
		for (int i = 0; i < as.length; i++) {
			as[i] = in.nextDouble();
			ps[i] = in.nextDouble();
			qs[i] = in.nextDouble();
		}
		ArrayList<Double> crs = new ArrayList<Double>();
		crs.add(0.0);
		crs.add(W);
		for (int i = 0; i < N; i++) {
			addPoint(crs, as[i], ps[i], qs[i], 0, 0, 0);
			for (int j = 0; j < i; j++) {
				addPoint(crs, as[i], ps[i], qs[i], as[j], ps[j], qs[j]);
			}
		}

		Collections.sort(crs);
		double ans = 0.0;
		for (int i = 0; i + 1 < crs.size(); i++) {
			double x1 = crs.get(i), x2 = crs.get(i+1);
			if (x1 < 0 || W < x2 || x2 < x1 + EPS) {
				continue;
			}
			int key = -1;
			double maxi = -1.0;
			for (int j = 0; j < N; j++) {
				double y = as[j] * sq((x1 + x2)/2.0 - ps[j]) + qs[j];
				if (y > maxi) {
					key = j;
					maxi = y;
				}
			}
			if (key == -1 || maxi < -EPS) {
				continue;
			}
			ans += calcIntegral(x1, x2, as[key], ps[key]);
		}
		System.out.printf("%.13f\n", ans);
	}

	double calcIntegral(double x1, double x2, double a, double p) {
		double ans = 0.0;
		final int ITER = 10000;
		double d = (x2 - x1) / ITER;
		for (int i = 0; i < ITER; i++) {
			ans += d / 2.0 *(func(x1+i*d, a, p) + func(x1+(i+1)*d, a, p));
		}
		return ans;
	}

	double func(double x, double a, double p) {
		return Math.sqrt(1 + sq(2*a*(x-p)));
	}

	void addPoint(ArrayList<Double> crs, double a1, double p1, double q1,
			double a2, double p2, double q2) {
		double a = a1 - a2, b = -2*a1*p1 + 2*a2*p2, c = a1*sq(p1)+q1 - a2*sq(p2)-q2;
		double d = b*b - 4*a*c;
		if (Math.abs(a) > EPS) {
			if (Math.abs(d) < EPS) {
				crs.add(-b/(2*a));
			} else if (d > 0) {
				crs.add( (-b - Math.sqrt(d)) / (2*a) );
				crs.add( (-b + Math.sqrt(d)) / (2*a) );
			}
		} else if (Math.abs(b) > EPS) {
			crs.add(-c / b);
		}
	}

	double sq(double x) {
		return x * x;
	}

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

Measured memory_bytes: 36012
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner scan = new Scanner(System.in);
        int A=Integer.parseInt(scan.next());
        int B=Integer.parseInt(scan.next());
        int C=Integer.parseInt(scan.next());
        int D=Integer.parseInt(scan.next());
        int E=Integer.parseInt(scan.next());
        int sum=0;
        if(A<=C){
            sum=(C-A)*60 +D-B -E;
            
        }
        else{
            sum=((C-A)+24) *60+D-B-E ;
        }
        System.out.println(sum);
    }
}


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

int main() {
	int CakeMax,CakeType;
	int c;
	
	cin >> CakeMax >> CakeType;
	
	int max = 0;
	
	for(int i = 0;i < CakeType;i++)
	{
		cin >> c;
		
		if(c > max)
			max = c;
	}
	
	int ans = max - (CakeMax - max) - 1;
	if(ans < 0)
		ans = 0;
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
        using namespace std; 
        #define int long long
        # define pii pair<int,int>
        const int maxn=1e6+5;
        signed main() { 
            #ifndef ONLINE_JUDGE
            freopen("input.txt","r",stdin);
            freopen("output.txt","w",stdout);
            #endif
            ios::sync_with_stdio(0);
            cin.tie(0);
            int a,b;
            cin>>a>>b;
            cout<<a*b;
        } 

Measured memory_bytes: 3644
#include <iostream>
using namespace std;
int main(void){
    
    int A, B, C, ans=0;
    int X;
    cin >> A >> B >> C >> X;
    for(int i=0; i<=A; i++){
        for(int j=0; j<=B; j++){
            for(int k=0; k<=C; k++){
                if(X==500*i + 100*j + 50*k){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;

}


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

int main(){
  int h,w;
  cin >> h >> w;
  vector<string> vec(2*h);

  for (int i = 0; i < 2*h; i+=2)
  {
    cin >> vec[i];
    vec[i+1] = vec[i];
  }

  for (int i = 0; i < 2*h; i++)
  {
    cout << vec[i] << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>

#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);

#define MOD 1000000007
#define ll long long int
#define MAX 100005

using namespace std;

int main() {

    IO


    ll x;

    cin >> x;

    ll resp=(x/500)*1000;
    x%=500;
    resp+=(x/5)*5;

    cout << resp << "\n";

    return 0;
}


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

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);  
	int h, w;
	cin >> h >> w;
  int c[10][10];
  for(int i = 0; i < 10; i++) {
  	for(int j = 0; j < 10; j++) {
  		cin >> c[i][j];
  	}
  }
  for(int i = 0; i < 10; i++) {
  	for(int j = 0; j < 10; j++) {
  		for(int k = 0; k < 10; k++) {
  			c[j][k] = min(c[j][k], c[j][i] + c[i][k]);
  		}
  	}
  }
  long long ans = 0;
  for(int i = 0; i < h; i++) {
  	for(int j = 0; j < w; j++) {
  		int t;
  		cin >> t;
  		if(t == -1) {
  			continue;
  		}
  		ans += c[t][1];
  	}
  }
  cout << ans << endl;
	return 0;	
}


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

class UnionFind {
 public:
     int n;
     std::vector<int> par;
     std::vector<int> num;

     explicit UnionFind(int n) {  // [0 n)のunion find
         this->n = n;
         this->par.resize(n);
         this->num.resize(n, 1);
         for (int i = 0; i < n; i++) {
             this->par[i] = i;
         }
     }

     int root(int i) {
         if (par[i] == i)
             return i;
         else
             return par[i] = root(par[i]);
     }

     bool same(int i, int j) {
         return root(i) == root(j);
     }

     void unite(int i, int j) {
         int t = root(i);
         int k = root(j);

         if (t == k) return;

         par[t] = k;
         num[k] += num[t];
     }

     int size(int i) {
         return num[root(i)];
     }
};

signed main() {
    ll n,m,ans=0;
    cin>>n>>m;
    vector<ll> v(n);
    UnionFind uf(n);
    vector<set<ll>> vs(n, set<ll>());
    rep(i,0,n){
        cin>>v[i];
        v[i]--;
    }
    rep(i,0,m){
        ll x,y;
        cin>>x>>y;
        x--; y--;
        uf.unite(x,y);
    }
    rep(i,0,n){
        vs[uf.root(i)].insert(v[i]);
    }

    rep(i,0,n){
        if (vs[uf.root(i)].count(i))
            ans++;
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LLI long long int
#define LI long int 
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//               When something is important enough, you do it even if the odds are not in your favor.
LLI dp[104][100004];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LI i,n,j,k;cin>>n>>k;
      LI a[n];
      fo(i,0,n) cin>>a[i];
      //memset(dp,-1,sizeof(dp));
      std::vector<LLI> pref (k+1);
      fo(j,0,k+1){
        if(j>a[0]) break;
        dp[0][j]=1;
      }
      fo(i,1,n){
        pref[0]=dp[i-1][0];
        fo(j,1,k+1) {
          pref[j]=pref[j-1]+dp[i-1][j];pref[j]%=MOD;
        }
        fo(j,0,k+1){  //  j is number of candies
          if(max((LI)0,j-a[i]-1)==0&&j-a[i]-1<0) dp[i][j]+=pref[j];
          else dp[i][j]+=(MOD+pref[j]-pref[max((LI)0,j-a[i]-1)])%MOD;dp[i][j]%=MOD;
        }
      }
      cout<<dp[n-1][k];
    }
    return 0;
}

Measured memory_bytes: 80896
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.lang.*;


public class Main{
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int h = sc.nextInt();
		int n = sc.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}
		int[] hp = new int[h + 1];
		for (int i = 1; i <= h; i++) {
			int min = 100000000;
			for (int j = 0; j < n; j++) {
				min = Math.min(min, hp[Math.max(0, i - a[j])] + b[j]);
			}
			hp[i] = min;
		}
		System.out.println(hp[h]);
	}
	
}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;
	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}
	private int readByte() {
		if (hasNextByte()) {
			return buffer[ptr++];
		} else {
			return -1;
		}
	}
	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}
	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
			ptr++;
		}
		return hasNextByte();
	}
	public String next() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}
	public long nextLong() {
		if (!hasNext()) {
			throw new NoSuchElementException();
		}
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || Integer.MAX_VALUE < nl) {
			throw new NumberFormatException();
		}
		return (int) nl;
	}
	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 23508