akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

fn main() {
    input! {
        (n, a, b, c) : (usize, usize, usize, usize),
        s : [String; n]
    };
    let mut dp = vec![[[[(3, 0); 7]; 7]; 7]; n+1];
    dp[0][a.min(6)][b.min(6)][c.min(6)].0 = 0;
    for i in 0..n {
        for ia in 0..=6 {
            for ib in 0..=6 {
                for ic in 0..=6 {
                    if dp[i][ia][ib][ic].0 == 3 { continue; }
                    if s[i] == "AB" {
                        if ib > 0 { dp[i+1][6.min(ia+1)][ib-1][ic] = (0, (ia*7+ib)*7+ic); }
                        if ia > 0 { dp[i+1][ia-1][6.min(ib+1)][ic] = (1, (ia*7+ib)*7+ic); }
                    }
                    if s[i] == "AC" {
                        if ic > 0 { dp[i+1][6.min(ia+1)][ib][ic-1] = (0, (ia*7+ib)*7+ic); }
                        if ia > 0 { dp[i+1][ia-1][ib][6.min(ic+1)] = (2, (ia*7+ib)*7+ic); }
                    }
                    if s[i] == "BC" {
                        if ic > 0 { dp[i+1][ia][6.min(ib+1)][ic-1] = (1, (ia*7+ib)*7+ic); }
                        if ib > 0 { dp[i+1][ia][ib-1][6.min(ic+1)] = (2, (ia*7+ib)*7+ic); }
                    }
                }
            }
        }
    }
    for ia in 0..=6 {
        for ib in 0..=6 {
            for ic in 0..=6 {
                if dp[n][ia][ib][ic].0 != 3 {
                    let mut res = vec![0; n];
                    let mut sa = ia;
                    let mut sb = ib;
                    let mut sc = ic;
                    for i in (0..n).rev() {
                        res[i] = dp[i+1][sa][sb][sc].0;
                        let idx = dp[i+1][sa][sb][sc].1;
                        sa = idx/7/7;
                        sb = idx/7%7;
                        sc = idx%7;
                    }
                    println!("Yes");
                    for t in res { println!("{}", ["A", "B", "C"][t]); }
                    return;
                }
            }
        }
    }
    println!("No");
}


Measured memory_bytes: 544524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P,P> PP;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

struct UnionFindTree {
    vector<int> par;
    vector<int> rank;
    vector<int> siz;

    void init(int n) {
        par.resize(n);
        rank.resize(n);
        siz.resize(n);
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
            siz[i] = 1;
        }
    }
    int find(int x) {
        if (par[x] == x) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) rank[x]++;
        par[y] = x;
        siz[x] += siz[y];
    }
    bool is_same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        x = find(x);
        return siz[x];
    }
};

ll n, m;
P a[MAX_N];
UnionFindTree g;
map<int, int> deg;
bool used[MAX_N]{};
vector<ll> v;

int main() {
    cin >> n >> m;
    REP(i,n){
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a,a+n);
    g.init(n);
    REP(i,m){
        int x, y;
        cin >> x >> y;
        g.unite(x,y);
    }
    int dsum = 0;
    REP(i,n){
        if(deg.count(g.find(i))==0){
            deg[g.find(i)] = g.size(i);
            dsum += g.size(i);
        }
    }
    if((deg.size()-1)*2 > dsum){
        cout << "Impossible" << endl;
    }
    else if(deg.size()==1){
        cout << 0 << endl;
    }
    else{
        ll ans = 0;
        REP(i,n){
            int x = g.find(a[i].second);
            if(!used[x]){
                used[x] = true;
                ans += a[i].first;
                deg[x]--;
            }
            else if(deg[x]>0){
                v.push_back(a[i].first);
                deg[x]--;
            }
        }
        REP(i,int(deg.size()-2)){
            ans += v[i];
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 6912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		String t = sc.next();
		String[] s1 = s.split("");
		String[] t1 = t.split("");
		
		int ans = 0;
		
		for(int i = 0; i < s1.length; i++) {
			if(s1[i].equals(t1[i])) {
				
			}else {
				ans++;
			}
		}
		
		System.out.print(ans);
	}

}


Measured memory_bytes: 66836
#include <stdio.h>
#include <string.h>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <iostream>
using namespace std;

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

	map <int,int> m;

	for (int i=0;i<n;i++) {
		scanf ("%d", &a);
		for (int j=-1;j<=1;j++) {
			if (m.find(a+j) != m.end()) {
				m[a+j] ++;
			} else {
				m[a+j] = 1;
			}
		}
	}

	int k = 0;
	map<int,int> :: iterator it;
	for (it = m.begin(); it != m.end(); it++) {
		k = max(k, it->second);
	}

	cout << k << endl;

	return 0;
}

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

using namespace std;

int main()
{
  long long a, b, n; cin >> a >> b >> n;
  if(n >= b-1)
 	 n =(((n+1)/b) * b)-1;
  cout << ((long long)(a*n)/b) - (((long long)n/b)*a)<< endl;
}

Measured memory_bytes: 3632
# -*- coding: utf-8 -*-
import sys
import itertools

