akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)
ll INF = 1LL << 60;

void solve(long long N, long long C, std::vector<long long> s, std::vector<long long> t, std::vector<long long> c){
    set< pair<pll, ll> > A;
    REP(i, N){
        A.insert(make_pair(pll(s[i], t[i]), c[i] ));
    }
    ll cnt = 0;
    while(!A.empty()){
        cnt++;
        pair<pll, ll> tmp = *A.begin();
        A.erase(A.begin());
        vector<set< pair<pll, ll> >::iterator > to_erase;
        for(auto it=A.begin(); it != A.end(); it++){
            if(it->second == tmp.second){ //* same channel
                if(it->first.first >= tmp.first.second){ //* can stay on the same machine
                    tmp = *it;
                    to_erase.push_back(it);
                }
            }
            else{ //* different channes
                if(it->first.first >= tmp.first.second+1){ //* can stay on the same machine
                    tmp = *it;
                    to_erase.push_back(it);
                }
            }
        }
        REP(i, to_erase.size()){
            A.erase(to_erase[i]);
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long C;
    scanf("%lld",&C);
    std::vector<long long> s(N);
    std::vector<long long> t(N);
    std::vector<long long> c(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&s[i]);
        scanf("%lld",&t[i]);
        scanf("%lld",&c[i]);
    }
    solve(N, C, std::move(s), std::move(t), std::move(c));
    return 0;
}


Measured memory_bytes: 9980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};
ll dp[100100][13];
int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> v;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        v.push_back({a,i});
    }
    sort(v.begin(),v.end());
    for(int i=0;i< n;i++){
        cout << v[i].second+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1780
n, a, b, c, d = map(int, input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1
if '##' in s[a:c+1] or "##" in s[b:d+1]:
    print('No')
    exit()

if c > d:
    if '...' in s[b-1:d+2]:
        print('Yes')
    else:
        print('No')
else:
    print('Yes')


Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll n, res = 0;
    string pre = "";

    cin >> n;
    vector<string> s(n);
    rep(i, n)
    {
        cin >> s[i];
    }
    sort(s.begin(), s.end());
    rep(i, n)
    {
        if (pre != s[i])
        {
            res++;
        }
        pre = s[i];
    }

    cout << res << endl;
}

Measured memory_bytes: 9596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) cin>>a.at(i);
  int ans=0;
  int mini=10000000;
  for(int i=0;i<n;i++){
    mini=min(mini,a.at(i));
    if(a.at(i)<=mini) ans++;
  }
  cout<<ans;
}


Measured memory_bytes: 1024
import java.util.*;

class Main {

  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);

    char s[] = sc.next().toCharArray();

    for (int i = 0; i < (1 << s.length - 1); i++) {
      String ans = "" + s[0];
      int sum = s[0] - '0';
      for (int j = 0; j < s.length-1; j++) {
        if ((1 & i>>j) == 1) {
          sum += s[j+1] - '0';
          ans += "+" + s[j+1];
        }
        else {
          sum -= s[j+1] - '0';
          ans += "-" + s[j+1];
        }
      }
      //System.out.printf("%s=%d\n", ans, sum);
      if (sum == 7) {
        System.out.println(ans + "=7");
        return;
      }
    }
    //System.out.println("No Answer");
  }
}


Measured memory_bytes: 25172
// Date: Sat Jun 08 13:09:40 JST 2013 
#include<iostream>
using namespace std;
int mt[16][16][16][16];
int dp[16][16];
int i,j,k,l,m,n,o,a,b,c,d,cnt,X,Y;
void init(){
  for(int i=0;i<16;i++){
    for(int j=0;j<16;j++){
      dp[i][j]=0;
      for(int k=0;k<16;k++){
    for(int l=0;l<16;l++){
      mt[i][j][k][l]=0;
    }
      }
    }
  }
}
int main(){
  int n;
  cin>>n;
  for(int data=0;data<n;data++){
    init();
    cin>>X>>Y>>m;
    for(int i=0;i<m;i++){
      cin>>a>>b>>c>>d;
      mt[a][b][c][d]=1;
      mt[c][d][a][b]=1;
    }
    dp[0][0]=1;
    for(int i=1;i<=X;i++){
      if(mt[i][0][i-1][0]==1){
    dp[i][0]=0;
      }else{
    dp[i][0]=dp[i-1][0];
      }
    }
 
    for(int i=1;i<=Y;i++){
 
      if(mt[0][i][0][i-1]){
    dp[0][i]=0;
      }else{
    dp[0][i]=dp[0][i-1];
      }
 
      for(int j=1;j<=X;j++){
    if(mt[j][i][j-1][i]==0){
      dp[j][i]+=dp[j-1][i];
    }
    if(mt[j][i][j][i-1]==0){
      dp[j][i]+=dp[j][i-1];
    }
      }
    }
    if(dp[X][Y]==0){
      cout<<"Miserable Hokusai!"<<endl;
    }else{
      cout<<dp[X][Y]<<endl;
    }
  }
  return 0;
}

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

