akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
using namespace std;
int main(){
  string str;
  getline(cin,str);
  int i;
  for(i=0;i<str.size();i++){
    if(str[i]>='a'&&str[i]<='z') str[i]+='A'-'a';
    else if(str[i]>='A'&&str[i]<='Z') str[i]+='a'-'A';
  }
    cout << str << endl;
  return 0;
}


Measured memory_bytes: 3172
import sys
sys.setrecursionlimit(100000000)

def dfs(node,distance):
  for next_node,edge_distangce in G[node]:
    if ans[next_node]==-1:
      ans[next_node]=(distance+edge_distangce)%2
      dfs(next_node,distance+edge_distangce)

n=int(input())
G=[[] for _ in range(n)]

for i in range(n-1):
  u,v,w = map(int,input().split())
  G[u-1].append([v-1,w])
  G[v-1].append([u-1,w])

ans = [-1]*n
dfs(0,0)
print(*ans,sep='\n')


Measured memory_bytes: 87100
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define all(c) c.begin(), c.end()
#define gmax(x,y) x=max(x,y)
#define gmin(x,y) x=min(x,y)
#define gadd(x,y) x=add(x,y)
#define gmul(x,y) x=mul(x,y)
using namespace std;

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

const int N = 2e5 +5;
int cnt[N];

int main(){
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
	int n,k;
	cin >> n >> k;
	rep(i,0,n){
		int x;
		cin >> x;
		++cnt[x];
	}
	vector<array<int,2>> v;
	rep(i,0,N){
		if(cnt[i]){
			v.push_back(array<int,2>{cnt[i], i});
		}
	}
	sort(all(v));
	int ans = 0;
	rep(i,0,(int)v.size()-k){
		ans += v[i][0];	
	}
	cout << ans << '\n';
}


Measured memory_bytes: 3188
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



