akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
# define ll long long
# define endl "\n"
# define str string
# define vll vector<ll>
# define pb push_back
# define mll map<ll,ll>
# define mp make_pair
# define ff first
# define ss second
# define pll pair<ll,ll>
# define f(x,y) for(int x=0;x<y;x++)
int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    str s;
    cin>>s;
    ll m=0;
    ll k=0;
    f(i,s.length()){
        if(s[i]=='R'){
            k++;
        }
        else{
            m=max(m,k);
            k=0;
        }
    }
    if(k>0){
        m=max(k,m);
    }
    cout<<m<<endl;
    return 0;
}

Measured memory_bytes: 3644
import bisect
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

a.sort()
c.sort()
ans = 0
for i in range(n):
    over = bisect.bisect_left(a, b[i])
    under = n - bisect.bisect_right(c, b[i])
    ans += over * under

print(ans)

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


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


int main() 
{
    int n;
    cin >> n;
    vector<int> p(n);
    vector<int> q(n);
    rep(i, n) cin >> p[i];
    rep(i, n) cin >> q[i];
    vector<int> v(n);
    rep(i, n) v[i] = i + 1;
    map<vector<int>, int> mp;
    do
    {
        mp[v] = mp.size();
    } while (next_permutation(v.begin(), v.end()));

    int ans;
    ans = abs(mp[p] - mp[q]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 5248
import sys
S = input()

ans = 0

for i in range(2 ** 3):
    s = S[0]
    for j in range(3):
        if ((i >> j) & 1):
            s += "+"
        else:
            s += "-"
        s += S[j + 1]
    if eval(s) == 7:
        print(s + "=7")
        sys.exit(0)

Measured memory_bytes: 3060
def resolve():
    H, W, A, B = map(int, input().split())
    G = [[0] * W for _ in range(H)]

    for _ in range(B):
        print('0' * A + '1' * (W - A))
    for _ in range(H - B):
        print('1' * A + '0' * (W - A))


if __name__ == "__main__":
    resolve()

Measured memory_bytes: 16512
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <climits>
#include <memory>
#include <sstream>
#include <iomanip>

using namespace std;

int main() {

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

	int a, b, k;
	cin >> a >> b >> k;
	int j = 0;
	for (int i = 100; ; i--) {
		if (a%i == 0 && b%i == 0) {
			j++;
		}
		if (j == k) {
			cout << i << endl;
			break;
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#define debug(x) cerr << __LINE__ << ' ' << #x << ':' << x << '\n'
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000010;
constexpr ll INF = 1000000000000000010;
constexpr ld eps = 1e-12;
constexpr ld pi = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

class unionfind {
	vector<int> par;
	vector<int> sz;
public:
	unionfind(int n) {
		par = vector<int>(n);
		for (int i = 0; i < n; i++) par[i] = i;
		sz = vector<int>(n, 1);
	}
	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}
	int si(int x) { return sz[find(x)]; }
	bool same(int x, int y) { return find(x) == find(y); }
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return;
		if (sz[x] < sz[y]) {
			par[x] = y;
			sz[y] += sz[x];
		}
		else {
			par[y] = x;
			sz[x] += sz[y];
		}
	}
};

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

	int n, m;
	cin >> n >> m;
	unionfind uni(n);
	rep(i, m) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		uni.unite(u, v);
	}
	int ans = 0;
	rep(i, n) chmax(ans, uni.si(i));
	cout << ans << '\n';
}


Measured memory_bytes: 4780
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let a=read::<usize>();
    let _=read::<usize>();
    for _ in 0..a{
        let s=read::<String>();
        println!("{}\n{}",s,s);
    }
}

Measured memory_bytes: 4352
for e in iter(input,'0'):
 a=list(tuple(map(int,input().split())) for _ in range(int(e)))
 s,t=a[0]
 b={tuple(map(int,input().split())) for _ in range(int(input()))}
 for x,y in b:
  for u,v in a[1:]:
   if(x+u-s,y+v-t)not in b:break
  else:print(x-s,y-t);break


Measured memory_bytes: 6048
//ex9_1
//TKC001

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 10

//data[SIZE-1]がstackの底、data[0]が天井、topはstackの一番上の要素の位置
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;
//stackの初期化、何もないっていない状態にする。
void init_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}
//番号が若い方が上なので、stackに要素が追加されるとtopが小さくなる
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//配列dataの一番番号の若いやつをstackから外す。
void pop(stack *stk){
    if(stk->count <= 0){
        //何もしないけど気持ち悪いから書いた
    }
    else{
        stk->top++;
        stk->count--;
    }
}
//dataの中身を後ろからcount個出力=stackの内容をすべて出力
void print_stack(stack *stk){
    int i;
    for(i = SIZE-1; i > SIZE-1-stk->count; i--){
        printf("%c", stk->data[i]);
    }
}

int main(void){
    int i;
    char str[SIZE+1];
    stack stk;
    //stackの初期化
    init_stack(&stk);
    //入力
    scanf("%s", str);
    //strの要素に応じてpushとdeleteを決める
    for (i = 0; i < strlen(str); i++){
        if(str[i] == 'B'){
            pop(&stk);
        }
        else if(str[i] == '0'){
            push(&stk, '0');
        }else{
            push(&stk, '1');
        }
    }
    //出力
    print_stack(&stk);
    

    return 0;
}

Measured memory_bytes: 1612
// tzl ak IOI! 
 
#include<bits/stdc++.h>
 
