akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main()
{
    char s[4];
    char t[4];
    scanf("%s",&s);
    scanf("%s",&t);
    int i,j,count=0;
    for(i=0,j=0; i<strlen(s); i++,j++)
    {
        if(s[i]==t[j])
            count++;
    }
    printf("%d",count);
    return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;


void Main(){

  int a,b; cin>>a>>b;
  int ans=0;
  reps(i,a,b+1){
    string x=to_string(i);
    if(x[0]==x[4] and x[1]==x[3]) ++ans;
  }

  cout<< ans<<"\n";

}

//-----------------------------------
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}
//-----------------------------------


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
int is_odd(int x) {
  int cnt = 0;
  while (x) {
    cnt++;
    x /= 10;
  }
  return cnt % 2;
}
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += is_odd(i);
  }  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import sys
from itertools import product

read = sys.stdin.read
readline = sys.stdin.readline

N, M, X, *CA = map(int, read().split())
CA = tuple(zip(*[iter(CA)] * (M + 1)))
answer = 10 ** 10
for i in product((0, 1), repeat=N):
    m = 0
    s = [0] * M
    for j in range(N):
        if i[j] == 1:
            m += CA[j][0]
            for k in range(M):
                s[k] += CA[j][k + 1]
    if all(j >= X for j in s):
        if answer > m:
            answer = m

if answer == 10 ** 10:
    print(-1)
else:
    print(answer)


Measured memory_bytes: 9200
#include<stdio.h>
#define MAX 10000

int main(void){
  int S[MAX],T[MAX],n,q,count=0,i,j;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&S[i]);
  }

  scanf("%d",&q);

  for(i=0;i<q;i++){
    scanf("%d",&T[i]);
  }

  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(S[j] == T[i]){
	count++;
	break;
      }
    }
  }
  printf("%d\n",count);
  return 0;  
}

