akhauriyash/Code-Regression huggingface dataset:
#if !defined(__clang__) && defined(__GNUC__)
#include <bits/stdc++.h>
#else
#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>
#endif //  !defined(__clang__) && defined(__GNUG__)
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/math/common_factor_rt.hpp>

using namespace std;

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

    // std::string S;
    // std::cin >> S;

    struct Pos {
        int64_t x;
        int64_t y;
    };

    std::vector<Pos> red;
    for (decltype(N) i = 0; i < N; ++i) {
        Pos t;
        std::cin >> t.x >> t.y;
        red.push_back(t);
    }

    std::vector<Pos> blue;
    for (decltype(N) i = 0; i < N; ++i) {
        Pos t;
        std::cin >> t.x >> t.y;
        blue.push_back(t);
    }

    // yの降順
    std::sort(std::begin(red), std::end(red),
              [](const auto& a, const auto& b) {
                  return a.y > b.y;
              });

    // xの昇順
    std::sort(std::begin(blue), std::end(blue),
              [](const auto& a, const auto& b) {
                  return a.x < b.x;
              });

    int count = 0;

    for (auto b: blue) {
        for (auto ri = red.begin(); ri != red.end(); ++ri) {
            if (b.x > ri->x && b.y > ri->y) {
                count++;
                red.erase(ri);
                break;
            }
        }
    }


    std::cout << count << std::endl;

    return 0;
}


Measured memory_bytes: 256
/*問題文の通りに直接シミュレーションするだけでは反転クエリが高速に処理できず、 O((N + Q)^2)
となり遅いです。
Ti = 1 のとき実際に文字列を操作するのではなく、現在どちら側が先頭かという情報を持っておけ
ば、Ti = 2 のクエリでもその情報を考慮することで、位置関係を保ったままシミュレーションできま
す。最後に全体を反転する必要がある場合に気をつけてください。
ここで、C + + などで普通の文字列型の先頭に追加する操作は計算量が悪いため、dequeue で文字
列を管理するか、左右で分けて文字列を保持し最後に適切に連結するといった方法で対処できます。*/
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <deque>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)