#define HEAP priority_queue
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n) - 1; i >= 0 ; --i)
#define forn(i, l, r) for(int i = (l); i <= (r); ++i)
#define nrof(i, r, l) for(int i = (r); i >= (l); --i)
#define FOR(a, b) for(auto (a): (b))
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define X first
#define Y second
#define eps 1e-6
#define pi 3.1415926535897932384626433832795
#define SZ(x) (int)x.size()
#define ALL(x) x.begin(), x.end()
#define FILL(a, b) memset((a), (b), sizeof((a)))
#define MCPY(a, b) memcpy((a), (b), sizeof((b)))
 
using namespace std;
 
typedef long long LL;
typedef double flt;
typedef vector<int> vi;
typedef vector<LL> vl;
typedef pair<int,int> pii;
typedef pair<int,LL> pil;
typedef pair<LL,int> pli;
typedef pair<LL,LL> pll;
typedef vector<pil> vil;
typedef vector<pii> vii;
typedef vector<pli> vli;
typedef vector<pll> vll;
 
const int iinf = 1e9 + 7;
const LL linf = 1ll << 60;
const flt dinf = 1e60;
 
template <typename T>
inline void scf(T &x)
{
	bool f = 0; x = 0; char c = getchar();
	while((c < '0' || c > '9') && c != '-') c = getchar();
	if(c == '-') { f = 1; c = getchar(); }
	while(c >= '0' && c <= '9') { x = x * 10 + c - '0'; c = getchar(); }
	if(f) x = -x; return;
}
 
template <typename T1, typename T2>
void scf(T1 &x, T2 &y) { scf(x); return scf(y); }
 
template <typename T1, typename T2, typename T3>
void scf(T1 &x, T2 &y, T3 &z) { scf(x); scf(y); return scf(z); }
 
template <typename T1, typename T2, typename T3, typename T4>
void scf(T1 &x, T2 &y, T3 &z, T4 &w) { scf(x); scf(y); scf(z); return scf(w); }
 
inline char mygetchar(){ char c = getchar(); while(c == ' ' || c == '\n') c = getchar(); return c; }
 
template <typename T>
void chkmax(T &x, const T &y){ if(y > x) x = y; return; }
 
template <typename T>
void chkmin(T &x, const T &y){ if(y < x) x = y; return; }
 
#ifdef ONLINE_JUDGE
#define debug(x,c) ;
#else
#define DEBUG
#define debug(x,c) cerr<<#x<<"="<<x<<c;
#endif
 
//---------------------------head----------------------------
 
const int N = 2e5 + 100;
 
int n, m;
int par[N];
int deg[N];
 
int F(int u){ return u == par[u] ? u : par[u] = F(par[u]); }
void UN(int u, int v){ debug(u, '\t') debug(v, '\n') par[F(u)] = F(v); }
 
void TZL()
{
	scf(n, m);
	rep(i, n + n) par[i] = i;
	rep(i, m)
	{
		int u, v;
		scf(u, v);
		u--; v--;
		deg[u]++;
		deg[v]++;
		u <<= 1;
		v <<= 1;
		UN(u, v | 1);
		UN(u | 1, v);
	}
	return;
}
 
void RANK1()
{
	LL cnt0, cnt1, ans;
	cnt0 = cnt1 = 0;
	rep(i, n + n) if(deg[i >> 1] && F(i) == i)
	{
		if(F(i) == F(i ^ 1)) cnt1++;
		else cnt0++;
	}
	ans = cnt0 * cnt0 / 2 + cnt1 * cnt1 + cnt0 * cnt1;
	debug(ans, '\n')
	ans += 1ll * n * n;
	for(int i = n - 1; i >= 0; --i) if(!deg[i]) n--;
	ans -= 1ll * n * n;
	printf("%lld\n", ans);
	return;
}
 
#define tzl int
#define ak main
#define IOI ()
tzl ak IOI
{
#undef tzl
#undef ak
#undef IOI
 
	TZL();
	RANK1();
 
#define tzl return
#define caisi 0
#define myy ;
	tzl caisi myy
#undef tzl
#undef caisi
#undef myy
}

Measured memory_bytes: 1408
//
//  main.c
//  b
//
//  Created by ティツ按佚・ツアツアテゥツ?古ヲツィツケ on 2016/05/18.
//  Copyright テつゥ 2016テ・ツケツエ ティツ按佚・ツアツアテゥツ?古ヲツィツケ. All rights reserved.
//

#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int a, b, c;
    scanf("%d%d", &a, &b);
    c = a * b;
    printf("%d\n", c);
    return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define ll long long
#define _69e27 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int N = 1e5+5, M=1e5+5, oo=0x3f3f3f3f, mod = 1e9+7;

