akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.io.*;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static final long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public  static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);
        // int n=sc.nextInt();
        // char c[][] = new char[h][w];
        // char c[]=sc.nextString().toCharArray();
        // int d[]=new int[n];
        // for(int i=0; i<n; i++) {d[i]=sc.nextInt();}

        int n=sc.nextInt();
        long k=sc.nextLong();
        long a[] = new long[n];
        long d[] = new long[50];
        long s=0;
        for (int i = 0; i < a.length; i++) {
        	a[i]=sc.nextLong();
        }
        for (int i = 0; i < d.length; i++) {
			for (int t = 0; t < a.length; t++) {
				d[i]+=(a[t]>>i)%2;
			}
		}
        long e=0;
        for (int i = 49; -1 < i; i--) {
        	if(d[i]<=n/2 && (e|(1L<<i))<=k) {
				e|=1L<<i;
			}
		}

        for (int i = 0; i < a.length; i++) {
			s+=e^a[i];
		}

        out.println(s);
        out.flush();
    }


    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }  
}

//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//        this.a=a;
//        this.b=b;
//    }
//    public int compareTo(P p){
//        return b-p.b; //des
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
    	int r[] = new int[size];
    	for (int i = 0; i < size; i++) {
			r[i] = this.nextInt(); 
		}
    	return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


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

int main(){
  string s;
  cin >> s;
  int64_t ans =0;
  int64_t tmp=0;
  for(int bit=0;bit<(1<<(s.size()-1));bit++){
    for(int i=0;i<s.size();i++){
      tmp+=s.at(i)-'0';
      if(bit>>i&1||i==s.size()-1){
        ans+=tmp;
        tmp=0;
      }
      else{
        tmp*=10;
      }
    }
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3568
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define swap(type ,a ,b) {type t; t=a; a=b; b=t;}
#define forN(i,n) for(i=0;i<n;i++)
#define forR(i,s,n) for(i=s;i<n;i++)
#define ll long long
#define pb(t,d,n) {t p;int i;forN(i,n){cin>>p;d.push_back(p);}}

using namespace std;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> pii;

typedef vector<pair<int,int>> vpii;

int main(){
    int a,b;
    cin >> a >> b;
    if(abs(a-b)%2==1) cout << "IMPOSSIBLE" << endl;
    else cout << (a+b)/2 << endl;
}

Measured memory_bytes: 888
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
typedef long long LL;
using namespace std;
char m[105][105];
int w, h, ans;
const int DIR [4][2]= {{-1, 0}, {1, 0}, {0, -1}, {0, 1}};
void dfs(int x, int y, char c);
bool is_valid(int x, int y);
int main() {
    //freopen("F:\\TestCode\\TestCLion\\in.txt", "r", stdin);
    while (scanf("%d%d", &h, &w) && w && h) {
        memset(m, 0, sizeof(m));
        ans = 0;
        for (int i = 0; i < h; i++)
            scanf("%s", m + i);
        for (int i = 0; i < h; i++) {
            for (int j = 0; j < w; j++) {
                if (m[i][j] != '.') {
                    dfs(i, j, m[i][j]);
                    ans++;
                }
            }
        }
        printf("%d\n", ans);
    }
    return 0;
}

void dfs(int x, int y, char c) {
    if (!is_valid(x, y) || m[x][y] != c) return;
    m[x][y] = '.';
    for (int i = 0; i < 4; i++)
        dfs(x + DIR[i][0], y + DIR[i][1], c);
}

bool is_valid(int x, int y) {
    return x >= 0 && x < h && y >= 0 && y < w;
}


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


int main() {
    string s; cin >> s;
    string x = "x";
    rep(i, s.size()-1) x.push_back('x');
    cout << x << endl;
}

Measured memory_bytes: 256
while True:
    try:
        s = input()
    except:
        break

    t, sc = s.split("=")
    sa, sb = t.split("+")

    if (len(sa) > 1 and sa[0] == 'X') \
       or (len(sb) > 1 and sb[0] == 'X') \
       or (len(sc) > 1 and sc[0] == 'X'):
        start = 1
    else:
        start = 0

    f = 0
    for i in range(start,10):
        na = int( sa.replace("X", str(i)) )
        nb = int( sb.replace("X", str(i)) )
        nc = int( sc.replace("X", str(i)) )
        if na + nb == nc:
            f += 1
            break

    if f > 0:
        print(i)
    else:
        print("NA")




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

int main(void){
  int n, stk[2000], sp;
  int flg[200]={0}, suc;
  
  cin >> n;
  sp = 0; suc = 0;
  for (int i=1; i<=n; i++){
    int t; cin >> t;
    if (t>0){ // in
      if (flg[t]){
        //cout << "deb: same cat went into twice" << endl;
        cout << i << endl;
        break;
      }
      flg[t]=1;
      stk[sp++] = t;
    } else { // out
      t = -t;
      if (!flg[t] || sp==0 || stk[sp-1]!=t){
        //if (!flg[t]) cout << "deb: the cat didnt went into" << endl;
        //if (sp==0) cout << "deb: no cat" << endl;
        //if (stk[sp-1]!=t) cout << "deb: the cat isnt the top" << endl;
        cout << i << endl;
        break;
      }
      sp--;
      flg[t]=0;
    }
    if (i==n) suc = 1;
  }
  if (suc) cout << "OK" << endl;
  return 0;
}


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

#include <math.h>
#include <stdio.h>

using namespace std;

int cost(int a[], int x, int y) {
	return abs(a[x] - a[y]);
}

int main(void) {
	int n;
	int a[1000*100+2];
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	a[0] = 0;
	a[n+1] = 0;
	int sum = 0;

	for (int i = 1; i <= n+1; i++) {
		sum += cost(a, i-1, i);
	}

	for (int i = 1; i <= n; i++) {
		printf("%d\n", sum - cost(a,i-1,i) - cost(a,i,i+1) + cost(a,i-1,i+1));
	}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    map<string, bool> seen;
        seen["gray"] = false;
        seen["brown"] = false;
        seen["green"] = false;
        seen["skyblue"] = false;
        seen["blue"] = false;
        seen["yellow"] = false;
        seen["orange"] = false;
        seen["red"] = false;
        seen[""] = true;
    int cnt=0, all=0;
    for (int i=0; i<N; i++){
        int rate; cin >> rate;
        string colar="";
        if (rate<400) colar = "gray";
        else if (rate<800) colar = "brown";
        else if (rate<1200) colar = "green";
        else if (rate<1600) colar = "skyblue";
        else if (rate<2000) colar = "blue";
        else if (rate<2400) colar = "yellow";
        else if (rate<2800) colar = "orange";
        else if (rate<3200) colar = "red";
        else all++;
        if (seen[colar]) continue;
        seen[colar] = true;
        cnt++;
    }
    cout << max(1,cnt) << " " << cnt+all << endl;
    return 0;
}

Measured memory_bytes: 3580
import java.util.*;
import java.util.stream.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    int[] A = new int[N];
    for (int i = 0; i < N; i++) {
      A[i] = in.nextInt();
    }
    int[] L = new int[N], R = new int[N];
    L[0] = A[0];
    R[N - 1] = A[N - 1];
    for (int i = 1; i < N; i++) {
      L[i] = gcd(L[i - 1], A[i]);
    }
    for (int i = N - 2; i >= 0; i--) {
      R[i] = gcd(R[i + 1], A[i]);
    }
    int ans = Math.max(R[1], L[N - 2]);
    for (int i = 1; i < N - 1; i++) {
      ans = Math.max(ans, gcd(L[i - 1], R[i + 1]));
    }
    System.out.println(ans);
  }

  public static int gcd(int x, int y) {
    return y == 0 ? x : gcd(y, x % y);
  }
}

