akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using  namespace std;
int main(){
    long long n, a;
    cin >> n;
    long long B[n];
    for(int i=0;i<n;i++){
       cin >> a;
       if(n%2==0){
           if((i+1)%2==1){
               B[n/2+((i+1)/2)] = a;
           }else{
               B[n/2-((i+1)/2)] = a;
           }
       }else{
           if((i+1)%2==1){
               B[n/2-((i+1)/2)] = a;
           }else{
               B[n/2+((i+1)/2)] = a;
           }
       }
    }
    for(int i=0;i<n;i++){
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
 
}


Measured memory_bytes: 3712
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)






int main() {
    ll n;
    cin >> n;
    vector<ll> a(n), b(n), c(n);
    REP(i, n){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector<vector<ll>> dp(n + 1, vector<ll>(3));
    REP(i, n){
        dp[i + 1][0] = max({dp[i + 1][0], dp[i][1] + a[i], dp[i][2] + a[i]});
        dp[i + 1][1] = max({dp[i + 1][1], dp[i][0] + b[i], dp[i][2] + b[i]});
        dp[i + 1][2] = max({dp[i + 1][2], dp[i][0] + c[i], dp[i][1] + c[i]});
    }
    cout << max({dp[n][0], dp[n][1], dp[n][2]}) << endl;
}


Measured memory_bytes: 8064
def solve(n, a, b):
    if a > b:
        return 0
    if a == b:
        return 1
    # if a < b
    if n == 1:
        return 0
    return (b * (n - 1) + a) - (a * (n - 1) + b) + 1

n, a, b = map(int, input().split())
print(solve(n, a, b))


Measured memory_bytes: 2940
#include<set>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int X[200011], Y[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) {
	scanf("%d%d", X+i, Y+i);
	if (X[i] > Y[i]) swap(X[i], Y[i]);
    }

    LL ans = 1LL<<62;
    LL xmi = *min_element(X, X+N);
    LL xma = *max_element(X, X+N);
    LL ymi = *min_element(Y, Y+N);
    LL yma = *max_element(Y, Y+N);
    amin(ans, (xma - xmi) * (yma - ymi));

    LL w = max(xma, yma) - min(xmi, ymi);

    multiset<int> M(X, X+N);
    vector<pair<int, int> > V;
    V.reserve(N);
    REP (i, N) {
	V.emplace_back(X[i] + Y[i], X[i]);
    }
    sort(V.begin(), V.end());

    amin(ans, w * (*M.rbegin() - *M.begin()));
    REP (i, N) {
	M.erase(M.find(V[i].second));
	M.insert(V[i].first - V[i].second);
	amin(ans, w * (*M.rbegin() - *M.begin()));
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 12800
N = int(input())
P = [int(input()) for _ in range(N)]
Q = [0] * N
for i in range(N):
    Q[P[i]-1] = i
ans = 0
cnt = 1
for i in range(N-1):
    if Q[i] < Q[i+1]:
        cnt += 1
    else:
        ans = max(ans, cnt)
        cnt = 1
ans = max(ans, cnt)
print(N - ans)

Measured memory_bytes: 18888
n = gets.to_i
ss = gets.chomp.chars
ans = ss.count("R") * ss.count("G") * ss.count("B")

0.upto(n) do |i|
  j = 1

  while i + 2 * j < n
    k = i + 2 * j

    a = ss[i]
    b = ss[i + j]
    c = ss[k]
    ans -= 1 if a != b && b != c && c != a

    j += 1
  end
end

puts ans


Measured memory_bytes: 14384
import java.util.Scanner;

public class Main{
	public static void main(String args[]) {
		Scanner scn = new Scanner(System.in);
		int N,M;
		int x,y,ans;
		String dir;
		int dis;
		boolean[][] map;
		while((N = scn.nextInt()) != 0) {
			map = new boolean[21][21];
			for(int i = 0;i < N;i++) {
				map[scn.nextInt()][scn.nextInt()] = true;
			}
			M = scn.nextInt();
			x = 10;y = 10;ans = 0;
			for(int i = 0;i < M;i++) {
				dir = scn.next();
				dis = scn.nextInt();
				for(int j = 0;j < dis;j++) {
					switch(dir) {
					case "N":
						y++;
						break;
					case "W":
						x--;
						break;
					case "S":
						y--;
						break;
					default:
						x++;
						break;
					}
					if(map[x][y]) {
						ans++;
						map[x][y] =false;
					}
				}
			}
			System.out.println(ans == N?"Yes":"No");
		}
		scn.close();
	}
}



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

// ====================================================================
#ifdef LOCAL
void __print(int x) {std::cerr << x;} void __print(long x) {std::cerr << x;} void __print(long long x) {std::cerr << x;} void __print(unsigned x) {std::cerr << x;}
void __print(unsigned long x) {std::cerr << x;} void __print(unsigned long long x) {std::cerr << x;} void __print(float x) {std::cerr << x;}
void __print(double x) {std::cerr << x;} void __print(long double x) {std::cerr << x;} void __print(char x) {std::cerr << '\'' << x << '\'';}
void __print(const char *x) {std::cerr << '\"' << x << '\"';} void __print(const std::string &x) {std::cerr << '\"' << x << '\"';} void __print(bool x) {std::cerr << (x ? "true" : "false");}
template<typename T, typename V> void __print(const std::pair<T, V> &x) {std::cerr << '{'; __print(x.first); std::cerr << ", "; __print(x.second); std::cerr << '}';}
template<size_t N> void __print(std::bitset<N> v) {std::cerr << '{'; for (size_t i = 0; i < N; i++) {std::cerr << v[i];} std::cerr << '}';}
template <typename A, typename B, typename C, typename D> void __print(std::tuple<A, B, C, D> p) {std::cerr << '(' << std::to_string(std::get<0>(p)) << ", " << std::to_string(std::get<1>(p)) << ", " << std::to_string(std::get<2>(p)) << ", " << std::to_string(std::get<3>(p)) << ')';}
template <typename A, typename B, typename C> void __print(std::tuple<A, B, C> p) {std::cerr << '(' << std::to_string(std::get<0>(p)) << ", " << std::to_string(std::get<1>(p)) << ", " << std::to_string(std::get<2>(p)) << ')';}
template <typename A, typename B> void __print(std::tuple<A, B> p) {std::cerr << '(' << std::to_string(std::get<0>(p)) << ", " << std::to_string(std::get<1>(p)) << ')';}
template<typename T> void __print(const T &x) {int f = 0; std::cerr << '{'; for (auto &i: x) std::cerr << (f++ ? ", " : ""), __print(i); std::cerr << "}";} void _print() {std::cerr << "]\n";}
template <typename T, typename... V> void _print(T t, V... v) {__print(t); if (sizeof...(v)) std::cerr << ", "; _print(v...);}
#define debug(x...) std::cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...) "?"
#endif
// ====================================================================

signed main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(NULL);

    int n, m;
    std::cin >> n >> m;

    std::vector<int> parent(n + 1);
    std::vector<int> size(n + 1, 1);
    std::iota(parent.begin(), parent.end(), 0);
    
    std::function<int(int)> root = [&](int x) {
        if (parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    };

    std::function<void(int, int)> unite = [&](int u, int v) {
        u = root(u);
        v = root(v);
        if (u == v) return;

        if (size[u] < size[v]) std::swap(u, v);
        parent[v] = u;
        size[u] += size[v];
    };


    // std::vector<std::vector<int>> g(n + 1);

    for (int _ = 0; _ < m; _++) {
        int u, v;
        std::cin >> u >> v;
        unite(u, v); 
        // g[u].emplace_back(v);
        // g[v].emplace_back(u);
    }

    std::cout << *std::max_element(size.begin() + 1, size.end());

    return 0;
}



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

int main(){
    int n;
    double w,h;
    while(scanf("%d,%lf,%lf", &n, &w, &h) != -1){
        double bmi = w/h/h;
        if(bmi >= 25)
            cout << n << endl;
    }
}
        
    

Measured memory_bytes: 1232
n=int(input())
ans=[0]*(10**4+1)
for x in range(1,10**2+1):
    for y in range(1,10**2+1):
        for z in range(1,10**2+1):
            if x**2+y**2+z**2+x*y+y*z+z*x<=10**4:
                ans[x**2+y**2+z**2+x*y+y*z+z*x]+=1
for i in range(1,n+1):
    print(ans[i])

Measured memory_bytes: 9340
/* winners never quit and quitters never win.
      #swap                                 */
      
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt(),k=nxt();
	ll sum1=0,sum2=0;
	rep(a,0,k-1)
		sum1+=a;
	rep(a,n+1,n-k+2)
		sum2+=a;
	ll ans=0,ind1=k-1,ind2=n-k+1;
	while(k<=n+1)
	{
		sum1+=ind1,sum2+=ind2;
		ind1++,ind2--;
		ll mini=min(sum1,sum2),maxi=max(sum1,sum2);
		ans=(ans+maxi-mini+1)%mod;
		k++;
	}
	cout<<ans<<endl;
	printclock;
	return 0;
}


