akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>

int main()
{
    long long n, m; std::cin >> n >> m;

    long long ans;
    if(n > m) {
        std::swap(n,m);
    }
    
    if(n == 1) {
        ans = abs(m - 2);
    }else if( n == 2) {
        ans = 0;
    } else {
        ans = (n-2)*abs((m-2));
    }

    std::cout << ans << std::endl;
}

Measured memory_bytes: 3604
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner scanner = new Scanner(System.in);
		
		int a = scanner.nextInt();
		
		int b = scanner.nextInt();
		
		int c = scanner.nextInt();
		
		scanner.close();
		
		int t;
		
		t = a;
		
		a = b;
		
		b = t;
		
		t = a;
		
		a = c;
		
		c = t;
		
		System.out.println(a + " " + b + " " + c);
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll dp[105000][14];
string S;

int main() {
    cin >> S;
    S = "#" + S;
    dp[0][0] = 1;
    for(int index = 1; index < S.size(); index++) {
        for(int before = 0; before < 13; before++) {
            for(int digit = 0; digit <= 9; digit++) {
                if(S[index] != '?' && S[index] != ('0' + digit)) continue;
                int after = (before * 10 + digit) % 13;
                dp[index][after] += dp[index-1][before];
                dp[index][after] %= mod;
            }
        }
    }
    cout << dp[S.size() - 1][5] << endl;
    return 0;
}


Measured memory_bytes: 11388
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 余りが0~12の桁DP
S = sr()
MOD = 10 ** 9 + 7
dp = [0] * 13 # 余り
dp[0] = 1
for s in S:
    prev = [x for x in dp]
    dp = [0] * 13
    if s == '?':
        add = range(10)
    else:
        add = [int(s)]
    for x in range(13):
        for a in add:
            dp[(10*x + a) % 13] += prev[x]
    dp = [y%MOD for y in dp]

print(dp[5])
        

Measured memory_bytes: 43740
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	int a[n], b[n], c[n], a1[n], b1[n], c1[n];
	for(int i=0; i<n; i++)
		cin>>a[i]>>b[i]>>c[i];
	a1[0]=a[0];
	b1[0]=b[0];
	c1[0]=c[0];
	for(int i=1; i<n; i++){
		a1[i]=max(b1[i-1],c1[i-1])+a[i];
		b1[i]=max(a1[i-1],c1[i-1])+b[i];
		c1[i]=max(a1[i-1],b1[i-1])+c[i];
	}
	int ans=max(a1[n-1],b1[n-1]);
	ans=max(ans,c1[n-1]);
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
read = map(int, open(0).readlines()).__next__
ans = []
while 1:
    D = read()
    if D == 0:
        break
    N = read()
    M = read()
    P = [read() for i in range(N-1)]
    P.append(0); P.append(D)
    Q = [read() for i in range(M)]

    P.sort(); Q.sort()
    it = iter(P).__next__
    prv = 0; nxt = it(); idx = 0
    res = 0
    for q in Q:
        while nxt <= q:
            prv = nxt; nxt = it()
        res += min(q - prv, nxt - q)
    ans.append("%d\n" % res)
open(1, 'w').writelines(ans)


Measured memory_bytes: 20136
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <tuple>
#include <bitset>

#include <queue>
#include <complex>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <fstream>
#include <random>
//#include <time.h>
#include <ctime>
#pragma endregion //#include
/////////
#define REP(i, x, n) for(int i = x; i < n; ++i)
#define rep(i,n) REP(i,0,n)
#define ALL(X) X.begin(), X.end()
/////////
#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
typedef std::pair<LL,LL> PLL;//
typedef std::pair<int,int> PII;//
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