int number(string &formula, int &index) {
	int value = 0;
	for(int i=index; i<(int)formula.size(); i++) {
		if(isdigit(formula.at(i))) {
			value = value * 10 + stoi(formula.substr(i,1));
			index++;
		}
		else {
			break;
		}
	}
	return value;
}

int formula1(string &formula, int &index) {
	int value = 0;
	value += number(formula, index);
	while(1) {
		if((int)formula.size() == index) {
			break;
		}

		if(formula.at(index) == '+') {
			index++;
			value += number(formula, index);
		}
		else if(formula.at(index) == '-') {
			index++;
			value -= number(formula, index);
		}
		else {
			break;
		}
	}
	return value;
}

int main(void) {
	string num = "";
	int goal = 7;

	cin >> num;

	vector<string> formulas(1<<3);
	for(int bits=0; bits<(1<<3); bits++) {
		bitset<3> s(bits);
		string op;
		string formula = "";

		for(int i=0; i<3; i++) {
			if(s.test(i)) {
				op.push_back('+');
			}
			else {
				op.push_back('-');
			}
		}

		for(int i=0; i<4; i++) {
			if(i == 3) {
				formula += num.at(i);
			}
			else {
				formula += num.at(i);
				formula.push_back(op.at(i));
			}
		}

		formulas.push_back(formula);
	}

	for(string f : formulas) {
		int index = 0;
		if(formula1(f, index) == goal) {
			cout << f << "=" << goal << endl;
			break;
		}
	}
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,i,j,k,c=0,d;
	cin>>n;
	long long a[n];
	cin>>a[0];
	for(i=1;i<n;i++){
		cin>>a[i];
		d=a[i-1]-a[i];
		if(d>0){
			a[i]+=d;
			c+=d;
		}
	}
	cout<<c<<endl;
	return 0;
}


Measured memory_bytes: 5176
import math

a,b = map(lambda x: int(x), input().split())


hati_s = a/0.08
hati_l = (a+1)/0.08

ten_s = b/0.1
ten_l = (b+1)/0.1

#print(hati_s,hati_l,ten_s,ten_l)


def intersec(a_min,a_max,b_min,b_max):
    if a_min < b_min:
        if a_max < b_min:
            return [0,0]
        else:
            if a_max < b_max:
                return [b_min,a_max]
            else:
                return [b_min,b_max]
    else:
        if b_max < a_min:
            return [0,0]
        else:
            if b_max < a_max:
                return [a_min,b_max]
            else:
                return [a_min,a_max]


def min_int(pair):
    if pair == [0,0]:
        return -1
    else:
        return math.ceil(pair[0])



tmp = intersec(hati_s,hati_l,ten_s,ten_l)

if math.ceil(tmp[0]) == math.ceil(tmp[1]):
    print(-1)
else:
    tst = min_int(tmp)
    print(tst)



Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <climits>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <list>
#include <ctime>
#include <complex>
#include <bitset>
#include <tuple>
#define MAXN 200000
using namespace std;

typedef long long int lli;