Measured memory_bytes: 648
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n, a[4][13] = {},m;
    char c;
    cin >> n;
    for (int i = 0; i < n;i++) {
        cin >> c >> m;
        if (c == 'S') a[0][m - 1] = 1;
        else if (c == 'H') a[1][m - 1] = 1;
        else if (c == 'C') a[2][m - 1] = 1;
        else a[3][m - 1] = 1;
    }
    for (int j = 0; j < 13; j++) {
        if (a[0][j] == 0) cout << "S" << " " << j + 1 << endl;
    }
    for (int j = 0; j < 13; j++) {
        if (a[1][j] == 0) cout << "H" << " " << j + 1 << endl;
    }
    for (int j = 0; j < 13; j++) {
        if (a[2][j] == 0) cout << "C" << " " << j + 1 << endl;
    }
    for (int j = 0; j < 13; j++) {
        if (a[3][j] == 0) cout << "D" << " " << j + 1 << endl;
    }
    return 0;
}




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

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, a, b) for (int i = (int)(a); i >= (int)b; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define rep(i, l, r) for (int i = (l); i <= (r); i++)
#define per(i, r, l) for (int i = (r); i >= (l); i--)
#define ms(x, y) memset(x, y, sizeof(x))
#define SZ(x) ((int)(x).size())

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const i64 maxn = 2*(i64)1e5+100;
i64 n, k, a[maxn], vis[maxn], pos[maxn];

void init() {
    ms(vis, 0);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
#ifdef LOCAL_DEFINE
    freopen("input.txt", "r", stdin);
#endif

    init();
    cin >> n >> k;
    for1(i, n) cin >> a[i];
    vis[1] = 1;
    bool flag = false;
    i64 cycle;
    int first = 1;
    i64 num;
    i64 now = 1;
    vi res;
    res.eb(1);
    pos[1] = 1;
    i64 pre;
    while (true) {
        int to = a[now];
        if (vis[to]) {
            if (to == now) {
                flag = true;
                num = to;
            } else {
                cycle = first + 1 - pos[to];
            }
            break;
        }
        ++first;
        pos[to] = first;
        res.eb(to);
        now = to;
        vis[to] = 1;
    }
    //cerr << "chk : " << pos[2] << endl;
//    cerr << cycle << '\n';
//    for (int x : res) cout << x << ' ';
//    cout << '\n';
    if (flag) {
        if (k < first) cout << res[k] << '\n';
        else cout << num << '\n';
    } else {
        pre = first - cycle;
        if (k < first) cout << res[k] << '\n';
        else {
         //   cerr << first << ' ' << cycle << ' ' << pre << endl;
            k -= first;
            k %= cycle;
            cout << res[pre+k] << '\n';
        }
    }

#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 8972
#include <iostream> 
#include <algorithm> 
#include <vector> 

const int inf=0x3f3f3f3f;
using namespace std; 
int main()
{
  ios::sync_with_stdio(false); 
  cin.tie(0); cout.tie(0); 
  int n,k; 
  cin>>n>>k;
  vector <int> a(n);  
  for (int i=0; i<n; i++) cin>>a[i]; 
  vector <int> dp(n, inf); dp[0]=0; 
  for (int i=0; i<n; i++){
    for (int j=1; j<=k && (i+j)<n; j++){
      dp[i+j]=min(dp[i+j],dp[i]+abs(a[i+j]-a[i]));   
    }
  }
  cout<<dp[n-1]<<"\n"; 
  return 0; 
}

Measured memory_bytes: 1024
D,G = map(int,input().split())
b = []
c = []
for i in range(D):
    x,y = map(int,input().split())
    b.append(x)
    c.append(y)
res = 10**18
for i in range(1<<D):
    s = format(i,"0"+str(D)+"b")
    score = 0
    num = 0 
    for j in range(D):
        if s[j]=='1':
            num+=b[j]
            score += b[j]*(j+1)*100 + c[j]
    if score >= G:
        res = min(num,res)
    else:
        for j in range(D)[::-1]:
            if s[j] == '0':
                if score + (b[j]-1)*100*(j+1)>=G:
                    if (G-score)%(100*(j+1))==0:
                        num+= (G-score)//(100*(j+1))
                        score = G
                    else:
                        num+= (G-score)//(100*(j+1)) + 1
                        score = G
                    break
                else:
                    num+= b[j]-1
                    score += (b[j]-1)*100*(j+1)
        if score>=G:
            res = min(num,res)
print(res)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<list>
#include<cmath>
#include<map>
using namespace std;
using ll = long long;
const int INF = 1e9;
int main() {
	string S, T;
	cin >> S >> T;
	bool ok = true;
	map<char, char>ma, ima;
	for (int i = 0; i < S.size(); ++i) {
		char s = S[i], t = T[i];
		if (ma.count(s))if (ma[s] != t)ok = false;
		if (ima.count(t))if (ima[t] != s)ok = false;
		ma[s] = t; ima[t] = s;
	}
	if (ok)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
#define ll  long long
#define ld long double
#define ms(a,v) memset(a,v,sizeof a)
#define pii pair<int, int>
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor
 *
 * */

int main(){
	ll l, r, ans = 2020; cin>>l>>r;
	if (r-l >= 2019){cout<<0; return 0;}
	for (ll i=l; i<=r; ++i) for(ll j=i+1ll; j<=r; ++j) 
		ans = min(ans, ((i%2019ll)*(j%2019ll))%2019ll);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
using namespace std;
/*
         ########     ########   ########   #########   ##       #######   ##       #######
         #      #     #      #   #      #       #       # #      #     #   # #      #     #
         #      #     #      #   #      #       #       #  #     #     #   #  #     #     #
         ########     #      #   #      #       #       #   #    #     #   #   #    #     #
         ###          #      #   #      #       #       #    #   #######   #    #   #######
         #  #         #      #   #      #       #       #   #    #     #   #   #    #     #
         #   #        #      #   #      #       #       #  #     #     #   #  #     #     #
         #    #       #      #   #      #       #       # #      #     #   # #      #     #
         #     #      ########   ########       #       ##       #     #   ##       #     #     
*/

#define rep(i, a, b) for (__typeof((b)) i = (a); i < (b); i++)
#define nrep(i, a, b) for (__typeof((b)) i = (a); i > (b); i--)
#define all(a) (a).begin(), (a).end()
#define ff first
#define ss second
#define ppi pair<int, int>
#define pppi pair<ppi, int>
#define vi vector<int>
#define vii vector<ppi>
#define viii vector<pppi>
#define vs vector<string>
#define pb push_back
#define bitcount __builtin_popcount //count no's of ones in a set bit
#define prq priority_queue
#define mp make_pair
#define mem(x, val) memset((x), (val), sizeof(x));
#define sz(x) (int)x.size()
#define M_PI 3.14159265358979323846
#define rootdada                      \
    ios_base::sync_with_stdio(false); \
    cin.tie(0);                       \
    cout.tie(0);
#define test  \
    int t;    \
    cin >> t; \
    while (t--)
#define debug(a)          \
    cerr << #a << ": ";   \
    for (auto i : a)      \
        cerr << i << " "; \
    cerr << '\n';
#define trace(a) cerr << #a << ": " << a << "\n"
#define print(ar, n)            \
    for (int u = 0; u < n; u++) \
    {                           \
        cout << ar[u] << " ";   \
    }                           \
    cout << endl;
#define int long long
#define M 1000000007
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
signed main()
{
    rootdada;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //   freopen("output.txt", "w", stdout);
    //  freopen("error.txt", "w", stderr);
#endif
    int n;
    cin >> n;
    vi a(n);
    rep(i, 0, n)
            cin >>
        a[i];
    sort(all(a));
    unordered_map<int, int> m;
    rep(i, 1, n)
    {
        if (a[i] == a[i - 1])
            m[a[i]] = 1;
    }
    int ans = 0;
    rep(i, 0, n)
    {
        int x = a[i];
        if (m[x] != 1)
            ans++;
        if (a[i] != a[i - 1])
        {
            for (int j = 2 * a[i]; j <= 1000000; j += a[i])
            {
                if (!m[j])
                    m[j] = 1;
            }
        }
    }

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

Measured memory_bytes: 44196
#include<cstdio>
#include<algorithm> 
#include<cstring>
#define LL long long
using namespace std;
bool f=false;
int read()
{
	int x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0'&&c<='9'){x=x*10+c-'0';c=getchar();}
	return x*f;
}
char s[10]; 
int main()
{
	scanf("%s",s+1);
	int n=strlen(s+1);
	for(int i=1;i<n;i++)
		if(s[i]=='A'&&s[i+1]=='C')f=true;
	if(f)printf("Yes");
	else printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <string>
#include <typeinfo>
#include <climits>
#include <algorithm>
#include <cctype>
#include <cstring>
#include <stdio.h>
#include <cstdlib>
using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if(a==1){
        a+=13;
    }
    if(b==1){
        b+=13;
    }
    if(a>b){
        cout << "Alice";
    }else if(a<b){
        cout << "Bob";
    }else{
        cout << "Draw";
    }
}


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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

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

const ll MAX = 100000;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
  set<ll> st;
  vector<ll> dp(MAX+1,INF);
  dp[0] = 0;
  for(ll i=1;i<MAX+1;i*=6) st.insert(i);
  for(ll i=1;i<MAX+1;i*=9) st.insert(i);
  for(auto x : st){
    rep(i,MAX+1){
      if(i+x < MAX+1) chmin(dp[i+x],dp[i]+1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

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

int main() {
  int N;
  cin>>N;
  int ans=N;
  vector<int>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<N-1;i++){
    if(a[i]==a[i+1]){
      a[i+1]=0;
      ans-=2;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 640
M = 17
m = Array.new(M).map{Array.new(M,0)}
memo = Array.new(M).map{Array.new(M,0)}
while true do
  x, y = gets.chomp.split().map(&:to_i)
  if x==0 && y==0 then
    break
  end
  for i in 0..y+1 do
    for j in 0..x+1 do
      m[i][j] = 1
      memo[i][j] = 0
    end
  end
  for i in 1..y do
    m[i] = [1] + gets.chomp.split().map(&:to_i) + [1]
  end
  for i in 1..x do
    if m[1][i]==0 then
      memo[1][i] = 1
    end
  end
  ans = 0
  for i in 2..y do
    for j in 1..x do
      if m[i][j]!=1 then
        if m[i][j]==0 then
          if m[i-1][j-1]!=2 then
            memo[i][j] += memo[i-1][j-1]
          end
          if m[i-1][j+1]!=2 then
            memo[i][j] += memo[i-1][j+1]
          end
        end
        if m[i-1][j]!=2 then
          memo[i][j] += memo[i-1][j]
        end
        if m[i-2][j]==2 then
          memo[i][j] += memo[i-2][j]
        end
      end
    end
  end
  for i in 1..x do
    ans += memo[y][i]
    if m[y-1][i]==2 then
      ans += memo[y-1][i]
    end
  end
  puts ans
end

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

#include <set>
#include <iterator>
using namespace std;
// using namespace __gnu_pbds;


#define f first
#define s second
#define pb push_back
#define all(x) x.begin(),x.end()

#define ll long long int
#define vi vector<int>
#define vii vector<pair<int,int> >
#define pii pair<int,int>
#define plii pair<pair<ll, int>, int>
#define piii pair<pii, int>
#define viii vector<pair<pii, int> >
#define vl vector<ll>
#define vll vector<pair<ll,ll> >
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define mp make_pair
#define ms(x, v) memset(x, v, sizeof x)
#define pr_vec(v) for(int i=0;i<v.size();i++) cout << v[i] << " " ;

#define f_in(st) freopen(st,"r",stdin)
#define f_out(st) freopen(st,"w",stdout)

#define INF (ll)1e17
#define matrix vector<vector<ll> >

#define fr(i, a, b) for(i=a; i<=b; i++)
#define fb(i, a, b) for(i=a; i>=b; i--)
#define ASST(x, l, r) assert( x <= r && x >= l )
#define maxbits 9
#define maxmask (1ll<<maxbits)
// typedef tree<pll, null_type, less<pll>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
const int  N=1e6 +10, M=(ll)1e9+1 ;
const int mod =(ll)1e9+7 ,sz=5, MAX=(ll)1e6+10;
string fir="Monocarp",sec="Bicarp";

ll fact[N],invfact[N];

ll po(ll a,ll x){
	if(x==0)
		return 1;
	if(x==1)
		return a;
	ll z=po(a,x/2);
	z=(z*z)%mod;
	if(x&1)
		z=(z*a)%mod;
	return z;
}

void initial(){
	fact[0]=1;
	for(ll i=1;i<N;i++){
		fact[i]=(fact[i-1]*i)%mod;
		invfact[i]=po(fact[i],mod-2);
	}
}


ll ncr(ll n,ll r){
	if(r==0 || n==r)
		return 1;
	return (((fact[n]*invfact[r])%mod) *invfact[n-r])%mod;	
}

void work(){
	ll h,w,a,b;
	cin >> h >> w >> a >> b;

	initial();

	ll ans=0;

	for(ll i=b+1;i<=w;i++){
		ll x1=h-a-1,y1=i-1;
		ll x2=a-1,y2=w-i;
		ll cur=(ncr(x1+y1,x1)*ncr(x2+y2,x2))%mod;
		// cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << cur << " " << ncr(x1+y1,x1) << "\n";
		// cout << cur << " ";
		cur%=mod;
		ans=(ans+cur)%mod;
	}

	cout << ans ;


}

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

	
	// precomp();
	ll t;
	// cin >> t;
	t=1;
	while(t--){
	        work();
	
	}
return 0;
}
	

Measured memory_bytes: 15872
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

template <typename T>
struct Graph_ {
  int n;
  vector<vector<T> > d;
  vector<vector<int> > path;
  Graph_(){

  }
  void set(int ns){
    n = ns;
    d = vector<vector<T> >(n, vector<T>(n, numeric_limits<T>::max() / 10));
    path = vector<vector<int> >(n, vector<int>(n, -1));
    for(int i = 0; i < n; i++)d[i][i] = 0;
  }
  Graph_(int ns) {
    n = ns;
    d = vector<vector<T> >(n, vector<T>(n, numeric_limits<T>::max() / 10));
    path = vector<vector<int> >(n, vector<int>(n, -1));
    for(int i = 0; i < n; i++)d[i][i] = 0;
  }
  void warshall_floyd(){
    for(int k = 0; k < n; k++){
      for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
          if(d[i][j] > d[i][k] + d[k][j]){
            d[i][j] = d[i][k] + d[k][j];
            path[i][j] = k;
          }
        }
      }
    }
  }
  void adde(int at, int to, T cost){
    d[at][to] = cost;
  }
};

typedef struct Graph_<int> GraphI;
typedef struct Graph_<ll> GraphL;

map<P, bool> mp;
GraphI graph;

void check(int i, int j){
  if(i == j)return;
  int md = graph.path[i][j];
  if(md == -1){
    mp[mk(i, j)] = true;
    mp[mk(j , i)] = true;
    return;
  }
  check(i, md);
  check(md, j);
}

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  graph.set(n);
  for(int i = 0; i < m; i++){
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    graph.adde(a, b, c);
    graph.adde(b, a, c);
    mp[mk(a, b)] = false;
    mp[mk(b, a)] = false;
  }
  graph.warshall_floyd();
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      check(i, j);
    }
  }
  int res = 0;
  for(auto itr = mp.begin(); itr != mp.end(); ++itr){
    if(!itr->second)res++;
  }
  cout << res / 2 << endl;
	return 0;
}


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

int main (){
  char c;
  cin >> c;
  
  if (c == 'a' || c =='i' || c =='u' || c =='e' || c =='o'){
    cout << "vowel";
  }
      
  else 
    cout << "consonant";
  
}

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

int main() {
  int64_t N;
  cin >> N;
  N = N - 1;
  bool finish = true;
  int i = 0;
  vector<char> vec(30);
  while(finish){
    int moji = N % 26;
    vec.at(i) = char(moji + 97);
    N = N /26 - 1;
    i++;
    if(N==-1) finish = false;
  }
  for(int j = 1; j < i+1; j++){
    cout << vec.at(i-j);
  }
}




Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
vector<int> adj[100005];
vector<int> dp(100005,-1);
int longest_path(int node)  {
    if(dp[node]!=-1)    return dp[node];
    int ans=0;
    for(auto i:adj[node])   {
        ans=max(ans,1+longest_path(i));
    }
    return dp[node]=ans;
}
int main()  {
    ios_base::sync_with_stdio(false);   cin.tie(0);     cout.tie(0);
    int n,m;    cin>>n>>m;
    int a,b;
    for(int i=0;i<m;i++)   {
        cin>>a>>b;
        adj[a].push_back(b);
    }
    int ans=0;
    for(int i=1;i<n+1;i++)   ans=max(ans,longest_path(i));
    cout<<ans;
}

Measured memory_bytes: 8192
n=int(input())
s=input()
count = 0
for i in range(n-1):
  a=s[:i + 1]
  b=s[i+1:]
  temp = 0
  for j in range(27):
    if chr(96+j) in a and chr(96+j) in b:
      temp += 1
  count = max(temp, count)
print(count)

Measured memory_bytes: 9092
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>

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

const int MOD = 1e9 + 7;
const int MAX = 1e9;
const ll LLMAX = 1e18;
const int INF = numeric_limits<int>::max();
const ll LLINF = numeric_limits<ll>::max();
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int R, G; cin >> R >> G;

    cout << 2 * G - R << endl;
    return 0;
}


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

// https://atcoder.jp/contests/abc125/tasks/abc125_c
void Solve01()
{
    int n;
    cin >> n;
    vector<int> gcd_left(n + 1), gcd_right(n + 1);
    vector<int> v(n + 1);

    for (int i = 1; i < n + 1; i++)
    {
        cin >> v[i];
    }
    gcd_left[1] = v[1];
    gcd_right[n] = v[n];
    for (int i = 2; i < n + 1; i++)
    {
        gcd_left[i] = __gcd(gcd_left[i - 1], v[i]);
    }
    for (int i = n - 1; i >= 1; i--)
    {
        gcd_right[i] = __gcd(gcd_right[i + 1], v[i]);
    }
    int m = max(gcd_left[n - 1], gcd_right[2]);
    for (int i = 2; i < n; i++)
    {
        m = max(m, __gcd(gcd_left[i - 1], gcd_right[i + 1]));
    }

    cout << m << endl;
}

int main()
{
    Solve01();
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e6;
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
int main() {
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  REP(i, m) cin >> c[i];
  sort(c.begin(), c.end());
  vector<vector<int>> dp(m + 1, vector<int>(n + 1, INF));
  REP(i, n + 1) dp[0][i] = i;
  for (int i = 1; i < m; i++) {
    REP(j, n + 1) {
      if (c[i] > j) {
        dp[i][j] = dp[i - 1][j];
      } else {
        chmin(dp[i][j], dp[i][j - c[i]] + 1);
        chmin(dp[i][j], dp[i - 1][j]);
      }
    }
  }
  cout << dp[m - 1][n] << endl;
}


Measured memory_bytes: 7140
#include <bits/stdc++.h>
using namespace std;
int n, md, ans[200005];
struct node
{
	int x, id;
}a[200005];
bool cmp(node u, node v) {return u.x < v.x;}
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i].x);
		a[i].id = i;
	}
	md = n / 2;
	sort(a + 1, a + n + 1, cmp);
	for (int i = 1, j = n; i < j; i++, j--) ans[a[i].id] = a[md + 1].x, ans[a[j].id] = a[md].x;
	for (int i = 1; i <= n; i++) printf("%d\n", ans[i]);
}