Measured memory_bytes: 3808
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <iostream>
#include <queue>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <string>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug: "<<x<<" "<<y<<endl;
using namespace std;
typedef long long ll;
const int maxn = 605;
const int mod = 1000000007;

vector<int>e[maxn];
double f[maxn];
int n;

double solve(int idx){
  for(int i=1;i<=n;i++)f[i]=0;
  for(int i=n-1;i>=1;i--){
    double mx = 0, sum = 0;
    for(int j=0;j<e[i].size();j++){
      sum+=f[e[i][j]];
      mx=max(mx,f[e[i][j]]);
    }
    if(idx!=i)f[i]=sum/e[i].size()+1;
    else f[i] = (sum-mx)/(e[i].size()-1)+1;
  }
  return f[1];
}

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int m;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int x,y;
    cin>>x>>y;
    e[x].push_back(y);
  }
  double ret = -1000.0;
  for(int i=1;i<n;i++){
    int idx = i;
    if(e[i].size()<=1)idx=n+1;
    double tt = solve(idx);
    if(ret<0||ret>tt)ret=tt;
  }
  printf("%.10f\n",ret);
  return 0;
}

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

int main(){
  int N,T;
  cin >> N >> T;
  vector<int> C(N),Time(N);
  for(int i=0;i<N;i++){
    cin >> C.at(i) >> Time.at(i);
  }
  int min,safe,out;
  safe = 0;
  out = 0;
  for(int i=0;i<N;i++){
    if(Time.at(i)<=T){
      if(safe == 0){
        min = C.at(i);
        safe++;
      }
      else if(C.at(i) < min){
        min = C.at(i);
        safe++;
      }
    }
    else
      out++;
  }
  if(out == N)
    cout << "TLE";
  else
  cout << min;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.Math.*;

public class Main {

	int INF = 1 << 28;
	//long INF = 1L << 62;
	double EPS = 1e-10;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n = sc.nextInt();
			if(n == 0) break;
			int m = sc.nextInt();
			UnionFind uf = new UnionFind(n);
			P[] ps = new P[m];
			int ans = 0;
			for(int i=0;i<m;i++) {
				String[] sp = sc.next().split(",");
				ps[i] = new P(Integer.parseInt(sp[0]), Integer.parseInt(sp[1]), Integer.parseInt(sp[2])/100 - 1);
			}
			sort(ps);
			for(P p: ps) if(!uf.same(p.f, p.t)){
				uf.unite(p.f, p.t);
				ans += p.v;
			}
			System.out.println(ans);
		}
	}
	
	public class UnionFind {
		int[] par, rank;
		
		public UnionFind(int n) {
			par = new int[n];
			rank = new int[n];
			for(int i=0;i<n;i++) par[i] = i;
		}
		
		//代表元を求める
		int find(int x) {
			if( par[x] == x ) return x;
			return par[x] = find(par[x]);
		}
		
		//要素xとyを併合する
		void unite(int x, int y) {
			x = find(x);
			y = find(y);
			if( x == y ) return;
			
			if( rank[x] < rank[y]  ) par[x] = y;
			else {
				par[y] = x;
				if( rank[x] == rank[y] ) rank[x]++;
			}
		}
		
		//同一の集合に含まれるか調べる．trueならxとyは同じ集合，falseなら異なる
		boolean same(int x, int y) {
			return find(x) == find(y);
		}
	}
	
	class P implements Comparable<P>{
		int f, t, v;
		
		P(int f, int t, int v) {
			this.f = f;
			this.t = t;
			this.v = v;
		}
		@Override
		public int compareTo(P o) {
			// TODO 自動生成されたメソッド・スタブ
			return v-o.v;
		}
	}

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

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 34184
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(), (x).end()
#define INF 1000000007
#define mod 1005
#define ll long long int
const double mx = 2e6 + 5 ;
void solve()
{
	int a, b, c;
	cin>>a>>b>>c;
	if(a+b+c>=22)
		cout<<"bust\n";
	else
		cout<<"win\n";
}
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3620
N = int(input())
AC=0
WA=0
TLE=0
RE=0
for i in range(N):
    tmp=input()
    if tmp=='AC':
        AC+=1
    elif tmp=='WA':
        WA+=1
    elif tmp=='TLE':
        TLE+=1
    elif tmp=='RE':
        RE+=1



