akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

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

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

vl getPrimes(ll x){
    vl ret;
    ll a = 2;
    while(x >= a*a){
        while(x % a == 0){
            x /= a;
            ret.push_back(a);
        }
        a++;
    }
    if(x != 1) ret.push_back(x);
    return ret;
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    ll n; cin >> n;
    auto primes = getPrimes(n);
    cout << n << ": " << join(primes, " ") << endl;
    return 0;
}


Measured memory_bytes: 3220
import copy
def convert(list):
    res=" ".join(map(str, list))
    return res

n=int(input())
a=list(map(str,input().split()))

b=a[:]
s=copy.deepcopy(a)

for i in range(n-1):
    for j in reversed(range(i+1,n)):
        if b[j][1]<b[j-1][1]:
            bj=b[j]
            b[j]=b[j-1]
            b[j-1]=bj
bub=convert(b)
print(bub)
print("Stable")

for k in range(n):
    minl=k
    for l in range(k,n):
        if s[minl][1]>s[l][1]:
            minl=l

    if minl!=k:
        sk=s[k]
        s[k]=s[minl]
        s[minl]=sk

se=convert(s)
print(se)
if s==b:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 6344
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    int n;  cin >> n;
    ll *a = new ll[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    ll mod = 1e9+7, *s = new ll[n];

    s[n-1] = a[n-1];
    for (int i = n-1; i > 1; i--) {
        s[i-1] = s[i] + a[i-1];
        s[i-1] %= mod;
    }

    ll ans = 0;
    for (int i = 0; i < n-1; i++) {
        ans += a[i]*s[i+1];
        ans %= mod;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;

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

Measured memory_bytes: 256
fn main(){
    let n:i32 = getline().trim().parse().unwrap();
    let mut t = n;
    let mut s = 0;
    while t > 0 {
        s += t % 10; t /= 10;
    }
    
    if (n % s == 0) {
        println!("Yes");
    }
    else {
        println!("No");
    }
}

fn getline() -> String{
    let mut r = String::new();
    std::io::stdin().read_line(&mut r).ok();
    return r;
}


Measured memory_bytes: 4352
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
typedef long long ll;
#define PB	push_back
#define FOR(n)			for(int i = 0; i < n; ++i)
#define RFOR(n)			for(int i = n; i >= 0; --i)
#define FORR(start,end) for(int i = start; i < end; ++i)
#define COUT(n)			cout << n << " " << flush
#define vi(v)			vector<int> v
#define vii(v)			vector<pair<int,int>> v
#define mkp(a,b)		make_pair(a,b)
#define ALL(obj)		obj.begin(), obj.end()
using namespace std;

int main() {
	int s;
	cin >> s;
	int f = s / 100;
	int se = s % 100;
	if (1 <= f && f <= 12) {
		if (1 <= se && se <= 12)
			cout << "AMBIGUOUS" << endl;
		else
			cout << "MMYY" << endl;
	}
	else {
		if (1 <= se && se <= 12)
			cout << "YYMM" << endl;
		else
			cout << "NA" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

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> PII;
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 EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int h, w, k; cin >> h >> w >> k;

	vector<vector<int>> amida(h+1, vector<int>(w));

	vector<vector<int>> dp(h+1, vector<int>(w));
	//必ず1からスタートする
	dp[0][0] = 1;

	for (int i = 1; i < h+1; i++) {

		//横棒を全列挙
		for (int bar = 0; bar < (1 << w - 1); bar++) {

			bool ng = false;
			//2個続いている場所がないかのチェック
			
			for (int j = 0; j < w - 2; j++) {
				if ((bar >> j) % 4 == 3) {
					ng = true;
					break;
				}
			}

			if (ng)continue;

			//置換の対応列を作る
			vector<int> swaprow(w);
			for (int j = 0; j < w; j++) {
				swaprow[j] = j;
			}

			for (int j = 0; j < w-1; j++) {
				if ((bar >> j) % 2 == 1) {
					swap(swaprow[j], swaprow[j + 1]);
				}
			}

			//遷移
			//jはswaprow[j]にいく

			for (int j = 0; j < w; j++) {
				dp[i][swaprow[j]] += dp[i - 1][j];
				dp[i][swaprow[j]] %= MOD;
			}

		}
	}

	cout << dp[h][k - 1] << endl;

	return 0;
}

Measured memory_bytes: 384
"use strict"

let inputs = ``;

const reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', function(input) {
  inputs = input
});
reader.on('close', function() {
  let items = inputs.trim().split(' ')
  let h = parseInt(items[0])
  let a = parseInt(items[1])
  const x = Math.floor(h / a)
  const y = h % a
  //console.log(`x : ${x}, y : ${y}`);
  if(y===0){console.log(x)}else console.log(x+1)
});

Measured memory_bytes: 21320
a = input()
b  =input()

m = len(a)
n = len(b)

ans = 10e9+7

for i in range(m-n+1):
	c=0;
	for j in range(n):
		if(a[i+j]!=b[j]):
			c+=1
	ans = min(c,ans)

print(ans)


Measured memory_bytes: 9020
#include <bits/stdc++.h>
using namespace std;
int a[202];
int main(){
    int n;
    scanf("%d", &n);
    for(int i=0;i<2*n;i++) scanf("%d", &a[i]);
    sort(a, a+2*n);
    int ans = 0;
    for(int i=0;i<2*n;i+=2) ans += a[i];
    printf("%d\n", ans);
}

Measured memory_bytes: 256
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}


