akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
#include <cstdlib> //整数のabs
#include <cmath> //小数のabs

int main(){
    int N, T, A;
    cin >> N >> T >> A;

    int H[N];
    for (int i=0; i<N; i++) cin >> H[i];

    double gap[N];
    for (int i=0; i<N; i++) gap[i]=abs(A-(T-H[i]*0.006));

    double minimum=gap[0];
    int ans=1;

    for (int i=1; i<N; i++){
        if (gap[i]< minimum){
            minimum=gap[i];
            ans=i+1;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;
int main(){
  long long N;
  scanf("%lld",&N);
  long long S;
  S=N*(N+1)/2;
  long long y=N/3;
  S-=y*(y+1)/2*3;
  y=N/5;
  S-=y*(y+1)/2*5;
  y=N/15;
  S+=y*(y+1)/2*15;
  printf("%lld",S);
  return 0;
}

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

int main() {
    int n;
    cin >> n;
    int kyu;
    if (400 <= n && n <= 599) kyu=8;
    else if (600 <= n && n <= 799) kyu=7;
    else if (800 <= n && n <= 999) kyu=6;
    else if (1000 <= n && n <= 1199) kyu=5;
    else if (1200 <= n && n <= 1399) kyu=4;
    else if (1400 <= n && n <= 1599) kyu=3;
    else if (1600 <= n && n <= 1799) kyu=2;
    else if (1800 <= n && n <= 1999) kyu=1;
    cout << kyu << endl;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b;
cin>>a>>b;
if(b>a){
    cout<<"0"<<endl;
}
else{
  int s=b*2;
  if(s>a){
    cout<<"0"<<endl;
  }
  else{
   cout<<abs(a-s)<<endl;
  }
}
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
  //
  string s;
  cin >> s;
  rep(i, s.size()) {
    char ch = s[i];
    if (i & 1) {
      // even
      if (ch != 'L' && ch != 'U' && ch != 'D') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      // odd
      if (ch != 'R' && ch != 'U' && ch != 'D') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 888
#include <stdio.h>
int main(){
   int m, f, r;
 while(1){
     scanf("%d %d %d ", &m, &f, &r);
     if(m==-1&&f==-1&&r==-1)break;
     if(m==-1||f==-1){
         printf("F\n");
     }else if(m+f>=80){
         printf("A\n");
     }else if(m+f>=65){
         printf("B\n");
     }else if(m+f>=50){
         printf("C\n");
     }else if(m+f>=30){
         if(r>=50){
             printf("C\n");
         }else{
             printf("D\n");
         }
     }else{
         printf("F\n");
     }
 }
 return 0;
}






Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define IFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define RPT(i,a,b) for(int i=(a);i<((a)+(b));++i)
#define IRPT(i,a,b) for(int i=((a)+(b)-1);i>=(a);--i)
#define BITBOOL(x,a) (((x)>>(a))&1)
constexpr int INF = (1 << 29);
constexpr ll INF_ = (1LL << 58);
constexpr ld EPS = (1e-10);
constexpr ld PI_ = 3.141592653589793238;//46264338327950288
constexpr ld E_ = 2.71828182845904523;//5360287471352
constexpr ll MOD = 1000000007;
ll modpow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a % m;
		a = a * a%m; n >>= 1;
	}
	return res;
}
int main(){
  int N;
  cin >> N;
  vector<ll> C(N,0);
  RPT(i,0,N) cin >> C[i];
  sort(C.begin(),C.end());
  reverse(C.begin(),C.end());
  ll A=modpow(2LL,2*N-1,MOD), ans=0, inv2=modpow(2LL,MOD-2,MOD),T=modpow(2LL,2*N-1,MOD);
  //ans += (C[0]*A % MOD);
  FOR(i,0,N){
    A = (i+2)*T % MOD;
    ans += (C[i]*A % MOD);
    ans %=MOD;
  }
  ans *= inv2;
  ans %= MOD;
  cout << ans;
  return 0;
}

Measured memory_bytes: 1792
import itertools
N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]
A = list(range(1, M+1))
AC = list(itertools.combinations_with_replacement(A,N))
anslist = [0] * len(AC)

for i in range(len(AC)):
  for j in range(Q):
    if AC[i][abcd[j][1]-1] - AC[i][abcd[j][0]-1] == abcd[j][2]:
      anslist[i] += abcd[j][3]

print(max(anslist))

Measured memory_bytes: 25188
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
#define eps 1e-8
#define eq(x,y) (fabs((x)-(y)) < eps)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int mod = 1e9+7;
long double PI = acosl(-1);
const ll infl = 1e18+100;
const int inf = 2e9+100;
const int nmax = 2e3+5;
const int MAXLG = log2(nmax)+1;
//mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
//typedef tree< int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ost;


int arr[nmax];
ll dp[nmax][nmax];

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

    int n;
    cin>>n;
    for(int i=1; i<=n; i++) cin>>arr[i];
    ll ans = 0;
    for(int i=1; i<=n; i++){
        int mx=-1, pos=-1;
        for(int j=1; j<=n; j++){
            if(arr[j] > mx) mx = arr[j], pos = j;
        }
        arr[pos] = 0;
        for(int bam=0; bam<=i-1; bam++){
            int dan = i-1 - bam;
            dp[bam+1][dan] = max(dp[bam][dan] + 1LL*abs(pos-(bam+1))*mx, dp[bam+1][dan]);
            dp[bam][dan+1] = max(dp[bam][dan] + 1LL*abs(pos-(n-dan))*mx, dp[bam][dan+1]);
        }
    }
    for(int i=0; i<=n; i++){
        ans = max(ans, dp[i][n-i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 26308
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        int area = a*b;
        int length = a*2+b*2;
        System.out.println(area+" "+length);
        sc.close();
    }
}


Measured memory_bytes: 26408
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws InterruptedException {
		FastScanner fs=new FastScanner();
		int n=fs.nextInt(), k=fs.nextInt();
		int[] a=fs.readArray(n);
		for (int i=0; i<n-k; i++) {
			System.out.println(a[i]>=a[i+k]?"No":"Yes");
		}
	}
	
	void sort(int[] a) {
		ArrayList<Integer> list=new ArrayList<>();
		for (int i:a) list.add(i);
		Collections.sort(list);
		for (int i=0; i<a.length; i++) a[i]=list.get(i);
	}
	
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		
		public String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
			
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
		
		public long[] readLongArray(int n) {
			long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextLong();
			return a;
		}
	}

}


Measured memory_bytes: 57608
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, X, Y;
    cin >> N >> X >> Y;
    vector<int> nums(N + 1, 0);
    for (int i = 1; i <= N; ++i)
    {
        for (int j = i + 1; j <= N; ++j)
        {
            int dist = j - i;
            // ペアがショートカット外のとき
            if (Y <= i || j <= X)
            {
                ++nums[dist];
            }
            else
            {
                dist = min(dist,
                    abs(i - X) + 1 + abs(j - Y));
                ++nums[dist];
            }
        }
    }
    for (int d = 1; d <= N - 1; ++d)
    {
        cout << nums[d] << '\n';
    }
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>
#include <queue>
#include <list>
using namespace std;
// #define fprintf(...) void(0)

bool judge(int N, int T,
           const vector< tuple<int, int, int> > &info, int O) {
    priority_queue< int, vector<int>, greater<int> > op;
    list< pair<int, int> > cs;
    for(int i=0; i<O; i++) op.emplace(0);
    for(int i=0; i<N; i++) cs.emplace_back(0, i);

    // fprintf(stderr, "# num of operators = %d\n", O);
    for(int t=0; t<=T and cs.size(); t++) {
        // customer 選ぶ
        for(auto itr = cs.begin(); itr!=cs.end(); ) {
            int p, k; tie(p, k) = *itr;
            int M, L, K; tie(M, L, K) = info[k];

            bool inc = false;
            if(p <= t and t + M <= T) {
                int o = op.top(); op.pop();
                if(o > t) {
                    // 対応できる operator がいない
                    op.emplace(o);
                    inc = true;
                }
                else {
                    // 対応
                    // fprintf(stderr, "t = %d, customer = %d, op time = %d\n", t, k + 1, o);
                    itr = cs.erase(itr);
                    op.emplace(t + M);
                }
            }
            else if(t + M > T) {
                return false;
            }
            else {
                inc = true;
            }
            
            if(inc) {
                // update time
                if(t - L == p) {
                    // fprintf(stderr, "t = %d, update: customer = %d, time = %d\n", t, k+1, t+K);
                    *itr = make_pair(t+K, k);
                    if(t + K > T) return false;
                }
                itr++;
            }
        }
    }

    return cs.empty();
}

int solve_testcase() {
    int N, T; cin >> N >> T;
    if(N == 0 and T == 0) return 1;

    vector< tuple<int, int, int> > info;
    for(int i=0; i<N; i++) {
        int M, L, K; cin >> M >> L >> K;
        info.emplace_back(M, L, K);
    }

    for(int m=1; m<=N; m++) {
        if(judge(N, T, info, m)) {
            cout << m << endl;
            return 0;
        }
    }
    return 0;
}

int main() {
    while(!solve_testcase());
    return 0;
}



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

using namespace std;

char p[8][8];

void rotate() 
{
    char bp[8][8];
    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            bp[i][j] = p[i][j];
        }
    }

    for (int i = 0; i < 8; i++) {
        for (int j = 0; j < 8; j++) {
            p[i][j] = bp[7 - j][i];
        }
    }
}

