akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(void){
    int n = 0,rate[9] = {399,799,1199,1599,1999,2399,2799,3199,3200},b[9] = {};
    cin >> n;
    int a[n];
    
    for(int i = 0;i < n;i++)cin >> a[i];
    for(int i = 0;i < n;i++){
        for(int j = 0;j < 8;j++){
            if(a[i] >= rate[8]){
                b[8]++;
                break;
            }
            
            if((rate[j]-399) <= a[i] && a[i] <= rate[j]){
                b[j]++;
                break;
            }
        }
    }
    
    int color = 0;
    for(int i = 0;i < 8;i++){
        if(b[i] > 0){
            color++;
            //cout << rate[i] << ":" << b[i] << endl;
        }
    }
    
    if(color == 0)cout << color+1;
    else cout << color;
    cout << " " << color + b[8] << endl;
}

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

int n,k,tot=0;
int a[100005],visited[100005];

signed main()
{
	cin>>n>>k;
	for (int i=1;i<=n;i++)  cin>>a[i];
	for (int i=1;i<=k;i++)
	{
		int u,v;
		cin>>u>>v;
		
		if (a[u]<=a[v])  visited[u]=1;
		if (a[u]>=a[v])  visited[v]=1;
	}
	for (int i=1;i<=n;i++)
	{
		if (visited[i]==0)  tot++;
	}
	cout<<tot<<endl;
	
	return 0;
}

Measured memory_bytes: 5184
i = list(map(int,input().split()))
w = i[0]
h = i[1]
x = i[2]
y = i[3]
r = i[4]
d1 = r + x
d2 = r + y
if r<= h and r<=w and 0<x<w and 0<y<h and d1<=w and d2<=h:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5596
#include <iostream>

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    if(a > b){
        for(int i = 0;i < a;i++){
        cout << b;
        }
        cout << endl;
    }else{
        for(int i = 0;i < b;i++){
        cout << a;
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int sum = 0;
		for (int i = 0; i < m; i++) {
			sum += Integer.parseInt(sc.next());
		}
		int ans = (n - sum >= 0) ? n - sum : -1;
		System.out.println(ans);
	}

}


Measured memory_bytes: 35016
n = int(input())

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