long long cnt[200000];

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

	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)cnt[i%k]++;


	long long ans = 0;
	rep(a, k) {
		int b = (k - a) % k;
		int c = a;
		if ((a+c)%k==0) {
			ans += cnt[a] * cnt[b] * cnt[c];
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define N 100
int main(){

  int n,flag,i,j,temp,A[N],count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  flag=1;
  while(flag){
    flag=0;
    for(j=1;j<=n-1;j++){
      if(A[j]<A[j-1]){
	temp=A[j];
	A[j]=A[j-1];
	A[j-1]=temp;
	flag=1;
	count++;
      }
    }

  }
  for(j=0;j<n;j++){
    printf("%d",A[j]);
    if(j==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 2140
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

ll gcd(ll a, ll b) {
    if(b == 0) return a;
    return gcd(b,a%b);
}
 
ll lcm(ll a, ll b) {
    ll g = gcd(a,b);
    return a / g * b;   // Be careful not to overflow
}

int main(int argc, char* argv[])
{
    int n,m;
    scanf("%d%d", &n, &m);
    vector<int> a(n);
    int i;
    int bad=0;
    ll aa;
    for(i=0; i<n; i++) {
        scanf("%d", &a[i]);
        if(a[i]%2) bad=1;
        a[i]/=2;
        if(i==0) aa=a[i];
        else aa=lcm(aa,a[i]);
        if(aa>m) {
            printf("0\n"); return 0;
        }
    }
    if(bad) {
        printf("0\n"); return 0;
    }
    for(i=0; i<n; i++) {
        ll tmp=aa/a[i];
        if(tmp%2==0) {
            printf("0\n"); return 0;
        }
    }

    if(aa>m) {
        printf("0\n"); return 0;
    }
    ll tmp=m/aa;
    printf("%lld\n", (tmp+1)/2);

    return 0;
}



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

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());
		
		//???????????\???
		for(int i = 0; i < n; i++){
			String[] tmpStr = br.readLine().split(" ");
			int[] lineLength = new int[3];
			int max = 0;
			int maxIndex = -1;
			
			for(int j = 0; j < 3; j++){
				lineLength[j] = Integer.parseInt(tmpStr[j]);
				if(lineLength[j] > max){
					max = lineLength[j];
					maxIndex = j;
				}
			}
			
			//??´?§?????§???¢?????§??????
			int sum = 0;
			for(int j = 0; j < 3; j++){
				
				int sq = lineLength[j] * lineLength[j];
				if(j == maxIndex){
					sum -= sq;
				}
				else {
					sum += sq;
				}
			}
			
			if(sum == 0){
				System.out.println("YES");
			}
			else {
				System.out.println("NO");
			}
		}
	}

}

Measured memory_bytes: 25716
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=int64_t;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using mii = map<int, int>;
using vi=vector<int>;
using vii=vector<vi>;
using vl=vector<ll>;
using vll=vector<vl>;
using tpi=tuple<int, int, int>;

int main() {
    int N;
    string S;
    cin >> N >> S;
    char ans[S.size()];
    for (size_t i = 0; i < S.length(); i++) {
        if ('Z' - S[i] >= N) {
            ans[i] = static_cast<char>(S[i] + N);
        } else {
            ans[i] = static_cast<char>( 'A' + N - 'Z' + S[i] - 1 );
        }
    }

    string anss(ans);
    for (size_t i = 0; i < S.length(); i++) {
        cout << ans[i];
    }
    cout << endl;
    return 0;
}
//NOPQRSTUVWXYZABCDEFGHIJKLM
//NOPQRSTUVWXYZABCDEFGHIJKLM

Measured memory_bytes: 888
n = int(input())
s = list(input())
rcnt = s[1:].count("E")
lcnt = 0
ans = rcnt
for i in range(1,n):
    if s[i-1] == "W":
        lcnt += 1
    if s[i] == "E":
        rcnt -= 1
    ans = min(ans,lcnt+rcnt)
print(ans)

Measured memory_bytes: 8268
n, a, b, c, d = map(int, input().split())
s = '#' + input()

def check(l, r):
    for i in range(l, r):
        if s[i] == '#' and s[i+1] == '#':
            return False

    return True

if c < d:
    if check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")
else: # c > d
    space = False

    for i in range(b, d+1):
        if s[i-1] == '.' and s[i] == '.' and s[i+1] == '.':
            space = True
            break

    if space and check(a, c) and check(b, d):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3636
import java.util.Scanner;

public class Main {

	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int first = scan.nextInt();
		String op = scan.next();
		int second = scan.nextInt();
		
		if(op.equals("+")) {
			System.out.println(first + second);
		}
		else {
			System.out.println(first - second);
		}
		
		
	}

}


Measured memory_bytes: 22612
#include <iostream>
 #include <algorithm>
 #include <vector>
 #include <string>
 #include <map>
 #include <set>
 using namespace std;
 long long calc(long long A) {
   long long cnt1 = (A+1) / 2;
   long long ans = cnt1 % 2;
   if(A % 2 == 0) ans ^= A;
   return ans;
 }
 
 int main() {
 	long long A, B;
 	cin >> A >> B;
 	long long ans = calc(B) ^ calc(A-1);
 	cout << ans << endl;
 }


Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()


def main():
    S = input()
    ans = 1000
    for i in range(len(S) - 2):
        val = int(S[i:i+3])
        ans = min(ans, abs(val - 753))
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
import java.io.*;
import java.math.*;
import java.util.*;
public class Main { 

	public static void main(String[] args) { //
		Scanner input = new Scanner(System.in);
		long limit = (long)(1e18);
		long ans = 1;
		int N = input.nextInt();
		boolean ZERO = false;
		long[] arr = new long[N];
		for (int i = 0; i < N; i++) {
			long x = input.nextLong();
			arr[i]=x;
		}
		for (int i = 0; i < N; i++) {
			long remaining = limit/ans;
			if (arr[i]>remaining) {
				ans=-1;
				break;
			}else ans*=arr[i];
		}
		for (int i = 0; i < N; i++) {
			if (arr[i]==0) {
				ZERO=true;
				break;
			}
		}
		System.out.println(ZERO?0:ans);
	}	
}

Measured memory_bytes: 50780
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W,x,y,z;
  cin >> H >> W; 
  vector<string> board(H);
 
  for(int i = 0; i < H; i++) {
    cin >> board[i];
  }
 
 
  for(int i=0; i < H; i++) {
    for(int j=0; j < W; j++) {
      if(board[i][j] == '#') continue;
 
      x = 0;
      for(int k = 0; k < 9; k++) {
        int y = i +k/3 -1;
        int z = j +k%3 -1;
        if (y < 0 or H <= y) continue;
        if (z < 0 or W <= z) continue;
        if (board[y][z] == '#') ++x;
      }
      board[i][j] = char( x + '0');
    }
  }
 
  for(int i = 0; i < H; i++) cout << board[i] << endl;
 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
int main(void){
int n,k;
int h[1000000];
int yes=0;
int count;
scanf("%d",&n);
scanf("%d",&k);
for(count=0;count!=n;count++)
{
    scanf("%d",&h[count]);
}
for(int count=0;count!=n;count++)
{
    if(h[count]>=k){yes++;}
}
printf("%d",yes);
return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
using namespace std;
#define rep(i, N) for (long long i = 0; i < N; i++)
using ll = long long;
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 long long INF = 1LL << 60;

int main() {
    ll N;
    cin >> N;
    vector<ll> dp(N + 1, INF);
    dp[0] = 0;
    for (ll i = 1; i <= N; i++) {
        ll power = 1;
        while (power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 6;
        }
        power = 1;
        while (power <= i) {
            chmin(dp[i], dp[i - power] + 1);
            power *= 9;
        }
    }
    cout << dp[N] << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main()
{
	int t;
	t=1;
	while(t--)
	{
		int n,k;
		cin>>n>>k;
		int arr[n];
		for(int i=0;i<n;i++)
		{
			cin>>arr[i];
		}
		int x=k;
		for(int i=0;i<n-k;i++)
		{
          if(arr[i]<arr[x])
          {
          	cout<<"Yes"<<endl;
          }
          else
          {
          	cout<<"No"<<endl;
          }
          x++;
		}

	}
}

Measured memory_bytes: 4416
from heapq import heappop, heappush
Q = int(input())
maxh = []
minh = []
sum1 = sum2 = b = med = 0
for i in range(Q):
  q = list(map(int, input().split()))
  if q[0]==1:
    b += q[2]
    if len(maxh)==0 or q[1]<-maxh[0]:
      heappush(maxh, -q[1])
      sum1 += q[1]
      if len(maxh)>len(minh)+1:
        t = -heappop(maxh)
        heappush(minh, t)
        sum1 -= t
        sum2 += t
    else:
      heappush(minh, q[1])
      sum2 += q[1]
      if len(maxh)<len(minh):
        t = heappop(minh)
        heappush(maxh, -t)
        sum1 += t
        sum2 -= t
    med = -maxh[0]
  else:
    ans = len(maxh)*med-sum1+sum2-len(minh)*med+b
    print(med, ans)

Measured memory_bytes: 11152
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x,a,b;cin>>x;
  bool isok=false;
  for(ll i=0;i<=1000;++i) {
    ll a_=i*i*i*i*i;
    for(ll j=-1000;j<=1000;++j) {
      if(a_==x+j*j*j*j*j) {
        isok=true;
        a=i,b=j;
      }
      if(isok) break;
    }
    if(isok) break;
  }
  printf("%lld %lld\n",a,b);
  return 0;
}

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

int main() {
    int n;
    char ch;
    cin >> n;
    bool flag = true;
    set<string> st;
    rep(i, n) {
        string str;
        cin >> str;
        st.insert(str);
        if(i && str.at(0) != ch) flag = false;
        ch = str.at(str.length() - 1);
    }
    if(st.size() != n) flag = false;
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
// Author : SAGORIKA DAS
#include <bits/stdc++.h>
#define F first
#define S second
#define MOD 1000000007
#define pb push_back
#define MAX 200002
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define mp make_pair
#define CLEAR(a) memset(a,0,sizeof a)
#define pii pair< int , int >
#define fr freopen("input.txt", "r", stdin)
#define fw freopen("output.txt", "w", stdout)
using namespace std;
#define int long long 
int f[26], a, b, t[MAX];
string s;
set< pair<int,int> > st;
set< pair<int,int> > :: iterator it;

bool check(int c){
    st.clear();
    for(int i=1;i<=s.size();i++)
        if(s[i-1]-'a' == c) t[i] = 1;
        else t[i] = 0;

    t[0] = 0;
    for(int i=1;i<=s.size();i++) t[i] += t[i-1];

    
    for(int i=1;i<=s.size();i++) t[i] = 2*t[i] - i;

    st.insert(mp(t[0], 0));
    for(int i=1;i<=s.size();i++) {
        it = st.lower_bound(mp(-1e18, -1));
        if(it->F < t[i] && i-it->S > 1){
            a = it->S+1; b =i;
            return 1;
        } 
        st.insert(mp(t[i], i));
    }

    return 0;
}

 main()
{
    //fr;fw;
    cin >> s;

    REP(i,s.size()) f[s[i]-'a']++;
    
    for(int i=0;i<26;i++){
        if(f[i] < 2) continue;
        if(check(i)){
            cout << a <<" "<< b;
            return 0;
        }
    }

    cout <<-1<<" "<<-1;
}


Measured memory_bytes: 7424
#include "bits/stdc++.h"

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll a,b,c;
string s;
int main() {
    cin>>a>>b>>c;
    p(max({a,b,c})-min({a,b,c}));
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int i;
  int a,b;
  int n;
	int number;

	while(scanf("%d %d",&a,&b)!=EOF){
    number=0;
  a=a+b;
  while(a!=0){
    a = a/10;
    number++;
  }
  printf("%d\n",number);
}
  return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#define pi acos(-1.0)
using namespace std;

const int maxn = 100;
int a[maxn];

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

  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ok = 1;
  for (int i = 0; i < n - 1; ++i) if (a[i] > a[i + 1]) { ok = 0; break; }
  if (ok) { cout << "YES"; return 0; }
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      swap(a[i], a[j]);
      ok = 1;
      for (int k = 0; k < n - 1; ++k) if (a[k] > a[k + 1]) { ok = 0; break; }
      if (ok) { cout << "YES"; return 0; }
      swap(a[i], a[j]);
    }
  }
  cout << "NO\n";
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
/**
********************************************************************
******************* Author:Bisnu sarkar ****************************
********************************************************************
**/
#define ull            unsigned long long
#define ll             long long
#define vi             vector<int>
#define pb             push_back
#define mp             make_pair
#define pii            pair<int,int>
#define vit            vector<int> :: iterator
#define sit            set<int> :: iterator
#define vrit           vector<int> :: reverse iterator
#define ff             first
#define ss             second
#define endl           '\n';
#define what_is(x)     cerr << #x << " is " << x << endl;
///*....Debugger....*/
#define error(args...) {vector <string> _v = split(#args, ','); err(_v.begin(), args); cout << endl;}
vector <string> split(const string &s, char c) {
    vector <string> v;
    stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x);
    return move(v);
}
void err(vector <string> :: iterator it) {}
template <typename T, typename... Args>
void err(vector <string> :: iterator it, T a, Args... args) {
    cout << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << ", ";
    err(++it, args...);
}
 
int ini(){int x; scanf("%d",&x);return x;}
long long inl(){ long long x;scanf("%lld",&x); return x;}
double ind(){double x; scanf("%lf",&x);return x;}
#define Iin ini();
#define Lin inl();
#define Din ind();

int set_1(int n,int pos){return n = (n | (1<<pos));}
int reset_0(int n,int pos){return n= n & ~(1<<pos);}
bool check_bit(int n,int pos){return n = n & (1<<pos);}

int dx[8]= {1,0,-1,0,-1,-1,1,1};
int dy[8]= {0,1,0,-1,-1,1,-1,1};
const int N = (int) 1e6 + 5;
const int M = (int) 1e9 + 7;
const double pi=2* acos(0.0);
const double eps=1e-9;

//int a[N];

pair<ll,ll> p[N];

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    int t=1,te=0;
  //  cin>>t;
    while(t--){
        int n;
        cin>>n;

        for(int i=1;i<=n;++i){
            ll x,y;
            cin>>x>>y;
            p[i]={y,x};
        }
        sort(p+1,p+n+1);
        ll sum=0;
        for(int i=1;i<=n;++i){
            sum+=p[i].ss;
            if(sum >p[i].ff){
                printf("No\n");
                return 0;
            }
        }
        printf("Yes\n");

        //printf("Case %d: ",++te);
    }
    return 0;
}