void disp()
{
    for (int i = 0; i < 8; i++){ 
        for (int j = 0; j < 8; j++) {
            cout << p[i][j];
        }
        cout << endl;
    }
}

int main()
{
    for (int i = 0; i < 8; i++) 
        for (int j = 0; j < 8; j++ )
            cin >> p[i][j];

    cout << "90" << endl;
    rotate();
    disp();

    cout << "180" << endl;
    rotate();
    disp();

    cout << "270" << endl;
    rotate();
    disp();

    
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, b, e) for (i64 i = (b); i <= (e); ++i)
#define repr(i, b, e) for (i64 i = (b); i >= (e); --i)

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;
// }}} End

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, M;
  cin >> N >> M;
  priority_queue<i64, vector<i64>, greater<>> que;
  rep(i, N) {
    int a; cin >> a;
    que.emplace(a);
  }
  vector<pii> vec(M);
  rep(i, M) {
    int b, c; cin >> b >> c;
    vec[i] = pii(c, b);
  }
  sort(all(vec), greater<>());
  for (auto e : vec) {
    i64 loop = e.second, norm = e.first;
    while (loop--) {
      if (norm > que.top()) {
        que.pop();
        que.emplace(norm);
      }
      else break;
    }
  }
  i64 res = 0;
  while (!que.empty()) {
    res += que.top();
    que.pop();
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 2676
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>

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

typedef long long ll;

using namespace std;

const int MOD = 1000000007;

int main() {
	int a, b, h;
	cin >> a >> b >> h;
	cout << (a + b)*h / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define f first
#define s second
#define mp make_pair
#define sz size()
#define ll long long
int n, k;
int a[(int)1e5+10];
int dp[(int)1e5+10];
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin >> n >> k;
	for(int i = 1; i <= n; ++i) cin >> a[i];
	for(int i = 0; i <= n; ++i) dp[i] = 1e9;
	dp[1] = 0;
	dp[2] = abs(a[2] - a[1]);
	for(int i = 3; i <= n; ++i)
		for(int j = 1; j <= k; ++j)
			if(j <= i) dp[i] = min(dp[i], dp[i - j] + abs(a[i] - a[i - j]));
	cout << dp[n];
	return 0;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += b[a[i] - 1]
    if i >= 1 and a[i] - a[i - 1] == 1:
        ans += c[a[i - 1] - 1]
print(ans)

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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

LL gcd(LL a,LL b){return b?gcd(b,a%b):a;}
LL lcm(LL a,LL b){return a/gcd(a,b)*b;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int n,dp[N],a[N],m,b[N];
const int mod=1e9+7;
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>m;
	for(int i=1;i<=m;i++){int s;cin>>s;b[s]=1;}
	dp[0]=1;
	for(int i=1;i<=n;i++){
		if(b[i])dp[i]=0;
		else {
			dp[i]=(0ll+dp[i-1]+(i>=2?dp[i-2]:0))%mod;
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
	int X;
	cin >> X;
	for (ll A = -3981; A <= 3981; ++ A) for (ll B = -3981; B <= 3981; ++ B) {
		if (A*A*A*A*A-B*B*B*B*B == X) {
			cout << A << " " << B << endl;
			return 0;
		}
	}
	throw 1;
}


Measured memory_bytes: 3636
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn solve() {
    input!(
        n: usize,
        d: [usize; n],
    );

    let mut d: Vec<usize> = d;

    d.sort();

    let t = d[n/2] - d[n/2-1];

    println!("{}", t);
}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;
	cin>>n>>m;
	int a[100];
	for(int i=0;i<m*2;i++){
		cin>>a[i];
	}
	int cnt=0;
	for(int k=1;k<=n;k++){
		for(int j=0;j<m*2;j++){
			if(a[j]==k){
				cnt++;
			}
		}
		cout<<cnt<<endl;
		cnt=0;
	}
}

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

int N;
char fid[610][610];
int ans;

int main()
{
    scanf("%d",&N);
    for(int i = 0; i < N; i++)
    {
        for(int j = 0; j < N; j++)
        {
            char c;
            scanf(" %c",&c);
            fid[i][j] = c;
            fid[i + N][j] = c;
            fid[i][j + N] = c;
            fid[i + N][j + N] = c;
        }
    }

    for(int k = 0; k < N; k++)
    {
        int h = k,w = 0;
        bool flag = true;
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < i; j++)
            {
                if(fid[(h + i) % N][(w + j) % N] != fid[(h + j) % N][(w + i) % N])flag = false;
            }
        }
        if(flag)ans += N - k;
    }
    for(int k = 1; k < N; k++)
    {
        int h = 0,w = k;
        bool flag = true;
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < N; j++)
            {
                if(fid[(h + i) % N][(w + j) % N] != fid[(h + j) % N][(w + i) % N])flag = false;
            }
        }
        if(flag)ans += N - k;
    }

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


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
int main()
{
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    cout << 100 << " " << 100 << endl;
    for(int i = 0; i < 50; i++)
    {
        if(i % 2 == 0)
        {
            for(int j = 0; j < 100; j++)
            {
                cout << ".";
            }
            cout << endl;
        }
        else
        {
            for(int j = 0; j < 100; j++)
            {
                if(j % 2 == 0 || b == 0)
                {
                    cout << ".";
                }
                else
                {
                    cout << "#";
                    b--;
                }
            }
            cout << endl;
        }
    }
    for(int i = 0; i < 50; i++)
    {
        if(i % 2 == 0)
        {
            for(int j = 0; j < 100; j++)
            {
                cout << "#";
            }
            cout << endl;
        }
        else
        {
            for(int j = 0; j < 100; j++)
            {
                if(j % 2 == 0 || a == 0)
                {
                    cout << "#";
                }
                else
                {
                    cout << ".";
                    a--;
                }
            }
            cout << endl;
        }
    }
}