int n, dp[N], arr[N];
int main()
{
    _69e27
    memset(dp, oo, sizeof dp);
    dp[0] = 0;
    cin >> n;
    for(int i=0; i<n; i++)
        cin >> arr[i];
    for(int i=0; i<n; i++){
        for(int j=i+1; j<=i+2; j++){
            if(j < n)
                dp[j]=min(dp[j], dp[i]+abs(arr[i]-arr[j]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

int main()
{
	ll A, B, N;
	cin >> A >> B >> N;

	ll x = min(N, B-1);

	cout << (A * x) / B - A * (x / B) << endl;
}

Measured memory_bytes: 3624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;
using static MyIO;
using static MyUtil;

public class A
{
	public static void Main() => (new Solver()).Solve();
}

public class Solver
{
	public void Solve()
	{
		var S = GetString();
		WriteLine(S.Contains("A") && S.Contains("B") ? "Yes" : "No");
	}
}

public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt() => int.Parse(getArg());
	public static long GetLong() => long.Parse(getArg());
	public static double GetDouble() => double.Parse(getArg());
	public static decimal GetDecimal() => decimal.Parse(getArg());
	public static string GetString() => getArg();
	public static char GetChar() => getArg()[0];
	public static int[] GetInts(long N) => Enumerable.Range(0, (int)N).Select(_ => GetInt()).ToArray();
	public static long[] GetLongs(long N) => Enumerable.Range(0, (int)N).Select(_ => GetLong()).ToArray();
	public static double[] GetDoubles(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDouble()).ToArray();
	public static decimal[] GetDecimals(long N) => Enumerable.Range(0, (int)N).Select(_ => GetDecimal()).ToArray();
	public static string[] GetStrings(long N) => Enumerable.Range(0, (int)N).Select(_ => GetString()).ToArray();
}

public static class MyUtil
{
	public static void chmax<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) < 0)
			x = y;
	}

	public static void chmin<T>(ref T x, T y) where T : IComparable<T>
	{
		if(x.CompareTo(y) > 0)
			x = y;
	}

	public static void swap<T>(ref T x, ref T y)
	{
		T tmp = x;
		x = y;
		y = tmp;
	}
}

Measured memory_bytes: 11092
import sys

if __name__ == "__main__":
    args = sys.stdin.read().split()
    N, A, B = tuple(map(int, args))

    sum_of_numbers_satisfying_conditions = 0
    for n in range(1, N + 1):
        sum_of_digits = sum(list(map(int, list(str(n)))))
        if A <= sum_of_digits <= B:
            sum_of_numbers_satisfying_conditions += n

    print(sum_of_numbers_satisfying_conditions)


Measured memory_bytes: 3060
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;typedef vector<ll> vll;
#define fill(a) memset(a, 0, sizeof (a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0; i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define each(it,s) for(auto it = s.begin(); it != s.end(); ++it)
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define _ios ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const int INF = 1e9 + 10;
const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int maxn = 2000100;

int main(){
        _ios;
        ll n; cin >> n;
        vll a(n);
        map<ll,ll>mp;
        rep(i,n){
            cin >> a[i];
            mp[a[i]]++;
        }
        ll ans = 0;
        for(auto x: mp){
            ll res  = x.ss;
            ans+=(res*(res-1)/2);
        }
        rep(i,n){
            cout<<ans-mp[a[i]]+1<<endl;
        }


return 0;
}








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

#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPL(i,a,n) for(ll i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define SORTVG(v) sort(v.begin(),v.end(),greater<>())
#define SORTV(v) sort(v.begin(),v.end())
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef tuple<int,int,bool> Tb;
typedef pair<int,int> Pii;
typedef vector<int> Vi;

template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}
template<class T> void YesNo(T& a) {if(a){cout << "Yes" << ENT;}else{cout << "No" << ENT;}}
template<class T> void YESNO(T& a) {if(a){cout << "YES" << ENT;}else{cout << "NO" << ENT;}}
template<class T> void AorB(T& a, string A,string B) {if(a){cout << A << ENT;}else{cout << B << ENT;}}


int atcoder(){
    int n,a,b;
    cin>>n>>a>>b;
  	cout<<(n-a+1)*(n-b+1)<<ENT;
    return 0;
}


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



Measured memory_bytes: 256
#include<stdio.h>
#define mod 1000000007
long long h,w,dp[1005][1005];
long long f(long long x,long long y)
{
	if(dp[x][y]!=-1)return dp[x][y]%mod;
	else if(x==h-1&&y==w-1)return 1;
	else if(x>=h||y>=w)return 0;
	else return dp[x][y]=(f(x+1,y)%mod+f(x,y+1)%mod)%mod;
}
int main()
{
	scanf("%Ld %Ld",&h,&w);
	long long a[1005][1005];
	char c[1005];
	for(int i=0;i<h;i++)
	{
			scanf("%s",c);
		for(int j=0;j<w;j++)
		{
			dp[i][j]=-1;
			if(c[j]=='.')a[i][j]=1;
			else
			{
				dp[i][j]=0;
			}
		}
	}
	printf("%Ld\n",f(0,0));
	return 0;
}

			
	


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

using namespace std;