/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  int n;
  cin>>n;
  vector<int> v(n),a,b;
  rep(i,n) cin>>v[i];
  rep(i,n){
    if(i%2==0){
      a.push_back(v[i]);
    }else{
      b.push_back(v[i]);
    }
  }
  if(n%2==0){
    reverse(b.begin(),b.end());
    for(auto c:b){
      cout<<c<<' ';
    }
    for(auto c:a){
      cout<<c<<' ';
    }
  }else{
    reverse(a.begin(),a.end());
    for(auto c:a){
      cout<<c<<' ';
    }
    for(auto c:b){
      cout<<c<<' ';
    }
  }
}

Measured memory_bytes: 3956
#include<iostream>
#include<cmath>
#include<map>
#include<vector>
#include<cstdlib>
#include<sstream>
#include<set>
#include<cstdio>
#include<cassert>
#define F first
#define S second
#define inf (1<<28)
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

struct P
{
  string unit;
  int mpower;
  int upower;
  P(string unit="$",int upower=-inf,int mpower=-inf):unit(unit),upower(upower),mpower(mpower){}
};
vector<vector<P> > G(210);
map<string,int> exist;

int toPower(string s)
{
  if(s == "1")return 0;
  int pos = 0;
  rep(i,s.size())
    {
      if(s[i] == '^')
	{
	  pos = i+1;
	  break;
	}
    }
  return (atoi)(s.substr(pos,s.size()-pos).c_str());
}

bool used[210];
int isok;//-1 -> No, 0 => Not yet, 1 -> Ok

void dfs(string now,string target,int power,int target_power)
{
  if(isok != 0)return;
  if(now == target)
    {
      isok = (power == target_power?1:-1);
      return;
    }
  int index = exist[now];
  if(used[index])return;
  used[index] = true;

  rep(i,G[index].size())
    {
      P p = G[index][i];
      int next_index = exist[p.unit];
      if(used[next_index])continue;
      dfs(p.unit,target,power+(p.mpower==0?p.upower:-p.mpower),target_power );
    }
}

bool check(string u1,string u2,int power)
{
  rep(i,110)used[i] = false;
  isok = 0;

  dfs(u1,u2,0,power);
  return isok == 1;
}

bool reachable;

void move(int now,int target)
{
  if(now == target)
    {
      reachable = true;
      return;
    }

  if(used[now])return;
  used[now] = true;

  rep(i,G[now].size())
    {
          
      assert(exist.count(G[now][i].unit));

      move(exist[G[now][i].unit],target);
    }

}

int main()
{
  int N;
  while(cin >> N,N)
    {
      assert(N <= 100);
      rep(i,N)G[i].clear();
      int index = 0;
      exist.clear();
      bool result = true;
      rep(i,N)
	{
	  string v1,unit1,v2,unit2,eq;
	  cin >> v1 >> unit1 >> eq >> v2 >> unit2;
	  if(unit1 == unit2)
	    {
	      if(v2 == "10^0")continue;
	      else            result = false;
	      continue;
	    }
	  //assert(unit1 != unit2);
	  if(!result)continue;
	  //cout << toPower(v1) << " " << unit1 << " = "<< toPower(v2) << " " << unit2 << endl;
	  if(exist.count(unit1) && exist.count(unit2))
	    {
	      rep(i,N)used[i] = false;
	      reachable = false;
	      move(exist[unit1],exist[unit2]);
	      if(reachable)
		{
		  int p1 = toPower(v1);
		  int p2 = toPower(v2);
		  result = check(unit1,unit2,p2);
		  //cout << "result = " << result << endl;
		}
	      else
		{
		  goto Insert;
		}
	      continue;
	    }

	  //cout << "not exists" << endl;
	  if(!exist.count(unit1))exist[unit1] = index++;
	  if(!exist.count(unit2))exist[unit2] = index++;
	Insert:;
	  int index1 = exist[unit1];
	  int index2 = exist[unit2];
	  G[index1].push_back(P(unit2,toPower(v2),toPower(v1)));
	  G[index2].push_back(P(unit1,toPower(v1),toPower(v2)));
	}
      cout << (result?"Yes":"No") << endl;
    }
  return 0;
}

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