ans="AC x "+str(AC)+"\n"+"WA x "+str(WA)+"\n"+"TLE x "+str(TLE)+"\n"+"RE x "+str(RE)+"\n"
print("{}".format(ans))


Measured memory_bytes: 9196
#![allow(unused_imports)]
    #![allow(dead_code)]
    use std::io::prelude::*;
    use std::cmp::{max, min};
    use std::collections::BinaryHeap;

    const MOD: i64 = 1e9 as i64 + 7; 

    fn main(){
        let n: usize = read();
        let mut a: Vec<usize> = vec![0; 5];
        for i in 0..n{
            let s: Vec<char> = read::<String>().chars().collect();
            match s[0] {
                'M' => a[0] += 1,
                'A' => a[1] += 1,
                'R' => a[2] += 1,
                'C' => a[3] += 1,
                'H' => a[4] += 1,
                _ => {},
            }
        }
        let mut ans: usize = 0;
        for i in 0..5{
            for j in i+1..5{
                for k in j+1..5{
                    ans += a[i] * a[j] * a[k];
                }
            }
        }
        println!("{}", ans);
    }

    fn read<T>() -> T
    where
        T: std::str::FromStr,
    {
        let stdin = std::io::stdin();
        let token: String = stdin
            .lock()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect();
        token.parse().ok().unwrap()
    }


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define OUT(x) cout << (x) << endl;
#define REP(i, n) for (int i=0; i<n; ++i)

