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

#define fi first
#define se second
#define show(x) cerr << #x << "=" << "\n"
typedef long long ll;
typedef unsigned long long ull;

using namespace std;
const ll llinf = LLONG_MAX;
const ull ullinf = ULLONG_MAX;

int n, m;
vector<pair<int, int> > v;
int dp[100001];


int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout << fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1 = freopen("in.txt", "r", stdin);
  //stream2 = freopen("out.txt", "w", stdout);
  if (stream1 == NULL) return 0;
  //if (stream2 == NULL) return 0;
#endif
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    v.push_back({b, a});
  }
  sort(v.begin(), v.end());
  int ans = 0;
  int l_cut = 0;
  int r_cut = 0;
  for (int i = 0; i < (int)v.size(); i++) {
    int right = v[i].fi;
    int left = v[i].se;
    if (i == 0) {
      l_cut = right - 1;
      r_cut = right;
      ans++;
    } else {
      if (left >= r_cut || right <= l_cut){
        l_cut = right - 1;
        r_cut = right;
        ans++;
      }
    }
  }
  cout << ans << endl;
#ifdef LOCAL_DEFINE
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << "s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}


Measured memory_bytes: 1400
from math import ceil
 
N, K = map(int,input().split())
A = sorted([int(i) for i in input().split()])
F = sorted([int(i) for i in input().split()],reverse=True)
# メンバーそれぞれが完食にかかる時間のリスト
cost = [A[i]*F[i] for i in range(N)]
 
# K回の修行でチーム成績がxになるか
def grade_is_x(x):
    training = 0
    for i in range(N):
        if cost[i] > x:
            training += ceil((cost[i]-x)/F[i])
            if training > K:
                return False
    return True
 
# 二分探索でxの最小値を求める
cost_max = max(cost)
ok = cost_max
ng = max(-1,max(cost)-K*F[cost.index(cost_max)])
while (ok - ng) != 1:
    mid = (ok + ng) // 2
    if grade_is_x(mid):
        ok = mid
    else:
        ng = mid
print(ok)

Measured memory_bytes: 122700
#include "bits/stdc++.h"
using namespace std;

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	cin >> n;
	cout << n / 3;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long LL;
#define N 1000 + 5
#define INF 0x3f3f3f3f

int n, mxid, Op[N];
LL odd, even, A[N];

int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i ++)
	{
		scanf("%lld", A + i);
		mxid = (!mxid || A[mxid] < A[i]) ? i : mxid;
	}
	if (A[mxid] <= 0)
	{
		printf("%lld\n", A[mxid]);
		printf("%d\n", n - 1);
		for (int i = n; i > mxid; i --)
			printf("%d\n", i);
		for (int i = 1; i < mxid; i ++)
			puts("1");
		return 0;
	}
	for (int i = 1; i <= n; i ++)
		A[i] = max(A[i], 0LL);
	for (int i = 1; i <= n; i += 2)
		odd += A[i];
	for (int i = 2; i <= n; i += 2)
		even += A[i];
	while (n > 1)
	{
		if (odd >= even)
		{
			if (n % 2 == 0 || A[n] <= 0)
				((n & 1) ? (odd -= A[n]) : (even -= A[n])), Op[++ Op[0]] = n --;
			else if (A[n - 2] > 0)
				even -= A[n - 1], Op[++ Op[0]] = n - 1, A[n - 2] += A[n], n -= 2;
			else if (n > 3)
				Op[++ Op[0]] = n - 2, A[n - 3] += A[n - 1], A[n - 2] = A[n], n -= 2;
			else swap(odd, even), Op[++ Op[0]] = n - 2, A[n - 2] = A[n - 1], A[n - 1] = A[n], n --;
		}
		else
		{
			if (n % 2 == 1 || A[n] <= 0)
				((n & 1) ? (odd -= A[n]) : (even -= A[n])), Op[++ Op[0]] = n --;
			else if (n == 2)
				odd = even, even = 0, Op[++ Op[0]] = n - 1, A[n - 1] = A[n], n --;
			else if (A[n - 2] > 0)
				odd -= A[n - 1], Op[++ Op[0]] = n - 1, A[n - 2] += A[n], n -= 2;
			else Op[++ Op[0]] = n - 2, A[n - 3] += A[n - 1], A[n - 2] = A[n], n -= 2;
		}
	}
	printf("%lld\n", A[1]);
	for (int i = 0; i <= Op[0]; i ++)
		printf("%d\n", Op[i]);
	return 0;
}

Measured memory_bytes: 128
n,m=(int(i) for i in input().split())
mtrx=[[int(i) for i in input().split()] for j in range(m)]
#print(mtrx)
mtrx+=[[mtrx[i][1],mtrx[i][0]] for i in range(m)]
#print(mtrx)
mylist=[10*mtrx[i][0]+mtrx[i][1] for i in range(len(mtrx))]
#print(mylist)
# 順列を格納するリスト
perm = []
cnt=[]
# 順列の生成
def make_perm(n, m = 0):
    if n == m and perm[0]==1:
        flag=1
        for i in range(len(perm)-1):
            myval=10*perm[i]+perm[i+1]
            myval1=mylist.count(myval)
            flag=flag*myval1
        cnt.append(flag)
        
    else:
        for x in range(1, n + 1):
            if x in perm: continue
            perm.append(x)
            make_perm(n, m + 1)
            perm.pop()
            
make_perm(n)
print(sum(cnt))


Measured memory_bytes: 3188
def s_in():
    return input()

def n_in():
    return int(input())

def l_in():
    return list(map(int, input().split()))

class Interval():
    def __init__(self, li):
        self.li = li
        self.n = len(li)
        self.sum_li = [li[0]]
        for i in range(1, self.n):
            self.sum_li.append(self.sum_li[i-1] + li[i])

    def sum(self, a, b=None):
        if b is None:
            return self.sum(0, a)

        res = self.sum_li[min(self.n-1, b-1)]
        if a > 0:
            res -= self.sum_li[a-1]
        return res

N = n_in()
X = l_in()

