akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main() {
  int A,B;
  scanf("%d%d", &A, &B);
  if(A <= 5){
    printf("0\n");
  }
  else if(A >= 6 && A <= 12){
    printf("%d\n",B/2);
  }
  else{
    printf("%d\n",B);
  }
  
  return 0;
}


Measured memory_bytes: 128
import bisect
N=int(input())
ls=[int(s) for s in input().split()]
ls.sort()
ans=0
for i in range(1,N-1):
  for j in range(i+1,N):
    k = bisect.bisect_right(ls[:i],ls[j]-ls[i])
    ans+=i-k
print(ans)

        
        
        
  

Measured memory_bytes: 52060
#include <bits/stdc++.h>
#define rep0(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define mREP(i,a,b) for (int i = a; i > (b); --i)
#define all(x) (x).begin(),(x).end()
const int INF = 1000000007;
typedef long long ll;
using namespace std;
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 gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }

int main(){
  string s;
  cin >> s;
  bool ans = false;
  rep0(i,s.size()-1){
    if(s[i] == 'A' && s[i+1] == 'C')ans = true;
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  string s;
  cin >> s;
  
  int count = 0;
  
  for(int i=0; i<s.size(); i++) {
    if(i % 2 == 0 && s.at(i) == '0') {
      count++;
    }
    else if(i % 2 == 1 && s.at(i) =='1') {
      count++;
    }
  }
  
  if(2 * count < s.size())
    cout << count << endl;
  else 
    cout << s.size() - count << endl;
}

Measured memory_bytes: 512
#include <stdio.h>

int main() 
{

    long long a, b, c;
    long long k;
    long long int sum = 0;
    scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

    if ( a < k ){
        k = k - a;
        sum = sum + a;
    } else { 
        sum = k;
        k = 0;
    }

    if ( b < k ){
        k = k - b;
    } else {
        k = 0;
    }

    sum = sum - k;  

    printf("%lld", sum);

    return 0;
}



Measured memory_bytes: 1732
#include <cstdio>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)

//------------------------------------------------------------------------------
typedef long long ll;

const int MOD = 1000000007;

ll N;
ll dp[65][3];

void solve() {
  dp[0][0] = 1;
  REP(i, 64) {
    if (N >> (63 - i) & 1) {
      dp[i + 1][0] = dp[i][0];
      dp[i + 1][1] = (dp[i][0] + dp[i][1]) % MOD;
      dp[i + 1][2] = (dp[i][1] * 2 + dp[i][2] * 3) % MOD;
    } else {
      dp[i + 1][0] = (dp[i][0] + dp[i][1]) % MOD;
      dp[i + 1][1] = dp[i][1];
      dp[i + 1][2] = (dp[i][1] + dp[i][2] * 3) % MOD;
    }
  }
  int ans = (dp[64][0] + dp[64][1] + dp[64][2]) % MOD;
  printf("%d\n", ans);
}

void input() {
  scanf("%lld", &N);
}

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


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

template <class T, class E>
struct SegmentTreeLaze {
  // 1-indexed
  typedef function<T(T, T)> F;
  typedef function<T(T, E)> G;
  typedef function<E(E, E)> H;
  int n, height;
  F f;
  G g;
  H h;
  T tunit;
  E eunit;
  vector<T> dat;
  vector<E> laz;
  SegmentTreeLaze(){};
  SegmentTreeLaze(int newn, F f, G g, H h, T nt, E ne)
      : f(f), g(g), h(h), tunit(nt), eunit(ne) {
    init(newn);
  }
  void init(int newn) {
    n = 1, height = 0;
    while(n < newn) n <<= 1, ++height;
    dat.assign(n << 1, tunit);
    laz.assign(n << 1, eunit);
  }

  inline T reflect(int k) {
    return laz[k] == eunit ? dat[k] : g(dat[k], laz[k]);
  }

  inline void eval(int k) {
    if(laz[k] == eunit) return;
    laz[k << 1] = h(laz[k << 1], laz[k]);
    laz[(k << 1) | 1] = h(laz[(k << 1) | 1], laz[k]);
    dat[k] = reflect(k);
    laz[k] = eunit;
  }

  inline void thrust(int k) {
    for(int i = height; i; --i) eval(k >> i);
  }

  void recalc(int k) {
    while(k >>= 1)
      dat[k] = f(reflect(k << 1), reflect((k << 1) | 1));
  }
  // [a,b)
  void update(int a, int b, E newdata) {
    thrust(a += n);
    thrust(b += n - 1);
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) laz[l] = h(laz[l], newdata), l++;
      if(r & 1) --r, laz[r] = h(laz[r], newdata);
    }
    recalc(a);
    recalc(b);
  }

  void set_val(int k, T newdata) {
    thrust(k += n);
    dat[k] = newdata;
    laz[k] = eunit;
    recalc(k);
  }

  // [a,b)
  T query(int a, int b) {
    thrust(a += n);
    thrust(b += n - 1);
    T vl = tunit, vr = tunit;
    for(int l = a, r = b + 1; l < r; l >>= 1, r >>= 1) {
      if(l & 1) vl = f(vl, reflect(l++));
      if(r & 1) vr = f(reflect(--r), vr);
    }
    return f(vl, vr);
  }
};

long long n, q;

int main() {
  cin >> n >> q;
  using P = pair<long long, long long>;
  auto f = [](P l, P r) {
    return P(l.first + r.first, l.second + r.second);
  };
  auto g = [](P l, long long r) {
    return P(r * l.second, l.second);
  };
  auto h = [](long long l, long long r) { return r; };
  SegmentTreeLaze<P, long long> seg(n, f, g, h, P(0, 0),
                                    -100000);
  for(int i = 0; i < n; ++i) seg.set_val(i, P(0, 1));
  for(int i = 0; i < q; ++i) {
    long long c, s, t, x;
    cin >> c >> s >> t;
    if(c)
      cout << seg.query(s, t + 1).first << endl;
    else {
      cin >> x;
      seg.update(s, t + 1, x);
    }
  }
  return 0;
}