int main(){
    int N;
    cin >> N;
    int A[5][120];
    for(int i=1; i<=2; i++){
        REP(j, N){
            cin >> A[i][j+1];
        }
    }

    // じつはN通りしかないので
    int ans=0;
    for(int i=1; i<=N; i++){
        int sum = 0;
        // 1~i
        for(int j=1;j<=i;j++){
            sum += A[1][j];
        }
        // i~N
        for(int j=i;j<=N;j++){
            sum += A[2][j];
        }
        if(ans < sum){
            ans=sum;
        } 
    }
    OUT(ans);
}


Measured memory_bytes: 256
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	q := getNextInt(scanner)
	aa := make([]int64, n)
	for i := 0; i < n; i++ {
		aa[i] = getNextInt64(scanner)
	}
	for i := 0; i < q; i++ {
		x := getNextInt64(scanner)
		l := -1
		s := int64(0)
		ans := int64(0)
		for r := 0; r < n; r++ {
			s += aa[r]
			for r > l && s > x {
				l++
				s -= aa[l]
			}
			ans += int64(r - l)
		}
		fmt.Fprintln(writer, ans)
	}
}



Measured memory_bytes: 4532
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

const int INF = 100000;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n, m; cin >> n >> m;
    vector<int> c(m);
    for (int i = 0; i < m; i++) cin >> c[i];
    
    vector<vector<int>> dp(m + 1, vector<int>(n + 1, INF));
    for (int i = 0; i < m + 1; i++) {
        dp[i][0] = 0;
    }
    
    for (int i = 0; i < m; i++) {
        for (int j = 0; j <= n; j++) {
            dp[i + 1][j] = (j - c[i] >= 0 ? min(dp[i + 1][j - c[i]] + 1, dp[i][j]) : dp[i][j]);
        }
    }
    
    cout << dp[m][n] << endl;
    
    return 0;
}



Measured memory_bytes: 7160
N, M, X = map(int,input().split())

C = list()
A = list()
for i in range(N):
	temp = list(map(int,input().split()))
	C.append(temp[0])
	A.append(temp[1:])	


MAX = 100000000000	

def func(cost,a,i):
	if min(a) >= X:
		return cost
	elif i == N:
		return MAX
	total_A = [x+y for (x,y) in zip(a,A[i])]
    
	return min(func(cost + C[i],total_A,i+1),func(cost,a,i+1))
	
ans = func(0,[0]*M,0)

if ans == MAX:
	print(-1)
else:
	print(ans)

Measured memory_bytes: 9228
#include<bits/stdc++.h>
	// #include <ext/pb_ds/assoc_container.hpp>
	// #include <ext/pb_ds/tree_policy.hpp>
	// using namespace __gnu_pbds;
	using namespace std;
	
	// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
	#define ll long long int
	#define ld long double
	#define pb push_back
	#define mp make_pair
	#define pll pair<ll,ll>
	
	vector <ll> v;
	
	ll fep(ll x, ll y, ll mod)
	{ll res=1;while(y>0){if(y&1)res=(res*x)%mod;
	    y=y>>1;x=(x*x)%mod;}return res%mod;}
	
	int main()
	{
		ios_base::sync_with_stdio(false);
		cin.tie(0);cout.tie(0);
	
		ll n,i,m,j,k,x,y,a,b,c,d,t,r;
		string s;
		
		cin >> r;
		cout << 2*3.1415*r;
	
		return 0;
	}


Measured memory_bytes: 3792
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };
bool valid_pos(int x, int y, int w, int h) { return 0 <= x && x < w && 0 <= y && y < h; }


vector<int> calc_required_level_to_rooms()
{
	int w, h, sx, sy;
	static int req[512][512];
	cin >> w >> h >> sx >> sy;
	--sx, --sy;
	for (int y = 0; y < h; ++y)
		for (int x = 0; x < w; ++x)
			cin >> req[y][x];

	vector<int> res;
	res.push_back(0);

	static bool visit[512][512];
	CLEAR(visit, 0);

	typedef pair<int, pint> P;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(1, pint(sx, sy)));
	while (!q.empty())
	{
		P tt = q.top(); q.pop();
		int level = tt.first;
		int x = tt.second.first, y = tt.second.second;
		if (visit[y][x])
			continue;

		visit[y][x] = true;
		res.push_back(level);

		for (int i = 0; i < 4; ++i)
		{
			int tx = x + dx[i], ty = y + dy[i];
			if (valid_pos(tx, ty, w, h) && !visit[ty][tx])
				q.push(P(max(level, req[ty][tx]), pint(tx, ty)));
		}
	}
	return res;
}
int main()
{
	ios::sync_with_stdio(false);

	int r;
	while (cin >> r, r)
	{
		vector<int> a = calc_required_level_to_rooms();
		vector<int> b = calc_required_level_to_rooms();

		if (a.size() < b.size())
			swap(a, b);

		int res = 1e9;
		for (int i = min<int>(r, a.size() - 1); i >= 0 && r - i < b.size(); --i)
			min_swap(res, a[i] + b[r - i]);
		cout << res << endl;
	}
}

