akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define pii pair<int,int>
using namespace std;
map<pii,int>pl;
pii pls[54];
int main(void)
{
	int n=0;
	int ans=0,cnt=0;
	int x=0,y=0;
	int i=0,j=0,k=0;
	cin>>n;
	ans=n;
	for(i=1;i<=n;i++)
	{
		cin>>pls[i].first>>pls[i].second;
		pl[pls[i]]=1;
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(i==j)
			{
				continue;
			}
			x=pls[j].first-pls[i].first;
			y=pls[j].second-pls[i].second;
			cnt=0;
			for(k=1;k<=n;k++)
			{
				if(pl.count({pls[k].first+x,pls[k].second+y}))
				{
					cnt++;
				}
			}
			ans=min(ans,n-cnt);
		}
	}
	cout<<ans;
	return 0;
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B<C+D){
    cout << "Right" << endl;
  }
  else if (A+B>C+D){
    cout << "Left" << endl;
  }
  else {
    cout << "Balanced" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
#include <math.h>
#include <limits.h>
#include <map>
#include <stack>
#include <list>
#include <deque>

using namespace std;
 int main(){
     string s,t;
     cin >> s >> t;
     int n=s.size(),m=t.size();
     for(int i=0;i<n;i++){
         bool ju=true;
         for(int j=0;j<m;j++){
             if(i+j>=n){
                 ju=false;
                 break;
             }
             if(s[i+j]!=t[j]){
                 ju=false;
                 break;
             }
         }
         if(ju){
             cout << i << endl;
         }
     }
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;

ll mod = 1000000007ll;
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; }
const ll inf = 1ll << 60;



int main() {
    ll n, a, b, c, d, e;
    scanf("%lld%lld%lld%lld%lld%lld", &n, &a, &b, &c, &d, &e);
    vector<ll> list(5);
    list.at(0) = a;
    list.at(1) = b;
    list.at(2) = c;
    list.at(3) = d;
    list.at(4) = e;
    ll min = *min_element(list.begin(), list.end());
    if(n % min == 0){
        printf("%lld", n / min + 4);
    } else {
        printf("%lld", n / min + 5);
    }
    return 0;
}


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


int main(){
	int n, m, q;
  	cin>>n>>m>>q;
  	int a[q], b[q], c[q], d[q];
  	for(int i=0;i<q;i++){
    	cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
  
  	vector<pair<int, pair<int, int>> > v;
  	for(int i=1;i<=m;i++){
  		v.push_back(make_pair(-1, make_pair(0, i)));
    }
  	int bn=0;
  	int num=0;
  	while(1){
      	if(num==v[bn].second.first) num++;
      	if(num==n) break;
    	for(int i=v[bn].second.second;i<=m;i++){
  			v.push_back(make_pair(bn, make_pair(num, i)));
    	}
      	bn++;
    }
  	
  	int max=-1;
  	int sum=0;
  	for(int i=v.size()-1;v[i].second.first==n-1;i--){
    	int t[n];
      	int l=n-1;
      	for(int j=i;;j=v[j].first){
      		t[l]=v[j].second.second;
          	l--;
          	if(v[j].first==-1) break;
        }
      	//if(t[0]==1 && t[1]==3 && t[2]==4) cout<<"ok"<<endl;
      
      	for(int k=0;k<q;k++){
        	if(t[b[k]-1]-t[a[k]-1]==c[k]) sum+=d[k]; 
        }
      	if(max<sum) max=sum;
      	sum=0;
    }
  	
  	cout<<max<<endl;
  	
  	for(int i=0;i<v.size();i++){
  		//cout<<v[i].second.first<<endl;
    }
}

Measured memory_bytes: 6416
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int number = sc.nextInt();
        List<Integer> takoyaki = new ArrayList<>();
        int ans = 0;
        for (int i = 0; i < number; i++) {
            takoyaki.add(sc.nextInt());
        }
        for (int i = 0; i < number; i++) {
            for (int j = i + 1; j < number; j++) {
                ans += takoyaki.get(i) * takoyaki.get(j);
            }
        }
        System.out.println(ans);
    }
}

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

using namespace std;

typedef long long int lli;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef pair <lli,lli> pii;
#define all(vec) vec.begin(),vec.end()
#define ff first
#define ss second
#define pi 3.141592653589
#define inf 4e18
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define for1(low,high,k) for(int i=low;i<high;i+=k)
#define for2(low,high,k) for(int j=low;j<high;j+=k)
#define rev(high,low,k) for(int i=high;i>=low;i-=k) 