Measured memory_bytes: 4480
n,k=map(int, input().split())
a = list(map(int, input().split()))
mod=10**9+7
if n==k:
    ans=1
    for i in range(k):
        ans*=a[i]
        ans%=mod
    print(ans)
    exit()
minus=[i for i in a if i<0]
plus=[i for i in a if i>=0]
from collections import deque
minus=deque(sorted(minus))
plus=deque(sorted(plus,reverse=True))

n_minus=len(minus)
n_plus=len(plus)

if n_minus==n:
    ans=1
    if k%2==0:
        for i in range(k):
            ans*=minus.popleft()
            ans+=mod
            ans%=mod
        print(ans)
        exit()
    else:
        for i in range(k):
            ans*=minus.pop()
            ans+=mod
            ans%=mod
        print(ans)
        exit()

cnt_minus=0
cand=deque([])
for i in range(k):
    if not plus or ((plus and minus) and abs(minus[0])>abs(plus[0])):
        cand.append(minus.popleft())
        cnt_minus+=1
    elif not minus or ((plus and minus) and abs(minus[0])<abs(plus[0])):
        cand.append(plus.popleft())
    else:
        if cnt_minus%2==1:
            cand.append(minus.popleft())
            cnt_minus+=1
        else:
            cand.append(plus.popleft())