Measured memory_bytes: 8888
#include <stdio.h>

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

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;


int main() {
    int N;
    cin >> N;
    ll dp[100005][3];
    ll happy[100005][3];
    
    for(int i = 1;i <= N;i++){
        cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
    }
    //ll dp[100005][3];

    for (int i = 1; i <= N; i++){
        for(int act = 0;act<3; act++){
            for (int prev = 0;prev<3;prev++){
                if (act == prev) continue;
                dp[i][act] = max(dp[i][act], dp[i-1][prev] + happy[i][act]);
                }
            }
        }
    ll ans = 0;
    rep(i,3) ans = max(ans,dp[N][i]);
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
#define int ll

using namespace std;

const int N=1e5+100;

int ans[N];

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    int g=__gcd(a,b);
    int ans=1;
    for(int p=2;p*p<=g;p++)
        if(g%p==0)
        {
            ans++;
            while(g%p==0)
                g/=p;
        }
    if(g>1)
        ans++;
    cout<<ans;
}


Measured memory_bytes: 256
n = gets.to_i
left = -1
right = n

def sum(x)
  (x*(x+1))/2
end

while left + 1 < right do
  mid = (left + right)/2
  if sum(mid) >= n
    right = mid
  else
    left = mid
  end
end

1.upto(right) do |i|
  puts i if i != sum(right)-n
end


Measured memory_bytes: 1788
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner scan=new Scanner(System.in);
        int num_que=scan.nextInt();
        int[] time=new int[num_que];
        int i,j;
        for(i=0;i<num_que;i++){
            time[i]=scan.nextInt();
        }
        int num_drink=scan.nextInt();
        int[] sign=new int[num_drink];
        int[] change=new int[num_drink];
        for(i=0;i<num_drink;i++){
            sign[i]=scan.nextInt();
            change[i]=scan.nextInt();
        }

        int sum_time=0;
        for(i=0;i<num_drink;i++){
            sum_time=0;
            for(j=0;j<num_que;j++){
                if(sign[i]==j+1){
                    sum_time+=change[i];
                }
                else{
                    sum_time+=time[j];
                }
            }
            System.out.println(sum_time);
        }
    }
}

Measured memory_bytes: 23892
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace Program
{
    public class ABC084D
    {
        static public void Main(string[] args)
        {
            var table = new bool[100001];
            table[0] = table[1] = true;
            for (int i = 2; i <= 316; ++i)
            {
                if (!table[i])
                {
                    for (int j = i * i; j <= 100000; j += i)
                    {
                        table[j] = true;
                    }
                }
            }

            var sumary = new int[100001];
            for (int i = 1; i <= 100000; ++i)
            {
                if (!table[i] && ((i + 1) % 2 == 0) && !table[(i + 1) / 2])
                {
                    sumary[i] = 1;
                }
                sumary[i] += sumary[i - 1];
            }

            var Q = NextInt;
            for (int i = 0; i < Q; ++i)
            {
                var l = NextInt;
                var r = NextInt;
                Console.WriteLine(sumary[r] - sumary[l - 1]);
            }
        }

        static class Console_
        {
            private static Queue<string> param = new Queue<string>();
            public static int NextInt() => int.Parse(NextString());
            public static long NextLong() => long.Parse(NextString());
            public static string NextString()
            {
                if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item);
                return param.Dequeue();
            }
        }
        static int NextInt => Console_.NextInt();
        static long NextLong => Console_.NextLong();
        static string NextString => Console_.NextString();
    }
}


Measured memory_bytes: 17732
#include<iostream>

int main()
{
    int i, *x=new int[10001];
    for(i = 0; i < 10000; i++)
    {
        std::cin>>x[i];
        if((x[i]<1 & 10000<x[i])&(x[i]!=0))
        {
            std::cout<<"Wrong Number!"<<std::endl;
            return -1;
        }
        else if (x[i]==0) {
            break;
        }
    }

    for(int j = 0; j < i; j++)
    {
        std::cout<<"Case "<<j+1<<": "<<x[j]<<std::endl;
    }
    
    delete[] x;
    
    return 0;
}


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

#define dump(...) cout<<"# "<<#__VA_ARGS__<<'='<<(__VA_ARGS__)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

constexpr int INF=1e9;
constexpr int MOD=1e9+7;
constexpr double EPS=1e-8;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename Ostream,typename Container>
Ostream& operator<<(Ostream& os,const Container& c){
	os<<'[';
	for(auto i=begin(c);i!=end(c);++i)
		os<<(i==begin(c)?"":" ")<<*i;
	return os<<']';
}

bool GaussJordan(const vvd& _a,const vd& b,vd& x)
{
	int n=_a.size();
	vvd a(n,vd(n+1));
	rep(i,n){
		copy(all(_a[i]),begin(a[i]));
		a[i][n]=b[i];
	}
	
	rep(i,n){
		int p=i;
		repi(j,i+1,n) if(abs(a[p][i])<abs(a[j][i])) p=j;
		if(abs(a[p][i])<EPS) return false;
		swap(a[i],a[p]);
		peri(j,i,n+1) a[i][j]/=a[i][i];
		rep(j,n) if(j!=i) peri(k,i,n+1) a[j][k]-=a[j][i]*a[i][k];
	}
	
	rep(i,n) x[i]=a[i][n];
	return true;
}