Measured memory_bytes: 0
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int n,m,a[N],num,ans,AC;
string str;
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		cin>>num>>str;
		if(str=="AC")
		{
			if(a[num]!=-1)
				ans+=a[num],a[num]=-1,AC++;
		}
		else
		{
			if(a[num]!=-1)
				a[num]++;
		}
	}
	cout<<AC<<' '<<ans;
	return 0;
}

Measured memory_bytes: 640
#ABC066C
n=int(input())
a=list(map(int, input().split()))
flg=n%2
half=n//2
front=[0]*(half+flg)
back=[0]*(half)
for i in range(half):
    front[half+flg-1-i]=a[2*i-flg+1]
    back[i]=a[2*i+flg]
if flg==1:
    front[0]=a[n-1]
print(' '.join(map(str, front+back)))


Measured memory_bytes: 31296
#include <iostream>
#include <string>
#include <vector>
using namespace std;


int main() {
	string correctS = "CODEFESTIVAL2016";
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.length(); ++i) {
		if (correctS[i] != s[i]) {
			++count;
		}
	}
	cout << count;

	return 0;
}


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

using namespace std;
int main()
{
  long int a, b, c, d;

  cin >> a >> b >> c;

  d = c - a - b;
  if (d > 0 && d * d > 4 * a * b)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin >> n;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  int ans=0,cnt=1;
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cnt++;
    }
    else{
      ans+=(cnt%2);
      cnt=1;
    }
  }
  ans+=(cnt%2);
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main() {
int N;
cin >> N;
int answer = 0;
for (int C = 1; C <= N; C += 2) {
    int num_of_divisors = 0;
    for (int X = 1; X <= C; ++X) {
        if(C % X == 0) {
            ++num_of_divisors;
        }
    }
if (num_of_divisors == 8) {
    ++answer;
    }
}
cout << answer << "\n";
return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,Pll> a,pair<ll,Pll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se.fi>b.se.fi;
}
//----------------------------------------------------------------------
ll dp[500][500];
ll sum[500];V<ll>a;
bool flag[500][500];
ll f(ll l,ll r){
    if(flag[l][r])return dp[l][r];
    flag[l][r]=1;
    ll res=INF;
    for(ll m=l;m<r;m++){
        chmin(res,sum[r]-sum[l]+a[l]+f(l,m)+f(m+1,r));
    }
    dp[l][r]=res;
    //cout<<l<<" "<<r<<" "<<dp[l][r]<<endl;
    return dp[l][r];
}
//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //-------------------------------
    ll n;cin>>n;
    a.resize(n);
    for(ll i=0;i<n;i++)cin>>a[i];
    sum[0]=a[0];
    for(ll i=1;i<n;i++){
        sum[i]=sum[i-1]+a[i];
        //cout<<sum[i]<<endl;
    }
    for(ll i=0;i<500;i++){
        for(ll j=0;j<500;j++){
            dp[i][j]=INF;
        }
        dp[i][i]=0;
        flag[i][i]=1;
    }
    cout<<f(0,n-1)<<endl;
    //-------------------------------  
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------







































Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(10**7)

def dfs(v, end):
    if visited[v]:
        return False
    visited[v] = True
    
    for e in graph[v]:
        res = dfs(e, end)
        if res:
            return True
    if v == end:
        return True
    else:
        return False
        

if __name__ == '__main__':
    N, M = map(int, input().split())
    A = [None]*M
    graph = [[] for _ in range(N)]
    
    for i in range(M):
        a, b = map(int, input().split())
        a -= 1
        b -= 1
        A[i] = [a, b]
        graph[a].append(b)
        graph[b].append(a)
    
    
    count = 0
    for a, b in A:
        graph[a].remove(b)
        graph[b].remove(a)
        visited = [False]*N
        if not dfs(a, b):
            count += 1
        graph[a].append(b)
        graph[b].append(a)
    print(count)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
class Program
{

    static void Main()
    {
        string[] ND = Console.ReadLine().Split(' ');
        long n = long.Parse(ND[0]);
        long d = long.Parse(ND[1]);
        long[] x = new long[n];
        long[] y = new long[n];
        long xy = 0;
        int count = 0;
        for(int i=0;i<n;i++)
        {
            string[] XY = Console.ReadLine().Split(' ');
            
            x[i] = long.Parse(XY[0]);
            y[i] = long.Parse(XY[1]);
            x[i] = x[i] * x[i];
            y[i] = y[i] * y[i];
            xy = x[i] + y[i];
            double root = Math.Sqrt(xy);
            if (root <= d)
            {
                count++;
            }
        }

        Console.WriteLine(count);
    }

}



Measured memory_bytes: 43696
#include <bits/stdc++.h>
//#include <ext/numeric>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#define oo 0x3f3f3f3f
#define OO 0x3f3f3f3f3f3f3f3f
#define popcount(n) __builtin_popcount(n)
#define popcountll(n) __builtin_popcountll(n)

using namespace std;
//using namespace __gnu_cxx;
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const double PI = acos(-1.0), EPS = 1e-6;
const long long inf = 2e12 + 12;
const int MAXN = 1000006, MAXM = 1003, Mod = 1000000007 , MAXLog = 20;