Measured memory_bytes: 52472
#include<bits/stdc++.h>
#define ll long long int
#define FastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;

int main(void)
{
    FastIO;
    
    string s,t;
    cin>>s;
    ll size=s.size();
    for(ll i=0;i<size;i++)
    {
    	t+=s[i];
	}
    if(s[size-1]=='s')
    {
    	t+="es";
	}
	else
	{
		t+="s";
	}
	cout<<t;
    
    return 0;
}

Measured memory_bytes: 3656
N, M, *AB = map(int, open(0).read().split())

E = [[] for _ in range(N + 1)]
for a, b in zip(*[iter(AB)] * 2):
    E[a].append(b)

dp = [0] * (N + 1)
for i in range(1, N + 1):
    dp[i] = max(dp[i], dp[i - 1])
    for j in E[i]:
        dp[j] = max(dp[j], dp[i] + 1)

print(dp[N])


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

int N, K;
int a[1010];
vector<ll> v;

ll dfs(int p, vector<ll> &w) {
  if (p < 0) return 0;
  vector<ll> w2;
  for (int i = 0; i < w.size(); i++) {
    if (w[i] >> p & 1) w2.emplace_back(w[i]);
  }
  if (w2.size() >= K) {
    return (1LL << p) + dfs(p-1, w2);
  } else {
    return dfs(p-1, w);
  }
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N >> K;
  for (int i = 0; i < N; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < N; i++) {
    ll sum = 0;
    for (int j = i; j < N; j++) {
      sum += a[j];
      v.emplace_back(sum);
    }
  }
  sort(v.rbegin(), v.rend());
  cout << dfs(40, v) << endl;

  return 0;
}

Measured memory_bytes: 11244
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define M 1000000007
#define all(a) (a).begin(),(a).end()
#define rep(i,n) reps(i,0,n)
#define reps(i,m,n) for(int i=(m);i<(n);i++)
// 二項係数
ll binomial(ll N, ll K) {
  if(K < 0 || N < K) return 0;
  ll ret = 1;
  for(int i = 1; i <= K; ++i) {
    ret *= N--;
    ret /= i;
  }
  return ret;
}
int main(){
  ll n;cin>>n;
  vector<ll> a(n);
  map<ll,ll> m;
  set<ll> s;
  rep(i,n){
    cin>>a[i];
    m[a[i]]++;
    s.insert(a[i]);
  }
  ll c=0;
  map<ll,ll> mp,mq;
  for(auto au:s){
    ll b=binomial(m[au],2);
    ll d=binomial(m[au]-1,2);
    c+=b;
    mp[au]=b;
    mq[au]=d;
  }
  rep(i,n){
    cout<<c-(mp[a[i]]-mq[a[i]])<<endl;
  }
}

