akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const ll INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int N; ll K;
    cin >> N >> K;
    vector<P> v(N);
    multiset<P> s;
    REP(i,N){
        cin >> v[i].first >> v[i].second;
        s.insert(v[i]);
    }

    ll l = 1;
    int ans;
    for(auto p : s){
        if(l<=K && K<l+p.second){ans = p.first; break;}
        l += p.second;
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin>>n;
    int m=n/15;
    cout<<800*n-200*m<<endl;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
# 全体の長さから右から数えて最初に出た1の箇所のインデックスを引く
# 後ろに続く0の数が2で割れる回数にあたる
# 例　全：6 インデックス 2 -1 
ans = float("inf")
for i in A:
    ans = min(ans, len(bin(i)) - bin(i).rfind("1") -1 )
print(ans)

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <iterator>
#include <climits>

using namespace std;

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

    vector<int> a(n+2);
    a[0] = 0;
    for (int i = 1; i < n + 1; i++) {
        cin >> a[i];
    }
    a[n+1] = 0;

    int total = 0;
    for (int i = 0; i < n + 1; i++) {
        total += abs(a[i] - a[i+1]);
    }

    for (int i = 0; i < n; i++) {
        int normal_cost = abs(a[i] - a[i+1]) + abs(a[i+1] - a[i+2]);
        int skip_cost = abs(a[i] - a[i+2]);
        if (normal_cost > skip_cost) {
            cout << total - abs(normal_cost - skip_cost) << endl;
        } else {
            cout << total << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 1664
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
#include <math.h>
#include <iostream>
#include <string>
#include<algorithm>
#include <vector>
using namespace std;


int main() {
	int N;
	string S;
	string T;
	cin >> N;
	cin >> S;
	cin >> T;

	for (int i = 0; i < N; ++i) {
		cout << S[i] << T[i];
	}


}

Measured memory_bytes: 256
def m(L,R):
 global c;c+=len(L)+len(R)
 T=[];j=0
 for l in L:
  while j<len(R)and R[j]<l:T+=[R[j]];j+=1
  T+=[l]
 while j<len(R):T+=[R[j]];j+=1
 return T
def d(A):s=len(A)//2;return m(d(A[:s]),d(A[s:])) if len(A)>1 else A
c=0
input()
print(*d(list(map(int,input().split()))))
print(c)


Measured memory_bytes: 63912
/********************************************//**
 ****** Author: Shivam Kejriwal *****************
 ****** Handle: techno_phyle    *****************
 ***********************************************/

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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
typedef long long ll;

#define mod 1000000007
#define N 100010
#define M 200010
#define db(a) cout << a << endl
#define db2(a,b) cout << a << " " << b << endl
#define dbp(a) cout << a.first << " " << a.second << endl
#define adb(a) for(auto it:a) cout << it << " "; cout << endl
#define adbp(a) for(auto it:a) cout << it.first << " " << it.second << endl
#define pb push_back
#define mp make_pair
typedef pair<double, long> key;

struct comp {
    bool operator()(pair<int,int> p1, pair<int,int> p2) {
        if (p1.first < p2.first) return false;
        if (p2.first < p1.first) return true;
        return p1.second < p2.second;
    };
};
//greater<pair<int,int> , greater<int>>
int main(){
	fastIO;
    //#ifndef ONLINE_JUDGE
    //    freopen("../input.txt", "r", stdin);
    //    freopen("../output.txt","w",stdout);
    //#endif
	int n,k;
    cin >> n >> k;
    int a[n+1];
    for(int i=1;i<=n;i++) cin >> a[i];
    int dp[n+1];
    dp[1] = 0;
    for(int i=2;i<=n;i++) dp[i] = INT_MAX;
    dp[2] = abs(a[2] - a[1]);
    for(int i=3;i<=n;i++){
        for(int j = 1;j<=k;j++){
            if((i-j)<1)
                break;
            dp[i] = min(dp[i] , abs(a[i] - a[i-j]) + dp[i-j]);

        }
    }
    cout << dp[n] << endl;
	return 0;

}



Measured memory_bytes: 1024
// AOJ 0604: Take the 'IOI' train
// 2017.12.5 bal4u@uu

#include <stdio.h>
#include <string.h>

char s[2002], t[2002];
int dp[2][2002][2002];

int main()
{
	int n, m, i, j, ans;
	char *p;

	fgets(s, 20, stdin);
	sscanf(s, "%d%d", &m, &n);
	fgets(s, 2002, stdin);
	fgets(t, 2002, stdin);

	for (p = s; *p > ' '; p++) *p = (*p >> 1) & 1;
	for (p = t; *p > ' '; p++) *p = (*p >> 1) & 1;

	ans = 0;
	memset(dp[0], -1, sizeof(dp[0]));

	for (i = 0; i <= m; i++) for (j = 0; j <= n; j++) {
		if (i < m) {
			if (dp[s[i]][i+1][j] < dp[1-s[i]][i][j] + 1)
				dp[s[i]][i+1][j] = dp[1-s[i]][i][j] + 1;
		}
		if (j < n) {
			if (dp[t[j]][i][j+1] < dp[1-t[j]][i][j] + 1)
				dp[t[j]][i][j+1] = dp[1-t[j]][i][j] + 1;
		}
	}
	for (i = 0; i <= m; i++) for (j = 0; j <= n; j++)
		if (ans < dp[0][i][j]) ans = dp[0][i][j];

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

Measured memory_bytes: 33112
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){  
    int n;
    cin>>n;
    long double a[n],ans;
    
    ans=0;
    for (int i = 0; i < n; i++)
    {
        cin>>a[i];
        ans+=(1/a[i]);
    }
    
    ans=1/ans;
    cout<<ans;
    
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

public static partial class Program
{
    public static void Main()
    {
        var abcd = CRL().ToCharArray().Select(x => x.ToLong()).ToArray();
        var a = abcd[0];
        var b = abcd[1];
        var c = abcd[2];
        var d = abcd[3];
        var part = new int[2] { -1, +1 };
        var res = new string[2] { "-", "+" };

        for (int bIdx = 0; bIdx < 2; bIdx++)
        {
            for (int cIdx = 0; cIdx < 2; cIdx++)
            {
                for (int dIdx = 0; dIdx < 2; dIdx++)
                {
                    if (a + b * part[bIdx] + c * part[cIdx] + d * part[dIdx] == 7)
                    {
                        CWL(a + res[bIdx] + b + res[cIdx] + c + res[dIdx] + d + "=7");
                        return;
                    }
                }
            }
        }
    }
}

public static partial class Program
{
    //テンプレここから
    private static long ToInt(this string str) => long.Parse(str);
    private static long[] ToInt(this IEnumerable<string> strs) => strs.Select(x => x.ToInt()).ToArray();
    public static long[] ArrayLongs(this string str, char opr = ' ') => str.Split(opr).ToInt();
    public static string CRL() => Console.ReadLine();
    public static void CWL(object obj) => Console.WriteLine(obj);
    public static long Diff(long a, long b) => Math.Abs(Math.Max(a, b) - Math.Min(a, b));
    public static long Sign(this long i) => Math.Sign(i);
    public static bool IsEven(this long i) => i % 2 == 0;
    public static bool IsEven(this int i) => i % 2 == 0;
    public static long[] dx = new long[] { 0, -1, 0, 1 };
    public static long[] dy = new long[] { -1, 0, 1, 0 };
    public static long mod = 1000000007;
    public static string alphabet = "abcdefghijklmnopqrstuvwxyz";
    public static long ToLong(this char c) => c.ToString().ToInt();
    //テンプレここまで
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int x[102];

signed main()
{
	IO_OP;
	
	int n;
	cin >> n;
	for(int i=0;i<n;i++) cin >> x[i];
	int mn = INF;
	for(int i=1;i<=100;i++) {
		int cur = 0;
		for(int j=0;j<n;j++) cur += (x[j]-i)*(x[j]-i);
		mn = min(mn, cur);
	}
	cout << mn << endl;
	
}





Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		TakashiInfo solver = new TakashiInfo();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class TakashiInfo {

		private int map[][] = new int[3][3];

		private Scanner scanner;
		private String output;

		public TakashiInfo() {
			scanner = new Scanner(System.in);
		}

		public void readInput() {
			for(int i=0; i<3; i++) {
				for(int j=0; j<3; j++) {
					map[i][j] = Integer.parseInt(scanner.next());
				}
			}
		}
		public void solve() {
			for(int i=0;i<3;i++) {
				for(int j=1; j<3; j++) {
					map[i][j]-= map[i][0];
				}
			}
			output = (map[0][1]==map[1][1] && map[1][1]==map[2][1] && map[0][2]==map[1][2] && map[1][2]==map[2][2])? "Yes":"No";
		}


		public void writeOutput() {
			System.out.println(output);
		}
	}

}


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

using namespace std;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1000000007;

using ll = long long;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll b, ll e, ll m){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    cout << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    cout << ']';
    return s;
}

map<ll, ll> factor;
template<typename T>
void factorization(T n){

    while (n % 2 == 0){
        ++factor[2];
        n /= 2;
    }
    for (T i = 3; i*i <= n; i += 2){
        while (n%i == 0){
            ++factor[i];
            n /= i;
        }
    }
    if (n > 2)
        ++factor[n];

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    ll ans = 1LL;
    for(int i = 1; i <= n; ++i){
        factorization(i);
    }

    for(auto x : factor){
        ans *= x.second+1;
        ans %= MOD;
    }

    ppp(ans);
    return 0;
}


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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using P = std::tuple<int,int>;

std::vector<int> Z_Algorithm(std::vector<int> seq){
    auto s = seq.size();
    std::vector<int> res(s);
    res[0] = s;

    int i = 1, j = 0; // satisfying seq[0..j) = seq[i..i+j)
    while(i < s){
        while(i + j < s && seq[j] == seq[i+j]){
            j += 1;
        }
        res[i] = j;
        if(j == 0){
            i += 1;
            continue;
        }
        int k = 1;
        while(i + k < s && k + res[k] < j){
            res[i+k] = res[k];
            k += 1;
        }
        i += k;
        j -= k;
    }

    return res;
}

int N;
std::vector<int> A, B, A2, B2, C, ks;

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

  std::cin >> N;

  A.resize(N);
  B.resize(N);
  A2.resize(N);
  B2.resize(N);
  C.resize(3 * N);

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

  for(int i=0;i<N;++i){
      std::cin >> B[i];
  }

  for(int i=0;i<N-1;++i){
      A2[i] = A[i] ^ A[i+1];
      B2[i] = B[i] ^ B[i+1];
  }
  A2[N-1] = A[N-1] ^ A[0];
  B2[N-1] = B[N-1] ^ B[0];

  std::copy(B2.begin(), B2.end(), C.begin());
  std::copy(A2.begin(), A2.end(), C.begin() + N);
  std::copy(A2.begin(), A2.end(), C.begin() + 2 * N);

  auto Z = std::move(Z_Algorithm(C));

  for(int i=0;i<N;++i){
      if(Z[i+N] >= N){
          ks.emplace_back(i);
      }
  }

  for(int k : ks){
      int x = A[k] ^ B[0];
      std::cout << k << " " << x << std::endl;
  }
}


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

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln "\n"
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s, t[16];

int main() {
	cin >> s;
	rep(i,16) {
		string tm;
		if (i>>0 & 1) tm += "A";
		tm += "KIH";
		if (i>>1 & 1) tm += "A";
		tm += "B";
		if (i>>2 & 1) tm += "A";
		tm += "R";
		if (i>>3 & 1) tm += "A";
		t[i] = tm;
	}
	rep(i,16) {
		if (s==t[i]) {
			cout << "YES" << ln;
			return 0;
		}
	}
	cout << "NO" << ln;
}

Measured memory_bytes: 256
//Problem D
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mul(a) (s=s*(a)%1000000007)
const int N=1005;
bool cmp(int a,int b){return a>b;}
int n,m,x,y,z,a[N],b[N];
ll s=1;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)scanf("%d",&b[i]);sort(b+1,b+m+1,cmp);
	for(int i=1;i<n;i++)if(a[i]==a[i+1]){printf("0");return 0;}
	for(int i=1;i<m;i++)if(b[i]==b[i+1]){printf("0");return 0;}
	for(int i=n*m;i;i--){
		int p=(a[x+1]==i),q=(b[y+1]==i);
		if(p==1&&q==1)++x,++y;
		if(p==1&&q==0)++x,mul(y);
		if(p==0&&q==1)++y,mul(x);
		if(p==0&&q==0)mul(x*y-z);
		++z;//printf("%d %d %d %lld\n",x,y,z,s);
	}
	printf("%lld",s);
	return 0;
}