if cnt_minus%2==0:
    ans=1
    for i in range(k):
        ans*=cand[i]
        ans+=mod
        ans%=mod
    print(ans)
    exit()

if 0 in cand:
    print(0)
    exit()

tmpm,tmpp=None,None

for i in range(k-1,-1,-1):
    if cand[i]<0 and tmpm==None:
        tmpm=cand[i]
    elif cand[i]>=0 and tmpp==None:
        tmpp=cand[i]

#print(tmpm,tmpp)
cand1,cand2=None,None
if tmpm!=None and plus:
    cand1=plus[0]/abs(tmpm)
if tmpp!=None and minus:
    if tmpp!=0:
        cand2=abs(minus[0])/abs(tmpp)
    else:
        cand2=0

if tmpp==0:
    if minus:
        ans=1
        flg=True
        for i in range(k):
            if flg and cand[i]==tmpp:
                flg=False
                continue
            ans*=cand[i]
            ans+=mod
            ans%=mod
        print((ans*minus[0])%mod)
        exit()
elif (cand1!=None and cand2==None) or ((cand1!=None and cand2!=None) and plus[0]*abs(tmpp)>=abs(minus[0]*tmpm)):
    ans=1
    flg=True
    for i in range(k):
        if flg and cand[i]==tmpm:
            flg=False
            continue
        ans*=cand[i]
        ans+=mod
        ans%=mod
    print((ans*plus[0])%mod)
    exit()