struct strt{
    int a, b;
};
int N, A[MAXN], ans[MAXN];
vector<int> G[MAXN], LIS;
bool visit[MAXN];
stack<strt> oper;
void dfs(int v){
    if(visit[v]) return;
    visit[v] = true;

    int x = A[v];

    if(LIS.empty() || LIS.back() < x){
        LIS.push_back(x);
        oper.push({-1});
    }else{
        auto itr = lower_bound(LIS.begin(), LIS.end(), x);
        int orig = (*itr);
        (*itr) = x;
        oper.push({(int)(itr - LIS.begin()), orig});
    }
    ans[v] = LIS.size();

    for(int j = 0; j < G[v].size(); ++j){
        int u = G[v][j];
        dfs(u);
    }

    strt t = oper.top(); oper.pop();
    if(t.a == -1){
        LIS.pop_back();
    }else{
        LIS[t.a] = t.b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> N;
    for(int j = 0; j < N; ++j)
        cin >> A[j];
    for(int j = 0; j < N - 1; ++j){
        int u, v; cin >> u >> v;
        G[u - 1].push_back(v - 1);
        G[v - 1].push_back(u - 1);
    }
    dfs(0);
    for(int j = 0; j < N; ++j)
        cout << ans[j] << "\n";
    return 0;
}

Measured memory_bytes: 28976
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

using namespace std;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

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


int main() {
	string s ; cin >> s;
	for(char c : s) if (c == '7') {cout << "Yes" << endl; return 0 ; }
	cout << "No"<< endl;
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		char[] cs = s.toCharArray();
		sc.close();

		String head = "";
		String tail = "";
		int count = 0;
		for(int i=0; i<n; i++) {
			if(cs[i]=='(') {
				count += 1;
			} else {
				count -= 1;
				if(count < 0) {
					head += "(";
					count = 0;
				}
			}
		}
		for(int i=0; i<count; i++)
			tail += ")";
		System.out.println(head + s + tail);
	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;


const int N = 200;

struct point{ int x, y; };
int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
char m[N][N];

int bfs(int h, int w, point start, point goal, int dis[N][N]){
    queue<point> q;

    dis[start.y][start.x] = 0;
    q.push(start);

    point u;
    while(!q.empty()){
        u = q.front(); q.pop();
        rep(i,4){
            point next;
            next.x = u.x + dx[i];
            next.y = u.y + dy[i];
            if(next.y >= h || next.y < 0 || next.x >= w || next.x < 0) continue;
            if(dis[next.y][next.x] == -1 && m[next.y][next.x] != '#'){
                dis[next.y][next.x] = dis[u.y][u.x] + 1;
                q.push(next);
            }
        }
    }
    return dis[goal.y][goal.x];
}

bool check(int dis[N][N], vector<point> v, int p){
    rep(i,v.size()){
        if(dis[v[i].y][v[i].x] <= p) return 1;
    }
    return 0;
}

int main(){
    int h, w;
    int dis[N][N];
    point princess, patch;
    vector<point> soldiers;

    scanf("%d%d", &h,&w);
    rep(i,h){
        scanf("%s", m[i]);
        rep(j,w){
            if(m[i][j] == '%') patch = {j, i};
            else if(m[i][j] == '@') princess = {j, i};
            else if(m[i][j] == '$'){
                point temp = {j, i};
                soldiers.emplace_back(temp);
            }
        }
    }

    memset(dis, -1, sizeof(dis));
    int p = bfs(h, w, princess, patch, dis);

    memset(dis, -1, sizeof(dis));
    bfs(h, w, patch, patch, dis); //dis???patch??????????????¢???????????????

    if(check(dis, soldiers, p)) printf("No\n");
    else printf("Yes\n");
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int gcd(int x,int y){
	
	if(x%y==0){
		return y;
	}else{
		return gcd(y,x%y);
	}
	
}

int main() {
	
	ll K,A,B;
	
	cin>>K>>A>>B;
	if(B-A<=2){
      ce(K+1)
    }else{
      ll ans=(K-(A-1))%2+(B-A)*((K-(A-1))/2)+A;
      	ce(ans)
    }

}

Measured memory_bytes: 768
abs=math.abs
N,X,Y=io.read("*n","*n","*n")
C={}
for i=1,N-1 do
	for j=i+1,N do
		l=math.min(abs(j-i),abs(X-i)+1+abs(j-Y),abs(Y-i)+1+abs(j-X))
		C[l]=(C[l] or 0)+1
	end
end
for i=1,N-1 do
print(C[i] or 0)
end

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

using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;

#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
 
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}

void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
////////////////////////////



int main(){fastio
    ll n,m;cin>>n>>m;
    vector<l_l>v[n+1];
    rep(i,1,m){
        ll a,b,c;cin>>a>>b>>c;
        v[a].pb(l_l(b,c));
        v[b].pb(l_l(a,-c));
    }
    ll d[n+1];rep(i,1,n)d[i]=inf;
    rep(i,1,n){
        if(d[i]==inf){
            d[i]=0;
            queue<ll>q;q.push(i);
            while(!q.empty()){
                ll t=q.front();q.pop();
                for(auto y:v[t]){
                    ll to=y.fi,dis=y.se;
                    if(d[to]==inf){
                        d[to]=d[t]+dis;
                        q.push(to);
                    }else{
                        if(d[to]!=d[t]+dis){
                            cout<<"No"<<endl;return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 14080
use itertools::Itertools;
use proconio::input;

fn main() {
    input!(n: usize, a: [usize; n], b: [usize; n]);

    if let Some(ans) = solve(n, &a, &b) {
        println!("Yes");
        println!("{}", ans.iter().map(|&v| v.to_string()).join(" "))
    } else {
        println!("No")
    }
}

fn solve(n: usize, a: &[usize], b: &[usize]) -> Option<Vec<usize>> {
    let mut d = 0;
    for i in 0..n {
        while i + d < n && a[i] >= b[i + d] {
            d += 1;
        }
    }
    if (0..n).all(|i| a[i] != b[(i + d) % n]) {
        Some([&b[d..], &b[..d]].concat())
    } else {
        None
    }
}


Measured memory_bytes: 10808
s = int(input())

def f(n):
    return n / 2 if n % 2 == 0 else 3 * n + 1

counter = 0
a = [s]
while True:
    ai = f(a[counter])
    if ai in a:
        break
    a.append(ai)
    counter += 1
print(counter+2)

Measured memory_bytes: 2940
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int H,W;
string s[55];

bool Check(int i, int j){
        for(int y=-1;y<=1; y+=2) {
                if((0<=i+y)&&(i+y<H)&&(s[i+y][j]=='#')) return true;
        }
        for(int x=-1; x<=1; x+=2){
                if((0<=j+x)&&(j+x<W)&&(s[i][j+x]=='#')) return true;
        }
        return false;
}

int main() {
        bool fl = true;

        cin >> H >> W;
        for(int i=0;i<H; i++) cin >> s[i];

        for(int i=0; (i<H)&&fl; i++){
                for(int j=0; (j<W)&&fl; j++){
                        if(s[i][j]=='#') fl=Check(i,j);
                }
        }

        if(fl) cout << "Yes" << endl;
        else cout << "No" << endl;

        return 0;
}

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

using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    if(s=="SUN") cout << 7;
    else if(s=="MON") cout << 6;
    else if(s=="TUE") cout << 5;
    else if(s=="WED") cout << 4;
    else if(s=="THU") cout << 3;
    else if(s=="FRI") cout << 2;
    else cout << 1;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n)   for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(long long i=(a);((a)<(b)?i<=(b):i>=(b));((a)<(b)?++i:--i))
#define ALL(v)     (v).begin(),(v).end()
#define debug(x)   cerr<<#x<<": "<<(x)<<endl
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
constexpr int    INF=1e9;
constexpr double EPS=1e-9;
constexpr int    MOD=1e9+7;
template<class Type>
void line(const Type &a){int cnt=0;for(const auto &elem:a){cerr<<(cnt++?' ':'>');cerr<<elem;}cerr<<endl;}

int main(){
	int n;
	cin>>n;
	
	vector<llong> a(n);
	REP(i,n) cin>>a[i];
	sort(ALL(a));
	
	int ans=1;
	llong sum=0;
	REP(i,n-1){
		sum+=a[i];
		if(a[i+1]<=2*sum) ans++;
		else ans=1;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 4020
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
//#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int mod = 1e9 + 7;
const int N = 200005;
const int K = 25;
int ans[N];
int f[N], invf[N], dp[K][N], a[N];
int binpow(int x, int y){
    if (y == 0) return 1;
    if (y % 2) return x * binpow(x, y - 1) % mod;
    int z = binpow(x, y / 2);
    return z * z % mod;
}
int c(int n, int k){
    if (k > n) return 0;
    return f[n] * invf[k] % mod * invf[n - k] % mod;
}
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n, k;
    cin >> n >> k;
    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i < N; i++) f[i] = f[i - 1] * i % mod;
    for (int i = 1; i < N; i++) invf[i] = binpow(f[i], mod - 2);
    for (int i = 1; i <= k; i++) cin >> a[i];
    dp[0][0] = 1;
    for (int i = 1; i <= k; i++){
        for (int j = 0; j <= n; j++){
            for (int l = 0; l <= min(j, a[i]); l++){
                dp[i][j] = (dp[i][j] + c(j, l) * c(n - l, a[i] - l) % mod * dp[i - 1][j - l]) % mod;
            }
        }
    }
    cout << dp[k][n];
}


Measured memory_bytes: 39168
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
// ------------------------
void solve() {
    int N, M; cin >> N >> M;
    vector<int> a(M), b(M); rep(i, M) cin >> a[i] >> b[i];
    map<int, int> mp; rep(i, N) mp[i] = 0;

    rep(i, M){
        ++mp[a[i]];
        ++mp[b[i]];
    }
    for (int i = 1; i <= N; ++i){
        cout << mp[i] << "\n";
    }
}

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

Measured memory_bytes: 256
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <tuple>

using namespace std;

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

long long int INF = 1e18;
long long int mod = 1000000007;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,n) for(i=0;i<n;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll number1,ll number2){
    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){
    if(number1 > number2){
        swap(number1 , number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1 , number1);
    }
}


ll i,j,k,ii,jj;
ll n,m;
ll a,b,c,d,e,g,h,r;
ll l;
ll num;
ll x[500005],y[500005],z[500005];
ll muki[200005],iro[200005];
ll ans[180000];
bool dame;
char s[500005],t[500005];
ll color[5000005],len[500005],sum[500005];
ll xnum,ynum;
ll dp[5005][5005];

int main(){
    
    cin >> s >> t;
    n = strlen(s);
    m = strlen(t);
    for(i=0;i<=n;i++){
        dp[i][0] = 0;
    }
    for(i=0;i<=m;i++){
        dp[0][i] = 0;
    }
    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            if(s[i-1] != t[j-1]){
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                dp[i][j] = max(dp[i][j],dp[i-1][j-1]);
            }else{
                dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
                dp[i][j] = max(dp[i][j],dp[i-1][j-1]+1);
            }
        }
    }
    a = n;
    b = m;
    while(1){
        if(s[a-1] == t[b-1]){
            ans[num++] = a-1;
            a--;
            b--;
        }else{
            if(dp[a][b] == dp[a-1][b]){
                a--;
            }else if(dp[a][b] == dp[a][b-1]){
                b--;
            }else{
                a--;
                b--;
            }
        }
        if((a==0 && b==0) || num == dp[n][m])break;
    }
    for(i=num-1;i>=0;i--){
        pu(s[ans[i]]);
    }
    el;
    return 0;
}



Measured memory_bytes: 145664
def resolve():
    INF = float("-inf")
    N = int(input())
    A = list(map(int, input().split()))

    skip = 1 + N % 2
    # i番目までの要素を見たときに、ｊ個選ばない時の最大値
    dp = [[INF] * (skip + 2) for _ in range(N + 1)]
    dp[0][0] = 0

    for i in range(N):
        for j in range(skip + 1):  # j: スキップする個数
            # 今見ている要素をスキップ
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j])
            now = dp[i][j]
            if (i + j) % 2 == 0:
                now += A[i]
            dp[i + 1][j] = max(dp[i + 1][j], now)

    print(dp[N][skip])


if __name__ == "__main__":
    resolve()

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

using namespace std;

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

int main(){

  int N;
  long long A;

  cin >> N;
  vector <long long> vA(N);
  //  vA.reserve(N);
  for(int i = 0; i< N; ++ i){
    cin >> A;
    vA.at(i) = A;
  }

  vector<long long> vL(N);
  vector<long long> vR(N);

  for(int i = 0; i< N ;++i){
    if(i == 0) vL.at(i) = 0;
    else vL.at(i) = gcd(vL.at(i-1), vA.at(i-1));
  }
  for(int i = N-1; i >= 0 ;--i){
    if(i == N-1) vR.at(i) = 0;
    else vR.at(i) = gcd(vR.at(i+1), vA.at(i+1));
  }

  long long ans = 1;
  for(int i = 0; i< N; ++i){
    long long tmp = gcd(vL.at(i), vR.at(i));
    if(tmp > ans) ans = tmp;
  }

  cout << ans << endl;;
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <numeric>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep1(i,n) for (int i = 1; i <= n; ++i)
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
const long long MOD = 1e9+7;
template<typename T> inline void add(T& a, T b) { a += b; if (a >= MOD) a -= MOD; }

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

  int N,T; cin >> N >> T;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int tmpm = A[0];
  int curmax = 0;
  int cnt = 0;
  rep1(i, N - 1) {
    int ben = A[i] - tmpm;
    if(ben > curmax) {
      curmax = ben;
      cnt = 1;
    } else if(ben == curmax) {
      ++cnt;
    }
    tmpm = min(tmpm, A[i]);
  }

  cout << cnt << endl;
}


Measured memory_bytes: 640
import sys
 
def main():
    input = sys.stdin.readline
    N = int(input())
    A = list(map(int, input().split()))
 
    ans = 0
    H = A[0]
    for a in A:
        if a >= H:
            ans += 1
 
        H = max(H, a)
 
    return ans
 
 
if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3060
# -*- coding:utf-8 -*-

def solve():
    N, M = list(map(int, input().split()))

    ac_dic = {}
    wa_lst = [0 for _ in range(N+1)]
    ac_score, wa_score = 0, 0
    for i in range(M):
        p, s = input().split()
        p = int(p)

        if not p in ac_dic:
            if s == "WA":
                wa_lst[p] += 1
                ac_dic[p] = False
            else:
                ac_score += 1
                ac_dic[p] = True
        else:
            if s=="WA" and not ac_dic[p]:
                wa_lst[p] += 1
            elif s=="AC" and not ac_dic[p]:
                ac_score += 1
                ac_dic[p] = True

    # waスコアを数える
    for i, score in enumerate(wa_lst):
        if i in ac_dic and ac_dic[i]:
            wa_score += wa_lst[i]

    print(ac_score, wa_score)


if __name__ == "__main__":
    solve()


Measured memory_bytes: 15924
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	
	string ans;
	
	int n;
	string s;
	
	cin >> n >> s;
	
	rep(i,s.size()){
		s[i]+=n;
		if(s[i]>'Z') s[i]-=26;
	}
	
    cout << s << '\n';
    
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int[] A;
        int n;
        n = sc.nextInt();
        A = new int[n];

        for(int i=n-1;i>=0;--i){
            A[i] = sc.nextInt();
        }
        print(A, n);
    }

    public static void print(int A[], int n){
        for(int i=0;i<n;++i){
            System.out.print(A[i]);
            if(i<n-1){System.out.print(" ");}
        }
        System.out.println();
    }
}



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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

template<class T,class U> void chmax(T& a, U b) {if(a<b)a=b;}
template<class T,class U> void chmin(T& a ,U b) {if(b<a)a=b;}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int a,b,c;
    cin >> a >> b >> c;

    if (a + b + c > 21) {
        cout << "bust" << endl;
    } else {
        cout << "win" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
void dfs(vector<int> &dp,vector<int> adj[],int u,vector<bool> &vis)
{
    vis[u]=true;
    for(int i=0;i<adj[u].size();i++)
    {
        if(!vis[adj[u][i]])
        {
            dfs(dp,adj,adj[u][i],vis);
        }
        dp[u]=max(dp[u],1+dp[adj[u][i]]);
    }
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<int> adj[n+1];
    for(int i=0;i<m;i++)
    {
       int u,v;
       cin>>u>>v;
       adj[u].push_back(v);
    }
    vector<int> dp(n+1,0);
    vector<bool> vis(n+1,false);
    for(int i=1;i<=n;i++)
    {
        if(!vis[i])
        {
          dfs(dp,adj,i,vis);
        }
    }
    int ans=INT_MIN;
    for(int i=1;i<=n;i++) ans=max(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string a,b;
  cin>>a>>b;
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  sort(a.begin(),a.end());
  if(a<b)cout<<"Yes";
  else cout<<"No";

  return 0;
}


Measured memory_bytes: 256
import numpy as np;
count = 0;
maxnum=0;
n,m = input().split();
mark=np.zeros(int(n));
s = input();

for i in range(1,int(n)):
    if(s[i]=='C' and s[i-1] == 'A'):
        count= count +1;
    mark[i] = count;
for j in range(int(m)): 
    x,y = input().split();
    print(int(mark[int(y)-1])-int(mark[int(x)-1]))

Measured memory_bytes: 15964
#include <stdio.h>
#include <iostream>
using namespace std;

int judge(int n, int x);

int main(void)
{		
	while (1) {
		int n, x;
		cin >> n >> x;
		
		if (n == 0 && x == 0) break;
		
		cout << judge(n, x) << endl;
	}
	
	return 0;
}

int judge(int n, int x)
{
	int count = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = i + 1; j <= n; j++) {
			for (int k = j + 1; k <= n; k++) {
				if (i + j + k == x) {
					count++;
					break;
				}
			}
		}
	}
	
	return count;
}

Measured memory_bytes: 3088
//Littleboy123 Template 1.1

#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(a) cout << (a) << '\n'
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pi acos(-1.0)

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

//End of template

int main(){
	init();

	//debug
	/*
	ifstream in("input.in");
	streambuf *cinbuf = std::cin.rdbuf();
	cin.rdbuf(in.rdbuf());

	ofstream out("out.txt");
	streambuf *coutbuf = std::cout.rdbuf();
	cout.rdbuf(out.rdbuf());
	*/
	//end debug

	ll a, b, c;
	cin >> a >> b >> c;
	ll aslia, aslib, aslic;
	aslia = a;
	aslib = b;
	aslic = c;
	ll u, v, w;
	int count = 0;
	while(a % 2== 0 && b % 2 == 0 && c % 2 == 0){
		count++;
		u = a/2;
		v = b/2;
		w = c/2;
		a = v+w;
		b = u+w;
		c = u+v;
		if(a == aslia && b == aslib && c == aslib){
			cout << -1 << nl;
			return 0;
		}
	}
	cout << count << nl;
	return 0;
}

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

int main(){

    int N,i,j;
    char W[100][11];
    char tailc,headc;

    scanf("%d",&N);

    for(i=0; i<N; i++){
        scanf("%s",W[i]);        
        fflush(stdin);
    }


    //重複の確認
    for(i=0; i<N; i++){
        for(j=0; j<N; j++){
            if(i==j)continue;
            if(strcmp(W[i],W[j])==0){
                //printf("%d,%d,%s,%s\n",i,j,W[i],W[j]);
                printf("No");
                return 0;
            }    
        }
    }

    //printf("重複なし\n");

    //末尾と戦闘が繋がっているかの確認
    for(i=0; i<N-1; i++){

        //printf("str:%s\n",W[i]);
        //末尾文字を取得
        for(j=0;;j++){
            if(W[i][j]=='\0'){
                tailc=W[i][j-1];
                break;
            }
        }

        //先頭文字を取得
        headc=W[i+1][0];

        if(tailc!=headc){
            //printf("tail:%c,head:%c,pos:%d\n",tailc,headc,i);
            printf("No");
            return 0;
        } 

    }

    printf("Yes");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N, K;
    cin >> N >> K;
    vector<int> H(N + 1, 0);
    for (int i = 1; i <= N; i++) cin >> H[i];
    vector<vector<int>> dp(N + 1, vector<int>(N - K + 1, INF));
    dp[0][0] = 0;
    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N - K; j++) {
            for (int k = 0; k < i; k++) {
                dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0LL, H[i] - H[k]));
            }
        }
    }
    int ans = INF;
    for (int i = 1; i <= N; i++) ans = min(ans, dp[i][N - K]);
    cout << (ans == INF ? 0 : ans) << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <unordered_set>