Measured memory_bytes: 256
class dice:
    def __init__(self):
        self.d = [0] + list(map(int, input().split()))
        
    def move(self):
        dir = list(input())
        up = [0,1,2,3] 
        for a in self.dir:
            if a == "E":
                up = [0, 7-up[3], up[2], up[1]]
            elif a == "W":
                up = [0, up[3], up[2], 7-up[1]]
            elif a == "N":
                up = [0, up[2], 7-up[1], up[3]]
            else:
                up = [0, 7-up[2], up[1], up[3]]
        print(self.d[up[1]])
        
    def solve(self):
        top, front = map(int, input().split())
        T = self.d.index(top)
        F = self.d.index(front)
        L =[[1,2,3], [2,6,3], [6,5,3], [5,1,3], [2,3,1], [3,5,1], [5,4,1], [4,2,1], [1,4,2], [4,6,2], [6,3,2], [3,1,2]]
        for l in L:
            if l[0] == T and l[1] == F:
                print(self.d[l[2]])
                break
            elif l[1] == T and l[0] == F:
                print(self.d[7-l[2]])
                break

ob = dice()
for x in range(int(input())):
    ob.solve()
        
        




Measured memory_bytes: 5612
towers = [
    [[0 for i in range(10)] for j in range(3)] for k in range(4)
]
floor = 3
 