Measured memory_bytes: 256
using System;

class Program {
	static void Main(string[] args) {
		int n5 = 0, n7 = 0;
		string[] buf = Console.ReadLine().Split(' ');
		
    foreach(string s in buf) {
      int i = int.Parse(s);
      if(i == 5) ++n5;
      else if(i == 7) ++n7;
      else break;
    }

    if(n5 == 2 && n7 == 1)
      Console.WriteLine("YES");
    else
      Console.WriteLine("NO");
	}
}


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

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

    ll n;
    cin >> n;
    vector<ll> a(n+2);
    a[0] = 0;
    a[n+1] = 0;
    for (ll i = 1;i <= n;i++){
        cin >> a[i];
    }
    ll sum = 0;
    for (ll i = 1; i < n+2; i++){
        sum += abs(a[i] - a[i-1]);
    }
    //cout << sum << endl;

    for (ll i = 1; i <= n; i++){
        ll ans = sum;
        ans -= abs(a[i] - a[i-1]);
        ans -= abs(a[i+1] - a[i]);
        ans += abs(a[i+1] - a[i-1]);
        cout << ans << "\n";
    }

}

Measured memory_bytes: 3916
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a; }

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

Measured memory_bytes: 1408
while True:
    num, mini, maxi = map(int, input().split())
    if num == 0: break
    scores = [ int(input()) for i in range(num) ]
    gap = 0
    ans = 0
    for i in range(mini, maxi + 1):
        gap = scores[i-1] - scores[i] if scores[i-1] - scores[i] >= gap else gap
        ans = i if scores[i - 1] - scores[i] >= gap else ans

    print(ans)


