akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

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

    while(1){
        x=-1;
        count=0;
        scanf("%d",&x);
        if(x<0)break;

        for(a=0;a<10;a++){
            for(b=0;b<10;b++){
                for(c=0;c<10;c++){
                    for(d=0;d<10;d++){
                        if(x==a+b+c+d){
                            count++;
                        }
                    }
                }
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

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

using i64 = long long;
using P = pair<i64, i64>;

#define overload3(_1, _2, _3, name, ...) name
#define rep1(i, n) for(i64 i = 0LL; i < (n); ++i)
#define rep2(i, a, b) for(i64 i = (a); i < (b); ++i)
#define rep(...) overload3(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define all(v) v.begin(), v.end()


void solve(long long N, std::vector<long long> A){
    vector<i64> table(N + 1);
    for(int i = N - 1; i >= 0; --i){
        table[i] = table[i + 1] + A[i + 1];
    }
    i64 ans = 0, cur = 1;
    if(N == 0){
        if(A[0] == 1) cout << 1 << endl;
        else cout << -1 << endl;
        return;
    }
    rep(i, N + 1){
        ans += cur;
        cur = min((cur - A[i]) * 2, table[i]);
        if((i != N && cur <= 0) || (i == N && cur < 0)){
            cout << -1 << endl;
            return;
        }
    }
    cout << ans << endl;
}

struct IoSetup {
    IoSetup() {
        // cin.tie(nullptr);
        // ios::sync_with_stdio(false);
        cout << fixed << setprecision(10);
        cerr << fixed << setprecision(10);
    }
} iosetup;

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N-0+1);
    for(int i = 0 ; i < N-0+1 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4852
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <typename T> bool chmax(T &a, const T &b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T> bool chmin(T &a, const T &b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
const long long INFLL = 1LL << 60;
const long long MOD = 1e9 + 7;

int main() {
    int A;
    cin >> A;
    cout << A + A * A + A * A * A << endl;
}

Measured memory_bytes: 3596
#include<stdio.h>
#define ARRAY_NUM 32

int main(){
	int Array[ARRAY_NUM] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K = 0;

    scanf("%d", &K);
    printf("%d", Array[K-1]);

  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main()
{
    int n,a,b,c,i;
    scanf("%d",&n);
    scanf("%d %d %d",&a,&b,&c);
    lli ans[n][3],an;
    ans[0][0]=a;ans[0][1]=b;ans[0][2]=c;
    for(i=1;i<n;i++)
    {
        scanf("%d %d %d",&a,&b,&c);
        ans[i][0]=max(ans[i-1][1]+a,ans[i-1][2]+a);
        ans[i][1]=max(ans[i-1][0]+b,ans[i-1][2]+b);
        ans[i][2]=max(ans[i-1][0]+c,ans[i-1][1]+c);
    }
    an=ans[n-1][0];
    if(ans[n-1][1]>an)
    an=ans[n-1][1];
    if(ans[n-1][2]>an)
    an=ans[n-1][2];
    printf("%lld",an);
}

Measured memory_bytes: 6140
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		// your code goes here
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int k=s.nextInt();
		int a[]=new int[n];
		for(int i=0;i<n;i++)
		{
		    a[i]=s.nextInt();
		}
		
		int dp[]=new int[n];
		dp[0]=0;
		dp[1]=Math.abs(a[0]-a[1]);
		
		for(int i=2;i<n;i++)
		{
		    int min=Integer.MAX_VALUE;
		    for(int j=1;j<=k;j++)
		    {
		        if(i-j>=0)
		    min=Math.min(Math.abs(a[i]-a[i-j])+dp[i-j],min);
		    }
		    dp[i]=min;
		}
		System.out.println(dp[n-1]);
	}
}


Measured memory_bytes: 50272
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <cmath>
#include <cstring>
 
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
 
int N, K;
int H[200001];
 
int main() {
    cin >> N >> K;
    rep(i, N) cin >> H[i];
    sort(H, H + N, std::greater<int>());
    ll sum = 0;
    for (int i = K; i < N; i ++) {
        sum += H[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

fn run() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut r = a.iter().fold(0, |s, a| s + *a);
    let mut l = 0;
    let mut ans = std::i64::MAX;
    for i in 0..(n - 1) {
        l += a[i];
        r -= a[i];
        ans = std::cmp::min(ans, (l - r).abs());
    }
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 9464
#include <stdio.h>

int main(){
    int a,b,c,i,x;
    scanf("%d %d %d",&a,&b,&c);
    x=0;
    for(i=a;i<=b;i++){
        if(c%i==0){
            x++;
        }
    }
    printf("%d\n",x);
    return 0;
}

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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void solve() {
    int N;
    cin >> N;
    int g[N][N];
    REP(i, N) {
        REP(j, N) {
            g[i][j] = -1;
        }
    }
    REP(i, N) {
        int A;
        cin >> A;
        REP(j, A) {
            int x, y;
            cin >> x >> y;
            x--;
            g[i][x] = y;
        }
    }
  
    int ans = 0;
    for (int i = 0; i < 1<<N; i++) {
        vector<int> vec(N);
        REP(k, N) {
            if (i>>k&1){
                vec[k] = 1;
            }
        }
        bool ok = true;
        for (int a = 0; a < N; a++) {
            if (i>>a & 1) {
                for (int b = 0; b < N; b++) {
                    if (g[a][b] != -1) {
                        if (vec[b] != g[a][b]) {
                            ok = false;
                        }
                    }
                }
            }
        }
        if (ok) {
            int tmp = 0;
            for (int a = 0; a < N; a++) {
                if (i>>a & 1) tmp++;
            }
            ans = max(ans, tmp);
        }
    }
    print(ans);
}

signed main() {
    solve();
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int k = sc.nextInt();
        long[] sumsA = new long[n + 1];
        for (int i = 1; i <= n; i++) {
            sumsA[i] = sumsA[i - 1] + sc.nextInt();
        }
        long[] sumsB = new long[m + 1];
        for (int i = 1; i <= m; i++) {
            sumsB[i] = sumsB[i - 1] + sc.nextInt();
        }
        int idx = m;
        int max = 0;
        for (int i = 0; i <= n && sumsA[i] <= k; i++) {
            while (sumsA[i] + sumsB[idx] > k) {
                idx--;
            }
            max = Math.max(max, i + idx);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 63392
n,m=map(int,input().split())
A=list(int(input()) for i in range(m))+[-1]
dp=[0]*(n+1)
dp[0]=1
j=0
for i in range(1,n+1):
    if i==A[j]:
        dp[i]=0
        j +=1
    else:
        dp[i]=dp[i-1]+dp[i-2]
print(dp[n]%1000000007)

Measured memory_bytes: 460020
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = null;
		PrintStream out = null;
		try {
			sc = new Scanner(System.in);
			out = System.out;
			exec(sc, out);
		} catch (Exception e) {
			e.printStackTrace();
			System.exit(1);
		} finally {
			if(out != null) {
				out.close();
			}
			if(sc != null) {
				sc.close();
			}
		}
		System.exit(0);
	}
	public static void exec(final Scanner sc, final PrintStream out) throws Exception{
		final int a = sc.nextInt();
		final String s = sc.next();
		if(a >= 3200) {
			out.println(s);
		}else {
			out.println("red");
		}
	}
}


Measured memory_bytes: 21844
X,N = map(int, input().split())
A = list(map(int, input().split()))
if N == 0:
    print(X)
else:
    if N == 1:
        if A[0] != X:
            print(X)
        else:
            print(X-1)
    else:
        B = []
        for i in range(N):
            B.append(abs(X-A[i]))
        B.sort()
        t = 0
        for i in range(N):
            if (i+1)//2 != B[i]:
                break
            else:
                t = t+1
        if t == N:
            if N%2 == 1:
                print(X-((N+1)//2))
            else:
                k = 0
                for i in range(N):
                    if A[i] == X-(N//2):
                        k = k+1
                if k == 0:
                    print(X-(N//2))
                else:
                    print(X+(N//2))
        else:
            if t%2 == 1:
                print(X-(t+1)//2)
            else:
                k = 0
                for i in range(N):
                    if A[i] == X-(t//2):
                        k = k+1
                if k == 0:
                    print(X-(t//2))
                else:
                    print(X+(t//2))


Measured memory_bytes: 9148
#include<bits/stdc++.h>
#define ll long long
#define a109 1000000009
#define mod 1000000007
#define pb push_back
using namespace std;

ll n,k,mn;

ll dizi[500];
ll dp[500][500];
ll pre[500];
ll dpf(int l,int r){
	// printf("%d %d\n",l,r );
	if(l>r)
		return LLONG_MAX;
	if(l==r){
		return 0;
	}
	if(dp[l][r]!=-1){
		return dp[l][r];
	}
	dp[l][r]=0;
	ll mn=4000000000000;
	for(int i=l;i<(r);i++){
		mn=min(mn,dpf(l,i)+dpf(i+1,r));
	}
	dp[l][r]=mn;
	dp[l][r]+=pre[r]-pre[l-1];
	// printf("%lld\n", mn);
	return dp[l][r];
}	

int main(){ 

	// freopen("a.gir","r",stdin);
 //    freopen("a.cik","w",stdout);
    memset(dp,-1,sizeof(dp));
	scanf("%lld",&n);
	for(int i=1;i<=n;i++){	
		scanf("%lld",&dizi[i]);
		pre[i]=pre[i-1]+dizi[i];	
	}
	printf("%lld\n",dpf(1,(n)) );
		
}


Measured memory_bytes: 2176
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n,d;
    cin>>n>>d;
    vector<double>a(n);
    vector<double>b(n);
    int m=0;
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
        if(sqrt(pow(a[i],2)+pow(b[i],2))<=d)m++;
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 6448
N = int(input())
A = list(map(int,input().split()))

def even_check(A):
    cnt = 0
    for i in range(N):
        if A[i]%2 == 0:
            cnt += 1
    if cnt == N:
        return True

total_cnt = 0
while even_check(A):
    for i in range(N):
        A[i] = A[i]/2
    total_cnt += 1

print(total_cnt)


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main()
{
    char s[100005];
    int ans[100005]={0}, i, cnt=0, f=0, cntr=1, cntl=0, tmpr, tmpl;
    cin >> s;
    while(s[i]!='\0'){
        cnt++;
        i++;
    }

    for(i=1;i<cnt;i++){
        if(s[i]=='R' && s[i-1]=='R') cntr++;
        else if(s[i]=='L' && s[i-1]=='R'){
            cntl++;
            tmpr=i-1;
            tmpl=i;
        }
        else if(s[i]=='L') cntl++;
        else if(s[i]=='R' && s[i-1]=='L'){
            if((cntr+cntl)%2==0){
                ans[tmpr]=(cntr+cntl)/2;
                ans[tmpl]=(cntr+cntl)/2;               
            }
            else{
                if(cntr>cntl){
                    if((cntr-1)%2==0){
                        ans[tmpr]=((cntr+cntl)/2)+1;
                        ans[tmpl]=ans[tmpr]-1;
                    }
                    else{
                        ans[tmpr]=(cntr+cntl)/2;
                        ans[tmpl]=ans[tmpr]+1;
                    }
                }
                else{
                    if((cntl-1)%2==0){
                        ans[tmpr]=(cntr+cntl)/2;
                        ans[tmpl]=ans[tmpr]+1;
                    }
                    else {
                        ans[tmpr]=((cntr+cntl)/2)+1;
                        ans[tmpl]=ans[tmpr]-1;
                    }
                }
            }
            cntr=1;
            cntl=0;
        }
    }

      if((cntr+cntl)%2==0){
                ans[tmpr]=(cntr+cntl)/2;
                ans[tmpl]=(cntr+cntl)/2;               
            }
            else{
                if(cntr>cntl){
                    if((cntr-1)%2==0){
                        ans[tmpr]=((cntr+cntl)/2)+1;
                        ans[tmpl]=ans[tmpr]-1;
                    }
                    else{
                        ans[tmpr]=(cntr+cntl)/2;
                        ans[tmpl]=ans[tmpr]+1;
                    }
                }
                else{
                    if((cntl-1)%2==0){
                        ans[tmpr]=(cntr+cntl)/2;
                        ans[tmpl]=ans[tmpr]+1;
                    }
                    else {
                        ans[tmpr]=((cntr+cntl)/2)+1;
                        ans[tmpl]=ans[tmpr]-1;
                    }
                }
            }

    for(i=0;i<cnt;i++){
        cout << ans[i] << " ";
    }
    cout <<endl;
            
            
    return 0;
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int main()
{
	deque<int> dq;
	int n;
	read(n);
	for(int i=1; i<=n; ++i){
		int a; read(a);
		if(i%2 == 1) dq.pb(a);
		else dq.push_front(a);
	}
	if(n&1) reverse(all(dq));
	for(int x:dq) printf("%d ", x);
	return 0;
}


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

int main(){
    int N, M, k, a;
    cin >> N >> M;
    vector<int> cnt(M, 0);
    for(int i = 0; i < N; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> a;
            cnt[a-1]++;
        }
    }
    int ans = 0;
    for(int i = 0; i < M; i++){
        if(cnt[i] == N) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		char a[][] = new char[8][8];

		for (int i = 0; i < 8; i++) {
			String s = sc.next();
			for (int j = 0; j < 8; j++) {
				a[i][j] = s.charAt(j);
			}
		}

		System.out.println("90");
		for (int j = 0; j < 8; j++) {
			for (int i = 7; 0 <= i; i--) {
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
		System.out.println("180");
		for (int i = 7; 0 <= i; i--) {
			for (int j = 7; 0 <= j; j--) {
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
		System.out.println("270");
		for (int j = 7; 0 <= j; j--) {
			for (int i = 0; i < 8; i++) {
				System.out.print(a[i][j]);
			}
			System.out.println();
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>
#include <sstream>
#include <algorithm>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;

bool palind(int x){
  stringstream ss;
  ss << x;
  string s = ss.str();
  string rs = s;
  reverse(rs.begin(), rs.end());
  return s == rs;
}

int main(){
  int n;

  while(cin >> n){
    int minDiff = INT_MAX;
    int ans = -1;

    for(int i = 1; i <= 10000; i++){
      if(palind(i) && minDiff > abs(i - n)){
        minDiff = abs(i - n);
        ans = i;
      }
    }

    cout << ans << endl;
  }
}

Measured memory_bytes: 1224
#include<algorithm>
#include<typeinfo>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iterator>
#include<functional>
#include<bitset>
#include<stack>
#define e exp(1)
#define eps 0.01
#define pi acos(-1)
using namespace std;
typedef long long ll;
const int maxn = 3e3 + 10;
int n;
ll a[maxn];
ll gcd(ll x, ll y) {
    return y ? gcd(y, x%y) : x;
}
ll lcm(ll x, ll y) {
    return x*y / gcd(x, y);
}
int main() {
    while (cin >> n) {
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        ll ans = 0;
        for (int i = 0; i < n; ++i) {
            ans += a[i]-1;
        }
        cout << ans << endl;
    }
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
// ascending order
#define asort(array, N) sort(array, array + N)
// descending order
#define asort_r(array, N) sort(array, array + N, greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N, Y;
	cin >> N >> Y;
	for(int i = 0; i <= N; i++) {
		for(int j = 0; j + i <= N; j++) {
			if(10000 * i + 5000 * j + 1000 * (N - i - j) == Y) {
				cout << i << " " << j << " " << N - i - j << endl;
				return 0;
			}
		}
	}
	cout << "-1 -1 -1" << endl;
			

}


Measured memory_bytes: 256
#include <stdio.h>
    
int main(void){
    int n,k;
    scanf("%d%d",&n,&k);
    k -= 1;
    char str[n];
    scanf("%s",str);
    if(str[k] == 'A'){
        str[k] = 'a';
    } else if (str[k] == 'B'){
        str[k] = 'b';
    } else {
        str[k] = 'c';
    }

    printf("%s",str);
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import itertools

S = input()
signs = [['+',''] for _ in range(len(S)-1)]

ans = 0
for comb in itertools.product(*signs):
    expr = ''
    for i in range(len(S)-1):
        expr += (S[i] + comb[i])
    expr += S[-1]
    ans += eval(expr)
print(ans)        


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<limits.h>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#define int long long
using namespace std;

int n;
int MAX;
int a[101];
bool k[101];//false 使わない true 使う
void saiki(int b) {
	if (b == 25||b==n+1) {
		int t = 0;
		for (int i = 1; i <= 24; i++) { if (k[i])t += a[i]; }
		for (int i = 25; i <= n; i++) {
			for (int j = 1; j <= 24; j++) {
				if (i%j == 0 && k[j]) {
					t += a[i];
					k[i] = true;
					break;
				}
				else {
					k[i] = false;
				}
			}
		}
		for (int i = n; i > 24; i--) {
			if (k[i])continue;
			bool OK = true;//自由に使えるか？
			for (int j = i*2; j <= n; j+=i) {
				if (!k[j])OK = false;
			}
			if (OK) {
				if (a[i] >= 0) {
					k[i] = true;
					t += a[i];
				}
			}
			else {
				int o = 0;
				if (a[i] >= 0) {
					for (int j = i; j <= n; j+=i) {
						if(!k[j])o += a[j];
					}
					if (o >= 0) {
						for (int j = i; j <= n; j += i) {
							k[j] = true;
						}
						t += o;
					}
				}
			}
		}
		MAX = max(MAX, t);
		return;
	}
	for (int i = 1; i < b; i++) {
		if (b%i == 0 && k[i]) {
			k[b] = true;
			saiki(b + 1);
			return;
		}
	}
	k[b] = false;
	saiki(b + 1);
	k[b] = true;
	saiki(b + 1);
}
signed main() {
	cin >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i + 1];
		sum += a[i + 1];
		a[i + 1] *= -1;
	}
	saiki(1);
	cout << sum + MAX << endl;
}

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

int gcd(int x, int y) {return (y?gcd(y,x%y):x);}

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<int> l(n), r(n);
    l[0] = 0;
    r[0] = 0;
    rep(i,n-1) l[i+1] = gcd(l[i],a[i]);
    rep(i,n-1) r[i+1] = gcd(r[i],a[n-i-1]);
    
    int ans = 0;
    rep(i,n) {
        ans = max(ans,gcd(l[i],r[n-i-1]));
    }
    cout << ans << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
void YN(bool f){ cout << (f ? "YES" : "NO");}
void yn(bool f){ cout << (f ? "yes" : "no");}
void YeNo(bool f) {cout << (f ? "Yes" : "No");}
signed main(){
    int n,a,b; cin >> n >> a >> b;
    vector<int>v(n);
    for(auto & e : v)  cin >> e;
    int ans = 0;
    for(int i = 1; i < n; ++i){
        ans += min((v[i] - v[i-1]) * a,b);
    }
    cout << ans << endl;
}


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

using namespace std;

int main(void)
{
    int X, N;
    int p[100];

    cin >> X >> N;
    bool samef = false;
    for(int i = 0; i < N; i++){
        cin >> p[i];
        if(X == p[i])   samef = true;
    }
    if(samef == false){
        cout << X;
    }   
    else{
        sort(p, p + N);

        int xIndex;
        for(int i = 0; i < N; i++){
            if(X == p[i]){
                xIndex = i;
                break;
            }
        }
        int ans;
        for(int d = X--, di = xIndex--; 1; di--, d--){
            if(di < 0 || d != p[di]){
                ans = d;
                break;
            }
        }
        for(int u = X++, ui = xIndex++; 1; ui++, u++){
            if(ui >= N || u != p[ui]){
                if(u - X < X - ans){
                    ans = u;
                }
                break;
            }
        }
        cout << ans;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3608
import sys
sys.setrecursionlimit(10 ** 9)

n = int(input())
h = [int(x) for x in input().split()]
dp = [-1 for _ in range(n)]


def rec_dp(i: int) -> int:
    global h, dp
    if i == 0:
        return 0
    if dp[i] != -1:
        return dp[i]
    res = rec_dp(i - 1) + abs(h[i] - h[i - 1])
    if i - 2 >= 0:
        res = min(rec_dp(i - 2) + abs(h[i] - h[i - 2]), res)
    dp[i] = res
    return res


print(rec_dp(n - 1))


Measured memory_bytes: 94080
st=input()
n=len(st)
if(n%2==0):
	print("No")
	exit(0)
if(st==st[::-1]):
	s1=""
	for i in range((n-1)//2):
		s1+=st[i]
	s2=""
	for i in range((n+3)//2-1,n):
		s2+=st[i]
	if(s1==s1[::-1] and s2==s2[::-1]):
		print("Yes")
	else:
		print("No")
else:
	print("No")

Measured memory_bytes: 3064
import java.io.PrintWriter
import java.util.NoSuchElementException

fun main(args: Array<String>) = IO().exec {
    val n = int()
    val a = LongArray(n){long()}
    val cnt = count(a)
    if ((cnt[0] ?: 0) == n) {
        println("Yes")
    } else if (n % 3 == 0 && cnt.size == 3 && cnt.values.all { it == n / 3 } && cnt.keys.fold(0L, {acc, item -> acc.xor(item)}) == 0L) {
        println("Yes")
    } else if (n % 3 == 0 && cnt.size == 2 && (cnt[0] ?: 0) == n / 3) {
        println("Yes")
    } else {
        println("No")
    }
}

fun count(arr: LongArray): MutableMap<Long, Int> {
    val hmap = mutableMapOf<Long, Int>()
    for (item in arr) {
        hmap[item] = (hmap[item] ?: 0) + 1
    }
    return hmap
}

class IO {
    val printable = 33..126
    val buffer = ByteArray(1024)
    var ptr = 0
    var buflen = 0
    val out = PrintWriter(System.out)
    fun hasNextByte(): Boolean {
        if (ptr < buflen) {
            return true
        } else {
            ptr = 0
            buflen = System.`in`.read(buffer)
            if (buflen <= 0) {
                return false
            }
        }
        return true
    }
    fun readByte(): Byte {
        return if (hasNextByte()) buffer[ptr++] else return -1
    }
    fun hasNext(): Boolean {
        while (hasNextByte() && buffer[ptr] !in printable) ptr++
        return hasNextByte()
    }
    fun string(): String {
        if (!hasNext()) throw NoSuchElementException()
        val sb = StringBuilder()
        var b = readByte()
        while (b in printable) {
            sb.appendCodePoint(b.toInt())
            b = readByte()
        }
        return sb.toString()
    }
    fun long(): Long {
        if (!hasNext()) throw NoSuchElementException()
        var n = 0L
        var minus = false
        var b = readByte()
        if (b == '-'.toByte()) {
            minus = true
            b = readByte()
        }
        if (b !in '0'.toByte()..'9'.toByte()) {
            throw NumberFormatException()
        }
        while (true) {
            if (b in '0'.toByte()..'9'.toByte()) {
                n *= 10
                n += b - '0'.toByte()
            } else if (b == (-1).toByte() || b !in printable) {
                return if (minus) -n else n
            } else {
                throw NumberFormatException()
            }
            b = readByte()
        }
    }
    fun int(): Int {
        val nl = long()
        if (nl !in Integer.MIN_VALUE..Integer.MAX_VALUE) throw NumberFormatException()
        return nl.toInt()
    }
    fun double(): Double {
        return string().toDouble()
    }
    fun print(obj: Any) = out.print(obj)
    fun print(i: Int) = out.print(i)
    fun print(l: Long) = out.print(l)
    fun println(obj: Any) = out.println(obj)
    fun println(i: Int) = out.println(i)
    fun println(l: Long) = out.println(l)
    inline fun exec(block: IO.() -> Unit) {
        block()
        out.flush()
    }
}

Measured memory_bytes: 40280
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n;
   cin >> n;
   printf("%.6lf\n", ((n + 1) / 2) / (double)n);
   return 0;
}


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

const double pi  = 2 * acos(0.0);
const double eps = 1e-8;

#define REP(i,a,b) for(int i=(a); i<(b);++i)
#define rep(i,n) REP(i,0,n)
#define INF (1<<30)
#define INFLL (1LL<<62)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

int main(void) {
  ios_base::sync_with_stdio(false); cin.tie(0);
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  if (A > B) swap(A, B);

  bool ok = false;
  for (int i = 0; i <= N - 1; i++) {
    if (B - (N - 1 - i) * C < A - i * D) continue;
    if (B - (N - 1 - i) * D > A - i * C) continue;

    ok = true;
    break;
  }

  if (ok) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <string>
           
using namespace std;
           
int main() {
int n;
cin >> n;
int min1 = 10000000;
int max1 = -10000000;
long sum = 0;
for(int i=0; i<n; ++i) {
int a;
cin >> a;
min1 = (min1 < a) ? min1 : a;
max1 = (max1 > a) ? max1 : a;
sum += a;
}
cout << min1 << " " <<  max1 << " " << sum << endl;
}


Measured memory_bytes: 3112
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <limits.h>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <vector>
#include <cstdio>
#define ll long long
#define rep2(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>()>
#define pb push_back
#define vec vector<int>
#define vecll vector<ll>
#define bs binary_search
#define All(c) (c).begin(),(c).end()
#define mp make_pair
using namespace std;
int in(){int x;scanf("%d",&x);return x;}
string stin(){string s;cin>>s;return s;}
ll lin(){ll x;scanf("%lld",&x);return x;}
int main(){
    ll r=in(),g=in(),b=in(),n=in();
    ll ans=0;
    for(int i=0;i*r<=n;i++)for(int j=0;i*r+j*g<=n;j++){
        if((n-(r*i+g*j))%b==0)ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
//Krunal_Mathukiya
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define li long int
#define pb push_back
#define mkp make_pair
#define nikalL return
#define umap unordered_map
#define fr(i,s,n) for(int i=s;i<=n;++i)
#define frr(i,s,n) for(int i=s;i>=n;--i)
#define jaldiKarNe ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mod 1000000007
int n,m;
int grid[1001][1001];
int vis[1001][1001];
int dp[1001][1001];
lli fn(int i,int j) {
	if(!grid[i][j]) return 0;
	if(i==0 || j==0) return 0;
	if(i==1 && j==1) return 1;
	if(vis[i][j]) return dp[i][j];
	vis[i][j]=1;
	lli curr=fn(i-1,j)+fn(i,j-1);
	curr%=mod;
	return dp[i][j]=curr;
}
void TestingChaluKarEyy(){
	cin>>n>>m;
	fr(i,1,n) {
		fr(j,1,m) {
			char ch;
			cin>>ch;
			if(ch=='.') grid[i][j]=1;
		}
	}
	cout<<fn(n,m);

}
int main(){
	jaldiKarNe;
	int TestingKaravvuChhe=1;
//	cin>>TestingKaravvuChhe;
	while(TestingKaravvuChhe--){
		TestingChaluKarEyy();
	}
}


Measured memory_bytes: 15352
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		int n= sc.nextInt();
		int x = sc.nextInt();
		sc.close();

		if(x == 1 || x == n*2-1){
			System.out.println("No");
		}else{
			System.out.println("Yes");
			if(x>n){
				for(int i=n; i<n*2; i++){
					if(i!=x){
						//System.out.println(i);
						out.println(i);
					}
					if(i%100 == 0){
						out.flush();
					}
				}
				out.flush();
				//System.out.println(x);
				out.println(x);
				for(int i=1; i<n; i++){
					if(i!=x){
						//System.out.println(i);
						out.println(i);
					}
					if(i%100 == 0){
						out.flush();
					}
				}
			}else{
				for(int i=n+1; i<n*2; i++){
					if(i!=x){
						//System.out.println(i);
						out.println(i);
					}
					if(i%100 == 0){
						out.flush();
					}
				}
				out.flush();
				//System.out.println(x);
				out.println(x);
				for(int i=1; i<n+1; i++){
					if(i!=x){
						//System.out.println(i);
						out.println(i);
					}
					if(i%100 == 0){
						out.flush();
					}
				}
			}
		}
		out.flush();
	}

}

Measured memory_bytes: 24508
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define MOD ((int)1e6 + 3)
#define INF ((int)1e9)
#define INFLL ((LL)1e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (1 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 1, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 0) u += MOD;
    return u;

}
int exp(int a, int b){
    LL res = 1;
    LL sum = a;
    for(int i=0;i<30;++i){
        if(BIT(i)&b){
            res = (res * sum)%MOD;
        }
        sum = (sum * sum) % MOD;
    }
    return res;
}
int main(){
    int N, A, B, C, D;
    cin >> N >> A >> B >> C >> D;
    string str;
    cin >> str;
    str = " " + str;
    bool flag = true;
    if(C < D){
        int count = 0;
        for(int i=B;i<D;++i){
            if(str[i] == '#'){
                ++count;
                if(count == 2){
                    flag = false;
                    break;
                }
            }else{
                count = 0;
            }
        }
        count = 0;
        for(int i=A;i<C;++i){
            if(str[i] == '#'){
                ++count;
                if(count == 2){
                    flag = false;
                    break;
                }
            }else{
                count = 0;
            }
        }
    }else{
        bool nf = false;
        int count = 0;
        for(int i=B;i<=D;++i){
            if(str[i]=='#'){
                ++count;
                if(count == 2){
                    flag = false;
                    break;
                }
            }else{
                count = 0;
                if(str[i-1]=='.'&&str[i+1]=='.'){
                    nf = true;
                }
            }
        }
        count = 0;
        for(int i=A;i<C;++i){
            if(str[i]=='#'){
                ++count;
                if(count == 2){
                    flag = false;
                    break;
                }
            }else{
                count = 0;
            }
        }
        if(!nf){
            flag = false;
        }
    }
    cout << (flag?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 772
K,N=io.read("*n","*n")
A={}
for i=1,N do
A[i]=io.read"*n"
end
A[N+1]=A[1]+K
local max=A[2]-A[1]
for i=2,N do
	a=A[i+1]-A[i]
	if(a>max)then max=a end
end
print(K-max)

Measured memory_bytes: 2304
def jpybtc(s):
    rate = 0
    if s == "JPY": 
        rate = 1.0 
    elif s == "BTC": 
        rate = 380000.0 
    return rate
    
n = int(input())
x = [0]*(n+1)
u = [0]*(n+1)
#print(x)
#print(u)

for i in range(1,n+1):
    x[i], u[i] = input().split()
x = list(map(float,x))
v = list(map(jpybtc,u))
#print(x)
#print(v)
sum = 0
for j in range(1,n+1):
    sum = sum + x[j] * v[j]
print(sum)

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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define FOR(i,m,n) for(int i=(m) ; i<(n) ; i++)
#define FORR(i,m,n) for(int i=(m) ; i>=(n) ; i--)

typedef long long ll;
typedef unsigned long long ull;

const int INF = 1000000000;

int main(){
   int n;cin>>n;
   vector<int> a(n);
   rep(i,n){
      cin>>a[i];
   }
   int ans = INF;
   rep(i,n){
      int count = 0;
      while(a[i]%2==0){
         a[i]/=2;
         count++;
      }
      ans = min(count,ans);
   }
   cout << ans;
   return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  ABC176D
#include <iostream>
#include <vector>
#include <deque> // dequeを使う
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using P = pair<int,int>;
const int di[]={-1,0,1,0};
const int dj[]={0,-1,0,1};
const int INF=1e8;
int main(int argc, const char * argv[]) {
    int h,w;
    cin >> h >> w;
    int ch,cw;
    cin >> ch>>cw;
    int dh,dw;
    cin >> dh>>dw;
    ch--;cw--;dh--;dw--;
    vector<string> s(h);
    rep(i,h){
        cin>>s.at(i);
    }
    vector<vector<int>> dist(h,vector<int>(w,INF)); // 距離を記録する
    dist.at(ch).at(cw)=0; // 開始位置
    deque<P> q;
    q.emplace_back(ch,cw);
    while(!q.empty()){
        int i=q.front().first;
        int j=q.front().second;
        q.pop_front();
        int d=dist.at(i).at(j);
        // 歩いて移動する
        rep(k,4){
            int ni=i+di[k];
            int nj=j+dj[k];
            if(ni<0||ni>=h||nj<0||nj>=w) continue;
            if(s.at(ni).at(nj)=='#') continue;
            if(dist.at(ni).at(nj)<=d)continue;
            dist.at(ni).at(nj)=d;
            q.emplace_front(ni,nj); // ni,njのPairをqに前方から入れる
        }
        // ワープ魔法を使って移動する
        for (int magic_i=-2; magic_i<=2; magic_i++) {
            for (int magic_j=-2; magic_j<=2; magic_j++) {
                int ni=i+magic_i;
                int nj=j+magic_j;
                if(ni<0||ni>=h||nj<0||nj>=w) continue;
                if(s.at(ni).at(nj)=='#') continue;
                if(dist.at(ni).at(nj)<=d+1)continue;
                dist.at(ni).at(nj)=d+1;
                q.emplace_back(ni,nj);
            }
        }
    }
    int ans=dist.at(dh).at(dw);
    if(ans==INF){
        cout<<-1<<endl;
    } else {
        cout<<ans<<endl;
    }
    return 0;
}


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

# define ll long long int



const int md = 1e9+7;





int main() {


 ll d,t,s;
 cin>>d>>t>>s;

 double x = d*1.0/s;
 t= t*1.0;
 //cout<<x<<endl;

 if(x<=t) cout<<"Yes"<<endl;
 else cout<<"No"<<endl;
 

 
    
}

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

int main() {
  int lim = 100000;
  vector<bool> f(100001, false);
  vector<int> c(100002, 0);

  // エラトステネスの櫛で素数を洗い出す
  for (int i = 2; i <= lim; i++) {
    if (f.at(i) == false) {
      // 初回であれば2より大きい2の倍数、つまり4から始まる
      // そこから2の倍数でループを回す
      for (int j = i + i; j <= lim; j = j + i) {
        f.at(j) = true;
      }
    }
  }

  // 奇数について、「2017に似た数」の条件を満たす場合は、カウントを +1 する
  // 偶数は (N + 1) / 2 で割り切れないため、考慮外とする
  for (int i = 3; i <= lim; i = i + 2) {
    // ともに素数の場合
    if (f.at(i) == false && f.at((i + 1) / 2) == false) {
      c.at(i)++;
    }
  }

  // 累積和にする
  for (int i = 3; i <= lim; i++) {
    c.at(i) = c.at(i) + c.at(i - 1);
  }

  int Q;
  cin >> Q;
  for (int i = 0; i < Q; i++) {
    int l, r;
    cin >> l >> r;
    // 3〜7 の場合は、7までの合計から2までの合計を引く
    cout << (c.at(r) - c.at(l - 1)) << endl;
  }

  return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <tuple>
#include <cassert>

using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define mp(a,b) make_pair((a), (b))
#define mt(a,b,c) make_tuple((a),(b),(c))

typedef long long ll;

int main(){
    ll x,y; cin >> x >> y;
    ll ans; ans = x * y;
    if(x==1 || y==1) ans = 1;
    else if(x%2==1 && y%2==1) ans = (ans+1) / 2;
    else ans = ans /2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
import java.io.InputStreamReader
import java.io.BufferedReader

fun main(args: Array<String>) {
  val br = BufferedReader(InputStreamReader(System.`in`))

  val n = br.readLine().toInt()
  val seq = br.readLine().split(" ").map { it.toInt() }.toIntArray()

  tailrec fun rec(acc: Int, pre: Int, i: Int, sign: Int): Int {
    return when {
      i == n -> acc
      pre == seq[i] && sign == 0 -> rec(acc, seq[i], i+1, 0)
      pre < seq[i] && sign == 0 -> rec(acc, seq[i], i+1, 1)
      pre > seq[i] && sign == 0 -> rec(acc, seq[i], i+1, -1)
      pre <= seq[i] && sign > 0 -> rec(acc, seq[i], i+1, 1)
      pre >= seq[i] && sign < 0 -> rec(acc, seq[i], i+1, -1)
      else -> rec(acc+1, seq[i], i+1, 0)
    }
  }

  val ans = rec(1, seq[0], 1, 0)
  println(ans)
}

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

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())
#define pb push_back
#define mp make_pair

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector <int> arr(n);
  for (int i = 0; i < n; i++) cin >> arr[i];
  multiset <int> ans;
  for (int i = 0; i < n; i++) {
    auto it = ans.lower_bound(arr[i]);
    if (it == begin(ans)) {
      ans.insert(arr[i]);
    } else {
      it--;
      ans.erase(it);
      ans.insert(arr[i]);
    }
  }
  cout << sz(ans) << '\n';
  return (0);
}


Measured memory_bytes: 5376
#include<stdio.h>
int main(){
  int x,y;

  while(1){
    {

    scanf("%d%d",&x,&y);

    if( x==0 && y==0 ){
      break;
    }

    }

  if( x>y ) printf("%d %d\n",y,x);
  else if( x<y ) printf("%d %d\n",x,y);
  else printf("%d %d\n",x,y);
  }


  return 0;
}

Measured memory_bytes: 600
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	a, _ := strconv.Atoi(nextLine())
	nextLine()
	nextLine()
	nextLine()
	e, _ := strconv.Atoi(nextLine())
	k, _ := strconv.Atoi(nextLine())
	if e - a > k {
		fmt.Println(":(")
	} else {
		fmt.Println("Yay!")
	}
}


Measured memory_bytes: 640
n=int(input())
a=list(map(int,input().split()))
x=0
y=0
for i in range(len(a)):
    if(a[i]%2==0):
        x+=1
        if(a[i]%3==0 or a[i]%5==0):
            y+=1

if(x==y):
    print("APPROVED")

else:
    print("DENIED")

Measured memory_bytes: 3060
use proconio;

fn main(){
  proconio::input! {
    n:i64
  }
  let mut sum:i64 = 0;
  for i in 1..n+1 {
    if i % 3 != 0 && i % 5 != 0 {
      sum += i
    }
  }
  println!("{}", sum)
}

Measured memory_bytes: 2132
import java.util.*;

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

        String W = sc.nextLine();
        String T = "";
        String[] T_split;

        int count = 0;
        while(true){
            T = sc.nextLine();
            if(T.equals("END_OF_TEXT")) break;  //終了条件
            T_split = T.split(" ",0);
            for(int i = 0;i < T_split.length;i++){
                T_split[i] = T_split[i].toLowerCase();
                if(T_split[i].matches(W))  count++;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 26296
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int manh(int x1, int y1, int x2, int y2)
{
    return abs(x1-x2) + abs(y1-y2);
}

int main(int argc, char **argv)
{
    int n, m;
    scanf("%d %d", &n, &m);

    int *a = (int *) malloc(sizeof(int) * n);
    int *b = (int *) malloc(sizeof(int) * n);
    int *c = (int *) malloc(sizeof(int) * m);
    int *d = (int *) malloc(sizeof(int) * m);
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (int i = 0; i < m; ++i) {
        scanf("%d %d", &c[i], &d[i]);
    }

    int *index = (int *) malloc(sizeof(int) * n);
    for (int i = 0; i < n; ++i) {
        int min = INT_MAX;
        for (int j = 0; j < m; ++j) {
            int dist = manh(a[i], b[i], c[j], d[j]);
            if (dist < min) {
                min = dist;
                index[i] = j + 1;
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        printf("%d\n", index[i]);
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

int main(){
  string s;
  cin >> s;
  assert(s.size() % 2 == 0);

  ll n = s.size();
  n /= 2;

  map<char,char> hey;
  hey['T'] = 'a';
  hey['L'] = 'i';
  hey['U'] = 'u';
  hey['R'] = 'e';
  hey['D'] = 'o';

  map<int,char> hi;
  // hi[1] = '';
  hi[2] = 'k';
  hi[3] = 's';
  hi[4] = 't';
  hi[5] = 'n';
  hi[6] = 'h';
  hi[7] = 'm';
  hi[8] = 'y';
  hi[9] = 'r';
  hi[0] = 'w';

  REP(i,n){
    int key = s[2*i]-'0';
    char way = s[2*i+1];
    if(key == 0 && way == 'U')cout << "nn";
    else{
      if(key!=1)cout << hi[key];
      cout << hey[way];
    }
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 1184
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	int D, G;
	cin >> D >> G;
	vector<int>p(D), c(D);
	rep(i, D)cin >> p[i] >> c[i];
	int ans = INF;
	for (int i = 0; i < (1ll << D); i++) {
		int sum = 0;
		int cost = 0;
		for (int j = 0; j < D; j++) {
			if ((i >> j) & 1) {
				sum += 100 * (j + 1) * p[j] + c[j];
				cost += p[j];
			}
		}
		if (sum >= G)ans = min(ans, cost);
		else {
			int num = G - sum; //必要な点数
			for (int j = D - 1; j >= 0; j--) {
				if (((i >> j) & 1) == 0) {
					int a = (num + 100 * (j + 1) - 1) / (100 * (j + 1));
					if (a <= p[j] - 1) {
						cost += a;
						num -= (100 * (j + 1)) * a;
						break;
					}
					else {
						cost += p[j] - 1;
						num -= (100 * (j + 1)) * (p[j] - 1);
					}
				}
			}
			if (num <= 0)ans = min(ans, cost);
		}
	}
	cout << ans << endl;
}

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

int main(){
  vector<int> a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(a.begin(), a.end());
  cout << a[0] + a[1] << endl;
}

Measured memory_bytes: 256