akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
const long long inf = 1000000001; // const 書き換え禁止
const double PI = 3.14159265358979323846; //M_PI はライブラリ

int main(void){
    string s,t;
    cin >> s;
    t = s;
    int count = 0;
    reverse(t.begin(),t.end());
    rep(i,s.size()){
        if(s[i] != t[i]){
            count++;
        }
    }
    cout << count/2 << endl;
}

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


void solve(long long n, long long m, long long d){
    double ans;
    if(d == 0) {
        ans = (double (m-1)/ (double) n);
    }
    else{
        ans = 2. * (n-d) / n * (m-1) / n;
    }
    cout << setprecision(10) << ans << endl;
}

int main(){
    long long n;
    scanf("%lld",&n);
    long long m;
    scanf("%lld",&m);
    long long d;
    scanf("%lld",&d);
    solve(n, m, d);
    return 0;
}


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

using namespace std;

int main() {
	int n;
	cin >> n;
	long long int a[n];
	for(int i = 0; i < n; i++) {
		cin >> a[i];
	}
	long long int sum[n + 1];
	sum[0] = 0LL;
	for(int i = 0; i < n; i++) {
		sum[i + 1] = sum[i] + a[i];
	}

	map<long long int,long long int> m;
	long long int ans = 0LL;
	
	for(int i = 0; i < n+1; i++) {
		ans += m[sum[i]];
		m[sum[i]] = m[sum[i]]+1LL;
	}
	cout << ans << endl;

}


Measured memory_bytes: 15872
N = int(input())
A = list(map(int, input().split()))

B = []
tmp = -1
for a in A:
    if a != tmp:
        B.append(a)
        tmp = a

if len(B) == 1:
    print(1)
    exit()

def f(A):
    ans = 1
    n = len(A)
    if A[0] < A[1]:
        ff = 1
    else:
        ff = -1
    for i in range(1, n - 1):
        if ff == 0:
            if A[i] < A[i + 1]:
                ff = 1
            else:
                ff = -1
        elif ff == 1:
            if A[i] > A[i + 1]:
                ans += 1
                ff = 0
        else:
            if A[i] < A[i + 1]:
                ans += 1
                ff = 0
    return ans

print(f(B))


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

int main() {
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> a(n), b(n, 1e9 + 7);
    ll ans = 1e18;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int k = 0; k < n; k++) {
        ll cnt = 0;
        for (int i = 0; i < n; i++) {
            b[i] = min(b[i], a[(i - k + n) % n]);
            cnt += b[i];
        }
        ans = min(ans, cnt + k * x);
    }
    cout << ans << endl;
    return 0;
}

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

c = []
ans = pow(10, 9)

for i in range(n):
    c.append(list(map(int, input().split())))
for mask in range((1 << n) - 1):
    sum = 0
    li = [0] * m
    for i in range(n):
        if (mask >> i) & 1 == 0:
            sum += c[i][0]
            for j in range(m):
                li[j] += c[i][j+1]
    check = True
    for j in range(m):
        if li[j] < x:
            check = False
            break
    if check:
        ans = min(sum, ans)