Measured memory_bytes: 32768
#include <iostream>
#include <iomanip>
#include <list>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    list<int> ans;
    repi(i, n, 0)
    {
        int a;
        cin >> a;
        if (n % 2)
        {
            if (i % 2)
            {
                ans.push_back(a);
            }
            else
            {
                ans.push_front(a);
            }
        }
        else
        {
            if (i % 2)
            {
                ans.push_front(a);
            }
            else
            {
                ans.push_back(a);
            }
        }
    }
    for (auto itr = ans.begin(); itr != ans.end(); itr++)
        cout << *itr << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 8448
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 200005;

int n, x, y, d[N], i, j;

int main() {
scanf("%d %d %d", &n, &x, &y);
for (i=1;i<=n;i++) for (j=i+1;j<=n;j++) d[min(j - i, abs(i - x) + abs(j - y) + 1)]++;
for (i=1;i<n;i++) printf("%d\n", d[i]);
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll a,b;
    cin>>a>>b;
    cout <<a*b/(__gcd(a,b))<<endl;
    return 0;
}


Measured memory_bytes: 256
N, C = map(int, input().split())
 
f = [[0] * 100000 for _ in range(C)]
 
for i in range(N):
    s, t, c = map(int, input().split())
    f[c-1][s-1:t] = [1] * (t-s+1)
 
print(max(map(sum, zip(*f))))

Measured memory_bytes: 28532
#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<int>se;
	for(int i=1;i<10;++i)
	{
		for(int j=1;j<10;++j) se.insert(i*j);
	}
	int a;
	cin>>a;
	if(se.count(a)) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 3588
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

#define X first
#define Y second

int main() {
    int n;
    cin>>n;
    rep(jfaefjo,n){
        int x,y,w,h;
        cin>>x>>y>>w>>h;
        int m;
        cin>>m;
        pii cat[200];
        rep(i,m){
            int a,b;
            cin>>a>>b;
            cat[i]=pii(a,b);
        }
        int ans=0;
        rep(i,m){
            if(x<=cat[i].X && cat[i].X<=x+w+1 && y<=cat[i].Y && cat[i].Y<=y+h+1){
                ans++;
            }
        }
        cout<<ans<<endl;
        
        
        
    }
    

    return 0;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <map>
#include <numeric>
#include <cmath>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <complex>
#include <string.h>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <iomanip>
#include <sys/time.h>
#include <tuple>
#include <random>
using namespace std;

#define endl '\n'
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define UNIQ(v) (v).erase(unique((v).begin(), (v).end()), (v).end())

typedef long long ll;
typedef long double ld;
typedef pair<int, string> P;
typedef tuple<int, string, string> T;
typedef complex<double> comp;
typedef vector< vector<ld> > matrix;
struct pairhash {
public:
    template<typename T, typename U>
    size_t operator()(const pair<T, U> &x) const {
	size_t seed = hash<T>()(x.first);
	return hash<U>()(x.second) + 0x9e3779b9 + (seed<<6) + (seed>>2);
    }
};
const int inf = 1e9 + 9;
const ll mod = 1e9 + 7;
const double eps = 1e-8;
const double pi = acos(-1);

int n;

bool solve() {
    while (n > 0) {
        if (n % 10 == 7)
            return true;
        n /= 10;
    }
    return false;
}

void input() {
    cin >> n;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(15);

    input();
    cout << (solve()?"Yes":"No") << endl;
}


Measured memory_bytes: 3016
#include <stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d",&a);  //1回a円
	scanf("%d",&b);  //b円持ってる
	scanf("%d",&c);  //c回聞く
	
	d=b/a;
	
	if(d>c){
		printf("%d",c);
	}
	else{
		printf("%d",d);
	}
	return 0;
}

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

const ll mod = (ll) 1e9+7;

void mult(ll &num, ll t){
    num *= t;
    if(num > mod){
        num %= mod;
    }
}