/* g++ -g -fsanitize=address -lasan -std=c++11 -Dfoo_ */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    while (cin >> s) {
        const int n = s.size();
        int i = 0; VI ans(n);
        while (i < n) {
            int j = i;
            while (j < n && s[j] == 'R')
                j++;
            int k = j;
            while (k < n && s[k] == 'L')
                k++;
            const int x = j-i;
            const int y = k-j;
            int a = (x+y)/2, b = x+y-a;
            if (a > b)
                swap(a,b);
            if (x > y) {
                if (x&1)
                    ans[j-1] = b, ans[j] = a;
                else
                    ans[j-1] = a, ans[j] = b;
            }
            else {
                if (y&1)
                    ans[j-1] = a, ans[j] = b;
                else
                    ans[j-1] = b, ans[j] = a;
            }
            i = k;
        }
        FOR(i,0,n)
            cout << ans[i] << ' ';
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 1104
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
  vector<int> a;
  int n,num;

  cin >> n;

  for (int i = 0; i < n; i++) {
    cin >> num;
    a.push_back(num);
    //cout << num << endl;
  }

  int q,b,e;
  cin >> q;
  for (int i = 0; i < q; i++) {
    cin >> b;
    cin >> e;

    auto itr_b = a.begin();
    auto itr_e = a.begin();

    for (int i=0;i<b;i++){
      itr_b++;
    }
    for (int i=0;i<e;i++){
      itr_e++;
    }
    reverse(itr_b, itr_e++);
  }
  auto itr = a.begin();
  for (itr = a.begin(); itr!=a.end(); ++itr) {
    if (itr!=--a.end()){
      printf("%d ",*itr);
    }else{
      printf("%d\n",*itr);
    }
  }
return 0;
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;


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

  string S;
  cin >> S;

  ll flag = 0;

  for (ll i = 0; i <= (S.size()-1)/2; i++) {
    if(!(S.at(i)==S.at(S.size()-1-i))){
      flag = 1;
    }
  }
      string S1,      S2;

  for (ll i = 0; i < (S.size()-1)/2; i++) {
    S1+=S.at(i);
  }
  S2 = S.substr((S.size() + 3) / 2 - 1);

  //cout << S1 << endl;
  //cout << S2 << endl;

  for (ll i = 0; i <= (S1.size() - 1) / 2; i++)
  {
    if (!(S1.at(i) == S1.at(S1.size() - 1 - i)))
    {
      flag = 1;
    }
  }
  for (ll i = 0; i <= (S2.size() - 1) / 2; i++)
  {
    if (!(S2.at(i) == S2.at(S2.size() - 1 - i)))
    {
      flag = 1;
    }
  }

  if(flag==1){
    cout << "No" << endl;
  }
  else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
/**
*    created: 24.06.2020 01:43:17
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

int ctoi(char c) {
	
}

signed main() {

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

    string s;
    cin >> s;
    auto ctoi = [&] (char c) {
        if (c >= '0' && c <= '9') return c - '0';
	    return -1;
    };
    int a = ctoi(s[0]);
    int b = ctoi(s[1]);
    int c = ctoi(s[2]);
    int d = ctoi(s[3]);

    for (int bit = 0; bit < (1 << 3); bit++) {
        int sum = a;
        string str = to_string(a);
        if ((bit >> 0) & 1) {
            sum += b;
            str.insert(1,"+");
        }
        else {
            sum -= b;
            str.insert(1,"-");
        }
        str.insert(2,to_string(b));
        if ((bit >> 1) & 1) {
            sum += c;
            str.insert(3,"+");
        }
        else {
            sum -= c;
            str.insert(3,"-");
        }
        str.insert(4,to_string(c));
        if ((bit >> 2) & 1) {
            sum += d;
            str.insert(5,"+");
        }
        else {
            sum -= d;
            str.insert(5,"-");
        }
        str.insert(6,to_string(d));
        if (sum != 7) continue;
        str.insert(7,"=7");
        cout << str << endl;
        return 0;
    }
    return 0;
}

Measured memory_bytes: 3724
S = input()
keyence = "keyence"
if S.split()[0] == keyence:
    print("YES")
for idx, (s, k)  in enumerate(zip(S, keyence)):
    if s==k:
        continue
    else:
        nokori = keyence[idx:]
        if S[-len(nokori):] == nokori:
            print("YES")
            break
        else:
            print("NO")
            break

Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <valarray>
#include <vector>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define fir first
#define foreach(it,X) for(__typeof((X).begin()) it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)x.size())

using namespace std;

struct timer{
	time_t start;
	timer(){start=clock();}
	~timer(){cerr<<1.*(clock()-start)/CLOCKS_PER_SEC<<" secs"<<endl;}
};

typedef istringstream iss;
typedef long long ll;
typedef pair<int,int> pi;
typedef stringstream sst;
typedef vector<int> vi;

int V,E;
string g[1010];
int odd,even;
int used[1010];

int dfs(int cur){
	int res=1;
	used[cur]=1;
	rep(i,V)if(g[cur][i]=='Y' && !used[i]){
		res+=dfs(i);
	}
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>V;
	rep(i,V)cin>>g[i];
	rep(i,V)rep(j,V)E+= g[i][j]=='Y';
	E/=2;
	rep(i,V)if(!used[i]){
		if(dfs(i)%2==1)odd++;
		else even++;
	}
	if(V%4==1){
		cout<<(E%2==1 ? "Taro":"Hanako")<<endl;
	}
	else if(V%4==3){
		cout<<(E%2==0 ? "Taro":"Hanako")<<endl;
	}
	else{
		int taro,hanako;
		if(V%4==0)taro=1 ^ (E%2);
		if(V%4==2)taro=0 ^ (E%2);
		hanako=taro^1;
		while(odd+even>2 && odd>0){
			if(taro==1){
				if(even>0)even--;
				else odd-=2,even++;
			}else{
				odd-=2,even++;
			}
			if(odd+even==2 || odd==0)break;
			if(hanako==1){
				if(even>0)even--;
				else odd-=2,even++;
			}else{
				odd-=2,even++;
			}
		}
		if(taro==1){
			cout<<(odd==2 ? "Taro":"Hanako")<<endl;
		}
		else{
			cout<<(odd==0 ? "Taro":"Hanako")<<endl;
		}
	}
}

Measured memory_bytes: 2268
#include<iostream>
using namespace std;
#define int64 long long int
int64 n,s;
bool chk(int64 n,int64 i,int64 s){
	int64 tot=0,x=n;
	while(x){
		tot+=x%i;
		x/=i;
	}
	return tot==s;
}
int64 calc(int64 n,int64 s){
	if(s>n)return -1;
	if(s==n)return n+1;
	for(int64 i=2; i*i<=n; i++){
		if(chk(n,i,s))return i;
	}
	int64 now = n-s, res = -1;
	for(int64 i=1; i*i<=now; i++)
		if(now%i==0){
			int64 x = i+1;
			if(chk(n,x,s)){
				if(res==-1 || res>x)
					res=x;
			}
			x=now/i+1;
			if(chk(n,x,s)){
				if(res==-1 || res>x)
					res=x;
			}
		}
	return res;
}
int main(){
	cin>>n>>s;
	cout<<calc(n,s)<<endl;
	return 0;
}

Measured memory_bytes: 384
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True  and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
a = inl()
b = [(a[i],i) for i in range(n)]
b.sort(reverse=True)
ddprint(b)
d = [[0]*(n+1) for i in range(n+1)]
for i in range(n):
    v,j = b[i]
    ddprint(f"i {i} v {v} j {j}")
    d[i+1][0] = d[i][0] + v*abs(n-1-i-j) # all to right
    d[i+1][i+1] = d[i][i] + v*abs(j-i) # all to left
    for k in range(1,i+1):
        v1 = d[i][k-1]+v*abs(j-k+1)  # k-1 infants on left
        v2 =  d[i][k]+v*abs(n-1-i+k-j) # i-k infants on right
        ddprint(f"k {k} v1 {v1} v2 {v2} d1 {d[i][k-1]} d0 {d[i][k]} x1 {k-i} x2 {n-1-i+k-j}")
        d[i+1][k] = max(v1,v2)
    if DBG:
        ddprint(i)
        ddprint(d[i+1])
print(max(d[n]))


Measured memory_bytes: 106448
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
void solve()
{
   ll n;
   cin>>n;
   std::vector<ll> p,q;
   ll op=1e9;
   for(int i=1;i<=n;i++)
   {
   	   ll x,y;
   	   cin>>x>>y;
   	   p.pb(x+y);
   	   q.pb(op+1-y+x);
   }
   sort(all(p));
   sort(all(q));
   ll ans=p.back()-p[0];
   ans=max(ans,q.back()-q[0]);
   cout<<ans;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 6664
#include<bits/stdc++.h>
#define ll long long int
#define ar array
#define pb push_back
#define forf(i,a,b) for(i = a; i< b; i++)
#define forb(i,a,b) for(i = b; i>=a; i--)
using namespace std;
const int mod = 1e9+7;
ll power(ll a,ll b){ll r=1;for(;b;b>>=1){if(b&1)r=r*a%mod;a=a*a%mod;}return r;}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin>>n>>k;
	ll ans = (n-k)*(n-k+1)/2;
	for(ll i = 1; i<=n; i++)
	{
		if(i==k || i<=k) continue;
		for(ll j = 1; j*i+k<=n;j++)
		{
			// cout<<ans<<endl;
			ll h = min((j+1)*i-1,n);
			ans += h-(i*j+k)+1;
			// cout<<ans<<endl;
		}
	}
	if(k==0) ans -= n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int n,a[200001]={};
  cin>>n;
  for(int i=0;i<n;i++) cin>>a[i];
 
  int max=a[1]-a[0];
  int min=a[0];
  for(int i=1;i<n;i++){

      if(a[i]-min>max)max=a[i]-min;
           if(min>a[i])min=a[i];
  }
  cout<<max<<endl;
  return 0;
}


Measured memory_bytes: 3896
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
const ll MOD = 1e9+7;
 
int main(){
  int p, q, r;
  cin >> p >> q >> r;
  cout << min(p, q)+min(max(p, q), r) << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

int main(int argc, char const* argv[])
{
    std::string in_str;
    std::cin >> in_str;

    int current_count = 0;
    int max = 0;
    for(auto c: in_str)
    {
        switch(c)
        {
            case 'A':
            case 'C':
            case 'G':
            case 'T':
                current_count++;
                break;
            default:
                max = std::max(current_count, max);
                current_count = 0;
                break;
        }
    }
    max = std::max(current_count, max);
    std::cout << max << std::endl;
    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   vector<ll>a(3);
    for (int i = 0; i < 3; ++i) {
        cin >>a[i];
    }
   sort(all(a));
   ll ans=0;
   ans+=abs(a[1]-a[0])+abs(a[2]-a[1]);
   cout <<ans <<endl;
   return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace::std;

long int N, A[100000],B[100000],ans,mi,minum;
char S[6];

int min(int x, int y) {
	if (x > y)return y;
	return x;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	mi = 2000000000;
	for (int i = 0; i < N; i++) {
		if (mi > B[i]) {
			mi = B[i];
			minum = i;
		}
	}

	ans = A[minum] + B[minum];

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


	


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	vector<char> res(3);
	rep(i, 3) res[i] = s[i + 1];
	rep(bit, (1 << 3)) {
		int tmp = s[0] - '0';
		string now = "";
		now += s[0];
		rep(i, 3) {
			if (bit & (1 << i)) {
				now += '+';
				tmp += res[i] - '0';
				now += res[i];
			}
			else {
				now += '-';
				tmp -= res[i] - '0';
				now += res[i];
			}
		}
		if (tmp == 7) {
			cout << now << "=" << 7 << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
d = set()
ans = []

for i in range(int(input())):
    str1, str2 = input().split()
    if (str1 == 'insert'):
        d.add(str2)
    else :
        if(str2 in d):
            ans.append('yes')
        else:
            ans.append('no')

for i in ans:
    print(i)




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

int n;
string name;
string t[102];

bool check(const string &a, const string &b){
  int an = a.length();
  int bn = b.length();

  if(an > bn) return false;

  for(int w = 1; w <= bn; w++){
    for(int si = 0; si < bn; si++){
      if(si + w * (an - 1) >= bn) break;

      int bi = si;
      bool flg = true;

      for(int ai = 0; ai < an; ai++){
        if(a[ai] != b[bi]){
          flg = false;
          break;
        }
        bi += w;
      }

      if(flg) return true;
    }
  }

  return false;
}

void solve(){
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(check(name, t[i])){
      ans++;
    }
  }
  cout << ans << endl;
}

int main(){
  while(cin >> n){
    cin >> name;
    for(int i = 0; i < n; i++){
      cin >> t[i];
    }
    solve();
  }
}

Measured memory_bytes: 1224
"use strict";
// inputに入力データ全体が入る
const main = (input) => {
  const [a, b, c, d] = input
    .trim()
    .split(" ")
    .map((e) => Number(e));
  // ここに処理を書く
  if (a + b < c + d) {
    return "Right";
  } else if (a + b == c + d) {
    return "Balanced";
  } else {
    return "Left";
  }
};

// ※この行以降は編集しない (標準入力から一度に読み込みMainを呼び出します)
console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));


Measured memory_bytes: 29512
#include<stdio.h>
#include<string.h>
int main() {
 char s[11];
 int n, a = 0, b = 0, c = 0, r = 0;
 scanf("%d", &n);
 for (int i = 0; i < n; i++) {
  scanf("%s", s);
  int l = strlen(s) - 1;
  for (int j = 0; j < l; j++)
   if(s[j] == 'A' && s[j + 1] == 'B') r++;
  if(s[0] == 'B') {
   if(s[l] == 'A') c++;
   else b++;
  }
  else if(s[l] == 'A') a++;
 }
 if (c > 0) {
  r += c - 1;
  if (a > 0) {r++, a--;};
  if (b > 0) {r++, b--;};
 }
 r += a<b? a: b;
 printf("%d", r);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <cstdlib>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
int main() {
    string s;
    string t;
    int q;
    cin >> t >> q;
    rep(i, q) {
        int ty;
        cin >> ty;
        if (ty == 1) {
            swap(s, t);
            
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                s += c;
            } else {
                t += c;
            }
        }
    }
    reverse(s.begin(), s.end());
    s += t;

    cout << s << endl;
    return 0;
}


Measured memory_bytes: 1128
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
    s = input()
    if s == 'AC':
        ac += 1
    elif s == 'WA':
        wa += 1
    elif s == 'TLE':
        tle += 1
    else:
        re += 1
print(f'AC x {ac}')
print(f'WA x {wa}')
print(f'TLE x {tle}')
print(f'RE x {re}')


Measured memory_bytes: 9192
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;
typedef long long int ll;

int main()
{
    ll N, K;
    cin >> N >> K;
    if (K%2==1) {
        ll ans = (N/K) * (N/K) * (N/K);
        std::cout << ans << '\n';
    }
    if (K%2==0) {
        ll ans = (N/K) * (N/K) * (N/K);
        ll ans2 = pow((N/(K/2)) - (N/K), 3);
        std::cout << ans + ans2 << '\n';
    }
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
int W,H,x,y,r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

    if(x>=r && x<=W-r && y>=r && y<=H-r  )
        puts("Yes");
    else 
        puts("No");
return 0;
}



Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;

int main(){
    ll l,r;
    cin >> l >> r;
    if(l - r >= 673){
        cout << 0 << endl;
        return 0;
    }

    int min = 2019;
    for(ll i=l;i<=r;i++){
        for(ll j=i;j<=r;j++){

            if(i!=j&&((i*j) %2019)<min){
                min = (i*j) %2019;
            }
            if(i*j%2019 == 0){
                cout << 0 << endl;
                return 0;
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 256
def I(): return int(input())
N = I()
ans = 0

if N>=105:
  for i in range(105, N+1, 2):
    count = 0
    for j in range(1, int(i**0.5)+1):
      if i%j==0:
        count +=2
    if count==8:
      ans +=1
print(ans)

Measured memory_bytes: 3060
n=int(input())
s=input()
r=s.count("R")
g=s.count("G")
b=s.count("B")
ans=r*g*b
for i in range(n-2):
  for j in range(i+1,n):
    k=2*j-i
    if k>(n-1):
      break
    if s[i]!=s[j]!=s[k]!=s[i]:
      ans-=1
print(ans)


Measured memory_bytes: 67744
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
#include<map>
#include<set>
using namespace std;

int main() {
	int N, M, x = 0,l=0;
	string  s;
	cin >> N;
	map<string, int>S, T, num;
	set<string>s1, t1;
	for (int i = 0;i < N;i++) {
		cin >> s;
		s1.insert(s);
		S[s]++;
	}


	cin >> M;
	for (int i = 0;i < M;i++) {
		cin >> s;
		t1.insert(s);
		T[s]++;
	}

	

	for (auto itr1 : s1) {
		for (auto itr2 : t1) {
			if (itr1 == itr2) {
				num[itr1] = S[itr1] - T[itr2];
			}
			else l++;
		}
		if (l == t1.size()) {
			num[itr1] = S[itr1];
			l = 0;
		}
		else l = 0;
	}


	for (auto itr : s1) {
		if (num[itr] >= x)x = num[itr];
	}

	cout << x << endl;

	return 0;

}

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

a = [0] * n

for i in range(n):
    a[i] = int(input())

a.sort()

r =[ 0] * len(a)

r[0] = a[(  n-1) // 2]

pr = 1
pi=0
pj=len(a)-1



while pr <len(a):
    r[pr] = a[pj]
    pr += 1
    pj -= 1
    if pr >=len(a):
        break
    r[pr] = a[pi]
    pr += 1
    pi += 1

result1 = 0
for i in range(n-1):
    result1 += abs(r[i+1] - r[i])

pr = 1
pi=0
pj=len(a)-1

while pr <len(a):
    r[pr] = a[pi]
    pr += 1
    pi += 1

    if pr >=len(a):
        break
    r[pr] = a[pj]
    pr += 1
    pj -= 1

result2 = 0
for i in range(n-1):
    result2 += abs(r[i+1] - r[i])

result = result1 if result1 > result2 else result2

print(result)


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

typedef vector<int> vi;
#define ll long long
#define loop(i,n) for(int i=0; i<n; i++)
#define loop1(i,n) for(int i=1; i<=n; i++)
#define loopi(i,s,e) for(int i=s; i < e; i++)
#define loopiRev(i,s,e) for(int i=s; i >= e; i--)
#define PI 3.14159265359
#define x first
#define y second
#define point pair<int,int>
#define len(s)   (int)s.length()
#define sz(v)    (int)v.size()
#define all(a)   a.begin(),a.end()
#define clr(x, val)	memset((x), (val), sizeof(x))

//you don't know math, unless you can do math!
int dp[100009];
vector<int> a;

int n,k;

int solve (int i){
    int &ret = dp[i];
    if(ret != -1) return ret;

    if(i == n - 1){
        return ret = 0;
    }

    int mn = INT_MAX;
    loop1(j, k) if(i+j < n) mn = min(mn, solve(i+j) + abs(a[i] - a[i+j]));

    return ret = mn;
}

int main() {
    //freopen("input.txt" , "r" , stdin) ;
    //freopen("output.txt" , "w" , stdout) ;

    cin.tie(0);
    cin.sync_with_stdio(0);

    clr(dp, -1);

    cin>>n>>k;
    a = vector<int> (n);
    loop(i, n) cin>>a[i];

    cout<<solve(0);
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int a, b;
  cin >> a >> b;

  rep(i, 20) {
    if (1 + (a-1)*i >= b) {
      cout << i << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
MOD = 10**9 + 7

n,m = map(int,input().split())
scc = min(n,m//2)
n -= scc
m -= scc*2

print(scc + m//4)

Measured memory_bytes: 3316
#include<iostream>
#include<string>
#include<stack>/*** LIFO *** stack<type> var;
push(), top():to get data, pop():to remove, size(), empty() ***/
using namespace std;

#define Fp(I, STAT, END) for(int I = STAT; I < END; I++)
#define Fm(I, STAT, END) for(int I = STAT; I > END; I--)

int main(){
    int N, K, d, temp;
    cin >> N >> K;
    int ans[N] = {};
    Fp(i, 0, K){
        cin >> d;
        Fp(j, 0, d){
            cin >> temp;
            ans[temp - 1]++;
        }
    }
    temp = 0;
    Fp(i, 0, N){
        if(ans[i] == 0) temp++;
    }
    cout << temp << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
// #define int long long
typedef long long ll;
typedef pair<int,int> pii;
#define ITR(v,c) for(auto v=begin(c);v!=end(c);v++)
#define FOR(v,a,n) for(int v=a;v<(int)(n);v++)
#define FORE(x,arr) for(auto &x:arr)
#define REP(v,n) FOR(v,0,n)
#define RREP(v,n) for(int v=(int)(n);v>=0;v--)
#define ALL(c) begin(c),end(c)
const int DX[4]={0,1,0,-1}, DY[4]={-1,0,1,0};
const int INF = 1e9;
const ll INFLL = 1e18;
template<class T,class U>ostream&operator<<(ostream &os,const pair<T,U> &p){
    os<<"("<<p.first<<","<<p.second<<")";return os;}
template<class T>ostream&operator<<(ostream &os,const vector<T> &v){
    ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;}
//------------------------------------------------------------------------------

ll table[2010][2010];
signed main() {
    REP(i,2010) REP(j,2010) table[i][j]=INFLL;

    ll n,x;
    cin>>n>>x;
    vector<ll> a(n);
    REP(i,n) cin>>a[i];

    REP(i,n) {
        table[i][0]=a[i];
        FOR(k,1,n) {
            table[i][k]=min(table[i][k-1],a[(n+i-k)%n]);
        }
    }

    ll ans=INFLL;
    REP(k,n) {
        ll sum=0;
        REP(i,n) {
            sum+=table[i][k];
        }
        ans=min(ans,k*x+sum);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  int n, k;
  cin >> n >> k;
  vector<int64_t> h(n);
  for (auto i = 0; i < n; i++) {
    cin >> h[i];
  }
  sort(begin(h), end(h));
  uint64_t ans = numeric_limits<uint64_t>::max();
  for (auto i = 0; i < n - k + 1; i++) {
    uint64_t d = h[i + k - 1] - h[i];
    ans = min(ans, d);
  }
  cout << ans << endl;
}


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

#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define fs first
#define sc second
#define pb push_back
#define mk make_pair

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

template<class S,class T>
ostream &operator<<(ostream &out, const pair<S,T> p){
	return out << "(" << p.fs << ", " << p.sc << ")";
}

template<class T>
ostream &operator<<(ostream &out, const vector<T> &v){
	out << "{";
	rep(i,v.size()) out << v[i] << ", ";
	return out << "}" << endl;
}

int main(){
	string s;
	cin >> s;
	string y = "YAKI";
	bool ok = true;
	ok = 3 < s.length();
	rep(i,min(4,(int)s.length())){
		if(y[i] != s[i]) ok = false;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
	string S;

	cin >> S;

	if(S == "Sunny"){
		cout << "Cloudy" << endl;
	}

	if(S == "Cloudy"){
		cout << "Rainy" << endl;
	}

	if(S == "Rainy"){
		cout << "Sunny" << endl;
	}


	return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	string t=s;
	for(int i=0;i<t.size()/2;i++)
	{
		char tt=t[i];
		t[i]=t[t.size()-i-1];
		t[t.size()-i-1]=tt;
	}
	for(int i=0;i<t.size();i++)
	{
		if(t[i]=='p')t[i]='q';
		else
		if(t[i]=='q')t[i]='p';
		else
		if(t[i]=='b')t[i]='d';
		else
		if(t[i]=='d')t[i]='b';
	}
	if(t==s)cout<<"Yes";
	else cout<<"No";
	return 0;
} 

Measured memory_bytes: 512
<?php
  
while ($line = fgets(STDIN)) {
   $stdin[] = trim($line);
}
#$v2 = str_split($stdin[0]);
#$v2 = explode(" ", $stdin[0]);

$line1 = explode(" ", $stdin[0]);
$line2 = explode(" ", $stdin[1]);

$kijun = $line1[1];

$count = 0;

foreach($line2 as $v){
  
  if($kijun <= $v){
    $count++;
  }
}

$ans = $count;

echo $ans . PHP_EOL;




Measured memory_bytes: 21372
#include <iostream>
#include <vector>
#include <cstdio>
#include <set>
#include <map>
#include <algorithm>
#define int long long int

using namespace std;

bool check(vector<char>& A, vector<int>& who, int i)
{
    if (who[i])
    {
        if (A[i] == 'o')
        {
            return who[(i+1) % A.size()] == 1 - who[(i-1+A.size()) % A.size()];
        }
        else
        {
            return who[(i+1) % A.size()] == who[(i-1+A.size()) % A.size()];
        }
    }
    else
    {
        if (A[i] == 'o')
        {
            return who[(i+1) % A.size()] == who[(i-1+A.size()) % A.size()];
        }
        else
        {
            return who[(i+1) % A.size()] == 1 - who[(i-1+A.size()) % A.size()];
        }
    }
}


main()
{
    //freopen("input.txt", "r", stdin);
    int N;
    cin>>N;
    vector<char> A(N);
    for(int i = 0; i < N; ++ i)
    {
        cin>>A[i];
    }
    vector<int> who(N);
    bool can = 0;
    vector<int> ans(N);
    for(int a = 0; a < 2; ++a)
    {
        for(int b = 0; b < 2; ++b)
        {
            who[0] = a;
            who[1] = b;
            //cout<<"NXT"<<endl;
            for(int i = 1; i < N - 1; ++ i)
            {
                if (who[i])
                {
                    if (A[i] == 'o')
                    {
                        who[i+1] = 1 - who[i-1];
                        //acout<<i<<' '<<who[i-1]<<' '<<who[i+1]<<endl;
                    }
                    else
                    {
                        who[i+1] = who[i-1];
                    }
                }
                else
                {
                    if (A[i] == 'o')
                    {
                        who[i+1] = who[i-1];
                    }
                    else
                    {
                        who[i+1] = 1 - who[i-1];
                    }
                }
            }
            if (check(A, who, N-1) && check(A, who, 0))
            {
                swap(who, ans);
                can = true;

            }
        }
    }


    if (can)
    {
        for(auto el:ans)
        {
            //cout<<el<<' ';
            if (el)
            {
                cout<<"W";
            }
            else
            {
                cout<<"S";
            }
        }
    }
    else
    {
        cout<<-1;
    }
    cout<<endl;
}



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

int num;
int a[21][21];

int retcost(int Island){
	int x=0;
	for(int i=1;i<=num;i++){
		if(a[Island][i]){
			a[i][Island]=0;
			x=max(x,a[Island][i]+retcost(i));
		}
	}
	return x;
}

int main(void){
	while(cin>>num,num){
		int I1,I2,t,ans,I[num+1]={},Cost=0;
		memset(a,0,sizeof(a));
		for(int i=1;i<num;i++){
			cin>>I1>>I2>>t;
			a[I1][I2]=a[I2][I1]=t;
			I[I1]++,I[I2]++;
			Cost+=t*2;
		}
		for(int i=1;i<=num;i++){
			for(int j=1;j<=num;j++){
				if((I[i]==1||I[j]==1)&&!((i==1&&I[i]==1)||(j==1&&I[j]==1))){
					Cost-=a[i][j]*2;
					a[i][j]=a[j][i]=0;
				}
			}
		}
		ans=Cost-retcost(1);
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 2992
import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 1_000_000_007; // 10^9+7
    // static final int MAX = 2_147_483_646; // intの最大値
    static final int INF = 1_000_000_000; // 10^9
    static final int MAX = 10_000_000;

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long ans = 0;
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= n; j++) {
                int tmp = gcd(i,j);
                for (int k = 1; k <= n; k++) {
                    ans += gcd(tmp,k);
                }
            }
        }
        System.out.println(ans);
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    static int lcm(int a, int b) {
        return a * b / gcd(a, b);
    }
}


Measured memory_bytes: 35872