int main(){
    string s;
    cin>>s;
    bool nflag=false,sflag=false,eflag=false,wflag=false;
    for(int i=0;i<s.size();i++){
        if(s[i]=='N')nflag=true;
        else if(s[i]=='W')wflag=true;
        else if(s[i]=='S')sflag=true;
        else if(s[i]=='E')eflag=true;
    }
    if(sflag==nflag&&wflag==eflag)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3564
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
double ans,m;
ll n;
ll logbase2(ll a)
{
    ll temp=0;
    while(a>1)
    {a=ceil(a*1.0/2);temp++;}
    return temp;
}
void solve()
{
    cin>>n>>m;
    for(ll i=1;i<=n;i++)
    {
        ll temp=1;
        while(temp*i<m)
        temp*=2;
        ans+=1.0/(temp*n);
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
}
int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
    //int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
n, x = map(int, input().split())
l = list(map(int, input().split()))

#l[0]: 2回目
cnt = n+1
for i in range(1, n):   #i+1回目の判断 できないならi
    l[i] += l[i-1]
    if l[i] > x:
        cnt = i+1   # i kai madedekita
        break
if l[0] > x:
    cnt = 1
print(cnt)

Measured memory_bytes: 38256
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

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

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

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n;
string s;

signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> s;

	int lw = 0;
	while(lw < n && s[lw] != 'W') lw++;

	int rr = n-1;
	while(rr > 0 && s[rr] != 'R') rr--;

	if(lw == n or rr == 0)
	{
		cout << 0 << endl;
		return 0;
	}

	int rct = 0;
	for (int i = lw; i <= rr; ++i)
		rct += (s[i] == 'R');

	int ans = 0;
	for (int i = 0; i < rct; ++i)
		ans += s[lw + i] == 'W';

	cout << ans << endl;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

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

int main() {
	// your code goes here
	ll n;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	    cin>>a[i];
    ll dp[n];
    memset(dp,0,sizeof(dp));
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(ll i=2;i<n;i++){
        
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n-1];
	return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2019/03/21  Problem: ABC 060 C / Link: http://abc060.contest.atcoder.jp/tasks/abc060_c  ----- */


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

	LL N, T; cin >> N >> T;
	vector<LL> a(N);
	for (int i = 0; i < N; ++i) {
		cin >> a[i];
	}

	LL s = 0, t = 0;
	LL ans = 0LL;
	FOR(i, 0, N) {
		if (t < a[i]) {
			ans += t - s;
			s = a[i];
		}
		t = a[i] + T;
	}
	ans += t - s;
	
	cout << (ans) << "\n";

	return 0;
}


Measured memory_bytes: 1792
/**
*    created: 13.05.2020 22:26:51
**/
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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++)
using namespace std;

signed main() {

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

    string s; cin >> s;
    string s1 = s.substr(0,2);
    string s2 = s.substr(2,2);
    int a = stoi(s1);
    int b = stoi(s2);
    if (1 <= a && a <= 12 && (b >= 13 || b == 0)) cout << "MMYY" << endl;
    else if (1 <= b && b <= 12 && (a >= 13 || a == 0)) cout << "YYMM" << endl;
    else if (1 <= b && b <= 12 && 1 <= a && a <= 12) cout << "AMBIGUOUS" << endl;
    else cout << "NA" << endl;
    return 0;
}

Measured memory_bytes: 3572
fun main(args: Array<String>) {
    var (N, D, A) = listOfInt()
    var XH = Array(N) {
        var (x, h)= listOfLong()
        x to h
    }.sortedBy { it.first }
    val d = D * 2
    val q = Queue<Pair<Long, Long>>()
    var ans = 0L
    var total = 0L
    repeat (N) {
        var (x, h) = XH[it]
        while (q.count() > 0 && q.first().first < x) {
            total -= q.dequeue()!!.second
        }
        h -= total
        if (h > 0) {
            val num = (h + A - 1) / A
            ans += num
            val dmg = num * A
            total += dmg
            q.enqueue(x + d to dmg)
        }
    }
    println(ans)
}
fun next() = readLine()!!
fun nextLong() = next().toLong()
fun listOfString() = next().split(" ")
fun listOfLong() = listOfString().map(String::toLong)
fun listOfInt() = listOfString().map(String::toInt)
class Queue<T> {
    val elements = mutableListOf<T>()
    fun count() = elements.size
    fun isEmpty() = elements.isEmpty()
    fun first() = elements[0]
    fun enqueue(item: T) = elements.add(item)
    fun dequeue() = if (!isEmpty()) elements.removeAt(0) else null
}

Measured memory_bytes: 132320
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, A, B;
  cin>>N>>A>>B;
  A--;
  B--;
  if((B-A)%2==0) {
    cout<<(B-A)/2<<endl;
  }
  else {
    ll ans1=0, ans2=0;
    ll tmpa=A, tmpb=B;
    ans1 += tmpa;
    tmpb -= tmpa;
    tmpa = 0;
    ans1++;
    tmpb--;
    ans1 += (tmpb-tmpa)/2;

    tmpa = A;
    tmpb = B;
    ans2 += N-tmpb-1;
    tmpa += N-tmpb-1;
    tmpb = N-1;
    ans2++;
    tmpa++;
    ans2 += (tmpb-tmpa)/2;
    cout<<min(ans1, ans2)<<endl;
  }
}