vector<bool> visit;
vector< vector<int> > gra;
int A,B;
void dfs(int v){
	visit[v] = true;
	int size = gra[v].size();
	int a,b;

	for(int i=0;i<size;++i){
		int to = gra[v][i];
		a = v;
		b = to;
		if( a > b )swap(a,b);
		if( A==a && B==b ) continue;
		if( visit[to] ) continue;//訪問済み
		dfs(to);
	}
}
void solve(){
	int N,K;
	cin >> N >> K;
	vector< pair<LL,LL> > pos(N);
	for(int i=0;i<N;++i){
		cin >> pos[i].first >> pos[i].second;
	}
	sort( pos.begin(), pos.end() );
	LL ans = LINF;
	if( K <= 3 ){
		vector<bool> v(N,false);
		for(int i=0;i<K;++i){
			v[N-1-i] = true;
		}
		do{
			LL MIN_X = +LINF;
			LL MAX_X = -LINF;
			LL MIN_Y = +LINF;
			LL MAX_Y = -LINF;
			for(int i=0;i<N;++i){
				if( v[i] ){
					MIN_X = min(MIN_X,pos[i].first);
					MAX_X = max(MAX_X,pos[i].first);
					MIN_Y = min(MIN_Y,pos[i].second);
					MAX_Y = max(MAX_Y,pos[i].second);
				}
			}
			LL AAA =(MAX_X-MIN_X)*(MAX_Y-MIN_Y);
			ans = min(ans, AAA );
		}while(next_permutation(v.begin(),v.end()));
		cout << ans << endl;
		return;
	}

	for(int A=0;A<N;++A){for(int B=A+1;B<N;++B){
	for(int C=B+1;C<N;++C){for(int D=C+1;D<N;++D){
		
		LL MIN_X = pos[A].first;
		MIN_X = min(MIN_X,pos[B].first);
		MIN_X = min(MIN_X,pos[C].first);
		MIN_X = min(MIN_X,pos[D].first);

		LL MAX_X = pos[A].first;
		MAX_X = max(MAX_X,pos[B].first);
		MAX_X = max(MAX_X,pos[C].first);
		MAX_X = max(MAX_X,pos[D].first);

		LL MIN_Y = pos[A].second;
		MIN_Y = min(MIN_Y,pos[B].second);
		MIN_Y = min(MIN_Y,pos[C].second);
		MIN_Y = min(MIN_Y,pos[D].second);

		LL MAX_Y = pos[A].second;
		MAX_Y = max(MAX_Y,pos[B].second);
		MAX_Y = max(MAX_Y,pos[C].second);
		MAX_Y = max(MAX_Y,pos[D].second);
		
		int res = 0;
		for(int i=0;i<N;++i){
			LL x = pos[i].first;
			LL y = pos[i].second;
			if( MIN_X<=x && x<=MAX_X && MIN_Y<=y && y<=MAX_Y ){
				++res;
			}
		}
		if( res >= K ){
			LL AAA =(MAX_X-MIN_X)*(MAX_Y-MIN_Y);
			ans = min(ans, AAA );
		}
	}}}}
	cout << ans << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  
  n1 = N / 1000;
  n2 = (N - n1 * 1000) / 100;
  n3 = (N - n1 * 1000 - n2 * 100) / 10;
  n4 = (N - n1 * 1000 - n2 * 100 - n3 * 10);
    
  if (n1 == n2 && n2 == n3) {
    cout << "Yes" <<endl;
  }
  else if (n2 == n3 && n3 == n4) {
    cout << "Yes" <<endl;
  }
  else {
    cout << "No" <<endl;
  }
}



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

using namespace std;

int main(){
  int n;
  int alice = 0;
  int bob = 0;
  vector<int> a;

  cin >> n;
  for (int i = 0; i < n; i++) {
    int m;
    cin >> m;
    a.push_back(m);
  }
  sort(a.begin(), a.end(), greater<int>());

  for (int i = 0; i < n; i++) {
    if (i % 2 == 0) {
      alice += a[i];
    } else {
      bob += a[i];
    }
  }

  cout << alice - bob << endl;
  return 0;
}


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

int main(){
  string pass,newpass;
  cin >> pass;
  cin >> newpass;
  int i=pass.size();
  int j=0;
  for(j=0;j<i;j++){
    if(pass.at(j)!=newpass.at(j)){
      cout << "No" <<endl;
      break;
    }
  }
  if(j==i){
    cout << "Yes" <<endl;
  }
}
    

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,k,n)       for(i=k;k<=n?i<=n:i>=n;k<=n?i++:i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
#define inf             1e18
#define mod             1000000007
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p,int m = inf) {int ans=1;x%=m;while(p>0){if(p&1)ans=(ans*x)%m;p=p>>1;x=(x*x)%m;}return ans;}
int inv(int x,int m=mod){return po(x,m-2,m)%m;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




const int N=1e6+6;
int n,m,k,x,y,z,a,b,c,d,i,j,l,r;








void sol()
{   
    cin>>n;
    
    c=0;
    mii m;
    vi v(50);
    fo(i,50)
    {
        v[i]=i*(i+1)/2;
    }
    while(n%2==0)n/=2,m[2]++;

    for(i=3;i*i<=n;i+=2)
    {
      while(n%i==0)n/=i,m[i]++;

    }
    
    if(n!=1)m[n]++;
    
    for(auto p:m)
    {
        i=lower_bound(all(v),p.ss)-v.begin();
        if(v[i]==p.ss)c+=i;
        else c+=i-1;
    }


    cout<< c <<endl;
}





int32_t main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3648
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
#include<tuple>
#include<stdio.h>
#include<set>

using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)