Measured memory_bytes: 4352
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define REP(i,a,b) for (int i = a ; i <= b ; i++)
#define REPI(i,a,b) for (int i = a ; i >= b ; i--)
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

const int OO = 1e9+7;
const int MOD = 1e9+7;
const int N = 1e5+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    //freopen("teleport.in","r",stdin);
    //freopen("teleport.out","w",stdout);

    int n,m,h,w;
    cin >> n >> m >> h >> w;

    int ans = n*m;
    ans -= h*m;
    ans -= w*(n-h);
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	REP(i, m)cin >> x[i];
	if (n >= m) cout << "0" << endl;
	else {
		sort(x.begin(),x.end());
		vector<int> diff(m);
		REP(i, m - 1) { diff[i] = x[i + 1] - x[i]; }
		DescSort(diff);
		int max_sum = 0;
		REP(i, n-1) { max_sum += diff[i]; }
		cout << (x[m-1]-x[0])-max_sum << endl;
	}
	
	return 0;
}



Measured memory_bytes: 1024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.Abc171
{
    class E
    {
        public static void Main()
        {
            var n = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var all = a.Aggregate((acc, x) => acc ^ x);
            Console.WriteLine(string.Join(" ", a.Select(x => (x ^ all).ToString())));
        }
    }
}


