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

#define dump(n) cout<<"# "<<#n<<'='<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;

const int INF=1e9;
const int MOD=1e9+7;
const double EPS=1e-9;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

// n以上の2の冪乗
int Need(int n)
{
	n--;
	for(int i=1;i<32;i<<=1) n|=n>>i;
	return n+1;
}

struct SegmentTree{
	int I(){return numeric_limits<int>::max();}
	int F(int a,int b){return min(a,b);}
	
	int size;
	vi data;
	SegmentTree(int s):size(Need(s)),data(size*2,I()){
		Build();
	}
	SegmentTree(const vi& a):size(Need(a.size())),data(2*size,I()){
		copy(all(a),begin(data)+size);
		Build();
	}
	void Build(){
		peri(i,1,size){
			int u=i*2,v=i*2+1;
			if(v<size) u=data[u],v=data[v];
			data[i]=data[u]==F(data[u],data[v])?u:v;
		}
	}
	int Get(int i){
		return data[size+i];
	}
	void Update(int i,int x){
		data[i+=size]=x;
		while(i/=2){
			int u=i*2,v=i*2+1;
			if(v<size) u=data[u],v=data[v];
			data[i]=data[u]==F(data[u],data[v])?u:v;
		}
	}
	int QueryIndex(int a,int b,int i,int l,int r){
		if(b<=l || r<=a) return 0;
		if(a<=l && r<=b) return i<size?data[i]:i;
		int u=QueryIndex(a,b,i*2,l,(l+r)/2),v=QueryIndex(a,b,i*2+1,(l+r)/2,r);
		return data[u]==F(data[u],data[v])?u:v;
	}
	int QueryIndex(int a,int b){
		int res=QueryIndex(a,b,1,0,size);
		return res==0?-1:res-size;
	}
	int Query(int a,int b){
		return data[QueryIndex(a,b,1,0,size)];
	}
};

int main()
{
	for(int n,q;cin>>n>>q && n|q;){
		//SegmentTree st(n);
		SegmentTree st(vi(n,numeric_limits<int>::max()));
		rep(_,q){
			int t; cin>>t;
			if(t==0){
				int i,x; cin>>i>>x;
				st.Update(i,x);
			}
			else{
				int a,b; cin>>a>>b; b++;
				cout<<st.Query(a,b)<<endl;
			}
		}
	}
}

Measured memory_bytes: 2320
from fractions import gcd
# from datetime import date, timedelta
from heapq import*
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import sys
sys.setrecursionlimit(10 ** 7)
MOD = 10 ** 9 + 7
# input = sys.stdin.readline


def main():
    w, a, b = map(int, input().split())
    if b > a + w or a > b + w:
        print(min(abs(b - (a+w)) , abs(a -w-b)))
    else:
        print(0)
    


if __name__ == '__main__':
    main()


Measured memory_bytes: 5048
#include <cstdio>
#include <queue>
using namespace std;

int main(){
  int n;
  scanf("%d", &n);

  priority_queue<int> pq;

  for (int i = 0; i < n; i++){
    int k;
    scanf("%d", &k);
    pq.push(k);
  }

  int d = 1;
  int sum = 0;
  while(!pq.empty()){
    sum += d * pq.top();
    pq.pop();
    d *= -1;
  }

  printf("%d\n", sum);

  return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int S;
    cin >> S;
    cout << S/3600 << ":" << S/60%60 << ":" << S%60 << endl; 
}



Measured memory_bytes: 3084
def gcd(a, b):
    while b != 0:
        y = a % b
        a = b
        b = y
    return a


d = []
m = []
while True:
    try:
        a, b = map(int, input().split())
        if a > b:
            num = gcd(a, b)
        elif a < b:
            num = gcd(b, a)
        else:
            num = a
        d.append(num)
        m.append(int(a*b/num))
    except EOFError:
        break

for i in range(len(d)):
    print(d[i], m[i])

Measured memory_bytes: 7648
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include<set>
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<array>
#include<cstdio>
#include<bitset>
#include<vector>
#include<utility>
#include<sstream>
#include<cstring>
#include <climits>
#include <fstream>
#include<iostream>
#include<iomanip>
#include<algorithm>
#include <unordered_map>
using namespace std;

#define endl "\n"
#define int long long

int k;
int dp[100001];

int go( int i, vector<int> &v ){
    int n = v.size();
    if( i == n-1 )return 0;
    if( dp[i] != -1 )return dp[i];
    int ans = LLONG_MAX;
    for( int j = i+1; j <= n-1 && j <= i+k; j++ ){
        ans = min(ans, go(j, v) + abs(v[i] - v[j]));
    }
    return dp[i] = ans;
}

int32_t main(){
    Yup;
    int n;
    cin >> n >> k;
    vector<int> v(n);
    for( int i = 0; i < n; i++ ){
        cin >> v[i];
    }
    memset(dp, -1, sizeof(dp));
    cout << go(0, v);
}

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

using namespace std;

int main(){
	string A, B;
	int buff = 2;
	cin >> A >> B;
	if(A.length() == B.length()){
		for(int i = 0; i < A.length(); i++){
			if(A[i] > B[i]){
				buff = 0;
				break;
			}else if(A[i] < B[i]){
				buff = 1;
				break;
			}
		}
	}else{
		if(A.length() > B.length()){
			buff = 0;
		}else{
			buff = 1;
		}
	}
	switch(buff){
		case 0:
			cout << "GREATER" << endl;
			break;
		case 1:
			cout << "LESS" << endl;
			break;
		case 2:
			cout << "EQUAL" << endl;
			break;
	}
	return 0;
}

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