P1 = sum(X)//N
P2 = sum(X)//N + 1

print(min(sum((P1-x)**2 for x in X), sum((P2-x)**2 for x in X)));


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, n) cin >> p[i];
  int mn = INF, ans = 0;
  rep(i, n) {
    if (p[i] <= mn) {
      ans++;
      chmin(mn, p[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
// Palindromic Numbers

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

bool is_palidr(string str, int len) {
    bool res = true;

    for (int i = 0; i < len/2; i++) {
        if (str[i] != str[len - i - 1]) {
            res = false;
            return res;
        }
    }

    // 回文の場合
    return res;
}

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

    int res = 0;
    for (int i = stoi(a); i <= stoi(b); i++) {
        if (is_palidr(to_string(i), to_string(i).size())) {
            res++;
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;

int main(){
  int N, K;
  cin >> N >> K;
  int h[N];
  for(int i=0;i<N;i++) cin >> h[i];
  int dp[N];
  for(int i=0;i<N; i++) dp[i] = INT_MAX;
  dp[0] = 0;
  for(int i = 0 ; i <N; i++){
     for(int j = 1 ; j <= K; j++){
        if(i+j<N){ dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j])); }
     }
  }
  cout << dp[N-1] << endl;
  return 0;
}


Measured memory_bytes: 1024
// Try Educational DP Contest
// author: Leonardone @ NEETSDKASU

fn main() {
	let mut stdin = String::new();
	std::io::Read::read_to_string(
		&mut std::io::stdin(),
		&mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
	let mut get = || stdin.next().unwrap();
	macro_rules! get {
		($t:ty) => (get().parse::<$t>().unwrap());
		() => (get!(i64));
	}
	
	let n = get!(usize);
	let w = get!();
	let mut dp = vec![w + 1; n * 1000 + 1];
	dp[0] = 0;
	for _ in 0..n {
		let wi = get!();
		let vi = get!(usize);
		for j in 0..dp.len() {
			let j = dp.len() - 1 - j;
			if dp[j]+wi > w {
				continue;
			}
			dp[j+vi] = std::cmp::min(dp[j+vi],
				dp[j]+wi);
		}
	}
	let (ans,_) = dp.iter()
		.enumerate()
		.filter(|&(_,wi)| *wi <= w)
		.max().unwrap();
	println!("{}", ans);
}

Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
#include<random>
#include<ctime>
using namespace std;

const long long int mod=1000000007;
const long long int INF=99999999999999999;

string str;
long long int n,k,q,m,a[200000],b,cou=0,res=0,poi[200000]={};

queue<long long int>que,nextque;
int main() {
	cout << fixed << setprecision(10);
	cin>>n>>k>>q;
	for(int i=1;i<=n;i++){
		poi[i]=k-q;
	}
	for(int i=0;i<q;i++){
		cin>>a[i];
		poi[a[i]]++;
	}
	for(int i=1;i<=n;i++){
		if(poi[i]>0){
			cout<<"Yes"<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
} 


Measured memory_bytes: 2176
// 128-C
// Swiches

#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

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

    int N, K;

    cin >> N >> K;

    double prob = 0.0;

    for (int i = 0; i < N; i++)
    {

         prob += double(1.0 / N) * pow(0.5, max(0.0, ceil(log2(K / double(i + 1)))));

    }

    cout << setprecision(12) << prob << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 10000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
//typedef pair<ll, ll> P;
typedef pair<P, int> PI;
typedef pair<int, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

struct Circle {
  int x, y, r, c;
  //vector<int> from, to;
  //int rest;
  int req;
  Circle(int x, int y, int r, int c) : x(x), y(y), r(r), c(c), req(0) {}
  Circle() : req(0) {}
};

#define N 25

Circle cc[N];
vector<int> cv[5];
map<int, int> memo;

int n;
int solve(int state) {
  if(memo.find(state) != memo.end()) {
    return memo[state];
  }
  int rr = 0;
  repl(c, 1, 4) {
    vector<int> &v = cv[c];
    rep(im, v.size()) {
      int i = v[im];
      if(state & (1 << i) && (cc[i].req & state) == 0) {
        rep(jm, im) {
          int j = v[jm];
          if(state & (1 << j) && (cc[j].req & state) == 0) {
            int r = solve(state ^ (1 << i) ^ (1 << j)) + 2;
            rr = maxd(rr, r);
          }
        }
      }
    }
  }
  memo[state] = rr;
  return rr;
}

int main() {
  while(cin >> n && n) {
    rep(i, 5) cv[i].clear();
    memo.clear();
    rep(i, n) {
      int x, y, r, c;
      cin >> x >> y >> r >> c;
      cc[i] = Circle(x, y, r, c);
      cv[c].push_back(i);
      rep(j, i) {
        if(pow2(cc[i].x - cc[j].x) + pow2(cc[i].y - cc[j].y) < pow2(cc[i].r + cc[j].r)) {
          cc[i].req |= 1 << j;
        }
      }
    }
    cout << solve((1<<n)-1) << endl;
  }
  return 0;
}

Measured memory_bytes: 50372
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int a = int.Parse(Console.ReadLine());
        int b = int.Parse(Console.ReadLine());
        int c = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());

        int count = 0;

        for (int indexA = 0; indexA <= a; ++indexA)
        {
            for (int indexB = 0; indexB <= b; ++indexB)
            {
                for (int indexC = 0; indexC <= c; ++indexC)
                {
                    int sum = indexA * 500 + indexB * 100 + indexC * 50;

                    if (sum == x)
                    {
                        ++count;
                    }

                }

            }

        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
using namespace std;
vector<int>G[1<<17];
int n,m;
long a,b,c;
int v[1<<17];
bool dfs(int u,int col)
{
	v[u]=col;
	bool ans=1;
	for(int i=0;i<G[u].size();i++)
	{
		if(!v[G[u][i]])ans&=dfs(G[u][i],3-col);
		else
		{
			ans&=v[G[u][i]]==3-col;
		}
	}
	return ans;
}
main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int x,y;cin>>x>>y;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	for(int i=0;i++<n;)
	{
		if(!v[i])
		{
			if(G[i].size()==0)c++;
			else if(dfs(i,1))a++;
			else b++;
		}
	}
	cout<<2*c*n-c*c+2*a+b*b+a*(a-1)*2+a*b*2<<endl;
}

Measured memory_bytes: 10624
using System.Linq;
using static System.Console;
using static System.Math;
class Z { static void Main() => new _K(); }
class _K
{
	int[] G => Strs.Select(int.Parse).ToArray();
	string[] Strs => ReadLine().Split();
	int K, L;
	readonly int[,,] sum;
	public _K()
	{
		var I = G;
		K = I[1];
		L = 4 * K;
		sum = new int[L + 1, L + 1, 2];
		for (var i = 0; i < I[0]; i++)
		{
			var S = Strs;
			Add(int.Parse(S[0]) % (2 * K) + 1, int.Parse(S[1]) % (2 * K) + 1, S[2] == "B" ? 0 : 1);
		}
		for (var c = 0; c < 2; c++)
		{
			for (var x = 0; x < L; x++) for (var y = 0; y <= L; y++) sum[x + 1, y, c] += sum[x, y, c];
			for (var x = 0; x <= L; x++) for (var y = 0; y < L; y++) sum[x, y + 1, c] += sum[x, y, c];
		}
		var max = 0;
		for (var i = 0; i < 2 * K; i++) for (var j = 0; j < K; j++) max = Max(max, Sum(i, j));
		WriteLine(max);
	}
	void Add(int x, int y, int c)
	{
		sum[x, y, c]++;
		sum[x + 2 * K, y, c]++;
		sum[x + 2 * K, y + 2 * K, c]++;
		sum[x, y + 2 * K, c]++;
	}
	int Sum(int i, int j) => Sum(i, j, 0) + Sum(i + K, j + K, 0) + Sum(i, j + K, 1) + Sum(i + K, j, 1);
	int Sum(int i, int j, int c) => sum[i + K, j + K, c] - sum[i + K, j, c] - sum[i, j + K, c] + sum[i, j, c];
}


Measured memory_bytes: 144324
#include<stdio.h>

int main(){
	int topthree[3]={0,0,0};
	int getnum,count;
	for(count=0;count<10;count++){
		scanf("%d",&getnum);
		if(getnum>topthree[0]){
			topthree[2]=topthree[1];topthree[1]=topthree[0];topthree[0]=getnum;
		}
		else if(getnum>topthree[1]){
			topthree[2]=topthree[1];topthree[1]=getnum;
		}
		else if(getnum>topthree[2]){
			topthree[2]=getnum;
		}
	}
	for(count=0;count<3;count++){
		printf("%d\n",topthree[count]);
	}
return 0;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
using namespace std;
#define MAXN 1000005
char s[MAXN];
int main()
{
	scanf("%s",s);
	int len=strlen(s);
	for(int i=0;i<len-1;i++)
	{
		if(s[i]==s[i+1])
		{
			printf("%d %d\n",i+1,i+2);
			return 0;
		}
		if(s[i]==s[i+2])
		{
			printf("%d %d\n",i+1,i+3);
			return 0;
		}
	}
	printf("-1 -1\n");
	return 0;
}

Measured memory_bytes: 256
//  main.cpp
//  CppTest

#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main(int argc, const char * argv[]) {

    /////////////////////
    // Write code below /
    /////////////////////
    int N;
    cin >> N;
    
    int quotient = N; // 商
    int sumOfDigit = 0;
    while (quotient > 0) {
        sumOfDigit += quotient % 10;
        quotient /= 10;
    }
    
    if (N % sumOfDigit == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = (int)1e5 + 5;

int count_zero(deque<int> a){
	int count = 0;
	rep (j, a.size()) count += (a[j] == 0);
	return count;
}	

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

	int N; cin >> N;
	vector<int> a(N,0);
	rep (j, N) cin >> a[j];
	sort(ALL(a), greater<int>());
	
	int check = N - 1;
	rep (i, N-1){
		if(a[i+1] < i+2){
			check = i;
			break;
		} // end if
	} // end rep

	int h = a[check] - check - 1;
	int w = 0;
	for (int i = check + 1; i < N; ++i){
		if (check + 1 != a[i]) break;
		++w;
	} // end for
	if (h % 2 != 0 || w % 2 != 0){
		cout << "First" << endl;
	}else{
		cout << "Second" << endl;
	} // end if

	return 0;
}

Measured memory_bytes: 640
n,m = map(int, input().split())
E = [[] for i in range(7)]
##+-どちらの方向に絶対値を最大化させるか
for i in range(n):
    xi,yi,zi = map(int, input().split())
    for j in range(7):
        x2,y2,z2 = xi,yi,zi 
        L = [x2,y2,z2]
        for k in range(3):
            if j>>k&1:
                L[k]*=-1
        sm = sum(L)
        E[j].append(sm)
for i in range(7):
    E[i].sort()

ans = 0
##m = 0 がコーナー
#python のlistの負index切片の仕様確認
#他のコーナーあるだろうか
if m==0:
    print(0)
    exit()
for i in range(7):
    ans = max(ans,abs(sum(E[i][-m:])))
print(ans)



Measured memory_bytes: 46572
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef std::pair<int,int> pair2;
typedef std::pair<int,pair2> pair3;
const ll INF = 1LL<<60;

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

  for(ll i=1;i<N+1;i++){
     ll ans=0;
     ll max=std::sqrt(i)+1;
    
    for(ll a=1;a<max+1;a++){
    	for(ll b=1;b<a+1;b++){
          for(ll c=1;c<b+1;c++){
            ll cal=(a+b+c)*a+(b+c)*b+c*c;
            if(cal==i)
            {//cout<<a<<","<<b<<","<<c<<","<<i<<endl;
            if(a==b&&b==c){ans++;}
             else if(a==b||b==c){ans=ans+3;}
             else {ans=ans+6;}
            }
          }
        }
    }  
     cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 3644
s=(input())
k=s[2:-1]
m=k.replace('C', 'c')
t=s[-1]
t1=s[1]
if k.count('C')==1 and s[0]=='A' and m==k.lower() and t==s[-1].lower() and s[1]==t1.lower():
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3060
import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  s <- getLine
  t <- getLine
  putStrLn $ if solve s t
             then "Yes"
             else "No"

solve :: String -> String -> Bool
solve s t = go s t (Map.fromList $ zip s t) (Map.fromList $ zip t s)
  where
    go :: String -> String -> Map.Map Char Char -> Map.Map Char Char -> Bool
    go [] _ _ _ = True
    go _ [] _ _ = True
    go (s:ss) (t:ts) smp tmp
       = smp Map.! s == t && tmp Map.! t == s
       && go ss ts smp tmp


Measured memory_bytes: 28028
#include<stdio.h>
#include<algorithm>
using namespace std;
const int mod=1e9+7;
long long pre[100005]={1},a[100005],ans=0;
int n,k;
bool cmp(long long a,long long b)
{
	return a<b;
}
/*快速幂板子*/
long long qmul(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1)res=res*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return res;
}
/*组合数板子*/
long long C(long long a,long long b)
{
	if(a<=0||b<=0||a<b)return 0;
	long long k1=pre[a]%mod;
	long long k2=qmul(pre[b]%mod,mod-2)%mod;
	long long k3=qmul(pre[a-b]%mod,mod-2)%mod;
	return ((k1*k2)%mod*k3)%mod;
}
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)scanf("%lld",&a[i]);
	sort(a,a+n,cmp);
	pre[0]=1;
	for(int i=1;i<=n;i++)pre[i]=pre[i-1]*i%mod;
	for(int i=0;i<n;i++)
	{
		if(n-i-1>=k-1)ans+=(mod-C(n-i-1,k-1))*a[i]%mod;
		if(i>=k-1)ans+=C(i,k-1)%mod*a[i]%mod;
		ans%=mod;
	}
	while(ans<0)ans+=mod;
	printf("%lld\n",ans%mod);
}
//

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

vector<int> adj[100000];
vector<pair<int,int>> ans;
int cnt[100000], parent[100000];
bool chk[100000];

void dfs(int c)
{
	chk[c]=true;
	for(auto n: adj[c]) {
		if(parent[n]==-1) {
			parent[n]=c;
			dfs(n);
		}
		else if(chk[n] && parent[c]!=n) {
			cnt[c]=1-cnt[c];
			ans.emplace_back(c,n);
		}
	}
	if(c) {
		if(cnt[c]) ans.emplace_back(c,parent[c]);
		else {
			cnt[parent[c]]=1-cnt[parent[c]];
			ans.emplace_back(parent[c],c);
		}
	}
	chk[c]=false;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	int N, M;
	for(cin>>N>>M;M--;) {
		int a, b;
		cin>>a>>b;
		adj[--a].push_back(--b);
		adj[b].push_back(a);
	}
	memset(parent,-1,sizeof(parent));
	parent[0]=0;
	dfs(0);
	if(cnt[0]) cout<<"-1\n";
	else {
		for(auto e: ans) cout<<e.first+1<<' '<<e.second+1<<'\n';
	}
	return 0;
}

Measured memory_bytes: 14964
n = int(input())
l,r = [],[]
for i,a in enumerate([int(i) for i in input().split()]):
    if (n%2 == 0 and (i+1)%2 == 0) or (n%2 == 1 and (i+1)%2 == 1):
        l.append(str(a))
    else:
        r.append(str(a))
for a in l[::-1]:
    print(a,end=' ')
for b in r:
    print(b,end=' ')
print()


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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 1e4 + 10;

int n, k;
char s[N], m;

bool check1(int p1, int p2, int len) {
  while (len < n) {
    if (s[p1 - len] > s[p2 - len]) return 1;
    if (s[p1 - len] < s[p2 - len]) return 0;
    len++;
  }
  return 0;
}

void trans1() {
  for (int i = 1; i <= n; i++) s[i + n] = s[n - i + 1];
  vector<int> res(0);
  int cur = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (s[i] == m) {
      int l = i, r = i;
      while (r < 2 * n && s[r + 1] == m) r++;
      int len = r - l + 1;
      if (r > n) {
        if (len > cur) {
          res.clear();
          res.push_back(r);
          cur = len;
        } else if (len == cur) {
          res.push_back(r);
        }
        i = r;
      }
    }
  }
  int tmp = res[0];
  for (int i = 1; i < res.size(); i++)
    if (check1(tmp, res[i], cur)) tmp = res[i];
  for (int i = tmp - n + 1; i <= tmp; i++) s[i - tmp + n] = s[i];
}

bool check2(int p1, int p2, int len) {
  while (len < n) {
    if (s[p1 + len] > s[p2 + len]) return 1;
    if (s[p1 + len] < s[p2 + len]) return 0;
    len++;
  }
  return 0;
}

void trans2() {
  for (int i = 1; i <= n; i++) s[i + n] = s[n - i + 1];
  vector<int> res(0);
  int cur = 0;
  for (int i = 1; i <= 2 * n; i++) {
    if (s[i] == m) {
      int l = i, r = i;
      while (r < 2 * n && s[r + 1] == m) r++;
      int len = r - l + 1;
      if (l <= n) {
        if (len > cur) {
          res.clear();
          res.push_back(l);
          cur = len;
        } else if (len == cur) {
          res.push_back(l);
        }
        i = r;
      }
    }
  }
  int tmp = res[0];
  for (int i = 1; i < res.size(); i++)
    if (check2(tmp, res[i], cur)) tmp = res[i];
  for (int i = tmp; i <= tmp + n - 1; i++) s[i - tmp + 1] = s[i];  
}

int main() {
//  freopen("tst.in", "r", stdin);
  n = read(), k = read();
  scanf("%s", s + 1);
  m = 'z';
  for (int i = 1; i <= n; i++) m = min(m, s[i]);
  for (int i = 1; i < k; i++) {
    trans1();
    bool fg = 0;
    for (int j = 1; j <= n; j++) if (s[j] != m) fg = 1;
    if (!fg) break; 
  }
  trans2();
  for (int i = 1; i <= n; i++) putchar(s[i]);
  puts("");
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <string>
#include <iomanip>
using namespace std;
int ue(int hoge){
	while(hoge/10){
		hoge/=10;
	}
	return hoge;
}
int sita(int hoge){
	return hoge%10;
}
int main(){
	int ct[10][10]={};
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		ct[ue(i)][sita(i)]++;
	}
	long long ans=0;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			ans+=ct[i][j]*ct[j][i];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
if x == 3 or x == 5 or x == 7:
    print('YES')
else:
    print('NO')

Measured memory_bytes: 38256
//Sani buyuk Osman Pasa Plevneden cikmam diyor.
//FatihSultanMehmedHan
//Abdulhamid Han
//Bismillahirrahmanirrahim
//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█
 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long lo;
typedef pair< lo,lo > PII;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define FOR for(int i=1;i<=n;i++)
#define mid ((start+end)/2)
#define ort ((bas+son)/2)
 
const lo MAX = -1000000000000000000;
const lo MIN = 1000000000000000000;
const lo inf = 1000000000;
const lo KOK = 100000;
const lo LOG = 30;
const lo li = 500005;
const lo mod = 1000000007;
 
int n,m,b[li],a[li],k,flag,t,dp[li],say,kon,dp1[li];
int cev;
string s;
multiset<int> st;
vector<int> v;
 
int main(void){
	fio();
	cin>>n>>k>>s;
	if(s[n]=='1'){cout<<"-1\n";return 0;}
	reverse(s.begin(),s.end());
	for(int i=0;i<=n;i++){
		if(s[i]=='1')say++;
		else{say=0;kon=i;}
		dp[i]=kon;
		if(say>=k){cout<<"-1\n";return 0;}
	}
	for(int i=n+1;i<=n+k+1;i++)dp[i]=kon;
	for(int i=n;i>=1;i--){
		if(s[i]=='0')kon=i;
		dp1[i]=kon;
	}
	cev=0;
	int ind=0;
	while(ind<n){
		v.pb(dp[ind+k]-ind);
		ind=dp[ind+k];
		cev++;
		
	}
	reverse(v.begin(),v.end());
	for(int i=0;i<(int)v.size();i++)cout<<v[i]<<" ";
	return 0;
}

Measured memory_bytes: 3656
import numpy as np
H,W = map(int,input().split())
table = []
for i in range(H):
    col = list(input())
    table.append(col)
table = np.array(table)
for i in range(1,H):
    for j in range(1,W):
        bubun = table[i-1:i+2,j-1:j+2]
        if bubun.shape != (3,3):
            continue
        center = bubun[1,1]
        if center == "#" and bubun[0,1] == "." and bubun[1,0] == "." and bubun[1,2] == "." and bubun[2,1] == "." :
            print("No")
            exit()
        #print(bubun)
print("Yes")


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

int main() {
  int sum1 = 0, sum2 = 0;
  for (int i = 0; i < 4; i ++) {
    int a; cin >> a;
    sum1 += a;
  }
  for (int i = 0; i < 4; i ++) {
    int b; cin >> b;
    sum2 += b;
  }

  cout << max(sum1, sum2) << endl;
}



Measured memory_bytes: 3084
#include<cstdio>
#include<algorithm>

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

using namespace std;

typedef long long ll;

const ll M=1000000;

int main(){
	for(int n;scanf("%d",&n),n;){
		char s[1000][9];
		rep(i,n) scanf("%s",s[i]);

		ll dp[1001]={1};
		rep(i,n){
			// 1 byte
			if(s[i][0]!='1'){
				ll c=1<<count(s[i]+1,s[i]+8,'x');
				dp[i+1]+=c*dp[i];
			}
			// 2 byte
			if(i>0 && s[i][0]!='0' && s[i][1]!='1' && s[i-1][0]!='0' && s[i-1][1]!='0' && s[i-1][2]!='1'){
				ll c1=0;
				rep(S,1<<4){
					bool ok=false;
					if(S>0
					|| s[i-1][3]=='1'
					|| s[i-1][4]=='1'
					|| s[i-1][5]=='1'
					|| s[i-1][6]=='1') ok=true;
					if(s[i-1][3]==(S&1<<0?'0':'1')
					|| s[i-1][4]==(S&1<<1?'0':'1')
					|| s[i-1][5]==(S&1<<2?'0':'1')
					|| s[i-1][6]==(S&1<<3?'0':'1')) ok=false;
					if(ok) c1++;
				}
				ll c2=1<<((s[i-1][7]=='x'?1:0)+count(s[i]+2,s[i]+8,'x'));
				dp[i+1]+=c1*c2*dp[i-1];
			}
			// 3 byte
			if(i>1 && s[i][0]!='0' && s[i][1]!='1' && s[i-1][0]!='0' && s[i-1][1]!='1' && s[i-2][0]!='0' && s[i-2][1]!='0' && s[i-2][2]!='0' && s[i-2][3]!='1'){
				ll c1=0;
				rep(S,1<<5){
					bool ok=false;
					if(S>0
					|| s[i-2][4]=='1'
					|| s[i-2][5]=='1'
					|| s[i-2][6]=='1'
					|| s[i-2][7]=='1'
					|| s[i-1][2]=='1') ok=true;
					if(s[i-2][4]==(S&1<<0?'0':'1')
					|| s[i-2][5]==(S&1<<1?'0':'1')
					|| s[i-2][6]==(S&1<<2?'0':'1')
					|| s[i-2][7]==(S&1<<3?'0':'1')
					|| s[i-1][2]==(S&1<<4?'0':'1')) ok=false;
					if(ok) c1++;
				}
				ll c2=1<<(count(s[i-1]+3,s[i-1]+8,'x')+count(s[i]+2,s[i]+8,'x'));
				dp[i+1]+=c1*c2*dp[i-2];
			}
			// 4 byte
			if(i>2 && s[i][0]!='0' && s[i][1]!='1' && s[i-1][0]!='0' && s[i-1][1]!='1' && s[i-2][0]!='0' && s[i-2][1]!='1' && s[i-3][0]!='0' && s[i-3][1]!='0' && s[i-3][2]!='0' && s[i-3][3]!='0' && s[i-3][4]!='1'){
				ll c1=0;
				rep(S,1<<5){
					bool ok=false;
					if(S>0
					|| s[i-3][5]=='1'
					|| s[i-3][6]=='1'
					|| s[i-3][7]=='1'
					|| s[i-2][2]=='1'
					|| s[i-2][3]=='1') ok=true;
					if(s[i-3][5]==(S&1<<0?'0':'1')
					|| s[i-3][6]==(S&1<<1?'0':'1')
					|| s[i-3][7]==(S&1<<2?'0':'1')
					|| s[i-2][2]==(S&1<<3?'0':'1')
					|| s[i-2][3]==(S&1<<4?'0':'1')) ok=false;
					if(ok) c1++;
				}
				ll c2=1<<(count(s[i-2]+4,s[i-2]+8,'x')+count(s[i-1]+2,s[i-1]+8,'x')+count(s[i]+2,s[i]+8,'x'));
				dp[i+1]+=c1*c2*dp[i-3];
			}
			dp[i+1]%=M;
		}
		printf("%lld\n",dp[n]);
	}

	return 0;
}

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

int main() {
	long long x, i = 1, m = 100;
	cin >> x;

	while (true) {
		m += (m / 100);
		if (m >= x) {
			cout << i << endl;
			break;
		}
		i++;
	}

}


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

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define all(x) (x).begin(), (x).end()
#define clr(ar, val) memset(ar, val, sizeof(ar))
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 (b < a) { a = b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
	ll a[3];cin>>a[0]>>a[1]>>a[2];
	ll ans=0;
	sort(a, a + 3);
	ans = a[0]+a[1];
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
//:Ditttoo
#include<bits/stdc++.h>
#define int long long int 
using namespace std;
const int N = (int)2e5 + 9;
int t[N],n;
void update(int v , int idx){for(;idx<=n;idx += idx & -idx)t[idx] = max(v,t[idx]);}
int get(int idx){int a = 0;for(;idx>0 ; idx -= idx & -idx)a = max(a,t[idx]);return a;}
int32_t main()
{
	cin>>n;

	int h[n+1] , a[n+1];
	for(int i=1;i<=n;i++) cin >> h[i];
	for(int i=1;i<=n;i++) cin >> a[i];

	int dp[n+1];

	for(int i=1;i<=n;i++){
		dp[h[i]] = get(h[i]) + a[i];
		update(dp[h[i]] , h[i]);
		// for(int i=1;i<=n;i++)cout<<t[i]<<" ";
		// cout << endl;
	}
	cout << get(n);




	return 0;
}        

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


constexpr long double pi = acos(-1L);

V<string> split(const string& s, char c) {
  V<string> res;
  stringstream ss(s);
  string t;
  while (getline(ss, t, c)) res.push_back(t);
  return res;
}

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  long double x = 0, y = 0;
  int th = 90;
  string s;
  while (getline(cin, s)) {
    auto ss = split(s, ',');
    int d = stoi(ss[0]), a = stoi(ss[1]);
    if (d == 0) break;
    x += d * cos(th * pi / 180);
    y += d * sin(th * pi / 180);
    th -= a;
  }
  cout << static_cast<int>(x) << '\n';
  cout << static_cast<int>(y) << '\n';
}


Measured memory_bytes: 3508
def sub_print(text, a, b):
    print(text[a:b])
    return text

def sub_reverse(text, a, b):
    return text[:a] + text[a:b][::-1] + text[b:]
def sub_replace(text, a, b, p):
    return text[:a] +p + text[b:]

func = {'print':sub_print, 'reverse':sub_reverse, 'replace':sub_replace}

text = input()
q = int(input())
for i in range(q):
    line = input().split()
    text = func[line[0]](text, int(line[1]), int(line[2]) + 1, *line[3:])

Measured memory_bytes: 6728
using System;
using System.Linq;
class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());
        long ans = 0;
        for (int i = 1; i <= n; i++)
        {
            if (i % 3 != 0 && i % 5 != 0)
            {
                ans += i;
            }
        }
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 17612
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    HashSet<Integer> set = new HashSet<Integer>();
    for (int i = 0; i < 3; i++) {
      set.add(sc.nextInt());
    }
    if (set.size() == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
    sc.close();
  }

}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int const MAXN=110000, MOD=1e9+7;
int n, m, dp[MAXN];
bool broken[MAXN];
int main(){
	cin>>n>>m;
	int temp;
	for(int i=0;i<m;i++){
		cin>>temp;
		broken[temp]=true;
	}
	dp[n]=1;
	for(int i=n-1;i>=0;i--)
		if(!broken[i])
			dp[i]=(dp[i+1]+dp[i+2])%MOD;
	cout<<dp[0];
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int, int>
#define ld long double
const int mod = 1e9 + 7;
 
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};
 
 
 
 
 int bin(multiset<int>&s)
 {

	 
	 int l=0,r=s.size()-1,mid,ans=1;
	 while(l<=r)
	 {
		 mid=(l+r)/2;
		 auto k =s.begin();
	   	advance(k,mid);
		 if(*k>=s.size()-mid)
		 { 
			 ans=s.size()-mid; r=mid-1;
		 }
		 else l=mid+1;
	 }
	 return ans;
 }
 
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 

 

int n;
cin>>n;
vector<int>v(n+1);

for(int i=1;i<=n;i++)cin>>v[i];

vector<int>dp(100006);
dp[1]=0,dp[2]=abs(v[2]-v[1]); 

for(int i=3;i<=n;i++)
{
	dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
}

cout<<dp[n];
 
}

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

#define INF INT_MAX
#define MMS(x, y) memset((x), (y), sizeof(x))
#define ll long long
#define vi vector <int>
#define pii pair <int, int>
#define EPS 1e-9

#define MAXN 100010
#define SEGN 300030
using namespace std;

ll N, K;
ll total;
int A[MAXN], B[MAXN];
bool used[MAXN];
void check(int X) {
    ll sum = 0;
    for (int i = 0; i < N; i++) {
        if ((A[i] | X) <= X) {
            sum += B[i];
        }
    }
    total = max(total, sum);
}
int main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
    }
    for (int i = 0; i < 30; i++) {
        if (K & (1 << i)) {
            int X = K;
            X ^= (1 << i);
            for (int j = i - 1; j >= 0; j--) {
                X |= (1 << j);
            }
            check(X);
        }
    }
    check(K);
    cout << total << "\n";
}