Measured memory_bytes: 5624
#include <bits/stdc++.h>
using namespace std;
int n;
double p[3030], dp[3030][3030], ans = 0;
void pri() {
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) cout << dp[i][j] << ", ";
		cout << endl;
	}
	cout << endl;
}
int main() { cout << fixed << setprecision(20);
	cin >> n;
	for (int i = 1; i <= n; i++) cin >> p[i];
	dp[1][0] = p[1];
	dp[0][1] = 1 - p[1]; dp[0][0] = 1;
	for (int i = 2; i <= n; i++) dp[i][0] = p[i] * dp[i-1][0];
	for (int i = 2; i <= n; i++) dp[0][i] = (1-p[i]) * dp[0][i-1];
	for (int i = 1; i <= n; i++) 
		for (int j = 1; j <= n; j++) {
			if (i+j>n) continue;
			dp[i][j] += (p[i+j] * dp[i-1][j] + (1-p[i+j]) * dp[i][j-1]);
			if (i > j and i+j == n) ans += dp[i][j];
		}
		
	//pri();
	cout << ans + dp[n][0];
	return 0;
}

Measured memory_bytes: 71936
import java.util.*;
class Main{
public static void main(String[] args) {
    Scanner yin = new Scanner(System.in);
    
    
    int N = yin.nextInt();
    int[] num = new int[N];
   
    
    for (int i = 0,j; i < N; i++) {
             num[i] = yin.nextInt();
        }
    
    int suanchang=0;
        
        for(int i = 0; i < num.length-1; i++){
            int min = i;
            
            for(int j = i+1; j <num.length ;j++){
                if(num[j]<num[min]){
                    min = j;
                }
            }
            if(min!=i){
               int temp = num[i];
                num[i] = num[min];
                 num[min] = temp;
                   suanchang++;
            }
        
        }
    

    
    for(int i=0;i<num.length-1;i++){
        System.out.print(num[i] + " ");
   }
        
        
        System.out.print(num[N-1]);
        System.out.println();
        System.out.println(suanchang);
   
    
    
            }

    }


Measured memory_bytes: 26168
#include<stdio.h>
int main()
{
   int a,b,c,d,n=0;
   scanf("%d%d",&a,&b);
   for(c=1;c<=b;c++)
   {
       scanf("%d",&d);
       n=n+d;
   }
   if(n>=a)
   {
       printf("Yes");

   }

   else{printf("No");}
    return 0;

}


Measured memory_bytes: 1700
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int x = sc.nextInt();
		int y = sc.nextInt();
		
		// 計算
		int result = 0;
		result = x + y/2;
		
		// 出力
		System.out.println(result);
	}
}



Measured memory_bytes: 21716
require 'prime'

N = gets.to_i

x = (1..40).to_a.inject([0]){|tot, i| tot << tot.last + i; tot}

ans = 0
N.prime_division.each do |b, e|
  i = 1
  while e >= x[i]
    i += 1
  end
  ans += i - 1
end
puts ans

Measured memory_bytes: 14480
import sys
from bisect import bisect_left, bisect_right

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
W = LI()


min_v = 1000000
for t in range(1,N+1):

    a = sum(W[:t])
    b = sum(W[t:])
    min_v = min(min_v,abs(a-b)) 
print(min_v)