Measured memory_bytes: 3568
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <map>
#define out(S) cout<<(S)<<endl;
#define mod(i) ((i)%(ll)(1000000000 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define For(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFor(i,a,b) for(size_t i=(a)-1;i>=(b);i--)
#define Rep(i,a) for(size_t i=0;i<(a);i++)
#define rRep(i,a) for(size_t i=(a)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)

vector<int> makeFactor(int x) {
	vector<int> factors;
	factors.push_back(2);
	for (size_t i = 3; i <= sqrt(x); i+=2)
	{
		bool flag = false;
		Foreach(item, factors) if (i%item == 0) { flag = true; break; }
		if (!flag) factors.push_back(i);
	}
	return factors;
}

int main(){
	string S;
	cin >> S;
	ll f = S.find_first_of('A');
	ll e = S.find_last_of('Z');
	out(e - f + 1);
}



Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main() {
    long long int n = 0, a = 0, b = 0, c = 0, d = 0, e = 0;
    scanf("%lld\n%lld\n%lld\n%lld\n%lld\n%lld", &n, &a, &b, &c, &d, &e);
    long long int min = a;
    if (b < min) min = b;
    if (c < min) min = c;
    if (d < min) min = d;
    if (e < min) min = e;
    long long int ans = (n%min == 0) ? n/min+4: n/min+5;
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 128
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline
setrecursionlimit(10 ** 7)

from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
from collections import deque, defaultdict, Counter
from itertools import combinations, permutations, combinations_with_replacement
from itertools import accumulate
from math import ceil, sqrt, pi, radians, sin, cos

MOD = 10 ** 9 + 7
INF = 10 ** 18

X, N = map(int, input().split())
A = list(map(int, input().split()))

for i in range(1000):
    if X - i not in A:
        print(X - i)
        exit()
    if X + i not in A:
        print(X + i)
        exit()

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

int main() {
  long long Q,H,S,D,N;
  cin >> Q >> H >> S >> D >> N;
  
  long long A = min(Q*4, H*2);
  A = min(A, S);
  
  if (A*2 >= D){
    cout << (N/2)*D + (N % 2)*A << endl;
  }
  else {
    cout << A*N << endl;
  }
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int D;
    cin >> D;
    vector<int>c(26);
    for(int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    vector<vector<int>>s(D,vector<int>(26));
    for(int i = 0; i < D; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int>t(D);
    for(int i = 0; i < D; i++) {
        t[i] = rand()%26+1;
    }
    int ans = 0;
    vector<int>Last(26);
    for(int i = 0; i < D; i++) {
        ans+=s[i][t[i]-1];
        Last[t[i]-1] = i+1;
        for(int j = 0; j < 26; j++) {
            ans-=c[j]*(i+1-Last[j]);
        }
    }
    int M = 3003333;
    vector<P>horyuu;
    int cnt = 0;
    for(int i = 0; i < M; i++) {
        int d = rand()%D+1;
        int q = rand()%26+1;
        int ord = ans;
        int X = 0;
        int Y = 0;
        int A = 0;
        int B = 0;
        ans+=s[d-1][q-1]-s[d-1][t[d-1]-1];
        for(int j = 0; j < D; j++) {
            if(t[j] == t[d-1]) {
                if(j == d-1) {
                    Y = j+1;
                }
                else {
                    X = j+1;
                }
                A = j+1;
            }
            if(t[j] == q) {
                Y = j+1;
                B = j+1;
            }
            ans-=c[t[d-1]-1]*(j+1-X)-c[t[d-1]-1]*(j+1-A);
            ans+=c[q-1]*(j+1-B)-c[q-1]*(j+1-Y);
        }
        if(ans > ord) {
            ord = ans;
            horyuu.push_back({d,q});
            cnt++;
        }
        else {
            ans = ord;
        }
        if(cnt == 2) {
            cnt = 0;
            t[horyuu[1].first-1] = horyuu[1].second;
            horyuu = {};
        }
    }
    for(int i = 0; i < D; i++) {
        cout << t[i] << "\n";
    }
}

Measured memory_bytes: 3720
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<vector>
#include<ctime>
#define ll long long
#define pr(x) cerr<<#x<<"="<<x<<endl
using namespace std;
ll n,k,ans,a[500][500],b[500][500],i,j;
int main()
{
	scanf("%lld",&n);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		{
			scanf("%lld",&a[i][j]);
		}
	for (k=1;k<=n;k++)
		for(i=1;i<=n;i++)
			for (j=1;j<=n;j++)
			if (k!=i&&j!=k&&i!=j)
			{
				if (a[i][k]+a[j][k]<a[i][j])
				{
					printf("-1\n");
					return 0;
				}
				if (a[i][k]+a[j][k]==a[i][j]) b[i][j]=b[j][i]=1;
			}
	for(i=1;i<=n;i++)
		for (j=1;j<=n;j++)
		{
			if (b[i][j]==0) ans+=a[i][j];
		}
	cout<<ans/2;
}

Measured memory_bytes: 2560
#include<iostream>
#include<string>
#include<math.h>
using namespace std;
int main()
{
	int n,m,a;
	cin >> n >> m;
	
	a = pow(2, m)*((1900 * m) + (100 * (n - m)));

	printf("%d", a);	

	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main(void){
    long long int i, j, k, n, a, b, ans=0, po=0;
    scanf("%lld %lld", &a, &b);
    printf("%lld", a*b);
    
}

Measured memory_bytes: 1732
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template <class T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
	for (const auto& e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}
template <class T>
ostream& operator<<(ostream& os, const set<T>& st) {
	for (const auto& e : st) os << e << " ";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
	os << "(" << p.first << "," << p.second << ")";
	return os;
}
template <class T1, class T2>
ostream& operator<<(ostream& os, const map<T1, T2>& mp) {
	for (const auto& e : mp) os << e << " ";
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T&& h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head&& h, Tail&&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	Int N;
	cin >> N;

	vector<pair<Int, Int>> red;
	vector<pair<Int, Int>> blue;

	Int a, b;
	for (Int i = 0; i < N; i++) {
		cin >> a >> b;
		red.push_back(make_pair(a, b));
	}

	Int c, d;
	for (Int i = 0; i < N; i++) {
		cin >> c >> d;
		blue.push_back(make_pair(c, d));
	}

	sort(red.begin(), red.end());
	sort(blue.begin(), blue.end());

	DMP(red, blue);

	vector<Int> seen(N);
	Int cnt = 0;
	Int temp;
	for (Int i = 0; i < N; i++) {//左端の青から固定して見ていく

		temp = -INF;
		for (Int j = 0; j < N; j++) {
			if (red[j].first>blue[i].first) {//赤のx	座標が青を超えるとbreak
				break;
			}
			else if (seen[j]) {//既にその赤の座標が使用済みならcontinue
				continue;
			}
			else if (temp==-INF) {//まだ一つも青の候補がない場合
				if (red[j].second>blue[i].second) {
					continue;
				}
				else {
					temp = j;
				}
			}
			else {//既に一つ以上青の候補が決まっている場合
				if (red[j].second > blue[i].second) {
					continue;
				}
				else if (red[j].second>red[temp].second) {
					temp = j;
				}
			}
		}

		if (temp==-INF) {
			continue;
		}
		else {
			cnt++;
			seen[temp]++;
		}

	}

	cout << cnt << "\n";


}


Measured memory_bytes: 256
N, K = map(int, input().split())

# 全てのbの候補について、aの候補の個数をかけ合わせる

if K == 0:
    ans = N**2
else:
    ans = 0
    for i in range(1,N-K+1):
        ans += i
        a_start = 2*K+i
        while a_start <= N:
            if a_start+i > N :
                ans += N - a_start +1
            else:
                ans += i
            a_start += K+i
print(ans)

Measured memory_bytes: 3060
import java.util.*;

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

    int k = sc.nextInt();
    int x = sc.nextInt();
    
    int min = x - k + 1;
    int max = x + k - 1;

    for (int i = min; i <= max; i++) {
      System.out.print(i + (i == max ? "": " "));
    }
    System.out.println();
    
  }
}


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

#define vint vector<int>
#define vvint vector<vint>
#define sint stack<int>
#define qint queue<int>
#define rep(i, n) for(int i=0;i<(int)(n);i++) // 繰り返し処理
#define all(x) (x).begin(),(x).end() // 全体 こんな感じで使う→sort(all(a));
#define ct(a) cout << a << endl
#define iceil(a,b) (a+(b-1))/b //int ceil : 繰り上げの割り算 通常のceilではceil((7.0/2.0))のようにしなければならなかった。
vint CinLine(int N){vint v(N);for(int i=0;i<N;i++){cin >> v.at(i);}return v;}//cin line 連続でvectorに格納
void CoutLine(vint v){for(int i=0;i<v.size()-1;i++){cout<<v.at(i)<<" ";}cout << v.at(v.size()-1)<<endl;}


int main() {
    int K;
    string S;
    cin >> K;
    cin >> S;
    int l = S.size();

    if(l <= K){
        ct(S);
    }else{
        string a = S.substr(0,K);
        cout << a << "..." << endl;
    }

}


/*
for(auto i : a){
    ct(i);
}
*/

Measured memory_bytes: 3632
n,m,q=map(int,input().split())
abcd=[[int(j)for j in input().split()]for i in range(q)]
ans=0
import itertools
for l in itertools.combinations_with_replacement(range(1,m+1),n-1):
    tmp=0
    for a,b,c,d in abcd:
        p,q=0,0
        if a==1:
            p,q=l[b-2],1
        else:
            p,q=l[b-2],l[a-2]
        if p-q==c:
            tmp+=d
    ans=max(ans,tmp)
print(ans)

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

using namespace std;


int main () {


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

	string s; cin >> s;

	int n = s.size();

	for (int i = 0; i < n; ++i) {
		if ((i + 1) & 1) {
			if (s[i] != 'R' && s[i] != 'U' && s[i] != 'D') {
				cout << "No" << '\n';
				return 0;
			}
		}
		else {
			if (s[i] != 'L' && s[i] != 'U' && s[i] != 'D') {
				cout << "No" << '\n';
				return 0;
			}
		}
	}

	cout << "Yes" << '\n';



	return 0;
}





Measured memory_bytes: 256
import scala.collection.mutable
object Main extends App {
  import scala.io.StdIn._
  val Array(h, w) = readLine.trim.split(' ').map(_.toInt)
  val state = Array.tabulate(h){_ ⇒ readLine.trim.toCharArray}
  val hatch = (0 until w).flatMap(x ⇒ (0 until h).filter(y ⇒ state(y)(x) == '%').map(y ⇒ Coordinate(x, y))).head
  val princess = (0 until w).flatMap(x ⇒ (0 until h).filter(y ⇒ state(y)(x) == '@').map(y ⇒ Coordinate(x, y))).head
  val minCost = Array.tabulate(h){_ ⇒ Array.tabulate(w){_ ⇒ -1}}
  minCost(hatch.y)(hatch.x) == 0
  val queue = mutable.Queue[Coordinate](hatch)

  while(queue.nonEmpty){
    val top = queue.dequeue()
    for (next ← top.neighbors if (0 until w).contains(next.x) && (0 until h).contains(next.y) && minCost(next.y)(next.x) == -1 && state(next.y)(next.x) != '#'){
      minCost(next.y)(next.x) = minCost(top.y)(top.x) + 1
      queue.enqueue(next)
    }
  }

  println(
    if ((0 until w).exists(x ⇒ (0 until h).exists(y ⇒ state(y)(x) == '$' && minCost(y)(x) <= minCost(princess.y)(princess.x)))) "No" else "Yes"
  )

  case class Coordinate(x: Int, y: Int) {
    def neighbors: List[Coordinate] = List(Coordinate(x + 1, y), Coordinate(x - 1, y), Coordinate(x, y + 1), Coordinate(x, y - 1))
  }
}


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

int main() {
    int K;
    vector<int> A(3);
    for (int i=0; i<3; i++) cin >> A.at(i);
    cin >> K;
    sort(A.begin(), A.end());
    cout << A.at(0) + A.at(1) + A.at(2)*pow(2,K) << "\n";
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using ld = long double;

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) {
  os << "{";
  rep(i, (int)v.size()) {
    if (i)
      os << ",";
    os << v[i];
  }
  os << "}";
  return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
  for (auto val : array)
    std::cout << val << ", ";
  std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

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

  ll n, a, b; std::cin >> n >> a >> b;
  ll sum = a + b, ans = 0;
  ans += n / sum * a;
  ans += min(n % sum, a);
  std::cout << ans << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>

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

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {


	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);

		String S=sc.next();
		int n=0;
for(int i=0;i<S.length();i++) {
	if(S.charAt(i)=='o')n++;
}
String ans="NO";
if(n+15-S.length()>=8)ans="YES";
		System.out.println(ans);

	}

}


Measured memory_bytes: 23892
n=int(input())
a=list(map(int,input().split()))
sum=1
flag=False
INF=1e18
for x in a:
    if(flag==False):
        sum*=x
    if(sum>INF):
        flag=True
if(0 in a):
    print(0)
elif(flag):
    print(-1)
else:
    print(sum)

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

int main()
{
	ll X, res = 1;
	cin >> X;
	X++;
	for (int i = 0; i < X;i++) {
		res = res * 2 + 1;
	}
	cout << res - 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	int a,c;
	char b;
	a=read();
	b=getchar();
	c=read();
	if(b=='+') write(a+c);
	else write(a-c);
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    int n, m;

    cin >> n >> m;

    multiset<ll> a;
    map<ll, ll, greater<ll>> p;

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

    for (int i = 0; i < m; i++)
    {
        int b, c;

        cin >> b >> c;

        p[c] += b;
    }

    int count = 0;

    ll ans = 0;

    for (auto z : p)
    {
        for (int i = 0; i < z.second; i++)
        {
            count++;

            if (count > n)
            {
                break;
            }

            ans += z.first;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 12800
/*  -*- coding: utf-8 -*-
 *
 * a.cc: Move and Win
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  if ((b - a) & 1) puts("Borys");
  else puts("Alice");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, ans = 0, j = 1;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a == j) {
      j++;
    }
    else {
      ans++;
    }
  }
  if (ans == N) {
    ans = -1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
S = input()
T = input()

n = len(S)
l = len(T)

for i in range(n-l+1)[::-1]:
  cnt = 0
  for j in range(l):
    if S[i+j] == "?" or S[i+j] == T[j]:
      cnt += 1
  
  if cnt == l:
    S = list(S[:i] + T + S[i+l:])
    for k in range(n):
      if S[k] == "?":
        S[k] = "a"
    print("".join(S))
    break
    
else:
  print("UNRESTORABLE")

Measured memory_bytes: 9064
#include<stdio.h>
double a,b,aa,bb,ans;
int main(void){
    scanf("%lf%lf%lf%lf",&a,&b,&aa,&bb);
    ans = a*b/2;
    printf("%lf",ans);
    if(a/2==aa&&b/2==bb){
        printf(" 1");
    }else{
        printf(" 0");
    }
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}
vector<int>g[210000];
char in[210000];


vector<int>scc_g[410000];
vector<int>scc_rev[410000];
int v[410000]; // used twice
int num[410000]; // inverse of conv
int conv[410000]; // dfs order of i-th vertex. note that it's kaerigake ordered
int scc[410000]; // the index of scc containing i-th vertex
int fi[410000]; // the first element of each scc
int ss[410000]; // size of each scc
int cur;
void dfs(int a){
	for(int i=0;i<scc_g[a].size();i++){
		if(v[scc_g[a][i]])continue;
		v[scc_g[a][i]]=1;
		dfs(scc_g[a][i]);
	}
	conv[a]=cur;
	num[cur++]=a;
}
void dfs2(int a){
	scc[a]=cur;
	ss[cur]++;
	for(int i=0;i<scc_rev[a].size();i++){
		if(v[scc_rev[a][i]])continue;
		v[scc_rev[a][i]]=1;
		dfs2(scc_rev[a][i]);
	}
}

int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s",in);
	for(int i=0;i<b;i++){
		int p,q;scanf("%d%d",&p,&q);p--;q--;
		g[p].push_back(q);
		g[q].push_back(p);
	}
	for(int i=0;i<a;i++){
		for(int j=0;j<g[i].size();j++){
			int to=g[i][j];
			if(in[i]!=in[g[i][j]]){
				scc_g[i*2].push_back(g[i][j]*2+1);
				scc_rev[g[i][j]*2+1].push_back(i*2);
			}else{
				scc_g[i*2+1].push_back(g[i][j]*2);
				scc_rev[g[i][j]*2].push_back(i*2+1);
			}
		}
	}
	int n=a*2;
	for(int i=0;i<n;i++){
		if(v[i])continue;
		v[i]=1;
		dfs(i);
	}
	cur=0;
	for(int i=0;i<n;i++)v[i]=0;
	for(int i=n-1;i>=0;i--){
		if(v[num[i]])continue;
		v[num[i]]=1;
		fi[cur]=num[i];
		dfs2(num[i]);
		cur++;
	}
	for(int i=0;i<cur;i++){
		if(ss[i]>=4){
			printf("Yes\n");return 0;
		}
	}printf("No\n");
}


Measured memory_bytes: 64000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int score = 0;
		int lowest = 0;
		for (int i = 0; i < n; i++) {
			int x = sc.nextInt();
			if (x % 10 != 0) {
				if (lowest == 0) {
					lowest = x;
				}
				if (x < lowest) {
					lowest = x;
				}
			}
			score += x;
		}
		if (score % 10 > 0) {
			System.out.println(score);
		} else {
			score -= lowest;
			if (score % 10 > 0) {
				System.out.println(score);
			} else {
				System.out.println("0");
			}
		}
		sc.close();
	}
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a')  cout << "vowel" << endl;
  else if (c == 'e')  cout << "vowel" << endl;
   else if (c == 'i')  cout << "vowel" << endl;
   else if (c == 'o')  cout << "vowel" << endl;
  else if (c == 'u') cout << "vowel" << endl;
else cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
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;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n, m;
	cin >> n >> m;
	vector<int> d(n), c(m);
	rep(i, n) cin >> d[i];
	rep(i, m) cin >> c[i];
	int dp[1001][1001];
	Fill(dp, MOD);
	rep(i, m) dp[0][i] = 0;

	rep(i, n) {
		rep(j, m) {
			chmin(dp[i+1][j+1], dp[i][j] + d[i] * c[j]);
			chmin(dp[i+1][j+1], dp[i+1][j]);
		}
	}
	cout << dp[n][m] << endl;
	return 0;
}


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

#define f(i,a,b) for( ll i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;	


using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;

/*
typedef tree<
ll,
null_type,
less<ll>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
 
const ll MAX = 1e6+10;
const ll inf = 1e9;

ll mod = 1e9+7;
ll fac[MAX];

ll bp(ll a,ll e){
	if(e==0) return 1LL;
	if(e&1) return (a*bp(a,e-1))%mod;
	ll x = bp(a,e>>1);
	return (x*x)%mod;
}

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

ll comb(ll a,ll b){
	if(a<b) return 0;
	return  (fac[a]* inv( (fac[b]*fac[a-b] )%mod ) )%mod;
}
ll per(ll a,ll x){
	return (fac[a]*inv(fac[a-x]))%mod;
}

ll pf[MAX];
int main(){
	fastio;
	fac[0] = 1;
	f(i,1,MAX) fac[i] = (fac[i-1]*i)%mod;
	ll n,m;
	cin>>n>>m;
	ll ans = 0;
	
	ll ac = 0;
	f(k,0,n+1){
		ll aux = (comb(n,k) * per(m,k) ) %mod;
		ll aux1 = per(m-k,n-k);
		ll sta = (aux*((aux1*aux1)%mod))%mod; 
		if(k&1) ans = (ans-sta+mod)%mod;
		else ans = (ans+sta+mod)%mod;
	}
	cout<< ans <<endl;

}

Measured memory_bytes: 11392
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
#define pi 3.1415926535897932384
using namespace std;

ld r;

int main()
{

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

    cin >> r;
    cout << (r+r)*pi;

    return 0;
}


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


int recur(int*arr,int n,int*dp){

	dp[1]=0;
	dp[2]=abs(arr[2]-arr[1]);
	for(int i=3;i<=n;i++){
			int a=dp[i-1]+abs(arr[i]-arr[i-1]);
			int b=dp[i-2]+abs(arr[i]-arr[i-2]);
			dp[i]=min(a,b);
	}
	return dp[n];

}

int main(){

	int n;
	cin>>n;
	int arr[100005];
	arr[0]=0;
	for(int i=1;i<=n;i++){
		cin>>arr[i];
	}
   int dp[100004]={0};
   cout<< recur(arr,n,dp)<<endl;


	return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  int n,t;
  cin >> n >> t;
  vector<P> a(n);
  rep(i,n){
    cin >> a[i].F >> a[i].S;
  }
  sort(a.begin(),a.end());

  vector<vector<ll>> dp(3010, vector<ll>(6010,0));
  rep(i,n)rep(j,6005){
    dp[i+1][j] = dp[i][j];
    if(j-a[i].F>=0 && j-a[i].F<t){
      dp[i+1][j] = max(dp[i+1][j], dp[i][j-a[i].F] + a[i].S);
    }
  }
  ll ans = 0;
  rep(i,6005){
    ans = max(ans, dp[n][i]);
  }
  cout << ans << ln;
  return 0;
}

Measured memory_bytes: 141696
/* 
  		!!~~~~~~~~~~~~~~~~~~     
  	#include < ~_~ Ajay > 
 	 	~~~~~~~~~~~~~~~~~~~~!!   
*/

#include<iostream>
#include<map>
#include<list>
#include<queue>
#include<vector>
#include<algorithm>
#include<climits>

using namespace std;

#define int long long
#define lmax LLONG_MAX
#define lmin LLONG_MIN
#define pb push_back
#define mp make_pair
#define f   first
#define s   second    
#define vi   vector<int> 
#define vpii   vector<pair<int,int> >
#define varr   vector<int> v[1000000]
#define mii    map<int,int>
#define msi    map<string,int>
#define mlist  map<int,list>

#define wloop   int t\
               ;cin>>t\
               ;while(t--)
#define forxNi(x,n) for(int i=x;i<n;i++)
#define forxNj(x,n) for(int j=x;j<n;j++)
#define forNxi(n,x) for(int i=n;i>=x;i--)
#define forNxj(n,x) for(int j=n;j>=x;j--)
#define endl  		'\n'

#define fastio ios_base::sync_with_stdio(0)\
               ;cin.tie(0)\
               ;cout.tie(0)

//------Code begins--->

int32_t main(){
	fastio;
	{int n,W;
		cin>>n>>W;
		int wt[n+1],val[n+1];
		forxNi(1,n+1){
			cin>>wt[i]>>val[i];
		}
		int dp[n+1][W+1];
		forxNi(0,n+1){
			forxNj(0,W+1){
				if(i==0 or j==0)dp[i][j]=0;
			}
		}
		forxNi(1,n+1){
			forxNj(1,W+1){
				if(wt[i]<=j)
					dp[i][j]=max(dp[i-1][j],val[i]+dp[i-1][j-wt[i]]);
				else 
					dp[i][j]=dp[i-1][j];
			}
		}

		// forxNi(0,n+1){
		// 	forxNj(0,W+1){
		// 		cout<<dp[i][j]<<" ";
		// 	}
		// 	cout<<endl;
		// }
		cout<<dp[n][W];
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 82436
#include <bits/stdc++.h>
using namespace std;
int main(void){
    //int a,b,c;
    string a,b,c;
    cin>>a>>b>>c;
    cout<<(char)toupper(a[0])<<(char)toupper(b[0])<<(char)toupper(c[0])<<endl;
    return 0;
}


Measured memory_bytes: 256