count = 0
count_b = 0
for i in range(len(a)):
    if a[i] <= b[i]:
        count += -(-(b[i]-a[i])//2)
        if (b[i]-a[i])%2 == 1:
            count_b += 1
    else:
        count_b += (a[i]-b[i])
if count >= count_b:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 4596
#![allow(unused_imports)]

use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::{i32, i64, i128, u32, u64, u128, f64};
use std::io::{stdout, Write, BufWriter};
use std::mem::{swap};
use proconio::marker::{Isize1, Usize1, Bytes, Chars};

#[proconio::fastout]
fn main() {
    proconio::input!{
        h: usize,
        w: usize,
        k: usize,
        mat: [Chars; h],
    }
    let mut ans = 0;
    for a in 0..1 << h {
        for b in 0..1 << w {
            let mut n = 0;
            for i in 0..h {
                if 1 << i & a == 0 {
                    for j in 0..w {
                        if 1 << j & b == 0 && mat[i][j] == '#' { n += 1; }
                    }
                }
            }
            if n == k { ans += 1; }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2208
#include <stdio.h>
int main(void){
    int a,b,r,d;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=((double)a/(double)b)*1;
    printf("%d %d %.5lf",d,r,f);
    return 0;
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
    
using namespace std;
    
#define int long long
#define endl "\n"

template<typename RandomIt>
void ruffleSort(RandomIt first, RandomIt last)
{
    random_device rd;
    mt19937 g(rd());
    shuffle(first, last, g);
    sort(first, last);
}

template<typename Container>
auto outputContainer(const Container & con) 
{
    for(int i = 0; i < con.size(); ++i)
        cout << con[i] << " \n"[i+1==con.size()];
}

template<typename T = int>
auto readVector(const int N) 
{
    vector<T> v(N);
    for(auto & e : v) cin >> e;
    return v;
}


int32_t main() {
    ios_base::sync_with_stdio(false); 
    cin.tie(nullptr);
    
    int n;
    cin >> n;

    int ans = 0;
    for(int i = 1; i <= n; ++i)
        for(int j = 1; j * i < n; ++j)
            ans++;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define v_exists(elem, v) find(v.begin(),v.end(),elem)!=v.end()

using namespace std;

long gcd(long a, long b) {
    return b == 0 ? a : gcd(b, a % b);
}

int main(){

  int N;
  long X;
  cin >> N;
  cin >> X;

  std::vector<long> distances;

  rep(i,N){
    long city;
    cin >> city;
    distances.push_back(abs(X-city));
  }

  cout << accumulate(distances.begin(), distances.end(), distances[0], gcd) << endl;

}


Measured memory_bytes: 1400
#include <iostream>

int main() {
    char b;
    std::cin >> b;

    switch(b) {
        case 'A':
            std::cout << 'T' << std::endl;;
            break;
        case 'T':
            std::cout << 'A' << std::endl;;
            break;
        case 'C':
            std::cout << 'G' << std::endl;;
            break;
        case 'G':
            std::cout << 'C' << std::endl;
            break;
    }
}


Measured memory_bytes: 256
import heapq
n,m = list(map(int,input().split()))
jobs = [[] for _ in range(m)]
for i in range(n):
    d,r = list(map(int,input().split()))
    if d-1 < m:
        jobs[d-1].append(-r)
rewords = 0
heap = []
for i in range(m):
    for reword in jobs[i]:
        heapq.heappush(heap,reword)
    if len(heap) > 0:
        reword = heapq.heappop(heap)
        rewords += -reword
print(rewords)

Measured memory_bytes: 23752
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < n; ++i)
using ll = long long;
const ll MOD = 1000000007;//998244353;
int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n; cin >> n;
   int ans = 0;
   rep(i,n){
      int a; cin >> a;
      if(((i+1)%2==1) && (a%2==1))ans++;
   }
   cout << ans << endl;
}

Measured memory_bytes: 3608
#include "bits/stdc++.h"
using namespace std;

vector<int> progress(vector<int> &lens, const int threshold){
    vector<int> foo;
    for(int i=0; i<(int)lens.size()-1; i++){
        if(lens[i]+lens[i+1]>=threshold){
            for(int j=0; j<i; j++){
                foo.push_back(j);
            }
            for(int j=lens.size()-2; j>=i; j--){
                foo.push_back(j);
            }
            break;
        }
    }
    return foo;
}

int main(){
    int n, m;
    while(scanf("%d%d", &n, &m)!=EOF){
        vector<int> a;
        for(int i=0; i<n; i++){
            int len;
            scanf("%d", &len);
            a.push_back(len);
        }
        vector<int> foo=progress(a, m);
        if(foo.empty()){
            printf("Impossible\n");
        }else{
            printf("Possible\n");
            for(int x : foo){
                printf("%d\n", x+1);
            }
        }
    }
    return 0;
}

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

using namespace std;

int main() {
    double A, B, H, M;
    cin >> A >> B >> H >> M;

    double x1, x2, y1, y2;
    x1 = A * cos((H/12 + M / 720) * 2 * M_PI);
    y1 = A * sin((H/12 + M / 720) * 2 * M_PI);

    x2 = B * cos(M / 60 * 2 * M_PI);
    y2 = B * sin(M / 60 * 2 * M_PI);
    printf("%.12f\n", pow(pow(x1 - x2,2) + pow(y1 - y2, 2), 0.5));
    return 0;
}

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

int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	int t, a;
	t = a = 0;
	t = (A+D-1) / D, a = (C+B-1) / B;
	if (t>a) {
		cout << "Yes";
	}
	else if (t < a) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

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

int main(){

	int x,a,b;

	scanf("%d %d %d",&x,&a,&b);

	if(max(x-a,a-x)<max(x-b,b-x)){
	printf("A\n");
	}
	else{
	printf("B\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, k, a[100000];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    sort(a, a + n);
    int sol = 2e9;
    for (int i = 0; i <= n - k; ++i)
        sol = min(sol, a[i + k - 1] - a[i]);
        
    cout << sol;
}


Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
using P = complex<double>;
using L = pair<P,P>;
#define X real()
#define Y imag()

double dot(P a, P b){ return a.X*b.X + a.Y*b.Y; }
double cross(P a, P b){ return a.X*b.Y - a.Y*b.X; }

double ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 and dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf),abs(a-ss));
}

double ss_dist(L a, L b){
  P af = a.first, as = a.second, bf = b.first, bs = b.second;
  return min({ps_dist(af,b),ps_dist(as,b),ps_dist(bf,a),ps_dist(bs,a)});
}

int main(){
  int Na, Nb;
  cin >> Na;
  vector<P> A, B;
  A.emplace_back(0,0);
  for(int i = 0; i < Na; ++i){
    double x, y;
    cin >> x >> y;
    A.emplace_back(x,y);
  }
  A.emplace_back(1000,0);
  cin >> Nb;
  B.emplace_back(0,1000);
  for(int i = 0; i < Nb; ++i){
    double x, y;
    cin >> x >> y;
    B.emplace_back(x,y);
  }
  B.emplace_back(1000,1000);
  double ans = 1e9;
  for(int i = 0; i <= Na; ++i){
    for(int j = 0; j <= Nb; ++j){
      ans = min(ans,ss_dist(L(A[i],A[i+1]),L(B[j],B[j+1])));
    }
  }
  printf("%.12f\n",ans);
}



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

using namespace std;

int b[111];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 0; i < n - 1; ++i){
        cin >> b[i];
    }
    int s = b[n-2] + b[0];
    for (int i = 0; i < n - 2; ++i){
        s+= min(b[i],b[i+1]);
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;
using namespace std;
//LLONG_MAX = 90^18
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No"); }
void Yes() { cout << "Yes"; }
void No() { cout << "No"; }

int N;
char S[4010];

int r_cnt[4010];
int g_cnt[4010];
int b_cnt[4010];

signed main()
{
	cin >> N;
	cin >> S;

	int r = 0;
	int g = 0;
	int b = 0;
	for (int i = N - 1; i >= 0; i--)
	{
		if (S[i] == 'R') r++;
		if (S[i] == 'G') g++;
		if (S[i] == 'B') b++;
		r_cnt[i] = r;
		g_cnt[i] = g;
		b_cnt[i] = b;
	}

	int sum = 0;

	for (int i = 0; i < N - 2; i++)
	{
		for (int j = i + 1; j < N - 1; j++)
		{
			int sub = j - i;
			int k = j + sub;
			if (k >= N) k = 4000;
			if ((S[i] == 'R' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'R'))
			{
				if (S[k] == 'B')
				{
					sum--;
				}
				sum += b_cnt[j + 1];
			}
			if ((S[i] == 'R' && S[j] == 'B') || (S[i] == 'B' && S[j] == 'R'))
			{
				if (S[k] == 'G')
				{
					sum--;
				}
				sum += g_cnt[j + 1];
			}
			if ((S[i] == 'B' && S[j] == 'G') || (S[i] == 'G' && S[j] == 'B'))
			{
				if (S[k] == 'R')
				{
					sum--;
				}
				sum += r_cnt[j + 1];
			}
		}
	}
	
	cout << sum << endl;
}




Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,k;
    cin>>n>>k;
    vector <int> H(n+1,0);
    for(int i=0;i<n;i++){
        cin>>H[i+1];
    }
    vector <int> res(n+1,INT_MAX);
    res[1]=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=min(n-i,k);j++){
                res[i+j]=min(res[i+j],res[i]+abs(H[i+j]-H[i]));
        }
    }
    cout<<res[n]<<endl;
}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;

ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