Measured memory_bytes: 1024
//#include <stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
#define PI 3.14159265359;

class Hoge{
  public:
					long int i0;
					int i1,N0;
					string s0;
					int* iarray0;
					Hoge(int);
					void func0();
					void array0();
	void printarray0();
	~Hoge();
  private:
	int ianswer;
	void search0();
	void inputarray(int*,int);
	void inputarray2(int*,int*,int);
	void printarray(int*,int);
					};


Hoge::Hoge(int itemp){
	
	i0=itemp;
	//cout<<"i0="<<i0<<endl;
	
									}

void Hoge::func0(){
	//cout<<"N0?"<<endl;
	//cin>>N0;
	 N0=5;
	iarray0=new int[N0];
	ianswer=0;
	//int N1=3;int N2=2;
	//int* iarray1=new int[N1];
	//int* iarray2=new int[N1];

	inputarray(iarray0,N0);
	search0();
	//printarray(iarray0,N0);
	//inputarray2(iarray1,iarray2,N1);
	
	//delete [] iarray1;
	//delete [] iarray2;
	
								}

void Hoge::search0(){
	//cout<<N0<<endl;
	for (int i0=0;i0<N0;i0++){
		//cout<<"i0="<<i0<<endl;
		//cout<<"iarray0[i0]="<<iarray0[i0]<<endl;
		if(iarray0[i0]==0){
			ianswer=i0+1;
			//cout<<"iarray0[i0]"<<iarray0[i0]<<endl;
		}
			
	}
	cout<<ianswer<<endl;
								}