#define shosu setprecision(10)
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> Q;
typedef pair<Q,ll> R;
ll longinf=1ll<<60;
int inf=1<<29;
//mleしなければぜんぶllでかく。
//↑はあんまり気にしなくていい。

int main(){
    int n;
    cin>>n;
    pair<int,pair<string,int>> p[n];
    rep0(i,n){
        string s;
        int q;
        cin>>s>>q;
        p[i]={q,{s,i+1}};
    }
    sort(p,p+n);
    reverse(p,p+n);
    pair<string,pair<int,int>> q[n];
    rep0(i,n){
        q[i].first=p[i].second.first;
        q[i].second.first=-p[i].first;
        q[i].second.second=p[i].second.second;
    }
    sort(q,q+n);
    rep0(i,n)
    cout<<q[i].second.second<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define s(x) (x).begin(),(x).end();
using namespace std;
typedef long long ll; 
template<class T> inline bool chmax(T& a, T b) {
     if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) {
     if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL<<60;

int main(){

    int  N,W;
    cin >> N>>W;

    ll weight[110],varue[110];
    rep(i,N)cin >> weight[i] >> varue[i];

    ll dp[110][110000] ={0};

    rep(i,N){
        rep(j,W+1){
            if(weight[i]<=j)chmax(dp[i+1][j],dp[i][j-weight[i]]+varue[i]);
            
            chmax(dp[i+1][j],dp[i][j]);
        }
    }   
    cout<<dp[N][W]<<endl;
}

Measured memory_bytes: 94720
from collections import defaultdict

n, m = map(int, input().split())
yp = []
for i in range(m):
    p, y = map(int, input().split())
    yp.append((y, p, i))
yp = sorted(yp)

code = [0] * m
ctr = defaultdict(int)
for i in range(m):
    ctr[yp[i][1]] += 1
    x = ctr[yp[i][1]]
    code[yp[i][2]] = '{:06}{:06}'.format(yp[i][1], x)
for c in code:
    print(c)

Measured memory_bytes: 40792
n = gets.to_i
array=gets.chomp.split(" ").map(&:to_i)
count = 0
(0..(n-2)).each do |i|
    ((i+1)..(n-1)).to_a.reverse.each do |j|
        if array[j] < array[j-1]
            count += 1
            tmp = array[j]
            array[j] = array[j-1]
            array[j-1] = tmp
        end
    end
end
puts array.join(" ")
puts count


Measured memory_bytes: 6928
package main

import (
	"bufio"
	"fmt"
	"os"
	"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)

	n := getNextInt(scanner)
	a1 := make([]int, n+1)
	a2 := make([]int, n+1)
	for i := 1; i <= n; i++ {
		a1[i] = getNextInt(scanner)
		a1[i] += a1[i-1]
	}
	for i := 1; i <= n; i++ {
		a2[i] = getNextInt(scanner)
		a2[i] += a2[i-1]
	}

	ans := 0
	for i := 1; i <= n; i++ {
		got := a1[i] + a2[n] - a2[i-1]
		if ans < got {
			ans = got
		}
	}
	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int main()
{
    ll n, x;
    cin >> n >> x;
    
    vector<ll> a(n);
    for(ll i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    
    ll count = 0;
    for(ll i = 0; i < n -1; ++i)
    {
        if(a[i] + a[i + 1] > x)
        {
            ll temp = (a[i] + a[i + 1]) - x;
            a[i + 1] = max(0LL, a[i + 1] - temp);
            count += temp;
        }
    }
    
    cout << count << endl;
    return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

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

  int a, b, c; cin >> a >> c >> b;
  if(a > c) swap(a, c);
  cout << (a < b && b < c ? "Yes" : "No") << endl;
  
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';


template<typename T> void drop(const T &x){cout<<x<<endl;exit(0);}

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];

  Int res=0;
  for(Int i=2;i<n;i++) res^=as[i];


  Int x=as[0],y=as[1];

  const Int INF = 1LL<<60;
  Int dp[2][2];
  dp[0][0]=dp[0][1]=INF;
  dp[1][0]=dp[1][1]=INF;

  Int mask=(1<<20)-1;
  for(Int q=0;q<(1<<20);q++){
    Int a=(x-q)&mask;
    Int b=(y+q)&mask;
    if(a^b^(res&mask)) continue;
    chmin(dp[(x>>20)!=((x-q)>>20)][(y>>20)!=((y+q)>>20)],q);
  }

  Int ans=x;
  for(Int i=0;i<2;i++){
    for(Int j=0;j<2;j++){
      if(dp[i][j]==INF) continue;
      Int q=dp[i][j];
      for(Int p=0;p<(1<<20);p++){
        Int z=(p<<20)|q;
        if(z>=x) continue;
        if((x-z)^(y+z)^res) continue;
        chmin(ans,z);
      }
    }
  }

  if(ans>=x) ans=-1;
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <map>
using namespace std;

void yakubun(int &p,int &q){
	for(int i = 2; i <= min(q,p); i++){
		if(p%i==0&&q%i==0){
			p/=i;
			q/=i;
			i--;
		}
	}
}
int gcd(int a,int b){
	if(b==0)
		return a;
	return gcd(b,a%b);
}

int lcm(int a,int b){
	return a*b/gcd(a,b);
}
// ツ暗クツつォツ算ツづーツ行ツつ、
void subOperation(int p,int q,int r,int s,int &np,int &nq){
	int t=lcm(s,q);
	int u=(t/q)*p-(t/s)*r;
    yakubun(u,t);
    np=u;nq=t;
}

#define EPS (1e-10)
int lim;
int cnt;

void dfs(int p,int q,int next,int rem,int a){
    if(a>lim)
        return;
    else{
        if(p==1)
            if(a*q<=lim&&q>=next)
                cnt++;
        rem--;
        if(rem==0)
            return;
        if(next*next*a>lim)
            return;
        for(int i = (lim/a); i >= next; i--){
            if(i*i*a>lim)continue;
            int np,nq;
            subOperation(p,q,1,i,np,nq);
            if(np<=0)
                break;
            if(i*a*nq<=lim)
                dfs(np,nq,i,rem,i*a);
        }
    }
}

int main(){
    int p,q,a,n;
    while(cin>>p>>q>>a>>n&&!(p==0&&q==0&&a==0&&n==0)){
        lim=a;cnt=0;
        yakubun(p,q);
        // ツ催渉可づ個青板つゥツづァツづづアツづづアツ暗クツつ「ツづつ「ツつュツ催帰
        dfs(p,q,1,n,1);
        printf("%d\n",cnt);
    }
    return 0;
}

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

int gcd(int a,int b){
  while(a!=0){
    if(a<b) swap(a,b);
    a %= b;
  }
  return b;
}

int main(){
  int n,k;
  cin >> n >> k;
  int a[n];
  int ma=0;
  for(int i=0;i<n;i++) {cin >> a[i] ; ma = max(ma,a[i]);};
  int g = a[0];
  for(int i=1;i<n;i++) g = gcd(g,a[i]);
  if(ma>=k&&k%g==0) cout << "POSSIBLE" << endl;
  else cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=2e5+10;
int n,a[maxn],idx[maxn],idx_cnt;
struct szsz{
	int c[maxn];
	inline int lowbit(int x){
		return x&(-x);
	}
	int sum(int x){
		int res=0;
		while(x){
			res+=c[x];
			x-=lowbit(x);
		}
		return res;
	}
	void add(int x){
		while(x<=maxn-10){
			c[x]++;
			x+=lowbit(x);
		}
	}
	void clear(){
		REP(i,1,maxn-10) c[i]=0;
	}
}bit;
bool check(int x){
	ll res=0;
	int cur=1e5;
	bit.clear();
	bit.add(cur);
	REP(i,1,n){
		if(a[i]>=x) ++cur;else --cur;
		res+=bit.sum(cur);
		bit.add(cur);
	}
	return 2*res>=(ll)n*(n+1)/2;
}
int main(){
	n=read();
	REP(i,1,n) a[i]=read(),idx[++idx_cnt]=a[i];
	sort(idx+1,idx+idx_cnt+1);
	idx_cnt=unique(idx+1,idx+idx_cnt+1)-idx-1;
	REP(i,1,n) a[i]=lower_bound(idx+1,idx+idx_cnt+1,a[i])-idx;
	int L=1,R=idx_cnt;
	while(L<=R){
		int Mid=(L+R)>>1;
		if(check(Mid)) L=Mid+1;
		else R=Mid-1;
	}
	printf("%d\n",idx[L-1]);
	return 0;
}

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

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;


//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()

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

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


struct Edge {
    int to, from;
    ll cost;
    Edge(int from, int to, ll cost): from(from), to(to), cost(cost) {}
};

typedef vector<vector<Edge>> AdjList;
AdjList graph;


ll A[100010], B[100010];
int main() {
    //cin.tie(0);
    //ios::sync_with_stdio(false);
    //cout << fixed << setprecision(10);

    ll N, M; cin >> N >> M;

    vector<pair<ll, ll>> vp;
    REP(i, N){
        ll A, B; cin >> A >> B;
        vp.push_back({A, -B});
    }

    sort(all(vp));

    priority_queue<pair<ll, ll>> q;
    ll ans = 0;
    int i = 0;

    REP(m, M){
        for(; i < N && vp[i].first <= m+1; i++){
            q.push({-vp[i].second, vp[i].first});
        }

        if(q.size() > 0){
            ans += q.top().first;
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 4848
#include <stdio.h>
#include <math.h>

#define true  1
#define false 0

int isprime(int n) {
  // special condition
  if (2 == n) return true;
  for (int i = 2; i <= sqrt(n); i++) {
    if (0 == n % i) return false;
  }
  return true;
}

int main(int argc, char **argv) {
  int n, a, cmt = 0;

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a);
    if (isprime(a)) cmt++;
  }

  printf("%d\n", cmt);
  return 0;
}


Measured memory_bytes: 2044
#define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int n;
llint a[200000];
llint ans = 0;

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

    sort(a, a + n);

    for (int i = 0; i < n; i++) {
        ans += abs(a[i] - a[n / 2]);
    }

    cout << ans << endl;

    return 0;
}

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

#define loop(i, num) for (int i = 0; i < num; i++)

using namespace std;

string stones;

int getDifferent() {

    int differences = 0;
    
    char current = stones[0];
    
    for (int i = 1; i < stones.size(); i++) {
    
        if (stones[i] == current)  continue;
        
        else  differences++, current = stones[i];
        
    }
    
    return differences;

}

int main() {
    
    cin >> stones;
    
    cout << getDifferent() << endl;

}


Measured memory_bytes: 512
'use strict'

function main(s) {  
  
  // 入力処理
  const input = Number(s.replace(/\n/g, '').split(' ').join(''));
  const result = Number.isInteger(Math.sqrt(input));
  console.log(result ? 'Yes' : 'No');
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

// 入力データの最後には\nが挿入されている
// console.log(すると、自動で\nが挿入される)

Measured memory_bytes: 11468
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

int A, B, C;


int main(){
	
	cin>>A>>B>>C;
	
	if( A == B ) cout<<C<<endl;
	if( B == C ) cout<<A<<endl;
	if( C == A ) cout<<B<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define FORD(i,a,b) for(int i=(a);i>=(b);--i)
#define TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=1e5+5;
int n,a[N];
int bit[N];

void upd(int x,int v){
	for(;x<N;x=x|(x+1))
		bit[x]=max(bit[x],v);
}

int get(int x){
	int res=0;
	for(;x>=0;x=(x&(x+1))-1)
		res=max(res,bit[x]);
	return res;
}

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	vector<int> c;
	REP(i,n){
		cin>>a[i];
		c.pb(a[i]);
	}
	sort(all(c));
	int res=0;
	reverse(a,a+n);
	REP(i,n){
		int x=lower_bound(all(c),a[i])-c.begin();
		int len=get(x)+1;
		upd(x,len);
		res=max(res,len);
	}
	cout<<res<<'\n';
}



Measured memory_bytes: 4564
N = int(input())
num = list(map(int,input().split()))
c = 0
for i in range(N-2):
    a = [num[i],num[i+1],num[i+2]]
    b =num[i+1]
    a.sort()
    if a[1] == b:
        c += 1
print(c)


Measured memory_bytes: 2940
// 周囲にある枚数+1(自分自身)が偶数なら表,奇数なら裏?
// 場合分け
#include<iostream>
using namespace std;
typedef long long ll;
int main(){
  ll n,m; cin >> n >> m;
  if(n==1 || m==1){
    if(n==1 && m==1) cout << 1 << endl;
    else if(max(n,m)==2) cout << 0 << endl;
    else cout << max(n,m) - 2 << endl;
  }else{
    cout << (n-2)*(m-2) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}

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

  int a=0,b=0;
  rep(i,s.size()){
    if(i%2&&s[i]=='0') a++;
    if(i%2&&s[i]=='1') b++;
    if(i%2==0&&s[i]=='1') a++;
    if(i%2==0&&s[i]=='0') b++;
  }


  cout<<min(a,b)<<endl;
}


Measured memory_bytes: 512
n = int(input())
A = list(map(int, input().split()))
m = {}
for a in A:
    m.setdefault(a, 0)
    m[a] += 1
# print(m)
all_combination = 0
for v in m.values():
    if v > 1:
        all_combination += int(v * (v - 1) / 2)
for a in A:
    ans = all_combination - (m[a] - 1)
    print(ans)

Measured memory_bytes: 25644
#include <iostream>

using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    int eight = (A * 25 + A % 2) / 2;
    int eightM = eight + 12;
    if(eightM % 25 == 0) eightM--;
    int res = max(eight, 10 * B);
    if(res > eightM || res > (10 * B + 9)) cout << -1 << endl;
    else cout << res << endl;
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	// 109-A
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a == 2 || b ==2)
		{
			System.out.println("No");
		}
		else
		{
			System.out.println("Yes");
		}

		sc.close();
	}
}

Measured memory_bytes: 23252
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int a, b;
  cin >> a >> b;
  cout << a * b << '\n';

  return 0;
}


Measured memory_bytes: 3628
import Control.Monad
main = do
  [h, w] <- map read . words <$> getLine
  a <- replicateM h getLine
  putStrLn $ solve h w a

solve:: Int -> Int -> [String] -> String
solve h w a = foldl (++) "" $ [tb, "\n"] ++ (map dec a) ++ [tb]
  where
    tb = replicate (w + 2) '#'

dec:: String -> String
dec s = "#" ++ s ++ "#\n"

Measured memory_bytes: 1532
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())//vectorの降順ソート
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;

typedef tuple<ll, ll, ll> T;

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


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    cout<<(b-a==c-b ? "YES":"NO")<<endl;
}