ll C(ll n,ll k)
{
  ll x=1,y=1;
  for(int i=1;i<=k;i++)
  {
    x=x*(n-i+1)%mod;
    y=y*i%mod;
  }
  return x * power(y,mod-2) % mod;
}

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

    ll a,b;

    ll n;cin>>n;
    vector<pair<ll,ll>> v(n);
    REP(i,n){
        cin>>a>>b;
        v[i] = {b,a};
    }
    VSORT(v);
    ll acm = 0;
    for(auto p:v){
        acm += p.second;
        if (acm>p.first){
            cout<< "No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int INF = 1000 * 1000 * 1000;
const int N = 100;
int n;
int c[N][N];
int d[N];
bool used[N];

int prim() {
  int i, res = 0;
  for (i=0; i<n; i++) {
    d[i] = INF;
    used[i] = false;
  }

  d[0] = 0;
  while (1) {
    int v = -1;
    for (i=0; i<n; i++)
      if (!used[i] && (v==-1 || (v>=0 && d[i]<d[v])))
        v = i;
  
    if (v==-1) break;
    used[v] = true;
    res += d[v];
    for (i=0; i<n; i++)
      d[i] = min(d[i], c[v][i]);
  }

  return res;
}

int main() {
  int i, j;
  scanf("%d ", &n);
  for (i=0; i<n; i++)
    for (j=0; j<n; j++) {
      scanf("%d ", &(c[i][j]));
      if (c[i][j]==-1) c[i][j] = INF;
    }
  printf("%d\n", prim());
  return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long int n;
  cin>>n;
  if(n == 0)
  {
	  cout<<0;
	  return 0;
  }
  if(n%2 == 1)
  {
	  cout<<0;
	  return 0;
  }
  n = n/2;
  long long int temp = n, c1 = 0, c2 = 1, k = 5;
  while(k <= temp)
  {
    c1 += temp/k;
    k*=5;
  }

  k = 2;
  temp = n;
  while(k<=temp)
    c2 += temp/k, k*=2;
   cout<<min(c1,c2);
}


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

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

typedef long long ll;

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

    string ans = "";
    for(char a : s){
        if(a == 'B'){
            if(ans.size() > 0){
                ans.erase(ans.size()-1, 1);
            }
        }else{
            ans += a;
        }
    } 
    cout << ans << endl;
}

Measured memory_bytes: 256
N,*A = `dd`.split.map &:to_i
dp = (0...N).map{ Array.new(N, 0) }
sp = [0]
(0...N).each{ |x| sp << sp[-1] + A[x] }
(1...N).each{ |d|
  (0...N-d).each{ |x|
    y = x+d
    dpx = dp[x]
    dpy = dp[y]
    mc = dpx[x] + dpy[x+1]
    (x+2..y).each{ |k| c = dpx[k-1] + dpy[k]; mc = c if c < mc }
    dpy[x] = dpx[y] = mc + sp[y+1] - sp[x]
  }
}
p dp[0][-1]


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

int main() {
  string c;
  cin >> c;
  if (c == "a"|| c == "i"|| c == "u"|| c == "e"|| c == "o"){
  	cout << "vowel" << endl;
  }
  else{
  	cout << "consonant" << endl;
  }
}

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


int main() {
	int n;
  	cin>>n;
  	int mymin=1000,mymax=0;
  	
  	for (int i=0;i<n;i++){
      	 int a;cin>>a;
      	
      	mymin=min(a,mymin);
      	mymax=max(a,mymax);
    }
  cout<<mymax-mymin<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) { //最大公約数
  if (b==0) return a;
  else return gcd(b, a%b);
}

ll lcm(ll a, ll b) { //最小公倍数
  return a * b / gcd(a, b);
}

ll digit_sum(ll a){ //10進桁和
  ll ans=0;
  while(a>0){
    ans+=a%10;
    a/=10;
  }
  return ans;
}



int main()
{
  ll n;
  cin>>n;
  ll sum=digit_sum(n);
  if(n%sum==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define sz(v) ((int)(v).size())
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 1000005;
const int mod = 998244353;

lint ipow(lint x, lint p){
	lint ret = 1, piv = x;
	while(p){
		if(p & 1) ret = ret * piv % mod;
		piv = piv * piv % mod;
		p >>= 1;
	}
	return ret;
}

int n;
lint sum[MAXN];

int main(){
	cin >> n;
	lint tot = 0;
	for(int i=0; i<n; i++){
		int x; scanf("%d",&x);
		sum[x] += x;
		tot += x;
		if(sum[x] >= mod) sum[x] -= mod;
	}
	for(int i=1; i<MAXN; i++){
		for(int j=2*i; j<MAXN; j+=i){
			sum[i] += sum[j];
		}
		sum[i] %= mod;
		sum[i] = sum[i] * sum[i] % mod;
		// sum[i] = (i의 배수들의 합)^2
		// sum
	}
	for(int i=MAXN-1; i>=1; i--){
		for(int j=2*i; j<MAXN; j+=i){
			sum[i] += mod - sum[j]; 
			sum[i] %= mod;
		}
	}
	lint ret = 0;
	for(int i=1; i<MAXN; i++){
		ret += sum[i] * ipow(i, mod - 2);
		ret %= mod;
	}
	ret += mod - tot % mod;
	ret %= mod;
	ret *= ipow(2, mod - 2);
	ret %= mod;
	cout << ret << endl;
}


Measured memory_bytes: 8192
#include<iostream>
#include<cstdio>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<map>
#include<stack>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<sstream>


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

#define PII pair<int,int>
#define PP pair< int,PII >

#define ci(x) (x-'0')

using namespace std;

int main(){
	
	int n;
	char str[10];
	scanf("%d", &n);
	
	rep(i,n){
		printf("Case %d:\n",i+1);
		int s;
		scanf("%d", &s);
		rep(j,10){
			s = s*s;
			sprintf(str,"%08d", s);
			s = ci(str[2])*1000+ci(str[3])*100+ci(str[4])*10+ci(str[5])*1;
			printf("%d\n",s);
		}
	}
	return 0;
}

Measured memory_bytes: 1208
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	int num;
	cin >> num;
	int a,v,maxa=0,maxv=0;
	for(int i=0;i<num;i++){
		cin >> a >> v;
		if(i==0) {
			maxa = a; maxv = v;
		}
		if(maxv < v){
			maxv = v; maxa = a;
		}
		if(maxv == v){
			if(maxa>a){
				maxv = v; maxa = a;
			}
		}
	}
	cout << maxa << " " << maxv << endl;
}

Measured memory_bytes: 1164
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <map>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 50
int N, M;
int K[Max];
int A[Max][Max];

int main(int argc, const char * argv[]) {
    N = inputValue();
    M = inputValue();
    rep(i, N) {
        K[i] = inputValue();
        inputArray(A[i], K[i]);
    }
    int ans = 0;

    rep(i, K[0]) {
        int allok = 1;
        repd(j, 1, N) {
            int isng = 1;
            rep(k, K[j]) {
                if (A[j][k] == A[0][i]) { 
                    //printf("%d,%d,%d\n", i, j, k);
                    isng = 0;
                    break;
                }
            }
            if (isng) {
                allok = 0;
                break;
            }
        }
        if (allok) ans+=1;
    }

    output(ans);

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    ll n,ans = 0,sum = 0;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        sum += a[i];
        sum %= mod;
    }
    for (int i = 0; i < n; ++i) {
        sum -= a[i];
        
        if(sum < 0) sum += mod;
        
        ans += sum*a[i];
        ans %= mod;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4780
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cctype>
#include<cmath>
#include<cassert>
#include<iostream>
#include<string>
#include<vector>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define FOREACH(i,c) for(__typeof((c).begin())i = (c).begin();i!=(c).end(); ++i)

//v4
int cond = 1;
string to_string(char c){return'\''+string(1,c)+'\'';}
string to_string(const string&s){return'"'+s+'"';}
string to_string(const char*s){return to_string((string)s);}
string to_string(bool b){return(b?"true":"false");}
string to_string(std::vector<bool>::reference&r){return to_string((bool)r);}
template<typename A,typename B>string to_string(const pair<A,B>&p){return"("+to_string(p.first)+", "+to_string(p.second)+")";}
template<typename A>string to_string(A v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x);}r+="}";return r;}
template<typename A,typename B>string to_string(map<A,B>v){int f=1;string r="{";for(auto x:v){if(!f){r+=", ";}f=0;r+=to_string(x.first)+" -> "+to_string(x.second);}r+="}";return r;}
void __db(int i,const vector<string>&s){cerr<<endl;}
template<typename T,typename... A>void __db(int i,const vector<string>&s,T t,A... a){if(i)cerr<<", ";cerr<<s[i]<<" = "<<to_string(t);__db(i+1,s,a...);}
string __cl(string s){while(!s.empty()&&s[0]==' ')s.erase(0,1);while(!s.empty()&&s.back()==' ')s.pop_back();return s;}
vector<string>__vars(string s){vector<string>r;s+=",";string n="";int d=0;for(auto x:s)if(x==','&&d==0){if(!n.empty())r.push_back(__cl(n));n="";}else{n+=x;if(x=='('||x=='[')d++;else if(x==')'||x==']')d--;}return r;}
#define DB(...){if(cond){cerr<<"Line:"<<__LINE__<<" ";__db(0,__vars(#__VA_ARGS__),__VA_ARGS__);}}

int main() {
  int n;
  scanf("%d", &n);
  int minel = 1000000000;
  int r = 0;
  REP(i, n) {
    int x;
    scanf("%d", &x);
    minel = min(x, minel);
    if (x == minel) r++;
  }
  printf("%d\n", r);

  return 0;
}

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

using namespace std;

int f(int n, vector<pair<int, int>> queries) {

    int min = INT_MIN;
    int max = INT_MAX;
    for (int i = 0; i < queries.size(); i++) {
        if (min < queries[i].first) {
            min = queries[i].first;
        }
        if (max > queries[i].second) {
            max = queries[i].second;
        }
    }

    if (max - min < 0) {
        return 0;
    }

    return max - min + 1;
}

int main() {

    int n, m;
    cin >> n >> m;

    vector<pair<int, int>> queries;
    for (int i = 0; i < m; i++) {
        pair<int, int> p;
        cin >> p.first;
        cin >> p.second;
        queries.push_back(p);
    }

    int result = f(n, queries);
    cout << result << endl;

    return 0;
}


Measured memory_bytes: 1908
#include <iostream>
#include <iomanip> // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple> // get<n>(xxx)
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set> // S.insert(M);
// if (S.find(key) != S.end()) { }
// for (auto it=S.begin(); it != S.end(); it++) { }
// auto it = S.lower_bound(M);
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib> // atoi(xxx)
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.
// insert #if<tab> by my emacs. #if DEBUG == 1 ... #end

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

string S, T;



int main () {
  cin >> S >> T;
  int N = S.size();
  int M = T.size();
  vector<string> V;
  for (auto i = 0; i <= N - M; ++i) {
    string X = S;
    for (auto j = 0; j < M; ++j) {
      X[i + j] = T[j];
    }
    for (auto i = 0; i < N; ++i) {
      if (X[i] == '?') X[i] = 'a';
    }
    // cerr << X << endl;
    V.push_back(X);
  }
  sort(V.begin(), V.end());
  for (auto X : V) {
    bool ok = true;
    for (auto i = 0; i < N; ++i) {
      if (S[i] != '?' && S[i] != X[i]) ok = false;
    }
    if (ok) {
      cout << X << endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE" << endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main() {
	int n;
	int*a;

	cin >> n;

	a = new int[n];

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

	for (int i = 0; i < n; i++) {
		if (i)cout << " ";
		cout << a[i];
	}
	cout << endl;

	delete[]a;

	return 0;
}

Measured memory_bytes: 1196
N, P = map(int, input().split())
S = [int(_) for _ in list(input())]
if P == 2 or P == 5:
    ans = 0
    for n in range(N):
        if S[n] % P == 0:
            ans += n + 1
    print(ans)
else:
    S = [(S[n] * pow(10, N - n - 1, P)) % P for n in range(N)]
    S.reverse()
    T = [0]
    for s in S:
        T.append((T[-1] + s) % P)
    lst = {i: 0 for i in range(P)}
    ans = 0
    for t in T:
        ans += lst[t]
        lst[t] += 1
    print(ans)


Measured memory_bytes: 69576
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		if (n % 2 == 0) {
		    System.out.println(n / 2 - 1);
		} else {
		    System.out.println(n / 2);
		}
	}
}


Measured memory_bytes: 21844
import java.util.Scanner;
class Main {
	public static void main(String args[]){
		int[][] timeCard = new int[3][6];
		Scanner scan = new Scanner(System.in);
		Main app = new Main();
		while(scan.hasNext()){
			app.input(timeCard,scan);
			app.workTime(timeCard);
			app.output(timeCard);
		}
	}
	
	public void input(int[][] timeCard,Scanner scan){
		for(int i=0;i<3;i++){
			String str = scan.nextLine();
			String[] splitLine = str.split(" ");
			for(int j=0;j<6;j++){
				timeCard[i][j] = Integer.parseInt(splitLine[j]);
			}
		}
	}
	
	public void workTime(int[][] timeCard){
		for(int i=0;i<3;i++){
			for(int j=2;j>=0;j--){
				if(timeCard[i][j] > timeCard[i][j+3]){
					timeCard[i][j+2]--;
					timeCard[i][j+3] += (60-timeCard[i][j]);
				}else{
					timeCard[i][j+3] -= timeCard[i][j];
				}
			}
		}
	}
	
	public void output(int[][] timeCard){
		for(int i=0;i<3;i++){
			System.out.println(timeCard[i][3]+" "+timeCard[i][4]+" "+timeCard[i][5]);
		}
	}
}

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

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


Measured memory_bytes: 256
from collections import Counter
S = str(input())
N = len(S)

#smod = [int(S[i:])%2019 for i in range(N)]
smod = [0]
tmod = 0
keta = 1
for i in range(N):
    temp = tmod + int(S[(N-1)-i])*keta
    #print(temp)
    tmod = temp%2019
    smod.append(tmod)
    keta = keta*10%2019


cmod = Counter(smod)
#print(cmod)

ans = 0
for i in cmod.values():
    ans += i*(i-1)/2
print(int(ans))
        


Measured memory_bytes: 16608
/*
ID: zhaowei10
TASK:
LANG: C++14
*/
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

using namespace __gnu_cxx;
using namespace __gnu_pbds;
using namespace std;

#ifdef LOCAL
#include <debug.h>
#else
#define debug(...) 0
#endif

#define eb emplace_back

using ll = long long;
using ld = long double;
using ii = pair<int, int>;
using vi = vector<int>;
using vii = vector<ii>;
using vc = vector<char>;
using vb = vector<bool>;
using vll = vector<ll>;

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

#ifdef LOCAL
  freopen("test.in", "r", stdin);
  freopen("test.out", "w", stdout);
#else
#endif

  int n;
  cin >> n;
  vll x(n);
  ll ans = 1;
  const ll lim = 1e18;
  for (int i = 0; i < n; ++i) {
    cin >> x[i];
    if (!x[i]) {
      cout << 0;
      return 0;
    }
  }
  for (int i = 0; i < n; ++i) {
    ll next = ans * x[i];
    if (next > lim || next < ans) {
      cout << -1;
      return 0;
    }
    ans = next;
  }

  cout << ans;
}


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



