akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=acos(-1.0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
vector<complex<double>> fft(vector<complex<double>> a,int bo){
    int n=a.size();
    int h=0;
    while((1<<h)<n)h++;
    rep(i,0,n){
        int j=0;
        rep(k,0,h)j|=((i>>k)&1)<<(h-1-k);
        if(i<j)swap(a[i],a[j]);
    }
    for(ll i=1;i<n;i*=2){
        rep(j,0,i){
            complex<double> w=polar(1.0,(-(2*pi)/(2*i))*j*bo);
            for(ll k=0;k<n;k+=i*2){
                complex<double> s=a[j+k];
                complex<double> t=a[j+k+i]*w;
                a[j+k]=s+t;
                a[j+k+i]=s-t;
            }
        }
    }
    if(bo==-1)rep(i,0,n)a[i]/=n;
    return a;
}
vector<complex<double>> fft(vector<double> a,int bo){
    vector<complex<double>> b(a.size());
    rep(i,0,a.size())b[i]=complex<double>(a[i],0);
    return fft(b,bo);
}
vector<double> convolve(vector<double> a,vector<double> b){
    int s=a.size()+b.size()-1;
    int t=1;
    while(t<s)t*=2;
    a.resize(t);
    b.resize(t);
    vector<complex<double>> A=fft(a,1);
    vector<complex<double>> B=fft(b,1);
    rep(i,0,t)A[i]*=B[i];
    A=fft(A,-1);
    rep(i,0,s)a[i]=A[i].real();
    return a;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<double> a(100001),b(100001);
    ll cn[100001];
    fill(cn,cn+100001,0);
    rep(i,0,n){
        int t;cin>>t;
        cn[t]++;
       
    }
    rep(i,0,100001){
        a[i]=(double)cn[i];
        b[i]=(double)cn[i];
    }
    vector<double> anss=convolve(a,b);
    ll ans[anss.size()];
    rep(i,0,anss.size())ans[i]=(ll)(anss[i]+0.4);
    ll sum=0;
    ll cnt=0;
    //cout<<anss.size()<<endl;
    rrep(i,anss.size()-1,0){
        if(cnt+ans[i]>m){
            sum+=i*(m-cnt);
            break;
        }
        else{
            sum+=i*ans[i];
            cnt+=ans[i];
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 21208
import java.util.List;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

/**
 * http://abc075.contest.atcoder.jp/tasks/abc075_c
 */
public class Main {

	static Point[] points;
	static Set<Integer> g = new HashSet<Integer>();
	static Set<Integer> v = new HashSet<Integer>();
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		final int M = sc.nextInt();
		points = new Point[N];
		for(int i=0; i<N; i++) points[i] = new Point(i);
		for(int i=0; i<M; i++){
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			points[x].neighbor.add(y);
			points[y].neighbor.add(x);
		}
		sc.close();
		dfs(0, 0, new ArrayList<Integer>());
		int m = 0;
		for(int i:g){
			for(int n:points[i].neighbor){
				if(g.contains(n)){
					m++;
				}
			}
		}
		System.out.println(M-m/2);
	}
	
	
	private static void dfs(int current, int previous, List<Integer> route) {
		if(route.contains(current)){
			int d = route.indexOf(current);
			for(int i=d; i<route.size(); i++) g.add(route.get(i));
			return;
		}
		v.add(current);
		for(int n: points[current].neighbor){
			if(n==previous) continue;
			List<Integer> newRoute = new ArrayList<Integer>();
			for(int r: route) newRoute.add(r);
			newRoute.add(current);
			dfs(n, current, newRoute);
		}
	}

	static class Point{
		public Point(int id) {
			this.id = id;
		}
		int id;
		Set<Integer> neighbor = new HashSet<>();
	}

}

Measured memory_bytes: 45232
#include <stdio.h>
#include <string.h>

int main(){
    char s[5];
    scanf("%s", s);
    int ans;

    /*if(s == "SUN")ans = 7;
    else if(s == "MON")ans = 6;
    else if(s == "TUE")ans = 5;
    else if(s == "WED")ans = 4;
    else if(s == "THU")ans = 3;
    else if(s == "FRI")ans = 2;
    else if(s == "SAT")ans = 1;*/
    if(strcmp(s, "SUN") == 0)ans = 7;
    else if(strcmp(s, "MON") == 0)ans = 6;
    else if(strcmp(s, "TUE") == 0)ans = 5;
    else if(strcmp(s, "WED") == 0)ans = 4;
    else if(strcmp(s, "THU") == 0)ans = 3;
    else if(strcmp(s, "FRI") == 0)ans = 2;
    else if(strcmp(s, "SAT") == 0)ans = 1;

    printf("%d", ans);

    return 0;

}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author cherrypi59
 */

#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define FFOR(i, a, b) FOR(i, a, b+1)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) FOR(i, 1, n+1)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define LEN(x) (int)(x).size()
#define DUMP(x) cerr<<__LINE__<<' '<<#x<<"="<<(x)<<endl;
#define pb push_back
#define eb emplace_back
#define mp make_pair

using namespace std;
using lint = long long;
using pii =  pair<int, int>;
using pll =  pair<lint, lint>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vector<T>>;
template <typename T> inline bool chmax(T &a, T b){if(a<b){a = b; return true;} return false;}
template <typename T> inline bool chmin(T &a, T b){if(a>b){a = b; return true;} return false;}

constexpr lint ten(int n) {return n==0 ? 1 : ten(n-1)*10;}

class DBannedK {
public:
    void solve(std::istream& in, std::ostream& out){
        ios_base::sync_with_stdio(false);
        in.tie(nullptr), out.tie(nullptr);
        int N;
        in>>N;
        vc<int> A(N);
        vc<lint> cnt(N, 0);
        REP(i, N){
            in>>A[i], A[i]--;
            cnt[A[i]]++;
        }
        lint ans = 0;
        for(auto c : cnt) ans += c * (c-1) / 2;
        REP(i, N) out<<ans-cnt[A[i]]+1<<'\n';
    }
};


int main() {
	DBannedK solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define y second

using namespace std;

typedef long long ll;

int a[20], b[20];

int main()
{
 	//freopen("input.txt", "r", stdin);
 	//freopen("output.txt", "w", stdout);
 	ios_base::sync_with_stdio(0); cin.tie(0);
 	int n;
 	cin >> n;
 	for (int i = 1; i <= n; i++) cin >> a[i];
 	for (int i = 1; i <= n; i++) cin >> b[i];

 	int ans = -1;
 	for (int mask = 0; mask < (1 << n); mask++)
 	{
 	 	vector <pair <int, int> > spis1, spis2, spis;
 	 	int odd = 0, even = 0;
 	 	for (int i = 1; i <= n; i++)
 	 		if (((1 << (i - 1)) & mask) != 0) odd++;
 	 		else even++;
 	   	if (odd != (n + 1) / 2 || even != n / 2) continue;
 	   	
 	   	for (int i = 1; i <= n; i++)
 	 		if (((1 << (i - 1)) & mask) != 0)
 	 		{
 	 		 	if (i % 2 == 1) spis1.pb(mp(a[i], i));
 	 		 	else spis1.pb(mp(b[i], i));
 	 		}
 	 		else
 	 		{
 	 		 	if (i % 2 == 0) spis2.pb(mp(a[i], i));
 	 		 	else spis2.pb(mp(b[i], i));
 	 		}
 	   	sort(spis1.begin(), spis1.end());
 	   	sort(spis2.begin(), spis2.end());
 	   	
 	   	int uk1 = 0, uk2 = 0;
 	   	while (uk1 < (int) spis1.size() || uk2 < (int) spis2.size())
 	   	{
 	   		if (uk1 < (int) spis1.size()) spis.pb(spis1[uk1]);
 	   		if (uk2 < (int) spis2.size()) spis.pb(spis2[uk2]);
 	   		uk1++, uk2++; 	
 	   	}
        
        bool fl = true;
 	   	for (int i = 0; i < n - 1; i++) if (spis[i].x > spis[i + 1].x) fl = false;
 	   	if (!fl) continue;
 	   	
 	   	int tek = 0;
 	   	for (int i = 0; i < n; i++)
 	   		for (int j = i + 1; j < n; j++)
 	   			if (spis[i].y > spis[j].y) tek++;
 	   	if (ans == -1) ans = tek;
 	   	else ans = min(ans, tek);
 	}
 	cout << ans << '\n';
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b){
	return (b > 0)? gcd(b, a % b) : a ;
}
long long int lcm(long long int a, long long int b){
	return a / gcd(a, b) * b; 
}
int main(){
	long long int A, B, C, D; 
	cin >> A >> B >> C >> D; 
	long long int S = B / C + B / D - B / lcm(C, D); 
	long long int T = (A-1) / C + (A-1) / D - (A-1) / lcm(C, D); 
	cout << B - A + 1 - S + T << endl; 
}

Measured memory_bytes: 256
def main():
    n = int(input())
    al = [chr(i) for i in range(97, 97 + 26)]
    name = []
    while True:
        n, mod = divmod(n-1, 26)
        name.append(al[mod])
        if n <= 0:
            break
    print("".join(name[::-1]))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9124
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) int(a.size())
const int N=15010;

int gi() {
	int x=0,o=1;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
	if(ch=='-') o=-1,ch=getchar();
	while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*o;
}

int n,ans=1e9,cs,ct,tt;
char s[N],t[N];
pii ps[N],pt[N],tmp[N];

int main() {
	cin>>n;
	scanf("%s%s",s+1,t+1);
	if(n<=2) {
		int ans=0;
		for(int i=1;i<=n;i++) ans+=s[i]!=t[i];
		cout<<ans;return 0;
	}
	for(int i=1;i<n;i++) {
		if(t[i]=='0'&&t[i+1]=='1') pt[++ct]=mp(0,i);
		if(t[i]=='1'&&t[i+1]=='0') pt[++ct]=mp(1,i);
	}
	int fst=-1,lst;
	for(int i=1;i<n;i++) {
		if(s[i]=='0'&&s[i+1]=='1') {
			ps[++cs]=mp(0,i);
			if(!~fst) fst=0;
			lst=0;
		}
		if(s[i]=='1'&&s[i+1]=='0') {
			ps[++cs]=mp(1,i);
			if(!~fst) fst=1;
			lst=1;
		}
	}
	for(int i=1;i<=ct;i++) fst^=1,tmp[++tt]=mp(fst,0);
	reverse(tmp+1,tmp+tt+1);
	for(int i=1;i<=cs;i++) tmp[++tt]=ps[i];
	for(int i=1;i<=ct;i++) lst^=1,tmp[++tt]=mp(lst,n);
	cs=tt;for(int i=1;i<=cs;i++) ps[i]=tmp[i];
	/*for(int i=1;i<=cs;i++)
		cerr<<ps[i].fi<<' '<<ps[i].se<<'\n';
	cerr<<'\n';
	for(int i=1;i<=ct;i++)
	cerr<<pt[i].fi<<' '<<pt[i].se<<'\n';*/
	for(int i=1;i<=cs-ct+1;i++) {
		if(ps[i].fi!=pt[1].fi) continue;
		int sum=0;
		for(int j=1;j<=cs;j++) {
			int goal;
			if(j<i) goal=0;
			else if(j>=i+ct) goal=n;
			else goal=pt[j-i+1].se;
			//cerr<<i<<' '<<j<<' '<<goal<<'\n';
			sum+=abs(ps[j].se-goal);
			if(sum>=ans) break;
		}
		//cerr<<i<<' '<<sum<<'\n';
		ans=min(ans,sum);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 512
#pragma GCC optimize("Ofast")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>

#define for0(i,n) for(ll i = 0;i < (n);i++)
#define for1(i,n) for(ll i = 1;i<=(n);i++)
#define for2(i,n) for(ll i = 2;i<=(n);i++)
#define fastio cin.tie(0);cout.tie(0);ios::sync_with_stdio(0)
#define rep(i,st,en,cnt) for(ll i = st;i <= en;i+=cnt)
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define bit(x,n) (x & (1<<(n)))
#define EPS 1e-8
#define all(x) (x).begin(),(x).end()
#define INF 0x3f3f3f3f3f3f3f
#define NEGINF -INF
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define inp_arr(a,n) for0(i,n) {cin>>a[i];}
#define out_arr(a,n) for0(i,n) {cout<<a[i]<<" ";}cout<<endl;
#define deb1(a) cout<<(a)<<endl;
#define deb2(a,b) cout<<(a)<<" "<<(b)<<endl;
#define deb3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl;

using namespace std;

typedef pair<int,int> ii;
typedef pair<long long,long long> pll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<long long> vl;
typedef vector<vector<ll> > vvl;
typedef vector<pair<long long, long long> > vll;

ii DR8[] = {{-1,0},{0,1},{1,0},{0,-1},{-1,1},{-1,-1},{1,1},{1,-1}};
ii DR4[] = {{-1,0},{0,-1},{0,1},{1,0}};

const ll mod = 998244353;

ll nop = 2;
vi primes(nop+1,1);

void sieve(){
    primes[1] = primes[0] = 0;
    for(ll i = 2;i * i <= nop;i++){
        if(primes[i]){
            for(ll j = i*i; j <= nop;j+=i){
                primes[j] = 0;
            }
        }
    }
}

ll gcd(ll a,ll b){
    if(b>a) swap(b,a);
    if(b==0) return a;
    return gcd(b,a%b);
}

void extgcd(ll a,ll b,ll& x,ll& y){  //a smaller b larger
    if(a==0) {
        x = a;y = b;
        return;
    }
    extgcd(b%a,a,x,y);
    ll y1 = y,x1 = x;
    x = y1 - (b/a)*x1;
    y = x1;
}

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

ll bexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans *= num;
        }
        num *= num;
        e>>= 1;
    }
    return ans;
}

ll mexp(ll num,ll e){
    ll ans = 1;
    while(e>0){
        if(e&1){
            ans = (ans *num)%mod;
        }
        num *= num;
        num %= mod;
        e>>=1;
    }
    return ans%mod;
}

ll modinv(ll a){
    a %= mod;
    return mexp(a,mod-2);
}

void solve() {
    int n;
    cin>>n;
    if(n%1000) {
        deb1(1000-(n%1000))
    }
    else deb1(0)
}

int main() {
    fastio;
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t = 1;
    //cin>>t;
    while(t--) {
        solve();
    }
    /* #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
    #endif */
    return 0;
}


Measured memory_bytes: 3652
import math
N = int(input())
C = []
S = []
F = []
for i in range(N-1):
    c,s,f = map(int,input().split())
    C.append(c)
    S.append(s)
    F.append(f)
j = 0
for j in range(N-1):
    ans = C[j]+S[j]
    k = j+1
    l = 0
    for l in range(N-j-2):
        if ans <= S[k+l]:
            ans+=C[k+l]+(S[k+l]-ans)
        else:
            b=math.ceil((ans-S[k+l])/F[k+l])
            ans+=C[k+l]+(S[k+l]+F[k+l]*b-ans)
    print(ans)
print(0)
        

Measured memory_bytes: 3188
#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) , 
//string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\n';  } while(next_permutation(s.begin(), s.end()));  
//for all permutation of s.
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define out(a,n)            for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<x<<" "<<endl;
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?cout<<(a/2+1)<<endl:cout<<a/2<<endl;
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb(a)                push_back(a)
#define all(a)              a.begin(),a.end()
using namespace std;
void show(int *a)
{
    int size = (*(&a + 1) - a)-1;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
vector<int> pf;
void primefactors(int n)  
{  
    while (n % 2 == 0)  
    pf.push_back(2),n = n/2;  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            pf.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  
        pf.push_back(n);
        //dont forgot to clear pf vector. 
}  
vector<int> fac;
//vector<int,greater<int>>fac;
void factors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            fac.push_back(i);
            else
            fac.push_back(i),fac.push_back(n/i); 
        } 
    } 
    //dont forgot to clear fac vector.
} 
// priority_queue stores the values in descending order q.front() returns maximum element. ".size() works for priority_queue."
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
//    cin>>t;
    while(t--)
    {
      int x,y;
      cin>>x>>y;
      if(y%2==0)
      {
          if(x<=y/2&&y/2<=2*x)
          {
              cout<<"Yes"<<endl;
          }
          else
          {
              cout<<"No"<<endl;
          }
      }
      else
      {
          cout<<"No"<<endl;
      }
        
        
    }
   

  
}

