akhauriyash/Code-Regression huggingface dataset:
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;

// vector set 等
#include <map>
#include <set>
#include <vector>

//マクロ
// forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
// Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
// FORAは範囲for文(使いにくかったら消す)
#define REP(i, n) for (ll i = 0; i < ll(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto& i : I)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size())
//定数
#define INF 1000000000000  // 10^12:∞
#define MOD 1000000007     // 10^9+7:合同式の法
#define MAXR 100000        // 10^5:配列の最大のrange
//略記
#define PB push_back  //挿入
#define MP make_pair  // pairのコンストラクタ
#define F first       // pairの一つ目の要素
#define S second      // pairの二つ目の要素

// 負の数にも対応した % 演算
ll mod(ll x) {
  ll res = x % MOD;
  while (res < 0) res += MOD;
  return res;
}

ll mpow(ll x, ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * x % MOD;
    x = x * x % MOD;
    n >>= 1;
  }
  return res;
}
// a^{-1} mod を計算する
ll minv(ll a) { return mpow(a, MOD - 2); }

signed main() {
  //入力の高速化用のコード
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<ll> v = vector<ll>(2020);

  ll s = 0;
  cin >> s;
  v[1] = 0;
  v[2] = 0;
  v[3] = 1;
  v[4] = 1;
  v[5] = 1;
  FOR(i, 6, s) {
    v[i] = 1;
    FOR(j, 3, i - 3) { v[i] = mod(v[i] + v[i - j]); }
  }
  // FOR(i, 1, s) cout << v[i] << endl;

  cout << v[s] << endl;

  return 0;
}

Measured memory_bytes: 3524
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#define INF 1e+9
#define mp make_pair
using namespace std;

struct edge{ int to,comp,cost; };
typedef pair<int,int> VC;//vertex,company
typedef pair<int,VC> P;//cost

int main(){
	int n,m;
	map<VC,int> d;
	set<int> cs[100000];
	map<VC,vector<edge>> G;
	cin >> n >> m;
	for(int i = 0;i < m;i++){
		int a,b,c;
		cin >> a >> b >> c; a--;b--;c--;
		G[mp(a,c)].push_back({b,c,0});
		G[mp(b,c)].push_back({a,c,0});
		cs[a].insert(c);
		cs[b].insert(c);
	}
	for(int i = 0;i < n;i++){
		for(auto it = cs[i].begin();it != cs[i].end();it++){
			d[mp(i,*it)] = INF;
			G[mp(i,*it)].push_back({i,-1,0});
			G[mp(i,-1)].push_back({i,*it,1});
		}
		d[mp(i,-1)] = INF;
	}
	d[mp(0,-1)] = 0;
	priority_queue<P,vector<P>,greater<P> > que;
	que.push(mp(0,mp(0,-1)));
	while(!que.empty()){
		P p = que.top();que.pop();
		int cost = p.first,v = p.second.first,comp = p.second.second;
		if(d[mp(v,comp)] < cost) continue;
		for(int i = 0;i < G[mp(v,comp)].size();i++){
			edge e = G[mp(v,comp)][i];
			if(d[mp(e.to,e.comp)] > d[mp(v,comp)] + e.cost){
				d[mp(e.to,e.comp)] = d[mp(v,comp)] + e.cost;
				que.push(mp(d[mp(e.to,e.comp)],mp(e.to,e.comp)));
			}
		}
	}
	if(d[mp(n - 1,-1)] == INF) cout << -1 << endl;
	else cout << d[mp(n - 1,-1)] << endl;
	return 0;
}

Measured memory_bytes: 117236
#include<stdio.h>
#include<math.h>