int main(){
	
	int x;
	int num = 0;
	
	
	while(1){
	 cin >> x;
		if(x == 0 )break;
	 
		num++;
		
		cout << "Case " << num << ": " << x <<endl;
	
	
	}
return 0;
}

Measured memory_bytes: 3080
if __name__ == '__main__':
	# '0'=黒 '1'=白
	S = input()
	N = len(S)
	BNum=0
	BNumEven=0
	for i in range(len(S)):
		if(S[i]=='0'):
			BNum+=1
		if(S[i]=='0' and i%2==1):
			BNumEven+=1
	NEven = N//2
	NOdd = N - NEven
	BNumOdd = BNum - BNumEven
	WNum=N-BNum
	WNumEven=N//2-BNumEven
	WNumOdd = WNum - WNumEven

	min_change = 100001
	#B even W odd
	if(WNumEven + BNumOdd<min_change):
		min_change = WNumEven + BNumOdd
	#B odd W even
	if(WNumOdd + BNumEven<min_change):
		min_change = WNumOdd + BNumEven

	print(min_change)

Measured memory_bytes: 3188
#include <iostream>
 
using namespace std;
 
int main(){
  int N;
  long long ans=0, c1=0, c2=0, K;
  cin >> N >> K;
  int A[N];
  for(int i=0; i<N; i++){
    cin >> A[i];
  }

  for(int i=0; i<N-1; i++){
    for(int j=i+1; j<N; j++){
      if(A[i] > A[j]){
        c1++;
      }
    }
  }

  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(A[i] > A[j]){
        c2++;
      }
    }
  }
  
  long long m1 = K;
  long long m2 = (K * (K - 1) / 2) % 1000000007;
  ans = (c1 * m1 + c2 * m2) % 1000000007;

  cout << ans << endl;
}


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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n, 0)
#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<ll, ll> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  int n; cin>>n;
  vector<ll> x(n, 0);
  vector<ll> y(n, 0);
  vector<ii> xy(n);
  for (int i=0; i<n; i++) {
    ll x,y; cin>>x>>y;
    xy[i] = make_pair(x,y);
  }

  sort(xy.begin(),xy.end());
  vector<ll> dp(n, 0);
  int ans=n;
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      ll dx = xy[j].first - xy[i].first;
      ll dy = xy[j].second - xy[i].second;
      vector<ll> done(n,0);
      int tmp=0;
      for (int k=0; k<n; k++) {
        if (done[k]) continue;
        done[k]=1;
        int p = k;
        for (int l=k+1; l<n; l++) {
          if (done[l]) continue;
          ll tdx = xy[l].first - xy[p].first;
          ll tdy = xy[l].second - xy[p].second;
          if (tdx == dx && tdy == dy && !done[l]) {
            done[l]=1;
            p = l;
          }
        }
        tmp++;
      }
      ans = min(ans, tmp);
    }
  }
  cout << ans << endl;
}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define N 300003
#define LL long long
#define mod 998244353

int n,ans,tot;
int a[N],sum[N];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

inline bool check(int x){
	int res=0;
	for (int i=1;i<n;i+=2)
	  if (sum[i]-res>=x) res=min(res,sum[i+1]);
	return sum[n]-res>=x;
}

int main(){
	n=read();
	for (int i=1;i<=n;i++)
	  a[i]=read();
	if (n%2==0){
		int sum1=0,sum2=0;
		for (int i=1;i<=n;i++)
		  if (i%2==1) sum1+=a[i];
		    else sum2+=a[i];
		printf("%d %d\n",max(sum1,sum2),min(sum1,sum2));
		return 0;
	}
	for (int i=1;i<=n;i++){
	  	if (!(i & 1)) ans+=a[i];
		if (i & 1) sum[i]=sum[i-1]+a[i];
		  else sum[i]=sum[i-1]-a[i];
		tot+=a[i];
	}
	int l=1,r=1000*n,res=1;
	while (l<=r){
		int mid=(l+r)/2;
		if (check(mid)){
			l=mid+1;
			res=mid;
		}
		else r=mid-1;
	}
	printf("%d %d\n",ans+res,(tot-ans-res));
	return 0;
}

Measured memory_bytes: 2560
package main
 
import "fmt"
 
func judge(rate int) int {
	if 400 <= rate && rate <= 599 {
		return 8
	} else if 600 <= rate && rate <= 799 {
		return 7
	} else if 800 <= rate && rate <= 999 {
		return 6
	} else if 1000 <= rate && rate <= 1199 {
		return 5
	} else if 1200 <= rate && rate <= 1399 {
		return 4
	} else if 1400 <= rate && rate <= 1599 {
		return 3
	} else if 1600 <= rate && rate <= 1799 {
		return 2
	//} else if 1800 <= rate <= 1999 {
	//	return 1
	} else {
		return 1
	}
	return 0
}
 
func main() {
	var rate int //ここで明示的に型を宣言している
	fmt.Scan(&rate) //rateはX整数で入力される
	ans := judge(rate)
	fmt.Println(ans)
}

Measured memory_bytes: 1772
use std::io::Read;

fn input() -> i64 {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    iter.next().unwrap().parse().unwrap()
}

fn prime_factorization(mut n:i64) -> Vec<(i64,i32)>{
    let mut i:i64 = 2;
    let mut res = Vec::<(i64,i32)>::new();
    while i*i<=n {
        if n%i==0{
            let mut cnt = 0;
            while n%i==0{
                n/=i;
                cnt+=1;
            }
            res.push((i,cnt))
        }
        i+=1;
    }
    if n>1 {
        res.push((n,1));
    }
    res
}

fn main() {
    let n = input();
    let pf = prime_factorization(n);
    let mut res = 0;
    for (_,mut cnt) in pf {
        let mut i = 1;
        while i<=cnt {
            res+=1;
            cnt-=i;
            i+=1;
        }
    }
    println!("{}",res);
}