int main(){
    deque<char> deq;
    string s;
    cin >> s;
    rep(i,s.size()) deq.push_back(s[i]);
    int q;
    cin >> q;
    bool f = true;
    while(q--){
        int a,b;
        char c;
        cin >> a;
        if (a == 1) f = !f;
        else{
            cin >> b >> c;
            if (f && b == 2) deq.push_back(c);
            else if (f && b == 1) deq.push_front(c);
            else if (!f && b == 1)deq.push_back(c);
            else deq.push_front(c);
        }
    }
    if (f){
        for (auto itr = deq.begin(); itr != deq.end(); itr++){
            cout << *itr;
        }
        cout << endl;
    }
    else {
        for (auto itr = deq.end()-1; itr != deq.begin(); itr--){
            cout << *itr;
        }
        cout << *(deq.begin()) << endl;
    }
    
   return 0;

}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){ 
    int N;
    cin >>N;
    vector<int> V(N);
    vector<int> C(N);
    int ans = 0;
    for(int i = 0;i < N;i++) cin >> V[i];
    for(int i = 0;i < N;i++) cin >> C[i];
    for(int i = 0;i < N;i++){
        if(V[i] > C[i]) ans += V[i] - C[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
N = int(input()[-1]) #N: int, the ones place of the inputed number

number_hon = {2, 4, 5, 7, 9} #number_hon: set
number_pon = {0, 1, 6, 8} #number_pon: set
number_bon = {3} #number_bon

if N in number_hon:
    print("hon")
elif N in number_pon:
    print("pon")
elif N in number_bon:
    print("bon")

Measured memory_bytes: 9184
#include<iostream>
#include<cstdio>
using namespace std;
long long n,a,b,ans=0;
int main(){
    cin>>n>>a>>b;
    long long tmp=n/(a+b);
    long long r=n%(a+b);
    if(r>a)
        r=a;
    ans=tmp*a+r;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
using namespace std;

int main() {
    int N;
    string A,B;
    cin >> N;
    cin >> A >> B;
    for (auto i = 0;i < N; ++i) {
        cout << A[i] << B[i];
    }
    cout << endl;
    return 0;
}

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

vector<int> v(303030);
ll n,k,m;
string s,t;

int main() {
  cin >> s >> k;
  int i=0;
  while(s[i]=='1') i++;
  if(i+1<=k) 
  cout << s[i] << endl;
  else 
  cout << 1 << endl;
}

Measured memory_bytes: 1408
#include <iostream>
using namespace std;
/*
Problem Statement
Takahashi is a user of a site that hosts programming contests.
When a user competes in a contest, the rating of the user (not necessarily an integer) 
changes according to the performance of the user, as follows:

Let the current rating of the user be 
a
Suppose that the performance of the user in the contest is 
b
Then, the new rating of the user will be the avarage of 
a
 and 
b
For example, if a user with rating 
1
 competes in a contest and gives performance 
1000
, his/her new rating will be 
500.5
, the average of 
1
 and 
1000
.
Takahashi's current rating is 
R
, and he wants his rating to be exactly 
G
 after the next contest.
Find the performance required to achieve it.
*/

int aRating(int a, int b){
    return (2 * b) - a;
}

int main(){
  	int r,g;
  	cin>>r>>g;
    cout<<aRating(r,g);
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, m;
    cin >> n >> m;
    vint a(n), b(n);
    vint c(m), d(m);
    rep(i, n) cin >> a[i] >> b[i];
    rep(i, m) cin >> c[i] >> d[i];

    vint ans(n, 0);
    rep(i, n) {
        int mn = INF;
        rep(j, m) {
            int dist = abs(c[j] - a[i]) + abs(d[j] - b[i]);
            if (dist < mn) {
                ans[i] = j+1;
                mn = dist;
            }
        }
    }

    rep(i, n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a == b){
        cout << c << endl;
    }
    else if(a == c){
        cout << b << endl;
    }
    else{
        cout << a << endl;
    }
return 0;
}

Measured memory_bytes: 256
n = int(input())
if n >= 64:
  print(64)
elif n >= 32:
  print(32)
elif n >= 16:
  print(16)
elif n >= 8:
  print(8)
elif n>=4:
  print(4)
elif n >= 2:
  print(2)
else:
  print(1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        boolean app = true;
        for(int i=0; i<n; i++) {
            int a = in.nextInt();
            if(a%2==0) {
                if(a%3==0 || a%5==0) {
                    // OK
                }
                else {
                    app = false;
                }
            }
        }
        System.out.println(app?"APPROVED":"DENIED");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define Rint register int
using namespace std;
const int N = 1000003;
template<typename T>
inline void read(T &x){
    int ch = getchar(); x = 0;
    for(;ch < '0' || ch > '9';ch = getchar());
    for(;ch >= '0' && ch <= '9';ch = getchar()) x = x * 10 + ch - '0';
}
int n, m, q, z, g, mod, u[N], v[N], c[N], fa[N], h[N];
bool pr[2][N];
inline int gcd(int a, int b){return b ? gcd(b, a % b) : a;}
inline int id(int x, int p, int q){return (x - 1) * 6 + p * 3 + q;}
inline int getfa(int x){while(x != fa[x]) x = fa[x] = fa[fa[x]]; return x;}
inline void comb(int x, int y){
    x = getfa(x); y = getfa(y);
    if(x != y){
        if(h[x] < h[y]) swap(x, y);
        fa[y] = x; h[x] += h[x] == h[y];
    }
}
inline int qmo(int x){return x + ((x >> 31) & mod);}
int main(){
    read(n); read(m); read(q); read(mod);
    for(Rint i = 1;i <= m;++ i){
        read(u[i]); read(v[i]); read(c[i]);
        g = gcd(g, abs(c[i] - c[1]));
    }
    if(!g) g = mod; mod = gcd(3 * g, mod); int z = c[1] % g;
    for(Rint i = 0;i < 6 * n;++ i) fa[i] = i;
    for(Rint i = 1;i <= m;++ i){
        int t = (c[i] - z) / g;
        for(Rint p = 0;p < 2;++ p)
            for(Rint q = 0;q < 3;++ q){
                comb(id(u[i], p, q), id(v[i], !p, (2 * q + t) % 3));
                comb(id(v[i], p, q), id(u[i], !p, (2 * q + t) % 3));
            }
    }
    for(Rint i = 0, t = z;i < (mod << 1);++ i, t = qmo(2 * t - mod)) pr[i & 1][t] = true;
    while(q --){
        int s, t, r; read(s); read(t); read(r);
        bool ans = 0;
        for(Rint p = 0;p < 2;++ p)
            for(Rint q = 0;q < 3;++ q)
                if(getfa(id(t, 0, 0)) == getfa(id(s, p, q))) ans |= pr[p][(r + z + (3 - q) * g) % mod];
        puts(ans ? "YES" : "NO");
    }
}

Measured memory_bytes: 12672
import std.stdio, std.string, std.conv;

void main() {
    auto AB = readln.split.to!(int[]);
    auto A = AB[0], B = AB[1];
    A = (A + 11) % 13;
    B = (B + 11) % 13;
    if (A < B) writeln("Bob");
    else if (A > B) writeln("Alice");
    else writeln("Draw");
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()


using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;



int main(){
    int n, m;
    cin >> n >> m;
    vector<ll> v(n);
    map<ll, ll>mp;
    ll res = 0;
    rep(i, n){
        int a;
        cin >> a;
        if(i == 0)v[i] = a;
        else v[i] = v[i - 1] + a;
        v[i] %= m;
        mp[v[i]]++;
        if(v[i] == 0)res++;
    }
    for(auto m : mp){
        res += (m.second) * (m.second - 1) / 2;
    }
    cout << res << endl;
}


Measured memory_bytes: 4992
<>;
for(`factor`){
	$x=$y=1;
	s/( \d+)\1*\b/$x*=$&**($a=$&=~y! !!%3);$y*=$&**(-$a%3)/ge;
	++$h{$x};
	$t{$x}=$y
}
$\=!!$h{1};
$h{1}=0;
$\+=$h{$h{$_}>$h{$t{$_}}?$_:$t{$_}},$h{$_}=$h{$t{$_}}=0for keys%h;
print


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

using namespace std;

#define lli long long
#define ld long double
#define mod 1000000007 
#define set(n) cout << fixed << setprecision(n)    
#define fi first
#define se second
#define mp make_pair
#define pll pair<lli, lli>
#define endl '\n'

const double PI = acos(-1);
const double epsilon = 1e-7;  // floating point precision

signed main(void) {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<lli> v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    lli mx = 0;
    lli ans = 0;
    for(int i = 0; i < n; i++) {
        if(v[i] < mx) {
            ans += (mx - v[i]);
        }
        else {
            mx = v[i];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4752
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <iomanip>
#include <stack>
using namespace std;
int main(){
  double tall;
  vector<double> v;
  while(cin>>tall){
    if(cin.eof())break;
    if(!tall)break;
    v.push_back(tall);
  }
  sort(v.begin(),v.end());
  cout<<v[v.size()-1]-v[0]<<endl;
}

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

					#define mp make_pair
					#define pb push_back
					#define sqr(x) (x) * (x)
					#define sors(s) sort(s.begin(), s.end())
					#define F first
					#define S second

					using namespace std;
					typedef long long ll;
					string s;
					int main()
					{
						cin >> s;
						if(s == "Sunny")
							cout << "Cloudy";
						else if(s == "Cloudy")
							cout << "Rainy";
						else if(s == "Rainy")
							cout << "Sunny";  
					}

Measured memory_bytes: 256
import java.util.*;
public class Main {
   public static void main(String[] args) {  
      Scanner sc = new Scanner(System.in);
      
      int N = sc.nextInt();
      sc.nextLine();
      String s = sc.nextLine();
      
      String res = "";
      for(char c : s.toCharArray()) {
         res += (char)(((c - 'A') + N) % 26 + 65);
      }
      System.out.println(res);
   }
}

Measured memory_bytes: 146992
#include<iostream>
#include<vector>
#define m 60000
using namespace std;
 int main(){
    int n,cnt=0;
    vector<bool>a(m+1,true);
    for(int i=2;i*i<=m;i++)
         if(a[i]) for(int j=i+i;j<=m;j+=i)  a[j]=false;   
    int p[50000];  
    for(int i=2;i<=m;i++){
            if(a[i]) { p[cnt]=i;cnt++; }
    }

    while(1){
        cin>>n;
        if(cin.eof()) break;
        for(int i=0;i<cnt;i++){
            if(p[i]<n && p[i+1]>n) {
		cout<<p[i]<<" "<<p[i+1]<<endl;
            }else if(p[i]==n) {
                cout<<p[i-1]<<" "<<p[i+1]<<endl;}
       } 
    }
    return 0;
}

Measured memory_bytes: 1236
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

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

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

template <typename T>
class UnionFind{
    public:
        int n;
        vector<T> p, rank;

        UnionFind(int n)
            : n(n), p(n+1, -1), rank(n+1) {}

        int find(int v){
            if(p[v] == -1){
                return v;
            }
            p[v] = find(p[v]);
            return p[v];
        }

        bool unite(int u, int v){
            u = find(u);
            v = find(v);

            if(u == v){
                return false;
            }

            if(rank[u] < rank[v]){
                swap(u, v);
            }

            if(rank[u] == rank[v]){
                rank[u]++;
            }

            p[v] = u;
            return true;
        }

        bool same(int u, int v){
            u = find(u);
            v = find(v);
            return u == v;
        }
};

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

    int n, m, k;
    cin >> n >> m >> k;
    vector<int> c(n + 1);
    rep(i, n) cin >> c[i+1];
    vector<tuple<int, int, int>> e(m);
    rep(i, m){
        int a, b, w;
        cin >> a >> b >> w;
        e[i] = make_tuple(w, a, b);
    }

    UnionFind<int> uf(n);
    vector<int> cc(k + 1);
    for(int i = 1; i <= n; i++){
        if(c[i] == 0){
            continue;
        }
        if(cc[c[i]] == 0){
            cc[c[i]] = i;
            continue;
        }
        uf.unite(i, cc[c[i]]);
        cc[c[i]] = i;
    }

    sort(ALL(e));
    int ans = 0;
    rep(i, m){
        if(k == 1){
            break;
        }
        int a, b, w;
        tie(w, a, b) = e[i];
        if(uf.unite(a, b)){
            ans += w;
            k--;
        }
    }

    if(k > 1){
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;

    return 0;
}


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

#define debug(...) fprintf(stderr, __VA_ARGS__)

#ifndef AT_HOME
#define getchar() IO::myGetchar()
#define putchar(x) IO::myPutchar(x)
#endif

namespace IO {
	static const int IN_BUF = 1 << 23, OUT_BUF = 1 << 23;

	inline char myGetchar() {
		static char buf[IN_BUF], *ps = buf, *pt = buf;
		if (ps == pt) {
			ps = buf, pt = buf + fread(buf, 1, IN_BUF, stdin);
		}
		return ps == pt ? EOF : *ps++;
	}

	template<typename T>
	inline bool read(T &x) {
		bool op = 0;
		char ch = getchar();
		x = 0;
		for (; !isdigit(ch) && ch != EOF; ch = getchar()) {
			op ^= (ch == '-');
		}
		if (ch == EOF) {
			return false;
		}
		for (; isdigit(ch); ch = getchar()) {
			x = x * 10 + (ch ^ '0');
		}
		if (op) {
			x = -x;
		}
		return true;
	}

	inline int readStr(char *s) {
		int n = 0;
		char ch = getchar();
		for (; isspace(ch) && ch != EOF; ch = getchar())
			;
		for (; !isspace(ch) && ch != EOF; ch = getchar()) {
			s[n++] = ch;
		}
		s[n] = '\0';
		return n;
	}

	inline void myPutchar(char x) {
		static char pbuf[OUT_BUF], *pp = pbuf;
		struct _flusher {
			~_flusher() {
				fwrite(pbuf, 1, pp - pbuf, stdout);
			}
		};
		static _flusher outputFlusher;
		if (pp == pbuf + OUT_BUF) {
			fwrite(pbuf, 1, OUT_BUF, stdout);
			pp = pbuf;
		}
		*pp++ = x;
	}

	template<typename T>
	inline void print_(T x) {
		if (x == 0) {
			putchar('0');
			return;
		}
		static int num[40];
		if (x < 0) {
			putchar('-');
			x = -x;
		}
		for (*num = 0; x; x /= 10) {
			num[++*num] = x % 10;
		}
		while (*num){
			putchar(num[*num] ^ '0');
			--*num;
		}
	}

	template<typename T>
	inline void print(T x, char ch = '\n') {
		print_(x);
		putchar(ch);
	}

	inline void printStr_(const char *s, int n = -1) {
		if (n == -1) {
			n = strlen(s);
		}
		for (int i = 0; i < n; ++i) {
			putchar(s[i]);
		}
	}

	inline void printStr(const char *s, int n = -1, char ch = '\n') {
		printStr_(s, n);
		putchar(ch);
	}
}
using namespace IO;

int n;
int a[200005], b[200005];

int main() {
	read(n);
	for (int i = 1; i <= n; ++i) {
		read(a[i]);
	}
	for (int i = 1; i <= n; ++i) {
		read(b[i]);
	}
	int d = 0;
	int pa = 1, pb = 1;
	for (int i = 1; i <= n; ++i) {
		while (pa <= n && a[pa] == i) {
			++pa;
		}
		d = std::max(d, pa - pb);
		while (pb <= n && b[pb] == i) {
			++pb;
		}
	}
	std::rotate(b + 1, b + n - d + 1, b + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (a[i] == b[i]) {
			printStr("No");
			return 0;
		}
	}
	printStr("Yes");
	for (int i = 1; i <= n; ++i) {
		print(b[i], " \n"[i == n]);
	}
}

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

int main(){
  string s;
  cin >> s;
  if(s == "hi" || s == "hihi" || s == "hihihi" || s == "hihihihi" || s == "hihihihihi"){
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}


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

int main() {
  int r, g, b, n;
  cin >> r >> g >> b;
  n = 100*r+10*g+b;
  if (n%4==0) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3616
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
using namespace std;

typedef uint64_t ull;
typedef int64_t ll;

int main(int argc, char* argv[])
{
	for (;;) {
		ull N, A;
		cin >> N >> A;
		if (cin.fail()) break;

		std::vector<ull> xx;
		for (ull i = 0; i < N; i++) {
			ull x;
			cin >> x;
			xx.push_back(x);
		}

		map<ull, map<ull, ull>> m; // <sum, <div, count>>
		m[0][0] = 1;
		for (ull x : xx) {
			auto old_m = m;
			for (auto& e1 : old_m) {
				for (auto& e2 : e1.second) {
					ull count = 0;
					auto it1 = old_m.find(e1.first + x);
					if (it1 != old_m.end()) {
						auto it2 = it1->second.find(e2.first + 1);
						if (it2 != it1->second.end()) {
							count = it2->second;
						}
					}
					m[e1.first + x][e2.first + 1] = count + e2.second;
				}
			}
		}

		ull result = 0;
		for (auto& e1 : m) {
			for (auto& e2 : e1.second) {
				if (e2.first > 0 && e1.first == A * e2.first) {
					result += e2.second;
				}
			}
		}

		printf("%llu\n", result);
	}

	return 0;
}


Measured memory_bytes: 3072
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  long s;
  cin >> s;
  if(s == 1 || s == 2) {
    cout << 4 << endl;
    return 0;
  }
  for(long i = 1; ; i++) {
    if(s % 2 == 0) {
      if(s == 4) {
        cout << i+3 << endl;
        return 0;
      }
      else s /= 2;    
    } 
    else s = 3*s + 1;
  }
}

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

using namespace std;

using ll = long long;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int tar = 1;
    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
        if (a == tar) ++tar;
    }
    cout << (tar == 1 ? -1 : n - tar + 1) << "\n";
    return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
var buf = make([]byte, 1000000)

func main() {
	sc.Buffer(buf, 1000000)

	var num int
	if sc.Scan() {
		num, _ = strconv.Atoi(sc.Text())
	}
	var seq = make([]int, num)

	if sc.Scan() {
		for i, v := range strings.Split(sc.Text(), " ") {
			seq[i], _ = strconv.Atoi(v)
		}
	}

	var min, max, sum int
	for _, i := range seq {
		sum += i
		if min == 0 || min > i {
			min = i
		}
		if max == 0 || max < i {
			max = i
		}
	}

	fmt.Printf("%d %d %d\n", min, max, sum)

}



Measured memory_bytes: 1560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846


using namespace std;

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

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

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

template<class T>T updmax(T &x, T y) { return x = max(x, y); }
template<class T>T updmin(T &x, T y) { return x = min(x, y); }

int main() {
	string s;
	cin >> s;
	int n = s.length();
	int x = 0;
	LL ret = 0;
	int i = n - 1;
	while (i >= 0) {
		if (s[i] == 'A') {
			ret += x;
			i--;
		}
		else if (s[i] == 'C') {
			if (i > 0 && s[i - 1] == 'B') {
				x++;
				i -= 2;
			}
			else {
				x = 0;
				i--;
			}
		}
		else {
			x = 0;
			i--;
		}
	}
	printf("%lld\n", ret);
	return 0;
}

Measured memory_bytes: 640
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextWord() string {
	sc.Scan()
	return sc.Text()
}

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

func max(v1, v2 int) int {
	if v1 > v2 {
		return v1
	}
	return v2
}

func main() {
	var dp [100005][3]int
	sc.Split(bufio.ScanWords)
	n := nextInt()
	var abc [3][]int
	for i := 0; i < n; i++ {
		abc[0] = append(abc[0], nextInt())
		abc[1] = append(abc[1], nextInt())
		abc[2] = append(abc[2], nextInt())
	}

	for j := 0; j < 3; j++ {
		dp[0][j] = abc[j][0]
	}

	for i := 1; i < n; i++ {
		dp[i][0] = max(dp[i-1][1]+abc[0][i], dp[i-1][2]+abc[0][i])
		dp[i][1] = max(dp[i-1][0]+abc[1][i], dp[i-1][2]+abc[1][i])
		dp[i][2] = max(dp[i-1][0]+abc[2][i], dp[i-1][1]+abc[2][i])
	}

	ans := max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2])
	fmt.Println(ans)
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<ll,ll> pll;
const ll INF = 2e18;
const int inf = 1e9+10;
const int maxN = 200010;
const int maxD = 15;
const int maxH = 100; 
const int MOD = 1000000007;

int T;
struct node
{
	int x,y,z,d;
	bool operator < (const node&p)const
	{
		return d < p.d;
	}
};
node a[maxN];
int p[maxN];
int n,m,Q;
int ans;
int check()
{
	int tmp = 0;
	for(int i=1;i<=Q;i++)
	{
		int x = a[i].x;
		int y = a[i].y;
		int z = a[i].z;
		int d = a[i].d;
		if(p[y] - p[x] == z)
		{
			tmp += d;
		}
	}
	return tmp;
}
void dfs(int k)
{
	if(k > n)
	{
		ans = max(ans,check());
		return ;
	}
	for(int i=p[k-1];i<=m;i++)
	{
		p[k] = i;
		dfs(k+1);
	}
}
int main()
{
	
	scanf("%d%d%d",&n,&m,&Q);
	for(int i=1;i<=Q;i++)
	{
		scanf("%d%d%d%d",&a[i].x,&a[i].y,&a[i].z,&a[i].d);
	}
	ans = 0;
	for(int i=1;i<=m;i++)
	{
		p[i] = i;
		dfs(2);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    if(s[s.size()-1] == 's') cout << s << "es" << endl;
    else cout << s << 's' << endl;
}

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

int main(){
  int N;
  double T,A;
  cin >> N;
  cin >> T >> A;
  vector<double> H(N);
  for(int i =0;i<N;i++){
    cin >> H[i];
  }
  
  vector<double> HT(N);
  for(int i = 0; i<N;i++){
    HT[i] = abs(A -(T - H[i]*0.006));
  }
  
  cout << distance(HT.begin(),min_element(HT.begin(),HT.end())) + 1 << endl;
}

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

struct edge{
  int a,b,c;
  bool operator<(const edge &e) const{
    return c < e.c;
  }
};
typedef long long ll;

struct uni{
  int d[100003];
  int f[100003];
  void init(){ memset(d,-1,sizeof(d)); memset(f,0,sizeof(f)); }
  int find(int a){ return d[a]<0?a:(d[a]=find(d[a])); }
  void marge(int a,int b){
    a = find(a); b = find(b);
    if( a == b ) return ;
    if( d[a] > d[b] ) swap(a,b);
    if( f[a] || f[b] ) f[a] = 1;
    d[a]+=d[b]; d[b] = a; 
  }
  bool same(int a,int b){
    return find(a) == find(b);
  }
  int size(int a){
    return -d[find(a)];
  }
  bool isbase(int a){ return f[find(a)]; }
};

int N,T,K;
uni U;

int main(){
  int ttt =0;
  while( cin >> N >> T >> K && (N||T||K) ){

    U.init();
    ll sum = 0;
    vector<edge> E;
    vector<edge> E2;
    for(int i=0;i<N-1;i++){
      int a,b,c;
      cin >> a >> b >> c;
      E.push_back( (edge){a,b,c} );
      sum += c;
    }
    for(int i=0;i<T;i++){
      int a; cin >> a;
      U.f[a] = 1;
    }
    for(int i=0;i<N-1;i++){
      if( !U.isbase(E[i].a) || !U.isbase(E[i].b) ) E2.push_back(E[i]);
    }
    ll res = 0;
    sort(E2.rbegin(),E2.rend());
    int ks = 0;
    for(int i=0;i<(int)E2.size();i++){
      int a = E2[i].a, b = E2[i].b, c = E2[i].c;
      if( U.same(a,b) ) continue;
      if( !U.isbase(a) || !U.isbase(b) ){
	U.marge(a,b);
	res += (ll)c;
	ks++;
      }
    }
    //  cout << ks << endl;
    //cout << N-K-1 << endl;
    assert(N-K-1>=ks);
    sort(E.rbegin(),E.rend());
    for(int i=0;N-K-1>ks;i++){
      if( U.same(E[i].a,E[i].b) ) continue;
      U.marge(E[i].a,E[i].b);
      res += (ll)E[i].c;
      ks++;
    }
    // cout << N - K - 1<< endl;
    //cout << ks << endl;
    cout << "Case " << ++ttt << ": " << sum - res << endl;
  }
}

Measured memory_bytes: 2388
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
s = input()

ans = 0
a_alr = []
b_alr = {}

for i in range(10):
    b_alr[str(i)] = []

for i in range(n-2):
    if(len(a_alr) == 10):
        break
    if(s[i] in a_alr):
        continue

    for j in range(i+1,n-1):
        if(len(b_alr[s[i]]) == 10):
            break
        if(s[j] in b_alr[s[i]]):
            continue
        
        ans += len(set(s[j+1:]))
        
        b_alr[s[i]].append(s[j])
    a_alr.append(s[i])

print(ans)

Measured memory_bytes: 3188
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;


int main(){
  long ii,jj,kk;

  int n,m,v;
  set<int> a,b;
  cin >> n;

  for(ii=0;ii<n;ii++){
    cin >> v;
    a.insert(v);
  }

  cin >> m;

  for(ii=0;ii<m;ii++){
    cin >> v;
    b.insert(v);
  }

  set<int>::iterator it;
  set<int> c;
  it = a.begin();

  while(it != a.end()){
    if(b.find(*it) != b.end()){
      c.insert(*it);
    }
    it++;
  }

  it = c.begin();
  
  while(it != c.end()){
    cout << *it << endl;
    it++;
  }
  
  return 0;
  
}



Measured memory_bytes: 23748
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
P art[500005],Art[500005];
ll a[500005];
ll ans;
ll k;
int n;
ll t;
int I;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
		cin>>art[i].first>>art[i].second;
	}
	sort(art,art+n);
	for(int i=0;i<n;i++){
		if(art[i].first==art[i+1].first){
			t=t+art[i].second;
		}else{
			t=t+art[i].second;
			Art[I].first=art[i].first;
			Art[I].second=t;
			t=0;
			//cout<<I<<" "<<Art[I].first<<" "<<Art[I].second<<endl;
			I++;
			//cout<<I<<" "<<Art[I].first<<" "<<Art[I].second<<endl;
		}
	}
	for(int i=1;i<I;i++){
		a[i]=Art[i].second+(Art[i-1].first-Art[i].first);
		//cout<<i<<" "<<a[i]<<endl;
	}
	ans=Art[0].second;
	k=ans;
	for(int i=1;i<I;i++){
		k=k+a[i];
		ans=max(ans,k);
		if(Art[i].second>k){
			ans=max(ans,Art[i].second);
			k=Art[i].second;
		}
		//cout<<i<<" "<<k<<" "<<ans<<endl;
	}
	//cout<<N<<" "<<I<<endl;
	cout<<ans<<endl;
    
}



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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

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

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int r, c;
  cin >> r >> c;
  cout << 2*c-r << endl;

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    int N;
    ll D;
    in2(N, D);

    vll X(N);
    vll Y(N);

    rep(i, N) in2(X[i], Y[i]);

    int c = 0;

    rep(i, N)
    {
        if (X[i] * X[i] + Y[i] * Y[i] <= D * D) c++;
    }

    outl(c);

    return 0;
}

Measured memory_bytes: 6316
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

int main() {
    ll N, K;
    cin >> N >> K;

    vector<ll> H(N);
    REP(i, N){
        cin >> H[i];
    }

    sort(H.rbegin(), H.rend());

    ll ans = 0;
    FOR(i, K, N-1){
        ans += H[i];
    }
    cout << ans << endl;
}

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

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

int main() {
  int N,M,R,a,b,c;
  cin >> N >> M >> R;
  vector<int> r(R);
  rep(i,R) {
    cin >> r[i];
    r[i]--;
    }
  vector<vector<ll>> cost(N,vector<ll>(N,200000000000));
  // vector<vector<vector<int>>> g(N);
  rep(i,M) {
    cin >> a >> b >> c;
    a--;b--;
    cost[a][b] = cost[b][a] = c;
  }

  rep(k,N)rep(i,N)rep(j,N){
    chmin(cost[i][j], cost[i][k] + cost[k][j]);
  }

  sort(r.begin(),r.end());

  ll res=LONG_LONG_MAX/100,tmp;
  while (next_permutation(r.begin(),r.end())) {
    tmp = 0;
    rep(i,r.size()-1) tmp+=cost[r[i]][r[i+1]];
    chmin(res,tmp);
  }
  cout << res << endl;
} 

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

using namespace std;

typedef long long ll;
typedef unsigned int ui;
typedef pair<int, int> pi;

#define fi first
#define se second

int read() {
  int res = 0, w = 1; char c = getchar();
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') c = getchar(), w = -1;
  while (isdigit(c)) res = (res << 1) + (res << 3) + c - '0', c = getchar();
  return res * w;
}

const int N = 110;

int n, m, a[N][N], b[N][N], c[N][N];

struct Edge {
  int u, v, nxt, id, mark;
} E[N * N];

int head[N], tot = 0, vis[N], match[N];

void addedge(int u, int v, int id) {
  E[++tot] = (Edge) {u, v, head[u], id, 0};
  head[u] = tot;
}

bool dfs(int u) {
  for (int i = head[u]; i; i = E[i].nxt) if (!E[i].mark) {
    int v = E[i].v;
    if (vis[v]) continue;
    vis[v] = 1;
    if (!match[v] || dfs(E[match[v]].u)) {
      match[v] = i;
      return 1;
    }
  }
  return 0;
}

int main() {
  n = read(), m = read();
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      a[i][j] = read();
      addedge(i, (a[i][j] - 1) / m + 1, a[i][j]);
    }
  }
  for (int i = 1; i <= m; i++) {
    memset(match, 0, sizeof(match));
    for (int j = 1; j <= n; j++) {
      memset(vis, 0, sizeof(vis));
      dfs(j);
    } 
    for (int j = 1; j <= n; j++) {
      b[E[match[j]].u][i] = E[match[j]].id;
      c[E[match[j]].v][i] = E[match[j]].id;
      E[match[j]].mark = 1;
    }
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", b[i][j]);
    }
    puts("");
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      printf("%d ", c[i][j]);
    }
    puts("");
  }
  return 0;
}


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

using namespace std;
const int MAXN=30;
const long long int MOD=1e9+7;
const long long int MAXK=2500000;

vector<int> combinazioni[MAXN];
long long int dp[MAXN][MAXK] ;
int N;

long long int solve(int index, int disponibili){
	if(disponibili==0){
		dp[index][disponibili]=1;
	}
	if(dp[index][disponibili]!=-1)
		return dp[index][disponibili];
	
	dp[index][disponibili]=0;
	for(auto elem : combinazioni[index]){
		int temp = disponibili - (1<<elem);
		int presente = disponibili / (1<<elem);
		if(presente%2==1)
			dp[index][disponibili]=(dp[index][disponibili]+solve(index+1,temp))%MOD;
	}
	return dp[index][disponibili];
}


int main(){
	cin>>N;
	int valore;
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			cin>>valore;
			if(valore)
				combinazioni[i].push_back(j);
		}
	}
	valore = 0;
	for(int i=0;i<N;i++){
		valore=(valore*2)+1;
	}
	//cout<<valore;
	for(int i=0;i<=N;i++)
		for(int j=0;j<=valore;j++)
			dp[i][j]=-1;
	cout<<solve(0,valore);
}