int main(){
  long long q,h,s,d;
  scanf("%lld%lld%lld%lld",&q,&h,&s,&d);
  long long n;
  scanf("%lld",&n);
  long long min1=0;
  if(4*q<=2*h&&4*q<=s){
    min1=4*q;
  }
  else if(2*h<=4*q&&2*h<=s){
    min1=2*h;
  }
  else{
    min1=s;
  }

  if(n%2==0){
    if(2*min1<=d){
      printf("%lld\n",n*min1);
    }
    else{
      printf("%lld\n",d*n/2);
    }
  }
  else{
    if(2*min1<=d){
      printf("%lld\n",min1*n);
    }
    else{
      printf("%lld\n",min1+d*(n-1)/2);
    }
  }
  
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int a;
string s;

signed main() {
    cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()


int main(){
    string s;
    cin >> s;
    ll w;
    cin >> w;
    for(ll i = 0; i < s.size(); i += w){
        cout << s.at(i);
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
def main():
    INF = 10**9
    N,K = map(int,input().split())
    h = list(map(int,input().split()))
    dp = [INF]*N
    dp[0] = 0
    for i in range(N):
        for j in range(1,K+1):
            if i-j >= 0:
                dp[i] = min(dp[i],abs(h[i]-h[i-j])+dp[i-j])
    print(dp[N-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 52448
#include <iostream>

using namespace std;

int main(){
  int n;
  while(cin >> n){
    int res = 0;
    for(int i=0;i<10000;i++){
       int s = 0;
       for(int t=i;t;t/=10) s += t%10;
       if(s==n) res++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 0
import sys
#input = sys.stdin.buffer.readline
 
def main():
    H,W,K = map(int,input().split())
    a = S = [list(map(int, list(input()))) for _ in range(H)]
    
    ans = 10**6
    for i in range(1<<H-1):
        cut,count = [-1],0
        for j in range(H-1):
            if (i>>j)&1 != 0:
                count += 1
                cut.append(j)
        cut.append(H-1)
        l = len(cut)-1
        use = [[0 for _ in range(W)] for _ in range(l)]
        for x in range(l):
            up,down = cut[x],cut[x+1]
            for y in range(up+1,down+1):
                for z in range(W):
                    use[x][z] += a[y][z]

        bl,yorn = [0 for _ in range(l)],True
        for right in range(W):
            st = [0 for _ in range(l)]
            for x in range(l):
                st[x] += use[x][right]
            if max(st) > K:
                yorn = False
                break
            else:
                for x in range(l):
                    bl[x] += st[x]
                if max(bl) > K:
                    count += 1
                    bl = st
        if yorn:
            ans = min(ans,count)
    
    print(ans)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 54620
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;

int main(){
    int n,k;
    cin >> n >> k;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    
    ll ans = INF;
    for(int i = 0; i < (2<<n); i++){
        ll height = a[0];
        ll cnt = 0;
        ll k_num = 0;
        for(int j = 0; j < n-1; j++){
            if(((i>>j)&1) == 1) k_num++;
        }
        if(k_num != k-1) continue;

        for(int j = 1; j < n; j++){
            if(((i>>(j-1))&1) == 0) {
                height = max(height, a[j]);
                continue;
            }
            if(height >= a[j]){
                cnt += (height+1)-a[j];
                height++;
            } else {
                height = a[j];
            }
        }
        ans = min(ans, cnt);
    }

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<array>
using namespace std;
int main(){
        array<int,3>ar;
        for(auto&e:ar){
                scanf("%d",&e);
        }
        sort(ar.begin(),ar.end());
        printf("%d %d %d\n",ar[0],ar[1],ar[2]);
        return 0;
}

Measured memory_bytes: 1188
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let (n,m) = {
        let t = read_vec::<i64>();
        (t[0],t[1])
    };
    let pmym = read_vec2::<i64>(m as u32);
    let mut test = vec!["".to_string();m as usize];
    let mut sub:Vec<_> = pmym.clone().into_iter().enumerate().map(|x|(x.1,x.0)).collect();
    // sub.sort_by_key(|k| k.1[1]);
    sub.sort();
    // println!("{:?}",sub);
    let mut b_key = 0;
    let mut c = 0;
    for (v,k) in sub{
        if b_key != v[0] {
            c = 1;
        }else {
            c += 1;
        }
        test[k] = format!("{:>06}{:>06}",v[0],c);
        b_key = v[0]
    }
    for v in test{
        println!("{}",v);
    }
}

Measured memory_bytes: 22780
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

#define P 1000000007

int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int main(void){
	int n=nextint();
	int m=nextint();
	long a=0, b=0;
	for(int i=0; i<n; i++){
		long x=nextint();
		a+=(i*2-n+1)*x%P;
	}
	for(int i=0; i<m; i++){
		long y=nextint();
		b+=(i*2-m+1)*y%P;
	}
	a = (a%P+(long)n*P)%P;
	b = (b%P+(long)m*P)%P;
	int ans = a*b%P;
	printf("%d\n", ans);
}


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

int checkdigit(int x){
    int n = 0;
    while(x > 0){

        x /= 10;
        n++;

    }

    return n;

}

int main(){
    int a,b,adigit;
    double m;
    cin >> a >> b;

    adigit = checkdigit(b);

    for(int i = 1;i <= adigit;i++){
        a *= 10;
    }

    a += b;

    m = sqrt(a);
    
    double j = 0;

    while(j < m)
        j++;

    if((m-j)==0)
        cout << "Yes" << endl;

    else
        cout << "No" << endl;


}

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

int main(){
  int n;
  cin >> n;
  vector<int> an(n);
  for(int i=0; i<n; ++i) cin >> an[i];
  int ans = 0;
  for(int i=0; i<n-1; ++i) for(int j=i+1; j<n; ++j){
    ans += an[i] * an[j];
  }
  cout << ans << endl;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  int N, A, B;
  cin >> N >> A >> B;
  string S;
  cin >> S;

  int inter = 0;
  int pass = 0;
  int length = S.size();
  for (int i = 0; i < length; ++i) {
    if (S[i] == 'a') {
      if (pass < (A + B)) {
        cout << "Yes" << endl;
        ++pass;
      } else {
        cout << "No" << endl;
      }
    } else if (S[i] == 'b') {
      if (pass < (A + B) && inter < B) {
        cout << "Yes" << endl;
        ++pass;
        ++inter;
      } else {
        cout << "No" << endl;
      }
    } else {  // 'c'
      cout << "No" << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 848
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int arr[m];
	int total = 0;
	for(int i=0; i<m; i++) cin>>arr[i];
	for(int i=0; i<m; i++) total+=arr[i];
	if(total>n) cout<<-1;
	else cout<<n-total;
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
     
using namespace std;
typedef long long ll;
const int tmax=3010;
const int nmax=3010; 
long DP[nmax][tmax];
int a[nmax],b[nmax];
char word[tmax];

int N;

void DFS(ll level){
    char climit =(char)'a';
    for (ll i=0; i< level; i++){
        climit = climit > (word[i]+1) ? climit : (word[i]+1);
    }
    for(char j='a'; j<= climit; j++){
        word[level] = j;
        if(level + 1 == N){
            word[level+1]='\0';
            cout << word << endl;
        } else
        {
            DFS(level + 1);
        }
    }
}


void solve(void){
    // cout << N << endl;  
    DFS(0);   
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> N;
    solve();
    
}



Measured memory_bytes: 1536
#include <iostream>
#include <string>

using namespace std;
int main()
{
	string s;
	cin >> s;
	if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3] || s[3] == s[4]) {
		cout << "Bad" << endl;
	}
	else {
		cout << "Good" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
// cpp219 - the 712534
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define fs first
#define sc second
#define mp make_pair
using namespace std;
const ll base = 7;
const ll N = 2e3 + 9;
const ll mod = 1e9 + 7;
typedef pair<ll,ll> LL;

ll d3,d5,d15;
ll n,s3,s5,s15;
int main(){
    ios_base::sync_with_stdio(false);
   	cin.tie(0); cout.tie(0);
    //freopen("test.inp", "r", stdin);
    cin>>n;
    d3 = n - n%3; d5 = n - n%5; d15 = n - n%15;
    d3 /= 3; d5 /= 5; d15 /= 15;
    s3 = d3 * (d3*3 + 3)/2; s5 = d5*(d5*5 + 5)/2;
    s15 = d15*(d15*15 + 15)/2;
    //cout<<d3<<" "<<d5<<" "<<d15<<"\n";
    cout<<n*(n + 1)/2 - s3 - s5 + s15;
}


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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  string s;
  cin>>s;
  int N=s.size();
  string bw="01";
  int ans1=0;
  for(int i=0;i<N;i++){
    if(s[i]!=bw[i%2])ans1++;
  }
  string wb="10";
  int ans2=0;
  for(int i=0;i<N;i++){
    if(s[i]!=wb[i%2])ans2++;
  }
  cout<<min(ans1,ans2)<<endl;
  return 0;
}


Measured memory_bytes: 512
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();

		long num[] = new long[100001];

		for (int i = 0; i < 12; i++) {
			num[i] = i+1;
		}
		if (k<12) {
			System.out.println(num[k-1]);
			return;
		}
		for (int i = 12; i < k; i++) {
			if (lastTwoDigitLessThanOne(num[i-1])) {
				num[i] = num[i-1]+1;
			} else {
				num[i] = calNew(num[i-1]);
			}
//			System.out.print(num[i] + ", ");
		}
		System.out.println(num[k-1]);
	}

	private static boolean lastTwoDigitLessThanOne(long num){
		long lastOne = (long)num%10;
		long lastTow = (long)num/10%10;
		if (lastOne == 9) {
			return false;
		}
		if (lastOne - lastTow == 1) {
			return false;
		}
		return true;
	}

	private static long calNew(long num){
		String numString = String.valueOf(num);
		int length = numString.length();
		int numIndex = length-1;
		for (int i = length-1; i >=1 ; i--) {
			int num1 = Character.getNumericValue(numString.charAt(i-1));
			int num2 = Character.getNumericValue(numString.charAt(i));
			if (num1+1==num2) {
				numIndex--;
			} else if (num1 == 9 && num2 == 9) {
				numIndex--;
			} else {
				break;
			}
		}
		int l = Character.getNumericValue(numString.charAt(0));
		if (l == 9 && numIndex == 0) {
			return num+1;
		}

		int num3 = Character.getNumericValue(numString.charAt(numIndex));
		StringBuilder sb = new StringBuilder(numString);
		sb.setCharAt(numIndex, (char) (num3+1+'0'));
		for (int i = numIndex+1; i < length; i++) {
			if (sb.charAt(i-1) == '0' || sb.charAt(i-1)-1 < 0) {
				sb.setCharAt(i, '0');
			} else {
				sb.setCharAt(i, (char)(sb.charAt(i-1)-1));
			}
		}
		return Long.valueOf(sb.toString());
	}

}


Measured memory_bytes: 32168
#include<iostream>
#include<deque>
#include<algorithm>

using namespace std;
  
int main(){
  int N;
  cin>>N;
  deque<int> deq(N);
  for(int i=0;i<N;i++){
    cin>>deq[i];
  }
  sort(begin(deq),end(deq));
  deque<int> ans;

  if(deq[0]<=1){
    int no=count(begin(deq),end(deq),1);
    auto p=upper_bound(begin(deq),end(deq),1);
    auto o=lower_bound(begin(deq),end(deq),1);
    if(o!=end(deq)&&(o-begin(deq))%2){
      swap(*o,o[-1]);
      if(o==p){
	p++;
      }
    }
    ans.insert(begin(ans),begin(deq),p);
    deq.erase(begin(deq),p);
  }
  if(deq.size()>=2&&deq.back()==3&&deq[deq.size()-2]==2){
    swap(deq[deq.size()-2],deq[deq.size()-1]);
  }
  ans.insert(begin(ans),begin(deq),end(deq));
  for(auto e:ans){
    cout<<e<<endl;
  }
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define int long long
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; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define FOR(i,a,b) for(long long i=a; i<b; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define PB(x) push_back(x)
#define MP make_pair
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstr vector<string>
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) max_element(x.begin(),x.end())
#define MIN(x) min_element(x.begin(),x.end())
#define couty cout<<'Y'<<'e'<<'s'<<endl
#define coutn cout<<'N'<<'o'<<endl
#define coutY cout<<'Y'<<'E'<<'S'<<endl
#define coutN cout<<'N'<<'O'<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
const long long dx[4]={1,0,-1,0};
const long long dy[4]={0,1,0,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;
//fixed<<setprecision(15);
signed main(){
    /*
    int n,y; cin >> n >> y;
    for(int i=0; i<=y/10000; i++){
        for(int j=0; j<=(y-10000*i)/5000; j++){
            if((i*10000+j*5000+(n-i-j)*1000)==y){
                cout<<i<<' '<<j<<' '<<n-i-j<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
    */
   int n; cin >> n;
   vint d(n); rep(i,n) cin >> d[i];
   sort(all(d));
   int res=1;
   rep(i,n-1){
       if(d[i]!=d[i+1]) res++;
   }
   cout<<res<<endl;

}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
int so[1000001],m[1000001];
int main(void){
	int i,j,n,x,v[30],flg;
	while(1){
		cin>>n>>x;
		if(n==0) break;
		for(i=0;i<n;i++) cin>>v[i];
		for(i=0;i<=x;i++) so[i]=1;
		for(i=2;i*i<=x;i++){
			if(so[i]!=0){
				for(j=i*2;j<=x;j+=i) so[j]=0;
			}
		}
		for(i=0;i<=x;i++) m[i]=0;
		m[0]=1;
		for(i=0;i<n;i++){
			for(j=0;j<=x;j++){
				if(m[j]==1) m[j+v[i]]=1;
			}
		}
		flg=0;
		for(i=x;i>0;i--){
			if(so[i]==1&&m[i]==1){
				cout<<i<<endl;
				flg=1;
				break;
			}
		}
		if(flg==0) cout<<"NA"<<endl;
	}
	return 0;
}

Measured memory_bytes: 10916
#include <iostream>

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

int main()
{
	long long m, n;
	std::cin >> m >> n;
	std::cout << mod_pow(m, n, 1000000007) << '\n';;
}



Measured memory_bytes: 3100
#include "stdio.h"
int main(){
	int A, B;
	scanf("%d %d", &A, &B);
	int maior = A + B;

	if(A - B >= maior){ 
		maior = A - B;
	}		

	if(A * B >= maior){ 
		maior = A * B; 	
	}
	
	printf("%d", maior);

	return 0;
}

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

using namespace std;

typedef vector<int> vi;

int bc(int x) {
    int r = 0;
    while (x) {
        r += x % 2;
        x /= 2;
    }
    return r;
}

void proc(int n, int b, int x, vi &v) {
    if (n == 0) {
        v.push_back(x);
        v.push_back(b ^ x);
        return;
    }

    if ((b >> n) == 0) {
        proc(n - 1, b, x, v);
        int orib = v[v.size()-1];
        int l1 = v[v.size()-1] ^ x;
        int l2 = v[v.size()-2] ^ x;
        v.resize(v.size()-1);
        b = l1 ^ l2;
        x ^= l2 ^ (1 << n);
        proc(n - 1, b, x, v);
        v.push_back(orib);
    } else {
        proc(n - 1, 1, x, v);
        b ^= (1 ^ (1 << n));
        x ^= (1 ^ (1 << n));
        proc(n - 1, b, x, v);
    }
}

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

    if (bc(a) % 2 == bc(b) % 2) {
        cout << "NO" << endl;
        return 0;
    }

    cout << "YES" << endl;

    vi v;
    proc(n - 1, b ^ a, a, v);

    for (int i = 0; i < v.size(); i++) {
        cout << v[i] << (i == v.size() - 1 ? '\n' : ' ');
    }

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)    FOR (i,0,n)
#define ALL(f,x,...) ([&](decltype((x)) ALL) {                          \
            return (f)(begin(ALL), end(ALL), ## __VA_ARGS__); })(x)

using namespace std;

vector<bool> check;
vector<int> p;

struct UnionFind
{
    vector<int> data;
    UnionFind() {}

    // edge v 要素数を size とし -1初期化
    UnionFind(int size) : data(size, -1) {}

    // 併合
    bool unite(int x, int y)
        {
            x = root(x);
            y = root(y);

            if (x != y)
            {
                if (data[y] < data[x]) swap(x, y);
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }

    // 判定
    bool same(int x, int y)
        {
            return root(x) == root(y);
        }

    // 根
    int root(int x)
        {
            return data[x] < 0 ? x : data[x] = root(data[x]);
        }

    int size(int x)
        {
            return -data[root(x)];
        }
};

template<class T> void gc(T &x)
{
    char c;
    int s = 0;
    x = 0;

    c = getchar_unlocked();

    if (c == '-') s = 1;
    else if ('0' <= c && c <= '9')  x = c - '0';

    while (true)
    {
        c = getchar_unlocked();

        if (c < '0' || c > '9') break;
        x = x * 10 + (c - '0');
    }

    if (s) x = -x;
}

int main()
{
    int N, M;

    gc(N);
    gc(M);

    p.resize(N);

    // 初期値 false
    check.resize(N);

    // Union-Find 初期化
    UnionFind uni(N);

    REP (i, N)
    {
        gc(p[i]);
        p[i]--;

        if (i == p[i])
        {
            check[i] = true;
        }
    }

    REP (i, M)
    {
        int l, r;
        gc(l);
        gc(r);

        // 0-indexed
        l--;
        r--;

        if (!uni.same(l, r))
        {
            uni.unite(l, r);
        }
    }

    int ans = 0;
    REP (i, N)
    {
        if (check[i])
        {
            ans++;
            continue;
        }

        if (uni.same(p[i], i)) ans++;
    }

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


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <vector>

using namespace std;

inline double manhattan_dist(const vector<int>& x, const vector<int>& y) {
  double r = 0.0;
  for (size_t i = 0; i < x.size(); ++i)
    r += abs(x[i] - y[i]);
  return r;
}

inline double euclid_dist(const vector<int>& x, const vector<int>& y) {
  double r = 0.0;
  for (size_t i = 0; i < x.size(); ++i)
    r += (x[i] - y[i]) * (x[i] - y[i]);
  return sqrt(r);
}

// Minkowski distance when p = 3
inline double minkowski3_dist(const vector<int>& x, const vector<int>& y) {
  double r = 0.0;
  for (size_t i = 0; i < x.size(); ++i) {
    const auto d = abs(x[i] - y[i]);
    r += d * d * d;
  }
  return cbrt(r);
}

inline double chebyshev_dist(const vector<int>& x, const vector<int>& y) {
  int m = 0;
  for (size_t i = 0; i < x.size(); ++i) {
    const auto d = abs(x[i] - y[i]);
    m = max(m, d);
  }
  return static_cast<double>(m);
}

int main() {
  int n;
  vector<int> x;
  vector<int> y;

  cin >> n;
  x.resize(n);
  y.resize(n);

  for (int i = 0; i < n; ++i)
    cin >> x[i];
  for (int i = 0; i < n; ++i)
    cin >> y[i];

  printf("%.6f\n", manhattan_dist(x, y));
  printf("%.6f\n", euclid_dist(x, y));
  printf("%.6f\n", minkowski3_dist(x, y));
  printf("%.6f\n", chebyshev_dist(x, y));
  return 0;
}

Measured memory_bytes: 3348
def main():
    n = int(input())

    cont = 0
    for _ in range(n):
        a, b = map(int, input().split())
        if a == b:
            cont += 1
            if cont >= 3:
                print('Yes')
                return
        else:
            cont = 0
    print('No')


if __name__ == '__main__':
    main()


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

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

using namespace std;
using ll = long long;
using P = pair<int,int>;


void calc_primefactorization(long long in, vector<vector<long long> >& out){
	
	long long N = in, Ntmp;
	long long p,e,p_init = 2;
	vector<long long> out_tmp(2);
	
	if( in == 1 ){
		out_tmp[0] = 1;
		out_tmp[1] = 1;
	}
	else{
		while( 1 ){

			Ntmp = N;
				
			p = N;
			e = 1;

			for(long long i = p_init;i * i <= N;i++){
						
				if( Ntmp % i == 0 ){
					e = 0;
					while( 1 ){
						if( Ntmp % i != 0 ){
							break;
						}
						else{
							Ntmp = Ntmp / i;
							e++;
						}
					}
					p = i;
					break;
				}
				
			}
			
			out_tmp[0] = p;
			out_tmp[1] = e;
			out.push_back(out_tmp);
			
			for(int i = 0;i < e;i++){
				N = N / p;
			}
			
			if( N == 1 ){
				break;
			}
			
		}
	}
	
}

long f(vector<int>& t, vector<int>& c, vector<vector<int> >& s, int& D){
	
	long F = 0;
	vector<int> last(N_Contest);
	
	for(int i = 0;i < D;i++){
		for(int j = 0;j < N_Contest;j++){
			if( j == t[i] - 1 ){
				F = F + s[i][j];
				last[j] = i + 1;
			}
			F = F - c[j] * ( (i + 1) - last[j]);
		}
	}
	
	return F;
	
}

void initialize(vector<int>& t, int& tmin, int& tmax){
	
	for(int i = 0;i < t.size();i++){
		t[i] = rand() % (tmax - tmin) + tmin;
	}
	
}

void generate_next(vector<int>& t, vector<int>& tnext, int& tmin, int& tmax){
	
	
	for(int i = 0;i < t.size();i++){
		
		int r = rand() % ( (tmax - tmin) / 2 ) - (tmax - tmin) / 4;
		tnext[i] = t[i] + r;
		//int r = rand() % (tmax - tmin);
		//tnext[i] = r;
		if( tnext[i] > tmax ){
			tnext[i] = tmax;
		}
		else if( tnext[i] < tmin ){
			tnext[i] = tmin;
		}
		
	}
	
	/*
	tnext = t;
	
	int ri = rand() % t.size();
	
	tnext[ri] = rand() % (tmax - tmin);
	
	if( tnext[ri] > tmax ){
		tnext[ri] = tmax;
	}
	else if( tnext[ri] < tmin ){
		tnext[ri] = tmin;
	}
	*/
	
}


int main(){
	
	srand((unsigned)time(NULL));
	
	//////////////////////////////////////////////////////////////////////////////////////
	//input
	int D;
	vector<int> c(N_Contest);
	cin >> D;
	for(int i = 0;i < N_Contest;i++){
		cin >> c[i];
	}
	
	vector<vector<int> > s(D, vector<int>(N_Contest));
	for(int i = 0;i < D;i++){
		for(int j = 0;j < N_Contest;j++){
			cin >> s[i][j];
		}
	}
	
	//////////////////////////////////////////////////////////////////////////////////////
	
	//////////////////////////////////////////////////////////////////////////////////////
	//solve
	int G = 1000;
	vector<int> t(D), tbest(D), tnext(D);
	long feval, fbest, fnext;
	int tmin = 0, tmax = N_Contest - 1;
	
	initialize(t, tmin, tmax);
	feval = f(t, c, s, D);
	tbest = t;
	fbest = feval;
	
	for(int i = 0;i < 100;i++){

		initialize(t, tmin, tmax);
		feval = f(t, c, s, D);
		tbest = t;
		fbest = feval;

		for(int g = 0;g < G;g++){
			
			generate_next(t, tnext, tmin, tmax);
			fnext = f(tnext, c, s, D);
			if( fnext > fbest ){
				fbest = fnext;
				tbest = tnext;
			}
			
		}
		
	}
	
	for(int i = 0;i < D;i++){
		cout << tbest[i] + 1 << endl;
	}
	//cout << fbest;
	
	
	return 0;
	
}


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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int n;
	cin >> n;
	int sum = 0;
	rep(i,n){
		int a,b;
		cin >> a >> b;
		sum += abs(a-b) + 1;
	}
	P(sum);
}

int main() {
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

int n;

void dfs(string s, char c, int len)
{
    if (len == n)
    {
        cout << s << endl;
        return;
    }

    for (char a = 'a'; a <= c; a++)
        dfs(s + a, c, len + 1);

    dfs(s + (char)(c + 1), (char)(c + 1), len + 1);
}

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

    cin >> n;

    dfs("a", 'a', 1);

    return 0;
}


Measured memory_bytes: 1536
import math
import fractions
import copy
import numpy as np
import heapq
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
if ip() >= 3200:
    print(input())
else:
    a = input()
    print("red")

Measured memory_bytes: 23296
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(n,v) cout<<#v<<":";for(int i=0;i<n;i++)cout<<v[i]<<" ";cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main(){
    string t;
    cin>>t;
    int n=0,w=0,s=0,e=0;
    for(auto x:t){
        if(x=='N') n++;
        if(x=='S') s++;
        if(x=='E') e++;
        if(x=='W') w++;
    }
    if(n*s==0&&n+s!=0){
        cout<<"No"<<endl;return 0;
    }
    if(e*w==0&&e+w!=0){
        cout<<"No"<<endl;return 0;
    }
    cout<<"Yes"<<endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main{
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] str = br.readLine().split(" ");
		int n = Integer.parseInt(str[0]);
		int q = Integer.parseInt(str[1]);
		@SuppressWarnings("unchecked")
		ArrayList<Integer>[] S = new ArrayList[n];
		for(int i = 0; i < n; i++) S[i] = new ArrayList<Integer>();
		for(int i = 0; i < q; i++){
			str = br.readLine().split(" ");
			int op = Integer.parseInt(str[0]);
			if(op == 0){
				int t = Integer.parseInt(str[1]);
				int x = Integer.parseInt(str[2]);
				S[t].add(x);
			}else if(op == 1){
				int t = Integer.parseInt(str[1]);
				if(S[t].isEmpty()) continue;
				System.out.println(S[t].get(S[t].size() - 1));
			}else{
				int t = Integer.parseInt(str[1]);
				if(S[t].isEmpty()) continue;
				S[t].remove(S[t].size() - 1);
			}
		}
	}
}



Measured memory_bytes: 70072
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int n;
    cin >> n;
    vector<int> t(n+1),x(n+1),y(n+1);

    for (int i = 1; i < n+1; i++){
        cin >> t[i] >> x[i] >> y[i];
    }
    bool flag = true;
    for (int i = 1; i < n+1; i++){
        ll t_sub = t[i] - t[i-1];
        ll x_sub = abs(x[i] - x[i-1]);
        ll y_sub = abs(y[i] - y[i-1]);
        if (t_sub < x_sub + y_sub || (t_sub - (x_sub + y_sub)) % 2 != 0){
            flag = false;
            break;
        } 
    }
    if (flag){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>

const int N = 1300;
const int M =256;

int main(void)
{
	char c[N],b[M];
	while(fgets(c,1300,stdin))
	{
		int s1=strlen(c)-1 ,go=0;
		for(int i = s1 , j=0 ; j<s1 ; i++ ,j++ )
		{
			c[i] = c[j];
		}
		fgets(b ,1300,stdin);
		for(int i =0 ;i<strlen(c);i++)
		{ 
		    int k=0;
		    
			for(int j =0 ; j<strlen(b)-1; j++)
			{    
		
				if(c[i+j] == b[j])
				{
					k++;
				}
				
				
				else
				{   
				   break;
				}
				
			}
			
			if(k == strlen(b)-1)
			{   
				go =1;
				break;
			}
			
		}
		if(go)
	    {   
	    	printf("Yes\n");
		}
		else
		{   
			printf("No\n");
		}
	}
}


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

using namespace std;

typedef long long ll; 
const int maxs = 2000001;

// int main(){

//    ll t, i, j, a, b, c, f, s, k, l, resa, resb, resc;

//    cin>>t;

//    while(t--){
//         cin>>a>>b>>c;
//         ll res = 1000000;
//         for(i = 1;i <= b;i++){
//             for(j = 1;j <= min(a, i);j++){
//                  s = i;
//                  f = j;
//                //  cout<<f<<" "<<s<<"\n";
//                  if(s%f!=0){
//                      continue;
//                  }
//                  else{
//                    k = s;
//                    while(k <= c){
//                        k += s;
//                    }
//                    if(k != c)
//                      k -= s;
//                    res = min(res, a-f+b-s+c-k);  
//                    //cout<<f<<" "<<s<<" "<<k<<"\n";
//                    resa = f;
//                    resb = s;
//                    resc = k;


//                  }
//             }
//         }
//         cout<<res<<"\n";
//         cout<<resa<<" "<<resb<<" "<<resc<<"\n";
//    }
// }


int main(){
   ll n, i, j, k;

   cin>>n;

     ll h[n][3];

     for(i = 0 ;i < n;i++){
         cin>>h[i][0]>>h[i][1]>>h[i][2];
     }
   
    ll dp[n][3];

    memset(dp, 0, sizeof(dp));
    dp[0][0] = h[0][0];
    dp[0][1] = h[0][1];
    dp[0][2] = h[0][2];

   

    for(i = 1;i < n;i++){
        dp[i][0] = max(dp[i-1][1], dp[i-1][2]) + h[i][0];
        dp[i][1] = max(dp[i-1][2], dp[i-1][0]) + h[i][1];
        dp[i][2] = max(dp[i-1][0], dp[i-1][1]) + h[i][2];

    }
    // for(i =0 ;i < n;i++){
    //     cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
    // }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<"\n";
}

Measured memory_bytes: 4992
T = input()
T = T.lower()
W = []
cnt = 0

while True:
    A = list(map(str, input().split()))
    if 'END_OF_TEXT' in A:
        break
    else:
        for word in A:
            word = word.lower()
            if word == T:
                cnt += 1
        
print(cnt)


Measured memory_bytes: 5560
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
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());
		sc.next();
		List<String> s = new ArrayList<String>();
		for (int i = 0; i < n; i++)
			s.add(sc.next());
		Collections.sort(s);
		for (int i = 0; i < n - 1; i++)
			System.out.print(s.get(i));
		System.out.println(s.get(n - 1));
	}
}

Measured memory_bytes: 21460
using System;

namespace _96_1
{
    class Program
    {
        static void Main(string[] args)
        {
			string[] acs = Console.ReadLine().Split(' ');
			int a = int.Parse(acs[0]);
			int b = int.Parse(acs[1]);
			if (b >=  a)
			{
				Console.WriteLine(a);
			}
			else
			{
				Console.WriteLine(a - 1);
			}
		}
    }
}


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

const int MAX = 100003;
int h, w, d;
struct position
{
	int x; int y;
};
position a[MAX];
int b[MAX];//

int power(position p, position q) {
	return abs(p.x - q.x) + abs(p.y - q.y);
}
int main() {
	cin >> h >> w >> d;
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			int e;
			cin >> e;
			a[e].x = j;
			a[e].y = i;
		}
	}
	for (int i = 1; i <= h*w; i++) {
		if (i <= d) {
			b[i] = 0;
		}
		else {
			b[i] = b[i - d] + power(a[i], a[i - d]);
		}
	}
	int q;
	cin >> q;
	for (int i = 0; i < q; i++) {
		int l, r;
		cin >> l >> r;
		cout << b[r] - b[l] << endl;
	}
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int dp[100005],h[100005];
  int n,k,sm;
  cin >> n >> k;
  for(int i=0; i<n; i++) cin >> h[i];
  
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);

  for(int i=2; i<n; i++){
    sm = 1;
    dp[i] = abs(h[i] - h[i-1]) + dp[i-1];
    for(int j=2; j<=k; j++){
      if(i - j < 0) break;
      if(abs(h[i] - h[i-j]) + dp[i-j] < abs(h[i] - h[i-sm]) + dp[i-sm]){
	dp[i] = abs(h[i] - h[i-j]) + dp[i-j];
	sm = j;
      }
    }
  }
  
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  rep(i,N) cin>>A[i];

  sort(A.begin(),A.end());
  A.erase(unique(A.begin(),A.end()),A.end());

  if(A.size()==N) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;

  return 0;
}


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

#include <boost/range/irange.hpp>
using boost::irange;

int main() {
  int h, w;
  cin >> h >> w;
  for (int i : irange(0, h)) {
    string s;
    cin >> s;
    cout << s << endl;
    cout << s << endl;
  }
}


Measured memory_bytes: 256
H, W, K = map(int, input().split())
c = [input() for _ in range(H)]

ans = 0
for i in range(1 << H+W):
    hcnt = []
    wcnt = []
    cnt = 0
    for j in range(H+W):
        if (i >> j) % 2 == 0:
            continue
        if j < H:
            hcnt.append(j)
        else:
            wcnt.append(j-H)
    for j in hcnt:
        for k in wcnt:
            if c[j][k] == "#":
                cnt += 1
    
    if cnt == K:
        ans += 1

print(ans)

Measured memory_bytes: 9196
n = int(input())
s = []
for i in range(n):
  s.append(int(input()))
if sum(s)%10 != 0:
  print(sum(s))
else:
  mn = 1000
  for si in s:
    if si%10 != 0:
      mn = min(si,mn)
  if mn == 1000:
    print(0)
  else:
    print(sum(s)-mn)


Measured memory_bytes: 38256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
  int n, k, ans = 0;
  cin >> n >> k;
  vector<int> v(n + 10);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.begin() + n);
  for (int i = 0; i < k; i++) {
    ans += v[i];
  }
  cout << ans << endl;
}

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

using ll = long long int;
using P = std::pair<int, int>;

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

int d[310][310];

constexpr int INF = 1e9 + 10;

int main()
{
    int n, m, l;

    std::cin >> n >> m >> l;

    rep(i, n)
    {
        rep(j, n)
        {
            d[i][j] = INF;
        }
    }

    rep(i, m)
    {
        int a, b, c;
        std::cin >> a >> b >> c;
        d[a][b] = c;
        d[b][a] = c;
    }

    rep(k, n)
    {
        rep(i, n)
        {
            rep(j, n)
            {
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    rep(i, n)
    {
        rep(j, n)
        {
            d[i][j] = (d[i][j] <= l) ? 1 : INF;
        }
    }

    rep(k, n)
    {
        rep(i, n)
        {
            rep(j, n)
            {
                d[i][j] = std::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    int q;
    std::cin >> q;

    rep(i, q)
    {
        int s, t;
        std::cin >> s >> t;
        std::cout << ((d[s][t] == INF) ? -1 : d[s][t] - 1) << std::endl;
    }

    return 0;
}

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

using namespace std;

void fastio() {
	cin.tie(nullptr);
	cin.sync_with_stdio(false);
}

using LL = long long;
using LD = long double;

const LL MOD = 1e9+7;
const LL INF = LLONG_MAX;
const LL N = 1e6+1;

int main() {
	fastio();
	
	LL n;
	cin >> n;
	vector <LL> a(n);

	for (auto &e : a ) {
		cin >> e;
	}

	LL mx = a[0], tot = 0;
	for (LL i = 1; i < n; ++i) {
		mx = max(mx, a[i]);
		tot += mx - a[i];
	}

	cout << tot << "\n";



}

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

#define N_MAX 100
#define M_MAX 10

#define ITEM_MAX (M_MAX * N_MAX)

int TodaMegumi(int NakamuraYuuiti, int MizuhasiKairi) {
	if (NakamuraYuuiti > MizuhasiKairi) return 1;
	if (NakamuraYuuiti < MizuhasiKairi) return -1;
	return 0;
}

int KitamuraEri(const void* AsumiKana, const void* KugimiyaRie) {
	return strcmp((const char*)AsumiKana, (const void*)KugimiyaRie);
}

int KatouEmiri(const void* HanazawaKana, const void* TamuraYukari) {
	int (*TomatuHaruka)[2] = (int(*)[2])HanazawaKana;
	int (*IgutiYuka)[2] = (int(*)[2])TamuraYukari;
	int IgarasiHiromi = TodaMegumi((*TomatuHaruka)[0], (*IgutiYuka)[0]);
	if (IgarasiHiromi != 0) return IgarasiHiromi;
	return TodaMegumi((*TomatuHaruka)[1], (*IgutiYuka)[1]);
}

typedef struct {
	int M;
	char item[M_MAX][32];
} info_t;

int N, F;
info_t info[N_MAX];

int name_count = 0;
char names[ITEM_MAX][32];

int get_id(const char* name) {
	int left = 0, right = name_count - 1;
	while (left <= right) {
		int mid = (left + right) / 2;
		int cmp = strcmp(names[mid], name);
		if (cmp == 0) {
			return mid;
		} else if (cmp < 0) {
			left = mid + 1;
		} else {
			right = mid - 1;
		}
	}
	printf("\"%s\" not found\n", name);
	exit(1);
}

int kumiawase[ITEM_MAX][ITEM_MAX];

int answerCount = 0;
int answer[ITEM_MAX * ITEM_MAX][2];

int main(void) {
	int i, j, k;
	if (scanf("%d%d", &N, &F) != 2) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &info[i].M) != 1) return 1;
		for (j = 0; j < info[i].M; j++) {
			if (scanf("%s", info[i].item[j]) != 1) return 1;
			strcpy(names[name_count++], info[i].item[j]);
		}
	}
	qsort(names, name_count, sizeof(*names), KitamuraEri);
	j = 1;
	for (i = 1; i < name_count; i++) {
		if (strcmp(names[i], names[i - 1]) != 0) {
			if (i != j) strcpy(names[j], names[i]);
			j++;
		}
	}
	name_count = j;

	for (i = 0; i < N; i++) {
		int ids[M_MAX];
		for (j = 0; j < info[i].M; j++) ids[j] = get_id(info[i].item[j]);
		for (j = 0; j < info[i].M; j++) {
			for (k = j + 1; k < info[i].M; k++) {
				int a = ids[j], b = ids[k], t;
				if (a > b) {
					t = a;
					a = b;
					b = t;
				}
				kumiawase[a][b]++;
			}
		}
	}

	for (i = 0; i < name_count; i++) {
		for (j = i + 1; j < name_count; j++) {
			if (kumiawase[i][j] >= F) {
				answer[answerCount][0] = i;
				answer[answerCount][1] = j;
				answerCount++;
			}
		}
	}
	qsort(answer, answerCount, sizeof(*answer), KatouEmiri);
	printf("%d\n", answerCount);
	for (i = 0; i < answerCount; i++) {
		printf("%s %s\n", names[answer[i][0]], names[answer[i][1]]);
	}

	return 0;
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 998244353;
int main(){
  int N;
  cin >> N;
  vector<int> X(N), D(N);
  for (int i = 0; i < N; i++){
    cin >> X[i] >> D[i];
  }
  vector<pair<int,int>> R(N);
  for (int i = 0; i < N; i++){
    R[i].first = X[i]; //始点
    R[i].second = X[i] + D[i]; //終点
  }
  sort(R.begin(), R.end());
  reverse(R.begin(), R.end());
  stack<pair<int,long long>> S;
  for (int i = 0; i < N; i++){
    if (S.empty()){
      S.push(make_pair(R[i].first, 1));
    } else {
      long long p = 1;
      while (!S.empty() && R[i].second > S.top().first){
        p *= (S.top().second + 1);
        p = p % MOD;
        S.pop();
      }
      S.push(make_pair(R[i].first, p));
    }
  }
  long long ans = 1;
  while (!S.empty()){
    ans *= S.top().second + 1;
    ans = ans % MOD;
    S.pop();
  }
  cout << ans;
}

Measured memory_bytes: 4992
#include<cstdio>
int main()
{
	long long int i, j, n, h, w;
	scanf("%lld", &n);
	int flag = 0;
	for (i = 1; i <= 3500; i++)
	{
		for (j = 1; j <= 3500; j++)
		{
			h = n*i*j;
			w = 4 * i*j - n*j - n*i;
			if (w>0)
			{
				if (h%w == 0)
				{
					printf("%lld %lld %lld", i, j, h / w);
					flag = 1;
					break;
				}
			}

		}
		if (flag == 1) break;
	}
	return 0;
}

Measured memory_bytes: 128
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val n=input.split("\n")(0).toInt
    val as=input.split("\n")(1).split(" ").map(_.toInt)
    val odd=as.filter(_%2==1).size
    val even2=as.filter(_%4==0).size
    val even=n-odd-even2
    if(even==0 && odd<=even2+1){
      "Yes"
    }else if(odd<=even2){
      "Yes"
    }else{
      "No"
    }
  }
}


Measured memory_bytes: 45228
#include <stdio.h>

int main(void) {
    char str[4];
    int i;
    int flagA, flagB;

    // input
    scanf("%s", str);

    flagA = 0;
    flagB = 0;
    for (i = 0; i < 3; i++) {
        if (str[i] =='A') {
            flagA += 1;
        }
        if (str[i] =='B') {
            flagB += 1;
        }
    }

    if (flagA == 3) {
        printf("%s\n", "No");
    } else if (flagB == 3) {
        printf("%s\n", "No");
    } else {
        printf("%s\n", "Yes");
    }
    return 0;
}


Measured memory_bytes: 128
use std::cmp::max;
use proconio::input;


fn main() {
    input! {
        n: usize,
        m: i64,
        q: i64,
        data: [(usize, usize, i64, i64); q],
    }

    let candidates = gen(n, m, &mut vec![]);

    let mut ans = 0;
    for seq in candidates.iter() {
        ans = max(ans, points(&seq, &data));
    }

    println!("{:?}", ans);
}

fn gen(n: usize, m: i64, cur: &mut Vec<i64>) -> Vec<Vec<i64>> {
    if cur.len() >= n {
        return vec![cur.clone()];
    }

    let mut res = Vec::new();

    match cur.last() {
        Some(l) => {
            for v in *l..=m {
                cur.push(v);
                res.append(&mut gen(n, m, cur));
                cur.pop();
            }
        },
        None => {
            res.append(&mut gen(n, m, &mut vec![1]));
        }
    }

    res
}


fn points(seq: &Vec<i64>, data: &Vec<(usize, usize, i64, i64)>) -> i64 {
    let mut prev = seq[0];
    for &s in seq.iter() {
        if !(prev <= s) {
            return 0;
        }
        prev = s;
    }

    let mut res = 0;
    for (a, b, c, d) in data.iter() {
        if seq[b - 1] - seq[a - 1] == *c {
            res += d;
        }
    }

    res
}


Measured memory_bytes: 9080
#include<stdio.h>
#include<string.h>

int main()
{
     int i,x,y;
     char a[25], b[25];
     gets(a);
     y=strlen(a)-1;
     x=y;
     for(i=0;i<=y;i++)
     {
          b[i]=a[x];
          x--;
     }
     b[i]='\0';
     puts(b);
     return 0;
}

Measured memory_bytes: 916