if ans == pow(10, 9):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define BIT(n) (1LL << (n))
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPB(i, n) for (int i = 0; i < BIT(n); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORA(i, n) for (auto &&i : n)
#define FORS(i, m, n) for (int i = m; i <= n; i++)
#define DEBUG(x) cerr << #x << ": " << x << "\n"
#define PRINTALL(V)                                                            \
  for (auto v : (V)) {                                                         \
    cerr << v << " ";                                                          \
  }                                                                            \
  cerr << "\n";
#define ALL(v) v.begin(), v.end()
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
#define epb emplace_back
#define int long long
using namespace std;
template < class T > bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template < class T > using vec = std::vector< T >;
template < class T > void print(const T &x) { cout << x << "\n"; }
const int MOD = 1000000007, INF = 1061109567;
const double EPS = 1e-10, PI = acos(-1.0);
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const int FACTSIZE = 100100;
int fact[FACTSIZE];
int revfact[FACTSIZE];
int binpow(int a, int b, int mo) {
  int ans = 1;
  do {
    if (b & 1)
      ans = 1ll * ans * a % mo;
    a = 1ll * a * a % mo;
  } while (b >>= 1);
  return ans;
}
void init() {
  fact[0] = 1, revfact[0] = 1;
  for (int i = 1; i < FACTSIZE; ++i) {
    fact[i] = fact[i - 1] * i % MOD;
    revfact[i] = binpow(fact[i], MOD - 2, MOD);
  }
}
signed main() {
  cin.tie(0), ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  init();
  int N;
  cin >> N;
  vec< int > pos(N, -1);
  int ans = 0;
  REP(i, N + 1) {
    int p;
    cin >> p;
    p--;

    if (pos[p] != -1) {
      ans = pos[p] + N - i;
    }
    pos[p] = i;
  }

  // N+1 C i - ans C i-1
  int valN = fact[N + 1];
  int valAns = fact[ans];
  REPS(i, N + 1) {
    int tmp = valN;
    tmp *= revfact[i];
    tmp %= MOD;
    tmp *= revfact[N + 1 - i];
    tmp %= MOD;
    if (i <= ans + 1) {
      int tmp2 = valAns;
      tmp2 *= revfact[i - 1];
      tmp2 %= MOD;
      tmp2 *= revfact[ans - (i - 1)];
      tmp2 %= MOD;

      tmp -= tmp2;
      tmp += MOD;
      tmp %= MOD;
    }
    print(tmp);
  }
}

Measured memory_bytes: 3584
/** author: __nishad__ **/
//#pragma GCC optimize(2)
//#pragma GCC optimize(3, "Ofast", "inline")
#include<bits/stdc++.h>
using namespace std;


typedef long long ll ;
typedef vector<ll> vll ;

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(v) (v).begin(),(v).end()
#define precision(k) cout<<setprecision(k)<<fixed;
#define loop(i,a,b) for(ll i=(a);i<(b);++i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define getpos(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define unq(v) sort(all(v)),(v).erase(unique((v).begin(),(v).end()),(v).end())
#define pb push_back
#define mp make_pair
#define pi 3.14159265358979323
#define endl "\n"

int main()
{
    IOS;

    int n, sum=0;
    cin>>n;

    int arr[n];
    bool check = true;

    loop(i, 0, n){
        cin>>arr[i];
    }

    while(check){
        loop(i, 0, n){
            if(arr[i]%2 == 0){
                arr[i] = arr[i]/2;
            }
            else
                check = false;
        }
        sum++;
    }

    cout<<sum-1;

}





























Measured memory_bytes: 3660
import java.util.*;
 
public class Main {
  
  public static void main(String[] args) {
    
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    String str = sc.next();
    
    if (num >= str.length()) {
      System.out.println(str);
    }
    else {
      System.out.println(str.substring(0, num) + "...");
    }
  }
}

Measured memory_bytes: 38476
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using P=pair<int,int>;
int inf=1e9;
queue<P> que;
vector<int>dx={0,0,1,-1};
vector<int>dy={1,-1,0,0};

int main(){
	int h,w,k;cin>>h>>w>>k;
	vector<string>a(h);
	for(auto&& u:a)cin>>u;
	vector<vector<int>>d(h,vector<int>(w,inf));
	rep(i,h)rep(j,w)if(a[i][j]=='S'){que.push(make_pair(i,j));d[i][j]=0;}
	while(!que.empty()){
		P z=que.front();que.pop();
		rep(i,4){
			int x,y;x=z.first+dx[i];y=z.second+dy[i];
			if(x<0||x>=h||y<0||y>=w)continue;
			if(d[x][y]==inf&&a[x][y]=='.' ){
				d[x][y]=d[z.first][z.second]+1;
				que.push(make_pair(x,y));
			}			

		}
	}	
	int mn=inf;
	rep(i,h)rep(j,w){if(d[i][j]<=k)mn=min({mn,i,j,h-1-i,w-1-j});}
	if (mn==0)cout<<1<<endl; 
	else  cout<<(mn-1)/k+2<<endl;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i,3) if (s[i] == t[i]) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <numeric>
#include <stack>
#include <set>
#include <queue>
#include <list>
using namespace std;
typedef long long ll;

void solve() {
	ll k; cin >> k;
	int ans = -1;
	ll cur = 0;
	for (int i = 0; i < 1e6 + 1000; i++) {
		cur = (10 * cur) + 7;
		cur %= k;
		if (cur % k == 0) {ans = i + 1; break;}
	}
	cout << ans ;

}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif

	// int t; cin >> t;
	// while (t--)
	solve();

}

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

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n,t;
    cin >> n >> t;
    
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    int sum = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i+1] - a[i] < t) sum += a[i+1] - a[i];
        else sum += t;
    }
    sum += t;
    cout << sum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll INF = 1LL << 60;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

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

// 二項係数計算
ll COM(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/
/*
    cout << fixed << setprecision(15);
*/
int main(){
    ll N,M;
    cin >> N >> M;
    ll ans = 0;
    while(N){
        ans++;
        N /= M;
    }
    cout << ans << endl;
}

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> x(m),dist(m-1);
    for(int i=0; i<m; i++){
        cin >> x.at(i);
    }

    sort(x.begin(),x.end());

    for(int i=0; i<m-1; i++){
        dist.at(i)=x.at(i+1)-x.at(i);
        //cout << dist.at(i) << endl;
    }

    sort(dist.begin(),dist.end());

    long int ans=0;
    int i=0;
    while(i+n<m){
        ans+=dist.at(i);
        i++;
        //cout << i << endl;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3924
import java.util.Scanner;
public class Main
{
	static int n,s;
	static long ans;
	public static void main(String[] args) 
	{
		Scanner in =new Scanner(System.in);
		for(;;)
		{
			n=in.nextInt();
			s=in.nextInt();
			if((n|s)==0)
				return;
			ans=0;
			solve(0,0,0);
			System.out.println(ans);
		}
	}
	public static void solve(int i,int sum,int N)
	{
		if(sum==s&&N==n)
		{
			ans++;
			return;
		}
		if(i>=10||sum>s)
			return;
		solve(i+1,sum,N);//数iを使わない
		solve(i+1,sum+i,N+1);//数iを使う
		return;
	}
}

Measured memory_bytes: 16228
#include<stdio.h>

int main(void)

{
	int a, b, c, x;
	scanf("%d %d %d",&a, &b, &c);
	if (a > b) {
		x = a;
		a = b;
		b = x;
	}
	if (b > c) {
		x = b;
		b = c;
		c = x;
	}
	if (a > b) {
		x = a;
		a = b;
		b = x;
	}
	printf("%d %d %d\n",a, b, c);
	return 0;
}


Measured memory_bytes: 2044
/*
    Created by 10_months
    Tag:
    Link:
*/

#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
                
using namespace std;

const long long inf = 1e17;
const int INF = 1e9;
const int N = 1234567;
const int M = 123456;

int n, odd;
                         
int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        if (x % 2 == 1) odd++;
    }
    if (odd % 2 == 0) puts("YES");
    else puts("NO");
    return 0;
}

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