Measured memory_bytes: 256
def dp(H, N, ab):
  max_a = max([ab[i][0] for i in range(N)])
  d = [INF for _ in range(H + max_a)]
  d[0] = 0
  for h in range(1, H + max_a):
    d[h] = min(d[h - a] + b for a, b in ab)
  return min(d[H:])
INF = 10 ** 10
H, N = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(N)]
print(dp(H, N, ab))

Measured memory_bytes: 3716
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int main() {
	int a,p,ma=0,cnt=0,last;
	cin>>a;
	for(int i=0;i<a;i++){
		cin>>p;
		if(last>=p && i!=0) cnt++;
		if(last<p && i!=0)
		{
			ma=max(cnt,ma);
			cnt=0;
		}
		last=p;
	}
	cout<<max(cnt,ma)<<endl;
	return 0;
}

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

using namespace std;

int main() {
  string s;
  cin >> s;
  if (s[1] == 'B') {
    cout << "ARC" << endl;
  } else {
    cout << "ABC" << endl;
  }

  return 0;
}
/* vim:set fdm=marker: */


Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y;  cin >> x >> y;
    ll ans = 0;
    while (x <= y) {
      ans++;
      x *= 2;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
d,x = gets.split.map(&:to_i)
count = 0
n.times do
  a = gets.to_i
  day = 1
  i = 0
  while day <= d
    count += 1
    i += 1
    day = (i * a) + 1
  end
end
count += x
puts count

Measured memory_bytes: 1788
class UnionFind(object):
    def __init__(self, size):
        self.parent = [i for i in range(size)]
        self.rank = [0 for _ in range(size)]
 
 
    def find(self, x):
        if self.parent[x] == x:
            return x
        else:
            return self.find(self.parent[x])
 
 
    def unite(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
 
        if self.rank[x] < self.rank[y]:
            self.parent[x] = y
        else:
            self.parent[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
 
    def same(self, x, y):
        return self.find(x) == self.find(y)
n, m = map(int, input().split())
U=UnionFind(n)
for i in range(m):
    x, y, z = map(int, input().split())
    U.unite(x-1, y-1)
cnt=0
for i in range(n):
    if U.find(i)==i:
        cnt+=1
print(cnt)

Measured memory_bytes: 94112
#include <stdio.h>

int main(void) {
  int N, X;
  scanf("%d %d", &N, &X);
  int L[100];
  for(int i = 0; i < N; i++) {
    scanf("%d", &L[i]);
  }

  int P = 0;
  int num = 0;
  while(P <= X) {
    if(num == N+1) break;
    P += L[num++];
  }
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 128
//懒得打
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <vector>
using namespace std;

const int N = 200005;

long long a[N],b[N];
long long c[N],d[N];

bool f[35];

int main()
{
    int n;
    
    scanf("%d",&n);
    
    for (int i = 0;i < n;i++)
    {
        scanf("%lld",&a[i]);
    }
    
    for (int i = 0;i < n;i++)
    {
        scanf("%lld",&b[i]);
    }
    
    for (int i = 0;i <= 30;i++)
    {
        long long t = ((long long)1 << i);
        
        for (int j = 0;j < n;j++)
        {
            c[j] = a[j] % (2 * t);
            d[j] = b[j] % (2 * t);
        }
        
        sort(d,d+n);
        
        for (int j = 0;j < n;j++)
        {
            long long y = 2 * t - c[j];
            long long x = t - c[j];
            
            int p1 = lower_bound(d,d+n,x) - d;
            int p2 = lower_bound(d,d+n,y) - d;
            
            if (d[p2] >= y) p2--;
            if (p2 >= n) p2--;
            //if (p1 >= n) p1--;
            
            if (p2 >= p1 && (p2 - p1 + 1) % 2) f[i] = !f[i];
            
            y = 4 * t - c[j];
            x = 3 * t - c[j];
            
            p1 = lower_bound(d,d+n,x) - d;
            p2 = lower_bound(d,d+n,y) - d;
            
            if (d[p2] >= y) p2--;
            if (p2 >= n) p2--;
            //if (p1 >= n) p1--;
            
            if (p2 >= p1 && (p2 - p1 + 1) % 2) f[i] = !f[i];
        }
    }
    
    long long ans = 0;
    
    for (int i = 0;i <= 30;i++)
    {
        if (f[i]) ans |= ((long long)1 << i);
    }
    
    printf("%lld\n",ans);
    
    return 0;
}

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

char c[3009][3009]; int H, W, p[3009], dp[3009][3];
bool useda[3009], usedb[3009];

int solve() {
	for (int i = 0; i < 3009; i++) { dp[i][0] = 0; dp[i][1] = 0; dp[i][2] = 0; }

	for (int i = H; i >= 1; i--) {
		if (useda[i] == true) {
			for (int j = 0; j <= 2; j++) dp[i - 1][2] = max(dp[i - 1][2], dp[i][j] + 1);
		}
		if (p[i] >= 1 && usedb[p[i]] == true) dp[i - 1][0] = max(dp[i - 1][0], dp[i][0] + 1);
		dp[i - 1][0] = max(dp[i - 1][0], max(dp[i][0], dp[i][1]));
		dp[i - 1][1] = max(dp[i - 1][1], dp[i][2]);
	}
	return max({ dp[0][0], dp[0][1], dp[0][2] });
}

int main() {
	cin >> H >> W;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> c[i][j];
		}
	}

	int ans = 0;
	for (int i = 2; i <= H + W; i++) {
		for (int j = 1; j <= H; j++) useda[j] = false;
		for (int j = 1; j <= W; j++) usedb[j] = false;
		for (int j = 1; j <= H; j++) p[j] = 0;

		vector<pair<int, int>> G;
		for (int j = 1; j <= H; j++) {
			int x = j, y = i - j;
			if (1 <= y && y <= W) { G.push_back(make_pair(x, y)); p[x] = y; }
		}
		for (int j = 0; j < G.size(); j++) {
			int px = G[j].first, py = G[j].second;
			if (c[px][py] == 'R' && c[px][py + 1] == 'G' && c[px][py + 2] == 'W') useda[px] = true;
			if (c[px][py] == 'R' && c[px + 1][py] == 'G' && c[px + 2][py] == 'W') usedb[py] = true;
		}

		int Z = solve();
		ans += Z;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 12036
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>

typedef  long long ll;
#define mop 1000000007
using namespace std;

int main() {
    

    ll n;
    cin >> n;
    int flag = 0;
    ll ans = 0;
    for (ll i=0;i<=n;i++){
        ll tmp = floor(i*1.08);
        if(tmp == n){
            flag = 1;
            ans = i;
            break;
        }
    }
    if(flag){
        cout << ans << endl;
    }else{
        cout << ":(" << endl;
    }
}

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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

template <int64 M>
struct ModInt {
    int64 n;
    constexpr ModInt(const int64 n = 0) noexcept : n(n % M) {}
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt& operator+=(const ModInt rhs) noexcept {
        n += rhs.n;
        while (n >= M) {
            n -= M;
        }
        return *this;
    }
    constexpr ModInt& operator-=(const ModInt rhs) noexcept {
        n -= rhs.n;
        while (n < 0) {
            n += M;
        }
        return *this;
    }
    constexpr ModInt& operator*=(const ModInt rhs) noexcept {
        (n *= rhs.n) %= M;
        return *this;
    }
    constexpr ModInt& operator/=(ModInt rhs) noexcept {
        *this *= pow(rhs, M - 2);
        return *this;
    }
    constexpr ModInt inv() const noexcept {
        return pow(*this, M - 2);
    }

    static ModInt pow(ModInt a, int64 n) {
        ModInt res = 1;
        while (n) {
            if (n % 2) {
                res *= a;
            }
            a *= a;
            n /= 2;
        }
        return res;
    }
};

constexpr int MAX_N = 3000;
constexpr int MAX_S = 3000;
constexpr int64 MOD = 998244353;

ModInt<MOD> dp[MAX_N + 1][MAX_S + 1];

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

    int n, s;
    cin >> n >> s;

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

    dp[0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            dp[i + 1][j] += dp[i][j] * 2;
            if (j + a[i] <= s) {
                dp[i + 1][j + a[i]] += dp[i][j];
            }
        }
    }
    cout << dp[n][s].n << endl;

    return 0;
}



Measured memory_bytes: 74004
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
t=[int(input()) for i in range(D)]
last=[0]*26
m=0
for i in range(D):
    m+=s[i][t[i]-1]
    last[t[i]-1]=i+1
    for j in range(26):
        m-=c[j]*(i+1-last[j])
    print(m)

Measured memory_bytes: 68520
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n;
int k;
int h[MAX_N];

int main() {
    fastio();

    cin >> n >> k;
    forn(i, n) {
        cin >> h[i];
    }

    sort(h, h + n);

    ll total = 0;
    for (int i = 0; i < n - k; i++) {
        total += h[i];
    }

    cout << total << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#define int long long
using namespace std;
vector<string>v;
signed main() {
	int n; cin >> n; char c; bool ans = 1;
	for (int i = 0; i < n; i++) {
		string s; cin >> s;
		for (int j = 0; j < v.size(); j++)if (s == v[j])ans = 0;
		if (i)if (s[0] != c)ans = 0;
		v.push_back(s);
		c = s[s.size() - 1];
	}
	cout << (ans ? "Yes\n" : "No\n");
}

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

int main(void) {
	int a,b,i,k;
	while(scanf("%d %d",&a,&b) != EOF){
	for(i=1;i<8;i++){
	k = (a+b)/pow(10,i);
	if(k==0) goto pr;
	}
	pr :
	printf("%d\n", i);
	}
	
	
	return 0;
}

Measured memory_bytes: 644
N = int(input())
A = [int(i) for i in input().split()]

dp = [1000] * N
M = 1000
for i in range(N) :
  for j in range(i + 1, N) :
    if A[j] > A[i] :
      kabu = max(dp[:i + 1]) // A[i]
      kane = max(dp[:i + 1]) % A[i]
      dp[j] = max(dp[j], kane + kabu * A[j])

print(max(dp))

Measured memory_bytes: 68132
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int n, ans=0;
    string s;
    cin >> n >> s;
    for(int i=0;i<1000;i++){
      int c[3] = {i/100, (i/10)%10, i%10};
      int f=0;
      for(int j=0;j<n;j++){
        if(s[j]-'0'==c[f]){
          f++;
        }
        if(f==3){
          ans++;
          break;
        }
      }
    }
   
    cout << ans << endl;

}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define  rep(i,n) for(li i = 0; i < (n); ++i)
#define  red(i,n) for(li i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a) 
using namespace std;
using li = long long;
using ul = unsigned long long;
using vi = vector<li>;
using vs = vector<string>;
inline ul gcd(ul a,ul b) { return b?gcd(b,a%b):a; }
const int INF=1000000009;


int main()
{
    int n,a,b,x=0;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        int q=0;
        for(char c:s)q+=c-'0';
        if(a<=q&&q<=b)x+=i;
    }
    cout<<x<<endl;
    return 0;
}



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

using namespace std;

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

	if (A == B) {
		cout << C;
	}
	else if (B == C) {
		cout << A;
	}
	else {
		cout << B;
	}

	cout << endl;

	return 0;
}