struct Point{
	double x,y,z;
	Point(){}
	Point(double x,double y,double z):x(x),y(y),z(z){}
	Point& operator+=(Point p){x+=p.x,y+=p.y,z+=p.z; return *this;}
	Point& operator-=(Point p){x-=p.x,y-=p.y,z-=p.z; return *this;}
	Point& operator*=(double c){x*=c,y*=c,z*=c; return *this;}
	Point& operator/=(double c){x/=c,y/=c,z/=c; return *this;}
};
Point operator+(Point a,Point b){return a+=b;}
Point operator-(Point a,Point b){return a-=b;}
Point operator*(Point a,double c){return a*=c;}
Point operator*(double c,Point a){return a*=c;}
Point operator/(Point a,double c){return a/=c;}
ostream& operator<<(ostream& os,const Point& p){
	return os<<'('<<p.x<<','<<p.y<<','<<p.z<<')';
}

int main()
{
	Point me; cin>>me.x>>me.y>>me.z;
	Point enemy; cin>>enemy.x>>enemy.y>>enemy.z;
	vector<Point> barriers(3);
	for(auto& b:barriers) cin>>b.x>>b.y>>b.z;
	
	//dump(me); dump(enemy); dump(barriers);
	
	// ビーム: p+dt (位置ベクトルp, 方向ベクトルd, 媒介変数t)
	// バリア: q+eu+fv (位置ベクトルq, 方向ベクトルe,f, 媒介変数u,v)
	Point p=me,d=enemy-me;
	Point q=barriers[0],e=barriers[1]-barriers[0],f=barriers[2]-barriers[0];
	
	// p+dt=q+eu+fvをt,u,vについて解く(x=(t,u,v))
	vvd a={{d.x,-e.x,-f.x},
				 {d.y,-e.y,-f.y},
				 {d.z,-e.z,-f.z}};
	vd b={q.x-p.x,
				q.y-p.y,
				q.z-p.z};
	vd x(3);
	GaussJordan(a,b,x);
	double t=x[0],u=x[1],v=x[2];
	
	// バリアが自分と敵の間にある
	if(EPS<t && t<1+EPS){
		// バリアを含む平面上の点q+eu+fvを二次元平面上の点(u,v)に射影する．
		// すると，バリアを構成する3点はそれぞれ(0,0),(1,0),(0,1)に射影されているので，
		// (u,v)がこの三角形の内側にあるか判定すればよい．
		if(-EPS<u && -EPS<v && u+v<1+EPS)
			cout<<"MISS"<<endl;
		else
			cout<<"HIT"<<endl;
	}
	else
		cout<<"HIT"<<endl;
}

Measured memory_bytes: 1244
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val a = sc.nextLong()
    val b = sc.nextLong()
    val div = n / (a + b)
    val rem = n - div * (a + b)
    println(div * a + Math.min(a, rem))
}

Measured memory_bytes: 31268
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <iostream>
#include <list>
#include <functional>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
using namespace std;
int a2[10020];
int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a2[i]);
	}
	int ok = 0, ct = 0;
	for (;;)
	{
		ok = 0;
		for (int i = 0; i < n; i++)
		{
			if (a2[i] % 2 == 0) {
				a2[i] /= 2; ok = 1; ct++;
			}
		}
		if (ok == 0)break;
	}
	printf("%d", ct);
}

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

