akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;
public class Hello
{

    public static void Main()
    {
        int N = int.Parse(Console.ReadLine());
        string[] s = Console.ReadLine().Split(' ');
        int[] num = s_to_i(s);
        bool[] color = new bool[8];
        for (int i = 0; i < 8; i++) color[i] = false;
        int pro_count = 0;
        for (int i = 0; i < N; i++)
        {
            if (num[i] < 3200) color[num[i] / 400] = true;
            else { pro_count++; }
        }

        int ans_min = 0;
        for (int i = 0; i < 8; i++) if (color[i]) ans_min++;
        if (ans_min == 0) { ans_min = 1; pro_count--; }
        int ans_max = ans_min + pro_count;
        Console.WriteLine("{0} {1}", ans_min, ans_max);
    }




    static int[] s_to_i(string[] s)
    {
        int[] ret = Array.ConvertAll<string, int>(s, delegate (string value) { return int.Parse(value); });
        return ret;
    }
}

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

int main() {
    int N; cin >> N;
    for (int i = 100; i > 0; i /= 10) {
        if (N / i == 7) {
            cout << "Yes" << endl;
            return 0;
        }
        N %= i;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;

int main()
{
    KAKA
    ll x,y;
    cin>>x>>y;
    if((y >= (2*x)) and (y <= (4 * x)))
    {
        ll a = y - (2*x);
        ll b = (4 * x) - y;
        if((!(a & 1)) and (!(b & 1)))
        {
            cout<<"Yes"<<"\n";
        }
        else cout<<"No"<<"\n";
    }
    else cout<<"No"<<"\n";
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define inf 0x7fffffff
#define eps 1e-4
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const double pi = acos(-1);
inline ll read(){
    ll x = 0, f = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') f = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9'){x = x *10 + ch -'0';ch = getchar();}
    return x * f;
}

int a,b,c,k;
int main(){
    int i,j;
    //freopen("a.out","r",stdin);
    //freopen("a.ans","w",stdout);
    a=read(),b=read(),c=read();k=read();
    int cnt=0;
    while(b<=a) b*=2,cnt++;
    while(c<=b) c*=2,cnt++;
    if(cnt<=k) puts("Yes");
    else puts("No");
    return 0;
}
/*
6
8 4
8 -4
5 5
5 -5
1 3
1 -3
*/

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	using P = pair<ll,ll>;
	int N;
	cin>>N;
	V<ll> a(N),b(N);
	V<P> v;
	rep(i,N){
		cin>>a[i]>>b[i];
		v.push_back(P(a[i]+b[i],i));
	}
	sort(all(v),greater<P>());
	ll d = 0;
	rep(i,N){
		int j = v[i].sc;
		if(i%2==0) d += a[j];
		else d -= b[j];
	}
	cout<<d<<endl;
}

Measured memory_bytes: 3956
#include <iostream>

using namespace std;

int main()
{
	while (1){
		int a, b, c, n, r[310], data[4][1000] = {};
		for (int i = 0; i < 310; i++){
			r[i] = 2;
		}
		cin >> a >> b >> c;
		if (a == 0 && b == 0 && c == 0) return 0;
		cin >> n;
		for (int i = 0; i < n; i++){
			for (int j = 0; j < 4; j++){
				cin >> data[j][i];
			}
			if (data[3][i] == 1){
				for (int k = 0; k < 3; k++) r[data[k][i] - 1] = 1;
			}
		}
		
		for (int i = 0; i < n; i++){
			if (data[3][i] == 0){
				int cou = 0;
				for (int j = 0; j < 3; j++){
					if (r[data[j][i] - 1] == 1) cou++;
				}
				if (cou == 2){
					for (int j = 0; j < 3; j++){
						if (r[data[j][i] - 1] != 1) r[data[j][i] - 1] = 0;
					}
				}
			}
		}

		for (int i = 0; i < a + b + c; i++) cout << r[i] << endl;
	}
}		

Measured memory_bytes: 3000
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <climits>
#include <cmath>
#include <complex>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <cstdint>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define mod 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

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

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

int main(){
    int n,x;
    cin >> n >> x;
    int m = n*2-1;
    if(x==1||x==m){
        cout << "No" << endl;
    }else{
        
        cout << "Yes" << endl;
        
        vector<int>res(m,-1);
        res[n] = x+1;
        res[n-1] = x;
        res[n-2] = x-1;
        vector<bool> used(m+1);
        used[x-1] = 1;
        used[x] = 1;
        used[x+1] = 1;
        int a = 1;
        for(int i=0;i<m;i++){
            if(res[i]==-1){
                while(used[a]){
                    a++;
                }
                used[a] = 1;
                res[i] = a;
            }
        }
        rep(i,m){
            cout << res[i] << "\n";
        }
    }
    return 0;
}

Measured memory_bytes: 2304
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    string S;
    cin >> N >> S;
    ll cnt[26] = {};
    for(auto c:S)cnt[c - 'a']++;
    ll ans = 1;
    rep(i,0,26)ans = (ans * (cnt[i] + 1)) % MOD;
    cout << (ans + MOD - 1) % MOD << endl;
}