const int MAXN = 2E5+2;

int n;
vector<pair<long long, int> > a(MAXN);
vector<bool> b(MAXN, 0);
vector<pair<int,int> > v;

long long pairing(long long X){
	int l = 0, r = 60, msb = 60;
	while(l<=r){
		int mid = (l+r)>>1;
		long long val = (1LL << mid);
		if(val > X) msb = mid, r = mid-1;
		else l = mid+1;
	}
	return (1LL<<msb) - X;
}

int main() {
	// your code goes here
	cin >> n;
	for(int i=1; i<= n; ++i){
		cin >> a[i].first; a[i].second = i;
	}
	sort(a.begin()+1, a.begin()+n+1);
	for(int i=n; i>= 1;--i){
		if(b[i]) continue;
		long long X = pairing(a[i].first);
		int l = 1, r = i-1, j = -1;
		while(l<=r){
			int mid = (l+r)>>1;
			
			if(a[mid].first < X) l = mid+1;
			else if(a[mid].first > X) r =mid-1;
			else if(b[mid]) l = mid+1;
			else j = mid, r = mid-1;
		}
		if(j!= -1){
			v.push_back({a[i].second, a[j].second});
			b[j] = b[i] = 1;
		}
	}
	cout << v.size() << "\n";
	return 0;
}

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

int main() {
  int _, g, b;
  cin >> _ >> g >> b;

  bool ng = ((g*10) + b) % 4;

  if (!ng) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
/**
>>> In The Name Of GOD
**/
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> pii;
typedef pair <ll,ll> pll;

#define pb push_back
#define pp pop_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define F first
#define S second
#define bs binary_search
#define smin(x,y) (x) = min((x) ,(y))
#define smax(x,y) (x) = max((x) ,(y))
#define sz(x) (int)(x).size()
#define ssz(x) (int)(x).length()
#define all(x) (x).begin(),(x).end()

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

///ifstream fin("input.txt");
///ofstream fout("output.txt");


/*bool cmp_pair_F_2(pair <int,int> x, pair <int,int> y)
{
    return x.F>y.F;
}
bool cmp_pair_S_2(pair <int,int> x, pair <int,int> y)
{
    return x.S>y.S;
}
bool cmp_pair_S_1(pair <int,int> x, pair <int,int> y)
{
    return x.S<y.S;
}*/

bool cmp(int x, int y)
{
	return x>y;
}



int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //int i,j;
    ll n,x;
    cin >> n >> x;
    ll d[n+1];
    d[0]=0;
    for (int i=1;i<=n;i++)
    {
        ll y;
        cin >> y;
        d[i]=d[i-1]+y;
        if (d[i]>x)
            return cout << i,0;
    }
    cout << n+1;
    return 0;
}


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

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

struct Data {
  int num;
  Data() : num(0x7FFFFFFF) {}
  Data(int n) : num(n) {}
};

inline Data Merge(Data left, Data right) {
  return Data(left.num < right.num ? left.num : right.num);
}

struct SegmentTree {
  static const int STsize = 1 << 18;
  Data data[STsize]; int n;
  SegmentTree(void) : n(STsize / 2) {}
  void update (int pos, Data value) {
    data[pos] = value;
    while (pos < 2*n-1) {
      int l = pos, r = pos^1;
      pos = pos / 2 + n;
      data[pos] = Merge(data[l], data[r]);
    }
  }
  Data sub(int fr, int to, int node, int la, int ra) {
    if (ra<=fr || to<=la) return Data();
    if (fr<=la && ra<=to) return data[node];
    Data vl = sub(fr, to, (node-n)*2+0, la, (la+ra)/2);
    Data vr = sub(fr, to, (node-n)*2+1, (la+ra)/2, ra);
    return Merge(vl, vr);
  }
  Data query(int fr, int to) { return sub(fr, to, 2*n-2, 0, n); }
};

int main() {
  SegmentTree sgt;
  int n,q;
  cin >> n >> q;
  REP(i,n) {
    sgt.update(i, 0x7FFFFFFF);
  }
  REP(i,q) {
    int c, x, y;
    cin >> c >> x >> y;
    if(c == 0) {
      sgt.update(x, y);
    } else {
      cout << sgt.query(x, y+1).num << endl;
    }
  }
  return 0;
}

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

class Point {
public:
  double x, y;
  Point(double x=0, double y=0) : x(x), y(y) {}
};

double dist(Point p1, Point p2) {
  return sqrt(pow(p1.x-p2.x, 2.0)+pow(p1.y-p2.y, 2.0));
}

double LawOfCosines(double a, double b, double c) {
  return acos( (b*b+c*c-a*a) / (2.0*b*c) );
}

Point circumcenter(Point pa, Point pb, Point pc) {
  /*
  double A = abs(atan2(pb.y-pa.y, pb.x-pa.x) - atan2(pc.y-pa.y, pc.x-pa.x));
  double B = abs(atan2(pa.y-pb.y, pa.x-pb.x) - atan2(pc.y-pb.y, pc.x-pb.x));
  double C = abs(atan2(pa.y-pc.y, pa.x-pc.x) - atan2(pb.y-pc.y, pb.x-pc.x));
  */
  double a = dist(pb, pc);
  double b = dist(pa, pc);
  double c = dist(pa, pb);
  double A = LawOfCosines(a, b, c);
  double B = LawOfCosines(b, c, a);
  double C = LawOfCosines(c, a, b);
  return Point((pa.x*sin(A*2)+pb.x*sin(B*2)+pc.x*sin(C*2))
	       /(sin(A*2)+sin(B*2)+sin(C*2)),
	       (pa.y*sin(A*2)+pb.y*sin(B*2)+pc.y*sin(C*2))
	       /(sin(A*2)+sin(B*2)+sin(C*2))
	       );
}