double area(int n, vector<pair<pair<int, int>, char>> &arr, double moment) {
    double mnx = LLONG_MAX, mxx = LLONG_MIN, mny = LLONG_MAX, mxy = LLONG_MIN;
    for (int i = 0; i < n; ++i) {
        double x = arr[i].first.first;
        double y = arr[i].first.second;
        if (arr[i].second == 'R') {
            x += moment;
        } else if (arr[i].second == 'L') {
            x -= moment;
        } else if (arr[i].second == 'U') {
            y += moment;
        } else {
            y -= moment;
        }
        mnx = min(mnx, x);
        mxx = max(mxx, x);
        mny = min(mny, y);
        mxy = max(mxy, y);
    }
//    cout << mxx << ' ' << mnx << ' ' << mxy << ' ' << mny << '\n';
    return 1.0 * (mxx - mnx) * (mxy - mny);
}


int main() {
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "rt", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0), cout.precision(9), cout << fixed;

    int n;
    cin >> n;
    vector<pair<pair<int, int>, char>> arr(n);
    for (int i = 0; i < n; ++i) {
        cin >> arr[i].first.first >> arr[i].first.second >> arr[i].second;
    }

    double l = 0, r = inf;
    double ans = LLONG_MAX;
    for (int i = 0; i < 300; ++i) {
        double m1 = l + (r - l) / 3;
        double m2 = r - (r - l) / 3;
        double f1 = area(n, arr, m1);
        double f2 = area(n, arr, m2);
        if (f1 > f2) {
            l = m1;
        } else {
            r = m2;
        }
        ans = min(ans, min(f1, f2));
    }

    cout << min(area(n, arr, l), area(n, arr, r)) << '\n';

    return 0;
}

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

int main()
{
    int a , b , c ;
    cin >> a >> b >> c ;
    cout << a <<" "<< b <<" "<< 3*c-a-b <<" "<< endl ;
    cout << 4*c-2*a-b <<" "<< c <<" "<< 2*a+b-2*c <<" "<< endl ;
    cout << a+b-c <<" "<< 2*c-b <<" "<< 2*c-a <<" "<< endl ;
}

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

int main(void) {
    int n = 0;
    char s[8] = {0};

    scanf("%s", s);
    printf("%s", s[2] == s[3] && s[4] == s[5] ? "Yes" : "No"); 
    return 0;
}



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

int main(){
  int a,b,c;
  cin>>a>>b>>c;
  if((a==5&&b==5&&c==7) || (a==5&&b==7&&c==5) || (a==7&&b==5&&c==5)){
    cout << "YES" <<endl;
  }else{
    cout << "NO";
  }
}

Measured memory_bytes: 256
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>
using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N;
string S;
ll sum = 0;
ll color[3] = {};