Measured memory_bytes: 512
c = [[int(i) for i in input().split()] for _ in range(3)]
cond = True
cond &= c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]
cond &= c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]
cond &= c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]
cond &= c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]
print("Yes" if cond else "No")

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

#define int             long long
#define FOR( i, m, n )  for( int (i) = (m); (i) < (n); (i)++ )
#define REP( i, n )     FOR( i, 0, n )
#define REPR( i, m )    for( int (i) = (m); (i) >= 0; (i)-- )
#define REPONE( i, n )  FOR( i, 1, n + 1 )
#define ALL( a )        (a).begin(), (a).end()
#define MP              make_pair

typedef pair<int, int> P;

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

const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int D, E;
    while( cin >> D >> E, D | E ){
        double ans = INF;
        REP( i, D + 1 ){
            int x = i;
            int y = D - i;

            chmin( ans, abs( sqrt( x * x + y * y ) - E ) );
        }

        printf( "%.10f\n", ans );
    }
}



Measured memory_bytes: 3220
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=2e5;
const int INF=1e9;
int main(){
	int N,M;cin>>N>>M;
	long A[N];priority_queue<long> pq;
	long sum=0;
	rep(i,0,N){
		cin>>A[i];sum+=A[i];
		pq.push(A[i]);
	}sort(A,A+N);
	long temp;
	rep(i,0,M){
		temp=pq.top();
		sum-=temp-temp/2;
		pq.pop();
		pq.push(temp/2);
	}cout<<sum<<endl;
}

Measured memory_bytes: 1912
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman001 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;
using namespace std;
int n,W,w[105],v[105],memo[105][100005],ans,sum;
int solve(int ind,int V)
{
    if(V < 0)
        return 1e9;
    if(ind == n)
        return (V)?1e9:0;
    int &ans = memo[ind][V];
    if(~ans)
        return ans;
    ans = min(solve(ind + 1,V),solve(ind + 1,V - v[ind]) + w[ind]);
    return ans;
}
int main()
{
    abdelrahman001
    memset(memo,-1,sizeof memo);
    cin >> n >> W;
    for(int i = 0;i<n;i++)
        cin >> w[i] >> v[i],sum+=v[i];
    for(int i = 0;i<=sum;i++)
        if(solve(0,i) <= W)
            ans = i;
    cout << ans;
    return 0;
}


Measured memory_bytes: 41344
n = int(input())
a = sorted(list(map(int,input().split())))
am = a[-1]+1
div = [1]*am
ans = 0

for i in range(n-1):
  a_i = a[i]
  if div[a_i]:
    for j in range(a_i,am,a_i):
      div[j] = 0
    if a_i < a[i+1]:
      ans += 1
if div[-1]:ans += 1
print(ans)



Measured memory_bytes: 32356
n,k=map(int,input().split())
a=list(map(int,input().split()))
b=[0]
c=[0]
for i in a:
  b.append(b[-1]+i)
  c.append(c[-1]+max(0,i))
ans=-float('inf')
for i in range(n-k+1):
  x=b[i+k]-b[i]
  y=c[n]-c[i+k]+c[i]
  ans=max(ans,y+max(0,x))
print(ans)

Measured memory_bytes: 16948
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

//namespaces
using namespace __gnu_pbds; 
using namespace std;

//MACROS
#define ld long double
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long 
#define For(i,s,e) for (int i=(s); i<(e); i++)
#define Fod(i,s,e) for (int i=(s); i>=(e); i--)
#define pii pair<ll,ll>
#define f first
#define s second
#define endl "\n"
#define all(container) container.begin(), container.end()
#define mp make_pair
#define int ll

//debug
#define TRACE
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

//Templates
template <typename T>
using ordered_set =tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }

//globals
ll const prime1 = 304933;
ll const prime2 = 15486277;
ll const mod = 1e9+7;
ll const inf = 1e18;
ll const size_1d = 1e6 + 7;
ll const size_2d = 1e3 + 7;

//functions
ll power(ll x, ll y, ll mod = 2e18){ ll ans = 1;x %= mod;while(y){if(y&1)ans = (x * ans) % mod;x = (x * x) % mod;y >>= 1;}return ans;}
ll modInverse(ll a, ll m){ll m0 = m;ll y = 0, x = 1;if (m == 1) return 0;while (a > 1){ ll q = a / m;ll t = m;m = a % m,a = t;t = y;y = x - q * y;x = t;}if(x < 0) x += m0;return x;} 
ll gcdext(ll a,ll b,ll *x = 0, ll *y = 0){if(a == 0){*x = 0;*y = 1;return b;}ll x1,y1;ll gcd1 = gcdext(b%a,a,&x1,&y1);*x = y1 - (b/a)*x1;*y = x1;return gcd1;}
int randomize(){return (rand()%10000);} 

// CODE STARTS HERE