Measured memory_bytes: 3672
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using ll = long long;
using pii = pair<ll,ll>;
using vi = vector<int>;

int main()
{
    cin.tie(0), ios::sync_with_stdio(false);
    ll N, T;
    ll a[200005] {};
    pii p[200005] {};

    ll ans = 0;

    cin >> N >> T;

    rep(i, N) {
        cin >> p[i].fi;
        p[i].se = p[i].fi + T;
    }

    ll maxt = p[0].fi;
    /*
    rep(i, N) {
        if (a[i] > maxt) {
            ans += a[i] - maxt;
            maxt = a[i];
        }
    }
    */

    rep(i, N) {
        if (p[i].fi > maxt) {
            ans += T;
            maxt = p[i].se;
        } else if (p[i].se > maxt) {
            ans += p[i].se - maxt;
            maxt = p[i].se;
        }
    }

    outl(ans);

}



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

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  for (int i = 0; i < k; i++) {
    if (i < a) {
      ans++;
      continue;
    }
    else if (a + b <= i) {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"

int main(int argc, char const *argv[]) {
  int R;
  std::cin >> R;

  if(R < 1200){
    std::cout << "ABC" << '\n';
  }else{
    if(R < 2800){
      std::cout << "ARC" << '\n';
    }else{
      std::cout << "AGC" << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include<cstdio>
#include <cstring>
#define endl '\n'
using namespace std;
int main()
{
	char s[11];
	cin>>s;
	int len = strlen(s);
	int l[11]={0},cnt = 0;
	for(int i = 0; i<len; i++)
	{
	    //cout<<"s[i] = "<<s[i]<<"    ";
		if(s[i]=='A' || s[i]=='C' || s[i]=='G' || s[i]=='T')
        {
            l[cnt]++;
            //cout<<"l[cnt] = "<<l[cnt]<<endl;
        }
		else{
                cnt++;
              //  cout<<"cnt = "<<cnt<<endl;
        }
	}
	sort(l,l+len);
//	for(int i = 0; i<cnt; i++)
//        cout<<l[i]<<" ";
    cout<<l[len-1];
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    int t[N],x[N],y[N];
    for(int i=0; i<N; i++){
        cin >> t[i] >> x[i] >> y[i];
    }

    int nowtime=0, nowx=0, nowy=0;
    for(int i=0; i<N; i++){
        if((t[i]%2==0 && (x[i]+y[i])%2 == 0)||(t[i]%2==1 && (x[i]+y[i])%2==1)){
            int difx = abs(nowx - x[i]);
            int dify = abs(nowy - y[i]);
            int diftime = abs(nowtime - t[i]);
            if(diftime >= difx + dify){
                nowtime = t[i];
                nowx = x[i];
                nowy = y[i];
            }else{
                cout << "No" << endl;
                return 0;
            }
        }else{
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
    #include <algorithm>
    #include <functional>
    #include <vector>
    #include <set>
    #include <map>
    #include <stack>
    #include <queue>
    #include <string>
     
    #define rep(i, n) for (int i = 0; i < n; i++)
    using namespace std;
    typedef long long ll;
     
    template<class T> inline bool chmin(T& a,T b) {if (a > b) {a = b; return true;} return false;}
    template<class T> inline bool chmax(T& a,T b) {if (a < b) {a = b; return true;} return false;}
     
    int main(){
      int n; cin >> n;
      int c = (n % 100) % 10;
      int b = ((n % 100) - c ) / 10;
      int a = (n - 10 * b - c) / 100;
      if (a == 7 || b == 7 || c == 7) cout << "Yes" << endl;
      else cout << "No" << endl;
    }

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
int main(){   
    string s;
    cin>>s;
    for(int i=0;s[i]!='\0';i++){
        if(s[i]=='A'&&s[i+1]=='C'){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <string>
#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;

int ans;

int main(void) {
    string n;
     cin >> n;
     rep(i, 0, 3) {
         if (n[i]=='7') {
             puts("Yes");
             return 0;
         }
     }

     puts("No");

	return 0;
}


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

int n[5];
vector<int> V;

int main(){
  for(int i = 0; i < 4; ++i){
    cin >> n[i];
    V.push_back(n[i]);
    //cout << V[i] << endl;
  }
  sort(V.begin(), V.end());
  if(V[0] == 1 && V[1] == 4 && V[2] == 7 && V[3] == 9){
    cout << "YES" << endl;
    //cout << V[0] << endl;
  }else{
    cout << "NO" << endl;
  }
}

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

int main(){
    int N;
    cin >> N;
    char s;
    int x=0,ans=0;
    while(cin >> s){
        if(s=='I') x++;
        else x--;
        ans=max(ans,x);
    }
    cout << ans << endl;
}

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

int main() {
  int N;
  cin>>N;
  int j=100;
  for (int i=0;i<N;i++){
    int x;
    int k=0;
    cin>>x;
    while (x%2==0){
      x=x/2;
      k++;
    } //k=ord2_x
   if(j>=k){
     j=k;
   }
  }
  cout<<j<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Point{
	int v,e;
	bool operator<(const Point b)const{
		return this->e > b.e;
	}
	Point(int a,int b):v(a),e(b){}
	Point():v(0),e(0){}
};

long long d[10000];
bool visit[10000] = {0};
vector <Point> G[10000];
priority_queue <Point> PQ;

const long long INF = 1e19;

void dj(int n){
	for(int i=0; i<n; i++) d[i] = INF;
	d[0] = 0;
	PQ.push(Point(0,0));
	Point p, q;
	while(!PQ.empty()){
		p = PQ.top(); PQ.pop();
		visit[p.v] = 1;
		if(d[p.v] < p.e) continue;
		int du = G[p.v].size();
		for(int i=0; i<du; i++){
			q = G[p.v][i];
			if(!visit[q.v] && q.e+d[p.v]<d[q.v]){
				d[q.v] = q.e + d[p.v];
				PQ.push(Point(q.v,d[q.v]));
			}
		}
	}
}
int main()
{	
	int n,u,du; cin>>n;
	for(int i=0; i<n; i++){
		scanf("%d%d",&u,&du);
		int v,e;
		while(du--){
			scanf("%d%d",&v,&e);
			G[u].push_back(Point(v,e));
		}
	}
	dj(n);
	for(int i=0;i<n;i++)
		printf("%d %d\n",i,d[i]);
	return 0;
}


Measured memory_bytes: 8120
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <functional>

using namespace std; using ll=long long; using ld=long double; using P=pair<ll,ll>; const int INF=1e9; const ll LINF=1e18;

int main(){
  int n; cin>>n;
  int bt=0, bx=0, by=0;
  bool ok=true;
  for(int i=0;i<n;i++) {
    int t,x,y; cin>>t>>x>>y;
    int z = (t-bt) - abs(bx-x) - abs(by-y);
    if (z<0) ok=false;
    else if (z%2) ok=false;
    bt=t; bx=x; by=y;
  }
  if (ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(void) {
  string predict;
  string ans;
  cin >> predict >> ans;
  int count = 0;
  for (int i = 0, len = predict.length(); i < len; i++) {
    if (predict[i] == ans[i]) count++;
  }
  cout << count << endl;
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
static const double EPS = 1e-9;
static const double PI = acos(-1.0);

#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, n) for (int i = (s); i < (int)(n); i++)
#define FOREQ(i, s, n) for (int i = (s); i <= (int)(n); i++)
#define FORIT(it, c) for (__typeof((c).begin())it = (c).begin(); it != (c).end(); it++)
#define MEMSET(v, h) memset((v), h, sizeof(v))

int memo[2][6][100010][5];
const ll MOD = 100000007;
char str[100010];

ll calc(int ok, int upper, int rest, int cont) {
  if (memo[ok][upper][rest][cont]) { return memo[ok][upper][rest][cont]; }
  if (rest == 0) { return 1; }
  ll ret = 0;
  if (ok && rest >= upper + 1) {
    assert(cont == 0);
    ret = (ret + calc(ok, upper, rest - upper, cont)) % MOD;
  }
  ret = (ret + calc(0, upper, rest - 1, 0)) % MOD;
  if (rest >= 2 && cont <= upper - 2) {
    ret = (ret + calc(0, upper, rest - 1, cont + 1)) % MOD;
  }
  return memo[ok][upper][rest][cont] = ret;
}

int main() {
  MEMSET(memo, 0);
  FOREQ(i, 1, 100000) {
    calc(1, 5, i, 0);
    calc(1, 3, i, 0);
  }
  memo[1][5][0][0] = 1;
  memo[1][3][0][0] = 1;
  while (scanf("%s", str), str[0] != '#') {
    int len = strlen(str);
    str[len++] = '$';
    int cnt = 0;
    int prev = -1;
    ll ans = 1;
    REP(i, len) {
      if (prev != str[i]) {
        //cout << cnt << " " << memo[1][cnt][0] << endl;
        int upper = 5;
        if (prev == '8' || prev == '0') { upper = 3; }
        ans = (ans * (ll)memo[1][upper][cnt][0]) % MOD;
        cnt = 0;
      }
      prev = str[i];
      cnt++;
    }
    printf("%lld\n", ans);
  }
}

Measured memory_bytes: 23000
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define pb push_back
#define fi first
#define se second
const ll inf = 1e18;
const ld pi = acos(-1.0);
const int N = 3e5+6;
const int M = 998244353;
vector<int>v[N];
bool vis[N];
int par[N];
void solve(){
    int n,m;
    cin>>n>>m;
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        v[x].pb(y);
        v[y].pb(x);
    }
    queue<int>q;
    q.push(1);
    vis[1] = true;
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int y:v[x]){
            if(vis[y])continue;
            vis[y] = true;
            par[y] = x;
            q.push(y);
        }
    }
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            cout<<"No"<<endl;
            return ;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=2;i<=n;i++){
        cout<<par[i]<<endl;
    }
}
int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
 //   cin>>t;
    while(t--)solve();
    return 0;
}


Measured memory_bytes: 15332
#include <iostream>

using namespace std;

int main()
{
	int x1, y1, x2, y2;

	cin >> x1;
	cin >> y1;
	cin >> x2;
	cin >> y2;

	cout << x2 + (y1 - y2) << " ";
	cout << y2 + (x2 - x1) << " ";
	cout << x1 + (y1 - y2) << " ";
	cout << y1 + (x2 - x1) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
	int n;
	long int pro;
	int i;
	
	while (scanf("%d", &n) != EOF) {
		pro = 1;
		
		for (i = 1; i <= n; i++) {
			pro *= i;
		}
		
		printf("%ld\n", pro);
	}
	
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
//#define uint __int128_t
 
#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
const ll MOD=1000000007,INF=1e18;

int N,M;
int cnt[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    //MOD同士の引き算に注意
    cin>>N>>M;
    rep(i,0,N){
        int K;
        cin>>K;
        rep(j,0,K){
            int a;
            cin>>a;
            a--;
            cnt[a]++;
        }
    }
    int ans=0;
    rep(i,0,M)if(cnt[i]==N)ans++;
    cout<<ans<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(int argc, char const* argv[])
{
	int n, q, answer = 0;
	cin >> n;
	int S[n];
	for (int i=0; i<n; i++) {
		cin >> S[i];
	}

	cin >> q;
	for (int i=0; i<q; i++) {
		int T;
		cin >> T;
		int *p = std::find (S, S+n, T);
		if (p != S+n){
			answer++;
		}
	}
	cout << answer << "\n";

	return 0;
}


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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

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

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    while(true)
    {
        int n; cin >> n;
        if(n == 0) break;

        vi w(n); REP(i, n) cin >> w[i];
        vvi dp(n, vi(n, 0)); 
        REP(i, n-1) if(abs(w[i] - w[i+1]) <= 1) dp[i][i+1] = 2;

        for(int length = 3; length <= n; length++)
        {
            for(int l = 0; l + length <= n; l++)
            {
                int r = l + length - 1;
                if(abs(w[l]-w[r]) <= 1 && dp[l+1][r-1] == length-2) dp[l][r] = length;
                for(int k = l; k < r; k++) chmax(dp[l][r], dp[l][k]+dp[k+1][r]);
            }
        }
        cout << dp[0][n-1] << endl;
    }
}


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

#define speed 			            ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n)		            for(ll i=a;i<n;i++)
#define even(x) 	                (((x)%(2)) == (0))
#define odd(x) 			            (((x)%(2)) == (1))
#define meme(x) 		            memset(x, 0, sizeof(x))
#define mod       		            1000000007

#define pb              	        push_back
#define mp                          make_pair
#define ff 			                first
#define ss 			                second
#define all(x)                      (x).begin(),(x).end()

typedef long double                 ld;
typedef pair<int,int>               pii;
typedef pair<ll,ll>                 pll;
typedef pair<double,double>         pdd;
typedef pair<ld,ld>                 pld;
typedef pair<string , string>       pss;


int main()
{
    speed
    int n;
    cin>>n;
    int count=0;
    int f=0;
    string ans="No";
    while(n--)
    {
        int x,y;
        cin>>x>>y;
        if(x==y && f==1)
        {
            count++;
            if(count>=3)
            ans="Yes";
        }
        else if(x==y && f==0)
        {
            count=1;
            f=1;
        }
        else
        {
            count=0;
        }
    }

    cout<<ans<<endl;
 
}



Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main(){

  int n,m,blank;
  string a[50],b[50];

  cin>>n>>m;

  for(int i=0;i<n;i++) cin>>a[i];
  for(int i=0;i<m;i++) cin>>b[i];

  for(int i=0;i<=n-m;i++) for(int j=0;j<=n-m;j++){
      if(a[i][j]==b[0][0]){
        blank=0;
        for(int k=0;k<m;k++) for(int u=0;u<m;u++) if(a[i+k][j+u]!=b[k][u]) blank++;
        if(blank==0){
          cout<<"Yes"<<endl;
          return 0;
        }
      }
    }
  cout<<"No"<<endl;

  return 0;

}



Measured memory_bytes: 256
import java.util.Scanner;



public class Main {

    public static void main(String[] args) {
        Scanner s=new Scanner(System.in);
        
        String in=s.next();
        
        if(in.charAt(0)<92) {
        	System.out.println("A");
        }else {
        	System.out.println("a");
        }
       
    }
}

Measured memory_bytes: 35740
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: usize = read();
    let t: usize = read();
    let mut minv = std::usize::MAX;

    for _ in 0..n {
        let c: usize = read();
        let ti: usize = read();

        if ti <= t {
            if c < minv {
                minv = c;
            }
        }
    }

    if minv == std::usize::MAX {
        println!("TLE");
        return;
    }
    println!("{}", minv);
}


Measured memory_bytes: 4352
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn input_arr<T: std::str::FromStr> () -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().flat_map(str::parse).collect()
}

fn main() {
    let n: usize = input_one().unwrap();
    let a: Vec<String> = input_arr();
    println!("{}", a[0].chars().zip(a[1].chars()).flat_map(|(a, b)| vec![a, b]).collect::<String>());
}


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

#define fast_cin() ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'

int main()
{
    int k;
    cin >> k;
    int num = 0;
    for (int i = 1; i <= k; ++i)
    {
        num = num * 10 + 7;
        num %= k;
        //out << num << "\n";
        if (num == 0)
        {
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 3556
<?php
fscanf(STDIN, "%d %d", $k, $s);
$c = 0;

for($x = 0; $x <= $k; $x++) {
  for($y = 0; $y <= $k; $y++) {
    $z = $s - $x - $y;
    if($z >= 0 && $z <= $k) {
        $c++;
    }
  }
}
echo $c."\n";


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

#define printl(s) cout << s << endl;
using ll = long long;
using pii = pair<int, int>;
using si = set<int>;

const ll modSeed = pow(10,9) + 7;
const int INF = 100'000'000;

template <typename T>
vector<T> getValues(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
int N,ans;

int main(){
  cin >> N;
  int aSet[N];  
  int alice=0;
  int bob = 0;

  for(int i=0;i<N;i++){
    cin >> aSet[i];
  }

  sort(aSet,aSet+N,greater<int>());
  for(int i=0;i<N;i++){
    if(i%2==0){
      alice+=aSet[i];
    }else{
      bob+=aSet[i];
    }
  }
  ans = alice -bob;
  printl(ans);
}


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

long A,B;

template<class T>
T gcd(T a, T b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }
    
    return b ? gcd(b, a % b) : a;
}

template<class T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}

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

    long ans=lcm(A,B);

    cout<<ans<<endl;
}

Measured memory_bytes: 256
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const inputs = input.trim().split('\n');
const n = Number(inputs[0]);
const adj = inputs.slice(1).map((s) => s.split(' ').map(Number));

const G = (new Array(n)).fill(0).map(() => (new Array(n)).fill(0));
for (let i = 0; i < n; i++) {
  const u = adj[i][0];
  const k = adj[i][1];
  const v = adj[i].slice(2);

  for (let j = 0; j < k; j++) {
    G[u - 1][v[j] - 1] = 1;
  }
}

console.log(G.map(list => list.join(' ')).join('\n'));



Measured memory_bytes: 16364
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int n[4];

    for (int i = 0; i < 4; i++){
        n[i] = 0;
    }

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

    bool A = true;
    
    for (int i = 0; i < 4; i++){
        if (n[i] >= 3){
            A = false;
        }
    }

    if (A == true){
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main()
{
	char A[11], B[11], C[11];
	int ALast, BLast;

	cin >> A >> B >> C;
	for (ALast = 0; A[ALast] != '\0'; ALast++);
	for (BLast = 0; B[BLast] != '\0'; BLast++);
	ALast--;
	BLast--;

	if (A[ALast] != B[0]) {
		cout << "NO" << endl;
		return 0;
	}
	if (B[BLast] != C[0]) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;

	return 0;
}

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

using namespace std;

/*

        Bismillahir Rahmanir Rahim
        Problem :
        Problem Link :
        Topics :
        Solver : Masud Parves
        I Love Code More than Sharks Love Blood <3
*/


#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define SZ(a)           (int)a.size()
#define all(a)  a.begin(), a.end()
#define allr(a)  a.rbegin(), a.rend()


#define sf(a)           scanf("%d",&a)
#define sff(a,b)        scanf("d",&a,&b)
#define sfff(a,b,c)     scanf("d%d",&a,&b,&c)

#define f0(i,b) for(int i=0;i<(b);i++)
#define f1(i,b) for(int i=1;i<=(b);i++)
#define f2(i,a,b) for(int i=(a);i<=(b);i++)
#define fr(i,b,a) for(int i=(b);i>=(a);i--)

#define CIN ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define TEST_CASE(t) for(int z=1 ; z<=t ; z++)
#define PRINT_CASE printf("Case %d: ",z)
#define Debug(x)            cout<<#x " = "<<(x)<<endl
#define NOT_VISITED 0
#define IS_VISITED 1
#define WHITE 0
#define GRAY 1
#define BLACK 2



int fx[4]= {1,-1,0,0};
int fy[4]= {0,0,1,-1};

/*-----------------------Bitmask------------------*/
//int Set(int N,int pos){return N=N  (1<<pos);}
//int Reset(int N,int pos){return N= N & ~(1<<pos);}
//bool Check(int N,int pos){return (bool)(N & (1<<pos));}
/*------------------------------------------------*/


const double PI = acos(-1.0);
const double EPS = 1e-6;
const int MOD = (int)1e9+7;
const int maxn = (int)3000+5;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> plli;
typedef pair<int, ll> pill;

int DP[maxn][maxn];
string a,b,ans;


void printSolution(int psA, int psB){
    if(a[psA]=='\0' or b[psB]=='\0'){
        cout<<ans<<endl;
        return;
    }

    if(a[psA]==b[psB]){
        ans+=a[psA];
        printSolution(psA+1,psB+1);
    }else {
        if(DP[psA+1][psB]>DP[psA][psB+1]){
            printSolution(psA+1, psB);
        }else printSolution(psA, psB+1);
    }
}

int LCS(int psA, int psB){

    if(a[psA]=='\0' || b[psB]=='\0'){
        return 0;
    }

    int &res = DP[psA][psB];

    if(res!=-1){
        return res;
    }

    if(a[psA]==b[psB]){
        res= 1+LCS(psA+1, psB+1);
    }else {
        res=max(LCS(psA+1, psB),LCS(psA, psB+1));
    }

    return res;
}


int main() {
    CIN
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    cin>>a>>b;

    memset(DP, -1 , sizeof(DP));

    int ans=LCS(0,0);

    printSolution( 0,0);

    return 0;
}



Measured memory_bytes: 35840
import std.stdio;
import std.algorithm;
import std.conv;
import std.array;
import std.string;
import std.math;
import std.functional;
import std.range;
import std.typecons;

void main(string[] args) {
  solve(readln, readln).writeln;
}

auto solve(string line1, string line2) {
  auto _ = line1.split.map!(to!int).array;
  auto N = _[0];
  auto K = _[1];
  auto a = line2.split;

  auto counter = new Counter!(string, int)(a);
  auto over = cast(int)counter.table.keys.length - K;
  if (over > 0) {
    return counter.items
      .sort!"a.value < b.value"
      .take(over)
      .map!"a.value"
      .sum;
  } else {
    return 0;
  }
}

unittest {
  assert(solve(
    "5 2",
    "1 1 2 2 5") == 1, "1");
  assert(solve(
    "4 4",
    "1 1 2 2") == 0, "2");
  assert(solve(
    "10 3",
    "5 1 3 2 4 1 1 2 3 4") == 3, "3");
}

class Counter(E, Int) {
  Int[E] table;

  this(E[] elems) {
    foreach(e; elems) {
      add(e);
    }
  }

  void add(E e, Int num = 1) {
    if (e in table) {
      table[e] += num;
    } else {
      table[e] = num;
    }
    if (table[e] == 0) {
      table.remove(e);
    }
  }

  Int get(E e) {
    return table.get(e, 0);
  }

  auto items() {
    return table.keys.map!(k => tuple!("key", "value")(k, table[k])).array;
  }
}

Measured memory_bytes: 39184
#include <iostream>
#include <chrono>
#include <cmath>
#include <string.h>
#include <iomanip>
#include <algorithm>
#include <unordered_set>
#include <vector>
#include <queue>
#include <math.h>
#include <unordered_map>
#include <fstream>
#include <functional>
#include <map>
#include <deque>
#include <string.h>

#define MAX(a, b) (a > b ? a : b)
#define MIN(a, b) (a < b ? a : b)
#define ABS(a) (a < 0 ? -a : a)
#define YesNo(flag) (flag ? "Yes\n" : "No\n")
#define YESNO(flag) (flag ? "YES\n" : "NO\n")

constexpr auto NMAX = (int)1e5 + 20;
constexpr auto INF_ULL = 18446744073709551615;
constexpr auto INF_INT = 2147483647;
constexpr auto PI = 3.14159265359;
using namespace std;

typedef unsigned long long ull;

vector<int> graph[NMAX];
bool vis[NMAX];
bool inQueue[NMAX];
int sign[NMAX];
int n, m;

void BFS(int node) {
	queue<int> Q;
	Q.push(node);

	while (!Q.empty()) {
		int node = Q.front();
		vis[node] = true;
		Q.pop();

		for (int i = 0; i < graph[node].size(); i++) {
			if (!vis[graph[node][i]] && !inQueue[graph[node][i]]) {
				sign[graph[node][i]] = node;
				Q.push(graph[node][i]);
				inQueue[graph[node][i]] = true;
			}
		}
	}
}

int main()
{
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		int a, b;
		cin >> a >> b;
		a--;
		b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	memset(sign, -1, sizeof(sign));
	BFS(0);

	for (int i = 1; i < n; i++) {
		if (sign[i] == -1) {
			cout << YesNo(false) << '\n';
			exit(0);
		}
	}
	cout << YesNo(true);
	for (int i = 1; i < n; i++) {
		cout << sign[i] + 1 << '\n';
	}
	return 0;
}

Measured memory_bytes: 10572
a = int(input())
b = int(input())

if a == b:
    print(1)
    exit()

# 二進数xの長さを求める時、len(bin(x)) - 2　では、xが0のとき1を返してしまい、バグる原因になる
# よって、二進数の長さを計算する関数を用意しておく
def bitlen(x):
    return 1 + bitlen(x >> 1) if x else 0

t = a ^ b
n = bitlen(t)

T = 1 << (n - 1)

a = a & (T * 2 - 1)
b = b & (T * 2 - 1)

sb = b & (T - 1)
b_max = (2 ** bitlen(sb) - 1) | T

if (T + a) > b_max:
    print((b_max - a + 1) + (2 * T - 1 - (T + a) + 1))
else:
    print(2 * T - 1 - a + 1)


Measured memory_bytes: 3188
data = input().split()
N = int(data[0])
Y = int(data[1])

flag = False

for a in range(N + 1):
    if flag:
        break
    for b in range(N + 1 - a):
        if flag:
            break
        c = N - a - b
        if c < 0:
            continue
        elif a * 10000 + b * 5000 + c * 1000 == Y:
            print(str(a) + " " + str(b) + " " + str(c))
            flag = True

if not flag:
    print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> P;
 
const int INF=1e9;
int h,w;
char maze[51][51];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
int d[50][50];
 
int main(){
  cin>>h>>w;
  for(int i=0;i<h;++i)cin>>maze[i];
 
  int ans=h*w;
 
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
        ans-=maze[i][j]=='#';
 
  for(int i=0;i<h;++i)
    for(int j=0;j<w;++j)
      d[i][j]=INF;
 
  queue<P> que;
 
  que.push(P(0,0));
  d[0][0]=1;
 
  while(que.size()){
 
    P p=que.front();
    que.pop();
 
    if(p.first==h-1&&p.second==w-1)
        break;
 
    for(int i=0;i<4;++i){
 
        int x=p.first+dx[i], y=p.second+dy[i];
 
        if(0<=x && x<h && 0<=y && y<w && maze[x][y]!='#' && d[x][y]==INF){
            que.push(P(x,y));
            d[x][y]=d[p.first][p.second]+1;
        }
 
    }
 
  }
 
  cout << (d[h-1][w-1]==INF? -1:ans-d[h-1][w-1]) << endl;
 
  return 0;
}

Measured memory_bytes: 256
# B - Guidebook
import numpy as np
# import pandas as pd 

N = int(input())
A, B = [[], []]

for _ in range(N):
  a, b = [i for i in input().split()]
  A.append(a)
  B.append(int(b))


A = np.array(A)[:, np.newaxis]
B = np.array(B)[:, np.newaxis].astype('int')
C = np.concatenate([A, B], axis=1)
C = C.tolist()

ans = sorted(C, key=lambda x:(x[0],-int(x[1])))

for i in ans:
  print(C.index(i)+1)


"""
df = pd.DataFrame(C, index=[i+1 for i in range(N)])
df = df.sort_values([0, 1], ascending=[True, False])
"""
# for i in df.index:
#  print(i)


Measured memory_bytes: 18680
from collections import deque
import sys
input = sys.stdin.readline

def main():
    N = int(input())

    q = deque()
    for i in range(1, 10):
        q.append(i)
    now = 0
    for _ in range(N):
        now = q.popleft()
        tmp = now%10
        if tmp != 0:
            q.append(now * 10 + tmp - 1)
        q.append(now * 10 + tmp)
        if tmp != 9:
            q.append(now * 10 + tmp + 1)
    print(now)

if __name__ == "__main__":
    main()

Measured memory_bytes: 11956
import sys
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7

s = S()

# n個のオセロストーンが1列にある。長さnの文字列sで石の状態はあらわされていて、
# i番目の石が白：w、黒:bであらわされている。
# 以下の操作を行う

# iがb,i+1がwなiを一つ選び、二つとも裏返す。

# 最大でこの作業を何回行うことができるか。

# 例
# bwbwbwbwbw ⇒ wbwbwbwbwb
# bwwbbbwwwbwb　⇒　wbwbbbwwwbwb　⇒ wwbbbwwwbwb　⇒ wwbbwbwwbwb　⇒ wwbwbbwwbwb　⇒
# wwwbbbwwbwb　⇒ wwwbbwbwbwb　⇒ wwwbwbbwbwb　⇒ wwwwbbbwbwb　⇒ wwwwbbbwbwb　⇒ 

# 最終的にwwwwwwbbbbbになるので、結論としてはwを左に動かした回数をカウントすればよい。
# このカウントは、左から見て行ってwが出た位置より左のbの数を足し上げればよい。
black = 0
ans = 0
for stone in s:
    if stone == "B":
        black = black + 1
    else:
        ans = ans + black
print(ans)

Measured memory_bytes: 73216
n=int(input())
a=[]
while n:
    a+=n%26,
    n//=26
a=a[::-1]
for i in range(len(a)-1,0,-1):
    if a[i]<1:
        a[i]+=26
        a[i-1]-=1
print(''.join(chr(c+96)for c in a[not a[0]:]))

Measured memory_bytes: 9104