Measured memory_bytes: 2112
#include <iostream>

using namespace std;

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

    int result = 0;
    for(int i = 0; i <= N; i++){
        int num = i;
        int sum = 0;
        while(num > 0){
            sum += num%10;
            num /= 10;
        }
        if((A <= sum)&&(sum <= B)){
            result += i;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

int main(){
    long int n,a,b,c;
    cin >> n;
    a=2;
    b=1;
    if(n==1){
        cout << 1;
        return 0;
    }
    for(int i=0;i<n-1;i++){
        c=a+b;
        a=b;
        b=c;
    }
    cout << c;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<list>
#include<map>
#include<deque>
#include<math.h>
using namespace std;
#define ll long long
bool visited[111];
ll d[111];
queue< ll > que;
vector <ll> G[111];
int main(){
    ll N;
    cin >> N;
    ll i,j;
    ll u,k,v;
    for(i=0;i<N;i++){
        cin >> u >> k;
        for(j=0;j<k;j++){
            cin >> v;
            G[u-1].push_back(v-1);
        }
        d[i]=-1;
        visited[i]=0;
    }
    que.push(0);
    visited[0]=1;
    d[0]=0;
    while(!que.empty()){
        v=que.front();
        que.pop();
        for(vector<ll>::iterator itr=G[v].begin();itr!=G[v].end();++itr){
            if(visited[*itr]==0){
                que.push(*itr);
                visited[*itr]=1;
                d[*itr]=d[v]+1;
            }
        }
    }
    for(i=0;i<N;i++){
        cout <<i+1 << " " <<d[i] <<endl;
    }
    return 0;
}



Measured memory_bytes: 3164
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000

vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N / i != i)
                res.push_back(N / i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> en = enum_divisors(M);
    ll res = 0;
    rep(i, en.size()) {
        if (en[i] * N <= M)
            res = en[i];
        else
            break;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
*/

ll n,ans=0;
string s[310];

bool is_symmerty(ll a,ll b){
	bool ok=true;
	rep(i,n){
		rep(j,n){
			if(s[(i-a+n)%n][(j-b+n)%n]!=s[(j-a+n)%n][(i-b+n)%n]){
				ok=false;
				break;
			}
		}
	}
	return ok;
}

void init(){
	cin>>n;
	rep(i,n)cin>>s[i];
}

int main(void){
	init();
	rep(i,n)if(is_symmerty(i,0))ans+=n;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <string>
#define ft first
#define sc second
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) (a)=max(a, b)
#define chmin(a, b) (a)=min(a, b)
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
static const ll INF=1e18;
static const ll MAX=101010;
static const ll MOD=1e9+7;


/*
 for(i=0; i<N; i++)
   cin >> a[i];
*/

bool dp[4444][8888*2][2];

int main(void) {
  ll i, j, k;
  
  string s;
  cin >> s;
  ll N=s.size();
  ll x, y;
  cin >> x >> y;
  
  vector<ll> v;
  v.push_back(-1);
  for(i=0; i<N; i++) if(s[i]=='T') v.push_back(i);
  v.push_back(N);
  
  vector<ll> d[2];
  for(i=1; i<(ll)v.size()-1; i++) d[i&1].push_back(v[i+1]-v[i]-1);
  
  /*最初はx軸の正の方向にしか進めない．
  そこをx方向の初期位置とみなすとy方向のdpとインデックスを揃えられる*/
  dp[0][8000+(v[1]-v[0]-1)][0]=1;
  dp[0][8000][1]=1;
  
  ll L[2];
  L[0]=d[0].size(); L[1]=d[1].size();
  
  for(ll r=0; r<2; r++) {
    for(i=0; i<L[r]; i++) {
      ll t=d[r][i];
      for(j=0; j<8080*2; j++) {
        if(j+t<8080*2) chmax(dp[i+1][j+t][r], dp[i][j][r]);
        if(j-t>=0)     chmax(dp[i+1][j-t][r], dp[i][j][r]);
      }
    }
  }
  
  pt((dp[L[0]][8000+x][0]&&dp[L[1]][8000+y][1] ? "Yes":"No"));
  
}





Measured memory_bytes: 139648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <algorithm>
#include <set>
#include <queue>
#include <map>
#include <climits>
#include <complex>
#include <numeric>
using namespace std;

#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 FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)
#define ALL(c) (c).begin(), (c).end()

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<int, pair<int, int> > pipii;
typedef vector<ll> vi;

const ll INF = (ll)1e10;
const int MOD = 1e9+7;

int main(void){
	ll n, m;
	cin >> n >> m;
	ll ans = INF;
	for(int i = 1; i <= (int)(sqrt(m)); i++){
		if(m % i == 0) {
			if(i >= n) ans = min(ans, (ll)i);
			if(m / i >= n) ans = min(ans, m / i);
		}
	}
	cout << m / ans << endl;
}

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

int gcd(int a,int b){
    if(a%b == 0){
        return b;
    }
    return gcd(b,a%b);
}

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

    int ans = 0;
    for(int i=0;i<n-1;i++){
        a[i+1] = gcd(a[i],a[i+1]);
        if(a[i+1] == 1){
            cout << a[i+1] << endl;
            exit(0);
        }
    }
    cout << a[n-1] << endl;
}


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

int main(){
  int a;
  char b[200]={0};
  int i;

  cin >> a >> b;
  for(i=0;i<a;i++){
    if(b[i]!=0) cout << b[i];
    else break;  
  }
  if(b[i]!=0) cout << "...";
  
}



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

#define REPI(x) for(int i=0;i<x;i++)
#define REPJ(x) for(int j=0;j<x;j++)

#define REPISE (s,e) for(int i=s,i<e;i++)
#define REPJSE (s,e) for(int j=s,j<e;j++)

typedef long long ll;

using namespace std;

int main ()
{
  int A,B,C,X,Y,res,price;
  vector<int> prices;

  cin >> A >> B >> C >> X >> Y;
  
  price = A*X + B*Y;
  prices.push_back (price);

  price = C*X*2 + B*max(Y-X,0);
  prices.push_back (price);

  price = C*Y*2 + A*max(X-Y,0);
  prices.push_back (price);

  res = prices[0];
  REPI(prices.size())
    res = min (res,prices[i]);

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int MiniProcess(int a,int b,int c){
    return abs(b-a)+abs(c-b);
}
int main(){
    cin >> a>> b >> c;
    int mini = 1000;
    mini=min(MiniProcess(a, b, c), mini);
	mini = min(MiniProcess(a, c, b), mini);
	mini = min(MiniProcess(b, a, c), mini);
	mini = min(MiniProcess(b, c, a), mini);
	mini = min(MiniProcess(c, b, a), mini);
	mini = min(MiniProcess(c, a, b), mini);
	cout << mini;


}


Measured memory_bytes: 256
#include<stdio.h>

#include<math.h>

int main()

{
    int a,b,con,res,k;

    while(scanf("%d %d",&a,&b)!=EOF){

            if(a<1 || b>100){

                break;
            }

    else if(b==100){

       con=(a*1000)+b;
    }

    else if(b<100 && b>=10){

        con=(a*100)+b;
    }

    else if(b<10){

        con=(a*10)+b;
    }

   res=sqrt(con);

   k=res*res;

   if(k==con){

    printf("Yes\n");

   }

   else{

      printf("No\n");
   }

    }

    return 0;

}


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

const bool DEBUG = false;

int main(int argc, char const *argv[]) {
  int A, B;
  cin >> A >> B;

  if (B == 1) {
    cout << 0 << endl;
    return 0;
  }

  int num = A;
  int count = 1;
  while (num < B) {
    num += A - 1;
    count++;
  }
  cout << count << endl;
  return 0;
}


Measured memory_bytes: 256
import math
from functools import reduce

K = int(input())

cnt = 0

def gcd(*numbers):
    return reduce(math.gcd, numbers)

for i in range(1, K+1):
    for j in range(i+1, K+1):
        for k in range(j+1, K+1):
            cnt += gcd(i, j, k)


cnt *= 6


tmp = 0
for i in range(1, K+1):
    for j in range(i+1, K+1):
       tmp += gcd(i, j)
tmp *= 6
cnt += tmp

tmp = 0
for i in range(1, K+1):
    tmp += i
cnt += tmp
print(cnt)

Measured memory_bytes: 9632
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve();

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

void solve() {
  for (int i = 1; i <=5; i++) {
    int x; cin >> x;
    if (x == 0) {
      cout << i << endl;
      return;
    }
  }
}


Measured memory_bytes: 3160
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                string[] s = Console.ReadLine().Split(' ');
                int m = int.Parse(s[0]);
                int f = int.Parse(s[1]);
                int r = int.Parse(s[2]);
                if( m == -1 && f == -1 && r == -1)
                {
                    break;
                }
                if ((m == -1 || f == -1) || (m + f < 30))
                {
                    Console.WriteLine("F");
                }else if(m + f >= 80)
                {
                    Console.WriteLine("A");
                }else if(m + f >= 65)
                {
                    Console.WriteLine("B");
                }else if((m + f >= 50) || (r >= 50))
                {
                    Console.WriteLine("C");
                }else
                {
                    Console.WriteLine("D");
                }
            }
        }
    }
}

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