void Hoge::array0(){

	cout<<"N0?";
	cin>>N0;
	
	
	for (int i0=0;i0<N0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray0[i0];
		
		
	}
}

void Hoge::inputarray(int* itemp,int itempn){
	//cout<<"hoge00"<<endl;
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		//cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
	}
}
void Hoge::inputarray2(int* itemp,int* itemp2,int itempn){
	
	int* iarray=itemp;
	int* iarray2=itemp2;
	int n0=itempn;
	
	for (int i0=0;i0<n0;i0++){
		cout<<"i0="<<i0<<endl;
		cin>>iarray[i0];
		cin>>iarray2[i0];
	}
}

void Hoge::printarray(int* itemp,int itempn){
	
	int* iarray=itemp;
	int n0=itempn;
	for (int i0=0;i0<n0;i0++){
		cout<<"iarray["<<i0<<"]="<<iarray[i0]<<endl;
	
	}
}
	
	void Hoge::printarray0(){
							 
							 for (int i0=0;i0<N0;i0++){
			cout<<"iarray0["<<i0<<"]="<<iarray0[i0]<<endl;
			
							 
							 }
	
	
}
Hoge::~Hoge(){
	
delete [] iarray0;
							}
int main(){
				int N;
				//cin>>N;
	
	Hoge* hoge=new Hoge(N);
	hoge->func0();
	
	//hoge->array0();
	//hoge->printarray0();
	return 0;
	//delete hoge;
}//end of main