int main() {
    cin >> N;
    cin >> S;
    REP(i, N) {
        if (S[i] == 'R') color[0]++;
        else if (S[i] == 'G') color[1]++;
        else color[2]++;
    }
    sum += color[0] * color[1] * color[2];

    
    //iは次の数字
    //int i = 1;
    //jは先頭の数字
    //int j = 1;
    for (int j = 1; j <= N; j++) {
        int i = 1;
        while (j + 2 * i <= N) {
            if (S[j - 1] != S[j + i - 1] && S[j + i - 1] != S[j + 2 * i - 1] && S[j + 2 * i - 1] != S[j - 1]) {
                //cout << "S[" << j - 1 << "]:" << S[j - 1] << " ";
                //cout << "S[" << j + i - 1 << "]:" << S[j + i - 1] << " ";
                //cout << "S[" << j + 2 * i - 1 << "]:" << S[j + 2 * i - 1] << endl;
                //全部違ったら
                sum--;
            }
            i++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3640
#include <iostream>
#include <iomanip> // << fixed << precision(10)
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
using namespace std;

#define FOR(i,s,t) for(int i=s;i<t;i++)
#define REP(i,n) FOR(i,0,n)
#define PRINT(s) cout << s << "\n"
#define SORT(A) sort(A.begin(), A.end())
#define EACHPRINT(A, T) for_each(begin(A), end(A), [&](T i){ cout << i << " "; });cout << "\n"
#define NEWMAT(N, M, ini) MAT(N, vector<lint>(M, ini))
#define MOD 1000000007

typedef long long lint;
typedef pair<lint, lint> P;
typedef vector<lint> V;
typedef vector<vector<lint>> MAT;
bool lessPair(const P& l, const P& r){return l.second < r.second;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lint N; cin >> N;
    lint Q; cin >> Q;
    string S; cin >> S;

    V X(N);
    X[0] = 0;
    REP(i, N-1) {
      if (S[i] == 'A' && S[i+1] == 'C') {
        X[i+1] = X[i] + 1;
      } else {
        X[i+1] = X[i];
      }
    }

    REP(i, Q) {
      lint x, y;
      cin >> x; cin >> y;
      PRINT(X[y-1]-X[x-1]);
    }
    return 0;
}


Measured memory_bytes: 1872
#include <stdio.h>

int main(void)
{
  int i;
  int card[2];

  for (i = 0; i < 2; i++) {
    scanf("%d", card + i);
    if (card[i] == 1)card[i] += 13;
  }

  printf((card[0] > card[1]) ? "Alice\n" : ((card[0] < card[1]) ? "Bob\n" : "Draw\n"));

  return(0);
}

Measured memory_bytes: 128
import java.io.PrintStream;
import java.util.Scanner;
public class Main {
    private static final PrintStream so = System.out;
    private static final Scanner     sc = new Scanner(System.in);

    public static void main(String[] args) {
        char[] a = sc.next().toCharArray();
        int w = sc.nextInt();
        
        for (int i = 0; i < a.length; i++) {
            if (i % w == 0) so.print(a[i]);
        }
    }
}


Measured memory_bytes: 23764
#include <cstdio>
#include <queue>
#include <algorithm>
using namespace std;
#define INF 1000001
//#define min(a,b) ((a) < (b) ? (a) : (b))
int main(){
    int cost[100][100];
    while (1) {
        int n,k,i,j;
        scanf("%d %d",&n,&k);
        if (n==0&&k==0) {
            return 0;
        }
        for (i=0; i<n; i++) {
            for (j=0; j<n; j++) {
                cost[i][j]=INF;
            }
        }
        for (i=0; i<k; i++) {
            int x;
            scanf("%d",&x);
            if (x==1) {
                int c,d,e;
                scanf("%d %d %d",&c,&d,&e);
                cost[c-1][d-1]=min(e, cost[c-1][d-1]);
                cost[d-1][c-1]=min(e, cost[c-1][d-1]);
            }else if (x==0){
                int a,b,sum[n];
                queue<int> q;
                for (j=0; j<n; j++) {
                    sum[j]=0;
                }
                scanf("%d %d",&a,&b);
                q.push(a-1);
                while (!q.empty()) {
                    int p=q.front();
                    q.pop();
                    for (j=0; j<n; j++) {
                        if (cost[p][j]!=INF&&a-1!=j) {
                            if (sum[j]>sum[p]+cost[p][j]||sum[j]==0) {
                                sum[j]=sum[p]+cost[p][j];
                                q.push(j);
                            }
                        }
                    }
                }
                if (sum[b-1]==0) {
                    printf("-1\n");
                }else{
                    printf("%d\n",sum[b-1]);
                }
            }
        }
    }
}

Measured memory_bytes: 1100
# AOJ 1202: Mobile Phone Coverage
# Python3 2018.7.28

from bisect import bisect_left
cno = 0
while True:
	n = int(input())
	if n == 0: break
	tbl, xx, yy = [], set(), set()
	for i in range(n):
		x, y, r = map(float, input().split())
		x, y, r = int(100*x), int(100*y), int(100*r)
		x1, y1, x2, y2 = x-r, y-r, x+r, y+r
		tbl.append((x1, y1, x2, y2))
		xx.add(x1); xx.add(x2)
		yy.add(y1); yy.add(y2)
	xx = sorted(xx); yy = sorted(yy)
	arr = [[0 for c in range(201)] for r in range(201)]
	for x1, y1, x2, y2 in tbl:
		l = bisect_left(xx, x1); r = bisect_left(xx, x2)
		u = bisect_left(yy, y1); d = bisect_left(yy, y2)
		for y in range(u, d):
			for x in range(l, r): arr[y][x] = 1
	ans = 0
	for r in range(1, len(yy)):
		t = yy[r]-yy[r-1]
		for c in range(1, len(xx)):
			if arr[r-1][c-1]: ans += t * (xx[c]-xx[c-1])
	ans //= 100
	cno += 1
	print(cno, "{:d}.{:02d}".format(ans//100, ans%100))



Measured memory_bytes: 6304
n = int(input())
t, x, y, ok = 0, 0, 0, True
for _ in range(n):
    t2, x2, y2 = map(int, input().split())
    dt = t2 - t
    delta = abs(x - x2) + abs(y - y2)
    if delta > dt:
        ok = False
    elif (delta - dt) % 2:
        ok = False
    t, x, y = t2, x2, y2
print("Yes" if ok else "No")

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

void bubbleSort(int A[], int N) {
  int flag = 1;
  int count = 0;
  while (flag) {
    flag = 0;
    for (int j = N-1; j > 0; j--) {
      if (A[j] < A[j-1]) {
        int tmp = A[j];
        A[j] = A[j-1];
        A[j-1] = tmp;
        count++;
        flag = 1;
      }
    }
  }

  cout << A[0];
  for (int i = 1; i < N; i++) cout << " " << A[i];
  cout << endl;

  cout << count << endl;
}

int main() {
   int N, A[100];

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

   bubbleSort(A, N);
}



Measured memory_bytes: 3116
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
#include<sstream>
#include<complex>
#include<functional>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<set>

const int MOD = 1000000007;

using namespace std;

int main(){

    int a,b,n;

    cin >> n >> a >> b;

    cout << min(a*n,b) << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define MAXN 200
using namespace std;
bool vis[MAXN];
int main(){
	int n,k,d;
	scanf("%d%d",&n,&k);
	for(register int i = 1;i <= k;i++){
		scanf("%d",&d);
		for(register int j = 1;j <= d;j++)
		{
			int u;
			scanf("%d",&u);
			vis[u] = 1;
		}
	}
	int ans = 0;
	for(register int  i= 1;i <= n;i++){
		if(!vis[i])ans++;
	}
	return !printf("%d",ans);
}

Measured memory_bytes: 1692
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		long[] h = new long[n];
		
		for(int i = 0; i < n ;i++) {
			h[i] = Long.parseLong(sc.next());
		}
		
		Arrays.sort(h);
		
		long res = Long.MAX_VALUE;
		
		for(int i = 0; i < n-(k-1); i++) {
			res = Math.min(h[i+(k-1)] - h[i], res);
		}
		
		System.out.println(res);
	}

}

Measured memory_bytes: 48852
#include<bits/stdc++.h>
#define maxn 200100
using namespace std;
int d[maxn],n,m,ans;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1,u,v;i<=m;++i)
		scanf("%d%d",&u,&v),d[u]^=1,d[v]^=1;
	for(int i=1;i<=n;++i)ans+=d[i]&1;
	if(ans>=2)puts("NO");
	else puts("YES");
}

Measured memory_bytes: 640
import java.util.*;

class Main{
  private static int[] vs;
  private static int[] ws;

  private static Cheet[][] memo;

  private static int N;

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

    for(int num = 1;; num++) {
      int W = sc.nextInt();
      if (W == 0) {
        break;
      }
      N = sc.nextInt();
      vs = new int[N];
      ws = new int[N];  

      memo = new Cheet[W+1][N+1];
      for (int i = 0; i < N; i++) {
        String[] s = sc.next().split(",");
        vs[i] = Integer.parseInt(s[0]); //value
        ws[i] = Integer.parseInt(s[1]); //weight
      }

      System.out.println("Case " + num + ":");
      int[] result = new int[2];
      dp(0, W, result);
      System.out.println(result[0]);
      System.out.println(result[1]);
    }
    sc.close();
  }

  public static void dp(int index, int weight, int[] out)
  {
    if (memo[weight][index] != null) {
      out[0] = memo[weight][index].value;
      out[1] = memo[weight][index].weight;
      return;
    }

    int[] res = new int[2];
    int[] res2 = new int[2];
    if (index == N) {
      res[0] = 0;
      res[1] = 0;
    }
    else if (ws[index] > weight) {
      dp(index + 1, weight, res);
    }
    else {
      dp(index + 1, weight, res);
      dp(index + 1, weight - ws[index], res2);
      res2[0] += vs[index];
      res2[1] += ws[index];
      if (res[0] < res2[0]) {
        res = res2;
      }
      else if (res[0] == res2[0]) {
        res[1] = Math.min(res[1], res2[1]);
      }
    }

    out[0] = res[0];
    out[1] = res[1];

    Cheet cheet = new Cheet();
    cheet.value = out[0];
    cheet.weight = out[1];
    memo[weight][index] = cheet;
    return;
  }

  private static class Cheet {
    public int value;
    public int weight;
  }
}


Measured memory_bytes: 92984
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, L;
    cin >> N >> L;
    int sum = 0, m = 10000, a = 0;
    REP(i, N) {
        sum += L + i;
        if (amin(m, abs(L + i))) {
            a = L + i;
        }
    }
    cout << sum - a << endl;
    return 0;
}