using namespace std;

unordered_set<int> G[200001];
int N, M;
int a, b;

int main() {

    scanf("%d %d", &N, &M);

    for (int i = 0; i < M; i++) {
        scanf("%d %d", &a, &b);
        G[a].insert(b);
        G[b].insert(a);
    }

    bool ans = false;

    for (int i:G[1]) {
        if (G[N].find(i) != G[N].end()) {
            ans = true;
        }
    }

    printf("%s\n", ans ? "POSSIBLE" : "IMPOSSIBLE");
}

Measured memory_bytes: 28480
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using ld = long double;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const long double PI = acos(-1.0L);
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)
    cin >> a[i];
  sort(a.begin(), a.end());
  rep(i, n-1) {
    if (a[i] == a[i+1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M,W,H,K;
	string s;
	while(cin>>s) {
		VI h(26);
		REP(i, s.size()) h[s[i]-'a']++;
		ll ans=1;
		REP(i, 26) if(h[i]%2==1) ans=0;
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
def acgt(t):
    if len(t) == 0:
        return 1
    if t[0] in ["A", "C", "G", "T"]:
        return acgt(t[1:])
    return 0
    
s = input() + "."*100
ans = 0
for l in range(20):
    for i in range(20):
        if acgt(s[i:i+l]):
            ans = l

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (ll i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> B[i];
    }

    priority_queue<iint> q;
    for (ll i = 0; i < N; i++) {
        q.push(make_pair(B[i], i));
    }

    ll ans = 0;
    while(!q.empty()){
        iint v = q.top(); q.pop();
        int s = v.first; int t = v.second;

        if(B[(t-1+N) % N] + B[(t+1)%N] < B[t]){
            ans += B[t] / (B[(t-1+N) % N] + B[(t+1)%N]);
            B[t] = B[t] % (B[(t-1+N) % N] + B[(t+1)%N]);
            if(B[t] < A[t]){
                if((A[t] - B[t]) % (B[(t-1+N) % N] + B[(t+1)%N]) != 0){
                    printf("-1\n"); return 0;
                }
                else{
                    ans -= (A[t] - B[t]) / (B[(t-1+N) % N] + B[(t+1)%N]);
                    B[t] = A[t];
                }
            }
            else if(B[t] == A[t]){

            }
            else{
                q.push(make_pair(B[t], t));
            }
        }
        else{

        }

    }

    for (int i = 0; i < N; i++) {
        if(A[i] != B[i]){
            printf("-1\n"); return 0;
        }
    }
    printf("%lld\n", ans);


}

Measured memory_bytes: 6940
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <deque>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
priority_queue<string, vector<string>, greater<string>> a[10];
int N;
set<char> S;

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

  cin >> N;
  a[0].push("a");
  S.insert('a');
  rep(i, N) {
    if (i==0) continue;
    priority_queue<string, vector<string>, greater<string>> que = a[i-1];
    while(!que.empty()) {
      string s = que.top(); que.pop();
      set<char> st;
      rep(i, s.size()) st.insert(s[i]);
      for (auto it = st.begin(); it != st.end(); ++it) {
        char k = *it;
        a[i].push(s+k);
      }
      auto itr = st.end();
      itr--;
      char c = *itr+1;
      a[i].push(s+c);
      if (que.empty()) S.insert(c);
    }
  }

  priority_queue<string, vector<string>, greater<string>> que2 = a[N-1];
  set<string> Ans;
  while(!que2.empty()) {
    string s = que2.top(); que2.pop();
    Ans.insert(s);
  }
  for (auto it = Ans.begin(); it != Ans.end(); ++it) cout << *it << endl;
  return 0;
}

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

int main(){
    int a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<a[k-1];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;

int main() {
  ll A, B, N;
  cin >> A >> B >> N;
  if (N < B) {
    cout << (A*N)/B - A*(N/B) << endl;
  }
  else {
    cout << (A*(B-1))/B - A*((B-1)/B) << endl;
  }
}

Measured memory_bytes: 3596
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    int64_t N;
    std::cin >> N;

    std::vector<int64_t> A;
    for (size_t i = 0; i < N; ++i) {
        int64_t t;
        std::cin >> t;
        A.push_back(t);
    }

    // 降順ソート
    std::sort(std::begin(A), std::end(A),
              [](const auto& a, const auto& b) {
                  return a > b;
              });


    for (auto a: A) {
        cerr << a << " ";
    }
    cerr << endl;

    // 判定
    if (N%2 != 0) {
        if (A.back() != 0) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    int64_t v = N - 1;
    for (int64_t i = 0; i < N/2; i+=2, v -= 2) {
        if (A[i] != v || A[i+1] != v) {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    int64_t ret = 1;
    for (int64_t i = 0; i < N/2; ++i) {
        ret *= 2;
        ret %= (1000000000LL + 7);
    }
    std::cout << ret << std::endl;

    return 0;
}


Measured memory_bytes: 1400