elif (cand1==None and cand2!=None) or ((cand1!=None and cand2!=None) and plus[0]*abs(tmpp)<abs(minus[0]*tmpm)):
    ans=1
    flg=True
    for i in range(k):
        if flg and cand[i]==tmpp:
            flg=False
            continue
        ans*=cand[i]
        ans+=mod
        ans%=mod
    print((ans*minus[0])%mod)
    exit()

Measured memory_bytes: 114624
using System;

public class hello
{
    public static void Main()
    {
        while (true)
        {
            var n = int.Parse(Console.ReadLine().Trim());
            if (n == 0) break;
            var res = 0;
            for (int i = 0; i < n / 4; i++)
                res += int.Parse(Console.ReadLine().Trim());
            Console.WriteLine(res);
        }
    }
}


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

#define read(num1, num2, num3) scanf("%d %d %d", &num1, &num2, &num3)
typedef long long int lli;

int main()
{
    int a, b, c;
    while(read(a,b,c)!=EOF)
    {
        if(a+b+c == 17) cout << "YES\n";
        else cout << "NO\n";
    }

    return 0;
}

Measured memory_bytes: 256
def two_ten(n):
    ans = ''
    while n:
        if n%2 == 0:
            ans += '0'
        else:
            ans += '1'
        n = n/2
    else:
        lis = list(ans)
        lis.reverse()
        return ''.join(lis).zfill(5)
    
def kawaii(lis):
    ans = []
    s = ''
    for v in lis:
        for c in v:
            s += c
            if s in dic:
                ans.append(dic[s])
                s = ''
    else:
        print ''.join(ans)

dic = {'101':' ', '000000':"'", '000011':',', '10010001':'-', '010001':'.', 
       '000001':'?', '100101':'A', '10011010':'B', '0101':'C', '0001':'D', 
       '110':'E', '01001':'F', '10011011':'G', '010000':'H', '0111':'I', 
       '10011000':'J', '0110':'K', '00100':'L', '10011001':'M', '10011110':'N', 
       '00101':'O', '111':'P', '10011111':'Q', '1000':'R', '00110':'S', '00111':'T', 
       '10011100':'U', '10011101':'V', '000010':'W', '10010010':'X', '10010011':'Y', '10010000':'Z'}

mathematics = {'A':0, 'B':1, 'C':2, 'D':3, 'E':4, 'F':5, 'G':6, 'H':7, 
               'I':8, 'J':9, 'K':10, 'L':11, 'M':12, 'N':13, 'O':14, 'P':15, 
               'Q':16, 'R':17, 'S':18, 'T':19, 'U':20, 'V':21, 'W':22, 'X':23,
               'Y':24, 'Z':25, ' ':26, '.':27, ',':28, '-':29, "'":30, '?':31}

while True:
    try:
        lis = []
        for c in raw_input():
            lis.append(two_ten(mathematics[c]))
        else:
            kawaii(lis)
    except EOFError:
        break