N, Y = [int(x) for x in input().split()]
M = [0, 0 , 0]

for c in itertools.combinations(range(N + 2), 2):
    M[0] = c[0]
    M[1] = c[1] - c[0] - 1
    M[2] = N - c[1] + 1
    money = M[0]*10000 + M[1]*5000 + M[2]*1000
    if money == Y:
        print(M[0], M[1], M[2])
        sys.exit()

print("-1 -1 -1")


Measured memory_bytes: 3064
/*
            _           __                _      _____ _____ _____ 
  ___ _   _| |__   ___ / _|_ __ ___  __ _| | __ |___  |___  |___  |
 / __| | | | '_ \ / _ \ |_| '__/ _ \/ _` | |/ /    / /   / /   / / 
| (__| |_| | |_) |  __/  _| | |  __/ (_| |   <    / /   / /   / /  
 \___|\__,_|_.__/ \___|_| |_|  \___|\__,_|_|\_\  /_/   /_/   /_/   

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll ;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vi;
typedef vector<pll> vpll;
typedef unordered_map <ll,ll> umap ; 
//#pragma GCC optimize "trapv"
#define loop(i,a,b) for(ll i=a ;i<b;i++)
#define For(i,n) for(int i=0;i<(ll)n;i++)
#define Rev(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,n) for(int i=1;i<=n;++i)
#define F first
#define S second
#define pb push_back
#define em emplace_back
#define all(v) (v).begin(),(v).end()                                                              
#define mems(x, y) memset(x, y, sizeof(x))
#define sz(v) (v).size()
#define mp(a,b) make_pair(a,b)
#define pf(n) cout<<n<<"\n"
#define pff(n) cout << n << " " ; 
#define ar array
#define endl "\n" 
#define PI acos(-1) 
//#define int ll 
long const M=1e9+7;
const long mxN =1e5+2 ;
void solve(){
  int a,b ; cin >> a >> b ;
  cout << a* b << endl ;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  //cout << setprecision(20) << fixed ;
  solve() ;
  //ll t ; cin >> t ; while(t--)solve() ;
	return 0;
}


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

using namespace std;

#define rep(i,m,n) for(long i=m;i<n;i++)


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

  if(b==1) cout << 0 << endl;
  else cout << (b-2)/(a-1)+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main() {
  int x,t; cin >> x >> t;
  COUT(max(0,x-t));
  return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

class Data{
public:
	ll y1,x1,y2,x2;
};

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

	ll H=in(),W=in();
	vector<vector<ll>> M(H,vector<ll>(W,0)),F(H,vector<ll>(W,0));
	REP(i,H){
		REP(j,W){
			M[i][j]=in();
		}
	}
	vector<Data> D;
	F[0][0]=1;
	queue<ll> Q;
	Q.push(0);
	while(!Q.empty()){
		auto x=Q.front();
		Q.pop();
		auto u=x%W,v=x/W;
		if(u<W-1 && F[v][u+1]==0){
			if(M[v][u]%2LL){
				M[v][u+1]++;
				Data d;
				d.y1=v,d.x1=u,d.y2=v,d.x2=u+1;
				D.push_back(d);
			}
			F[v][u+1]=1;
			Q.push(u+1+v*W);
		}
		else if(v<H-1 && F[v+1][u]==0){
			if(M[v][u]%2LL){
				M[v+1][u]++;
				Data d;
				d.y1=v,d.x1=u,d.y2=v+1,d.x2=u;
				D.push_back(d);
			}
			F[v+1][u]=1;
			Q.push(u+(v+1)*W);
		}
		else if(u>0 && F[v][u-1]==0){
			if(M[v][u]%2LL){
				M[v][u-1]++;
				Data d;
				d.y1=v,d.x1=u,d.y2=v,d.x2=u-1;
				D.push_back(d);
			}
			F[v][u-1]=1;
			Q.push(u-1+v*W);
		}
		else if(v>0 && F[v-1][u]==0){
			if(M[v][u]%2LL){
				M[v-1][u]++;
				Data d;
				d.y1=v,d.x1=u,d.y2=v-1,d.x2=u;
				D.push_back(d);
			}
			F[v-1][u]=1;
			Q.push(u+(v-1)*W);
		}
	}
	out(D.size());
	for(auto& x:D){
		out(x.y1+1,x.x1+1,x.y2+1,x.x2+1);
	}
	return 0;
}


Measured memory_bytes: 10224
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
ll a,b,c,k;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>a>>b>>c>>k;
	if(k%2==1)
		cout<<b-a<<"\n";
	else
		cout<<a-b<<"\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef tree<pair<int, int>, null_type, less<pair<int, int>>, rb_tree_tag,
		tree_order_statistics_node_update> ordered_set;

#define el				'\n'
#define sz(v)			((int)((v).size()))
#define all(v)          ((v).begin()),((v).end())
#define clr(v, d)		memset(v, d, sizeof(v))

double const EPS = 1e-8, PI = acos(-1);
const int N = 2e5 + 9, M = 1e4 + 9, OO = (int) 2e9 + 1;
const long long MOD = 998244353, INF = 1e18 + 9;

typedef long long ll;

void OUTPUT() {
	cout << fixed << setprecision(0);
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
}

void INPUT() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}

map<int, char> mp;

int main() {
//	INPUT();
	OUTPUT();
	bool can = 1;
	int n, m, id;
	char s;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> id >> s;
		id--;
		if (mp.find(id) == mp.end()) {
			mp[id] = s;
		} else {
			if (mp[id] != s)
				can = 0;
		}
	}
	int st = (n == 1 ? 0 : n == 2 ? 10 : 100);
	int ed = (n == 1 ? 10 : n == 2 ? 100 : 1000);
	for (int i = st; i < ed; i++) {
		bool check = 1;
		string str = to_string(i);
		for (auto xx : mp) {
			if (str[xx.first] != xx.second) {
				check = 0;
			}
		}
		if (check && can) {
			cout << str;
			return 0;
		}
	}
	cout << -1;
	return 0;

}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.setf(ios::fixed); cout.precision(20);
    int n; cin >> n;
    vector<ll> a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    ll mn = 0, mx = 0;
    if (n & 1) {
        mn = a[n / 2], mx = b[n / 2];
    } else {
        mn = a[n / 2 - 1] + a[n / 2];
        mx = b[n / 2 - 1] + b[n / 2];
    }
    cout << mx - mn + 1 << "\n";
}


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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010;

int n;
PII order[N];

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        int x;
        scanf("%d", &x);
        order[i] = {x, i};
    }
    sort(order + 1, order + 1 + n);

    for(int i = 1; i <= n; i++) printf("%d ", order[i].second);
    puts("");
    return 0;
}


Measured memory_bytes: 1536
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#define REP(i,n) for (int i=0;i<(n);i++)
using namespace std;

int main(){
    int n, m;
    cin >> n >> m;

    //外側だけ指定
    vector<vector<int>> v(m);
    for(int i = 0; i < m; ++i){
        int tmp;
        cin >> tmp;
        v[i].resize(tmp);
        for(int j = 0; j < tmp; ++j){
            cin >> v[i][j];
            --v[i][j];
        }
    }

    vector<int> p(m);
    REP(i, m) cin >> p[i];

    int res = 0;
    for(int bit = 0; bit < (1<<n); ++bit){
        bool ok = true;
        for(int i = 0; i < m; ++i){
            int con = 0;
            for(auto t : v[i]){//tがbitに入るかどうか
                if(bit & (1 << t)) ++con;
            }
            if(con % 2 != p[i])
                ok = false;
        }
        if(ok)
            ++res;
    }

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



Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
MOD = 1000000007
def POW(x, y): return pow(x, y, MOD)
def INV(x, m=MOD): return pow(x, m - 2, m)
def DIV(x, y, m=MOD): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()
def II(): return int(input())

N=II()
s=input()
last = ""
cnt = 0
for i in range(N):
    if last != s[i]:
        cnt += 1
        last = s[i]

print(cnt)


Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define ll long long
#define imfor(i, n) for(int i = 0; i < n; i++)
using namespace std;
ll MOD = 1000000007;

int main() {
    string s;
    cin >> s;
    reverse(s.begin(), s.end());
    int pos = 0;
    int f = 1;
    while (true) {
        if (pos == s.size()) {
            break;
        }
        string s1, s2, s3;
        imfor(i, 7) {
            s1.push_back(s[pos + i]);
        }
        imfor(i, 5) {
            s2.push_back(s[pos + i]);
        }
        imfor(i, 6) {
            s3.push_back(s[pos + i]);
        }
        if (pos + 6 <= s.size() - 1 && s1 == "remaerd") {
            pos += 7;
        }
        else if (pos + 4 <= s.size() - 1 && s2 == "maerd") {
            pos += 5;
        }
        else if (pos + 5 <= s.size() - 1 && s3 == "resare") {
            pos += 6;
        }
        else if (pos + 4 <= s.size() - 1 && s2 == "esare") {
            pos += 5;
        }
        else {
            f = 0;
            break;
        }
    }
    if (f) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 512
#include <iostream> 
#include <bits/stdc++.h>
#include <vector> 
#include <algorithm> 
#include <string>
#include <cmath>
#include <iomanip> 
#include<climits> 
#include <utility>      
#include <numeric> 
#include <iterator>
#include <map> 
using namespace std; 
#define ll long long int
int main() {
string s,t;
cin>>s>>t;
t.append(s);
cout<<t<<endl;  
}


Measured memory_bytes: 256
n = int(input())
s = input()
b = []
for i in range(n):
    if s[i] == '#':
        b.append(i)
if len(b) == 0:
    print(0)
else:
    ans = min(s[b[0]::].count('.'), s.count('#'))
    nb = len(b)
    for i in range(1,len(b)-1):
        ans = min(ans, i + n-b[i]-nb+i)
    print(ans)


Measured memory_bytes: 11368
import javax.sound.midi.Soundbank;
import java.util.*;
import java.lang.*;

public class Main
{
    public static void main (String[] args)
    {
        // your code goes here
        Scanner s = new Scanner(System.in);
        int n= s.nextInt();
        int c= 0;
        for(int j=0; j<n; j++)
        {
            int x = s.nextInt();
            if(j%2==0&&x%2==1)
                c++;
        }

        System.out.println(c);

    }
}


Measured memory_bytes: 35840
n,m = map(int,input().split())
l,r = map(int,input().split())
counter = 0
for i in range(m-1):
    l1,r1 = map(int,input().split())
    if l < l1:
        l = l1
    if r > r1:
        r = r1
if r < l:
    print(0)
else:
    print(r-l+1)


Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>

using namespace std;

typedef pair<int,int> ii;
typedef vector<int> vi;
#define REP(i, a, b) for(int i = int(a); i <= int(b); i++)
#define LOOP(i, v) for(int i = 0; i < v.size(); i++)
#define EPS 1e-9
#define INF 1e12
#define debug(x) cerr << "DEBUG : " << (#x) << " => " << (x) << endl

int R, C;
string s[12];
bool ok[12][12][12][12];

bool taken[12];
int with[12];
vi deja;

bool test()
{
  vector<ii > pp;
  REP(i, 0, R-1)
  {
    if(with[i] >= i) pp.push_back(make_pair(i, with[i]));
  }
  deja.assign(C, false);
  bool seul = false;
  REP(i, 0, C-1)
  {
    if(!deja[i])
    {
      REP(j, i+1, C-1)
      {
        bool oui = true;
        LOOP(k, pp)
        {
          if(!ok[pp[k].first][pp[k].second][i][j])
          {
            oui = false;
            break;
          }
        }
        if(oui)
        {
          deja[i] = true;
          deja[j] = true;
          break;
        }
      }
      if(!deja[i])
      {
        if(seul) return false;
        LOOP(k, pp)
        {
          if(!ok[pp[k].first][pp[k].second][i][i]) return false;
        }
        seul = true;
        deja[i] = true;
      }
    }
  }
  return true;
}

bool dp(int x, bool dejaun)
{
  if(x == R)
  {
    return test();
  }
  
  if(taken[x]) return dp(x+1, dejaun);
  else
  {
    if(!dejaun)
    {
      taken[x] = true;
      with[x] = x;
      if(dp(x+1, true)) return true;
      taken[x] = false;
    }
    REP(y, x+1, R-1)
    {
      if(!taken[y])
      {
        taken[x] = true;
        taken[y] = true;
        with[x] = y;
        with[y] = x;
        if(dp(x+1, dejaun)) return true;
        taken[x] = false;
        taken[y] = false;
      }
    }
    return false;
  }
}

int main()
{
  scanf("%d %d\n", &R, &C);
  
  REP(i, 0, R-1)
  {
    getline(cin, s[i]);
  }
  
  REP(i, 0, R-1)
  {
    REP(j, i, R-1)
    {
      REP(k, 0, C-1)
      {
        REP(l, k, C-1)
        {
          if(s[i][k] == s[j][l] && s[i][l] == s[j][k])
          {
            ok[i][j][k][l] = true;
            ok[i][j][l][k] = true;
            ok[j][i][k][l] = true;
            ok[j][i][l][k] = true;
          }
        }
      }
    }
  }
  
  REP(i, 0, R-1) taken[i] = false;
  if(dp(0, false)) printf("YES\n");
  else printf("NO\n");
  
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //setprecision
#include <cstdio>
#include <cstdlib>
#include <cmath>
#define PI 3.141592653589793

double surface(double a, double b, double C);
double length(double a, double b, double C);
double height(double a, double b, double C);

int main(void) {
    double a; // ????????????
    double b; // ????????????
    double C; // ?§?????????§??????
    std::cin >> a >> b >> C;
    C = C / 180 * PI;
    double S = surface(a, b, C);
    double L = length(a, b, C);
    double h = height(a, b, C);
    std::cout << std::fixed << std::setprecision(12);
    std::cout << S << std::endl;
    std::cout << L << std::endl;
    std::cout << h << std::endl;
    return EXIT_SUCCESS;
}

double surface(double a, double b, double C) {
    return a * b * sin(C) / 2.0;    
};

double length(double a, double b, double C) {
    double s = sqrt(a * a + b * b - 2 * a * b * cos(C)); 
    return a + b + s;
};

double height(double a, double b, double C) {
    double S = surface(a, b, C);
    return 2.0 * S / a;
};

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline

sys.setrecursionlimit(10000)


N, T = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

ma = A[-1]
mas = 1
resma = 0
rescc = 0
for i in range(N-2, -1 ,-1):
    if A[i] > ma:
        ma = A[i]
        mas = 1
    elif A[i] == ma:
        mas += 1
    else:
        if ma - A[i] > resma:
            resma = ma - A[i]
            rescc = 1
        elif ma - A[i] == resma:
            rescc += 1
        else:
            pass

print(rescc)

Measured memory_bytes: 15012
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

using namespace std;


using int64 = long long;
const int mod = (1e9 + 7);

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}


int main() {
  int H, W, K;
  cin >> H >> W >> K;
  auto item = make_v< int >(H, W);
  for(int i = 0; i < K; i++) {
    int y, x, v;
    cin >> y >> x >> v;
    --y, --x;
    item[y][x] = v;
  }
  auto dp = make_v< int64 >(4, W);
  for(int i = 0; i < H; i++) {
    auto nxt = make_v< int64 >(4, W);
    for(int j = 0; j < W; j++) {
      for(int k = 0; k < 4; k++) {
        chmax(nxt[0][j], dp[k][j]);
        chmax(nxt[1][j], dp[k][j] + item[i][j]);
        if(j > 0 && k < 3) chmax(nxt[k + 1][j], nxt[k][j - 1] + item[i][j]);
        if(j > 0) chmax(nxt[k][j], nxt[k][j - 1]);
      }
    }
    dp.swap(nxt);
  }
  cout << max({dp[0][W - 1], dp[1][W - 1], dp[2][W - 1], dp[3][W - 1]}) << "\n";
}



Measured memory_bytes: 38772
#!/usr/bin/env python3
import sys


def solve(N: int, K: int, h: "List[int]"):
    avg = sum(h)/N

    h.sort()

    ans = 1000000000000
    for i in range(N-K+1):
        ans = min(ans, h[i+K-1]-h[i])
    
    print(ans)

    return


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    h = [ int(next(tokens)) for _ in range(N) ]  # type: "List[int]"
    solve(N, K, h)

if __name__ == '__main__':
    main()


Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
int gcdEx(int a, int b, int *x, int *y){if(!a){*x=0;*y=1;return b;}
int x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
int modI(int b, int m)      {int x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}
typedef long long           ll;
typedef pair<int, int>      pii;
typedef vector<int>         vi;
typedef vector<pii>         vii;
typedef set<int>            si;
typedef map<string, int>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(int i=b;i<n;i++)
#define loopv(b,n,a)         for(int i=b;i<n;i+=a)
#define loopr(b,n)           for(int i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define mini(a)    ( min_element((a).begin(), (a).end()) - (a).begin())
#define maxi(a)    ( max_element((a).begin(), (a).end()) - (a).begin())
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (int)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}
#define trace1(x)               cerr<<#x<<": "<<x<<endl
#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
//#define ONlo
int main()
{
 // freopen("input.txt","r",stdin);
    ll t=1;
//    cin>>t;
    while(t--)
    {
        string s;
        cin>>s;
        ll n=s.size();
        ll ans=0;
        loop(i,0,n)
        {
            if(s[i]!=s[n-i-1])
            {
                s[n-i-1]=s[i];
                ans++;
            }
        }
        cout<<ans;
    }


return 0;
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

using namespace std;

int main()
{
    int W, a, b;
    if (scanf("%d%d%d", &W, &a, &b) < 3) return 0;

    int ans;

    if (a + W <= b)  ans = b - (a + W);
    else if (a <= b && b <= a + W) ans = 0;
    else if (a <= b + W && b <= a) ans = 0;
    else ans = a - (b + W);

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


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

#define pb push_back
#define mp make_pair

typedef long long ll;

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
  ll n, m;
  cin >> n >> m;

  if(n == 1 or m == 1) cout << max(1LL, n-2) * max(1LL, m-2) << endl;
  else cout << (n-2)*(m-2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int A, B, C;
  cin >> A >> B >> C;
  
  B *= C;
  
  if(B >= A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  
  //cout << B << endl;
}

Measured memory_bytes: 3592
import java.io.*;
import java.util.*;

public class Main {
  private static String solve(int n, char[] cs) {
    StringBuffer sb = new StringBuffer();
    for (char c : cs) {
      sb.append((char)((c - 'A' + n) % 26 + 'A'));
    }
    return sb.toString();
  }
  
  private static void execute(ContestReader reader, PrintWriter out) {
    int n = reader.nextInt();
    char[] cs = reader.nextCharArray();
    out.println(solve(n, cs));
  }
  
  public static void main(String[] args) {
    ContestReader reader = new ContestReader(System.in);
    PrintWriter out = new PrintWriter(System.out);
    execute(reader, out);
    out.flush();
  }
}

class ContestReader {
  private BufferedReader reader;
  private StringTokenizer tokenizer;
  
  ContestReader(InputStream in) {
    reader = new BufferedReader(new InputStreamReader(in));
  }
  
  public String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }
  
  public int nextInt() {
    return Integer.parseInt(next());
  }
  
  public long nextLong() {
    return Long.parseLong(next());
  }
  
  public double nextDouble() {
    return Double.parseDouble(next());
  }
  
  public String[] next(int n) {
    String[] array = new String[n];
    for (int i = 0; i < n; i++) {
      array[i] = next();
    }
    return array;
  }
  
  public int[] nextInt(int n) {
    int[] array = new int[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextInt();
    }
    return array;
  }
  
  public long[] nextLong(int n) {
    long[] array = new long[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextLong();
    }
    return array;
  }
  
  public double[] nextDouble(int n) {
    double[] array = new double[n];
    for (int i = 0; i < n; i++) {
      array[i] = nextDouble();
    }
    return array;
  }
  
  public char[] nextCharArray() {
    return next().toCharArray();
  }
  
  public int[][] nextInt(int n, int m) {
    int[][] matrix = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextInt();
      }
    }
    return matrix;
  }
  
  public long[][] nextLong(int n, int m) {
    long[][] matrix = new long[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextLong();
      }
    }
    return matrix;
  }
  
  public double[][] nextDouble(int n, int m) {
    double[][] matrix = new double[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        matrix[i][j] = nextDouble();
      }
    }
    return matrix;
  }
  
  public char[][] nextCharArray(int n) {
    char[][] matrix = new char[n][];
    for (int i = 0; i < n; i++) {
      matrix[i] = next().toCharArray();
    }
    return matrix;
  }
}


Measured memory_bytes: 22484
'use strict'

const main = (INPUT) => {
  const [S, T] = INPUT.split('\n')
  let ans = 0
  for (let i = 0; i < S.length; i++) {
    if (S[i] != T[i]) {
      ans++
    }
  }
  console.log(ans)
}

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


Measured memory_bytes: 32844
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.format;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;
 
alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");
 
T lread(T = long)()
{
    return readln.chomp.to!T();
}
 
T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}
 
void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void main()
{
    long a, b, c;
    scan(a, b, c);
    auto d = max(10 * a + b + c, a + 10 * b + c, a + b + 10 * c);
    d.writeln();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
using P= pair<int,int>;
 
int main() {
    ll N,K;
    cin>>N>>K;
    long double rate=0.0;
    for(int i=1;i<=N;i++){
      ll n=i;
      ll t=0;
      
      while(n<K){
        n*=2;
        t++;
        //cout<<n<<endl;
      }
      //cout<<t<<endl;
      long double d=(long double)1.0/(long double)N;
      rate+=d*pow((long double)0.5,(long double)t);
      //cout<< fixed << setprecision(15) <<(1/N)+pow(0.5,t)<<endl;
    }
    
    cout<< fixed << setprecision(15) <<rate<<endl;
    return 0;
}

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

typedef long long ll;
const int N=2e5+4;
int a[N],n;

bool cmp(int a,int b)
{
	return a>b;
}

int main()
{
	ll sum=0;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1,cmp);
	sum+=a[1];
	for(int i=3;i<=n;i++)
	{
		sum+=a[1+(i-1)/2];
	}
	printf("%lld",sum);
}

Measured memory_bytes: 4524
$n = <>;
$k = <>;
$flg=0;
$ans=1;
for($i=0;$i<$n;$i++){
	if(2**$i >= $k){
    	$flg = 1;
    }
	if($flg == 0){
		$ans *= 2;
    }else{
    	$ans += $k;
   	}
}
print $ans;

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define ld long double
const ll MOD = 998244353;
const ll INF = 1e18;
using namespace std;


main(){    
    #ifdef XOX
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\Input.txt", "r", stdin);
        freopen("D:\\V S Code\\cpp\\competitiveProgramming\\OPT.txt", "w", stdout);
    #endif

    ios::sync_with_stdio(!cin.tie(NULL));
    
    ll a;
    cin >> a;
    ll b = a + (a * a) + (a * a * a);
    cout << b;
}

Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
using namespace std;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)

typedef long long ll;
#define INF 1e18

int main(){
	ll a; cin>>a;
	ll b; cin>>b;
	long double h; cin>>h;
	long double m; cin>>m;
	h=h/12*2*M_PI;
	h+=m/(60*12)*2*M_PI;
	m=m/60*2*M_PI;
	long double ans;
	ans=a*a+b*b-2*a*b*cosl(h-m);
	printf("%.10llf\n",sqrtl(ans));
	return 0;
}


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

long solve(long n) {
    long m = 1 + n;
    int cl = ceil(sqrt(n));

    long double tmp;
    for (int i = 1; i <= cl; ++i) {
        tmp = (long double)i + (long double)n/(long double)i;
        if (tmp == (long)tmp && m > tmp) {
            m = tmp;
        }
    }

    return m;
}


int main () {
    long n;
    scanf("%ld", &n);
    long m = solve(n);

    printf("%ld\n", m - 2);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF LLONG_MAX/10
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    int a[n];
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    if(sum%(4*m)==0){
        sum=sum/(4*m);
    }
    else{
        sum=sum/(4*m)+1;
    }
    int ans=0;
    rep(i,n){
        if(a[i]>=sum){
            ans++;
        }
        if(m==ans){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main() {
	while (true) {
		int n, x;
		int Output = 0;

		cin >> n >> x;

		if (n == 0 && x == 0)break;

		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x)
						Output++;
				}
			}
		}

		cout << Output << endl;
	}

	return 0;
}

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

int main() {
  int N, oturi = 0, kai;
  cin >> N;
  if (N < 1000){
    oturi = 1000 - N;
  }
  else if (N%1000 == 0){
    oturi = 0;
  }
   else {
    kai = N/1000;
    oturi = (kai + 1)*1000 - N;
  }
  cout << oturi << endl;
    
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,i,j;
	cin>>n;
	vector< pair<int,int> > r(n),b(n);
	for(i=0;i<n;i++){
              cin>>r[i].second>>r[i].first;
        }
	for(i=0;i<n;i++){
              cin>>b[i].first>>b[i].second;
        }
	sort(r.begin(),r.end());
	sort(b.begin(),b.end());
	vector<int> a(n);
	int mj,ans=0;
	for(i=0;i<n;i++)
	{
		bool f=false;
		for(j=0;j<n;j++)
		{
			if(r[j].second<b[i].first&&r[j].first<b[i].second)
			{
				if(a[j]==0)
				{
					f=true;
					mj=j;
				}
			}
		}
		if(f)
		{ans++;a[mj]=1;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <string>
#include <string.h>
#include <cmath>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#define pi acos(-1.0)
#define INF 0x3f3f3f3f
#define SIZE 200005
using namespace std;
typedef	long long ll;
ll n, m, i, j, k, h, t, maxn, ttt, t1, t2, sig = 0, l, d;
char str[SIZE], str2[SIZE];
int dr[SIZE], ch[SIZE];

int left(int p)
{
	for (int i = 0; i < m; i++)
	{
		if (str[p] - 'A' == ch[i])
		{
			p += dr[i];
			if (p < 0) return 1;
			if (p >= n) return 0;
		}
	}
	return 0;
}
int right(int p)
{
	for (int i = 0; i < m; i++)
	{
		if (str[p] - 'A' == ch[i])
		{
			p += dr[i];
			if (p >= n) return 1;
			if (p < 0) return 0;
		}
	}
	return 0;
}
int main()
{
	ios::sync_with_stdio(0);
	cin >> n >> m;
	cin >> str;
	for (int i = 0; i < m; i++)
	{
		cin >> str2;
		ch[i] = str2[0] - 'A';
		cin >> str2;
		if (str2[0] == 'L') dr[i] = -1;
		else dr[i] = 1;
	}
	int ans = n, l = -1, r = n;
	while (r - l > 1)
	{
		int d = (l + r) / 2;
		if (left(d)) l = d;
		else r = d;
	}
	ans -= r;
	l = -1, r = n;
	while (r - l > 1)
	{
		int d = (l + r) / 2;
		if (right(d)) r = d;
		else l = d;
	}
	ans -= n - r;
	cout << ans;
	return 0;
}

Measured memory_bytes: 2048
#include <stdio.h>

int main(void)
{
	int s;
	int h, m, se;
	
	scanf("%d", &s);

	h = s / 3600;
	s = s - (h * 3600);

	m = s / 60;
	s = s - (m * 60);


	se = s;

	printf("%d:%d:%d\n", h, m, se);

	return (0);
}

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

int main(){
  int num;
  cin>>num;
  int *heights=new int[num];
  for(int index=0; index<num; index++) cin>>heights[index];
  
  int *minCost = new int[num];
  minCost[0]=0;
  minCost[1]=abs(heights[0]-heights[1]);
  for(int i=1; i<num-1; i++){
  	minCost[i+1]=min(abs(heights[i]-heights[i+1])+minCost[i], abs(heights[i+1]-heights[i-1])+minCost[i-1]);
  }
  cout<<minCost[num-1]<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>>
using namespace std;
int main()
{
    int h,a,cnt=0;
    cin>>h>>a;
 if(h%a==0)
 {
     cnt=h/a;
 }
 else
    cnt=h/a+1;
  cout<<cnt<<endl;


    return 0;
}


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

#define MAX_N 100005

int n ,m;
vector <int> adj[MAX_N];

int main()
{
    scanf("%d%d",&n,&m);
    for(int a,b,i=0; i<m; i++){
        scanf("%d%d",&a,&b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    deque <int> path{1};
    vector <bool> in_path(n+1);
    in_path[1] = 1;
    for(int ok=1; ok--; ){
        for(int&v : adj[path.back()])
            if(!in_path[v]){
                path.push_back(v);
                in_path[v] = 1;
                ok = 1;
                break;
            }
    }
    for(int ok=1; ok--; ){
        for(int&v : adj[path.front()])
            if(!in_path[v]){
                path.push_front(v);
                in_path[v] = 1;
                ok = 1;
                break;
            }
    }


    printf("%d\n",path.size());
    for(int&o : path)
        printf("%d ",o);
    printf("\n");
}


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

int main() {
    char tmp;
    string a;
    cin >> a;
    tmp = a[0];
    bool flag=false;
    for (int i=1;i<3;i++){
        if (a[i]!=tmp) flag=true;
    }
    if (flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            String S = in.next();
            long K = in.Long();
            char[] cs = S.toCharArray();
            for (int i = 0; i < S.length(); i++) {
                char c = S.charAt(i);
                if (c != '1') {
                    out.println(c);
                    return;
                }
                if (i == K - 1) {
                    out.println(1);
                    return;
                }
            }
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

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

    }
}



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

int main() {
 int K;
  int N;
  cin >> K >> N;
  vector<int> vec(N);
  for ( int i=0; i<N; i++){
    cin >> vec.at(i);
  }
  int count;
  int aa;
  count = vec.at(0) + K - vec.at(N-1);
  for (int i=0; i < (N-1); i++){
    aa = vec.at(i+1) - vec.at(i);
    if (aa > count){
      count = aa;
    }
  }
  cout << K - count << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#ifdef PRAGMA
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#endif
#define fst first
#define snd second
#define fore(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define bs binary_search
#define mm(a,b) memset(a,b,sizeof(a))
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int) (n).size())
#define MAXI ((ll)1e16)
#define MINI ((ll)-1e16)
using namespace std;
typedef long long ll;  
const long long M = 1e9 +7;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }        
ll n,k;
ll a[22][22];
ll dp[22][1<<22];

ll solve(int h, int m){
	if(h==n&&m==(1<<n)-1)return 1;
	ll &r = dp[h][m];
	if(~r)return r;
	ll res=0;
	fore(i,0,n){
		if(a[h][i]==1 && !(m&(1<<i))){
			res=(res+solve(h+1,m|(1<<i)))%M;
		}
	}
	return r=res;
}


int main(){FIN;
	cin >> n;
	fore(i,0,n){
		fore(j,0,n){
			cin >> a[i][j];
		}
	}
	mm(dp,-1);
	cout << solve(0,0);
}

Measured memory_bytes: 721280
package main

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

var sc = bufio.NewScanner(os.Stdin)

func main() {
	// Code for C - Good Sequence
	var N int
	fmt.Scanf("%d", &N)

	sc.Split(bufio.ScanWords)

	var temp int
	a := make(map[int]int, N)
	for i := 0; i < N; i++ {
		temp = nextInt()
		a[temp]++
	}

	var count int
	for i, v := range a {
		if i != v {
			if v > i {
				count += v - i
			} else {
				count += v
			}
		}
	}

	fmt.Println(count)
}


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

#define int           long long 
#define S             second
#define F             first
#define pb            push_back
#define all(c)        (c).begin(),(c).end()
#define rall(c)       (c).rbegin(),(c).rend() 
#define lb            lower_bound
#define si(c)         (int)((c).size())
#define lcm(a, b)      (a * (b / __gcd(a,b)))  
#define inf           (int)(1e18)
#define endl          '\n'
#define mp            make_pair
#define time(s)       (double(clock()-s)/double(CLOCKS_PER_SEC))
#define debug(args...)    _F(#args, args)
#define vi            std::vector<int>
#define pii           pair<int, int> 
#define vpi           vector<pii>

clock_t start;
mt19937_64 rng(chrono::system_clock::now().time_since_epoch().count());

template<typename T> void _F(const char *name, T arg1){ cerr << name << " = " << arg1 << endl;}
template<typename T, typename... Args> void _F(const char *names, T arg1, Args... args)
{ const char *name = strchr(names, ',');cerr.write(names, name-names) << " = " << arg1 << endl;_F(name+2, args...);}

template< typename T1, typename T2 > istream& operator>>(istream& in, pair<T1, T2> &q){ in >> q.F >> q.S; return in;}
template< typename T1, typename T2 > ostream& operator<<(ostream& out, pair<T1, T2> &q){ out << q.F << " " << q.S; return out;}
template< typename T1, typename T2 > pair<T1, T2> operator+(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F+p2.F, p1.S+p2.S};}
template< typename T1, typename T2 > pair<T1, T2> operator-(pair<T1, T2> p1, pair<T1, T2> p2){ return {p1.F-p2.F, p1.S-p2.S};}
template< typename T1, typename T2 > bool operator<(pair<T1, T2> p1, pair<T1, T2> p2){ return p1 < p2 ;}

template<typename T> void Unique(vector<T> &v){
    sort(all(v)), v.resize(distance(v.begin(), unique(all(v))));
}

const int N = 2e6+1;
const int M = 1e9+7;
const int MOD = 1e9+7;

struct Comb{
    int fac[N], inv[N];
     
    int modPow(int b, int p) { 
        int r = 1; 
        while(p) { 
            if(p&1) r = r*b%MOD;
            b = (b*b)%MOD; 
            p >>= 1; 
        } return r;
    }
    Comb(){
        fac[0] = inv[0] = 1;
        for(int i = 1; i < N; i++){
            fac[i] = fac[i-1]*i%MOD;
        }
        inv[N-1] = modPow(fac[N-1], MOD-2);
        for(int i = N-2; i >= 0; i--){
            inv[i] = inv[i+1]*(i+1)%MOD;
        }
    }
    int ncr(int n, int r){
        if(r > n || r < 0 || n < 0) return 0;
        return fac[n]*inv[r]%MOD*inv[n-r]%MOD;
    }
}cc;


void solve(int &test) {
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = si(s)+k;
    int l = si(s);
    int ans = 0;
    for(int i = l; i <= n; i++){
        ans += (cc.ncr(i-1, l-1)*cc.modPow(25, i-l)%M*cc.modPow(26, n-i))%M;
        ans %= M;
    }
    cout << ans << endl;
}

signed main(){

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

    int t = 1;

    start = clock(); 

    cout << fixed << setprecision(20);
    

    // cin >> t;
     
    for(int i = 1; i <= t; ++i){
        solve(i);
    }
    cerr << time(start);
    return 0;
}

Measured memory_bytes: 35572