main() {
  Point p[3];
  Point op;
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) {
    for(int j = 0; j < 3; j++) cin >> p[j].x >> p[j].y;
    op = circumcenter(p[0], p[1], p[2]);
    /*double A = abs(atan2(p[1].y-p[0].y, p[1].x-p[0].x)
		   - atan2(p[2].y-p[0].y, p[2].x-p[0].x));*/
    printf("%.3f %.3f %.3f\n", op.x, op.y, dist(op,p[0]));
  }
}

Measured memory_bytes: 0
import java.io.{BufferedReader, InputStreamReader}
import java.util

object Main extends App {
  val in = new BufferedReader(new InputStreamReader(System.in))
  val n = in.readLine.toInt
  val a, b, c = in.readLine.split(" ").map(_.toInt)

  util.Arrays.sort(a)
  util.Arrays.sort(b)
  util.Arrays.sort(c)
  
  val ans = {
      var posA, posC = 0

      def findA(tar:Int):Int = {
        while(posA < n && a(posA) < tar) posA += 1
        posA
      }
      def findC(tar:Int):Int = {
        while(posC < n && c(posC) <= tar) posC += 1
        posC
      }

      b./:(0L)((acc,e) => {
        val ac = findA(e)
        val cc = n - findC(e)

        acc +  ac.toLong * cc.toLong
      })
    }