Measured memory_bytes: 3568
/*#pragma GCC optimize("Ofast") 
#pragma GCC target("avx,avx2,fma") 
#pragma GCC optimization("unroll-loops") */

#include<bits/stdc++.h>   
#include<tr1/unordered_map>
#define ll long long int   
#define pb push_back
#define mkp make_pair 
#define mod 1000000007 
#define maxn 100001 
#define ff first
#define ss second
using namespace std;    


int main(){    
  ios_base::sync_with_stdio(false); 
  cin.tie(NULL);     
  string s; 
  cin>>s;  
  ll sum=0; 
  for(int i=0;i<s.size();++i) 
      sum+=s[i]-'0';   
  
  if(sum%9==0)   
      cout<<"Yes\n"; 
  else cout<<"No\n";
  
  return 0;
}


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

using namespace std;

int main()
{
    multiset<int, greater<int> > s;
    int n;
    int a,b;
    int p;
    int d;
    int ans;
    int div=0;
    cin >> n;
    cin >> a >> b;
    cin >> p;
    ans = p;
    for(int i=0;i<n;++i)
    {
        cin >> d;
        s.insert(d);
    }
    multiset<int, greater<int> >::iterator it = s.begin();
    while(it != s.end())
    {
        if((double)((*it)/b) > (double)(ans/(a+div*b)))
        {
            ans += *it;
            ++div;
        }
        ++it;
    }
    cout << ans / (a + div*b) << endl;

}

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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int main()
{
    string a,b,u;
    int x,y;
    cin>>a>>b>>x>>y>>u;
    if(u==a)
        x--;
    else
        y--;
    cout<<x<<" "<<y;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int max=0;
		int prt=0;
		for(int i=0;i<n;i++){
			int h =sc.nextInt();
			if(h>=max){
				max=h;
				prt++;
			}
		}
		System.out.print(prt);
	}
}

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

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