int main(){
  int Xmin=0,Xmax,Ymin=0,Ymax,N;
  cin >> Xmax >> Ymax >> N;
  int x,y,a;
  for(int i=0;i<N;i++){
    cin >> x >> y >> a;
    if(a==1){
      Xmin=max(Xmin,x);
    }else if(a==2){
      Xmax=min(Xmax,x);
    }else if(a==3){
      Ymin=max(Ymin,y);
    }else{
      Ymax=min(Ymax,y);
    }
  }
  cout << max(0,Xmax-Xmin)*max(0,Ymax-Ymin) << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

type UnionFind struct {
	Par []int
}

func NewUnionFind(n int) *UnionFind {
	uf := &UnionFind{
		Par: make([]int, n),
	}
	uf.Init(n)
	return uf
}

func (uf *UnionFind) Init(n int) {
	for i := 0; i < n; i++ {
		uf.Par[i] = -1
	}
}

func (uf *UnionFind) Find(x int) int {
	if uf.Par[x] < 0 {
		return x
	}
	uf.Par[x] = uf.Find(uf.Par[x])
	return uf.Par[x]
}

func (uf *UnionFind) Unite(x, y int) {
	x, y = uf.Find(x), uf.Find(y)
	if x == y {
		return
	}

	if uf.Par[x] > uf.Par[y] {
		x, y = y, x
	}
	uf.Par[x] += uf.Par[y]
	uf.Par[y] = x
}

func (uf *UnionFind) Same(x, y int) bool {
	return uf.Find(x) == uf.Find(y)
}

// xの属する集合の要素数
func (uf *UnionFind) Size(x int) int {
	return -uf.Par[uf.Find(x)]
}

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n, m := nextInt(), nextInt()
	// 各言語の話者リスト
	speaker := make([][]int, m)
	for i := range speaker {
		speaker[i] = make([]int, 0)
	}
	for i := 0; i < n; i++ {
		k := nextInt()
		for j := 0; j < k; j++ {
			l := nextInt() - 1
			speaker[l] = append(speaker[l], i)
		}
	}

	uf := NewUnionFind(n)
	for _, sp := range speaker {
		if len(sp) == 0 {
			continue
		}
		for i := 1; i < len(sp); i++ {
			uf.Unite(sp[0], sp[i])
		}
	}

	if uf.Size(0) == n {
		puts("YES")
	} else {
		puts("NO")
	}
}