Measured memory_bytes: 256
n = gets().to_i
arr = gets().split.map(&:to_i)

def bubble_sort(n, arr)
  cnt = 0
  for i in 0..(n-1)
    for j in (n-1).downto(i+1)
      if arr[j] < arr[j-1]
        arr[j], arr[j-1] = arr[j-1], arr[j]
        cnt += 1
      end
    end
  end
  return arr, cnt
end

arr, cnt = bubble_sort(n, arr)
puts arr.join(' ')
puts cnt


Measured memory_bytes: 6880
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vector<int> v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    set<lli> prime;
    prime.insert(2);
    for(lli i=3;i<=100000;i++){
        lli ic=i;
        for(auto j:prime){
            if(j*j>ic&&ic!=1){
                prime.insert(ic);
                break;
            }
            else{
                if(ic%j==0){
                    while(ic%j==0) ic/=j;
                }
            }
        }
    }
    vi cnt(1000001,0);
    for(auto v:prime){
        if(prime.count((v+1)/2)) cnt[v]+=1;
    }
    for(lli i=1;i<cnt.size();i++) cnt[i]+=cnt[i-1];
    lli q;
    cin>>q;
    rep(i,q){
        lli l,r,ans=0;
        cin>>l>>r;
        ans=cnt[r]-cnt[l-1];
        out(ans);
    }
}

Measured memory_bytes: 8960
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m,l;
//ll dp[15][1005];
void solve()
{   
  
string s;
cin>>s;
for(int i=0;i<3;i++)
{
    if(s[i]=='7') {cout<<"Yes\n";return;}
}
cout<<"No\n";




}    
int main()
{  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    //cout<<primes.size();
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}


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

int main(){
  int N;
  cin >> N;
  int mid=0, mval=0;
  for(int i=0; i<N; i++){
    int a, b;
    cin >> a >> b;
    if(a>mid){
      mid=a;
      mval=b;
    }
  }
  cout << mid+mval << endl;
  return 0;
}

Measured memory_bytes: 256