n = int(input())
for i in range(n):
    b,f,r,v = list(map(int,input().split()))
    towers[b-1][f-1][r-1] += v
 
for b in towers:
    for f in b:
        for r in f:
            print(' ' + str(r), end='')
        print('')
    if floor:
        print('#'*20)
        floor -= 1

Measured memory_bytes: 7712
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<iostream>
using namespace std;

int main()
{
    int a,b,c;
    while(cin>>a>>b>>c)
    {
        int d;
        d=a*100+b*10+c;
        int flag=0;
        if(d%4!=0)
            flag=1;
        if(!flag)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
   
using namespace std;
  
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(14)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;
 
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
 
template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A,class B> using umap = unordered_map<A,B>;
   
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}


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

    int n,m;
    cin >> n >> m;

    if(abs(n-m) >= 2) return cout << "0\n",0;

    int a = 1,b = 1;
    reps(i,n){
        (a *= i) %= mod;
    }
    reps(i,m){
        (b *= i) %= mod;
    }

    int res = (a * b) % mod;
    if(n - m == 0) (res *= 2) %= mod;

    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
	Scanner sc=new Scanner(System.in);
	void e(){
		while(true){
			int t=0,n=0,s=0,f=0,a=0;
			t=sc.nextInt();
			if(t==0)break;
			n=sc.nextInt();
		
			for(int i=0; i<n; i++){
				s=sc.nextInt();
				f=sc.nextInt();
				a+=(f-s);
			}
		
			if(a>=t){
				System.out.println("OK");
			}else{
				System.out.println(t-a);
			}
		}
	}
	public static void main(String[]agrs){
		new Main().e();
	}
}

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