typedef long long ll;
int main(){
    ll N, A, B; cin >> N >> A >> B;
    
    if((B-A)%2==0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	m := scanInt()
	a := scanInts(n)

	uf := make(unionFind, n+1)
	uf.init()
	for i := 0; i < m; i++ {
		x := scanInt()
		y := scanInt()
		uf.unite(x,y)
	}

	ans := 0
	for i := 0; i < n; i++ {
		if uf.find(i+1) == uf.find(a[i]) { ans++ }
	}

	fmt.Fprintln(wr, ans)
}

type unionFind []int

func (uf *unionFind) init() {
	for i := 0; i < len(*uf); i++ { (*uf)[i] = -1 }
}

func (uf *unionFind) find(x int) int {
	if (*uf)[x] < 0 { return x }
	(*uf)[x] = uf.find((*uf)[x])
	return (*uf)[x]
}

func (uf *unionFind) unite(x, y int) {
	x, y = uf.find(x), uf.find(y)
	if x != y {
		if (*uf)[x] > (*uf)[y] { x,y = y,x }
		(*uf)[x] += (*uf)[y]
		(*uf)[y] = x
	}
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
//#pragma GCC optimize("O3")
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) if (i % 3 != 0 && i % 5 != 0) ans += i;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
#pragma GCC target ("avx2")
#pragma GCC optimize "trapv"
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define input(a,n) for(ll i1=0;i1<n;i1++)cin>>a[i1]
#define ll long long
#define pi 2 * acos(0.0)
#define usll unordered_set<ll>
#define sll set<ll>
#define vll vector<ll>
#define mll map<ll,ll>
#define pll pair<ll,ll>
#define umll unordered_map<ll,ll>
#define S second
#define sz size()
#define all(v) v.begin(),v.end()
#define Y cout<< "YES"<< "\n"
#define N cout<< "NO"<< "\n"
#define F first
#define mp make_pair
#define pb push_back
#define pf push_front
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,k,d;
    cin>>x>>k>>d;
    if(x==0)
    {
        if(k%2==0)
            cout<<0;
        else
            cout<<d;
    }
     else if(x>=0)
    {
       if((x/d)>k)
           cout<<abs(x-k*d);
       else if((x/d)<=k)
       {
          ll ans=x;
          while(k&&(ans>0))
          {
              ans-=(d);
              k--;
          }
          if(k%2==0)
          {
              cout<<(ll)(abs(ans));
          }
          else
          {
              cout<<(ll)(abs(ans+d));
          }
       }
    }
    else if(x<0)
    {
        if((-(x/d))>(k))
           cout<<abs(x+k*d);
        else if((-(x/d))<=(k))
        {
            ll ans=x;
            while(k&&ans<0)
            {
               ans+=(d);
               k--;
            }
            if(k%2==0)
            {
                cout<<abs(ans);
            }
            else
            {
                cout<<abs(ans-d);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include <fstream>
#include <stdio.h>
#include <stdlib.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<sstream>
#include<algorithm>
#include<map>
#include<complex>
using namespace std;


#define li			long long int
#define rep(i,to)	for(int i=0;i<((int)(to));i++)
#define repp(i,start,to)	for(int i=(int)(start);i<((int)(to));i++)
#define pb			push_back
#define sz(v)		((li)(v).size())
#define bgn(v)		((v).begin())
#define eend(v)		((v).end())
#define allof(v)	(v).begin(), (v).end()
#define dodp(v,n)		memset(v,(li)n,sizeof(v))
#define bit(n)		(1ll<<(li)(n))
#define mp(a,b)		make_pair(a,b)
#define rin	rep(i,n)
#define EPS 1e-10
#define ETOL 1e-8
#define MOD 1000000007
#define p2(a,b)		cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)		cout<<a<<"\t"<<b<<"\t"<<c<<endl


int main(){
	li n;
	cin>>n;
	
	li res=100;
	rin{
		double tres=(double)res*1.05;
		if(tres-(int)tres==0)res=(int)tres;
		else res=(int)tres+1;
	}
	
	cout<<res*1000<<endl;
	
	return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;

signed main(){
    fastio
    int n;cin>>n;
    string s;
    cin>>s;
    ll ans=0;
    map<string,int>m;
    for(int i=n-1;i>=0;i--){
        string req;
        if(s[i]=='R')       req="BG";
        else if(s[i]=='G')  req="BR";
        else                req="GR";
        ans+=m[req];
        // cout<<"Check\n";
        // for(auto x:m){
        //     cout<<x.first<<" "<<x.second<<"\n";
        // }cout<<"\n";
        // cout<<i<<" "<<m[req]<<"\n";
        for(int j=i+2;j<n;j+=2){
            int k=(i+j)/2;
            string temp=string(1,s[k]);
            temp+=s[j];
            sort(temp.begin(),temp.end());
            if(temp==req)    ans--;
        }
        for(int j=i+1;j<n;j++){
            string temp=string(1,s[i]);
            temp+=s[j];
            sort(temp.begin(),temp.end());
            m[temp]++;
        }
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3632
def resolve():
    N, K = [int(i) for i in input().split()]
    H = sorted([int(input()) for _ in range(N)])
    minA = float("inf")
    for i in range(N - K + 1):
        minA = min(minA, H[i + K - 1] - H[i])
    print(minA)


resolve()


Measured memory_bytes: 14176
#include<iostream>
#include<cstring>
#include<cmath>
#include<queue>
#include<cstdio>
#include<algorithm>
#define LL long long
#define INF 1ll<<60
using namespace std;
const int N=2e5+100;
const int M=4e5+100;
const int mod=1e9+7;
int head[N],Next[M],ver[N],tot;
void add(int x,int y) {
    ver[++tot]=y;
    Next[tot]=head[x];
    head[x]=tot;
}
int vis[N];
int n,flag;

int tmp[N],kk=0;
void dfs(int x){
	if(x==n){
			tmp[++kk]=x;
			return ;
		}
	for(int i=head[x];i;i=Next[i]){
		
		int y=ver[i];
		if(vis[y])continue;
		vis[y]=1;
		
		dfs(y);
		if(kk){
			tmp[++kk]=x;
			return ;	
		}
	}
}
int mark[N];
int cal(int x){
	int cnt=0;
	for(int i=head[x];i;i=Next[i]){
		
		int y=ver[i];
		
		if(mark[y]||vis[y]==flag)continue;//cout<<y<<".."<<" "<<vis[y]<<" "<<flag<<endl;
		mark[y]=1;
		cnt+=cal(y);
	}
	return cnt+1;
	
}
int main() {

    while(cin>>n) {
        tot=1;
        int num1=0,num2=0;
        memset(head,0,sizeof(head));
        memset(Next,0,sizeof(Next));
        memset(ver,0,sizeof(ver));
        memset(vis,0,sizeof(vis));
        memset(mark,0,sizeof(mark));
        tmp[0]=0;
        kk=0;
        int x,y;
        for(int i=1; i<n; i++) {
            cin>> x >> y;
            add(x,y);
            add(y,x);
        }
		vis[1]=1;
        dfs(1);
        
        memset(vis,0,sizeof(vis));
        int l=1,r=kk;
        while(l<=r){
        	int x=tmp[l];
        	int y=tmp[r];
        	if(vis[y]==0)vis[y]=1;
        	if(vis[x]==0)vis[x]=2;
        	l++;r--;
  	
		}
//		for(int i=1;i<=n;i++)cout<<vis[i]<<" ";
//		cout<<endl;
		flag=2;
		mark[1]=1;
		num1=cal(1);
		
		flag=1;
		memset(mark,0,sizeof(mark));
		mark[n]=1;
		num2=cal(n);
		
		
		//cout<<num1<<" "<<num2<<endl;
        if(num1>num2){
        	cout<<"Fennec"<<endl; 
        	
		}else{
			cout<<"Snuke"<<endl;
			
		}

    }
    return 0;

}


Measured memory_bytes: 8448
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int d[5*100000+1];
int main(){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    ll res = n*2;
    rep(i,n){
        string ss = s.substr(i,n-i),tt = t.substr(0,n-i);
        if(ss==tt){
            res = n*2-n+i;
            break;
        }
    }
    cout<<res<<endl;
}



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

int par[10001], depth[10001];

void init(int n){
 
  for(int i = 0; i < n; i++) par[i] = i, depth[i] = 0;
}

int find(int x){
  
  if(par[x] == x) return x;
  else return par[x] = find(par[x]);

}

void unite(int x, int y){
  
  x = find(x), y = find(y);
  if(x == y) return;
  if(depth[x] < depth[y]) par[x] = y;
  else{
    par[y] = x;
    if(depth[x] == depth[y]) depth[x]++;
  }

}

int same(int x, int y){
  
  return (find(x) == find(y));
}

int main(){

  int n, q;
  cin >> n >> q;
  init(n);
  
  while(q--){
    int com, x, y;
    cin >> com >> x >> y;
    if(!com) unite(x, y);
    else cout << same(x, y) << endl;
  }

}
    

Measured memory_bytes: 1240
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    int N;cin>>N;
    set<int> st;
    REP(i,N){
        int a;cin>>a;
        if(!st.erase(a))st.insert(a);
    }
    cout<<st.size()<<endl;
    return 0;
}

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

using namespace std;
int X,N;
int A[2000010]{};
bool B[2000010]{};

int main()
{
  cin>>N;
  for(int i=1;i<=N;i++)cin>>A[i];
  int count=0;
  for(int i=1;i<=N;i++){
    if(A[A[i]]==i)count++;
  }

  cout<<count/2;
  return 0;
}





Measured memory_bytes: 3980
#include<bits/stdc++.h>
#define ll long long
using namespace std;
template<typename tn> void read(tn &a){
	tn x=0,f=1; char c=' ';
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	a=x*f;
}
const int N = 1001000,mod = 1e9+7;
int n;
ll inv[N],fac[N],ifac[N],f[N][3],P[N],L[N];
ll fp(ll a,ll k){
	ll ans=1;
	for(;k;k>>=1,a=a*a%mod)
		if(k&1) ans=a*ans%mod;
	return ans;
}
void solveP(){
	f[0][0]=1;
	for(int i=1;i<=n;i++){
		f[i][0]=(f[i-1][1]+f[i-1][2])%mod;
		f[i][1]=(f[i-1][0]+f[i-1][2])%mod;
		f[i][2]=(f[i-1][0]+f[i-1][1])%mod;
	}
	fac[0]=1;
	for(int i=1;i<=n;i++) fac[i]=fac[i-1]*i%mod;
	ifac[n]=fp(fac[n],mod-2);
	for(int i=n;i;i--) ifac[i-1]=ifac[i]*i%mod;
	auto C=[&](int n,int m){
		return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
	};
	for(int i=1;i<=n;i++)
		P[i]=f[i][1]*C(n,i)%mod;
	ll Inv=1,inv=fp(3,mod-2);
	for(int i=1;i<n;i++) Inv=Inv*inv%mod;
	for(int i=1;i<=n;i++) P[i]=P[i]*Inv%mod;
}
void solveL(){
	ll len=fp(3*n,mod-2);
	inv[1]=1;
	for(int i=2;i<=n;i++) inv[i]=inv[mod%i]*-(mod/i)%mod;
	for(int i=1;i<=n;i++){
		ll tot=len*i%mod;
		L[i]=inv[i]*inv[i]%mod*tot%mod;
	}
}
int main(){
	read(n);
	solveP();
	solveL();
	ll ans=0;
	for(int i=1;i<=n;i++)
		ans=(ans+1ll*P[i]*L[i])%mod;
	cout<<(ans+mod)%mod<<'\n';
	return 0;
}


Measured memory_bytes: 62848
from itertools import combinations as comb

N = int(input())
n = N-1 if N%2 else N
s = set()

for i in range(1, N+1):
    if N%2:
        a, b = i, N-i
    else:
        a, b = i, N-i+1
    if a<b:
        s.add((a, b))

l = [i for i in comb(range(1, N+1), 2) if not i in s]
print(len(l))
for i in l:
    print(*i)

Measured memory_bytes: 3996
class Observatory:
    def __init__(self, height):
        self.height = height
        self.around = []

    def is_good(self, li, di):
        flag = True
        for i in self.around:
            oo = li[i - 1]
            if oo.height >= self.height:
                flag = False
            else:
                di[i - 1] = False
        return flag


n, m = map(int, input().split())
h = [int(i) for i in input().split()]
observatories = [Observatory(h[i]) for i in range(n)]
dic = {}
for i in range(n):
    dic[i] = True

for i in range(m):
    a, b = map(int, input().split())
    observatories[a - 1].around.append(b)
    observatories[b - 1].around.append(a)

ans = 0

for i in range(n):
    o = observatories[i]
    if dic[i]:
        if o.is_good(observatories, dic):
            ans += 1

print(ans)


Measured memory_bytes: 54380
IDENTIFICATION DIVISION.
      PROGRAM-ID. 079A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 N PIC X(4).
      01 INP.
      	03 INP1 PIC 9(1).
      	03 INP2 PIC 9(1).
      	03 INP3 PIC 9(1).
      	03 INP4 PIC 9(1).
      
      PROCEDURE DIVISION.
      ACCEPT N.
      MOVE N TO INP.
      
      EVALUATE TRUE
      WHEN ( INP1 = INP2 ) AND ( INP2 = INP3 )
      WHEN ( INP2 = INP3 ) AND ( INP3 = INP4 )
      	DISPLAY "Yes"
      WHEN OTHER
      	DISPLAY "No"   
      END-EVALUATE.
      
      STOP RUN.

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rp(i,j) for(long long i=0;i<j;i++)
#define MAX 100
int main(){
    int n=1;
    while(n>0){
        int a[MAX],max=0,n_max=0;
        char c[MAX],max_c;
        cin>>n;
        rp(i,n)cin>>c[i];
        rp(i,26)a[i]=0;
        rp(i,n){
            int x=a[c[i]-65];
            a[c[i]-65]++;
            if(x==max){
                max++;
              	max_c=c[i];
            }
            else if(x>=n_max){
                n_max=x+1;
            }
            if(max-n_max>n-i-1){
                cout<<max_c<<" "<<i+1<<endl;
                break;
            }
            if(i==n-1)cout<<"TIE"<<endl;
    	}
    }
    return 0;
}


Measured memory_bytes: 3088
N = int(input())
l = []
for _ in range(N):
    l.append(input())

from collections import Counter

co = Counter(l).most_common()
l = [co[0][0]]

for n in range(len(co)-1):
    if co[n+1][1] == co[n][1]:
        l.append(co[n+1][0])
    else:
        break
l.sort()

for n in range(len(l)):
    print(l[n])

Measured memory_bytes: 45068
#include<bits/stdc++.h>
#define rep(i,n) for(int (i) = 0;(i) < (n);(i)++)
#define SORT(c) sort((c).begin(),(c).end())
#define MOD 1000000007 //S.size() 配列名.length()
using namespace std;
typedef unsigned long long ll;

int main(void){
	int n;
	cin >> n;
	int a[n];
	rep(i, n) cin >> a[i];

	int min = a[0];
	int ans = -MOD;
	int max_memo[n];
	max_memo[n - 1] = a[n - 1];
	for(int i = n - 2; i >= 0; i--){
		if(a[i] >= max_memo[i + 1]) max_memo[i] = a[i];
		else max_memo[i] = max_memo[i + 1];
	}
	for(int i = 0; i < n - 1; i++){
		if(a[i] < min) min = a[i];
		int num = max_memo[i + 1] - a[i];
		if(num > ans) ans = num;
	}

	cout << ans << endl;

	return 0;
}



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

int main() {
	string s;
	cin >> s;
	int a = 0, b = 0, c = 0;

	for (int i = 0; i < 3; i++) {
		if (s.at(i) == 'a') a++;
		else if (s.at(i) == 'b') b++;
		else if (s.at(i) == 'c') c++;
	}

	if (a == 1 && b == 1 && c == 1) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt();
			int b = scanner.nextInt();
			System.out.println(((a & 1) == 0) || ((b & 1) == 0) ? "Even" : "Odd");
		}
	}
}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
double prb  (int i, int k) {
  int p = 0;
  for (; i < k; p++) i <<= 1;
  return pow(0.5, p);
}
int main() {
  int n, k;
  cin >> n >> k;
  double ret = 0;
  for (int i = 1; i <= n; i++) {
    ret += prb(i, k);
  }
  ret /= n;
  cout << setprecision(11) << ret << endl;
  return 0;
}

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

ll solve() {
    ll N;
    cin >> N;
    ll a, s1 = 0, s2 = 0;
    ll r1 = 0, r2 = 0;
    for ( int i = 0; i < N; i++ ) {
        cin >> a;
        s1 += a;
        s2 += a;
        if ( i & 1 ) {
            if ( s1 < 1 ) {
                r1 += 1 - s1;
                s1 = 1;
            }
            if ( s2 > -1 ) {
                r2 += s2 + 1;
                s2 = -1;
            }
        } else {
            if ( s1 > -1 ) {
                r1 += s1 + 1;
                s1 = -1;
            }
            if ( s2 < 1 ) {
                r2 += 1 - s2;
                s2 = 1;
            }
        }
    }
        
    ll ans = min(r1, r2);
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
a=list(input())
if len(a)==1:
  if a[0]=='2' or  a[0]=='4' or  a[0]=='5' or a[0]=='7' or a[0]=='9':
    print('hon')
  elif a[0]=='0' or  a[0]=='1' or  a[0]=='6' or a[0]=='8' :
    print('pon')  
  else:
    print('bon')
elif len(a)==2:
  if a[1]=='2' or  a[1]=='4' or  a[1]=='5' or a[1]=='7' or a[1]=='9':
    print('hon')
  elif a[1]=='0' or  a[1]=='1' or  a[1]=='6' or a[1]=='8' :
    print('pon')  
  else:
    print('bon')
elif len(a)==3:
  if a[2]=='2' or  a[2]=='4' or  a[2]=='5' or a[2]=='7' or a[2]=='9':
    print('hon')
  elif a[2]=='0' or  a[2]=='1' or  a[2]=='6' or a[2]=='8' :
    print('pon')  
  else:
    print('bon')



Measured memory_bytes: 9132
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<cstdio>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<stack>
#include<iterator>
#include<functional>
#include<string.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//namespace mp = boost::multiprecision;

int main() {
	int n; cin >> n;
	int count = 0;
	while (n !=0) {
		
		if (n % 10 == 2) {
			count++;
		}
		n=n / 10;
	}
	cout << count << endl;

}
	

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define deb(x) cerr<<#x<<" "<<x<<"\n"
#define debi cerr<<"hey sparky\n"
#define f first
#define s second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define newline cout<<"\n"
#define yes cout<<"YES"<<"\n"
#define no cout<<"NO"<<"\n"
#define INF (int)1e5
#define nax (int)1e5+2
using namespace std;
// look for  all edge cases
//search for a pattern


int main(){
	fast;
	ll n;
	cin >> n;
	ll sum = 0;
	for(ll i = 1 ; i<= n; i++){
		for(ll j = 1 ;j <= n ;j++){
				for(ll k = 1; k<=n ;k++){
					ll temp = __gcd(k,j);
					temp  = __gcd(temp,i);
					sum += temp;
				}
		}
	}
	cout<<sum;
	
	return 0;
	
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define ROOP(i, N) for(int i=0; i++; i<N)
#define RVROOP(i, N) for(int i=N; i--; i>=0)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main() {
  int M,D,MM,DD; cin>>M>>D>>MM>>DD;
  if(M!=MM){
    cout<<"1"<<endl;
  }
  else{
    cout<<"0"<<endl;
  }
}


Measured memory_bytes: 256
#include <utility>
#include <stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define YES(b) std::cout<< (b ? "Yes" : "No")
using namespace std;
int main() {
	int n, sum = 0,m=1500001;
	int w[1500000];
	string s;
	cin >> n >>s;
	REP(i, n) {
		if (s[i] == 'W') {
			sum++;
		}
		w[i] = sum;
	}
	REP(i, n) {
		sum = 0;
		if (i > 0) {
			sum += w[i - 1];
		}
		if (i < n - 1) {
			sum += (n - 1 - i) - (w[n - 1] - w[i]);
		}
		m = min(m, sum);
	}
	cout << m;
}

Measured memory_bytes: 3204
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define yes(n) cout << ((n) ? "yes" : "no"  ) << endl
#define Yay(n) cout << ((n) ? "Yay!": ":(") << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define VSUM(V) accumulate(ALL(V), 0)
#define MID(a,b,c) (a) < (b) && (b) < (c)
#define MIDe(a,b,c) (a) <= (b) && (b) <= (c)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define IN4(a,b,c,d) cin >> a >> b >> c >> d
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b != 0 ? gcd(b, a % b) : a;} //最大公約数
int lcm(int a, int b){return a * b / gcd(a, b);}
string toStrUp(string str){char diff = 'A'-'a';REP(i,str.size()) str[i] += diff;return str;}
string gCh(string str, int key){return str.substr(key,1);}

signed main() {
  RAPID;
  // デフォルト変数定義
  int n=0,m=0,a=0,b=0,d=0,x=0,y=0,z=0;
  double c = 0;
  string s="",t="";
  //

  // ここから
  IN(n);
  Vi v(n);
  VIN(v)
  Vi up(n);
  FOR(i,0,n){up[i] = i+1;}
  REP(i,n){
    if(v[i]!=up[i]) c++;
  }
  c /= 2;
  YES(c<=1);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
using namespace std;
int main()
{
    char a;
    cin>>a;
    if(a=='a'){cout<<"vowel"<<endl;return 0;}
    else if(a=='e'){cout<<"vowel"<<endl;return 0;}
         else if(a=='i'){cout<<"vowel"<<endl;return 0;}
              else if(a=='o'){cout<<"vowel"<<endl;return 0;}
                   else if(a=='u'){cout<<"vowel"<<endl;return 0;}
                         else{cout<<"consonant"<<endl;}
                         return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
const int inf=1000000000000000007;
const int MOD=1000000007;
int n;
int a[4000]={};
int memo[4000][4000][2];
//0->太郎くん, 1->次郎くん
int rec(int l,int r,int t){
    if(t==0){
        if(memo[l][r][0]!=inf){
            return memo[l][r][0];
        }
        else{
            memo[l][r][0]=max(rec(l+1,r,1)+a[l],rec(l,r-1,1)+a[r]);
            return memo[l][r][0];
        }
    }
    else{
        if(memo[l][r][1]!=inf){
            return memo[l][r][1];
        }
        else{
            memo[l][r][1]=min(rec(l+1,r,0)-a[l],rec(l,r-1,0)-a[r]);
            return memo[l][r][1];
        }
    }
    return 0;
}
signed main(){
  cin>>n;
  rep(i,n)cin>>a[i];
  rep(i,n+5){
      rep(j,n+5){
          memo[i][j][0]=inf;
          memo[i][j][1]=inf;
      }
  }
  rep(i,n+5){
      memo[i][i][0]=a[i];
      memo[i][i][1]=-a[i];
  }
  cout<<rec(0,n-1,0)<<endl;
  /*
  rep(i,n){
      rep(j,n){
          cout<<memo[i][j][0]<<" ";
      }
      cout<<endl;
  }*/
  return 0;
}

Measured memory_bytes: 188544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const int N = 200000;

int n, a[N], b[N];

int main()
{
    scanf( "%d", &n );
    for( int i = 1; i <=n ; i ++ )
        scanf( "%d%d", &a[i], &b[i] );
        
    ll ans = 0, min_b = INF; bool same = true;
    for( int i = 1; i <= n; i ++ ) {
        ans += b[i];
        if( b[i] < a[i] && b[i] < min_b ) 
            min_b = b[i]; 
        if( a[i] != b[i] ) same = false;
    }

	if( same ) printf( "0\n" );
    else printf( "%lld\n", ans - min_b );

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    long long int a,b,gcd,lcm,m,u,temp;
    while(scanf("%llu %llu",&a,&b)!=EOF){
        m=(a*b);{
        while(b!=0){
            temp=b;
            b=(a%b);
            a=temp;
        }
         gcd=a;
         lcm=m/gcd;
        }
        printf("%llu %llu\n",gcd,lcm);
    }
    return 0;
}

Measured memory_bytes: 600
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long ll;
const long long INF = 1e18;

ll n;
ll a[405], dp[405][405], pre[405];


int main(){
	cin >> n;
	pre[0] = 0;
	for(ll i = 1; i <= n; i++){
		cin >> a[i];
		dp[i][i] = 0;
		pre[i] = pre[i - 1] + a[i];
	}
	ll ans = 0, tmp = 0;
	for(ll i = 2; i <= n; i++){
		for(ll l = 1; l <= n - i + 1; l++){
			ll r = l + i - 1;
			dp[l][r] = INF;
			for(ll k = l; k <= r; k++){
				dp[l][r] = dp[l][r] <  dp[l][k] + dp[k + 1][r] + pre[r] - pre[l - 1] ? dp[l][r] :  dp[l][k] + dp[k + 1][r] + pre[r] - pre[l - 1];
			}
		}
	}
	cout << dp[1][n] << endl; 
	return 0;
}

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

int yuku(long long a,long long b){
    long long e;
    if(b > a){
        e = a;
        a = b;
        b = e;
    }
    long long d,c = b;
    while(c != 0){
        d = c;
        c = a%b;
        a = b;
        b = c;
    }
    return(d); 
}

int main() {
    long long a,b = 0,c,d,n;
    cin >> n;
    for(int i = 1;i <= n;i++){
        for(int j = 1;j <= n;j++){
            for(int f = 1;f <= n; f++){
                a = yuku(i,j);
                a = yuku(a,f);
                b += a;
            }
        }
    }
    cout << b << endl;
}

Measured memory_bytes: 3636
#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 << "Left" << endl;
  }
  else if (a + b < c + d ){
    cout << "Right" << endl;
  }
  else{
    cout << "Balanced" << endl;
  }


}


Measured memory_bytes: 256
def main():
    import sys
    from collections import deque
    input = sys.stdin.readline

    # comb init
    mod = 1000000007
    nmax = 2*10 ** 5 + 10  # change here
    fac = [0] * nmax
    finv = [0] * nmax
    inv = [0] * nmax
    fac[0] = 1
    fac[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    for i in range(2, nmax):
        fac[i] = fac[i - 1] * i % mod
        inv[i] = mod - inv[mod % i] * (mod // i) % mod
        finv[i] = finv[i - 1] * inv[i] % mod

    def comb(n, r):
        if n < r:
            return 0
        else:
            return (fac[n] * ((finv[r] * finv[n - r]) % mod)) % mod

    N = int(input())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)


    que = deque()
    que.append(1)
    seen = [-1] * (N+1)
    seen[1] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + 1
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()

    dp = [1] * (N+1)
    size = [1] * (N+1)
    for v in seq:
        for u in child[v]:
            size[v] += size[u]
        L = size[v] - 1
        for u in child[v]:
            dp[v] = (dp[v] * (dp[u] * comb(L, size[u]))%mod)%mod
            L -= size[u]

    seq.reverse()
    dp2 = [0] * (N+1)
    for v in seq:
        if v == 1:
            dp2[1] = dp[1]
            continue
        p = par[v]
        dp2[v] = dp[v]
        PP = (dp2[p] * pow((dp[v] * comb(N-1, size[v]))%mod, mod-2, mod))%mod
        dp2[v] = (dp2[v] * PP * comb(N-1, size[v]-1))%mod
    for v in range(1, N+1):
        print(dp2[v])


if __name__ == '__main__':
    main()


Measured memory_bytes: 124748
import java.io.*; 
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 998244353;
	//static final long MOD = 1000000007;
	static boolean[] visited;
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        String s = sc.next();
        if (s.equals("Sunny")) {
        	System.out.println("Cloudy");
        } else if (s.equals("Cloudy")) {
        	System.out.println("Rainy");
        } else {
        	System.out.println("Sunny");
        }
    }
    
    public static int[] baseN(int N, int num) {
    	int[] ans = new int[N];
    	for (int i = N-1; i >= 0; i--) {
    		int pow = (int)Math.pow(N,i);
    		ans[i] = num/pow;
    		num -= ans[i]*pow;
    	}
    	return ans;
    }
    
    public static int[][] sort(int[][] array) {
    	//Sort an array (immune to quicksort TLE)
		Random rgen = new Random();
		for (int i = 0; i< array.length; i++) {
		    int randomPosition = rgen.nextInt(array.length);
		    int[] temp = array[i];
		    array[i] = array[randomPosition];
		    array[randomPosition] = temp;
		}
		Arrays.sort(array, new Comparator<int[]>() {
			  @Override
			  public int compare(int[] arr1, int[] arr2) {
				  //Descending order
				  return arr2[0]-arr1[0];
			  }
		});
		return array;
	}
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

class Node {
	public HashSet<Node> children;
	public int n;
	
	public Node(int n) {
		this.n = n;
		children = new HashSet<Node>();
	}
	
	public void addChild(Node node) {
		children.add(node);
	}
	
	public void removeChild(Node node) {
		children.remove(node);
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return n;
	}

	@Override
	public boolean equals(Object obj) {
		if (! (obj instanceof Node)) {
			return false;
		} else {
			Node node = (Node) obj;
			return (n == node.n);
		}
	}
	
	public String toString() {
		return (this.n+1)+"";
	}
}

Measured memory_bytes: 20692
#include <iostream>
#include <algorithm>
using namespace std;
int main(void){
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
     int C,A,N,ans=0;
     cin>>C>>A>>N;
     int t=min(C,min(A,N));
     C-=t;
     A-=t;
     ans+=t;
     t=min(C/2,A);
     C-=t*2;
     ans+=t;
     ans+=C/3;
     cout<<ans<<endl;
     
 }
}

Measured memory_bytes: 3120
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};

int main(){
    double W,H,x,y;cin >> W >> H >> x >> y;
    cout<<(W*H)/2<<" ";
    /*
    if(y/H == x/W){
        cout<<1<<endl;
      //  cout<<"A"<<endl;
        return 0;
    }
    */
    if(H/2 == y && W/2 == x){
        cout<<1<<endl;
        return 0;
    }
    cout<<0<<endl;
}


Measured memory_bytes: 256