Measured memory_bytes: 2120
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

def max(a,b)
  return a>b ? a : b
end
N=gets.to_i
A=get_i
find={}
A.each do|a|
  find[a]=0 if find[a]==nil
  find[a]+=1
end
a=[]
find.each do|key,val|
  if val>=4
      a.push(key)
      a.push(key)
  elsif val>=2
      a.push(key)
  end
end
n=a.size
ans=0
a.sort!{|x,y| y<=>x}
ans=a[0]*a[1] if n>1
puts ans

Measured memory_bytes: 16012
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <cassert>
#include <climits>

using namespace std;

typedef long long lint;

const double EPS = 1e-10;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
const int INF = 1001001001;
const lint INFLL = 1001001001001001001ll;

#define zclear(a) memset((a), 0, sizeof(a))
#define mclear(a) memset((a), -1, sizeof(a))

#define show(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int a[1000000];
vector<int> cmp;

int main()
{
	int N, Q;
	
	scanf("%d %d", &N, &Q);
	
	for (int i = 0; i < N; i++){
		scanf("%d", a + i);
		cmp.push_back(a[i]);
	}
	
	sort(cmp.begin(), cmp.end());
	
	multiset<int> ms;
	multiset<int>::iterator it;
	for (int i = 0; i < Q; i++){
		char q[1024];
		int arg;
		scanf("%s %d", q, &arg);
		
		if (q[0] == 'A'){
			ms.insert(a[--arg]);
		}
		else if (q[0] == 'R'){
			it = ms.lower_bound(a[--arg]);
			ms.erase(it);
		}
		else {
			int lo = 0, hi = 1000000001;
			
			while (lo != hi){
				int mid = lo + hi >> 1;
				int prev = 0;
				int fail = 0;
				
				for (it = ms.begin(); it != ms.end(); it++){
					int pos = lower_bound(cmp.begin(), cmp.end(), *it - mid) - cmp.begin();
					fail += max(pos - 1 - prev + 1, 0);
					prev = upper_bound(cmp.begin(), cmp.end(), *it) - cmp.begin();
				}
				fail += max(N - 1 - prev + 1, 0);
				if (fail <= arg) hi = mid;
				else lo = mid + 1;
			}
			if (lo != 1000000001) printf("%d\n", lo);
			else printf("NA\n");
		}
	}
	
	return (0);
}