Measured memory_bytes: 9968
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-4;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	int i,j,H,W,K;cin>>H>>W>>K;
	vector<string>aaa(H);
	vector<vector<int>>bbb(H,vector<int>(W));
	for(i=0;i<H;i++){cin>>aaa[i];}
	string q=string(W,'.');
	int ban=1;
	int sai=-1;
	for(i=0;i<H;i++){
		if(aaa[i]!=q){
			if(sai==-1){sai=i;}
			for(j=0;j<W;j++){
				bbb[i][j]=ban;
				if(aaa[i][j]=='#'){ban++;}
			}
			for(j=W-1;j>=0;j--){
				if(aaa[i][j]=='#'){break;}
				bbb[i][j]--;
			}
		}else if(i>0){bbb[i]=bbb[i-1];}
	}
	
	for(i=sai-1;i>=0;i--){bbb[i]=bbb[i+1];}
	for(i=0;i<H;i++){
		for(j=0;j<W;j++){
			cout<<bbb[i][j]<<' ';
		}
		cout<<endl;
		
	}
	return 0;
}


Measured memory_bytes: 1280
#-------最強ライブラリSCC(Python)ver25252------
#卍分解卍
#出力例は辺の順が逆！ずるい！

import copy
import sys
sys.setrecursionlimit(1000000)

class csr:
  # start 頂点iまでの頂点が、矢元として現れた回数
  # elist 矢先のリストを矢元の昇順にしたもの
  def __init__(s, n, edges):
    s.start = [0] * (n + 1)
    s.elist = [[] for _ in range(len(edges))]
    for e in edges:
      s.start[e[0] + 1] += 1
    for i in range(1, n + 1):
      s.start[i] += s.start[i - 1]
    counter = copy.deepcopy(s.start)
    for e in edges:
      s.elist[counter[e[0]]] = e[1]
      counter[e[0]] += 1

class scc_graph:

  edges = []

  # n 頂点数
  def __init__(s, n): s._n = n
  def num_vertices(s): return s._n
  # 辺を追加 frm 矢元 to 矢先
  # O(1)
  def add_edge(s, frm, to): s.edges.append([frm, [to]])

  # グループの個数と各頂点のグループidを返す
  def scc_ids(s):
    g = csr(s._n, s.edges)
    now_ord = group_num = 0
    visited = []
    low = [0] * s._n
    ord = [-1] * s._n
    ids = [0] * s._n
    # 再帰関数 
    def dfs(self, v, now_ord, group_num):
      low[v] = ord[v] = now_ord
      now_ord += 1
      visited.append(v)
      for i in range(g.start[v], g.start[v + 1]):
        to = g.elist[i][0]
        if ord[to] == -1:
          now_ord, group_num = self(self, to, now_ord, group_num)
          low[v] = min(low[v], low[to])
        else:
          low[v] = min(low[v], ord[to])
      if low[v] == ord[v]:
        while True:
          u = visited.pop()
          ord[u] = s._n
          ids[u] = group_num
          if u == v: break
        group_num += 1
      return now_ord, group_num

    for i in range(s._n):
      if ord[i] == -1: now_ord, group_num = dfs(dfs, i, now_ord, group_num)
    for i in range(s._n):
      ids[i] = group_num - 1 - ids[i]
    return [group_num, ids]

  # 強連結成分となっている頂点のリストのリスト トポロジカルソート済み
  # O(n + m)
  def scc(s):
    ids = s.scc_ids()
    group_num = ids[0]
    counts = [0] * group_num
    for x in ids[1]: counts[x] += 1
    groups = [[] for _ in range(group_num)]
    for i in range(s._n):
      groups[ids[1][i]].append(i)
    return groups


#-------最強ライブラリここまで------

def main():
  input = sys.stdin.readline

  n, m = list(map(int, input().split()))
  ab = [list(map(int, input().split())) for _ in range(m)]

  g = scc_graph(n)

  for i in range(m):
    u, v = ab[i]
    g.add_edge(u, v)

  scc = g.scc()

  print(len(scc))

  for v in scc:
    print(len(v), end = " ")
    for x in v:
      print(x, end = " ")
    print("")

main()

Measured memory_bytes: 278868
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
using namespace std;
typedef long long ll;
ll x;
int main(void){
  cin >> x;
  ll a = (x+10)/11;
  ll b = 0;
  if(x-11*(a-1) <= 6){
    a--;
    b = 1;
  }
  a *= 2;
  cout << a+b << endl;
}


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

int a, b, k;