int main() {
    ll n, m;
    cin >> n >> m;
    if(abs(n-m) > 1){
        cout << 0 << endl;
        return 0;
    }
    ll ans = 1LL;
    if(n == m){
        ans = 2LL;
    }

    while(n--) mult(ans, n+1);
    while(m--) mult(ans, m+1);
    cout << ans << endl;
}


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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
int main(){
    int n,h;
    cin>>n>>h;
    vector<pair<int,int>> v(n);
    int ma = 0;
    for(auto &a : v) {cin>>a.second >> a.first;ma=max(ma,a.second);}
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int count = 0;
    for(int i=0;i<n;++i){
        if(v[i].first > ma){h-=v[i].first;count++;}
        if(h <=0)break;
    }
    if(h >0){
        count += (h+ma-1)/ma;
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 1024
c=input()
d={'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12, 'm': 13, 'n': 14, 'o': 15, 'p': 16, 'q': 17, 'r': 18, 's': 19, 't': 20, 'u': 21, 'v': 22, 'w': 23, 'x': 24, 'y': 25, 'z': 26, 1: 'a', 2: 'b', 3: 'c', 4: 'd', 5: 'e', 6: 'f', 7: 'g', 8: 'h', 9: 'i', 10: 'j', 11: 'k', 12: 'l', 13: 'm', 14: 'n', 15: 'o', 16: 'p', 17: 'q', 18: 'r', 19: 's', 20: 't', 21: 'u', 22: 'v', 23: 'w', 24: 'x', 25: 'y', 26: 'z'}
print(d[d[c]+1])


Measured memory_bytes: 3064
# Sum Difference
from collections import defaultdict
N, X, D = map(int, input().split())
if D < 0:
    X, D = -X, -D

if D == 0:
    Sets = set()
    for i in range(N+1):
        Sets.add(i*X)
    print(len(Sets))
    exit()

# D>0
ans = 0
Mode = defaultdict(list)
for i in range(N+1):
    L = (i*X+D*i*(i-1)//2-i*X % D)//D
    R = (i*X+D*i*(2*N-1-i)//2-i*X % D)//D
    Mode[i*X % D].append((L, 1))
    Mode[i*X % D].append((R+1, -1))
Data = []
for key in Mode.keys():
    Mode[key].sort()
    cnt = 1
    sums = Mode[key][0][0]
    for num, which in Mode[key][1:]:
        Data.append((sums, num, cnt))
        cnt += which
        sums = num
ans = 0
for l, r, v in Data:
    if v > 0:
        ans += r-l
print(ans)

Measured memory_bytes: 153812
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    N = int(input())
    A = list(map(int, input().split()))
    d_0 = [N for _ in range(61)]
    d_1 = [0 for _ in range(61)]
    max_d = 0
    for a in A:
        d = 0
        while a > 0:
            keta = a % 2
            a //= 2
            if keta == 1:
                d_0[d] -= 1
                d_1[d] += 1
            d += 1
        if d > max_d:
            max_d = d
    # print(d_0)
    # print(d_1)
    answer = 0
    for i in range(max_d):
        answer += d_0[i] * d_1[i] * 2 ** i
        answer %= MOD
    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 124304
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define dunk(a) cout << (a) << "\n"
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll a, b, c;
	cin >> a >> b >> c;
	if (c - a - b <= 0) {
		puts("No");
		return 0;
	}
	if (4 * a * b < (c - a - b) * (c - a - b)) puts("Yes");
	else puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
ll gcd(ll a,ll b) {return  b ? gcd(b,a%b) : a;}
const long long INF = 1LL << 60;
const int mod = 1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

int main() {
     char c;
     cin >> c;
     if(c<='Z') cout << 'A' <<endl;
     else cout << 'a' <<endl;
}

Measured memory_bytes: 3632
//ProblemC

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemC

class Solve {
private:

	void solve() {
		int A, B, C, X, Y;
		cin >> A >> B >> C >> X >> Y;

		if (2 * C - A - B >= 0) {
			int x = X;
			int y = Y;
			cout << A * x + B * y << endl;
		}
		else {
			int z = X, y = max(Y - z, 0);
			int t = B * y + 2 * C * z;

			z = Y;
			int x = max(X - z, 0);
			t = min(t, x * A + 2 * C * z);
			cout << t << endl;
		}		
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
#include<string>
#include<iostream>
using namespace std;
int main(){
  string str;
  cin>>str;
  int n;
  cin>>n;
  for(int i=0;i<n;i++){
    string inst;
    int a,b;
    cin>>inst>>a>>b;
    if(inst=="replace"){
      string repla;
      cin>>repla;
      for(int j=a,k=0;j<=b;j++,k++)
	str[j]=repla[k];
    }else if(inst=="reverse"){
      char re[str.size()];
      for(int j=a;j<=b;j++)
	re[j]=str[j];
      for(int j=b,k=a;j>=a;j--,k++)
	str[j]=re[k];
    }else{
      for(int j=a;j<=b;j++){
	cout<<str[j];
	if(j==b)
	  cout<<endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3208
#include<stdio.h>
int ta[100010],nt[200010],to[200010];
int u[100010],d[2][200010],r=0;
int f(int s,int n,int x){
  int i,j;
  u[s]=1;
  for(i=ta[s];i+1;i=nt[i]){
    if(u[to[i]])continue;
    if(j=f(to[i],n+1,x)){
      d[x][r++]=s;
      //printf("!%d\n",s);
      return j;
    }
  }
  //printf("!%d\n",s);
  d[x][r++]=s;
  return n;
}
int main(){
  int n,m,a,b,i,s,t;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)ta[i+1]=-1;
  for(i=0;i<m;i++){
    scanf("%d %d",&a,&b);
    nt[i  ]=ta[to[i+m]=a];
    nt[i+m]=ta[to[i  ]=b];
    ta[b]=i+m;
    ta[a]=i;
  }
  r=0;
  s=f(1,1,0);
  r=0;
  t=f(1,1,1);
  printf("%d\n",s+t-1);
  for(i=0;i<s-1;i++)printf("%d ",d[0][i]);
  while(t--)printf("%d ",d[1][t]);
  printf("\n");
  return 0;
}
  


Measured memory_bytes: 7296
/**
 * The man who codes no bugs
 * McCheng is the man studying Maths in CUHK with IQ200
 * @author McCheng
 */

#include <bits/stdc++.h>
using namespace std;

class BAnOddProblem {
public:
    static constexpr int kStressCount = 0;
    static void generateTest(ostream& test) {}
	void solve(istream& cin, ostream& cout) {
int n;
cin>>n;
int cnt=0;
        for (int i = 0; i < n; i++) {
            long long tmp;
            cin>>tmp;
            if (i%2==0 && tmp%2) cnt++;
        }
        cout<<cnt;
	}
};

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    istream &in(cin);
    ostream &out(cout);
    out << fixed;
    out.precision(20);
    BAnOddProblem solver;
    solver.solve(in, out);
}


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

int main() {
    int n;
    cin >> n;
    long long ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 3 == 0) continue;
        if (i % 5 == 0) continue;
        ans += i;
    }

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

Measured memory_bytes: 3612
'use strict'
const Main = (input) => {
	let xs = input.trim().split(' ');
    let len = xs.length;
    let ans = '';
    for(let i = len-1; i>=0; i--){
    ans += xs[i];
    }
    console.log(ans);
    
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));


Measured memory_bytes: 21064
// template version 1.7

// varibable settings {{{
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

#define int long long
#define INF 1e18
// #define INF 2147483647
#define MOD 1e9+7
#define infile "../test/sample-1.in"
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;
// }}}

int solve(){
  int X,Y,Z,K;cin>>X>>Y>>Z>>K;
  int A[X];
  rep(x, X){
    cin>>A[x];
  }
  int B[Y];
  rep(y, Y){
    cin>>B[y];
  }
  int C[Y];
  rep(z, Z){
    cin>>C[z];
  }
  vi AB;
  rep(i, X){
    rep(j, Y){
      AB.pb(A[i]+B[j]);
    }
  }
  sort(all(AB), greater<int>());
  dump(AB);

  vi res;
  rep(i, min(3002LL, sz(AB))){
    rep(j, Z){
      res.pb(AB[i]+C[j]);
    }
  }
  sort(all(res), greater<int>());
  rep(i, K){
    cout << res[i] << endl;
  }

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 43364
/**
 *   author: Shubham Srivastava
 *   created: 10 August 2019  17:29:53
**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    int a,b;cin>>a>>b;
    cout<<max(max((a-b),a*b),(a+b));
return 0;
}

Measured memory_bytes: 256
S = input()

A = 10 * int(S[0]) + int(S[1])
B = 10 * int(S[2]) + int(S[3])

# print(A)
# print(B)

flag_YYMM = 0
flag_MMYY = 0

if 1 <= A and A <= 12 : 
    flag_MMYY = 1
if 1 <= B and B <= 12 : 
    flag_YYMM = 1
    
if flag_YYMM == 0 and flag_MMYY == 0 : 
    print("NA")
elif flag_YYMM == 0 and flag_MMYY == 1 : 
    print("MMYY")
elif flag_YYMM == 1 and flag_MMYY == 0 : 
    print("YYMM")
elif flag_YYMM == 1 and flag_MMYY == 1 : 
    print("AMBIGUOUS")

Measured memory_bytes: 3064
//
//  main.cpp
//
// https://atcoder.jp/contests/abc127/tasks/abc127_f

#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = long long;
using ull = unsigned long long;

int main(int argc, char* argv[]) {
    int H, W;
    cin >> H >> W;
    struct Cell {
        int hor_len = -1;
        int ver_len = -1;
        pair<int, int> hor_ptr = {-1, -1};
        pair<int, int> ver_ptr = {-1, -1};
        bool is_wall() {
            return hor_ptr == pair<int, int>{-1, -1};
        }
    };
    vector<vector<Cell>> grid;
    for (int x = 0; x <= W; x++) {
        grid.push_back(vector<Cell>(H+1));
    }
    for (int y = 0; y <= H; y++) {
        string line;
        if (y < H) {
            cin >> line;
        }
        for (int x = 0; x <= W; x++) {
            char c = 0;
            if (y < H && x < W) {
                c = line[x];
            }
            if (x == W || y == H || c == '#') {
                if (x > 0 && !grid[x-1][y].is_wall()) {
                    pair<int, int> head = grid[x-1][y].hor_ptr;
                    grid[head.first][head.second].hor_len = x - head.first;
                }
                if (y > 0 && !grid[x][y-1].is_wall()) {
                    pair<int, int> head = grid[x][y-1].ver_ptr;
                    grid[head.first][head.second].ver_len = y - head.second;
                }
            } else {
                if (x > 0 && !grid[x-1][y].is_wall()) {
                    grid[x][y].hor_ptr = grid[x-1][y].hor_ptr;
                } else {
                    grid[x][y].hor_ptr = {x, y};
                }
                if (y > 0 && !grid[x][y-1].is_wall()) {
                    grid[x][y].ver_ptr = grid[x][y-1].ver_ptr;
                } else {
                    grid[x][y].ver_ptr = {x, y};
                }
            }
        }
    }
    int max_val = numeric_limits<int>::min();
    for (int x = 0; x < W; x++) {
        for (int y = 0; y < H; y++) {
            if (grid[x][y].is_wall()) {
                continue;
            }
            int len = -1;
            pair<int, int> hor_head = grid[x][y].hor_ptr;
            len += grid[hor_head.first][hor_head.second].hor_len;
            pair<int, int> ver_head = grid[x][y].ver_ptr;
            len += grid[ver_head.first][ver_head.second].ver_len;
            max_val = max(max_val, len);
        }
    }
    cout << max_val << endl;
}


Measured memory_bytes: 96256
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        StringBuilder sb = new StringBuilder();
        String W = sc.nextLine();
        String buf;
        while(!((buf = sc.nextLine()).equals("END_OF_TEXT"))){
            sb.append(buf.toLowerCase()).append(System.lineSeparator());
        }
        int counter = 0;
        String[] words = sb.toString().split("[ ,.\"\n]");
        for(int i = 0; i < words.length; i++){
            if(words[i].matches(W)) counter++;
        }
        System.out.println(counter);
    }
}



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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  
  int N;
  if ( a == b && b == c){
    N = 1;
  }
  else if ( a == b && a != c ){
    N = 2;
  }
  else if ( b == c && a != b){
    N = 2;
  }
  else if ( a == c && a != b){
    N = 2;
  }
  else {
    N= 3;
  }
  
  cout << N ;
}

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

int v[100000];
int cnteven[100001];
int cntodd[100001];
int main(){
        int n;
        scanf("%d",&n);
        memset(cnteven,0,sizeof(cnteven));
        memset(cntodd,0,sizeof(cntodd));
        for(int i = 0; i < n; i++){
                scanf("%d",v+i);
                if(i % 2 == 0){
                        cnteven[v[i]]++;
                }else{
                        cntodd[v[i]]++;
                }
        }

        int maxodd = 0;
        int maxodd_i = 0;
        for(int i = 1; i <= 100000; i++){
                if(maxodd < cntodd[i]){
                        maxodd = cntodd[i];
                        maxodd_i = i;
                }
        }
        //int maxoddcnt = cntodd[maxodd_i];
        cntodd[maxodd_i] = 0;
        int secondodd = 0;
        int secondodd_i = 0;
        for(int i = 1; i <= 100000; i++){
                if(secondodd < cntodd[i]){
                        secondodd = cntodd[i];
                        secondodd_i = i;
                }
        }

        int maxeven = 0;
        int maxeven_i = 0;
        for(int i = 1; i <= 100000; i++){
                if(maxeven < cnteven[i]){
                        maxeven = cnteven[i];
                        maxeven_i = i;
                }
        }
        //int maxevencnt = cnteven[maxeven_i];
        cnteven[maxeven_i] = 0;
        int secondeven = 0;
        int secondeven_i = 0;
        for(int i = 1; i <= 100000; i++){
                if(secondeven < cnteven[i]){
                        secondeven = cnteven[i];
                        secondeven_i = i;
                }
        }

        if(maxeven_i != maxodd_i){
                printf("%d\n",n/2-maxodd+n/2-maxeven);
        }else{
                if(secondeven >  secondodd){
                        printf("%d\n",n/2-maxodd+n/2-secondeven);
                }else{
                        printf("%d\n",n/2-secondodd+n/2-maxeven);
                }
        }
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int num[55];
int main () {
  int n;
  scanf("%d", &n);
  FOR(i, 1, n) scanf("%d", &num[i]);
  sort(num + 1, num + n + 1);
  ld ans = num[1];
  FOR(i, 2, n) {
    ans = (ans + num[i]) / 2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;
struct edge{ int to,rev; ll cap; };
vector< vector<edge> > G(110);
bool used[110];

#define INF (1LL << 55)

void addEdge(int from, int to, ll cap)
{
  G[from].push_back((edge){to, (int)G[to].size(), cap});
  G[to].push_back((edge){from, (int)G[from].size()-1, 0});
}

ll dfs(int v, int t, ll f)
{
  if(v == t) return f;
  used[v] = true;
  for(int i = 0; i < G[v].size(); i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      ll d = dfs(e.to, t, min(f, e.cap));
      if(d > 0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}

ll maxFlow(int s, int t)
{
  ll flow = 0;
  for(;;){
    memset(used, false, sizeof(used));
    ll f = dfs(s, t, INF);
    if(f == 0) return flow;
    flow += f;
  }
}

int main()
{
  map<string, int> days = {
    {"Sunday",0},
    {"Monday",1},
    {"Tuesday",2},
    {"Wednesday",3},
    {"Thursday",4},
    {"Friday",5},
    {"Saturday",6}
  };
  ll N, W;
  while(cin >> N >> W, N || W){
    G.clear(); G.resize(N + 9);
    int S = N + 7, T = S + 1;
    ll lesson = 0;
    for(int i = 0; i < N; i++){
      ll t; int c;
      cin >> t >> c;
      lesson += t;
      addEdge(S, i, t);
      for(int j = 0; j < c; j++){
	string day;
	cin >> day;
	addEdge(i, N + days[day], INF);
      }
    }
    for(int i = 0; i < 7; i++){
      addEdge(N + i, T, W);      
    }
    cout << (maxFlow(S, T) >= lesson ? "Yes":"No") << endl;
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MAX = 2020;

VI g[MAX];
int A[MAX];

int U[MAX];

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

VI merge(VI& a, VI& b)
{
	VI res;
	res.reserve(SZ(a) + SZ(b));

	a.PB(-INF);

	int ind = 0;
	FOR (i, 0, SZ(a))
	{
		while(ind < SZ(b) && b[ind] > a[i])
		{
			res.PB(b[ind]);
			ind++;
		}

		if (i == SZ(a) - 1) break;
		res.PB(a[i]);
	}

	return res;
}


VI dfs(int x)
{
	U[x] = true;
	VI res;
	FOR (i, 0, SZ(g[x]))
	{
		int to = g[x][i];
		if (U[to]) continue;
		VI v = dfs(to);

		res = merge(res, v);
	}

	reverse(ALL(res));
	res.PB(A[x]);
	reverse(ALL(res));
	return res;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);
	FOR (i, 0, n)
	{
		scanf("%d", &A[i]);
	}

	sort(A, A+n);

	FOR (i, 0, n)
	{
		FOR (j, 0, n)
		{
			if (i == j) continue;
			if (gcd(A[i], A[j]) != 1) g[i].PB(j);
		}
	}

	VI res;

	FOR (i, 0, n)
	{
		if (U[i]) continue;
		VI v = dfs(i);
		res = merge(res, v);
	}

	FOR (i, 0, SZ(res))
	{
		printf("%d ", res[i]);
	}
	printf("\n");


}


Measured memory_bytes: 16000
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll n;
cin>>n;
ll a[n];
map<ll,ll>rensou;
for(ll i=0;i<n;i++){
    cin>>a[i];
    rensou[a[i]]++;
}
ll sum=0;
for(auto f:rensou){
    if(f.second>1){
    sum+=nCr(f.second,2);
    }
}
for(ll i=0;i<n;i++){
    cout<<sum-rensou[a[i]]+1<<endl;
}
}



Measured memory_bytes: 12416
#![allow(non_snake_case)]

#[allow(unused_macros)]
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($r:tt)*) => { let stdin = std::io::stdin(); let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock())); let mut next = move || -> String{ bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect() }; input_inner!{next, $($r)*} }; }
macro_rules! input_inner { ($next:expr) => {}; ($next:expr, ) => {}; ($next:expr, $var:ident : $t:tt $($r:tt)*) => { let $var = read_value!($next, $t); input_inner!{$next $($r)*} };}
macro_rules! read_value { ($next:expr, ( $($t:tt),* )) => { ( $(read_value!($next, $t)),* ) }; ($next:expr, [ $t:tt ; $len:expr ]) => { (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>() }; ($next:expr, chars) => { read_value!($next, String).chars().collect::<Vec<char>>() }; ($next:expr, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

fn main() {
    input!{
        N: usize,
        p:[usize;N]
    }
    let mut p = p;
    p.sort();
    let mut ans = p.pop().unwrap() / 2;
    ans += p.iter().sum::<usize>();
    println!("{}", ans);
}


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

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<=b)
    cout<<a<<endl;
  else
    cout<<a-1<<endl;



  return 0;
}


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

using namespace std;

char ret(int i) {
    if (i < 10) return '0' + i;
    else return 'A' + (i-10);
}

int main(void){
    int n, m, q;
    char c;
    while (cin>>n>>m>>q && n) {
        vector<vector<int> > s(q, vector<int>(n));
        vector<vector<int> > b(q, vector<int>(m));
        
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < n; j++) {
                cin >> c;
                if (i == 0) s[i][j] = c-'0';
                else {
                    if (c == '0' && s[i-1][j] == 1) s[i][j] = 1;
                    else if (c == '1' && s[i-1][j] == 1) s[i][j] = 0;
                    else s[i][j] = c-'0';
                }
            }
            for (int j = 0; j < m; j++) {
                cin >> c;
                b[i][j] = c-'0';
            }
        }
        
        vector<vector<bool> > x(n, vector<bool>(m, true));
        for (int i = 0; i < q; i++) {
            for (int j = 0; j < n; j++) {
                bool f;
                s[i][j] == 1 ? f = true : f = false;
                for (int k = 0; k < m; k++) {
                    if (f) {
                        if (b[i][k] == 0) x[j][k] = false;
                    }
                    else {
                        if (b[i][k] == 1) x[j][k] = false;
                    }
                }
            }
        }
        
        vector<char> ans(m, 'x');
        for (int i = 0; i < m; i++) {
            c = '.';
            for (int j = 0; j < n; j++) {
                if (x[j][i] == 1) {
                    if (c == '.') c = ret(j);
                    else c = '?';
                }
            }
            if (c == '.') c = '?';
            ans[i] = c;
        }
        for (int i = 0; i < m; i++) cout << ans[i];
        cout << endl;
    }
}

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

int main() {
  int n, m;

  cin >> n >> m;

  vector<string> a(n), b(m);

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

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

  for (int i = 0; i <= n - m; i++) {
    for (int l = 0; l <= n - m; l++) {
      int flag = 1;
      for (int j = 0; j < m && flag; j++) {
        for (int k = 0; k < m && flag; k++) {
          if (a[j + i][k + l] != b[j][k]) {
            flag = 0;
            break;
          } else if (j == m - 1 && k == m - 1) {
            cout << "Yes";
            return 0;
          }
        }
      }
    }
  }

  cout << "No";

  return 0;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main() {
	int S;
	cin >> S;
	int a, b, c, d;
	a = S / 1000;
	b = (S - 1000 * a) / 100;
	c = (S - 1000 * a - 100 * b) / 10;
	d = S % 10;
	if (a == b||b==c||c==d) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main
{
	public static void main(String args[])
	{
		Scanner sc=new Scanner(System.in);
        int a=sc.nextInt();
        
        if(a>=30){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
        sc.close();
    }
}

Measured memory_bytes: 35628
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int main(){
  int N;
  void bubble_sort(vector<string> &v, vector<string> &bs, int N);
  bool selection_sort(vector<string> &v, vector<string> &rt, vector<string> &bs, int N);
  
  cin >> N;
  vector<string> s(N), rt(N), bs(N);
  for(int i = 0; i < N; i++) cin >> s.at(i);
  bubble_sort(s, bs, N);
  for(int i = 0; i < N; i++){
    cout << bs.at(i);
    if(i != N-1) cout << " ";
  }
  cout << endl;
  cout << "Stable" << endl;
  bool flag = selection_sort(s, rt, bs, N);
  for(int i = 0; i < N; i++){
    cout << rt.at(i);
    if(i != N-1) cout << " ";
  }
  cout << endl;
  if(flag == true) cout << "Stable" << endl;
  else cout << "Not stable" << endl;
  
  return 0;
}

void bubble_sort(vector<string> &v, vector<string> &bs, int N){
  for(int i = 0; i < N; i++) bs.at(i) = v.at(i);
  for(int i = 0; i < N; i++){
    for(int j = N-1; j > i; j--){
      if(bs.at(j)[1] < bs.at(j-1)[1]) swap(bs.at(j), bs.at(j-1));
    }
  }
}

bool selection_sort(vector<string> &v, vector<string> &rt, vector<string> &bs, int N){
  for(int i = 0; i < N; i++) rt.at(i) = v.at(i);
  for(int i = 0; i < N; i++){
    int minj = i;
    for(int j = i; j < N; j++){
      if(rt.at(j)[1] < rt.at(minj)[1]) minj = j;
    }
    if(i != minj) swap(rt.at(i), rt.at(minj));
  }
  if(rt == bs) return true;
  else return false;
}


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

using namespace std;
using i64 = std::int_fast64_t;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  i64 N, D, A;
  cin >> N >> D >> A;
  vector<i64> X(N), H(N);
  for (int i = 0; i < N; i++) {
    cin >> X[i] >> H[i];
  }

  vector<int> indices(N);
  for (int i = 0; i < N; i++) {
    indices[i] = i;
  }
  sort(indices.begin(), indices.end(),
       [&](int a, int b) { return X[a] < X[b]; });

  vector<i64> NX(N), NH(N);
  for (int i = 0; i < N; i++) {
    NX[i] = X[indices[i]], NH[i] = H[indices[i]];
  }
  X = NX, H = NH;

  i64 res = 0;
  vector<i64> CS(N + 1, 0);
  for (int i = 0; i < N; i++) {
    if (CS[i] < H[i]) {
      int idx = upper_bound(X.begin(), X.end(), X[i] + 2 * D) - X.begin();
      int cnt = (H[i] - CS[i] + A - 1) / A;

      CS[i] += A * cnt;
      CS[idx] -= A * cnt;

      res += cnt;
    }
    CS[i + 1] += CS[i];
  }
  cout << res << '\n';
  return 0;
}


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

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

    long long int N = 0, M = 0, A = 0;
    cin>>N>>M;
    for(int i = 0; i < M; i++){
        cin>>A;
        N -= A;
    }

    if(N < 0)
        cout<<"-1"<<endl;
    else
        cout<<N<<endl;
    return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>
int main(void){
  int a,b;
  int sum=0,count=0;
  scanf("%d",&a);
  scanf("%d",&b);
  
  while(count<2){
  	if(a>=b){
    	sum+=a;
    	a-=1;
  	}else{
    	sum+=b;
    	b-=1;
  	}
    count++;
  }
  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
using namespace std;
int n,k;
int ans=0;
int main()

{
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for (int i=1;i<=n;i++){
		int a;
		cin>>a;
		if (a>=k) ans++;
	}

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

Measured memory_bytes: 256