Measured memory_bytes: 4352
#include<iostream>
#include<cstring>
using namespace std;
main()
{
  char str[64];
  bool f=false;
  char check[20][20];
  
  strcpy(check[0],"AKIHABARA");

  strcpy(check[1],"AKIHABAR");

  strcpy(check[2],"AKIHABRA");
  
  strcpy(check[3],"AKIHABR");
  
  strcpy(check[4],"AKIHBARA");

  strcpy(check[5],"AKIHBAR");

  strcpy(check[6],"AKIHBRA");
  
  strcpy(check[7],"AKIHBR");
    
  strcpy(check[8],"KIHABARA");

  strcpy(check[9],"KIHABAR");

  strcpy(check[10],"KIHABRA");
  
  strcpy(check[11],"KIHABR");

  strcpy(check[12],"KIHBARA");

  strcpy(check[13],"KIHBAR");

  strcpy(check[14],"KIHBRA");
  
  strcpy(check[15],"KIHBR");

  cin >> str;

  if(strlen(str)<=9){
    for(int i=0;i<16;i++){
      if(strcmp(str,check[i])==0)
        f=true;
    }
  }

  if(f)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
square = []
while True:
    data = [int(e) for e in input().split()]
    if data[0]==0 and data[1]==0:
        break
    square.append(data)

for i in range(len(square)):
    for j in range(square[i][0]):
        for k in range(square[i][1]):
            if (j+k)%2==0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


Measured memory_bytes: 7008
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define LIMIT 500


int compare_int(const void *a,const void *b){
  if(*(int*)a > *(int*)b) return 1;
  return -1;
}

int N, K;
int A[LIMIT];
int amari[LIMIT];

int ok(int d){
  for (int i = 0; i < LIMIT; i++) {
    amari[i] = 1e9+1;
  }
  for (int i = 0; i < N; i++) {
    amari[i] = A[i]%d;
  }

  qsort(amari, LIMIT, sizeof(int), compare_int);

  int sum[N+1];
  sum[0] = 0;
  for (int i = 1; i <= N; i++) {
    sum[i] = sum[i-1]+amari[i-1];
  }

  for (int i = 0; i <= N; i++) {
    if(sum[i] == ((N-i)*d-sum[N]+sum[i]) && sum[i] <= K) return 1;
  }

  return 0;
}


int main(void){
  scanf("%d%d", &N, &K);

  int sum = 0;
  for (int i = 0; i < N; i++) {
    scanf("%d", &A[i]);
    sum += A[i];
  }

  int ans = 1;
  for (int i = 1; i < sqrt(sum); i++) {
    if(sum%i) continue;
    if(ok(sum/i)){
      ans = sum/i;
      break;
    }
    if(ok(i)) ans = i;
  }

  printf("%d\n", ans);


  return 0;
}

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

//Common
using namespace std;using f64 = double;using i64=long long;using u64=unsigned long long;
template<typename T> using Arr=vector<T>;template<typename T> using Func=function<T>;template<typename T> using Str=basic_string<T>;
#define hfor(v, s, e) for(int v=(s);(s)<=v&&v<(e);++v)//half-opened range
#define hfori(v, s, e) for(int v=(e)-1;(s)<=v&&v<(e);--v)//inversion
#define hforo(v, s, e) int v=(s);for(;(s)<=v&&v<(e);++v)//out declaration
#define hforoi(v, s, e) int v=(e)-1; for(;(s)<=v&&v<(e);--v)
#define cfor(v, s, e) hfor(v,(s),(e)+1)//closed range
#define cfori(v, s, e) hfori(v,(s),(e)+1)
#define cforo(v, s, e) hforo(v,(s),(e)+1)
#define cforoi(v, s, e) hforoi(v,(s),(e)+1)
#define rep(v,x) hfor(v,0,(x))
#define repi(v,x) hfori(v,0,(x))
#define repo(v,x) hforo(v,0,(x))
#define all(x) (x).begin(),(x).end()
#define pushb push_back
#define pushf push_front
#define popb pop_back
#define popf pop_front
#define empl emplace
#define emplb emplace_back
#define emplf emplace_front
#define fi first
#define se second
#define cxp constexpr
#define PQ std::priority_queue

//Math
template<typename T> cxp T inf() { return numeric_limits<T>::max() / 2; }
template<typename T> inline T sq(T x){return x*x;}
cxp int lgc(int x){return 64-__builtin_clzll(x-1);}
cxp int lgf(int x){return 63-__builtin_clzll(x);}
int rd(int lb, int ub){static mt19937 rng(time(0)^i64(new int)); return uniform_int_distribution<int>(lb, ub-1)(rng);}
int rd(int ub=inf<int>()){return rd(0,ub);}
const f64 pi=acosl(-1), eps=1e-10;

//IO
template<typename T>ostream& operator<<(ostream& s, const Arr<T>& a) {for(auto i:a) cout<<i<<' '; return s;}
int getint(){int x;cin>>x;return x;}
char getchr(){char x;cin>>x;return x;}
#ifndef DEBUG
	//#pragma GCC optimize ("Ofast") //somtimes it become more slower
	auto __PRE_RUN__=(ios::sync_with_stdio(0), cin.tie(0), cout.tie(0),(cout<<fixed<<setprecision(11)), 0);
#endif

//Misc
int sz(const auto& x){return x.size();}
auto split(auto s, auto p){
	Arr<decltype(s)> ret;
	auto it1=s.begin();
	for(auto it2=it1; (it2 = find(it1,s.end(),p)) != s.end(); it1=it2+1)
		ret.pushb({it1, it2});
	ret.pushb({it1,s.end()});
	return ret;
}
template<typename T> T rev(const T& a){return {a.rbegin(),a.rend()};}
Arr<int> range(int n){ Arr<int> ret(n); rep(i,n)ret[i]=i; return ret; }
struct defer{ defer(auto f):f(f){} ~defer(){f();} function<void()> f; };
#define defer(x) auto _##__COUNTER__ = defer([&](){x;});
#define lam(expr, ...) [&](__VA_ARGS__){return expr;}
#define reduce accumulate

#define endl '\n'//not interactive?
#define int i64//MLE?
using pint = pair<int,int>;
using tint = tuple<int,int,int>;

int len(int n){
	if(!n) return 1;
	return len(n-1)*2+3;
}
int p(int n){
	if(!n) return 1;
	return p(n-1)*2+1;
}

int f(int n, int k){
	if(k<=0) return 0;
	if(!n) return 1;
	if(len(n-1)+1>=k)
		return f(n-1,k-1);
	return p(n-1)+f(n-1,k-1-len(n-1)-1)+1;
}

signed main(){
	int n,k; cin>>n>>k;
	cout<<f(n,k)<<endl;
	return 0;
}



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

int main()
{
    char a[3];
    cin>>a;
    if(a[0]=='7' || a[1]=='7' || a[2]=='7')
    {
        cout<<"Yes\n";
    }
    else
    {
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var a, b, c, x int
	fmt.Scan(&a)
	fmt.Scan(&b)
	fmt.Scan(&c)
	fmt.Scan(&x)

	var result int
	for i := 0; i <= a; i++ {
		for j := 0; j <= b; j++ {
			for m := 0; m <= c; m++ {
				if i*500+j*100+m*50 == x {
					result++
				}
			}
		}
	}
	fmt.Println(result)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N;
    cin >> N;
    vector<double> x(N);
    vector<string> u(N);
    double total=0;
    for(size_t i=0;i<N; i++)
    {
        cin >> x[i] >> u[i];
        if(u[i]=="JPY") total+=x[i];
        else total+=x[i]*380000.0;
    }
    cout << fixed << setprecision(10) << total << endl;

 #ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int k_max = 1000010;
		int prime[] = new int[k_max];

		Arrays.fill(prime, 1);
		prime[0] = 0;
		prime[1] = 0;
		for (int i = 2; i < k_max; i++) {
			for (int j = i * 2; j < k_max; j += i) {
				prime[j] = 0;
			}
		}

		while (true) {
			int n = sc.nextInt();
			int cost = sc.nextInt();
			if ((n | cost) == 0) {
				break;
			}
			int price[] = new int[n];
			int array[] = new int[cost + 1];
			for (int i = 0; i < n; i++) {
				price[i] = sc.nextInt();
				if (price[i] < cost + 1) {
					array[price[i]] = 1;
				}
			}

			int id = 0;
			while (true) {
				while (id < cost + 1 && array[id] == 0) {
					id++;
				}
				if (cost + 1 <= id) {
					break;
				}
				for (int i = 0; i < n; i++) {
					if (id + price[i] < cost + 1) {
						array[id + price[i]] = 1;
					}
				}
				id++;
			}
			boolean flag = false;
			for (int i = cost; 0 <= i; i--) {
				if (array[i] == 1 && prime[i] == 1) {
					System.out.println(i);
					flag = true;
				}
				if (flag) {
					break;
				}
			}

			if (!flag) {
				System.out.println("NA");
			}
		}
	}
}

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

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

#define vint(v, n) vector<int> v(n); REP(i,n) cin >> v[i];

int main(void){

  cin.tie(0);
  ios::sync_with_stdio(false);

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

  cout << (A+B)%24 << endl;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#define int            int64_t
#define double         long double
#define nitro          ios_base::sync_with_stdio(false);cin.tie(0);
#define vi             vector<int64_t>
#define si             set<int>
#define pub            push_back
#define puf            push_front
#define pob            pop_back
#define pof            pop_front
#define PI             3.1415926535897932384626433832795
#define read(a)        for(auto& x : a) cin>> x
#define endl           '\n'
#define gap            ' '
#define min3(a,b,c)    min(a, min(b, c))
#define max3(a,b,c)    max(a, max(b, c))
#define MOD            1000000007
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
int32_t main()
{
    nitro
    int n,c=0;;cin>>n;
    for(int i=0,x;i<n;++i)
    {
    	cin>>x;
    	if(x%2!=0) c++;
    }
    cout<<(c%2==0?"YES":"NO");
}


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

int main() {
	int N, M, C;

	cin >> N >> M >> C;
	int kaz = 0;
	vector<int> v1; int sum =C;
	for (int x = 0; x < M; x++) {
		int y; cin >> y;
		v1.push_back(y);
	}
	for (int i = 1; i <= N; i++) {
	
		for (int j = 1; j <= M; j++) {
			int z; cin >> z;
			sum = v1[j - 1] * z + sum;
		}
		if (0 < sum) {
			kaz = kaz + 1;
		}
		sum = C;
	}
	cout << kaz;
	system("pause");
	return 0;
}

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

using namespace std;

typedef long long ll;

const ll MOD = 1000000007;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll T[n], A[n];
    for(int i=0;i<n;i++) cin >> T[i];
    for(int i=0;i<n;i++) cin >> A[i];
    // max value of candidates, flag if only one or not
    vector<pair<ll, bool> > vp;
    for(int i=0;i<n;i++){
        if(i == 0 || T[i] > T[i-1]){
            vp.push_back(make_pair(T[i], true));
        }else if(T[i] == T[i-1]){
            vp.push_back(make_pair(T[i], false));
        }else{
            cout << 0 << endl;
            return 0;
        }
    }
    ll ans = 1;
    for(int i=n-1;i>=0;i--){
        if(i == n-1 || A[i] > A[i+1]){
            if(vp[i].second && vp[i].first == A[i]){
                ans *= 1LL;
            }else if(!(vp[i].second) && vp[i].first >= A[i]){
                ans *= 1LL;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else if(A[i] == A[i+1]){
            if(vp[i].second && vp[i].first <= A[i]){
                ans *= 1LL;
            }else if(!(vp[i].second)){
                ans *= min(vp[i].first, A[i]);
                ans %= MOD;
            }else{
                cout << 0 << endl;
                return 0;
            }
        }else{
            cout << 0 << endl;
            return 0;
        }
        // cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
#include<stdio.h>

int main(){
  int n,a,i,count=0;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(sosu(a)==1)count++;
  }

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

int sosu(int x){
  int i;
  if(x==2) return 1;
  else if(x<2) return 0;
  else if(x%2==0) return 0;
  for(i=3;i*i<=x;i+=2){
    if(x%i==0) return 0;
    //else return 1;
  }
  return 1;
}



Measured memory_bytes: 2064
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
		int n;
		cin >> n;
		int mountains[n];
		for(int i=0; i<n; i++){
				cin >> mountains[i];
		}

		int cnt =1;
		int max = mountains[0];
		for(int i=1; i<n; i++){
				if(mountains[i] >= max){
						cnt++;
						max = mountains[i];
				}
		}
		cout << cnt << endl;
}

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

template <class T> using V = vector<T>;
template <class S, class T> using P = pair<S, T>;
template <class... T> using TP = tuple<T...>;

using ll = long long;
using db = double;
using ldb = long db;
using str = string;
using vll = V<ll>;
using vvll = V<V<ll>>;
using pll = P<ll,ll>;
using tpll = TP<ll,ll,ll>;
using vpll =V<pll>;
using vst = V<str>;
using vch = V<char>;

#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(b);i>(ll)(a);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) __lcm(a,b)
#define co(a) cout<<a<<endl
#define ci(a) cin>>a
#define pb(a) push_back(a)
#define pob pop_back()
#define mp make_pair
#define mt make_tuple
#define pbmp(a,b) push_back(mp(a,b))
#define subs(a,b) substr(a,b)
#define cfs(a) cout<<fixed<<setprecision(a)
#define INF 1e16
#define mod 1e9+7


int main() {
  ll n;
  cin>>n;
  vpll v(n);
  FOR(i,0,n){
    cin>>v[i].se>>v[i].fi;
  }
  SORT(v);
//  ll t=0,ti=0;
//  t=v[0].fi;
//  ti=v[0].se;
//  ll time=-v[i].se+v[i].fi;
  bool D=false;
//  if(tim<0){
//    D=true;
//  }
  ll time=0;
  ll t=0;
  FOR(i,0,n){
    t+=v[i].se;
    time=v[i].fi-t;
    if(time<0){
      D=true;
      break;
    }
  }
  if(D){
    co("No");
  }
  else{
    co("Yes");
  }
}
    

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

using namespace std;

int main()
{
	int n, m;
	scanf("%d", &n);
	
	vector<int> v;
	
	for(int i = 0; i < n; i++)
	{
		scanf("%d", &m);
		v.push_back(m);
	}
	
	int k = v[0];
	int l = -2000000000;
	
	for(int i = 1; i < v.size(); i++)
	{
		l = max(l, v[i] - k);
		k = min(v[i], k);
	}

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


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
int main()
{
    int n;
    cin>>n;
    vi a(n);
    ll tot=0;
    for(int i=0;i<n;i++) cin>>a[i],tot+=a[i];
    ll ans=0x3f3f3f3f3f3f3f3f;
    ll cc=0;
    for(int i=0;i<n-1;i++)
    {
        cc+=a[i];
        ans=min(ans,abs(cc-(tot-cc)));
    }
    print(ans);
    
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <algorithm>
#include <queue>
using namespace std;

int a[300005];
long long pre[300005], suff[300005];

int main(){
    int N;
    scanf("%d", &N);
    for(int i=1; i<=3*N; i++) scanf("%d", &a[i]);
    priority_queue<int> pq;
    long long sum = 0;
    for(int i=1; i<=N; i++) sum += a[i], pq.push(-a[i]);
    pre[N] = sum;
    for(int i=N+1; i<=2*N; i++){
        sum += a[i];
        pq.push(-a[i]);
        int val = pq.top();
        pq.pop();
        sum += val;
        pre[i] = sum;
    }
    while(!pq.empty()) pq.pop();
    sum = 0;
    for(int i=2*N+1; i<=3*N; i++) sum += a[i], pq.push(a[i]);
    suff[2*N+1] = sum;
    for(int i=2*N; i>=N; i--){
        sum += a[i];
        pq.push(a[i]);
        int val = pq.top();
        pq.pop();
        sum -= val;
        suff[i] = sum;
    }
    long long res = -1e18;
    for(int i=N; i<=2*N; i++) res = max(res, pre[i]-suff[i+1]);
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<string> vecb(N);
   for (int i = 0; i < N; i++) {
     cin >> vecb.at(i);
   }
  int M;
  cin >> M;
  vector<string> vecr(M);
   for (int i = 0; i < M; i++) {
     cin >> vecr.at(i);
   }
  int x = 0;
   for (int i = 0; i < N; i++) {
     int a = 0;
     for (int j = 0; j < N; j++) {
       if(vecb.at(j) == vecb.at(i))
         a ++;
     }
        for (int k = 0; k < M; k++) {
          if(vecr.at(k) == vecb.at(i))
            a--;
        }
     if (a > x)
       x = a;
   }
  cout << x << endl;
}

Measured memory_bytes: 3604
# ABC138E - Strings of Impurity
import sys
input = sys.stdin.readline

def main():
    S = input().rstrip()
    T = input().rstrip()
    if set(T) <= set(S):
        lim_s, lim_t = len(S) - 1, len(T)
        ans, cur, idx = 1, 0, -1
        while cur < lim_t:
            x = S[idx + 1 :].find(T[cur])
            if x == -1:
                ans += 1
                idx = -1
            else:
                idx += x + 1
                cur += 1
        ans = (ans - 1) * (lim_s + 1) + idx + 1
        print(ans)
    else:  # corner case
        print(-1)


if __name__ == "__main__":
    main()

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

S = input()
s_list = list(S)
s_l = len(s_list)
N = s_l + 1
t_list = ["ou"] if s_list[0] == "<" else ["totsu"]

# 1回目のループ: 凹凸↗︎↘︎を判定する
for i, char in enumerate(s_list):
    # 凹であるかどうか
    is_ou = False
    is_totsu = False
    if i == s_l - 1:
        if char == ">":
            is_ou = True
        else:
            is_totsu = True
    else:
        if s_list[i] == "<" and s_list[i + 1] == ">":
            is_totsu = True
        elif s_list[i] == ">" and s_list[i + 1] == "<":
            is_ou = True

    if is_ou:
        t = "ou"
    elif is_totsu:
        t = "totsu"
    elif char == "<":
        t = "up"
    else:
        t = "down"
    t_list.append(t)

# 2回目のループ: 凹と↗︎部分の値を確定させる
x_list = []
for i, t in enumerate(t_list):
    if t == "ou":
        x = 0
    elif t == "up" or i == N - 1:
        x = x_list[i - 1] + 1
    else:
        x = None
    x_list.append(x)

# 3回目のループ: 末尾から見ていって、凸と↘︎部分を確定させる
total = 0

for i in range(N):
    idx = N - (i + 1)
    t = t_list[idx]
    if t == "down":
        x_list[idx] = x_list[idx + 1] + 1
    elif t == "ou" or t == "down":
        pass
    elif t == "totsu":
        if idx == 0:
            x_list[0] = x_list[1] + 1
        elif idx == N - 1:
            x_list[idx] = x_list[idx - 1] + 1
        else:
            a = x_list[idx - 1]
            b = x_list[idx + 1]
            x_list[idx] = max(a, b) + 1
    total += x_list[idx]

ans = total
print(ans)


Measured memory_bytes: 31900