int main() {
  cin >> a >> b >> k;
  for (int i = 0; i < k; ++i) {
    a /= 2;
    b += a;
    swap(a, b);
  }
  if (k & 1) swap(a, b);
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<algorithm>
#define mod 1000000007
using namespace std;
long long n,m,a,b,ans;
long long fac[1000005];
long long qpow(long long base,long long t)
{
	long long ret=1;
	while(t)
	{
		if(t&1) ret=ret*base%mod;
		base=base*base%mod;
		t>>=1;
	}

	return ret;
}
long long C(long long N,long long M)
{
	if(!M) return 1;
	if(N<M) return 0;
  	return fac[N]*qpow(fac[M],mod-2)%mod*qpow(fac[N-M],mod-2)%mod;
}
long long solve(long long h,long long w)
{
	return C(h+w-2,h-1);
}
int main()
{
	int i,j;
	long long A,B,C,D,t1,t2,t;
	cin>>n>>m>>a>>b;
	fac[0]=1;
	for(i=1;i<=n+m;i++)
		fac[i]=fac[i-1]*i%mod;
	for(i=b+1;i<=m;i++)
	{
		t=solve(n-a,i)*solve(a,m-i+1)%mod;
		ans=(ans+t)%mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
m,k=map(int,input().split())
lst=list(map(int,input().split()))
if 0 in lst:
    k-=1
    if k==0:
        print(0)
        exit()
p=list(filter(lambda x:x>0,lst))
n=list(map(abs,filter(lambda x:x<0,lst)))
n.sort()
ans=[]
if len(n)>=k:
    ans.append(n[k-1])
i=min(len(n),k-1)-1
while i>=0 and 0<=k-i-2<len(p):
    ans.append(n[i]*2+p[k-i-2])
    i-=1
i=min(len(p),k-1)-1
if len(p)>=k:
    ans.append(p[k-1])
while i>=0 and 0<=k-i-2<len(n):
    ans.append(p[i]*2+n[k-i-2])
    i-=1
print(min(ans))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int ans = 0, cnt = 1;
    bool f = false;
    rep(i, n - 1)
    {
        if (s[i] != s[i + 1])
        {
            if (f)
            {
                f = false;
                cnt++;
            }
            else
            {
                if (k != 0)
                {
                    f = true;
                    cnt++;
                    k--;
                }
                else
                {
                    ans += cnt - 1;
                    cnt = 1;
                }
            }
        }
        else
        {
            cnt++;
        }
    }
    ans += cnt - 1;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int main()
{
    int h, w;
    cin >> h >> w;
    vector<vector<int>> s(h, vector<int>(w));
    rep(i, h)
    {
        rep(j, w)
        {
            char c;
            cin >> c;
            if (c == '#')
            {
                s[i][j] = 1;
            }
            else
            {
                s[i][j] = 0;
            }
        }
    }
    int mvx[2] = {1, 0};
    int mvy[2] = {0, 1};
    queue<pair<int, int>> que;
    que.emplace(0, 0);
    vector<vector<int>> use(h, vector<int>(w, INF));
    int color = 0;
    if (s[0][0] != color)
        use[0][0] = 1;
    else
        use[0][0] = 0;
    map <pair<int,int>,int> mp;
    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        color = s[p.first][p.second];
        rep(i, 2)
        {
            int nx = p.second + mvx[i];
            int ny = p.first + mvy[i];
            if (nx >= w || ny >= h)
                continue;
            if (color != s[ny][nx] && s[ny][nx] == 1)
                use[ny][nx] = min(use[ny][nx], use[p.first][p.second] + 1);
            else
            {
                use[ny][nx] = min(use[p.first][p.second], use[ny][nx]);
            }
            if (mp[make_pair(ny, nx)]==0)
                que.emplace(ny, nx);
            mp[make_pair(ny, nx)]++;
        }
    }
    cout << use[h - 1][w - 1] << endl;
}

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

using namespace std;


int main()
{
//    const int N = 10000000;
    int N;
    cin >> N;
    unsigned long long a[N + 1];
    for (int i = 1; i <= N; i++) {
        a[i] = 1;
    }
    for (int i = 2; i<= N; i++) {
        for (int j = 1; ; j++) {
            if (i * j <= N) {
                a[i * j]++;
            } else {
                break;
            }
        }
    }
    unsigned long long sum = 0;
    for (int i = 1; i <= N; i++) {
        sum += i * a[i];
    }
    cout << sum << endl;
    return 0;
}

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

using namespace std;

int h,w;
int c[10][10];
int a[10] = {0,0,0,0,0,0,0,0,0,0};

int min_cost[10] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1};

int get_min(int *cost, bool *f){
    int min = 1000;
    for(int i = 0; i < 10; i++){
        if(f[i]){
            if(min >= cost[i]) {
                min = cost[i];
            }
        }
    }
    for (int i = 0; i < 10; i++)
    {
        if (f[i])
        {
            if (min == cost[i])
            {
                f[i] = false;
            }
        }
    }
    return min;
}

int calc(int num){
    int min;
    int cost[10];
    bool f[10] = {true, true, true, true, true, true, true, true, true, true};
    for(int i = 0; i < 10; i++) cost[i] = c[num][i];
    f[num] = false;
    do{
        min = get_min(cost, f);
        for (int j = 0; j < 10; j++)
        {
            if (!f[j] && j != num)
            {
                for (int k = 0; k < 10; k++)
                {
                    if (f[k])
                    {
                        int buf = cost[j] + c[j][k];
                        if (cost[k] > buf) cost[k] = buf;
                    }
                }
            }
        }
    }while(f[1]);
    return cost[1];
}

int main(){
    cin >> h >> w;
    int buf, cost = 0;
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cin >> c[i][j];
        }
    }
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> buf;
            if(buf == 1 || buf == -1) continue;
            a[buf]++;
        }
    }
    for(int i = 0; i < 10; i++){
        if(i == 1) continue;
        if(a[i] > 0){
            cost = cost + calc(i) * a[i];
        }
    }
    cout << cost << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 1000000010
#define EPS 1e-9
#define fst first
#define scd second

#define debug(x) cout<<x<<endl;
#define repi(i,x,n) for(int i=x;i<n;i++)
#define rep(i,n) repi(i,0,n)
#define lp(i,n) repi(i,0,n)
#define repn(i,n) for(int i=n;i>=0;i--)
#define int long long
#define endl "\n"