Measured memory_bytes: 9092
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}
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 long long INF=1LL << 60;
long long a,b;
long long dp[100200][110];
long long w[110],v[110];

int main() {
    int a,b;
    cin>>a>>b;
    vector<vector<int>> vec(b);
    rep(i,b){
        int k;
        cin>>k;
        vec.at(i).resize(k);
        rep(j,k){
            cin>>vec.at(i).at(j);
            vec.at(i).at(j)--;
        }
    }
    vector<int> p(b);
    rep(i,b){
        cin>>p.at(i);
    }
    int ans=0;
    for(int bit=0;bit<(1<<a);bit++){
        bool flag=true;
        for(int i=0;i<b;i++){
            int c=0;
            for(int j:vec.at(i))
                if(bit&(1<<j)){
                    ++c;
                    //bitflagがtrueの時の動作
                }
            c%=2;
            if(c!=p.at(i)){
                flag=false;
            }
        }
        if(flag){
            ans++;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
template<class T> inline bool chmin(T &a, T b) {if (a>b) {a = b; return 1;} return 0;};
template<class T> inline bool chmax(T &a, T b) {if (a<b) {a = b; return 1;} return 0;};
typedef long long int ll;
const long long INF = 1LL << 60;

class UnionFind {
public:
    vector < ll > par; // 各元の親を表す配列
    vector < ll > siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};


int main(){
  int N, M; cin >> N >> M;
  set<pii> s;
  rep(i,M){
    int a, b; cin >> a >> b;
    a--, b--;
    if (a>b) swap(a,b);
    s.insert({a,b});
  }
  UnionFind uf(N);
  for (auto p : s){
    int a = p.first, b = p.second;
    uf.merge(a,b);
  }

  ll ans = 0;
  rep(i,N){
    chmax(ans, uf.size(i));
  }
  cout << ans << endl;

  // cout << fixed << setprecision(10);
  
  return 0;
}

Measured memory_bytes: 15660
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int h = scanner.nextInt();
        final int w = scanner.nextInt();
        final int[] counts = new int[26];
        for (int i = 0; i < h; i++) {
            final String a = scanner.next();
            for (int j = 0; j < w; j++) {
                counts[a.charAt(j) - 'a']++;
            }
        }

        if (h % 2 == 0 && w % 2 == 0) {
            if (Arrays.stream(counts).allMatch(i -> i % 4 == 0)) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else if (h % 2 == 1 && w % 2 == 1) {
            final boolean res = Arrays.stream(counts).filter(i -> i % 2 == 1).count() == 1 &&
                Arrays.stream(counts).map(i -> i % 2 == 0 ? i : (i - 1)).filter(i -> i % 4 != 0).count() <= (h + w - 2) / 2;
            if (res) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            final boolean res = Arrays.stream(counts).allMatch(i -> i % 2 == 0) &&
                Arrays.stream(counts).filter(i -> i % 2 == 0 && i % 4 != 0).count() <= (h % 2 == 0 ? h : w) / 2;
            if (res) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }
    }
}


Measured memory_bytes: 34472
#include <bits/stdc++.h>
using namespace std;
char ma[5] = {'M', 'A', 'R', 'C', 'H'};

int main(){
	int n;
	long long out = 0;
	string str;
	map<char, long long> m;
	cin >> n;

	for( int i = 0; i < n; ++i ){
		cin >> str;
		if( str[0] == 'M' ||str[0] == 'A' ||str[0] == 'R' ||str[0] == 'C' ||str[0] == 'H' ){
			m[str[0]]++;
		}
	}

	for( int i = 0; i < 3; ++i ){
		for( int j = i+1; j < 4; ++j ){
			for( int k = j+1; k < 5; ++k ){
				out += m[ma[i]]*m[ma[j]]*m[ma[k]];
			}
		}
	}
	cout << out << endl;
	return 0;
}

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

int main(){
    ll n,l;
    cin>>n>>l;
    vector<string> s(n);
    for(ll i=0;i<n;i++) cin>>s[i];
    sort(all(s));
    for(ll i=1;i<n;i++) s[0]+=s[i];
    cout<<s[0]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
#define mod 998244353
#define maxn 330
using namespace std;
inline int getint(){
    char c=getchar();int x=0;bool p=0;
    while((c>'9'||c<'0')&&c!='-')c=getchar();
    if(c=='-')p=1,c=getchar();
    while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();
    if(p)x=-x;return x;
}
inline int qpower(int x,int k){
	int ans=1;
	for(;k;k>>=1,x=1ll*x*x%mod)if(k&1)ans=1ll*ans*x%mod;
	return ans;
}
int n,m,cnt,a[maxn][maxn],b[maxn][maxn];
int main(){
	memset(b,0,sizeof(b));
	n=getint(),m=getint();
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	a[i][j]=getint();
	cnt=0;
	for(int i=1;i<=n;++i)
	for(int j=1;j<=m;++j)
	if(a[i][j]){
		if(!b[j][j]){
			++cnt;
			for(int k=j;k<=m;++k)b[j][k]=a[i][k];
			break;
		}
		else for(int k=j;k<=m;++k)a[i][k]^=b[j][k];
	}
	int ans=qpower(2,n)-qpower(2,n-cnt);
	if(ans<0)ans+=mod;
	ans=1ll*ans*qpower(2,m-1)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}
        static String getStr(){return sc.next();}
        static int getInt(){return sc.nextInt();}
        static Long getLong(){return sc.nextLong();}
        static boolean isNext(){return sc.hasNext();}
        public static void main(String[] args){
          int N = getInt();
          long output = getLong();
          while(isNext()){
            output = lcm(getLong(),output);
          }
          myout(output);
          
          //myout(lcm(10,new Long("1000000000000000000")));
          //myout(gcd(10,new Long("1000000000000000000")));
        }
        //便利メソッド追加枠ここから
public static long lcm(long m, long n) {return Math.max(m,n) / gcd(m, n) * Math.min(m,n);}
  public static long gcd(long m, long n) {return n != 0 ? gcd(n, m % n) : m;}
        //便利メソッド追加枠ここまで
}


Measured memory_bytes: 23636
#include<stdio.h>


int main()
{
    int a,b,c,d;

    scanf("%d %d %d",&a,&b,&c);
    d=b/a;

    if(d>=c)
    {
        printf("%d\n",c);
    }
    else if(d<c)
    {
        printf("%d\n",d);
    }
    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using vc = vector<char>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;} 
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        string S;
        cin >> S;
        string ans(len(S), 'x');
        cout << ans << endl;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
using namespace std;
 
#define ll long long
 
int main() {
	ll tower[1000];
	for (int i = 0; i < 999; i++) {
		tower[i] = (1 + (i + 1)) * (i + 1) / 2;
	}
	ll a, b, d, ans;
	cin >> a >> b;
	d = b - a;
	ans = tower[d - 1] - b;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n, s0, s1, g0, g1 = gets.split.map(&:to_i)
s = gets.chomp

#s[s1-1] = 'f'
#s[g1-1] = 'g'
#p [s[s0,g0-s0],s[s1,g1-s1]]
if s[s0,g0-s0].index("##") || s[s1,g1-s1].index("##")
  
  puts "No"
  exit
end

f = s[s1-2, g1-s1+3]
#p f#
if g0 > g1 && ! f.index("...")
  puts "No"
  exit
end

puts "Yes"

Measured memory_bytes: 2556
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e9 + 7;
const ll MOD = 1e9 + 7;

int n;
string table = "01235789";
string ans;

int main(){
	while (cin >> n&&n){
		ans = "";
		while (n / 8 > 0){
			int num = n % 8;
			ans += table[num];
			n /= 8;
		}
		ans += table[n];
		reverse(ALL(ans));
		cout << ans << endl;
	}
}

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

using namespace std;

#define ll long long
#define ull unsigned long long

int dp[100005][3];

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

    int n, k, r, s, p;
    cin >> n >> k >> r >> s >> p;
    string t;
    cin >> t;
    int ans = 0;
    for (int i = 0; i < k; i++) {
        int pre, pp = -1;
        vector<int> dp(3, 0);
        for (int j = i; j < n; j += k) {
            if (t[j] == 's') {
                if (pp != 0) {
                    dp[0] = max({dp[0], dp[1], dp[2]}) + r;
                    pp = 0;
                }
                else {
                    dp[0] = max(dp[0], max(dp[1], dp[2]) + r);
                    pp = -1;
                }
            }
            if (t[j] == 'p') {
                if (pp != 1) {
                    dp[1] = max({dp[0], dp[1], dp[2]}) + s;
                    pp = 1;
                }
                else {
                    dp[1] = max(dp[1], max(dp[0], dp[2]) + s);
                    pp = -1;
                }
            }
            if (t[j] == 'r') {
                if (pp != 2) {
                    dp[2] = max({dp[0], dp[1], dp[2]}) + p;
                    pp = 2;
                }
                else {
                    dp[2] = max(dp[2], max(dp[0], dp[1]) + p);
                    pp = -1;
                }
            }
        }
        ans += max({dp[0], dp[1], dp[2]});
    }
    cout << ans << '\n';
}

Measured memory_bytes: 512
#include <stdio.h>
long long all[30000];
long long max=999999999;
int allcount=0;
int check(long long num)
{
	int have3=0;
	int have5=0;
	int have7=0;
	long long now=num;
	while(now!=0)
	{
		if(now%10==3)
		{
			have3=1;
		}
		else if(now%10==5)
		{
			have5=1;
		}
		else
		{
			have7=1;
		}
		now/=10;
	}
	if(have3==1&&have5==1&&have7==1)
	{
		return 1;
	}
	return 0;
}
void getall(long long now)
{
	if(now>max)
		return;
	if(check(now)==1)
	{
		all[allcount]=now;
		allcount++;
	}
	getall(now*10+3);
	getall(now*10+5);
	getall(now*10+7);
}
int cmp(const void*a,const void*b)
{
	long long la=*(long long*)a;
	long long lb=*(long long*)b;
	if(la>=lb)
		return 1;
	else
		return -1;
}
int main()
{
	int i,j;
	long long time;
	getall(3);
	getall(5);
	getall(7);
	qsort(all,allcount,sizeof(all[0]),&cmp);
	scanf("%lld",&time);
	for(i=0;i<allcount;i++)
	{
		if(all[i]<=time)
		{
			continue;
		}
		else
		{
			break; 
		}
	}
	printf("%d",i);
	return 0;
} 

Measured memory_bytes: 508