Measured memory_bytes: 405760
import java.util.*;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        Set<Character> letters = new HashSet<>();
        letters.add('A');
        letters.add('T');
        letters.add('C');
        letters.add('G');

        int count = 0;
        int max = 0;

        for (char c : s.toCharArray()) {
            if (letters.contains(c)) count++;
            else count = 0;
            max = Math.max(max, count);
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 21844
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a[] = new int[n];
		int ans = 0;
		Map<Integer, Integer> mp = new HashMap<>();
		for(int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			if(mp.get(a[i]) == null)mp.put(a[i], 1);
			else mp.put(a[i], mp.get(a[i])+1);
		}
		for(int i : mp.keySet()) {
			if(mp.get(i)>i) ans += mp.get(i) - i;
			else if(mp.get(i) < i) ans += mp.get(i);
		}
		System.out.println(ans);
		
		
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

int gcd(int former, int latter){
    if((former <= 0)||(latter <= 0))return 0;
    if(former%latter == 0)return latter;
    if(latter%former == 0)return former;
    return gcd(latter, former%latter);
}

int main(void){
    int K;
    cin >> K;
    vector<int> gcdsum(K, 0);
    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            gcdsum[a-1] += gcd(a,b);
        }
    }
    int res = 0;
    for(int a=1; a<=K; a++){
        for(int b=1; b<=K; b++){
            res += gcdsum[gcd(a,b)-1];
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

struct Node {
	int key;
	Node *prev, *next;
};

Node *nil;

void init() {
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void insert(int key) {
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil; 
}

Node* list_search(int key) {
	Node *cur = nil->next;
	while(cur != nil && cur->key != key) {
		cur = cur->next;
	}
	return cur;
}

void delete_node(Node *t) {
	if(t == nil) return;
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void delete_frist() {
	delete_node(nil->next);
}

void delete_last() {
	delete_node(nil->prev);
}

void delete_key(int key) {
	delete_node(list_search(key));
}

int main(void) {
	int n, key;
	char com[20];
	scanf("%d", &n);
	int np = 0;
	int size = 0;
	int nd = 0;
	init();
	
	for(int i = 0; i < n; i++) {
		scanf("%s%d", com, &key);
		if(com[0] == 'i') {
			insert(key);
			np++;
			size++;
		}
		else if(com[0] == 'd') {
			if(strlen(com) > 6) {
				if(com[6] == 'F') {
					delete_frist();
				} else if(com[6] == 'L') {
					delete_last();
				}
			}
			else {
				delete_key(key);
				nd++;
			}
			size--;
		}
	}
	

	Node *cur = nil->next;
	int isf = 0;
	while(1) {
		if(cur == nil) {
			break;
		}
		if(isf++ > 0) {
			printf(" ");
		}
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 33856
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define reppe(i,a,b) for(int i = (int)(a) ; i <= (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)
#define repme(i,a,b) for(int i = (int)(a) ; i >= (int)(b) ; --i)

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}
class Radix {
private:
  const char* s;
  int a[128];
public:
  Radix(const char* s = "0123456789ABCDEF") : s(s) {
    int i;
    for(i = 0; s[i]; ++i)
      a[(int)s[i]] = i;
  }
  std::string to(long long p, int q) {
    int i;
    if(!p)
      return "0";
    char t[64] = { };
    for(i = 62; p; --i) {
      t[i] = s[p % q];
      p /= q;
    }
    return std::string(t + i + 1);
  }
  std::string to(const std::string& t, int p, int q) {
    return to(to(t, p), q);
  }
  long long to(const std::string& t, int p) {
    int i;
    long long sm = a[(int)t[0]];
    for(i = 1; i < (int)t.length(); ++i)
      sm = sm * p + a[(int)t[i]];
    return sm;
  }
};

int main() {
    ll N, K; cin >> N >> K;
    Radix r;
    cout << r.to(N, (int)K).size() << endl;
}


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

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

  sort(s.begin(), s.end());

  for(int i = 1; i < s.size(); i++){
    if(s[i] == s[i-1]){
      cout << "no" << endl;
      return 0;
    }
  }

  cout << "yes" << endl;

  return 0;

}


Measured memory_bytes: 256
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define UNIQUE(a) unique(a.begin(), a.end())
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <cctype>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;

int main() {
	int a, b;
	cin >> a >> b;
	if (a <= 5) {
		cout << "0" << endl;
	}
	else if (6 <= a && a <= 12) {
		cout << b / 2 << endl;
	}
	else {
		cout << b << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
        using namespace std;
   #define int long long
    const int MAX =200002;
const int MOD =1000000007;

     signed main(){
int ans=MOD;string s,x;
cin>>s;
for(char i0='a';i0<='z';i0++){
    x=s;
    int n=x.size();
    for(int i=1;i<=s.size();i++){
        bool k=true;
        if(x[0]!=i0)k=false;
        for(int j=0;j<s.size()-i;j++){
            if(x[j+1]==i0)x[j]=i0;
            else k=false;
        }
        if(k){ans=min(ans,i-1);break;}
    }
}
cout<<ans<<endl;


     }


 


 






    





      

        


Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int N;
    long T;
    cin >> N >> T;
    vector<long> t(N);
    rep(i,N){
        cin >> t.at(i);
    }
    long ans=0;
    rep(i,N-1){
        if(t.at(i+1)-t.at(i)>=T){
            ans+=T;
        }else{
            ans+=t.at(i+1)-t.at(i);
        }
    }
    ans +=T;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#128_D
import heapq
n, k = map(int, input().split())
v = list(map(int, input().split()))

ans = 0
for x in range(1, min(n, k)+1):
    for l in range(0, x+1):
        r = x - l
        v_ = v[:l] + v[n-r:]
        heapq.heapify(v_)
        for _ in range(k-x):
            if len(v_) == 0:
                break
            if v_[0] < 0:
                heapq.heappop(v_)
            else:
                break
        ans = max(ans, sum(v_))
        
print(ans)

Measured memory_bytes: 3064