Measured memory_bytes: 9200
import java.io.*;
import java.util.Arrays;

public class Main {

    public static void main(String[] args) {
        try (CustomReader in = new CustomReader()) {
            new Main().execute(in);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public void execute(CustomReader in) throws IOException {
        final int N = Integer.parseInt(in.readLine());
        int[] A = in.readLineAsIntArray();

        for (int i = 0; i < N; i++) {
            A[i] -= i + 1;
        }
        Arrays.sort(A);
        int k = N / 2;
        long minS = S(A, A[k]);
        if(N>1) {
            minS = Math.min(minS, S(A, A[k + 1]));
            minS = Math.min(minS, S(A, (A[k] + A[k + 1]) / 2));
        }
        System.out.println(minS);

    }

    private long S(int[] a, int b) {
        long s = 0L;
        for (int i = 0; i < a.length; i++) {
            s += Math.abs(a[i] - b);
        }
        return s;
    }

    static class CustomReader extends BufferedReader {
        private static final int DEFAULT_BUF_SIZE = 2048;

        public CustomReader() throws IOException {
            super(new InputStreamReader(System.in), DEFAULT_BUF_SIZE);
        }

        public int[] readLineAsIntArray() throws IOException {
            String[] strArray = this.readLine().split(" ");
            int[] intArray = new int[strArray.length];
            for (int i = 0, n = strArray.length; i < n; i++) {
                intArray[i] = Integer.parseInt(strArray[i]);
            }
            return intArray;
        }

        public int[][] readAsIntMatrix(int rows, int columns) throws IOException {
            int[][] matrix = new int[rows][columns];
            for (int i = 0; i < rows; i++) {
                String[] r = this.readLine().split(" ");
                for (int j = 0; j < columns; j++) {
                    matrix[i][j] = Integer.parseInt(r[j]);
                }
            }
            return matrix;
        }
    }
}

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

l = []
for i in range(n):
    x,y = input().split()
    y = int(y)
    l.append([x,y,i])
l.sort(key=lambda x:x[1],reverse=True)
l.sort(key=lambda x:x[0])

for s in l:
    print(s[2]+1)

Measured memory_bytes: 62820
import sys

def calc():
    while 1:
        n = int(raw_input())
        if n <= 0:
            break
        a = 0
        b = 0
        while n > 0:
            ans = map(int, raw_input().split())
            if ans[0] > ans[1]:
                a += ans[0] + ans[1]
            elif ans[0] < ans[1]:
                b += ans [0] + ans[1]
            else:
                a += ans[0]
                b += ans[1]
            n -= 1
        print a, b
        
    
if __name__ == '__main__':
    calc()

Measured memory_bytes: 6372
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

set<string> make(string s)
{
	set<string> res;
	int n = s.size();
	REP(i, n)
	{
		string tmp = s;
		tmp.erase(tmp.begin() + i);
		res.insert(tmp);
	}
	REP(i, n + 1)
	{
		REP(j, 26)
		{
			char c = 'a' + j;
			string tmp = s;
			tmp.insert(tmp.begin() + i, c);
			res.insert(tmp);
		}
	}
	REP(i, n)
	{
		REP(j, 26)
		{
			char c = 'a' + j;
			string tmp = s;
			tmp[i] = c;
			res.insert(tmp);
		}
	}
	REP(i, n - 1)
	{
		string tmp = s;
		swap(tmp[i], tmp[i + 1]);
		res.insert(tmp);
	}
	return res;
}

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	int n, d;
	while (cin >> n >> d, n)
	{
		vs v(n);
		REP(i, n) cin >> v[i];
		sort(ALL(v));
		set<string> ans;
		if (d == 0)
		{
			REP(i, n)REP(j, i)
			{
				if (v[i] == v[j]) ans.insert(v[j] + "," + v[i]);
			}
		}
		vector<set<string>> st(n);
		REP(i, n)
		{
			st[i] = make(v[i]);
		}
		if (d == 1)
		{
			REP(i, n)REP(j, i)
			{
				if (st[i].count(v[j])) ans.insert(v[j] + "," + v[i]);
			}
		}
		if (d == 2)
		{

			REP(i, n)REP(j, i)
			{
				for (auto k : st[j])
				{
					if (st[i].count(k))
					{
						ans.insert(v[j] + "," + v[i]);
						break;
					}
				}
			}
		}
		for (auto i : ans) cout << i << endl;
		cout << ans.size() << endl;
	}
	return 0;
}

Measured memory_bytes: 17304
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
const double EPS = 1e-9;
typedef pair<int, int> P;
typedef unsigned int ui;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps=1e-8;
int main() {
	int n; cin >> n;
	rep(whi, n) {
		string s; cin >> s;
		int len = s.length();
		vector<int> v[10000];
		int cnt = 0;
		rep(i, len) {
			if (s[i] == '[')cnt++;
			else if (s[i] == ']') {
				sort(v[cnt].begin(), v[cnt].end());
				int l = v[cnt].size();
				int sum = 0;
				if (l == 1) {
					sum += v[cnt][0]/2+1;
				}
				else {
					rep(j, l / 2+1) {
						sum += v[cnt][j];
					}
				}
				v[cnt].clear();
				cnt--; v[cnt].push_back(sum);
			}
			else {
				string t; t = s[i];
				while ('0' <= s[i + 1] && s[i + 1] <= '9') {
					i++; t += s[i];
				}
				v[cnt].push_back(stoi(t));
			}
		}
		cout << v[0][0] << endl;
	}
	return 0;
}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main(){
  int h, w, m;
  cin >> h >> w >> m;
  vector<string> choco(h);
  for(int i=0; i<h; ++i) cin >> choco[i];
  int ans = INF;
  for(int i=0; i<(1<<(h-1)); ++i){
    int nans = 0;
    vector<int> gr(h);
    gr[0] = 0;
    for(int j=0; j<h-1; ++j){
      if(i>>j &1){
        gr[j+1] = gr[j] + 1;
        ++nans;
      }
      else gr[j+1] = gr[j];
    }
    vector<int> cnt(h, 0);
    vector<bool> cut(w+1, false);
    cut[0] = true;
    bool ansis = true;
    //cout << "grupe:" << gr[0] << " " << gr[1] << " " << gr[2] << endl;
    for(int j=0; j<w; ++j){
      for(int k=0; k<h; ++k){
        if(choco[k][j]-'0') ++cnt[gr[k]];
      }
      //cout << "j:" << j << " cnt:" << cnt[0] << " " << cnt[1] << " " << cnt[2] << endl;
      for(int k=0; k<h; ++k){
        if(cnt[k] > m && cut[j]){
          ansis = false;
          break;
        }else if(cnt[k] > m){
          ++nans;
          cut[j] = true;
          cnt = vector<int>(h,0);
          --j;
          break;
        }
      }
      if(!ansis) break;
    }
    //cout << "i:" << i << " ansis:" << ansis << " nans:" << nans << endl;;
    if(ansis) ans = min(ans, nans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
using P = pair<int,int>;
using ll = long long;
static const int INF = 1000000000;
static const ll MOD = 1000000007;

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  ll ans = 0;
  ll tmp  = 0;
  for(int i = 0; i < n-1; ++i){
    if(h[i] >= h[i+1]){
      tmp++;
    }
    else{
      tmp = 0;
    }
    ans = max(ans, tmp);
  }

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

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

using namespace std;
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    return GCD(b, a % b);
}

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

    int find_ = 1;
    repp(i, 0, N) {
        if (A[i] == find_) {
            ++find_;
        }
    }
    if (find_ == 1)
        cout << -1 << endl;
    else
        cout << N - find_ + 1 << endl;
}


Measured memory_bytes: 1024
package main

import (
	"fmt"
)

const n = 7

var (
	seq = []int{}
	flg bool
)

func dfs(left, i int, str string) {
	if i == len(seq) {
		if left == 0 && !flg {
			fmt.Printf("%s=%d\n", str, n)
			flg = true
		}
		return
	}
	for j := range make([]struct{}, 2) {
		if j == 1 || i != 0 {
			tmp := [...]string{"-", "+"}[j]
			if i == 0 {
				tmp = ""
			}
			tmp += string(seq[i] + '0')
			dfs(left-seq[i]*[...]int{-1, 1}[j], i+1, str+tmp)
		}
	}
}

func main() {
	var abcd string
	fmt.Scan(&abcd)

	for _, c := range abcd {
		seq = append(seq, int(c)-'0')
	}
	dfs(n, 0, "")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int N, L;
    cin >> N >> L;
    int sum = 0, Min = INT_MAX;
    for (int i = 0; i < N; i++)
    {
        chmin(Min, abs(L + i));
        sum += L + i;
    }
    for (int i = 0; i < N; i++)
    {
        if (Min == abs(L + i))
            sum -= L + i;
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
S = input()
l = len(S)
mozi = []
for i in range(l):
    mozi.append(S[i])
mozi = list(set(mozi))
C = [chr(i) for i in range(ord("a"),ord("z")+1)]

for i in mozi:
    for j in C:
        if i == j:
            C.remove(j)
if len(C) == 0:
    print("None")
else:
    print(C[0])

Measured memory_bytes: 9572
a,b,c,d,e,f = map(int, input().split())
water, suger = 0,0
dense = 0
waters = set()
sugers = set()
for i in range(0,31,a):
  for j in range(i,31,b):
    waters.add(j*100)
for i in range(0,f//2+1,c):
  for j in range(i,f//2+1,d):
    sugers.add(j)
waters = sorted(list(waters))
sugers = sorted(list(sugers))
for w in waters:
  for s in sugers:
    sw = w+s
    if sw > f or s > (w//100)*e or sw == 0:
      continue
    if s / (s+w) >= dense:
      water,suger = sw,s
      dense = s / (s+w)
print(water,suger)
    

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    ll r = 0;
    for (int i = 1; i <= n; i++) {
        if (i % 3 == 0 || i % 5 == 0) continue;
        r += i;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 3620
/*
    ____        __
   / __ \____  / /_  ____ _____ ___
  / /_/ / __ \/ __ \/ __ `/ __ `__ \
 / _, _/ /_/ / / / / /_/ / / / / / /
/_/ |_|\____/_/ /_/\__,_/_/ /_/ /_/
*/
#include<bits/stdc++.h>

typedef long long ll ;

#define X   first
#define Y   second
#define mp  make_pair
#define pii pair<int , int>
#define vec vector
#define vpii vector<pair<int , int>>
#define i_n   int i = 0 ; i< n ; i++
#define cn  int n ; cin>>n
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define migmig ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define cina int a[n] ; for(int i = 0 ; i < n ; i++) cin>>a[i]
#define pb push_back
#define SZ(x) ll(x.size())

using namespace std;
const int maxn = 1000*100+5 ;

int main()
{
	migmig ;
	int n ; 
	cin>>n; 
	vec<int>v; 
	int ans =0 ; 
	for(int i = 0 ; i < n ; i ++)
	{
		int x ; 
		 cin>>x ; 
		 if(x % 2 == 0) v.pb(x) ; 
		}	
	for(int i = 0 ; i < v.size() ; i++)
	{
	    //cout<<v[i]<" "; 
		while(v[i] > 1)
		{
			if(v[i]  % 2 == 0)
			{
				v[i] /= 2 ; 
				ans++ ; 
			}
			else 
			{
				break; 
			}
		}
	}
//	cout<<endl ; 
	cout<<ans; 
	
}
//////
////////
///////////



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rp(i,n) for(int i=0; i<n; i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
using G=vector<vector<int>>;

int dp[11][8][2];
int main(){
    string N;
    cin >> N;
    int d=N.size();
    vector<int> n(d);
    rp(i,d) n[i]=N[i]-'0';
    dp[1][0][1]=1;
    if(n[0]==3) dp[1][1][0]=1;
    if(n[0]>3){
        dp[1][1][1]=1;
        if(n[0]==5) dp[1][2][0]=1;
        if(n[0]>5){
            dp[1][2][1]=1;
            if(n[0]==7) dp[1][4][0]=1;
            if(n[0]>7) dp[1][4][1]=1;
        }
    }
    for(int i=1; i<d; i++){
        rp(j,8){
            rp(smaller,2){
                if(j==0) dp[i+1][0][1]=dp[i][0][1];
                if(!smaller&&n[i]<3) continue;
                dp[i+1][j|1][smaller||(3<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<5) continue;
                dp[i+1][j|2][smaller||(5<n[i])]+=dp[i][j][smaller];
                if(!smaller&&n[i]<7) continue;
                dp[i+1][j|4][smaller||(7<n[i])]+=dp[i][j][smaller];
            }
        }
    }
    cout << dp[d][7][0]+dp[d][7][1] << endl;
    return 0;
}

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

void swap(int *x, int *y){
  int z;
  z = *x;
  *x = *y;
  *y = z;
  return;
}

int main(){
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);
  swap(&x, &y);
  swap(&x, &z);
  printf("%d %d %d\n", x, y, z);
  return 0;
}

Measured memory_bytes: 128
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 11 05:38:56 2019

@author: shinjisu
"""


# ABC 200点問題
import math


def getInt(): return int(input())


def getIntList(): return [int(x) for x in input().split()]


def zeros(n): return [0]*n


def dmp(x):
    global debug
    if debug:
        print(x)


debug = True


def getIntLines(n): return [int(input()) for i in range(n)]


def getIntMat(n):
    mat = []
    for i in range(n):
        mat.append(getIntList())
    return mat


def zeros2(n, m): return [zeros(m)]*n


def prob096():  # Maximum Sum
    X = getIntList()
    K = getInt()
    dmp((X, K))
    total = sum(X) - max(X) + max(X)*2**K
    return total


def prob097():  # Exponential
    X = getInt()
    dmp(X)
    if X == 1:
        return 1
    for n in range(X, 0, -1):
        dmp(n)
        for b in range(2, int(math.sqrt(X))+1):
            a = n
            exp = True
            while a > 1:
                if a % b != 0:
                    exp = False
                    break
                a //= b
            if exp:
                break
        if exp:
            break
    return n


debug = False
print(prob097())


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

const int BRA = 18000;
const int BRB = 19000;
const int A1A = 19995;
const int A1B = 19996;
const int TMP = 12222;
const int CHK = 16666;
const int BUILD = 14000;
vector<array<int, 4>> ops;

void add(int a, int p, int q, int r) {
    ops.push_back({a, p, q, r});
}

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

    add(0, 2, 0, 1000);
    add(0, 2, 1, 1001);
    add(0, 1000, 1001, 1002);
    add(1, 1000, 1002, 3);
    add(1, 0, 3, A1A);
    add(1, 1, 3, A1B);
    for(int i = 4; i <= 32; i++)
        add(1, i - 1, i - 1, i);
    // a[i + 3] = 2^i for i <= 29
    int ps = 40;
    for(int d = 29; d >= 0; d--) {
        int pps = ps - 1;
        add(1, 3 + d, pps, ps);
        ps++;
        add(0, ps - 1, A1A, ps);
        ps++;
        add(1, 2, ps - 1, BRA + d);
        for(int j = 0; j < d; j++) {
            add(1, ps - 1, ps - 1, ps);
            ps++;
        }
        add(1, pps, ps - 1, ps);
        pps = ps;
        ps++;
    }
    ps = 9001;
    for(int d = 29; d >= 0; d--) {
        int pps = ps - 1;
        add(1, 3 + d, pps, ps);
        ps++;
        add(0, ps - 1, A1B, ps);
        ps++;
        add(1, 2, ps - 1, BRB + d);
        for(int j = 0; j < d; j++) {
            add(1, ps - 1, ps - 1, ps);
            ps++;
        }
        add(1, pps, ps - 1, ps);
        pps = ps;
        ps++;
    }

    for(int d1 = 0; d1 < 30; d1++) {
        for(int d2 = 0; d2 < 30; d2++) {
            add(1, 2, BRA + d1, CHK);
            add(1, 2, BRB + d2, CHK + 1);
            add(1, CHK, CHK + 1, CHK + 2);
            add(0, 3, CHK + 2, BUILD);
            for(int i = BUILD + 1; i <= BUILD + d1 + d2; i++)
                add(1, i - 1, i - 1, i);
            add(1, BUILD + d1 + d2, TMP, TMP);
        }
    }
    add(1, TMP, 2, 2);

    cout << ops.size() << '\n';
    for(auto &[a, p, q, r] : ops) {
        if(a == 0)
            cout << "< " << p << " " << q << " " << r << '\n';
        else
            cout << "+ " << p << " " << q << " " << r << '\n';
    }
}

Measured memory_bytes: 3764
#include <string.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <cstring>
#include <math.h>
#include <set>
#include <vector>
#include <algorithm>
#include <map>
#pragma warning(disable:4996)

using namespace std;

typedef long long ll;
#define INF 0x3f3f3f3f
#define ESP 1e-8;
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
const double PI = acos(-1.0);

#define N 505

struct ST{
	ST(int a, int b) {
		r = a, c = b;
	}
	int r, c;
};

int a[N][N], h, w, cnt, tot;
vector<ST> steps[N*N];

bool next(int &r, int &c) {
	if ((c == 1 && r%2 == 0) || (c == w && r%2))
		r++;
	else if (r % 2)
		c++;
	else
		c--;
	if (r > h)
		return 1;
	return 0;
}

int main() {
	int i, j;
	bool rec;
	while (scanf("%d%d", &h, &w) != EOF) {
		tot = rec = cnt = 0;
		for (i = 0; i <= h * w; i++)
			steps[i].clear();
		for (i = 1; i <= h; i++)
			for (j = 1; j <= w; j++)
				scanf("%d", &a[i][j]);
		i = j = 1;
		do {
			if (a[i][j] % 2) {
				steps[cnt].push_back(ST(i, j));
				if (rec)
					cnt++;
				rec = !rec;
			}
			else if (rec)
				steps[cnt].push_back(ST(i, j));
		} while (!next(i, j));
		for (i = 0; i < cnt; i++) 
			tot += steps[i].size() - 1;
		printf("%d\n", tot);
		for (i = 0; i < cnt; i++)
			for (j = 0; j < steps[i].size() - 1; j++) {
				int r1, c1, r2, c2;
				r1 = steps[i][j].r;
				c1 = steps[i][j].c;
				r2 = steps[i][j + 1].r;
				c2 = steps[i][j + 1].c;
				printf("%d %d %d %d\n", r1, c1, r2, c2);
			}
	}

	return 0;
}

Measured memory_bytes: 12928
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	string a;
	cin >> a;
	int n = a.size();
	vec(c,26);
	REP(i,n){
		char t = a[i];
		int d = t-97;
		c[d]++;
	}
	REP(i,26){
		if(c[i] == 0){
			char s = i + 97;
			cout << s << endl;
			goto owa;
		}
	}
	cout << "None" << endl;
	owa:

    return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;


public class Main {
	public int a[]= new int[10];
	public void topThree(){
		
	}
	public void order(){
		int temp;
		int i,j;
		for(i=0;i<3;i++)
			for(j=i;j<10;j++){
				if(a[i]<a[j]){
					temp=a[j];
					a[j]=a[i];
					a[i]=temp;
				}
			}
	}
	public void display(){
		int i;
		for(i=0;i<3;i++){
			System.out.println(a[i]);
		}
	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		Scanner sc = new Scanner(System.in);
		Main m=new Main();
		int i=0;
		for(i=0;i<10;i++){
			m.a[i]=sc.nextInt();
		}
		m.order();
		m.display();
		
	}
	
}

Measured memory_bytes: 12000
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
ll N;
ll a[300001];
ll R=0;
int main() {
	cin>>N;
	for(int i = 0; i<N * 3; i++)cin>>a[ i ];

	sort(a,a + N * 3, greater<long long>() );


	int S = 0;
	for(int i = 1; S<N; i+=2){
		R += a[ i ];
		S += 1;
	}



	cout<<R<<endl;
 	return 0;
}


Measured memory_bytes: 2560