Measured memory_bytes: 66016
#include <algorithm>
#include <functional>
#include <iostream>
#include <vector>

using namespace std;

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

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

    vector<int> b(m);
    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    sort(a.begin(), a.end(), greater<int>());
    sort(b.begin(), b.end(), greater<int>());

    long long res = 1;
    for (int i = 0, j = 0, k = 0; i < n * m; i++) {
        int dj = 0;
        while (j + dj < n && a[j + dj] == n * m - i) {
            dj++;
        }
        j += dj;

        int dk = 0;
        while (k + dk < m && b[k + dk] == n * m - i) {
            dk++;
        }
        k += dk;

        if (dj == 0 && dk == 0) {
            res *= max(j * k - i, 0);
        } else if (dj == 0 && dk == 1) {
            res *= j;
        } else if (dj == 1 && dk == 0) {
            res *= k;
        } else if (dj >= 2 || dk >= 2) {
            res = 0;
        }
        res %= 1000000007;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int max(int,int);

int main(void){
  int n,m,h[201],r[201],i,j,t,dp[201],res;

  while(scanf("%d",&n),n){
    for(i=0;i<n;i++)scanf("%d %d",&h[i],&r[i]);
    scanf("%d",&m);
    for(i=n;i<n+m;i++)scanf("%d %d",&h[i],&r[i]);

      for(i=0;i<n+m;i++){
	  for(j=i;j<n+m;j++){
	      if(h[i]>h[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
		}
	      if(h[i]==h[j] && r[i]>r[j]){
		  t=h[i];
		  h[i]=h[j];
		  h[j]=t;
		  t=r[i];
		  r [i]=r[j];
		  r[j]=t;
	      }
	  }
	}
      for(i=0;i<n+m;i++)dp[i]=0;
      dp[0]=1;
      
      for(i=0;i<n+m;i++){
	for(j=i+1;j<n+m;j++){
	  if(h[i]<h[j] && r[i]<r[j] && dp[i]>=dp[j])dp[j]=dp[i]+1;
	}
      }
      res=0;
      for(i=0;i<n+m;i++)res=max(res,dp[i]);

      printf("%d\n",res);
  }
  
  return 0;
}

int max(int x,int y){
  return x>y?x:y;
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)

int main() {
	int N, K; cin >> N >> K;
	int a = 1;
	rep(i, 0, N) {
		a = ((2 * a < a + K) ? 2 * a : a + K);
	}
	cout << a << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl
int main(){
    ll n, k;
    cin >> n >> k;

    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(all(a)); reverse(all(a));
    ll ans = 0;
    for(int i = k; i < n; i++){
        ans += a[i];
    }
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;


public class Contest
{
	public static void Main()
	{

/*
		int n = a[0];
		int[][] e = new int[n][];
		for(int i=0; i<n; i++) e[i] = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(zzz => int.Parse(zzz)));
*/

 //       long a,b,c,d,e,f;
 //       MyRead.Multi(out a, out b, out c, out d, out e, out f);
        int a;
        MyRead.Multi(out a);

		int[] e = Array.ConvertAll(Console.ReadLine().Split(' '), new Converter<string,int>(zzz => int.Parse(zzz)));
		int[] d = new int[a];
        Array.Copy(e, d, e.Length);
        Array.Sort(d);
		int cnt = 0;
		for(int i=0; i<a; i++) if (e[i] != d[i]) cnt++; 

		string s = cnt <3?"YES":"NO";


		Console.WriteLine(s);
	}
	
	private static int calc_main(int[] a,int[] b,int[] c,int[] d) {



		return 0;
	}




}

public static class MyRead
{
	private static bool eq<T, U>() => typeof(T).Equals(typeof(U));
	private static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
	private static T cv<T>(string s) => eq<T, int>()    ? ct<T, int>(int.Parse(s))
	                                  : eq<T, long>()   ? ct<T, long>(long.Parse(s))
	                                  : eq<T, double>() ? ct<T, double>(double.Parse(s))
	                                  : eq<T, char>()   ? ct<T, char>(s[0])
	                                                    : ct<T, string>(s);
	public static string[] Multi<T>(out T a) {
		var ar = Console.ReadLine().Split(new char[] {' '}, StringSplitOptions.RemoveEmptyEntries); 
		a = cv<T>(ar[0]);
		return ar;
	}
	public static string[] Multi<T, U>(out T a, out U b) {
		var ar = Multi<T>(out a); 
        b = cv<U>(ar[1]);
		return ar;
	}
	public static string[] Multi<T, U, V>(out T a, out U b, out V c) {
		var ar = Multi<T, U>(out a, out b); 
        c = cv<V>(ar[2]);
		return ar;
	}
	public static string[] Multi<T, U, V, W>(out T a, out U b, out V c, out W d) {
		var ar = Multi<T, U, V>(out a, out b, out c); 
        d = cv<W>(ar[3]);
		return ar;
	}
	public static string[] Multi<T, U, V, W, X>(out T a, out U b, out V c, out W d, out X e) {
		var ar = Multi<T, U, V, W>(out a, out b, out c, out d); 
        e = cv<X>(ar[4]);
		return ar;
	}
	public static string[] Multi<T, U, V, W, X, Y>(out T a, out U b, out V c, out W d, out X e, out Y f) {
		var ar = Multi<T, U, V, W, X>(out a, out b, out c, out d, out e); 
        f = cv<Y>(ar[5]);
		return ar;
	}
}




Measured memory_bytes: 11348
#include <stdio.h>
#include <vector>
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

int main(){
	string N;
	cin >> N;
  	int sum = 0;
  	for(auto c: N){
      sum += (c-'0');
    }
  	string ans;
  	if(sum%9 == 0) ans = "Yes";
  	else ans = "No";
  
  	cout << ans << endl;

}

Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define PPF pop_front
#define PPB pop_back
#define MA make_pair
#define ll long long
#define PA pair<int,int>
#define VE vector<int>
#define VP vector<PA>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POSSIBLE(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
#define Possible(i) cout<<(i?"Possible":"Impossible")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=998244353;
//
struct poi{
	int X;int Y;int Z;
	bool operator<(const poi&R)const{
		return X==R.X ? Y==R.Y ? Z<R.Z : Y<R.Y : X<R.X;
	}
};
//
ll GCD(ll A,ll B){
  return (B==0)?(A):(GCD(B,A%B));
}
ll LCM(ll A,ll B){
  return A/GCD(A,B)*B;
}
//
int main(){
	int A,B;
	cin>>A>>B;
	if(A+B==15){
		cout<<"+"<<endl;
	}else if(A*B==15){
		cout<<"*"<<endl;
	}else{
		cout<<"x"<<endl;
	}
	return 0;
}

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

int main()
{
  int a, b, c, e;
  cin >> a >> b >> c;
  if(a > b){
    e = b;
    b = a;
    a = e;
  }
  if(b > c){
    e = c;
    c = b;
    b = e;
  }
  if(a > b){
    e = b;
    b = a;
    a = e;
  }

  cout << a << " " << b << " " << c << "\n";
  return 0;
}

Measured memory_bytes: 1164
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define mkt make_tuple
#define no {cout << "-1\n"; return;}

int gcd(int a, int b) {
    while (b) {
        a %= b; swap(a, b);
    }
    return a;
}

void solve() {
    int a, b;
    cin >> a >> b;
    int g = gcd(a, b);
    set <int> s;
    for (int i = 2; i * i <= g; ++i)
        if (g % i == 0) {
            s.insert(i);
            while (g % i == 0)
                g /= i;
        }
    if (g > 1)
        s.insert(g);
    cout << s.size() + 1;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, a;
int main() {
	cin >> n >> a;
	
	cout << n * n - a << endl;
	
	return 0;
}


Measured memory_bytes: 256
import java.io.File;
import java.io.IOException;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
 
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner sc = new Scanner(file);
		
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		Integer[] a = new Integer[N];
		//int[] a = new int[N];
		for(int i = 0; i < N; i++) a[i] = sc.nextInt();
		
		Arrays.sort(a,  Collections.reverseOrder());
		
		int alice = 0;
		int bob = 0;
		for(int i = 0; i < a.length; i++){
			if(i % 2 == 0) alice += a[i];
			else bob += a[i];
		}
		
		System.out.println(alice-bob);
	}
}

Measured memory_bytes: 23764
n = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

# 0,0 →1,N-1
# 1行目のi+1　～ N-1と、 2行目のi～N-2の合計を比較。
# 2行目の方が大きくなったら下に移動する。

maxcnt = 0

if n == 1:
    maxcnt=A1[0]+A2[0]
else:   
    for j in range(n-1):
        cnt1a = sum(A1[:j+1])
        #cnt2a = sum(A2[0:j])
        #cnt1b = sum(A1[j:n-1+1])
        cnt2b = sum(A2[j:])
        if cnt1a + cnt2b > maxcnt:
            maxcnt = cnt1a + cnt2b
            #ch = j
            #print(cnt1a + cnt2b)

print(maxcnt)



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

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

    long long a, b, c, k, ans=0;
    cin >> a >> b >> c >> k;
    if(a>=k){
        ans = k;
    }
    else{
        ans = a;
        k = k-a;
        if(b<k){
            k = k-b;
            ans = ans-k;
        }
    }
    cout << ans << endl;

    return 0;
}

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

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

int main(void)
{
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <bitset>
using namespace std;
int n;
string x;
vector< int > mem;
int sub(int a){
    if(mem[a] != -1) return mem[a];
    return mem[a] = sub(a%(bitset<32>(a).count())) + 1;
}
int main(void){
    cin >> n >> x;
    mem.assign(n+3, -1);
    mem[0] = 0;
    int cnt = 0;
    for(int i=0;i<n;i++){
        if(x[i] == '1') cnt++;
    }
    if(cnt == 0){
        for(int i=0;i<n;i++){
            cout << 1 << endl;
        }
        return 0;
    }
    if(cnt == 1){
        for(int i=0;i<n;i++){
            if(x[i] == '1') cout << 0 << endl;
            else{
                if(i == n-1){
                    cout << 2 << endl;
                }else{
                    cout << 1 << endl;
                }
            }
        }
        return 0;
    }
    reverse(x.begin(), x.end());
    vector<int> y(n+1, 0), z(n+1, 0), py(n+1, 1), pz(n+1, 1);
    for(int i=0;i<n;i++){
        // cout << "x[i]: " << x[i] << ": ";
        y[i+1] = y[i];
        z[i+1] = z[i];
        py[i+1] = (py[i]*2) % (cnt-1);
        pz[i+1] = (pz[i]*2) % (cnt+1);
        if(x[i] == '1'){
            y[i+1] += py[i];
            z[i+1] += pz[i];
            y[i+1] %= cnt-1;
            z[i+1] %= cnt+1;
        }
        /*
        cout << " y: " << y[i+1];
        cout << " z: " << z[i+1];
        cout << endl;
        */

    }
    for(int i=n-1;i>=0;i--){
        if(x[i] == '0'){
            cout << sub((z[n] + pz[i])%(cnt+1))+1 << endl;
            // cout << ": " << (z[n] + pz[i])%(cnt+1) << endl;
        }else{
            cout << sub((y[n] - py[i] + cnt - 1)%(cnt-1))+1 << endl;
            // cout << ": " << (y[n] - py[i] + cnt - 1)%(cnt-1) << endl;
        }
    }

    // cout << cnt << endl;
}


Measured memory_bytes: 7016
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    string S;cin >> S;
    int N = S.size()-1;
    int ans = 0;
    REP(i,S.size()/2){
        if(S[i] != S[N-i]) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  int a[n];
  int i,j;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  int x;
  int cont=0;
  int minj;
  int flag=0;
  for(i=0;i<n;i++){
    minj=i;
    for(j=i;j<n;j++){
      if(a[j]<a[minj]){
	minj=j;
	flag=1;
      }
    }
    if(flag==1){
      x=a[i];
      a[i]=a[minj];
      a[minj]=x;
      cont++;
      flag=0;
    }
  }
  for(i=0;i<n-1;i++)printf("%d ",a[i]);
  printf("%d\n%d\n",a[n-1],cont);
  return 0;
}



Measured memory_bytes: 2140
#include<stdio.h>
#include<ctype.h>
#include<string.h>
int main(void)
{
  char W[11],T[1001];
  int count=0,i;
  scanf("%s",&W);
  fflush(stdin);
  for(i=0;i<11;i++ )
    {
      W[i] = tolower(W[i]);
      if(W[i] == '\0'){break;}
    }
  for( ; ; ){
    scanf("%s",&T);
    if(!strcmp(T,"END_OF_TEXT")){break;}
    fflush(stdin);
     for(i=0;i<1001;i++ )
    {
      T[i] = tolower(T[i]);
      if(T[i] == '\n'){break;}
    }
  if(!strcmp(W,T)){count++;}
  }
  printf("%d\n",count);
  
    return 0;
}

Measured memory_bytes: 556
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n;
string s;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> n >> s;
    int cnt = 0;
    for (int i = 0; i <= n - 3; i++) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;
    }
    cout << cnt << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long LL;
int main()
{
    LL n,a,b;
    cin>>n>>a>>b;

        if(a>b )
        {
            cout<<"0"<<endl;
            return 0;
        }
        if(n == 1 && a != b)
        {
            cout<<"0"<<endl;
            return 0;
        }
        cout<<(b-a)*(n-2)+1<<endl;;



    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int main()
{
  long long N,a,b;
  scanf("%lld%lld%lld",&N,&a,&b);
  long long ans;
  if(a%2==b%2){
    ans=(std::max(a,b)-std::min(a,b))/2ll;
  }
  else{
    ans=std::min((a+b-1)/2ll,(2*N-a-b+1)/2ll);
  }
  printf("%lld\n",ans);
  return 0;
}


Measured memory_bytes: 128
/*
 AtCoder AXC 000
 */
 
#include <stdio.h>

int main(void){
	
	int a,b,c,x; //xは50の倍数
	int p=0;
	int i,j,k,n,m;
	int temp_x;
	
	
	(void)scanf("%d",&a);
	(void)scanf("%d",&b);
	(void)scanf("%d",&c);
	(void)scanf("%d",&x);
	
	temp_x = x;
	
	for(i=0; x >= 500 && i < a; i++) x -= 500;
	for(j=0; x >= 100 && j < b; j++) x -= 100;
	for(k=0; x >=  50 && k < c; k++) x -= 50;
	
	if(x != 0){
		printf("%d",p);
		return 0;
	}
	
	for(; i>=0;i--,j+=5){
		// 500 -> 100*5
		
		for(n=j,m=k; n>=0; n--,m+=2){
			// 100 -> 50*2
			if(i<=a && n<=b && m<=c){
				//printf("(500,100,50) = (%d,%d,%d)\n",i,n,m);
				p++;
			}
		}
	}
	
	printf("%d",p);
	
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main()
{
  int j, n, maxv, minv, R[200000];

  scanf("%d",&n);
  for( j=0 ; j<n ; j++ )
    scanf("%d",&R[j]);

  minv = R[0];
  maxv = R[1] - R[0];

  for( j=1 ; j<n ; j++ ){
    if(R[j]-minv>maxv) maxv = R[j]-minv;
    if(minv>R[j]) minv = R[j];
  }
  printf("%d\n",maxv);
  return 0;
}

Measured memory_bytes: 1376
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
typedef pair<int,int> pii;

int main(){
    int n,m;
    cin>>n>>m;
    vector<int> room(n+1,0);
    vector<vector<int>> g(n+1);
    vector<int> used(n+1,0);

    rep(i,m){
        int a,b;
        cin>>a>>b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    used[1]=1;
    queue<int> que;
    que.push(1);
    cout<<"Yes"<<endl;
    while(!que.empty()){
        int loc = que.front();que.pop();
        for(auto v:g[loc]){
            if(used[v]==1){
                continue;
            }else{
                room[v]=loc;
                used[v]=1;
                que.push(v);
            }
        }
    }

    for(int i=2;i<=n;i++){
        cout<<room[i]<<endl;
    }

    return 0;
}

Measured memory_bytes: 10560
x=[]
y=[]
while True:
    n,k=map(int,input().split())
    if n==0 and k==0:
        break
    else:
        x=[int(input()) for i in range(n)]
        if len(x)<k:
            pass
        else:
            s=sum(x[0:k])
            y.append(s)
            for i in range(0,n-k):
                s=s-x[i]+x[i+k]
                y.append(s)
            print(max(y))
            


Measured memory_bytes: 11708
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
	public static void main (String[] args) throws java.lang.Exception
	{

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x;
		double r, mennseki, ennsyuu;
		x = br.readLine();
		String[] ary = x.split(" ");
		r = Double.parseDouble(ary[0]);
		mennseki = r * r * Math.PI;
		ennsyuu = 2 * Math.PI * r;
		System.out.printf("%.6f", mennseki);
		System.out.print(" ");
		System.out.printf("%.6f", ennsyuu);
	}
}

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

#define rep(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int a;
  string b;
  cin >> a >> b;
  int c = pow(10,b.size()) * a + stoi(b);
  //cout << sqrt(c) << endl;
  if(((int)sqrt(c) * (int)sqrt(c)) == c) cout << "Yes";
  else cout << "No";
  cout << endl;
}


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

int main(){
  int H,N;cin>>H>>N;
  int sum=0;
  for(int i=0;i<N;i++){
    int a;cin>>a;
    sum+=a;
  }
  if(H<=sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

using namespace std;

int main()
{
  int n;
  cin>>n;
  vector<vector<int>> happy(n,vector<int>(3,0));
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>happy[i][j];
  vector<vector<int>> dp(n,vector<int>(3,0));
  for(int i=0;i<3;i++)
    dp[0][i]=happy[0][i];
  for(int i=1;i<n;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++)
      {
        if(j==k)continue;
        dp[i][j]=max(dp[i][j],dp[i-1][k]+happy[i][j]);
      }
  int ans=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
Imports System

Module Program
    Sub Main(args As String())

        Dim N As Integer = Console.ReadLine()

        Dim J(3) As Integer
        Dim s As String

        For i As Integer = 1 To N
            s = Console.ReadLine()
            Select Case s
                Case "AC"
                    J(0) += 1
                Case "WA"
                    J(1) += 1
                Case "TLE"
                    J(2) += 1
                Case "RE"
                    J(3) += 1
            End Select
        Next

        Console.WriteLine($"AC x {J(0)}")
        Console.WriteLine($"WA x {J(1)}")
        Console.WriteLine($"TLE x {J(2)}")
        Console.WriteLine($"RE x {J(3)}")

    End Sub

End Module


Measured memory_bytes: 31516
n, x = map(int, input().split())
ns = list(map(int, input().split()))
ttl = 0
if ns[0] >= x:
    ttl += ns[0] - x
    ns[0] = x
for i in range(n - 1):
    eat = max(0, ns[i]+ns[i+1]-x)
    ttl += eat
    ns[i + 1] -= eat
print(ttl)
    

Measured memory_bytes: 14252
#include<stdio.h>
#include<stdlib.h>
int main(void){

int i,j;
int sum=0;
int n;
int t=0;
int w[101];
long min;
int s1=0;
int s2=0;

scanf("%d",&n);
for(i=0;i<n;i++){ 
scanf("%d ",&w[i]);
sum+=w[i];
}
//printf("%d\n",sum);
int sa[n];  
 
for(i=0;i<n;i++){
  s1+=w[i];
  //printf("%d\n",s1);
  s2=sum-s1;
  sa[i]=abs((s1-s2));
}
  
min=sa[0];  
  
for(i=0;i<n;i++){
  if(min>sa[i]){
    //printf("s");
    min=sa[i];
  }
}

printf("%d",min);
  
return 0;
}

Measured memory_bytes: 128
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    a=sort(parseMap(split(readline())))
    println(a[end]-a[1])
end
main()

Measured memory_bytes: 114460
x = [int(input()) for i in range(5)]
k = int(input())
flag = 0
for i in range(5):
  for j in range(4):
    if x[i] - x[j] > k:
      flag = 1
else:
  if flag == 1:
    print(":(")
  else:
    print("Yay!")

Measured memory_bytes: 3064
#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>;

int main() { 
  int n, a, b;
  string ans = "pon";
  cin >> n;
  a = n % 100;
  b = a % 10;
  if (b == 2 or b == 4 or b == 5 or b == 7 or b == 9) {
    ans = "hon";
  }
  if (b == 0 or b == 1 or b == 6 or b == 8) {
    ans = "pon";
  }
  if (b == 3) {
    ans = "bon";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
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 ll INF = 1LL << 60;
const int MAX = 1000000010;
const ll MOD = 1000000007;
const double PI = acos(-1);

bool is_prime(ll n) {
    if (n == 1) return false;
    if (n == 2) return true;
    for (int i = 3; (ll)i * i <= n; i = i + 2) {
        if (n % i == 0) return false;
    }

    return true;
}

int main () {
    ll N; cin >> N;
    ll x = N;
    map<int, int> m;
    while (N % 2 == 0) {
        m[2]++;
        N /= 2;
    }
    for (int i = 3; (ll)i * i <= x; i = i + 2) {
        while (N % i == 0) {
            m[i]++;
            N /= i;
        }
    }
    

    ll ans = 0;
    for (auto p : m) {
        int cnt = p.second;
        int i = 1;
        while (cnt - i >= 0) {
            cnt -= i;
            i++;
            ans++;
        }
        //cout << p.first << ":" << p.second << endl;
    }

    if (is_prime(N)) ans++;
    if (x == 1) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
N,K=map(int,input().split())
P=list(map(int,input().split()))
C=list(map(int,input().split()))

E=[]
color=["white" for _ in range(N)]
for i in range(N):
    if color[i]=="white":
        index,F=i,[]
        while 1:
            if color[index]=="white":
                color[index]="black"
                index=P[index]-1
                F.append(C[index])
            else:break
        E.append(F)

ans=-float("inf")
for A in E:
    length=len(A)
    if sum(A)<0:
        A=A*2
        for i in range(length):
            point=0
            for j in range(min(K,length)):
                point +=A[i+j]
                ans=max(ans,point)
    else:
        div,mod=divmod(K,length)
        base=(div-1)*sum(A)
        A=A*3
        for i in range(length):
            point=0
            for j in range(mod+length):
                point +=A[i+j]
                ans=max(ans,base+point)
print(ans)

Measured memory_bytes: 74244
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <sstream>

#define rep(i, a) REP(i, 0, a)
#define REP(i, a, b) for(int i = a; i < b; ++i)
#define rrep(i, a) RREP(i, a, 0)
#define RREP(i, a, b) for(int i = a; i >= b; --i)
#define repll(i, a) REPLL(i, 0, a)
#define REPLL(i, a, b) for(ll i = a; i < b; ++i)
#define rrepll(i, a) RREPLL(i, a, 0)
#define RREPLL(i, a, b) for(ll i = a; i >= b; --i)

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int, int> P;
typedef std::pair<int, P> PP;
const double PI = 3.14159265358979323846;
const double esp = 1e-9;
const int infi = (int)1e+9 + 10;
const ll infll = (ll)1e+18 + 10;

std::string str1, str2;
int s1, s2;
int dp[1005][1005];

int main(){
	std::cin >> str1 >> str2;
	s1 = str1.size();
	s2 = str2.size();

	rep(i, s1 + 1)dp[i][0] = i;
	rep(i, s2 + 1)dp[0][i] = i;

	REP(i, 1, s1 + 1){
		REP(j, 1, s2 + 1){
			int cost = 1;
			if (str1[i - 1] == str2[j - 1])cost = 0;
			dp[i][j] = std::min(dp[i - 1][j] + 1, std::min(dp[i][j - 1] + 1, dp[i - 1][j - 1] + cost));
		}
	}

	std::cout << dp[s1][s2] << std::endl;

	return 0;
}

Measured memory_bytes: 5120