  println(ans)
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "YES" << '\n'; exit(0); }
inline void no() { cout << "NO" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  vi32 cnt(4);
  rep(i, 3) {
    int a, b; cin >> a >> b;
    a--, b--;
    cnt[a]++, cnt[b]++;
  }
  rep(i, 4) if (cnt[i] >= 3) no();
  yes();
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll p[55];
ll f(ll n, ll x){
    if(n == 0) return 1;
    if(x == 1) return 0;
    if(x == p[n+2] - 3) return p[n+1] - 1;
    ll res = 0;
    if(x == p[n+1] - 1){
        return p[n];
    }
    if(x > p[n+1] - 1){
        res += p[n];
        x -= p[n+1] - 1;
    }else x--;
    
    return res + f(n-1, x);
}
int main() {
    ll n, x;
    cin >> n >> x;
    p[0] = 1;
    for(int i=1;i<55;i++) p[i] = p[i-1] * 2;
    cout << f(n, x) << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
idx = [i for i in range(1, n+1)]
a = [int(inp) - i for inp, i in zip(input().split(), idx)]
a.sort()
if n % 2 == 0:
    med = (a[(n-2)//2] + a[(n-2)//2+1])//2
else:
    med = a[(n-1)//2]
ans = 0
for ai in a:
    ans += max(ai-med, -ai+med)
print(ans)

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

int main() {
    int N, Y;
    cin >> N >> Y;
    int res10000 = -1, res5000 = -1, res1000 = -1;
    for (int a = 0; a <= N; ++a) {  // 10000円の枚数を 0 〜 N で調べる
        for (int b = 0; b + a <= N; ++b) {  // 5000円の枚数を 0 〜 N-a で調べる
            int c = N - a - b;  // 1000円の枚数は決まる
            int total = 10000*a + 5000*b + 1000*c;
            if (total == Y) {  // 答えが見つかったら
                res10000 = a;
                res5000 = b;
                res1000 = c;
            }
        }
    }

    // 答えを出力 (見つかっていなくても -1 -1 -1 になるので OK です)
    cout << res10000 << " " << res5000 << " " << res1000 << endl;
}


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

typedef int keytype;

//quicksort(<#keytype *a#>, <#int first#>, <#int last#>)

void quicksort(keytype a[], int first, int last){
    int i, j;
    keytype x, t;
    
    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int gcd(int x, int y){
    if (y == 0) return x;
    else        return gcd(y, x % y);
}

int main() {
    int n,k,a[200000],sa[200000];
    int i,max=0;
    scanf("%d %d",&k,&n);
    for (i=0; i<n; i++) scanf("%d",&a[i]);
    for (i=0; i<n-1; i++) {
        sa[i]=a[i+1]-a[i];
    }
    sa[n-1]=k-a[n-1]+a[0];
    quicksort(sa, 0, n-1);
    printf("%d",k-sa[n-1]);
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <string>
using namespace std;
int main(void){
  string s;
  bool can;
  cin >> s;
  if(s.length()%2==1){
    s.erase(s.end()-1,s.end());
  }else{
    s.erase(s.end()-2,s.end());
  }
  while(true){
    int st = s.length()/2;
    can = true;
    for(int i=0;i<st;i++){
      if(s[i]!=s[i+st]){
        can=false;
        break;
      }
    }
    if(can){
      cout << s.length()<<endl;
      break;
    }else{
      s.erase(s.end()-2,s.end());
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <stack>
#include <math.h>

using namespace std;

typedef long long int ll;
typedef long double ld;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define vsort(a) sort(a.begin(), a.end())
#define rev(a) reverse(a.begin(), a.end())


// a,bの最小公倍数
ll LCM(ll a, ll b){ll lcm = a * b; ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return lcm /= b;}
// a,bの最大公約数
ll GCD(ll a, ll b){ll r = a % b;while(r != 0){a = b; b = r; r = a % b;}return b;}


const int MOD = 1000000007;
const int INF = INT_MAX;



int main(){


    int d[5];
    rep(i,5) cin >> d[i];

    int mn = 10;
    rep(i,5){
        if (d[i]%10 != 0 && d[i]%10 < mn) mn = d[i]%10;
    }

    int sum = 0;
    rep(i,5){
        if (d[i]%10 == 0) sum += d[i];
        else sum += (d[i]/10 + 1) * 10;
    }
    sum -= 10 - mn;


    cout << sum << endl;


}





//              g++ -std=c++1z


Measured memory_bytes: 888
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

bool ans;
int N, L;
string S;

bool isPalindrome(string S){
    bool flag = true;

    int K = S.size();

    if(K==2){
        return S[0] == S[1];
    }

    rep(i, (K-1)/2){
        if(S[i] != S[K - 1 - i]){
            // cout << S[i] << " " << S[K - 1 - i] << endl;
            flag = false;
            break;
        }
    }

    return flag;
}

void solve(){
    L = (N-1)/2;

    // cout << S.substr(0,L) << endl;
    // cout << S.substr(L+1, L) << endl;

    if(isPalindrome(S) && isPalindrome(S.substr(0,L)) && isPalindrome(S.substr(L+1, L))){
        ans = true;
    } else{
        ans = false;
    }

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

int main(){
    cin >> S;
    N = S.size();

    solve();
}


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

int w[750][750];
int id[750];
int dp[750][750];
int main(){
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < m; i ++){
		int u, v;
		cin >> u >> v;
		w[u - 1][v - 1] = 1;
		w[v - 1][u - 1] = 1;
	}
	for(int i = 0; i < n; i ++) id[i] = -1;
	int cnt[2] = {0};
	bool f = 1;
	vector<pair<int, int> > ans;
	for(int step = 0; step < n; step ++){
		bool flag = 0;
		for(int i = 0; i < n; i ++){
			for(int j = 0; j < n; j ++){
				if(i == j) continue;
				if(!w[i][j]){
					if(id[i] == -1 && id[j] == -1){
					}
					else {
						if(id[i] == id[j]){
							f = 0;
							break;
						}
						else if(id[i] != -1 && id[j] != -1){
							
						}
						else if(id[i] != -1) id[j] = 1 - id[i], cnt[1 - id[i]] ++, flag = 1;
						else id[i] = 1 - id[j], cnt[id[i]] ++, flag = 1;
					}
				}
			}
		}
		if(!flag){
			ans.emplace_back(cnt[0], cnt[1]);
			cnt[0] = 0, cnt[1] = 0;
			for(int i = 0; i < n; i ++){
				if(id[i] == -1){
					id[i] = 0;
					cnt[0] ++;
					break;
				}
			}
		}
	}
	ans.emplace_back(cnt[0], cnt[1]);
//	for(int i = 0; i < ans.size(); i ++){
//		cout << ans[i].first << ' ' << ans[i].second << '\n';
//	}
	if(!f){
		cout << -1 << '\n';
		return 0;
	}
	dp[0][0] = 1;
	for(int i = 0; i < ans.size(); i ++){
		for(int j = 0; j <= n; j ++){
			if(!dp[i][j]) continue;
			dp[i + 1][j + ans[i].first] = 1;
			dp[i + 1][j + ans[i].second] = 1;
		}
	}
	int rlt = 1e9;
	for(int i = 0; i <= n; i ++){
		if(dp[ans.size()][i]){
			rlt = min(rlt, i * (i - 1) / 2 + (n - i) * (n - i - 1) / 2);
		}
	}
	cout << rlt << '\n';
}


Measured memory_bytes: 4480
import java.util.Scanner;

class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int x = sc.nextInt();
    int cnt = x / 100;
    int rem = x % 100;
    
    if(cnt*5 < rem){
      System.out.println(0);
    }else{
      System.out.println(1);
    }
    
  }
}


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

int main(){
    int n, m; cin >> n >> m;
    scc_graph data(n);
    for (int i = 0; i < m; i++) {
        int a, b; cin >> a >> b;
        data.add_edge(a, b);
    }
    auto ans = data.scc();
    cout << (int)ans.size() << "\n";
    for (auto p : ans) {
        cout << (int)p.size() << " ";
        for (auto pp : p) cout << pp << " ";
        cout << "\n";
    }
    return 0;
}

Measured memory_bytes: 40584
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using ld = long double;
using pint = pair<int, int>;

template <class T>
using vec = vector<T>;
template <class T>
using vec2 = vector<vec<T>>;
template <class T>
using vec3 = vector<vec2<T>>;

constexpr int INF = numeric_limits<int>::max();
constexpr ll INFL = numeric_limits<ll>::max();
//constexpr ll MOD = 1000000007; // 10^9+7
constexpr ll MOD = 998244353;

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

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

vector<long long> fac, finv, inv;

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

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll modpow(ll x, ll n, const ll &mod)
{
    ll ret = 1;
    while (n > 0)
    {
        if (n & 1)
        {
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

ll N, M, K;

ll solve()
{
    ll ret = 0;
    for (int k = 0; k <= K; ++k)
    {
        ll a = 1;
        a *= M;
        a %= MOD;
        a *= modpow(M - 1, N - 1 - k, MOD);
        a %= MOD;
        a *= COM(N - 1, k);
        a %= MOD;
        ret += a;
        ret %= MOD;
    }
    return ret;
}

int main()
{
    COMinit(2 * 100000);
    cin >> N >> M >> K;
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 7848
#include <bits/stdc++.h>
using namespace std;
struct Node{
	int st,en,len;
}node[100005];
bool cmp(Node x,Node y){
	if(x.en==y.en) return x.len<y.len;
	return x.en<y.en;
}
int main(){
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		int x,len;
		cin>>x>>len;
		node[i].st=x-len;
		node[i].en=x+len;
		node[i].len=node[i].en-node[i].st;
	}
	sort(node,node+n,cmp);
	int tim=node[0].en,cnt=1;
	for(int i=1;i<n;i++){
		if(node[i].st>=tim){
			cnt++;
			tim=node[i].en;
		}
	} 
	cout<<cnt<<endl;
} 

Measured memory_bytes: 1408
#include<iostream>                                                                   
#include<cstdio>
#include<algorithm>
using namespace std;
static const int MAX=26; 
static const int NIL=-1;

typedef struct Node{
    int parent,left,right;
}Node;

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
    
    if(u==NIL)return;
    D[u]=d;
    setDepth(T[u].left,d+1);
    setDepth(T[u].right,d+1);
}

int setHeight(int u){
    int h1=0,h2=0;
    if(T[u].left!=NIL)
        h1=setHeight(T[u].left)+1;
    if(T[u].right!=NIL)
        h2=setHeight(T[u].right)+1;
    return H[u]=max(h1,h2);    
}
int getSibling(int u){
    if(T[u].parent==NIL) return NIL;
    if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
        return T[T[u].parent].left;
    if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
        return T[T[u].parent].right;
    return NIL;    
        
}                    
void print(int u){
    printf("node %d: ",u);
    printf("parent = %d, ",T[u].parent);
    printf("sibling = %d, ",getSibling(u));
    int deg=0;
    if(T[u].left!=NIL)deg++;
    if(T[u].right!=NIL)deg++;
    printf("degree = %d, ",deg);
    printf("depth = %d, ",D[u]);
    printf("height = %d, ",H[u]);

    if(T[u].parent==NIL) printf("root\n");
    else if(T[u].left==NIL&&T[u].right==NIL) printf("leaf\n");
    else printf("internal node\n");

    
}
int main(){
    int v,l,r,root=0;
    cin>>n;
    for(int i=0;i<n;i++)T[i].parent=NIL;
    for(int i=0;i<n;i++){
        cin>>v>>l>>r;
        T[v].left=l;
        T[v].right=r;
        if(l!=NIL) T[l].parent=v;
        if(r!=NIL) T[r].parent=v;
    }
    for(int i=0;i<n;i++){
        if(T[i].parent==NIL)
            root=i;
    }
    setDepth(root,0);
    setHeight(root);

    for(int i=0;i<n;i++) print(i);
    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (ll i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < int > a(N);
    REP(i,N) cin >> a[i];

    int Nim = 0;
    REP(i,N) Nim |= (a[i] & 1);

    if (Nim == 1) {
        cout << "first" << endl;
    } else {
        cout << "second" << endl;
    }

    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define next Next
#define int long long
const int N=1e6+5;
int n,gs,ans,c[N],a[N];
vector<int>g[N];
char s[N];
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int lowbit(int x)
{
	return x&-x;
}
int sum(int x)
{
	int res=0;
	while(x>0)
	{
		res+=c[x];
		x-=lowbit(x);
	}
	return res;
}
void add(int x,int y)
{
	while(x<=n)
	{
		c[x]+=y;
		x+=lowbit(x);
	}
}
signed main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=1;i<=n;i++)
		g[s[i]-'a'].push_back(i);
	for(int i=0;i<26;i++)
	{
		int m=g[i].size();
		if(m%2==1)gs++;
		for(int j=0;j<m;j++)
			a[g[i][j]]=g[i][m-j-1];
	}
	if(gs>1){puts("-1");return 0;}
	for(int i=1;i<=n;i++)
	{
		ans+=sum(a[i]);
		add(a[i],1);
	}
	cout<<ans/2;
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

string n;
signed main() {
  cin >> n;
  for(int i=0;i<3;i++){
    if(n[i]=='1')cout<<'9';
    else cout<<'1';
  }
  cout<<endl;
}


Measured memory_bytes: 256
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, accumulate
import itertools
import heapq
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def print_matrix(mat):
    for i in range(len(mat)):
        print(*mat[i])


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    N, H = MI()
    a = []
    b = []

    for i in range(N):
        _a, _b = MI()
        heappush(b, -1 * _b)
        heappush(a, -1 * _a)

    largest_a = -1 * heappop(a)
    count = 0

    while H > 0:
        damage = -1 * heappop(b)
        if largest_a > damage:
            break

        H -= damage
        count += 1

        if len(b) == 0:
            break

    H = max(H, 0)
    # print(count)
    # print((H + largest_a - 1) // largest_a)

    print((H + largest_a - 1) // largest_a + count)


if __name__ == '__main__':
    main()


Measured memory_bytes: 60076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();
            string[] strs = line.Split(' ');
            int X = int.Parse(strs[0]);
            int Y = int.Parse(strs[1]);

            if (Y >= X * 2 && Y <= X*4 && Y % 2 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


Measured memory_bytes: 27028
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define jaldi_chal  ios_base::sync_with_stdio(0); cin.tie(0);
#define tr(c,i) for(auto i=(c).begin(); i != (c).end(); i++)
#define REP(i,k) for( ll i=0;i<k;i++)
#define REW(i,a,b) for(ll i=a;i<=b;i++)
#define MOD 1000000007
#define F first
#define dbg(x)  cout<<#x<<" " <<x<<endl;
#define S second
#define inf 1e10
#define endl "\n"
#define setbit(n) __builtin_popcount(n)
#define all(x) x.begin() , x.end()
#define clr(x) memset(x,0,sizeof(x))
ll power(ll a, ll b);
ll dp[100001];

ll vis[100001];

vector<ll> arr[100001];


void visit(ll node)
{
	vis[node] = 1;

	for (auto x : arr[node])
	{
		if (!vis[x])
		{
			visit(x);


		}
		dp[node] = max(dp[node], 1 + dp[x]);
	}


}


int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	jaldi_chal
	ll t = 1, i;
	// cin >> t;
	while (t--)
	{
		ll n, m;
		cin >> n >> m;

		set<ll> s;




		REW(i, 1, m)
		{
			ll u, v;
			cin >> u >> v;


			arr[u].push_back(v);
		}


		for (ll i = 1; i <= n; i++)
		{
			if (!vis[i]) visit(i);
		}


		ll ans = -1;

		for (ll i = 1; i <= n; i++)
		{
			ans = max(ans, dp[i]);
		}

		cout << ans << endl;













	}


	return 0;
}


ll power(ll a, ll b) {
	ll res = 1;
	while (b)
	{
		if (b % 2) b-- , res = res * a;
		else b = b / 2 , a *= a;
	}
	return res;
}

Measured memory_bytes: 13332
#include<stdio.h>
#include<string.h>
int main()
{
    int i,c=0;
    char s[100];
    gets(s);
  int  len=strlen(s);
    for(i=0;i<len;i++)
    {
       if(s[i]=='7')c++; 
    }
    if(c>0)printf("Yes\n");
    else printf("No\n");
   }

Measured memory_bytes: 1956
N,M,*A = `dd`.split.map &:to_i
twos = A.map{ |a| x = 0; while a > 0 && a % 2 == 0 do x += 1; a >>= 1; end; x }
if twos.min == 0 || twos.min < twos.max
  p 0; exit
end

B = A.map{ |a| a / 2 }
Y = B.reduce{ |a,b| a * b / a.gcd(b) }
p (M / Y + 1) / 2

Measured memory_bytes: 15240
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int ans = 0;
    for (int i = 1; i < n - 1; i++)
    {
        if (p[i - 1] > p[i] && p[i] > p[i + 1] || p[i - 1] < p[i] && p[i] < p[i + 1])
        {
            ++ans;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define LENGTH 256

int main(void){

  char judge[LENGTH];
  int N;
  int acCount = 0;
  int waCount = 0;
  int tleCount = 0;
  int reCount = 0;
  scanf("%d",&N);

  for(int i = 0; i < N; i++){
     scanf("%s", judge);

     if (strcmp(judge, "AC") == 0) {
       acCount++;
     } else if(strcmp(judge,"WA") == 0){
       waCount++;
     } else if(strcmp(judge,"TLE") == 0){
       tleCount++;
     } else {
       reCount++;
     }
  }

  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", acCount, waCount, tleCount, reCount);

  return 0;

}

Measured memory_bytes: 1732
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long ans = x/11*2;
		if(x % 11 > 6)
			ans += 2;
		else if(x % 11 > 0)
			ans++;
		System.out.println(ans);
	}

}

Measured memory_bytes: 21844
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>

using namespace std;

#define N 4
#define N2 16
#define LIMIT 45

const int dx[4] { -1, 0, 1, 0 };
const int dy[4] { 0, -1, 0, 1 };
const char dir[4] { 'u', 'l', 'd', 'r' };

int MDT[N2][N2];

struct Puzzle {
	int f[N2], space, MD;
};

int getAllMd(Puzzle p) {
	int sum = 0;
	for (int i = 0; i < N2; ++i) {
		if (p.f[i] == N2)
			continue;
		sum += MDT[i][p.f[i] - 1];
	}
	return sum;
}

Puzzle state;
int limit;
int path[LIMIT];
bool dfs(int depth, int prevR) {
	if (state.MD == 0)
		return true;
	if (depth + state.MD > limit)
		return false;

	int sx = state.space / N;
	int sy = state.space % N;
	Puzzle tmp;
	for (int r = 0; r < 4; ++r) {
		if (max(r, prevR) - min(r, prevR) == 2)
			continue;
		int tx = sx + dx[r];
		int ty = sy + dy[r];
		if (tx < 0 || ty < 0 || tx >= N || ty >= N)
			continue;
		tmp = state;
		state.MD -= MDT[tx * N + ty][state.f[tx * N + ty] - 1];
		state.MD += MDT[sx * N + sy][state.f[tx * N + ty] - 1];
		swap(state.f[sx * N + sy], state.f[tx * N + ty]);
		state.space = tx * N + ty;
		if (dfs(depth + 1, r)) {
			path[depth] = r;
			return true;
		}
		state = tmp;
	}
	return false;
}

string deepening(Puzzle p) {
	p.MD = getAllMd(p);
	for (limit = p.MD; limit <= LIMIT; ++limit) {
		state = p;
		if (dfs(0, -100)) {
			string ans;
			for (int i = 0; i < limit; ++i) {
				ans += dir[path[i]];
			}
			return ans;
		}
	}
	return "";
}

int main() {
	for (int i = 0; i < N2; ++i) {
		for (int j = 0; j < N2; ++j) {
			MDT[i][j] = abs(i / N - j / N) + abs(i % N - j % N);
		}
	}
	Puzzle p;
	for (int i = 0; i < N2; ++i) {
		scanf("%d", &p.f[i]);
		if (p.f[i] == 0) {
			p.f[i] = N2;
			p.space = i;
		}
	}
	string ans = deepening(p);
	cout << ans.size() << endl;

	return 0;
}

Measured memory_bytes: 3264
import string
from itertools import zip_longest

turn = int(input())
dic = {s: i for i, s in enumerate(string.ascii_lowercase)}
t_s, h_s = 0, 0

for _ in range(turn):
    t, h = input().split()
    if t == h:
        t_s += 1
        h_s += 1
    for t_c, h_c in zip_longest(t, h, fillvalue='a'):
        if dic[t_c] > dic[h_c]:
            t_s += 3
            break
        elif dic[t_c] < dic[h_c]:
            h_s += 3
            break

print(t_s, h_s)



Measured memory_bytes: 6720
#include <iostream>
#include <vector>
#include <algorithm>
#include <random>
#include <string>
#include <cmath>

using namespace std;
//int moreGcd
int N = 0;
vector<int > h;
int Min = 10000000;

/*
void search(int s, vector<int > cost){

    if(s == N ){
        int tempMin = 0;

        for(int i = 1; i < cost.size(); i++){
            tempMin += abs(cost[i - 1] - cost[i]);
        }

        if(Min > tempMin){
            Min = tempMin;
        }

    }else if(s > N ){
        //cout << s << endl;
        return;
        //ちょうど足場にたどり着いていなければ何もしません
    }

    cost.push_back(h[s]);

    search(s + 1, cost);
    search(s + 2, cost);


}
*/

int main(){
    
    cin >> N;

    int t = 0;

    for(int i = 0; i < N; i++){
        cin >> t;
        h.push_back(t);
    }
    
    vector<int > cost(N, 0);
    cost[0] = 0;
    cost[1] = abs(h[0] - h[1]);

    //for(int i = 1; i + 1 <= N - 1; i++){
    //    cost[i + 1] =  min(cost[i - 1] + abs (h[i - 1] - h[i + 1]), cost[i] + abs(h[i] - h[i + 1]));
    //}

    for(int i = 2; i  < N; i++){
        cost[i] = min(cost[i-2]+abs(h[i-2]-h[i]), cost[i-1]+abs(h[i]-h[i-1])); 
        //cout << cost[i] << endl; 
    }
    
    //search(0, cost);

    cout << cost[N-1] << endl;

}

Measured memory_bytes: 1144
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		long r=0,g=0,b=0;
		for(int i=0;i<N;i++) {
			if(S.charAt(i)=='R') {
				r++;
			}else if(S.charAt(i)=='G') {
				g++;
			}else {
				b++;
			}
		}
		long ans = r*g*b;
		for(int i=0;i<N;i++) {
			for(int j=i+1;j<N;j++) {
				int k = j+j-i;
				if (k < N && S.charAt(i) != S.charAt(j) && S.charAt(j) != S.charAt(k) && S.charAt(i) != S.charAt(k)) {
					ans--;
						}
			}
		}
		if(ans<=0) {
			System.out.println("0");
		}else {
			System.out.println(ans);	
		}
	}

}




Measured memory_bytes: 37172
#if 0
????????£????????????15m
????????????1.61s?????£????????????set??§?????????????????§?????????
unordered_set
#endif

#include <iostream>
#include <unordered_set>
#include <string>
using namespace std;

int main(){
	unordered_set<string> S;
	string cmd;
	string word;
	int n;
	cin>>n;
	for(int i=0;i<n;++i){
		cin>>cmd;
		if(cmd=="insert"){
			cin>>word;
			S.insert(word);
		}else if(cmd=="find"){
			cin>>word;
			if(S.count(word)==1)
				cout<<"yes"<<endl;
			else
				cout<<"no"<<endl;
		}
	}
}

Measured memory_bytes: 32068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long ;
int main(){
    int n,k;
    cin >> n >> k;
    int R,S,P;
    cin >> R >> S >> P;
    string kyotai;
    cin >> kyotai;
    ll ans=0;
    rep(i,n){
        if(i>=k){
            if(kyotai[i] == kyotai[i-k]){
                kyotai[i] = '?';
            }
            else{
                if(kyotai[i] == 'r') ans += P;
                else if(kyotai[i] == 's') ans += R;
                else if (kyotai[i] == 'p') ans += S;
            }
        }
        else{
            if(kyotai[i] == 'r') ans += P;
            else if(kyotai[i] == 's') ans += R;
            else if (kyotai[i] == 'p') ans += S;
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/dsu>
using namespace atcoder;
#include <math.h>
#include <vector>
#include <queue>
#include <iomanip>
#include <string>
#include <algorithm>
using Graph = vector<vector<int>>;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep_1 (i,j,n) for(int i=j;i<n;i++)
typedef long long ll;
const ll l_INF = 1010101010101010;
const int INF = 1010101010;
const int dx[4] = {-1,0,1,0};
const int dy[4] = {0,-1,0,1};
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvll = vector<vll>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(){
  int n,q; cin>>n>>q;
  dsu d(n);
  rep(i,q){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0) d.merge(u, v);
    else{
      if(d.same(u, v)) cout<<1<<endl;
      else cout<<0<<endl;
    }
  }
  return 0;
}


Measured memory_bytes: 3900