h,w = inm()
s = []
nb = 0
for i in range(h):
    ss = ins()
    s.append(ss)
    nb += ss.count('#')
q = deque([(0,0)])
d = [[BIG]*w for i in range(h)]
d[0][0] = 0
while len(q)>0:
    x,y = q.popleft()
    dd = d[x][y]
    for dx,dy in [(0,1),(0,-1),(1,0),(-1,0)]:
        xx = x+dx
        yy = y+dy
        if 0<=xx<h and 0<=yy<w and s[xx][yy]=='.' and d[xx][yy]>dd+1:
            d[xx][yy] = dd+1
            q.append((xx,yy))
z = d[h-1][w-1]
print(-1 if z==BIG else (h*w-nb-z-1))


Measured memory_bytes: 73912
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

//#define TEST

int bitcount(int f) {
	int cnt = 0;
	while (f) {
		cnt += (f & 1);
		f /= 2;
	}
	return cnt;
}

signed main() {
	// 入力の受け取り
	int n, k; cin >> n >> k;
	vector<int> a(n);
	for (int i = 0; i < n; ++i) cin >> a[i];
	// 和をkにできるカードのとり方をbit全探索
	vector<bool> ok((1 << n), false);
	for (int f = 0; f < (1 << n); ++f) {
		// 全部取ってちょうどkか判定する
		int total = 0;
		for (int i = 0; i < n; ++i)
			if (f & (1 << i))
				total += a[i];
		if (total == k) ok[f] = true;
		// 一部取ってちょうどkか判定する
		for (int i = 0; i < n; ++i)
			if (f & (1 << i))
				ok[f] = ok[f] || ok[f ^ (1 << i)];
	}
#ifdef TEST
	for (int f = 0; f < (1 << n); ++f)
		if (!ok[f])
			cout << f << " ";
	cout << endl;
#endif
	// !ok[f]なfについて、n-bitcount(f)のminを求める
	int res = n;
	for (int f = 0; f < (1 << n); ++f)
		if (!ok[f])
			res = min(res, n - bitcount(f));
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 3236
#input
N = int(input())
A = list(map(int,input().split()))
#b = int(input())
 
#s = [0,0,0]
#s[0] = int(input/100)
#s[1] = int(input/10 - s[0]*10)
#[2] = int(input%10)
 
count = 0
flag = 0
 
#loop
while(1):
  for i in range(N):
    
    if A[i] %2 == 1:
      flag = 1
    else:
      temp = A[i]/2
      A[i] = temp;
  
  #judge
  if flag == 1:
    break
  else:
    count +=1
    #print(A)
 
#print('result')
#print(A)
print(count)

Measured memory_bytes: 3060
def kengo(n, x):
    if n == 0:
        if x == 0:
            return 0
        else:
            return 1
    if x == 0:
        return 0
    if x <= 2 ** (n + 1) - 2:
        return kengo(n - 1, x - 1)
    if x <= 2 ** (n + 2) - 4:
        return 2 ** n + kengo(n - 1, x - 2 ** (n + 1) + 1)
    else:
        return 2 ** (n + 1) - 1

n, x = map(int, input().split())
print(kengo(n, x))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll mod = 1000000007;
const ll INF = 9223372036854775807;
#define Sort(a) sort(a.begin(), a.end())
#define Bsort(a) sort(a.begin(), a.end(), greater<ll>())
#define Pi acos(-1)

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << setprecision(15) << fixed;
  ll n, m;
  cin >> n >> m;
  if (n-m == 0) {
    ll ans = 1;
    for (ll i = 2; i <= n; i++) {
      ans *= i;
      ans %= mod;
    }
    ans = ans*ans%mod*2%mod;
    cout << ans << '\n';
  } 
  else if (abs(n-m) == 1) {
    ll a = max(n,m);
    ll b = min(n,m);
    ll ans = 1;
    for(ll i = 2; i <= b; i++) {
      ans *= i;
      ans %= mod;
    }
    ans = ans*ans%mod*a%mod;
    cout << ans << '\n';
  }
  else {
    cout << 0 << '\n';
  } 
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;

int main(){
	int h1, m1, h2, m2, k;
	cin>>h1>>m1>>h2>>m2>>k;
	int time = (h2-h1)*60 + (m2-m1);
	cout<<time - k<<endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;


int main(){
    int a[3];
    for(int i=0;i<3;i++){
        cin >> a[i];
    }
    sort(a,a+3);
    int k;
    cin >> k;
    int t=1;
    for(int i=0;i<k;i++){
        t*=2;
    }
    cout << a[2]*t+a[1]+a[0] << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
using namespace std;
typedef long long ll;
// static const int max_n = 110;
// static const llong max_cost = 2000000000000000;
// // vector<vector<llong>> matrix(max_n, vector<llong>(max_n, 0));
// // vector<vector<llong>> adj_matrix(max_n, vector<llong>(max_n, max_cost));
// vector<vector<pair<llong, int>>> adj_list(max_n);
// vector<llong> distance_table(max_n, max_cost);
// set<pair<llong, int>> points_sort_x;
// set<pair<llong, int>> points_sort_y;

// int N;



int main(){
    // int u, v;
    // bool updated = false;
    ll N, M, cost, total_num;
    scanf("%lld", &N);
    string n_s = to_string(N);
    bool is_ok = false;
    for(int i=0;i<3;i++){
        if(n_s[i] == '7'){
            is_ok = true;
        }
    }

    if(is_ok){
        printf("Yes\n");
    }else{
        printf("No\n");
    }


    return 0;

}

Measured memory_bytes: 3164
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <iomanip>
#include <algorithm>
#include <sstream>
#include <string>
#include <math.h>
#include <set>
using namespace std;
 
int main() {
	ios::sync_with_stdio(false);
	long long n,x;
	cin >> n >> x;
	long long a[n],b[n];
	for (int i=0;i<n;i++) cin >> a[i],b[i]=a[i];
	for (int i=1;i<n;i++) {
		if (a[i]+a[i-1]>x) {
			if (a[i-1]>=x) {
				a[i-1]=x;
				a[i]=0;
			} else {
				a[i]=x-a[i-1];
			}
		}
	}
	long long c=0;
	for (int i=0;i<n;i++) c+=b[i]-a[i];
	cout << c;
}

Measured memory_bytes: 1792