signed main(){
    IOS
    int n;cin >> n;
    std::vector<int> v(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> v[i];
    }
    int count = 1;
    for (int i = 0; i < n; ++i)
    {
        if(v[i] == count){
            count++;
        }
    }
    if(count == 1) cout << -1 << endl;
    else cout << n - count  + 1<< endl;

    return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
typedef long long ll;

int main() {
    string S; cin >> S;
    int N = S.size();
    reverse(S.begin(),S.end());
    string s,lr,rr;
    string l = S.substr(0,(N-1)/2);
    string r = S.substr((N+3)/2-1);
    for(int i = N-1; i >= 0; i--){
        s.push_back(S[i]);
        if(i > (N-1)/2) rr.push_back(S[i]);
        if(i < (N-1)/2) lr.push_back(S[i]);
    }
    if(s == S){
        if(l == lr && r == rr){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }else{
        cout << "No" << endl;
    }
}

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

int main() {
    ll N,K;cin >> N >> K;
    ll ans = 0;
    for (ll i = K;i <= N + 1;i++){
        ll Max = 0;ll Mini = 0;
        Max = ((N + N - i + 1) * i)/ 2 ;
        Mini = ((i - 1) * i) / 2;
        ans += (Max - Mini + 1) % mod;
        ans %= mod;
        if (ans < 0) ans += mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3680
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    int i=0;
    string s;
    string lefts, rights, mids;

    pr(i);
    cin >> s;

    if(s=="Vacant"){
        return 0;
    }
    lefts = s;

    pr(n-1);
    cin >> s;
    if(s=="Vacant"){
        return 0;
    }
    rights = s;

    int left = 0, right = n;
    int mid = (left+right)/2;

    while(1){
        pr(mid);
        cin >> mids;
        if(mids=="Vacant") return 0;
        
        if(mids == lefts){
            if((mid - left)%2 == 0){
                left = mid;
                lefts = mids;
            }else{
                right = mid;
                rights = mids;
            }
        }else{
            if((mid - left)%2 == 0){
                right = mid;
                rights = mids;
            }else{
                left = mid;
                lefts = mids;
            }
        }

        mid = (left+right)/2;
    }
    return 0;}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
//using Edge = pair<int, ll>;
//using Graph = vector<vector<int>>;
//using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

string S;
long long m, c, t;

void add(int i) {
    if (S[i] == 'M'){
        ++m;
    }
    else if (S[i] == 'C') {
        ++c;
        t += m;
    }
}

void erase(int i) {
    if (S[i] == 'M'){
        --m;
        t -= c;
    }
    else if (S[i] == 'C'){
        --c;
    }
}

void solve() {
    int N;
    cin >> N >> S;
    int Q; cin >> Q;
    for (int i = 0; i < Q; ++i) {
        int k; cin >> k;
        ll ans = 0;
        m = 0; t = 0;

        int r = 0;
        for (int l = 0; l < N;) {
            while (r < N && r - l < k) add(r++);
            if (S[l] == 'D') ans += t;
            erase(l++);
        }
        cout << ans << endl;
    }
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 1412
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i,N) for(int i=0;i<(N);i++)
using namespace std;

int main(){
	long long N,M;
	cin>>N>>M;
	vector<long long> P(M),Y(M);
	rep(i,M)cin>>P[i]>>Y[i],--P[i];
	vector< vector<long long> > city(N);
	rep(i,M)city.at(P[i]).push_back(Y[i]);
	rep(i,N){
		sort(city.at(i).begin(), city.at(i).end());
	}
	rep(i,M){
		int cityNum=P[i];
		printf("%06d",cityNum+1);
		//Y[i]はcity[P[i]]の始まりからどれだけ進んだかを表す
		int id = lower_bound(city.at(cityNum).begin(), city.at(cityNum).end(), Y[i]) - city.at(cityNum).begin();
		printf("%06d\n",id+1);
	}
}

Measured memory_bytes: 10300
#include <iostream>
#include <string>
using namespace std;
int main(void){//デバッグつら
    string s;
    string x;
    int i,j,k,b=0,f=0;
    bool c=true;
    long long int ans=0;
    cin>>s>>k;
    x=s;
    for(i=1;i<s.length();i++){
        if(s[i-1]==s[i]){
            if(x[i-1]==x[i]){
                ans++;
                x[i]='0';
            }
            if(c==true)f++;
            b++;
        }else{
            c=false;
            b=0;
        }
       // cout<<f<<" "<<b<<" "<<ans<<endl;
    }
    if(c==true){
        cout<<s.length()*k/2;
    }else{
        //cout<<x;
        ans*=k;
        if(f%2==0 && b%2==0 && s[s.length()-1]==s[0])ans+=k-1;
        cout<<ans;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MD 1000000007
typedef long long int ll;
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,p;
    cin>>a>>p;
    cout<<(a*3+p)/2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int A,B,C;
    cin>>A>>B>>C;

    int ans=0;
    if(A+1+B>=C){
        ans=B+C;
    }else {
        ans=1+A+B*2;
    }
    cout << ans << endl;
    



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
char f(char a, int n) {
  char ans = a+n;
  if (ans>'Z') ans-=26;
  return ans;
}
int main()
{
  int n;
  string s;
  cin >> n;
  cin >> s;
  string ans = s;
  for (int i=0; i<s.size(); i++) {
    ans[i] = f(s[i], n);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

struct UnionFind {
    int n, cc, *u;
    UnionFind() : n(0), cc(0), u(NULL) {}
    UnionFind(int n_) : n(n_), cc(n_) {
	u = new int[n_];
	memset(u, -1, sizeof (int) * n);
    }
    UnionFind(const UnionFind &y) : n(y.n), cc(y.cc) {
	u = new int[y.n];
	memcpy(u, y.u, sizeof (int) * n);
    }
    ~UnionFind() {
	delete[] u; u = NULL;
	n = cc = 0;
    }
    friend void swap(UnionFind &x, UnionFind &y) {
	swap(x.n, y.n); swap(x.cc, y.cc); swap(x.u, y.u);
    }
    UnionFind& operator=(UnionFind y) { 
	swap(*this, y);
	return *this;
    }
    int root(int x) {
	int y = x, t;
	while (u[y] >= 0) y = u[y];
	while (x != y) { t = u[x]; u[x] = y; x = t; }
	return y;
    }
    bool link(int x, int y) {
	x = root(x); y = root(y);
	if (x == y) return false;
	if (u[y] < u[x]) swap(x, y);
	u[x] += u[y]; u[y] = x; cc--;
	return true;
    }
    bool same(int x, int y) { return root(x) == root(y); }
    int size(int x) { return -u[root(x)]; }
    int count() { return cc; }
};

int N, H, W;

struct Card {
    int r, c, a;
    bool operator<(const Card &o) const {
	return a < o.a;
    }
} C[100011];

int S[200011];

void MAIN() {
    scanf("%d%d%d", &N, &H, &W);
    REP (i, N) {
	scanf("%d%d%d", &C[i].r, &C[i].c, &C[i].a);
	C[i].r--;
	C[i].c--;
    }
    sort(C, C+N);

    UnionFind U(H+W);
    LL ans = 0;
    for (int i=N; i--;) {
	int x = U.root(C[i].r), y = U.root(C[i].c + H);
	if (x == y) {
	    if (S[x] < U.size(x)) {
		S[x]++;
		ans += C[i].a;
	    }
	} else if (S[x]+S[y] < U.size(x)+U.size(y)) {
	    U.link(x, y);
	    int z = U.root(x);
	    S[z] = S[x] + S[y] + 1;
	    ans += C[i].a;
	}
    }

    printf("%lld\n", ans);
}


int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



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

int main() {
  int N, A, min=30;
  cin >> N;
  
  for(int i=0; i<N; i++){
    cin >> A;
    
    int count = 0;
    while(A % 2 == 0){
      count++;
      A /= 2;
    }
    if(count < min){
      min = count;
    }
  }
  cout << min << endl;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
	static long c=0;
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int A[] = new int[n];
		for(int i=0; i<n; i++){
			A[i] = sc.nextInt();
		}
		mergeSort(A, 0, n);
		System.out.println(c);
	}
	static void mergeSort(int A[], int left, int right){
		if(left+1 < right){
			int mid = (left + right)/2;
			mergeSort(A, left, mid);
			mergeSort(A, mid, right);
			merge(A, left, mid, right);
		}
	}
	static void merge(int A[], int left, int mid, int right){
		int n1 = mid - left;
		int n2 = right - mid;
		int L[] = new int[n1+1];
		int R[] = new int[n2+1];
		for(int i=0; i<n1; i++){
			L[i] = A[left + i];
		}
		for(int i=0; i<n2; i++){
			R[i] = A[mid + i];
		}
		L[n1] = R[n2] = Integer.MAX_VALUE;
		int i, j;
		i = j = 0;
		for(int k=left; k<right; k++){
			if(L[i] <= R[j]){
				A[k] = L[i++];
			} else{
				A[k] = R[j++];
				c += (n1 - i);
			}
		}
	}
}

Measured memory_bytes: 96932
package main

import "fmt"

func main() {
	var A,B,C,K int
	fmt.Scan(&A, &B,&C,&K)

	var a,b,c int
	if K >= A {
		a = A
		K = K - a
	} else {
		a = K
		K = 0
	}

	if K >= B {
		b = B
		K = K -b
	} else {
		b = K
		K = 0
	}

	if K == C {
		c = C
	} else {
		c = K

	}

	res := a -c


	fmt.Println(res)

}


Measured memory_bytes: 1752
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define INF 1000000001

#define MR 1000000
vector<ll> PN_chk(MR+1,1);

//O(MR)
void init_eratosthenes(){
    PN_chk[0]=0;PN_chk[1]=0;//2以上の数の素因数分解をするので無視して良い
    for(int i=2;i<=sqrt(MR)+1;i++){
        //たどり着いた時に素数と仮定されているなら素数
        //ある素数の倍数はその素数で割り切れるのでマークづけ
        if(PN_chk[i]==1) {
            for(int j=2;j<=MR/i;j++){
                PN_chk[j*i]=i;
            }
        }
    }
}

//素因数分解で出てきた素数を全て挿入する
vector<ll> prime;

//O(logn)
//primeは整列されていない
void prime_factorize(ll n){
    if(n<=1) return;
    //1の場合はnは素数
    if(PN_chk[n]==1){
        prime.push_back(n);
        return;
    }
    //マークされている数は素数
    prime.push_back(PN_chk[n]);

    //マークされている数でnを割った数を考える
    prime_factorize(ll(n/PN_chk[n]));
}//mainでinitを一度実行、primeはnの度に初期化

ll gcd(ll a, ll b){
    if (a%b == 0) return(b);
    else return(gcd(b, a%b));
}
 
ll lcm(ll a, ll b){
    return a * b / gcd(a, b);
}

int main() {
    init_eratosthenes();

    int n;cin >> n;
    vector<int> s(1000001);
    bool pairwise=true;
    vector<ll> a(n);for(int i=0;i<n;i++) cin >> a[i];

    for(int i = 0; i < n; i++) {
        prime_factorize(a[i]);
        for(int j = 0; j < prime.size(); j++) {
            if(s[prime[j]]==0) s[prime[j]]=i;
            else if(s[prime[j]]!=i){
                pairwise=false;
            }
        }
        vector<ll> x;
        prime=x;
    }

        if(pairwise==true){
            cout << "pairwise coprime" << endl;
            return 0;
        }
        else{
            ll p=a[0];
            for(int i = 1; i < n; i++) {
                p = gcd(p,a[i]);
            }

            if(p==1){
                cout << "setwise coprime" << endl;
            }
            else{
                cout << "not coprime" << endl;
            }
        }
    
    
    return 0;
}

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

using namespace std;

int main()
{
    int n ;
    cin>>n ;
    int arr[n*2] ;
    for(int i = 0; i < 2*n ; ++i)
        cin>>arr[i] ;
    sort(arr , arr + n*2) ;
    int ans = 0 ;
    for(int i = 0 ; i < 2*n ; i += 2)
        ans += arr[i] ;
    return cout<<ans , 0 ;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    cases = dict()
    for _ in range(N):
        s = input()
        cases[s] = cases.get(s, 0) + 1
    
    results = ["AC", "WA", "TLE", "RE"]

    for r in results:
        print(f"{r} x {cases.get(r, 0)}")
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 9184
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int a, b, c;
	cin >> a >> b >> c;
	if (a == b + c || b == a + c || c == a + b) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+7;
int h[maxn],k,cnt=0,flag=1,n;
long long ans=0;
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	sort(h,h+n);
	for(int i=0;i<n-k;i++){
		ans+=h[i];
	}
	cout<<ans;
/*	while(flag){
		h=h-a;
		if(h==0||h<0){
			flag=0;
		}
		cnt++;
	}
	cout<<cnt;*/
	
	
	return 0;
 } 

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define w cout
#define e endl

using namespace std;

const int N = 1e6 , mod = 1e9 + 7;
int n , arr[N];
long long check(long long mid) {
    long long ret = 0;
    for(int i = 1 ; i <= n ; i ++ ) {
        ret += abs(arr[i] - (mid + i));
    }
    return ret;
}
    

int main() {
    cin >> n;
    long long ans = 0;
    for(int i = 1 ;i <= n; i ++ ) {
        cin >> arr[i];
        ans += abs(arr[i] - (i));
    }
    
    long long l = -1e9 - 1 , h = 1e9 + 1;
    while(l <= h) {
        long long mid = (l + h) / 2;
        long long temp1 = check(mid);
        long long temp2 = check(mid + 1);
        ans = min({ans , temp1 , temp2});
        
        if(temp1 > temp2) {
            l = mid + 1;
        } else {
            h = mid - 1;
        }
    }
   
    w << ans;

}


Measured memory_bytes: 1024
s=input()
if int(s[0]+s[1]) <= 12 and int(s[2]+s[3]) <= 12:
    if int(s[0]+s[1]) == 0 and int(s[2]+s[3]) != 0:
        print('YYMM')
    elif int(s[2]+s[3]) == 0 and int(s[0]+s[1]) != 0:
        print('MMYY')
    else:
        if int(s[0]+s[1]) == 0 and int(s[2]+s[3]) == 0:
            print('NA')
        else:
            print('AMBIGUOUS')
elif int(s[0]+s[1]) <= 12 and int(s[2]+s[3]) > 12:
    print('MMYY' if int(s[0]+s[1]) > 0 else 'NA')
elif int(s[0]+s[1]) > 12 and int(s[2]+s[3]) <= 12:
    print('YYMM' if int(s[2]+s[3]) > 0 else 'NA')
else:
    print('NA')

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for(int i = n-1; i >= 0; i--)
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  FastIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
typedef long long ll;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using VL = vector<ll>;
using VVL = vector<vector<ll>>;
using VP = vector<P>;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }

int main(){
    int n;
    cin >> n;
    VP ab(n), cd(n);
    rep(i,n) cin >> ab[i].first >> ab[i].second;
    rep(i,n) cin >> cd[i].first >> cd[i].second;

    sort(all(ab));
    sort(all(cd));

    VI used(n);
    int ans = 0;
    rrep(i, n){
        int usej = n+1, dis = 2 * n;
        rrep(j,n){
            if (ab[i].first >= cd[j].first) break;
            if (used[j] == 1) continue;
            if (ab[i].first < cd[j].first && ab[i].second < cd[j].second){
                if (chmin(dis, cd[j].second - ab[i].second)) usej = j;
            }
        }
        if (usej != n+1){
            used[usej] = 1;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  char a,b,c,d,e,f,g,h,i;
  vector<vector<char>> p(3, vector<char>(3));
  for (int  k = 0; k < 3; k++) for ( int l = 0; l < 3; l++) cin >> p.at(k).at(l);
  
  cout << p.at(0).at(0) << p.at(1).at(1) << p.at(2).at(2);
}

Measured memory_bytes: 256
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        root = x
        queue = [x]
        data = []
        while queue:
            now = queue.pop()
            if self.par[now] == now:
                root = now
            else:
                # 根でないなら親の要素で再検索
                data.append(now)
                queue.append(self.par[now])
        # 検索する過程で親を更新
        for y in data:
            self.par[y] = root
        return root

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        t = (x == y)
        if UnionFind.same_check(self, x, y):
            return t
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return t

    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self, x):
        q = UnionFind.find(self, x)
        return self.count[q]


n = int(input())
vertex = []
for i in range(n):
    xi,yi = map(int,input().split())
    vertex.append((xi, yi, i))

edge = []
vertex.sort()
for i in range(1, n):
    edge.append((vertex[i][0] - vertex[i - 1][0], vertex[i][2], vertex[i - 1][2]))

vertex.sort(key= lambda x:x[1])
for i in range(1, n):
    edge.append((vertex[i][1] - vertex[i - 1][1], vertex[i][2], vertex[i - 1][2]))

edge.sort()
u = UnionFind(n)
ans = 0
for d, i, j in edge:
    if u.union(i, j):
        continue
    ans += d

print(ans)


Measured memory_bytes: 48232
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static int getInt(String a){
        return Integer.parseInt(a);
    }
    public static void main(String [] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        StringTokenizer st = new StringTokenizer(br.readLine());
        int n = getInt(st.nextToken());
        long d = getInt(st.nextToken());
        int ans = 0;
        d *= d;

        while(n-- != 0){
            st = new StringTokenizer(br.readLine());
            long x = getInt(st.nextToken());
            long y = getInt(st.nextToken());
            if(x*x + y*y <= d){
                ans +=1;
            }
        }
        bw.write(ans+"");

        bw.flush();
        bw.close();
        br.close();
    }
}


Measured memory_bytes: 55684
/*
─────────────────────
───────────████████──
──────────███▄███████
──────────███████████
──────────███████████
──────────██████─────
──────────█████████──
█───────███████──────
██────████████████───
███──██████████──█───
███████████████──────
███████████████──────
─█████████████───────
──███████████────────
────████████─────────
─────███──██─────────
─────██────█─────────
─────█─────█─────────
─────██────██────────
─────────────────────
*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define int long long
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; fori (i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; fori (i, 1, n) {fori (j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) fori (i, 1, n) {fori (j, 1, m) cout << a[i][j] << " "; cout << endl;} cout << endl;
#define all(v) v.begin(), v.end()
#define sz(s) (int)(s.size())
#define pb push_back
#define fi first
#define se second
#define rz resize
#define fori(i, a, b) for (int i = (a); i <= (b); i++)
#define ford(i, a, b) for (int i = (a); i >= (b); i--)
#define sort1(v) sort(v.begin(), v.end()) 
#define endl '\n'
 
using namespace std;
using namespace __gnu_pbds; 
 
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair <int, int>> vpi;
typedef vector < vector <int> > vvi;
 
const int INF = 4e18;
const int mod = 1e9+7; 
     
signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    //start from here

    read(k);
    vector <string> vec;
    vec.pb("0");
    vec.pb("1");
    vec.pb("2");
    vec.pb("3");
    vec.pb("4");
    vec.pb("5");
    vec.pb("6");
    vec.pb("7");
    vec.pb("8");
    vec.pb("9");

    int next = 1;

    while(vec.size() <= k)
    {
    	string s = vec[next];

    	char c = s[sz(s)-1];
    	char c1 = c-1;
    	char c2 = c+1;

    	if(c != '0') vec.pb(s+c1);
    	vec.pb(s+c);
    	if(c != '9') vec.pb(s+c2);
    	next++;
    }

    cout << vec[k];

    return 0;
}


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

int main(int argc, char **argv)
{
    int N;
    std::cin >> N;

    int max_v = -1;
    int min_v = 1000000001; // > 10^9
    for(int i = 0; i < N; i++){
        int v;
        std::cin >> v;
        if(v > max_v) max_v = v;
        if(v < min_v) min_v = v;
    }
    std::cout << (max_v - min_v) << std::endl;
}


Measured memory_bytes: 256
#include<cstdio>
	#include<iostream>
	#include<algorithm>
	#include<cstring>
	using namespace std;
	int main()
	{
		int a,b,c,d,e,f;
		cin>>a>>b>>c>>d>>e>>f;
		int x[31]={0},y[3001]={0};
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		x[a]=x[b]=1;
		y[c]=y[d]=1;
		for(int i=1;i<=30;i++)
		{
			if(!x[i])
			{ if(i>a)
				if(x[i-a])
				x[i]=1;
			 if(i>b)
			   if(x[i-b])
			    {
				x[i]=1;}
			}
		} 
		for(int i=1;i<=3000;i++)
		{
			if(!y[i])
			{ if(i>c)
				if(y[i-c])
				 {
				 y[i]=1;}
			 if(i>d)
			   if(y[i-d])
			    {
				y[i]=1;}
			}
			
		} 
		double den=0.0;
		int max1=0,max2=0;
		for(int i=1;i<=f/100;i++)
		 for(int j=1;j<=f;j++)
		 {
		 	if(x[i] && y[j])
		 		if((j/i<e || (j/i==e && j%i==0)) && i*100+j<=f && 1.0*j/i>den)
		 		{
				 den=1.0*j/i;
		 		 max1=i*100+j;
		 		 max2=j;
		 	    }
		 }
		 if(max1!=0)
		 cout<<max1<<" "<<max2;
		else cout<<a*100<<" "<<max2;
	} 

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

int main()
{
	int a, b, c;
	int count = 3;
	cin >> a >> b >> c;

	if (a == b || a == c || b == c)
	{
		count--;
	}
	if (a == b && a == c)
	{
		count--;
	}
	cout << count << endl;
	return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long N, long long M){
    int odd = M - M/2, even = M/2;
    rep(i,0,odd) {
        cout << (odd - i) << " " << (odd - i + (1+2*i)) << endl;
    }
    rep(i,0,even) {
        cout << (2*odd+even - i) << " " << (2*odd+even - i + (2+2*i)) << endl;
    }
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


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

int main() {
	const int max = 110000;
	int n, t[max], x[max], y[max];
	cin >> n;
	t[0] = x[0] = y[0] = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> t[i] >> x[i] >> y[i];
	}

	bool flg = true;
	for (int i = 1; i <= n; ++i) {
		int dt = t[i] - t[i-1];
		int dist = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1]);
		if (dt < dist) flg = false;
		if (dist % 2 != dt % 2) flg = false;
	}

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


Measured memory_bytes: 1408
MAX = 2001


def prim(tree: [int], adjacent_list: [[int]]):
    cost = 0
    next = 0
    for l in adjacent_list:
        l[next] = MAX
    while True:
        tree.append(next)
        min_list = list()
        for t in tree:
            min_list.append(min([(v, i) for i, v in enumerate(adjacent_list[t])]))
        min_cost, i = min(min_list)
        if min_cost == MAX:
            return cost
        cost += min_cost
        for l in adjacent_list:
            l[i] = MAX
        next = i


if __name__ == '__main__':
    N = int(input())
    adjacent_list = [[int(e) if int(e) != -1 else MAX for e in input().rstrip().split()] for _ in range(N)]
    test_list = []
    print(prim(test_list, adjacent_list))

Measured memory_bytes: 7772
A = sorted(list(map(int, input().split())))
ans = 0

while len(set(A))>1:
    if A[2] > A[0]+1:
        A[0] += 2
    elif A[1] == A[2] and A[0] == A[1]-1:
        A[1] += 1
        A[2] += 1
    elif A[0]== A[1] and A[1] == A[2]-1:
        A[0] += 1
        A[1] += 1
    elif A[0] < A[1]:
        A[0] += 2
    ans += 1
    A.sort()

print(ans)


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

# Generated by 1.1.6 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():
    # Failed to predict input format
    N,M,X = map(int,input().split())
    C = []
    A = []
    for i in range(N):
        l = list(map(int,input().split()))
        C.append(l[0])
        A.append(l[1:])
    INF = 10**10
    minCost = INF
    for b in range(1<<N):
        cost = 0
        costs = [0] * M
        for j in range(N):
            if b & 1 > 0:
                for k in range(M):
                    costs[k] += A[j][k]
                cost += C[j]
            b= b>>1
        if min(costs) >= X:
            minCost = min(minCost,cost)
    if minCost == INF:
        print(-1)
    else:
        print(minCost)


    pass

if __name__ == '__main__':
    main()


Measured memory_bytes: 68356
n = gets.to_i
hs = gets.split.map(&:to_i)
dp = {}
dp[1] = 0
dp[2] = (hs[0] - hs[1]).abs
n.times.with_index(1) do |_,i|
  next if i == 1 || i == 2
  dp[i] = [dp[i-1] + (hs[i-2]-hs[i-1]).abs, dp[i-2] + (hs[i-3]-hs[i-1]).abs].min
end

puts dp[n]


Measured memory_bytes: 17028
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>


using namespace std;


int main() {
    int h, w, n;
    cin >> h >> w >> n;

    int black = 0;
    int i = 0;
    while (black < n) {
        if (h >= w) {
            black += h;
            w--;
        } else {
            black += w;
            h--;
        }
        i++;
    }
    cout << i << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int x = sc.nextInt();
        int[] c = new int[n];
        int[][] a = new int[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = sc.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = sc.nextInt();
            }
        }

        int ans = -1;
        for (int bit = 0; bit < (1 << n); bit++) {
            int csum = 0;
            int[] asum = new int[m];
            for (int i = 0; i < n; i++) {
                if ((1 & (bit >> i)) == 1) {
                    csum += c[i];
                    for (int j = 0; j < m; j++) {
                        asum[j] += a[i][j];
                    }
                }
            }
            boolean morethanx = true;
            for (int i = 0; i < m; i++) {
                if (asum[i] < x) {
                    morethanx = false;
                    break;
                }
            }
            if (morethanx) {
                if (ans == -1) {
                    ans = csum;
                } else {
                    ans = Math.min(ans, csum);
                }
            }
        }
        System.out.println(ans);
    }
}


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

typedef vector<int> vi;

const int MOD = (int)1e9 + 7;
int H, W;
vector<string> G;
vector<vi> dp;

void input_init(void) {
	string str;
	cin >> H >> W;
	str = string(W + 1, '@');
	G.resize(H + 1);
	G[0] = str;
	for (int j = 1; j <= H; ++j) {
		cin >> str;
		G[j] = "@" + str;
	}
	dp.resize(H + 1, vi(W + 1, 0));
}

void solve(void) {
	dp[1][0] = 1;
	for (int j = 1; j <= H; ++j) {
		for (int i = 1; i <= W; ++i) {
			if (G[j][i] == '#')
				dp[j][i] = 0;
			else
				dp[j][i] = (dp[j][i - 1] + dp[j - 1][i]) % MOD;
		}
	}
}

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

	input_init();
	solve();

	cout << dp[H][W] << '\n';
	return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
ll n,m;
ll siz[100010];
ll par[100010];
ll a[100010][2];
inline ll pare(int x)
{
	if (par[x]==x) return x;
	else return pare(par[x]);
}
inline void join(int x,int y)
{
	if (siz[x]>siz[y]) swap(x,y);
	siz[y]+=siz[x];
	par[x]=y;
}
ll res;
vector<ll> v;
int main()
{
	cin >>n>>m;
	for (int i=0;i<m;i++) cin >>a[i][0]>>a[i][1];
	for (int i=0;i<n;i++)
	{
		par[i]=i;
		siz[i]=1;
	}
	res=n*(n-1)/2;
	for (int i=m-1;i>=0;i--)
	{
		int x=a[i][0],y=a[i][1];
		x--,y--;
		x=pare(x),y=pare(y);
		if (x==y)
		{
			v.push_back(res);
		    //cout <<res<<" #########\n";
			continue;
		}
		else
		{
			v.push_back(res);
		    //cout <<res<<" #########\n";
			res-=siz[x]*siz[y];
			join(x,y);
		}
	}
	reverse(v.begin(),v.end());
	for (int i=0;i<m;i++) cout <<v[i]<<"\n";
	return 0;
}

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

class Program
{
    public static void Main()
    {

        var s = Console.ReadLine().ToArray();
        string ans = "Good";
        for(int i = 0; i < s.Length - 1; i++)
        {
            if(s[i] == s[i+1])
            {
                ans = "Bad";
            }
        }


        Console.WriteLine(ans);

    }
}

Measured memory_bytes: 13268
n,m = map(int,input().split())
ls = [[x for x in input() + '#'] for i in range(n)] + [['#']*(m+1)]
yokodp = [[0 for x in range(m+1)] for i in range(n+1)]
for i in range(n+1):
    yoko = 0
    for j in range(m+1):
        if ls[i][j] == '#':
            yokodp[i][j] = yoko
            yoko = 0
        else:
            yoko += 1
for i in range(n,-1,-1):
    check = 0
    for j in range(m,-1,-1):
        if yokodp[i][j] != 0:
            check = yokodp[i][j]
        if ls[i][j] == '.':
            yokodp[i][j] = check
tatedp = [[0 for x in range(m+1)] for i in range(n+1)]            
for j in range(m+1):
    tate = 0
    for i in range(n+1):
        if ls[i][j] == '#':
            tatedp[i][j] = tate
            tate = 0
        else:
            tate += 1
for j in range(m,-1,-1):
    for i in range(n,-1,-1):
        if tatedp[i][j] != 0:
            check = tatedp[i][j]
        if ls[i][j] == '.':
            tatedp[i][j] = check
ans = 0
for i in range(n):
    for j in range(m):
        if ls[i][j] == '.':
            ans = max(ans,tatedp[i][j] + yokodp[i][j] - 1)
import time
time.sleep(0.09)
print(ans)


Measured memory_bytes: 248928