signed main(){
  cin.tie(0);	
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  rep(i,50000){
    int num=(i+1)*(1.08);
    if(num==n){cout<<i+1<<endl;return 0;}
  }
  cout<<":("<<endl;

  return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> PP;

struct edge {
	int to, cost;
	edge(int t,int c):to(t),cost(c) {}
};

int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int ddx[]={1,1,1,0,-1,-1,-1,0},ddy[]={1,0,-1,-1,-1,0,1,1};

ll mypow(ll x,ll n,ll m) {	//xのn乗をmで割った余り
	if(n==0) return 1;
	if(n%2==0) return mypow(x*x%m,n/2,m);
	else return x*mypow(x,n-1,m)%m;
}

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

string s;
int prv[26],dist[26];
int flg,FLG=-1;

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

	cin>>s;
	REP(i,26) prv[i]=-1,dist[i]=-1;
	REP(i,s.size()) {
		int p=s[i]-'a';
		if(prv[p]==-1) dist[p]=i;
	  else dist[p]=max(dist[p],i-prv[p]-1);
		prv[p]=i;
		if(i==0) FLG=p;
		else if(FLG!=p) flg=1;
	}
	if(flg==0) {
		cout<<0<<endl;
		return 0;
	}
	int sz=s.size();
	REP(i,26) {
		if(dist[i]==-1) continue;
		dist[i]=max(dist[i],sz-prv[i]-1);
	}
	int ans=INF;
	REP(i,26) {
		if(dist[i]==-1) continue;
		ans=min(ans,dist[i]);
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#include <atcoder/all>
#define popcount __builtin_popcount
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef pair<int, int> P;
using mint=modint998244353;
mint f[2000010], invf[2000010];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i;
    invf[n]=mint(1)/f[n];
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1);
}
mint comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]*invf[x-y];
}
mint p2i[200020];
vector<vector<mint>> vp;
vector<mint> solve(int l, int r){
    if(l==r){
        return vp[l];
    }
    int m=(l+r)/2;
    return convolution(solve(l, m), solve(m+1, r));
}
int main()
{
    int n;
    cin>>n;
    int c[100010]={};
    for(int i=0; i<2*n; i++){
        int h; cin>>h;
        c[h]++;
    }
  fac(100000);
    p2i[0]=1, p2i[1]=mint(1)/mint(2);
    for(int i=2; i<=100000; i++) p2i[i]=p2i[i-1]*p2i[1];
    vector<int> vc;
    for(int i=0; i<=100000; i++){
        if(c[i]) vc.push_back(c[i]);
    }
    auto calc=[&](int k){
        return f[2*k]*p2i[k]*invf[k];
    };
    for(auto x:vc){
        vector<mint> vpi(x/2+1);
        for(int i=0; i<=x/2; i++){
            vpi[i]=comb(x, 2*i)*calc(i);
        }
        vp.push_back(vpi);
    }
    int s=vp.size();
    auto v=solve(0, s-1);
    mint ans=0;
    for(int i=0; i<=n; i++){
        if(i>=v.size())break;
        mint z=calc(n-i)*v[i];
        if(i&1) ans-=z;
        else ans+=z;
    }
    cout<<ans.val()<<endl;
    return 0;
}

Measured memory_bytes: 25896
n,m = map(int,input().split())
li = [int(input()) for i in range(m)]
p = 1000000007
ans = 0

steps = [0]*(max(10,n+1))
steps[1] = 1
steps[2] = 2
for i in range(3,n+1):
  steps[i] = (steps[i-1] + steps[i-2])%p
if m == 0:
  print(steps[n])
else:
  if li[0] == 1:
    ans += 1
  else:
    ans += steps[li[0]-1]%p

  for i in range(m-1):
    if li[i+1] == li[i]:
      continue
    elif li[i+1] - li[i] == 1:
      ans = 0
    elif li[i+1] - li[i] == 2:
      continue
    else:
      ans *= steps[li[i+1]-li[i]-2]
      ans %= p

  if li[m-1] == n-1: 
    print(ans)
  else:
    print((ans*steps[n-li[m-1]-1])%p)

Measured memory_bytes: 11048
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    string S;
    int f=0;
    long long int ans=1;
    cin >> S;
    for(int i=0;i<S.size()-1;i++){
        if(f==1){
            ans++;
            f=0;
        }
        else if(S[i] == S[i+1] && i==S.size()-2){
            i++;
        }
        else if(S[i] == S[i+1]){
            ans++;
            i++;
            f = 1;
        }else{
            ans++;
            f=0;
        }
    }

    
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.*;

public class Main {
    static Scanner scanner;

    public static void main(String[] args) {
        scanner = new Scanner(System.in);
        String a = scanner.nextLine();
        String b = scanner.nextLine();
        if (b.startsWith(a)) printYes();
        else printNo();
    }

    public static int nextInt() {
        return Integer.parseInt(scanner.next());
    }

    public static long nextLong() {
        return Long.parseLong(scanner.next());
    }

    public static double nextDouble() {
        return Double.parseDouble(scanner.next());
    }

    public static short nextShort() {
        return Short.parseShort(scanner.next());
    }

    public static float nextFloat() {
        return Float.parseFloat(scanner.next());
    }

    public static void printYes() {
        System.out.println("Yes");
    }

    public static void printYES() {
        System.out.println("YES");
    }

    public static void printNo() {
        System.out.println("No");
    }

    public static void printNO() {
        System.out.println("NO");
    }

    public static void nextLine() {
        scanner.nextLine();
    }
}

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

using namespace std;

template<typename T>
long long modpow(const T n,const T p,const T mod);
template<typename T>
long long modinv(const T n,const T mod);
template<typename T>
bool chmax(T &a,const T &b);
template<typename T>
bool chmin(T &a,const T &b);

long long inf=1000000007;