int main(){
	fast;
	lli n,x,y;
	cin>>n;
	lli count=0;
	while (n--){
		cin>>x>>y;
		if (x==y) count++;
		else if (count<3) count=0;
	}
	if (count>=3) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <fstream>
#include <cstdlib>
#include <cstdio>
#define REP(i, n) for(int i=0; i<(n); i++)
#define FOR(i, a, n) for(int i=(a); i<(n); i++)
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<string> vs;

int main(){
    int N;cin>>N;
    vector<long int> B(N);
    REP(i, N){
        long int a;cin>>a;
        B[i] = a-(i+1);
    }
    sort(B.begin(), B.end());
    long int ans = 0;
    if(B.size()%2==1){
        long int b = B[B.size()/2];
        REP(i, B.size()){
            ans += abs(B[i] - b);
        }
    }else{
        long int b = (B[N/2-1] + B[N/2])/2;
        REP(i, B.size()){
            ans += abs(B[i] - b);
        }
        b = (B[N/2-1] + B[N/2])/2;
        long int tmp = 0;
        REP(i, B.size()){
            tmp += abs(B[i] - b);
        }
        ans = ans < tmp ? ans : tmp;
    }

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

Measured memory_bytes: 1792
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aryssoncf
 */

#include <bits/stdc++.h>
//
// Created by aryssoncf on 28/10/2019.
//

#include <type_traits>


#include <iterator>
#include <utility>

template<typename T>
constexpr auto hasBegin(int) -> decltype(std::begin(std::declval<T>()), true) {
    return true;
}

constexpr bool hasBegin(...) {
    return false;
}

template<typename T>
using IsContainer = std::integral_constant<bool, hasBegin<T>(0)>;


#ifndef JHELPER_EXAMPLE_PROJECT_IO_HPP
#define JHELPER_EXAMPLE_PROJECT_IO_HPP

#endif //JHELPER_EXAMPLE_PROJECT_IO_HPP

template<typename T>
std::istream &operator>>(std::istream &is, std::vector<T> &vec) {
    for (T &element: vec) {
        is >> element;
    }
    return is;
}

template<typename T, typename U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    is >> p.first;
    is >> p.second;
    return is;
}

template<class X, class Y>
std::ostream &operator<<(std::ostream &os, std::pair<X, Y> const &p) {
    return os << p.first << " " << p.second;
}

template<class Ch, class Tr, class Container>
std::basic_ostream<Ch, Tr> &operator<<(std::basic_ostream<Ch, Tr> &os, Container const &x) {
    bool first = true;
    for (auto &y : x) {
        if (first) {
            first = false;
        } else {
            os << " ";
        }
        os << y;
    }
    return os;
}

using namespace std;

/*
PROG:
LANG: C++
*/

class D {
    const string MOVES = "rsp";

    int r, s, p;

    int f(const string &str) {
        int n = str.size();
        vector<vector<int>> dp(n + 1, vector<int>(3));
        for (int i = 1; i <= n; i++) {
            char c = str[i - 1];
            for (int j = 0; j < 3; j++) {
                for (int k = 0; k < 3; k++) {
                    if (k != j) {
                        dp[i][j] = max(dp[i][j], dp[i - 1][k]);
                    }
                }
                if (MOVES.find(c) == j) {
                    dp[i][j] += c == 'r' ? r : c == 's' ? s : p;
                }
            }
        }
        int res = 0;
        for (int x: dp[n]) {
            res = max(res, x);
        }
        return res;
    }

public:
    void solve(std::istream &in, std::ostream &out) {
        int n, k;
        in >> n >> k;
        in >> r >> s >> p;
        string T;
        in >> T;
        int res = 0;
        for (int i = 0; i < k; i++) {
            string aux;
            for (int j = i; j < n; j += k) {
                aux += MOVES[(MOVES.find(T[j]) + 2) % 3];
            }
            res += f(aux);
        }
        out << res << "\n";
    }

    void setup() {}
};


int main() {
    std::ios_base::sync_with_stdio(false);
    D solver;
    solver.setup();
    std::istream &in(std::cin);
    std::ostream &out(std::cout);
    in.tie(nullptr);
    out << std::fixed;
    out.precision(20);
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 5888
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
int p[200000]={0};
int main(){
int i,n,d=-1000000001,b;
scanf("%d",&n);
for(i=0;i<n;i++)
scanf("%d",&p[i]);
b=p[n-1];
for(i=n-2;i>=0;i--){
d=max(d,b-p[i]);
if(b<p[i])
b=p[i];
}
printf("%d\n",d);
return 0;
}


Measured memory_bytes: 4000
package main

import (
	"fmt"
	"sort"
)

func main() {
	var n int
	var l int
	var ans string

	fmt.Scanf("%d %d", &n, &l)

	ary := make([]string, n)

	for i := 0; i < n; i++ {
		fmt.Scanf("%s", &ary[i])
	}

	sort.Sort(sort.StringSlice(ary))
	for _, v := range ary {
		ans += v
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
 
using namespace std;
 
#define ld long double
#define ll long long
#define ull unsigned long long
#define dd double
#define lbits 64
#define ibits 32

const double pi = acos(-1);
const ll mod = (ll)(1e9 + 9);

bool isPrime(ll x){for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;}
double dist(dd a,dd b,dd c,dd d){return sqrt((c-a)*(c-a)+(d-b)*(d-b));}

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    srand(time(0));

    int n,m;cin>>n>>m;
    if(n == 1 && m == 1){
            cout<<"1000000";
            return 0;
    }
    map<int,int> mp;
    mp[1] = 300000;
    mp[2] = 200000;
    mp[3] = 100000;
    cout<<mp[n] + mp[m];

    // CHECK THE OVERFLOW
    // CHECK THE BOUNDS

    return 0;
}

Measured memory_bytes: 256
/*
 * Author:  heyuhhh
 * Created Time:  2020/5/12 15:13:30
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 2e3 + 5;

int n, x, y;
int ans[N];

void run() {
    cin >> n >> x >> y;
    for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
            int dis = j - i;
            dis = min(dis, min(abs(x - i) + 1 + abs(y - j), abs(y - i) + 1 + abs(x - j)));
            if (dis < n) ++ans[dis];
        }
    }
    for (int i = 1; i < n; i++) {
        cout << ans[i] << '\n';
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w",stdout);
    #endif
    double a,b,c,d;
    cin>>a>>b>>c>>d;
    double min = c*60 + d;
    double min_angle = 6*min;
    double hr_angle = (30*c) + ((d/60)*30);
    double diff_angle = abs(min_angle-hr_angle);
    

    double res = pow(a,2) + pow(b,2) - (2*a*b*cos((M_PI * diff_angle ) /180.0));
    printf("%.30lf", sqrt(res));
}

Measured memory_bytes: 4248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }

const int MOD = 1000000007;
const int INF = 1e9;

const int mod = 1000000007;
const int inf = 1e9;
#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int n, m;
    cin >> n >> m;
    vector<Pll> a(n), b(m);
    for(int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
    for(int i = 0; i < m; i++) cin >> b[i].first >> b[i].second;
    for(int i = 0; i < n; i++){
        int ans = -1;
        ll mi = 1e18;
        for(int j = 0; j < m; j++) {
            if(chmin(mi, abs(a[i].first-b[j].first)+abs(a[i].second-b[j].second))) {
                ans = j;
            }
        }
        cout << ans+1 << endl;
    }
}

Measured memory_bytes: 256
while True:
  H,W = map(int,input().split())
  if H==0 and W ==0:
    break
  for i in range(H):
    for e in range(W):
      if i%2 ==0 and e%2 !=0:
        print('.',end='')
      elif i%2 ==0 and e%2==0:
        print('#',end='')
      elif i%2 !=0 and e%2 ==0:
        print('.',end='')
      else:
        print('#',end='')
    print()
  print() 


Measured memory_bytes: 7000
#include <string>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <cmath>
#include <complex>
#include <cstdio>
#include <queue>

using namespace std;
typedef long long ll;

int main()
{
	int N, M;
	cin >> N >> M;
	//vector<pair<int, int>> q;
	map<int, int> m;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		m[a]++;
		m[b]++;
	}
	bool ans = true;
	for (const auto& i : m) {
		if (i.second % 2 != 0) {
			ans = false;
			break;
		}
	}
	cout << (ans ? "YES" : "NO") << endl;
	return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

use std::collections::BinaryHeap;

fn main() {
    let nm: Vec<usize> = read_vec();
    let n = nm[0];
    let m = nm[1] as u32;
    let mut ab: Vec<Vec<u32>> = read_vec2(n);
    let mut bh: BinaryHeap<u32> = BinaryHeap::new();
    ab.sort_by(|x, y| {
        if x[0] == y[0] {
            y[1].partial_cmp(&x[1]).unwrap()
        } else {
            x[0].partial_cmp(&y[0]).unwrap()
        }
    });

    let mut ans: u32 = 0;

    let mut j: usize = 0;
    for i in 1..(m + 1) {
        while j < ab.len() {
            if ab[j][0] <= i {
                bh.push(ab[j][1]);
                j += 1;
            } else {
                break;
            }
        }
        if let Some(x) = bh.pop() {
            ans += x;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 10492
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
template<class T> inline bool chmax(T& a, T b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a>b) { a=b; return 1; } return 0; }

ll N,W;
vector<ll> w(110),v(110);
vector<vector<ll>> dp(110,vector<ll> (100010,0));

int main(){
    cin>>N>>W;
    for(ll i=0;i<N;i++) cin>>w[i]>>v[i];
    for(ll i=0;i<N;i++){
        for(ll j=0;j<=W;j++){
           if(j-w[i]>=0) chmax(dp[i+1][j],dp[i][j-w[i]]+v[i]);
            chmax(dp[i+1][j],dp[i][j]);
        }
    }
    
    cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 87296
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

static void printOut(int A[], int N) {
    int i;

    for ( i = 0; i < N; i++ ) {
        printf("%u%s", A[i], i == N -1 ? "" : " ");
    }
    printf("\n");

    return;
}

static int selectionSort(int A[], int N) {
    int i, j, minj;
    int swap=0;

    for ( i = 0; i < N; i++) {
        minj = i;
        
        for ( j = i; j < N; j++) {
            if ( A[j] < A[minj] ) {
                minj = j;
            }
        }
        if ( i != minj ) {        
            int t;
            t      = A[i];
            A[i]   = A[minj];
            A[minj] = t;
            swap++;
        }
    }

    return swap;
}

int main(int argc, char* argv[]) {
    int ret;
    int i;
    int N;
    int *A;
    int c;

    ret = scanf("%d\n", &N);
    assert( ret == 1 );
    assert( (1 <= N) && N <= 100 );

    A = malloc(sizeof(int) * N);
    assert( A != NULL );

    memset(A, 0x00, sizeof(int) * N);
    i = 0;
    while ( ((ret = fgetc(stdin)) != EOF) && (i < N) ) {
        if ( ret == ' ' ) {
            assert( (0 <= A[i]) && (A[i] <= 1000) );
            i++;
            continue;
        }
        if ( isdigit(ret) ) {
            A[i] = A[i] * 10 + (ret - '0');
            continue;
        }
        break;
    }
    
    c = selectionSort(A, N);

    printOut(A, N);

    printf("%d\n", c);

    free(A);

    return 0;
}
    



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


int main(){
    int n,p;cin >> n >> p;
    vector<P> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].fs >> v[i].sc;
    }
    sort(ALL(v));
    vector<LL> dp(10000,-1);
    dp[0] = 0;
    LL ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = p-1; j >= 0; j--) {
            if(dp[j] == -1) continue;
            dp[j+v[i].fs] = max(dp[j+v[i].fs],dp[j]+v[i].sc);
        }
        for (int j = 0; j < p + v[i].fs; j++) {
            ans = max(ans,dp[j]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
n,m=map(int, input().split())
ps=[list(input().split()) for _ in range(m)]

ac=[None]*n
wa=[0]*n
wa_cnt=0

for i in range(m):
    if ac[int(ps[i][0])-1]==None and ps[i][1]=='AC':
        ac[int(ps[i][0])-1]=1
        wa_cnt+=wa[int(ps[i][0])-1]
    elif ac[int(ps[i][0])-1]==None and ps[i][1]=='WA':
        wa[int(ps[i][0])-1]+=1
print(ac.count(1), wa_cnt)


Measured memory_bytes: 27452
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
#include <functional>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i, n) for (int i = 1; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
using namespace std;
using ll = long long;
constexpr int inf = 1000000000;
constexpr ll INF = 5000000000000000000;

template <typename T> bool chmax(T &a, T b) {if (a < b) {a = b; return true;} return false;}

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    if (N == 2) {
        cout << max(A[0], A[1]) << "\n";
        return 0;
    }
    
    vector<vector<ll>> dp(N, vector<ll>(3, -INF));
    dp[0][0] = A[0];
    dp[1][1] = A[1];
    dp[2][0] = A[0] + A[2];
    dp[2][2] = A[2];
    for (int i = 3; i < N; ++i) {
        if (i % 2 == 0) {
            chmax(dp[i][0], dp[i - 2][0] + A[i]);
            chmax(dp[i][2], dp[i - 2][2] + A[i]);
            chmax(dp[i][2], dp[i - 3][1] + A[i]);
        } else {
            chmax(dp[i][1], dp[i - 2][1] + A[i]);
            chmax(dp[i][1], dp[i - 3][0] + A[i]);
        }
    }
    
    if (N % 2 == 0) {
        cout << max(dp[N - 2][0], dp[N - 1][1]) << "\n";
    } else {
        cout << max({dp[N - 3][0], dp[N - 2][1], dp[N - 1][2]}) << "\n";
    }
    return 0;
}


Measured memory_bytes: 15644
include Math

a,b,h,m = gets.split(' ').map(&:to_f)

w_a = 2.0 * PI / (12*60)
w_b = 2.0 * PI / 60
t = 60*h+m

x_a = a * cos(w_a * t)
y_a = a * sin(w_a * t)
x_b = b * cos(w_b * t)
y_b = b * sin(w_b * t)

# p a
# p b
# p h
# p m
# p w_a
# p w_b
# p PI
# p t
# p "xの角度: #{w_a * t * 360 / (2*PI)}"
# p "yの角度: #{w_b * t * 360 / (2*PI) % 360}"
# p x_a
# p y_a
# p x_b
# p y_b

puts sqrt((x_a-x_b)**2 + (y_a-y_b)**2)

Measured memory_bytes: 14756
import std.stdio;
import std.string;
import std.conv;

void main()
{
    int N = readln.chomp.to!int;
    int H = readln.chomp.to!int;
    int W = readln.chomp.to!int;

    int result = (N - H + 1) * (N - W + 1);

    writeln(result);
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<numeric>
#include<utility>
#include<unordered_map> //hash map

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF 1000000000
#define MOD 1000000007

typedef  long long ll;

using namespace std;

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

double euclid_distance(double a,double b){
    return sqrt(a*a+b*b);
}

ll gcd(ll  a,ll b){
    ll r;
    if(a < b){
        ll tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return b;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

ll r_fuct[2000];
ll fuct[2000];

//MOD逆元
void conb(ll n,ll k){
    fuct[0] = 1;
    for(int i = 1;i < k+1;i++){
        fuct[i] *= fuct[i-1]%MOD;
        
        ll b = MOD, u = 1, v = 0;
        ll value = fuct[i];
        while (b) {
            ll t = value / b;
            value -= t * b;
            swap(value, b);
            u -= t * v;
            swap(u, v);
        }
        u %= MOD;
        if (u < 0) u += MOD;
        r_fuct[i] = u;
    }
}

ll factrial(ll n){
    if(n == 0) return 1;
    ll p = factrial(n-1)*n%MOD;
    return p;
}

//MOD逆元
ll farmat(ll n,ll p){    
    if(p == 0) return 1;
    else if(p == 1) return n%MOD;
    ll d = farmat(n,p/2);
    if(p%2 == 0){
        return (d*d)%MOD;
    }else{
        return ((n*d)%MOD*d)%MOD;
    }
}

ll conbination(ll n,ll k){
    ll a = factrial(n);
    ll b = factrial(k);
    ll c = factrial(n-k);
    return (a*farmat(b,MOD-2)%MOD*farmat(c,MOD-2))%MOD;
}

int n;
int memo[10000000];

int fib(int i){
    if(i <= 1) return i;
    if(memo[i] != 0) return memo[i];
    return memo[i] = fib(i-1)+fib(i-2);
}


void solve() {
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b)*c/2 << endl;
}


int main() {

	cin.tie(0);
	ios::sync_with_stdio(false);
	solve();
	return 0;
}


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

#define NM_MAX 2002

using namespace std;

int n, m;

bool ma[NM_MAX][NM_MAX];

int lg[NM_MAX][NM_MAX];

int v[NM_MAX];

int mxl[NM_MAX];
int mxr[NM_MAX];

stack <int> st;

int main()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i++)
    {
        string s;
        cin >> s;
        for(int j = 1; j <= m; j++)
            ma[i][j] = (s[j - 1] == '#');
    }
    for(int i = 1; i < n; i++)
        for(int j = 1; j < m; j++)
            ma[i][j] = ma[i][j] ^ ma[i + 1][j] ^ ma[i][j + 1] ^ ma[i + 1][j + 1];
    n--;
    m--;
    for(int i = n; i >= 1; i--)
        for(int j = 1; j <= m; j++)
            if(ma[i][j] == 1)
                lg[i][j] = 0;
            else
                lg[i][j] = lg[i + 1][j] + 1;
    int ans = max(n, m) + 1;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 1; j <= m; j++)
            v[j] = lg[i][j];
        for(int j = 1; j <= m; j++)
        {
            while(!st.empty() && v[st.top()] >= v[j])
                st.pop();
            if(st.empty())
                mxl[j] = j - 1;
            else
                mxl[j] = j - (st.top() + 1);
            st.push(j);
        }
        while(!st.empty())
            st.pop();
        for(int j = m; j >= 1; j--)
        {
            while(!st.empty() && v[st.top()] >= v[j])
                st.pop();
            if(st.empty())
                mxr[j] = m - j;
            else
                mxr[j] = st.top() - 1 - j;
            st.push(j);
        }
        while(!st.empty())
            st.pop();
        for(int j = 1; j <= m; j++)
            ans = max(ans, (mxl[j] + mxr[j] + 2) * (v[j] + 1));
    }
    cout << ans << "\n";
    return 0;
}


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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    map<ll,int> mp;
    vector<ll> a(0);
    for(int i = 0;i < n;i ++){
        int x;
        cin >> x;
        mp[x] ++;
    }
    for(auto ite = mp.begin();ite != mp.end();++ite){
        if(ite->second>3){a.push_back(ite->first);a.push_back(ite->first);}
        else if(ite->second>1) a.push_back(ite->first);
    }
    sort(a.begin(),a.end());
    if(a.size()>1)cout << a[a.size()-1]*a[a.size()-2] << endl;
    else cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int main()
{
    int sx, sy, tx, ty;
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for(int i=1; i<=ty-sy; i++)
        putchar('U');
    for(int i=1; i<=tx-sx; i++)
        putchar('R');
    for(int i=1; i<=ty-sy; i++)
        putchar('D');
    for(int i=1; i<=tx-sx; i++)
        putchar('L');
    putchar('L');
    for(int i=1; i<=ty-sy+1; i++)
        putchar('U');
    for(int i=1; i<=tx-sx+1; i++)
        putchar('R');
    putchar('D');
    putchar('R');
    for(int i=1; i<=ty-sy+1; i++)
        putchar('D');
    for(int i=1; i<=tx-sx+1; i++)
        putchar('L');
    putchar('U');
    return 0;
}


Measured memory_bytes: 256
inputNum = list(map(int, input().split()))

P = inputNum[0]
Q = inputNum[1]
R = inputNum[2]

# 飛行時間の和の候補から比較して求める
candidacy1 = P + Q
candidacy2 = R + Q
candidacy3 = P + R

result = candidacy1
if result > candidacy2:
    result = candidacy2

if result > candidacy3:
    result = candidacy3

print(result)

Measured memory_bytes: 3060
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cstdio>
#include<vector>
#include<queue>
#include<cmath>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
const int mod = 998244353;
inline int read()
{
	register int x = 0 , f = 0; register char c = getchar();
	while(c < '0' || c > '9') f |= c == '-' , c = getchar();
	while(c >= '0' && c <= '9') x = (x << 3) + (x << 1) + c - '0' , c = getchar();
	return f ? -x : x;
}
int n , sa , sb;
int a[420] , b[420] , f[420][420][420] , inv[420] , fac[420];
inline int add(int a , int b) { a += b; return a >= mod ? a - mod : a; }
inline int mul(int a , int b) { return (LL)a * b % mod; }
inline int ksm(int a , int k) { int ans = 1; for( ; k ; k >>= 1 , a = mul(a , a)) if(k & 1) ans = mul(ans , a); return ans; }
int main()
{
	n = read();
	for(int i = 1 ; i <= n ; ++i) sa += (a[i] = read()) , sb += (b[i] = read());
	inv[0] = fac[0] = 1;
	for(int i = 1 ; i <= 400 ; ++i) fac[i] = mul(fac[i-1] , i);
	inv[400] = ksm(fac[400] , mod - 2);
	for(int i = 399 ; i ; --i) inv[i] = mul(inv[i+1] , i+1);
	f[0][0][0] = mod - 1;
	for(int i = 1 ; i <= n ; ++i)
		for(int j = 0 ; j <= sa ; ++j)
			for(int k = 0 ; k <= sb ; ++k) if(f[i-1][j][k])
			{
				f[i][j][k] = add(f[i][j][k] , f[i-1][j][k]);
				int res = 1;
				for(int l = 0 ; l < b[i] ; ++l , res = mul(res , a[i]))
					f[i][j + a[i]][k + l] = add(f[i][j + a[i]][k + l] , mod - mul(f[i-1][j][k] , mul(res , inv[l])));
			}
	int ans = 0;
	for(int i = 1 ; i <= sa ; ++i)
	{
		int y = ksm(i , mod - 2);
		int x = mul(sa , y);
		for(int j = 0 ; j <= sb ; ++j , x = mul(x , y)) ans = add(ans , mul(fac[j] , mul(x , f[n][i][j])));
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 274688
function reduce() {
    local f=$1;shift;
    local v=$1;shift;
    while [ $# -gt 0 ]
    do
        v=$($f $v $1)
        shift
    done
    echo $v
}

function _max() {
    echo $[$1>$2?$1:$2]
}

function max() {
    echo $(reduce _max $@)
}

function _min() {
    echo $[$1<$2?$1:$2]
}

function min() {
    echo $(reduce _min $@)
}

read N M X Y
read x
read y
max_x=$(max X ${x[@]})
min_y=$(min Y ${y[@]})
if ((max_x < min_y))
then
    echo "No War"
else
    echo "War"
fi


Measured memory_bytes: 964
#include<iostream>

using namespace std;

int main()
{
    string s;
    cin >> s;
    if(s.length() == 2)
    {
        cout << s<<endl;
    }
    else{
        for(int i = s.length()-1 ; i >= 0 ; i--)
        {
            cout<<s[i];
        }
    }
    return 0;
}


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

using namespace std;
#define int long long
int32_t  main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, W;
    cin >> n >> W;

    int w[n], val[n];

    for (int i = 0; i < n; ++i) {
        cin >> w[i] >> val[i];
    }

    int dp[n + 1][W + 1] = {};

    for (int i = 1; i <= n; i++) {
        for (int wt = 0; wt <= W; wt++) {
            dp[i][wt] = dp[i - 1][wt];
            if (wt - w[i - 1] >= 0)
                dp[i][wt] = max(val[i - 1] + dp[i-1][wt - w[i - 1]], dp[i][wt]);
        }
    }
    cout << dp[n][W];
    return 0;
}

Measured memory_bytes: 79232
// class point	の練習（クラスの高度な実装）
#include <iostream>
#include <iomanip>
using namespace std;



int main() {
	int a, b;

	cin >> a >> b;

	cout << a / b << " " << a % b << " " <<fixed<<setprecision(6)<< (double)a / (double)b << endl;

	return 0;
}




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

#define int long long

using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,m;
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

vector<pair<long long, long long> > prime_factorize(long long n) {
    vector<pair<long long, long long> > res;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) { ++num; n /= p; }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main(){
    cin>>n>>m;
    COMinit();
    auto vec=prime_factorize(m);
    int ans=1;
    for(auto e:vec){
        int num=e.second;
        int tmp=COM(num+n-1,n-1);
        ans=(ans*tmp)%MOD;
    }
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 12160
let a, b, k = Scanf.scanf " %d %d %d" @@ fun a b c -> a, b, c
let l, r = max a @@ b - k + 1, min b @@ a + k - 1
let _ =
  if l <= r then for i = a to b do Printf.printf "%d\n" i done
  else
    (for i = a to r do Printf.printf "%d\n" i done;
    for i = l to b do Printf.printf "%d\n" i done)

Measured memory_bytes: 384
import java.util.*;
import java.util.function.*;
import java.lang.*;
import java.io.*;


public class Main {
    static long medianx2(long[] A){
        long[] B = Arrays.copyOf(A,A.length);
        Arrays.sort(B);
        if(B.length %2 == 0) return B[B.length/2 - 1] + B[B.length/2];
        else return 2 * B[B.length / 2];
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] A = new long[N];
        long[] B = new long[N];
        for(int n=0; n<N; n++){
            A[n] = sc.nextLong();
            B[n] = sc.nextLong();
        }
        long min = medianx2(A);
        long max = medianx2(B);
        System.out.println(N%2==0 ? 1+max-min : 1+(max-min)/2);
    }
}



Measured memory_bytes: 63028
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, m;
	scanf("%d%d", &n, &m);
	vector<int> h(n);
	rep(i, n)scanf("%d", &h[i]);
	vector<vector<int>> g(n);
	rep(i, m) {
		int a, b;
		scanf("%d%d", &a, &b);
		--a, --b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	int ans = 0;
	rep(i, n) {
		bool f = true;
		for (const auto& aa : g[i]) {
			if (h[aa] >= h[i])f = false;
		}
		ans += f;
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 8864
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String args[]) throws Exception{
        BufferedReader stdR = new BufferedReader(new InputStreamReader(System.in));
        String[] str = stdR.readLine().split(" ");
        int H1 = Integer.parseInt(str[0]);
        int H2 = Integer.parseInt(str[1]);
        if(H1 + H2 == 15) {
            System.out.println("+");
        }else if(H1 * H2 == 15) {
            System.out.println("*");
        }else {
            System.out.println("x");
        }
    }
}


Measured memory_bytes: 20692
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <algorithm>
#include <functional>

using namespace std;

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

	int X;
	cin >> X;

	int A;
	cin >> A;

	int B;
	cin >> B;

	int left_money = X - A;
	if (left_money < B)
	{
		cout << 0;
	}
	else
	{
		cout << left_money % B;
	}

	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

struct UnionFind {
	int s, num; // [0, s) の s 個の要素がある。num は非空集合の個数。
	vector<vector<int>> v;
	vector<int> find;
	
	UnionFind() { s = 0; }
	UnionFind(int s) { init(s); }
	void init(int arg_s) {
		num = s = arg_s;
		v.clear();
		find.clear();
		inc(i, s) { v.PB({i}); find.PB(i); }
	}
	bool unite(int x, int y) {
		assert(inID(x, 0, s) && inID(y, 0, s));
		if(find[x] == find[y]) { return false; }
		num--;
		if(v[find[x]].size() > v[find[y]].size()) { swap(x, y); }
		int fx = find[x];
		for(auto && e: v[find[x]]) { v[find[y]].PB(e); find[e] = find[y]; }
		v[fx].clear();
		return true;
	}
};


int n, m, a[50], b[50];

int main() {
	cin >> n >> m;
	inc(i, m) { cin >> a[i] >> b[i]; a[i]--; b[i]--; }
	
	UnionFind uf;
	int ans = 0;
	inc(i, m) {
		uf.init(n);
		inc(j, m) {
			if(j == i) { continue; }
			uf.unite(a[j], b[j]);
		}
		if(uf.num != 1) { ans++; }
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
x = gets.chomp.to_i

primes = []
n = 2

while n <= Math.sqrt(x).to_i
  prime_flag = true

  primes.each do |prime|
    prime_flag = false if n % prime == 0
  end

  primes << n if prime_flag
  n += 1
end



while 1
  prime_flag = true

  primes.each do |p|
    prime_flag = false if x % p == 0
  end

  if prime_flag == true
    p x
    exit
  end

  x += 1
end



Measured memory_bytes: 1916
while True:
    x,y=map(int,input().split())
    if x<y:
        x,y=y,x
    count=0
    if x==0 and y==0:
        break
    while y!=0:
        a=x%y
        x=a
        x,y=y,x
        count+=1
    print(x,count)


Measured memory_bytes: 5608
/*
 * atcoder ABC 135 : C. City Savers
 * Solution : editorial
 * Code by : anaksoleh
 * 22 august 2019
 *
 */

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int N;
int monster[100005];
int hero[100005];

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

	cin >> N;
	for(int i = 1 ; i <= (N+1) ; i++){
		cin >> monster[i];
	}

	for(int i = 1 ; i <= N ; i++){
		cin >> hero[i];
	}

	int myTown = 0 , myTown2 = 0;
	ll monsKilled = 0;
	for(int i = 1 ; i <= N ; i++){
		if(i < 2){
			myTown = min(monster[i],hero[i]);
			myTown2 = min(monster[i+1],hero[i] - myTown);
			monsKilled = myTown + myTown2;
		}else{
			myTown = min(monster[i] - myTown2,hero[i]);
			myTown2 = min(monster[i+1],hero[i] - myTown);
			monsKilled += (myTown + myTown2);
		}
	}

	cout << monsKilled << '\n';

	return 0;	
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
 
int main()
{
    char str[1001];     /*入力される文字列*/
    char substr[1001];  /*処理用文字列*/
    char order[8];      /*命令用文字列*/
    char p[1001];       /*置換用文字列*/
    int q;              /*命令の数*/
    int a, b;           /*命令で指定される文字の番号*/
    int inc, dec;       /*インクリメント、デクリメント変数*/
    char rev;           /*入れ替え用文字*/
 
    /*文字列の入力*/
    scanf("%s",str);
    /*命令の数の入力*/
    scanf("%d",&q);
 
    for (int i = 0; i < q;i++) {
        scanf("%s", order);
        /*表示*/
        if (strcmp(order, "print") == 0) {
            /*aとbの入力*/
            scanf("%d %d", &a, &b);
            /*表示する文字数分substrにコピー*/
            strncpy(substr,&str[a],b - a + 1);
            /*終端記号を添付*/
            substr[b - a + 1] = '\0';
            /*表示する*/
            printf("%s\n",substr);
        }
        /*逆順*/
        else if (strcmp(order, "reverse") == 0) {
            /*aとbの入力*/
            scanf("%d %d", &a, &b);
            /*incとdecの設定*/
            inc = a;
            dec = b;
            /*逆順にする範囲の先頭と末尾を入れ替える（中心に行くまで）*/
            while (inc < dec) {
                rev = str[dec];
                str[dec] = str[inc];
                str[inc] = rev;
                inc++;
                dec--;
            }
        }
        /*置換*/
        else if (strcmp(order, "replace") == 0) {
            /*aとbの入力*/
            scanf("%d %d %s", &a, &b, p);
            /*strの指定された場所をpに置き換え*/
            for (int i = 0; i < b - a + 1; i++) {
                str[a + i] = p[i];
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2148
ab = input()
ablist = ab.split(' ')
a = int(ablist[0])
blist = ablist[1].split('.')
b1 = int(blist[0])
b2 = int(blist[1])
ab1 = a * b1
ab2 = (a*b2) // 100 
result = ab1 + ab2
print(int(result))

Measured memory_bytes: 61820
import string
L = string.split(raw_input())
W = int(L[0])
H = int(L[1])
x = int(L[2])
y = int(L[3])
r = int(L[4])

if x - r < 0:
    print "No"
elif y - r < 0:
    print "No"
elif x + r > W:
    print "No"
elif y + r > H:
    print "No"
else:
    print "Yes"

Measured memory_bytes: 6488
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <map>
#include <queue>
#include <math.h>

using namespace std;
#define LL long long
using VS = vector<string>;
using VI = vector<int>;
using VL = vector<LL>;
using VVI = vector<VI>;
using VVL = vector<VL>;
#define FOR(i,s,e) for(i = s; i < e; i++)
#define FORR(i,s,e) for(i = e-1; i >= s; i--)
const LL INF = (LL)1e16;
const LL MOD = (LL)1e9 + 7;

int main(){
  while (1){
    int n,t[16][17],i,j;
    LL m,k,l;
    cin >> n;
    if (n == 0) return 0;
    FOR(i,0,n) FOR(j,0,n+1) cin >> t[i][j];
    m = (1<<n);
    VL dp(m),p(n);
    FOR(i,0,m) dp[i] = INF;
    FOR(i,0,n){
      p[i] = (1<<i);
      dp[p[i]] = t[i][0];
    }
    FOR(k,0,m){
      FOR(i,0,n){
        if (!(k&p[i])){
          l = (k|p[i]);
          dp[l] = min(dp[l],dp[k]+t[i][0]);
          FOR(j,0,n){
            if (k&p[j]){
              if (dp[l] > dp[k]+t[i][j+1]) dp[l] = dp[k]+t[i][j+1];
            }
          }
        }
      }
    }
    cout << dp[m-1] << endl;
  }
  return 0;
}



Measured memory_bytes: 3592
n = gets.to_s.to_i

ans = n
(n+1).times do |i|
  
  c = 0
  t = i
  while t > 0
    c += t%6
    t /= 6
  end
  next if ans <= c
  t = n-i
  while t > 0
    c += t%9
    t /= 9
  end
  
  ans = c if ans > c
end

puts ans

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

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int w[maxn], v[maxn], dp[maxn];

const int V = 1e5;

int main() {
    int n, W, res = 0;
    memset(dp, 0x3f, sizeof(dp));
    scanf("%d%d", &n, &W);
    for (int i = 1; i <= n; i++) scanf("%d%d", &w[i], &v[i]);
    dp[0] = 0;
    for (int i = 1; i <= n; i++) {
        for (int j = V; j >= v[i]; j--) {
            dp[j] = min(dp[j], dp[j - v[i]] + w[i]);
            if (dp[j] <= W) res = max(res, j);
        }
    }
    printf("%d\n", res);
	return 0;
}


Measured memory_bytes: 6400