Measured memory_bytes: 256
function main(input) {
  const args = input.split("\n");
  const n = args.length;

  for (let i = 0; i < n; i++) {
    let m, f, r;
    [m, f, r] = args[i].split(" ").map((x) => Number(x));
    if (m === -1 && f === -1 && r === -1) {
      break;
    }
    if (m === -1 || f === -1) {
      console.log("F");
    } else if (m + f >= 80) {
      console.log("A");
    } else if (65 <= m + f && m + f < 80) {
      console.log("B");
    } else if (50 <= m + f && m + f < 65) {
      console.log("C");
    } else if (30 <= m + f && m + f < 50) {
      if (r >= 50) {
        console.log("C");
      } else {
        console.log("D");
      }
    } else {
      console.log("F");
    }
  }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15360
#!/usr/bin/env python3
import math
n = int(input())
txy = [map(int, input().split()) for _ in range(n)]
t, x, y = [list(i) for i in zip(*txy)]

gt = 0
gx = 0
gy = 0

for i in range(n):
    wt = t[i] -gt
    ww = abs(x[i] - gx) + abs(y[i] - gy)
    if (wt < ww) or ((wt - ww) % 2 == 1):
        print("No")
        break

    gt = t[i]
    gx = x[i]
    gy = y[i]

else:
    print("Yes")

Measured memory_bytes: 63196
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n, a, b, tot=0;
	scanf("%d", &n);
	for (int i=1; i<=n; i++){
		scanf("%d%d", &a, &b);
		if (a==b) tot++;
		else tot=0;
		if (tot>=3){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3684