int main(){
	long long h,w,m;
	cin>>h>>w>>m;
	map<pair<long long,long long>,long long> zisyo;
	vector<long long> H(300001,0),W=H;

	for(long long i=0;i<m;i++){
		long long a,b;
		cin>>a>>b;
		H[a]++;
		W[b]++;
		zisyo[make_pair(a,b)]=1;
	}

	long long cntH=-1;
	long long cntW=-1;
	vector<long long> maxH,maxW;

	for(long long i=0;i<=300000;i++){
		if(H.at(i)>cntH){
			maxH.clear();
			maxH.push_back(i);
			cntH=H.at(i);
		}else if(H.at(i)==cntH){
			maxH.push_back(i);
		}

		if(W.at(i)>cntW){
			maxW.clear();
			maxW.push_back(i);
			cntW=W.at(i);
		}else if(W.at(i)==cntW){
			maxW.push_back(i);
		}
	}

	long long add=-1;

	for(auto i:maxH){
		for(auto j:maxW){
			if(!zisyo.count(make_pair(i,j))){
				add=0;
				break;
			}
		}
	}

	cout<<cntH+cntW+add<<endl;

	return 0;
}

template<typename T>
long long modpow(const T n,const T p,const T mod){
	if(p==0) return 1;
	if(p%2==0){
		long long a=modpow(n,p/2,mod);
		return a*a%mod;
	}
	if(p%2==1) return (modpow(n,p-1,mod)*n)%mod;
	cerr<<"ERROR"<<endl;
	return 1;
}

template<typename T>
long long modinv(const T n,const T mod){
	return modpow(n,mod-2,mod);
}

template<typename T>
bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return 1;
	}
	return 0;
}

template<typename T>
bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return 1;
	}
	return 0;
}


Measured memory_bytes: 32896
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	k := getNextInt(scanner)
	t := getNextInt(scanner)
	aa := make([]int, t)

	for i := 0; i < t; i++ {
		aa[i] = getNextInt(scanner)
	}
	sort.Ints(aa)
	ans := aa[t-1] - 1 - (k - aa[t-1])
	if ans < 0 {
		ans = 0
	}
	fmt.Fprintln(writer, ans)

	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long 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; }

int main(){
    vector<int> a(3);
    for(int i=0; i<3; i++) cin >> a[i];
    sort(a.begin(), a.end());
    if(a[0] == 5 && a[1] == 5 && a[2] == 7) cout << "YES\n";
    else cout << "NO\n";
}

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

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

    if(s.size() == 2){
        if(s[0] == s[1]){
            cout << 1 << " " << 2 << endl;
        } else {
            cout << -1 << " " << -1 << endl;
        }
        return 0;
    }
    for(int i = 0; i < s.size() - 3; i++){
        map <char, int> char_counts;
        for(int j = 0; j < 3; j++){
            if(char_counts.find(s[i + j]) != char_counts.end()){
                char_counts[s[i + j]] += 1;
            } else {
                char_counts[s[i + j]] = 1;
            }
        }

        for(auto it = char_counts.begin(); it != char_counts.end(); it++){
            if(it->second > 1){
                cout << i + 1 << " " << i + 3 << endl;
                return 0;
            }
        }
    }
    cout << -1 << " " << -1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	string s;
	cin>>s;
	if(s[2]==s[3] && s[4]==s[5])cout<<"Yes";
	else cout<<"No";	



}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 256
x1, y1, x2, y2 = list(map(int, input().split()))
diff_x = x2 - x1
diff_y = y2 - y1
x3 = x2 - diff_y
y3 = y2 + diff_x
x4 = x1 - diff_y
y4 = y1 + diff_x
print(" ".join(map(str,[x3, y3, x4, y4])))


Measured memory_bytes: 38256
#include<iostream>
using namespace std;
const int maxn=1<<18;
int n,up,mx[maxn],sec[maxn],dp[maxn];
void update(int i,int x){
	if(x>mx[i]){
		sec[i]=mx[i];
		mx[i]=x;
	}
	else if(x>sec[i]){
		sec[i]=x;
	}
}
signed main(){
	cin>>n;
	up=1<<n;
	for(int i=0;i<up;i++) cin>>mx[i];
	for(int j=0;j<n;j++){
		for(int i=0;i<up;i++){
			if((i>>j)&1){
				if(mx[i^(1<<j)]) update(i,mx[i^(1<<j)]);
				if(sec[i^(1<<j)]) update(i,sec[i^(1<<j)]);
			}
		}
	}
	for(int i=1;i<up;i++){
		dp[i]=max(dp[i-1],mx[i]+sec[i]);
		cout<<dp[i]<<endl;
	}
}

Measured memory_bytes: 6700
#!/usr/bin/env python3
mod = 10**9 + 7
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]
ok = [True] * (n + 1)
for x in a:
    ok[x] = False
dp = [0] * (n + 1)
dp[0] = 1
for i in range(n + 1):
    if i > 0 and ok[i - 1]:
        dp[i] = (dp[i] + dp[i - 1]) % mod
    if i > 1 and ok[i - 2]:
        dp[i] = (dp[i] + dp[i - 2]) % mod
print(dp[n])


Measured memory_bytes: 9616
#include <iostream>
using namespace std;
int main(void){
    int a;
    cin >> a;
    if(a < 1200){
        cout << "ABC";
    }else if(1200 <= a && a < 2800){
        cout << "ARC";
    }else if(2800 <= a){
        cout << "AGC";
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int N,X,Y;

int main(){
  cin>>N>>X>>Y;
  int cnt[2800];
  for(int i=1; i<=N-1; i++){
    for(int j=i+1; j<=N; j++){
      cnt[min(j-i,abs(X-i)+1+abs(Y-j))]++;
    }
  }
  for(int k=1;k<N;k++)cout<<cnt[k]<<endl;
}


Measured memory_bytes: 256