using namespace std;

typedef long long ll;

ll solve(ll x, ll y) {
	if (x == y) return 0;
	ll tmp = 1;
	while (tmp <= y) tmp <<= 1;
	tmp >>= 1;
	if (x >= tmp) return solve(x - tmp, y - tmp);
	else {
		y -= tmp;
		if (y + 1 >= x) return (tmp - 1) - (y + 1) + 1;
		ll res = (tmp - 1) - x + 1;
		ll hoge = 1;
		while (hoge <= y) hoge <<= 1;
		x = min(x, hoge) - 1;
		res += max(x - (y + 1) + 1, 0LL);
		return res;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll a, b;
	cin >> a >> b;
	cout << solve(a, b) + b - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ls = []
ans = ('Yes')
for i in range(N):
    ls.append(input())
for i in range(1,N):
    if ls[i] in ls[:i]:
        ans = ('No')
        break
    else:
        if ls[i][0] == ls[i-1][-1]:
            continue
        else:
            ans = ('No')
            break
print(ans)

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

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__);
#else
#define dbg(...) 
#endif

int main() {
	ios_base::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<ll> A(N);
	for(int i=0; i<N; i++){
		cin >> A[i];
	}

	map<ll, int> cnt;
	for(int i=0; i<N; i++){
		cnt[A[i]-i]++;
	}

	ll ans = 0;
	for(int i=0; i<N; i++){
		ans += cnt[-A[i]-i];
		cnt[A[i]-i]--;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 27280
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long
using namespace std;
int main(){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    
    cout<<min(k,a)-max((ll)0,k-a-b);
    return 0;
}

Measured memory_bytes: 3620
import std.stdio, std.algorithm, std.conv, std.array, std.string;

enum DREAM = "dream";
enum DREAM_CNT = DREAM.length;
enum DREAMER = "dreamer";
enum DREAMER_CNT = DREAMER.length;
enum ERASE = "erase";
enum ERASE_CNT = ERASE.length;
enum ERASER = "eraser";
enum ERASER_CNT = ERASER.length;

void main()
{
    auto s = readln.chomp;

    while (!s.empty) {
        if (s.endsWith(DREAMER)) {
            s = s[0..$-DREAMER_CNT];
        } else if (s.endsWith(ERASER)) {
            s = s[0..$-ERASER_CNT];
        } else if (s.endsWith(DREAM)) {
            s = s[0..$-DREAM_CNT];
        } else if (s.endsWith(ERASE)) {
            s = s[0..$-ERASE_CNT];
        } else {
            writeln("NO");
            return;
        }
    }
    writeln("YES");
    return;
}

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

typedef long long ll;
typedef unsigned long long ull;

int main() {
  ll a;
  string s;
  cin >> a;
  cin >> s;

  if (a >= 3200) {
    cout << s << endl;
  } else {
    cout << "red" << endl;
  }
  
  return 0;
}

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

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

    string s,t;
    int i,x=0;
	cin >>s>>t;

	if(s.size() < t.size())
    {
        for(i=0; i<s.size(); i++)
        {
            if(s[i] == t[i])
                x++;
        }
    }
    if(x == s.size())
        cout<<"Yes"<<endl;

    else
        cout<<"No"<<endl;

}


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

using namespace std;

#define all(v)				((v).begin()), ((v).end())
#define allr(v)				((v).rbegin()), ((v).rend())
#define sz(v)				((int)((v).size()))
#define rep(i, v)		for(int i=0;i<sz(v);++i)
#define lp(i, n)		for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)	for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)	for(int i=(j);i>=(int)(n);--i)
#define ll long long
#define pb					push_back
#define fIO ios_base::sync_with_stdio(0);cin.tie(0);

const ll oo = 1e8;
const double pi = 3.1415926535897;


const double EPS = (1e-7);
int dcmp(double x, double y) {	return fabs(x-y) <= EPS ? 0 : x < y ? -1 : 1;	}


typedef vector<int>                vi;
typedef vector<pair<int,int>>      vii;
typedef vector<ll>                 vll;
typedef vector<double>             vd;
typedef vector< vi >               vvi;
typedef vector< vd >               vvd;
typedef vector<string>             vs;

/**
    * PLEASEEE READDD PROBLEEEM CARFULLY ****
    * Always check for OVERFLOW ll vs int
    * Always check for array bounds
    * Check for function return
    * READ OUTPUT SECTION AGAIN!!!
**/

struct edge{
    int from, to, w;

    edge(){}
    edge(int x, int y, int we): from(x), to(y), w(we){}

    bool operator < (const edge &rhs) const{
        return w > rhs.w;
    }

};

const int N = 1e5 + 5;

vi adj[N];
int dis[N][2];

void dfs(int nd, int p, int f) {
    for(auto ch : adj[nd]) {
        if(ch == p) continue;
        dis[ch][f] = dis[nd][f] + 1;
        dfs(ch, nd, f);
    }
}

int main(){
    fIO

    int n, u, v;
    cin >> n >> u >> v;

    int x, y;
    for(int i = 0; i < n - 1; i++) {
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }

    dfs(u, u, 0);
    dfs(v, v, 1);

    int maxi = -1;
    for(int i = 1; i <= n; i++) {
        if(dis[i][0] < dis[i][1]) {
            //cout << i << " " << dis[i][0] << " " << dis[i][1] << "\n";
            int diff = dis[i][1] - dis[i][0];
            maxi = max(maxi, dis[i][0] + (diff - 1));
        }
    }
    cout << maxi;
}








Measured memory_bytes: 12928
#include<bits/stdc++.h>
using namespace std;
#define ll long long int

int main(){
  ll n;
  cin>>n;
  vector<ll> B(n-1);
  for(ll i=0;i<n-1;i++){
   	cin>>B[i]; 
  }
  ll ans = 0;
  ll prev;
  for(ll i=n-2;i>=0;i--){
   	if(i == n-2){
     ans += 2*B[n-2];
      prev = B[n-2];
    }
    else{
     	if(B[i] < prev){
        	ans -= prev;
          	ans += 2*B[i];
          	prev = B[i];
        }
      	else{
        	ans += B[i];
          prev = B[i];
        }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
from heapq import *


n, m = map(int, input().split())
PAIRS = [[-a, -1] for a in map(int, input().split())]
heapify(PAIRS)

for _ in range(m):
    b, c = map(int, input().split())
    heappush(PAIRS, [-c, -b])

answer = 0
for _ in range(n):
    pair = heappop(PAIRS)
    answer += -pair[0]
    pair[1] += 1
    if pair[1] != 0:
        heappush(PAIRS, pair)

print(answer)


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

int main() {
	string s;
	cin >> s;

	int n = s.length();
	vector<int> group;

	int zero = 0;
	int one = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') zero++;
		else one++;

		if (i == s.length() - 1) {
			group.push_back(zero > 0? zero : one);
		} else if (zero > 0 && s[i + 1] == '1') {
			group.push_back(zero);
			zero = 0;
		} else if (one > 0 && s[i + 1] == '0') {
			group.push_back(one);
			one = 0;
		}
	}

	int gsize = (int) group.size();
	
	if (gsize == 1) {
		printf("%d\n", group[0]);
		return 0;
	}

	int tot = 0;

	for (int i = 0; i < gsize; i++) {
		tot += group[i];
	}

	int ans = n;
	int tmp = 0;

	for (int i = 0; i < gsize - 1; i++) {
		tmp += group[i];
		tot -= group[i];

		ans = min(ans, max(n - tmp, n - tot));
	}

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

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

using namespace std;

typedef long long LL;

const int N = 1010;

int n, x;
int a[N];

int main()
{
    int res = 0;
    cin >> n >> x;
    for(int i = 0; i < n; i++)
    {
        cin >> a[i];
        res += a[i];
    }
    sort(a, a + n);
    x -= res;

    cout << n + x / a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, K;

  std::cin >> N >> K;

  std::cout << (N % K == 0 ? 0 : 1) << std::endl;
  
  return 0;
}


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

using namespace std;

//#define int long long
#define FOR(i, j, k) for(int i = j; i < (int)k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF (1 << 30)

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;

const int MOD = 1e9 + 7;
const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
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; }

int p[5000];
int tmp[5000];

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

    int n;
    cin >> n;
    rep(i, n) cin >> p[i];
    int res = INF;
    rep(i, p[0] + 1) {
        int cnt = i;
        memset(tmp, 0, sizeof(tmp));
        tmp[0] = i;
        FOR(j, 1, n) {
            cnt += (p[j - 1] - tmp[j - 1]) * 2;
            tmp[j] += p[j - 1] - tmp[j - 1];
            chmin(tmp[j], p[j]);
        }
        cnt += p[n - 1] - tmp[n - 1];
        chmin(res, cnt);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3244
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:512000000")
#include<utility>
#include<iostream>
#include<fstream>
#include<vector>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<functional>
#include<random>
#include<climits>
#include<queue>
#include<stack>
#include<deque>
#include<bitset>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<cassert>
#include<ccomplex>

//4Head

#define all(x) x.begin(), x.end()
#define mp make_pair
#define X first
#define Y second

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
mt19937_64 gen(time(NULL));

ll const mod = 1e9 + 7;

namespace {
	ll mul(ll a, ll b) {
		ll val = a * b - (ll)((ld)a * b / mod) * mod;
		if (val < 0) val += mod;
		if (val >= mod) val -= mod;
		return val;
	}

	ll poww(ll a, ll b) {
		ll val = 1;
		a %= mod;
		while (b > 0) {
			if (b % 2) val = mul(a, val);
			a = mul(a, a);
			b >>= 1;
		}
		return val % mod;
	}

	ll inv(ll a) {
		return poww(a, mod - 2);
	}
}

ll const maxn = 3e5 + 5;

ll fact[maxn];

ll C(ll n, ll k) {
	return mul(fact[n], inv(mul(fact[k], fact[n - k])));
}

signed main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	fact[0] = 1;
	for (ll i = 1; i < maxn; i++) fact[i] = (i * fact[i - 1]) % mod;
	ll n, k; cin >> n >> k;
	vector<ll>a(n);
	for (ll i = 0; i < n; i++) cin >> a[i];
	sort(all(a));
	ll ans = 0;
	ll ans1 = 0;
	for (ll i = k - 1; i < n; i++) {
		(ans += mul(a[i], C(i, k - 1))) %= mod;
	}
	reverse(all(a));
	for (ll i = k - 1; i < n; i++) {
		(ans1 += mul(a[i], C(i, k - 1))) %= mod;
	}
	ans -= ans1;
	ans %= mod;
	if (ans < 0) ans += mod;
	cout << ans << endl;

	return 0;
}

/*
3
0 1
3 0
1 0
*/

Measured memory_bytes: 3456
// https://atcoder.jp/contests/abc169/tasks/abc169_d
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
  ll N;
  cin >> N;
  ll ans = 0;

  for (ll i = 2; i * i <= N; i++) {
    ll e = 0;
    while (N % i == 0) {
      N /= i;
      e++;
    }

    ll cnt = 1;
    while (cnt <= e) {
      ans++;
      e -= cnt;
      cnt++;
    }
  }

  // ~√N までの数で割っても1にならない(つまり√Nより大きな素数)の場合
  if (N != 1) ans++;
  cout << ans;
}

Measured memory_bytes: 3620
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

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

#define INF 1000000000

int solve2(int xy){
  int y=0;
  int ans=INF;
  while(y*y<=xy){
    ans=min(ans, y + xy-y*y);
    y++;
  }
  return ans;
}

void solve(int e){
  int z=0;
  int ans=INF;
  while(z*z*z<=e){
    ans = min(ans, z+solve2(e-z*z*z));
    z++;
  }
  cout << ans << endl;
}

int main(){
  while(true){
    int e;
    scanf("%d", &e);
    if(e==0) break;
    solve(e);
  }
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (abs(C-A)<=D || (abs(B-A) <=D && abs (C - B) <= D)){
  cout << "Yes";
  }else{
  cout << "No";
  }
}


Measured memory_bytes: 256
# util functions

# debug
$debugFlag = ( ARGV[0] != nil )
p "==== DEBUG MODE ====" if $debugFlag

# input
inputs = []
lc = 0
while l = $stdin.gets do
  if false
    inputs << l.chomp.split(" ").map(&:to_s)
  else
    inputs << (l.chomp.split(" ").map(&:to_i) << (lc-1)) 
  end
  lc += 1
end

# input check
if $debugFlag
  p "--- INPUT (begin) ---"
  inputs.each do |l_i|
    p l_i
  end
  p "--- INPUT (end) ---"
  print "\n"
end

city_year_list = inputs[1..-1]
p city_year_list if $debugFlag

# body
# categorized = []
# city_year_list.each do |e_i|
#   if categorized[e_i[0]] == nil
#     categorized[e_i[0]] = [e_i[1]]
#   else
#     categorized[e_i[0]] << e_i[1]
#   end
# end

# categorized.each do |c_i|
#   c_i.sort! if c_i
# end

# p categorized if $debugFlag

# city_year_list.each do |c_i|
#   printf("%06d%06d\n", c_i[0], categorized[c_i[0]].index(c_i[1]) + 1)
# end

h = {}
ans = []
city_year_list.sort_by{ |p, y, i| y }.each do |p, y, i|
  if h[p] == nil
    h[p] = 1
  else
    h[p] += 1
  end
  ans[i] = sprintf("%06d%06d\n", p, h[p])
end

puts ans

Measured memory_bytes: 24788
#include <cstdio>
#include <queue>
#include <utility>
#include <map>
using namespace std;
typedef pair<unsigned int,int> P;
#define AT(X,Y)(((X)>>((Y)*3))&7)
unsigned int F(unsigned int x,int y,int z) {
	unsigned int tmp=0;
	for(int i=0;i<8;i++) if(i!=y&&i!=(y+z))tmp|=(AT(x,i)<<(i*3));
	tmp|=(AT(x,y)<<(3*(y+z)));
	tmp|=(AT(x,y+z)<<(3*y));
	return tmp;
}
int main() {
	unsigned int start=076543210;
	map<unsigned,int> M;
	M[start]=0;
	queue<P> Q;
	Q.push(P(start,0));
	while(!Q.empty()) {
		P p=Q.front();Q.pop();
		int zero;
		for(zero=0;AT(p.first,zero);zero++);
		if(zero%4!=0) {
			unsigned int tmp=F(p.first,zero,-1);
			if(M.find(tmp)==M.end()) { M[tmp]=p.second+1; Q.push(P(tmp,p.second+1)); }
		}
		if(zero%4!=3) {
			unsigned int tmp=F(p.first,zero,1);
			if(M.find(tmp)==M.end()) { M[tmp]=p.second+1; Q.push(P(tmp,p.second+1)); }
		}
		if(zero<=3) {
			unsigned int tmp=F(p.first,zero,4);
			if(M.find(tmp)==M.end()) { M[tmp]=p.second+1; Q.push(P(tmp,p.second+1)); }
		}else {
			unsigned int tmp=F(p.first,zero,-4);
			if(M.find(tmp)==M.end()) { M[tmp]=p.second+1; Q.push(P(tmp,p.second+1)); }
		}
	}
	int n,m;
	while(scanf("%d",&n)!=EOF) {
		m=n;
		for(int i=1;i<8;i++) {
			scanf("%d",&n);
			m|=((n)<<(i*3));
		}
		printf("%d\n",M[m]);
	}
}

Measured memory_bytes: 2000
#include<stdio.h>

void swap(int *a, int *b){
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int array[100];

int selection(int *A, int N){
    int i,j;
    int minj;
    int change = 0;
    for(i=0;i<N;i++){
        minj = i;
        for(j=i;j<N;j++){
            if(A[minj] > A[j]) minj = j;
        }
        if(minj != i){
            change++;
            swap(&A[minj], &A[i]);
        }
    }
    return change;
}

int main(void){
    int n;
    int i;
    int ans;
    scanf("%d", &n);
    
    for(i=0;i<n;i++){
        scanf("%d", &array[i]);
    }
    
    ans = selection(array, n);
    
    for(i=0;i<n;i++){
        if(i < n-1) printf("%d ", array[i]);
        else printf("%d\n", array[i]);
    }
    printf("%d\n", ans);
    
    return 0;
}

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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9
#define LINF (ll)4e18
#define MOD (int)(1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define PI 3.1415926535898
#define NP(v) next_permutation(v.begin(),v.end())

//------------------------------------------------------

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

    ll csum[n + 1];
    csum[0] = 0;

    rep2(i, n) {
        ll a;
        cin >> a;
        csum[i] = csum[i - 1] + a;
    }

    ll Min = LINF;

    rep2(i, n - 1) {
        ll x = csum[i];
        ll y = csum[n] - csum[i];
        Min = min(Min, abs(x - y));
    }

    cout << Min << endl;

    return 0;
}



Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<queue>

using namespace std;

int partition(vector<pair<int, char> > &A, int p, int r){
	int x = A[r].first;
	int i = p - 1;
	for (int j = p; j < r; j++){
		if (A[j].first <= x) swap(A[++i], A[j]);
	}
	swap(A[++i], A[r]);
	return i;
}

void quicksort(vector<pair<int, char> > &A, int p, int r){
	if (p < r){
		int q = partition(A, p, r);
		quicksort(A, p, q - 1);
		quicksort(A, q + 1, r);
	}
}

void solve(){
	int n;
	bool stable = true;
	cin >> n;
	map<int, queue<char> > que;
	vector<int> j(12, 0);
	vector<pair<int, char> > A(n);
	for (int i = 0; i < n; i++) {
		cin >> A[i].second >> A[i].first;
		que[A[i].first].push(A[i].second);
	}
	quicksort(A, 0, n - 1);
	for (int i = 0; i < n; i++) {
		if (que[A[i].first].front() != A[i].second) stable = false;
		else que[A[i].first].pop();
	}
	if (stable) cout << "Stable" << endl;
	else cout << "Not stable" << endl;
	for (int i = 0; i < n; i++){
		cout << A[i].second << " " << A[i].first << endl;
	}
	//cout << endl;
}

int main(){
	solve();
}

Measured memory_bytes: 21496
import sys, math
from functools import lru_cache
from collections import deque
sys.setrecursionlimit(10**9)
MOD = 10**9+7

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def i2(n):
    tmp = [list(mi()) for i in range(n)]
    return [list(i) for i in zip(*tmp)]

S = input()
i = 1
r = len(S)
while True:
    if i >= len(S):
        break
    if S[i] == S[i-1]:
        r -= 1
        i += 2
    i += 1

print(r)

Measured memory_bytes: 9544
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define REP(i,x,n) for(int i = (x); i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);

int main(void)
{
    ll n, m, ans=0;
    cin >> n >> m;
    ans += min(n, m/2);
    if(m - 2*n >= 0) m -= n*2;
    else m = 0;
    ans += m/4;
    cout << ans << endl;
    return 0;
}


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

int n, m, ans;
vector<int> adj[57];
bool vis[57];
bool curvis[57];
int curpos, curx;

void dfs2(int pos)
{
    curvis[pos] = 1;
    for (auto x : adj[pos]) {
        if (pos == curpos && x == curx) continue;
        if (!curvis[x]) {
            dfs2(x);
        }
    }
}

void dfs(int pos)
{
    vis[pos] = 1;
    for (auto x : adj[pos]) {
        if (!vis[x]) {
            curpos = pos, curx = x;
            dfs2(1);
            bool flg = true;
            for (int i = 1; i <= n; i++) {
                if (!curvis[i]) flg = false;
                curvis[i] = 0;
            }
            if (!flg) ans++;
            dfs(x);
        }
    }
}


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

    int u, v;
    for (int i = 1; i <= m; i++) {
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    dfs(1);

    cout << ans;
}


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

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if( x-r >= 0 && x+r <= W && y-r >= 0 && y+r <= H){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3084
#include <iostream>
//#include <fstream.h>
//#include <cstring>
using namespace std;

int main() {
  
  int n[10];
  int temp,i,j;

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

  for(i=0;i<9;i++) {
    for(j=i+1;j<10;j++) {
      if(n[i]<n[j]) {
	temp=n[i];
	n[i]=n[j];
	n[j]=temp;
      }
    }
  }

  //cout << "\n";
  cout << n[0] << "\n";
  cout << n[1] << "\n";
  cout << n[2] << "\n";

  return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    vector<int> a(4);
    for (int i = 0; i < 4; ++i)
        a[i] = nap[i] - '0';
    for (int i = 0; i < (1 << 3); ++i)
    {
        int wyn = a[0];
        for (int j = 0; j < 3; ++j)
        {
            if ((i & (1 << j)) > 0)
                wyn += a[j + 1];
            else
                wyn -= a[j + 1];
        }
        if (wyn == 7)
        {
            cout << a[0];
            for (int j = 0; j < 3; ++j)
            {
                if ((i & (1 << j)) > 0)
                    cout << "+" << a[j + 1];
                else
                    cout << "-" << a[j + 1];
            }
            cout << "=7";
            return 0;
        }
    }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;
double x[100],y[100];
double px[10000],py[10000];
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<a;i++)scanf("%lf,%lf",x+i,y+i);
		int now=0;
		for(int i=0;i<a;i++){
			for(int j=i+1;j<a;j++){
				if((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j])<4.0000001){
					double d=sqrt((x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]));
					double mx=(x[i]+x[j])/2;
					double my=(y[i]+y[j])/2;
					double s=sqrt(1-d*d/4);
					double theta=atan((y[i]-y[j])/(x[i]-x[j]));
					px[now]=mx-sin(theta)*s;
					py[now++]=my+cos(theta)*s;
					px[now]=mx+sin(theta)*s;
					py[now++]=my-cos(theta)*s;
				}
			}
		}
		int ret=1;
		for(int i=0;i<now;i++){
			int k=0;
			for(int j=0;j<a;j++)if((px[i]-x[j])*(px[i]-x[j])+(py[i]-y[j])*(py[i]-y[j])<1.0000001)k++;
			ret=max(ret,k);
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 0
#define _CRT_SECURE_NO_WARNINGS

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int H, W, N;
int sr, sc;
string S[2];

int main() {
	cin >> H >> W >> N;
	cin >> sr >> sc;
	--sr;
	--sc;
	cin >> S[0];
	cin >> S[1];
	int i1 = 0, i2 = H, j1 = 0, j2 = W;
	for (int x = N - 1; x >= 0; --x) {
		switch (S[1][x]) {
		case 'L':
			j2++;
			j2 = min(j2, W);
			break;
		case 'R':
			j1--;
			j1 = max(j1, 0);
			break;
		case 'U':
			i2++;
			i2 = min(i2, H);
			break;
		case 'D':
			i1--;
			i1 = max(i1, 0);
			break;
		}
		switch (S[0][x]) {
		case 'R':
			j2--;
			j2 = min(j2, W);
			break;
		case 'L':
			j1++;
			j1 = max(j1, 0);
			break;
		case 'D':
			i2--;
			i2 = min(i2, H);
			break;
		case 'U':
			i1++;
			i1 = max(i1, 0);
			break;
		}
		if (i1 == i2 || j1 == j2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	if (i1 <= sr && sr < i2 && j1 <= sc && sc < j2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 776
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int N;
    cin >> N;
    N = N % 10;
    if (N == 3) cout << "bon" << endl;
    else if ( N < 2 || N == 6 || N == 8) cout << "pon" << endl;
    else cout << "hon" << endl;

    return 0;
}


Measured memory_bytes: 3044
#include<bits/stdc++.h>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define inf 2000000000
#define infLL 2000000000000000000
#define MAX 500005
#define mx 10004
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(t) printf("Case %d: ", t)
#define pii pair<int, int>
#define MOD 1000000007
#define mod 1000000009
#define PI acos(-1.0)
#define eps 1e-9
#define mem(a, b) memset(a, b, sizeof(a))
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

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

inline int Set(int N, int pos){return N=N | (1<<pos);}
inline int Reset(int N, int pos){return N=N & ~(1<<pos);}
inline bool Check(int N, int pos){return (bool)(N & (1<<pos));}

inline void normal(ll &a) { a %= mod; (a < 0) && (a += mod); }
inline ll modMul(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a * b) % mod; }
inline ll modAdd(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); return (a + b) % mod; }
inline ll modSub(ll a, ll b) { a %= mod, b %= mod; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while (p) { if (p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, mod - 2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll fast_exp(ll x, ll n, ll m)
{
    ll res = 1;
    while(n>0)
    {
        if(n%2==1)
            res = (res * x) % m;
        x = (x * x) % m;
        n/=2;
    }
    return res%m;
}

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

clock_t t_Start;
void Start()
{
    t_Start = clock();
}
void End()
{
    double Time = (double)(clock()-t_Start)/CLOCKS_PER_SEC;
    error(Time);
}

typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>orderedSet1;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
    //Start();

    int n, m;
    cin>>n>>m;
    int ans[5];
    memset(ans, -1, sizeof(ans));
    for(int i = 0; i < m; i++)
    {
        int s, c;
        cin>>s>>c;
        if(ans[s]==-1)
        {
            ans[s] = c;
        }
        else if(ans[s]!=c)
        {
            cout<<"-1"<<endl;
            return 0;
        }
    }
    if(n!=1 && ans[1]==0)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    for(int i = 1; i <= n; i++)
    {
        if(ans[i]==-1 && i==1 && n > 1)
            cout<<1;
        else if(ans[i]==-1)
            cout<<0;
        else
            cout<<ans[i];
    }

    //End();
    return 0;
}


Measured memory_bytes: 256