akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

int N, M;
int H[100010];
bool good[100010];

signed main()
{
	cin >> N >> M;
	rep(i, N) cin >> H[i];

	rep(i, N) good[i] = true;

	rep(i, M) {
		int a, b; cin >> a >> b;
		--a, --b;
		if (H[a] > H[b]) {
			good[b] = false;
		} else if (H[a] < H[b]) {
			good[a] = false;
		} else {
			good[a] = good[b] = false;
		}
	}

	int ans = 0;

	rep(i, N) {
		ans += good[i];
		if (good[i]) {
			//printf("%lld is good\n", i+1);
		}
	}

	cout << ans << endl;
}



Measured memory_bytes: 4512
//#pragma GCC target("avx2")
//#pragma GCC optimization("O3")
//#pragma GCC optimization("unroll-loops")
//assert(q==w) если q!=w --> runtime error
#include <bits/stdc++.h>

#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define ub upper_bound
#define lb lower_bound
#define bit __builtin_popcount
#define memset(x) memset(x,0,sizeof(x))

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vector<int>> matrix;

inline void boost(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

const ll maxn=2e5+123;
const ll inf=1e9+123;
const ll linf=1e18+123;
const ll mod=1e9+7;
const double eps=1e-9;
const double pi=acos(-1);
int dx[8]={0,1,-1,0,1,-1,1,-1};
int dy[8]={1,0,0,-1,1,1,-1,-1};

int main(){
    boost();
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int n;
    cin>>n;
    int kol=n/100;
    int q=n%100;
    if(n<100){
        cout<<"0";
        return 0;
    }
    if(q<=kol*5){
        cout<<"1";
        return 0;
    }
    cout<<"0";
	exit(0);
}


Measured memory_bytes: 256
using System;

class Program {
  static void Main(string[] args) {
    const char DOT = '.';
    const char SHARP = '#';
    string[] val = Console.ReadLine().Split();
    int H = int.Parse(val[0]);
    int W = int.Parse(val[1]);

    char[,] C = new char[H + 2, W + 2];
    bool[,] A = new bool[H, W];
    int[,] way = {{-1,0}, {0,1}, {1,0}, {0,-1}};

    for (int i = 0; i < H + 2; ++i) {
      C[i, 0] = C[i, W + 1] = DOT;
    }
    for (int i = 0; i < W + 2; ++i) {
      C[0, i] = C[H + 1, i] = DOT;
    }
    for (int i = 0; i < H; ++i) {
      string str = Console.ReadLine();
      for (int j = 0; j < W; ++j) {
        C[i + 1, j + 1] = str[j];
      }
    }
    
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (C[i + 1, j + 1] == DOT) continue;
        for (int k = 0; k < 4; ++k) {
          if (C[way[k,0] + i + 1, way[k,1] + j + 1] == SHARP) {
            A[i,j] = A[way[k,0] + i, way[k,1] + j] = true;
          }
        }
      }
    }

    bool ok = true;
    for (int i = 0; i < H; ++i) {
      for (int j = 0; j < W; ++j) {
        if (C[i+1, j+1] == SHARP && !A[i,j]) {
          ok = false;
          goto LOOPEND;
        }
      }
    }

  LOOPEND:
    if (ok) {
      Console.WriteLine("Yes");
    }
    else {
      Console.WriteLine("No");
    }
  }
}


Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int a, b;
    cin >> a >> b;
    if(a+b < 24) {
        cout << a+b;
    }
    else {
        cout << a+b-24;
    }    
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI acos(-1)
#define eq(x,y) (fabs((x)-(y)) < eps)
#define debug(x) cerr<<x<<endl;
#define endl "\n"
#define pb push_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int inf=1e9+7;
const int nmax=1e5+10;
const int eps=1e-8;


int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;
    //cout.tie(NULL);
    int a,b;
    cin>>a>>b;

    int c=a+b;
    int d=a-b;
    int e=a*b;

    int ans=max(c,max(d,e));
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        long K = sc.nextLong();

        System.out.println(solve(A, B, C, K));
    }

    private static long solve(int A, int B, int C, long K) {
        long count = B - A;
        if (K%2 == 0) count *= -1;


        return count;
    }
}

Measured memory_bytes: 23252
#include "bits/stdc++.h"

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> X(N);

    for (int i = 0; i < N; ++i) cin >> X[i];

    int sum = 0;
    for (int i = 0; i < N; ++i) sum += X[i];

    int P = sum / N;

    int ans = INT_MAX;
    for (int k = 0; k < 2; ++k) {
        int d = 0;
        for (int i = 0; i < N; ++i) d += (X[i] - P) * (X[i] - P);
        ans = min(ans, d);
        P++;
    }
    cout << ans << endl;
}

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

const int MAXN = 1e5+5;
int n, m, fa[MAXN];

struct edge
{
	int u, v;
}e[MAXN];

long long ans[MAXN], sz[MAXN];

int find(int x)
{
	if(x == fa[x])
		return x;
	
	return fa[x] = find(fa[x]);
}

int main()
{
	cin >> n >> m;
	
	for(int i = 1; i <= m; ++i)
		cin >> e[i].u >> e[i].v;
	for(int i = 1; i <= n; ++i)
		fa[i] = i, sz[i] = 1;
	
	ans[m] = (long long)n * (n - 1) / 2;
	
	for(int i = m; i >= 1; --i)
	{
		int u = find(e[i].u), v = find(e[i].v);
		
		if(u == v)
			ans[i - 1] = ans[i];
		else
		{
			ans[i - 1] = ans[i] - sz[v] * sz[u];
			sz[v] += sz[u];
			fa[u] = v;
		}
	}
	
	for(int i = 1; i <= m; ++i)
		cout << ans[i] << endl;
	
	return 0;
}

Measured memory_bytes: 4096
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"
 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int h,w,n;
    cin>>h>>w>>n;
    int m=max(h,w);
    int ans=0;
    int c=0;
    while(c<n){
        c+=m;
        ans++;
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 256
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>

using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     vi              vector<int>
#define     vll             vector<ll>
#define     sz(x)           (int)x.size()
#define     pb              push_back
int dx[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
int dy[] = { -1, 0, 1, -1, 1, -1, 0, 1 };

int main() {
	ll n,k;cin>>n>>k;
	vll v(n);
	loop(n,i,0)cin>>v[i];
	sort(allv(v));
	ll l=-1e18,r=1e18,res=-1;
	while(l<=r){
		ll mid=(l+r)/2,cnt=0;
		loop(n,i,0){
			if(v[i]>0){
			ll li=i+1,ri=n-1,c=i;
			while(li<=ri){
				ll j=(li+ri)/2;
				if(v[i]*v[j]<=mid){
					c=j;
					li=j+1;
				}
				else ri=j-1;
			}
			cnt+=(c-i);
		}
			else{
				ll li=i+1,ri=n-1,c=n;
				while(li<=ri){
					//cout<<li<<' '<<ri<<' '<<mid<<' '<<i<<endl;
					ll j=(li+ri)/2;
					if(v[i]*v[j]<=mid){
						c=j;
						ri=j-1;
					}
					else li=j+1;
				}
				cnt+=(n-c);
			}
		}
			if(cnt>=k){
				res=mid;
				r=mid-1;
			}
			else l=mid+1;
		}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1792
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


class UnionFind:
    # Reference: https://note.nkmk.me/python-union-find/
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())


def main():
    N, M, *XYZ = map(int, read().split())
    uf = UnionFind(N)
    for x, y, z in zip(XYZ[::3], XYZ[1::3], XYZ[2::3]):
        uf.union(x - 1, y - 1)

    print(uf.group_count())
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 105084
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <utility>
#include <functional>

using namespace std;

int main() {
	string s;
	cin >> s;
	cout << s.substr(0, 4) << " " << s.substr(4) << endl;

	return 0;
}

Measured memory_bytes: 256
import math
def func(num):
    lists = []
    root = math.floor(math.sqrt(num))
    
    while(num%2==0):
        num = num // 2
        if(num%2!=0):
            lists.append(2)
            
    for j in range(3,root+2,2):
        while(num%j==0):
            num = num //j
            if(num%j!=0):
                lists.append(j)
        if(num==1):
            break

    if(num>1):
        lists.append(num)
    return lists

if __name__ == "__main__":
    a,b = (int(i) for i in input().split())
    
    lists1 = func(a)
    lists2 = func(b)
    
    ans = set(lists1) & set(lists2)
    print(len(ans)+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,0,n+1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
const int MOD=1e9+7;
const int INF=1e18;

signed main(){
    int N,A,B;cin>>N>>A>>B;
    cout<<min(B,N*A)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) _MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define pb push_back
#define all(x) begin(x),end(x)
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cerr<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cerr<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.first<<","<<p.second<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
#else
#define dbg(...) {}
#endif

template<int mod=1000000007>
class ModInt {
  int x;
public:
  ModInt() : x(0) {}
  ModInt(const ModInt &y): x(y.x) {}
  ModInt(int64_t y){ x = y % mod; if(x < 0) x += mod; }
  ModInt &operator += (const ModInt &p){ x += p.x; if(x >= mod) x -= mod; return *this; }
  ModInt &operator -= (const ModInt &p){ x -= p.x; if(x < 0) x += mod; return *this; }
  ModInt &operator *= (const ModInt &p){ x = (int) (1LL * x * p.x % mod); return *this; }
  ModInt &operator /= (const ModInt &p){ *this *= p.inverse(); return *this; }
  ModInt operator -() const { return ModInt(-x); }
  ModInt operator + (const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator - (const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator * (const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator / (const ModInt &p) const { return ModInt(*this) /= p; }
  ModInt operator ^ (const int64_t y) const { return pow(y); }
  bool operator == (const ModInt &p) const { return x == p.x; }
  bool operator != (const ModInt &p) const { return x != p.x; }
  ModInt operator = (const int64_t y) { return *this = ModInt(y); }
  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0){
      t = a/b; a -= t*b; swap(a, b);
      u -= t*v; swap(u, v);
    }
    return ModInt(u);
  }
  ModInt pow(int64_t y) const {
    if(x==0) return ModInt(0);
    int64_t r = 1, t = x;
    while(y > 0){
      if(y&1) r = r*t%mod;
      t = t*t%mod; y >>= 1;
    }
    return ModInt(r);
  }
  friend ostream &operator << (ostream &os, const ModInt<mod> &p) { return os<<p.x; }
  friend istream &operator >> (istream &is, ModInt<mod> &a) { int64_t x; is>>x; a = ModInt<mod>(x); return is; }
};
using Int = ModInt<>;

Int dp[10005][105][2];

int main(){
  string sk;
  int d;
  cin>>sk>>d;

  int n = sk.size();
  vector<int> k(n);
  rep(i,n) k[i] = sk[i] - '0';

  dp[0][0][1] = 1;
  rep(i,n) rep(j,d){
    rep(x,10){
      dp[i+1][(j+x)%d][0] += dp[i][j][0];
      if(x < k[i]) dp[i+1][(j+x)%d][0] += dp[i][j][1];
      if(x == k[i]) dp[i+1][(j+x)%d][1] += dp[i][j][1];
    }
  }

  cout << (dp[n][0][0] +  dp[n][0][1] - 1) << endl;


  return 0;
}


Measured memory_bytes: 8704
//submitted by HimJ
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;
const int mxn=1e5+1;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  ll t=1;
  //cin>>t;
    while(t--){
            int n,i;
    cin>>n;
    ll arr[n];
    fr(i,0,n)
    cin>>arr[i];
    sort(arr,arr+n);
    ll N,R;
    fr(i,1,n)
    {
        ll s=arr[i]/2;
        int idx=lower_bound(arr,arr+n,s)-arr;
        if(idx>=i)
        {
            if(idx-1>=0&&idx-1<i)
                idx--;
            else
            continue;
        }
        if(arr[i]%2)
        {
            ll r=arr[idx];
            ll r2=0;
            if(idx-1>=0)
                r2=arr[idx-1];
            if(r-s-1>s-r2)
                r=r2;
//            if(N==0)
//            {
                N=arr[i];
                R=r;
//            }
//            else 
//            {
//                
//            }
        }
        else
        {
            ll r=arr[idx];
            ll r2=0;
            if(idx-1>=0)
                r2=arr[idx-1];
            if(r-s>s-r2)
                r=r2;
//            if(N==0)
//            {
                N=arr[i];
                R=r;
//            }
        }
    }
    cout<<N<<" "<<R;
    }
  return 0;
  }



Measured memory_bytes: 1024
data_h = []
data_w = []
while True:
  h, w = (int(i) for i in input().split())
  if h == w == 0:
    break
  else:
    data_h.append(h)
    data_w.append(w)

for i in range(len(data_h)):
  h = data_h[i]
  w = data_w[i]
  for j in range(1,h+1):
    for k in range(1,w+1):
      if j == 1 or j == h or k == 1 or k == w:
        print('#',end='')
      else:
        print('.',end='')
    print('')
  print('')

Measured memory_bytes: 6812
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
// typedef tuple<int,int,int> tp;
// typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1,1,1,-1,-1};
int dy[]={1,0,-1,0,1,-1,1,-1};//RDLU
int main(){
	int a;
	cin>>a;
	if(a<1200)cout<<"ABC"<<endl;
	else if(a<2800)cout<<"ARC"<<endl;
	else cout<<"AGC"<<endl;
}







Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int xs[] = {-1,0,0,1},ys[] = {0,-1,1,0};
  int xm[] = {-1,-1,-1,0,0,1,1,1}, ym[] = {-1,0,1,-1,1,-1,0,1};
  int xl[] = {-2,-1,-1,-1,0,0,0,0,1,1,1,2};
  int yl[] = {0,-1,0,1,-2,-1,1,2,-1,0,1,0};

  int x,y,n;
  int max = 0, cnt = 0;

  int map[14][14] = {0};

  while(scanf("%d,%d,%d",&x,&y,&n) != EOF){
    x += 2;
    y += 2;
    switch(n){
    case 1:
      map[x][y]++;
      for(int i = 0; i < 4; i++){
	map[x + xs[i]][y + ys[i]]++;
      }
      break;

    case 2:
      map[x][y]++;
      for(int i = 0; i < 8; i++){
	map[x + xm[i]][y + ym[i]]++;
      }
      break;

    case 3:
      map[x][y]++;
      for(int i = 0; i < 12; i++){
	map[x + xl[i]][y + yl[i]]++;
      }
      break;
    }
  }

  for(int i = 2; i < 12; i++){
    for(int j = 2; j < 12; j++){
      if(map[i][j] == 0){
	cnt++;
      }
      if(map[i][j] > max){
	max = map[i][j];
      }
    }
  }
    
  printf("%d\n%d\n",cnt,max);

  return 0;
}

Measured memory_bytes: 1028
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a[45],n;
  cin >> n;
  a[0] = 1;
  a[1] = 1;
  if (n < 2){
    cout << a[n] << endl;
  }
  else{
    for (int i=2; i<=n; i++)
      a[i] = a[i-1] + a[i-2];
    cout << a[n] << endl;
  }
}

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

bool is_prime(int k)
{
	for(int j=2;j*j<=k;j++){
		if(k%j==0) {
			return false;
		}
	}
    return true;
}

int main()
{
    stringstream ss;
    // 入力
    int A,B;
    cin>>A>>B;
    cout<<(A-1)*(B-1)<<endl;
    return 0;
}

Measured memory_bytes: 256
//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
const double pi = acos(-1);
const ll SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[200005], finv[200005], inv[200005];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑



string ans1, ans2;
int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	while (b != d) {
		ans1 += "U";
		++b;
	}
	while (a != c) {
		ans1 += "R";
		++a;
	}
	for (int i = 0; i < ans1.length(); ++i) {
		if (ans1[i] == 'U') { ans2 += "D"; }
		else { ans2 += "L"; }
	}

	cout << ans1 << ans2 << "LU" << ans1 << "RD" << "RD" << ans2 << "LU" << endl;
}

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

using namespace std;


int main() {
	int N, M;
	int count = 0;
	int count_max = -100;
	string search_word;

	cin >> N;

	vector<string> s(N);
	for (int i = 0; i < N; i++) {
		cin >> s.at(i);
	}

	cin >> M;

	vector<string> t(M);
	for (int i = 0; i < M; i++) {
		cin >> t.at(i);
	}

	for (int i = 0; i < N; i++) {
		count = 0;
		search_word = s.at(i);

		for (int j = 0; j < N; j++) {
			if (s.at(j) == search_word) {
				count++;
			}
		}

		for (int j = 0; j < M; j++) {
			if (t.at(j) == search_word) {
				count--;
			}
		}

		if (count > count_max) {
			count_max = count;
		}
	}

	for (int i = 0; i < M; i++) {
		count = 0;
		search_word = t.at(i);

		for (int j = 0; j < N; j++) {
			if (s.at(j) == search_word) {
				count++;
			}
		}

		for (int j = 0; j < M; j++) {
			if (t.at(j) == search_word) {
				count--;
			}
		}

		if (count > count_max) {
			count_max = count;
		}
	}

	if (count_max < 0) {
		count_max = 0;
	}

	cout << count_max << endl;
	
	return 0;
}

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

int xv[]={-1,0,1,0},yv[]={0,-1,0,1};

void solve(int n){
   vector<int> x(1,0);
   vector<int> y(1,0);
   
   for(int i=0;i<n-1;i++){
       int a,b;
       cin>>a>>b;
       x.push_back(x[a]+xv[b]);
       y.push_back(y[a]+yv[b]);
   }
   cout<<(*max_element(x.begin(),x.end())-*min_element(x.begin(),x.end())+1)<<" "<<(*max_element(y.begin(),y.end())-*min_element(y.begin(),y.end())+1)<<endl;
   
   
}

int main (){
    int a;
    while(cin>>a,a){
        solve(a);
    }
}

Measured memory_bytes: 3108
taro, hanako = 0, 0
gets.chomp.to_i.times do
  t,h = gets.chomp.split
  case t.casecmp(h)
  when 1
    taro += 3
  when 0
    taro += 1
    hanako += 1
  when -1
    hanako += 3
  end
end
puts "#{taro} #{hanako}"

Measured memory_bytes: 6104
import math
a, b, h, m = map(int, input().split())
rad_a = 360 * h / 12 + 30 * m / 60
rad_b = 360 * m / 60 

ans = a**2 + b **2 - 2*a*b*math.cos(math.radians(rad_a - rad_b))
print(math.sqrt(ans))

Measured memory_bytes: 9420
import java.util.Scanner;

public class Main {
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int X = sc.nextInt();
		int a500 = 0;
		int a5 = 0;
		int u = 0;
		
		a500 = X/500;
		a5 = (X%500)/5;
		
		System.out.println(a500*1000+a5*5);
		
		sc.close();
	}
}

Measured memory_bytes: 23764
'use strict';
const p = s => console.log(s);

// inputに入力データ全体が入る
function Main(input) {
  // 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n");
  let N = input[0].split(" ")[0];

  let isSeven = false;

  while(N>1) {
    let num = Math.floor(N % 10)
    if(num === 7) {
      isSeven = true;
      break;
    }
    N = Math.floor(N / 10)
  }
  if(isSeven) p('Yes');
  else p('No');
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29624
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

inline void solve() {
	int n, m, x;
	cin >> n >> m >> x;
	vector<int> cost(n);
	vector<vector<int>> l(n, vector<int>(m));
	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		for (int j = 0; j < m; j++) {
			cin >> l[i][j];
		}
	}

	int otv = 1e9;
	for (int i = 0; i < (1 << n); i++) {
		int c = 0;
		vector<int> lvl(m, 0);
		for (int j = 0; j < n; j++) {
			if (((i >> j) & 1) == 1) {
				c += cost[j];
				for (int k = 0; k < m; k++) {
					lvl[k] += l[j][k];
				}
			}
		}
		
		bool ok = 1;

		for (int j = 0; j < m; j++) {
			if (lvl[j] < x)
				ok = 0;
		}

		if (ok)
			otv = min(otv, c);
	}

	if (otv == 1e9)
		cout << -1;
	else
		cout << otv;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	for (; q > 0; q--) {
		solve();
		cout << '\n';
	}
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
const LL N=10000009;
LL s[N+5];


int main()
{
    LL n;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        for(int j=i; j<=n; j+=i)
            s[j]++;
    }
    LL ans=0;
    for(LL i=1;i<=n;i++)
        ans+=(i*s[i]);
    cout<<ans;
}


Measured memory_bytes: 81716
import java.util.Scanner;

public class Main {

	final int size = 3;
	final int[][] grid = new int[size][size];
	
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		Scanner sc = new Scanner(System.in);
		for(int i=0; i<size; i++)
			for(int j=0; j<size; j++) grid[i][j] = sc.nextInt();
		sc.close();
		int aAry[] = new int[size];
		int bAry[] = new int[size];
		
		for(int i=0; i <= grid[0][0]; i++) {
			aAry[0] = i;
			bAry[0] = grid[0][0] - aAry[0];
			bAry[1] = grid[0][1] - aAry[0];
			bAry[2] = grid[0][2] - aAry[0];
			aAry[1] = grid[1][0] - bAry[0];
			aAry[2] = grid[2][0] - bAry[0];
			if(judge(aAry, bAry)) {
				System.out.println("Yes");
				return;
			}
		}
		
		System.out.println("No");
	}

	boolean judge(int aAry[], int bAry[]) {
		boolean res = true;
		
		for(int i=0; i<size; i++) {
			for(int j=0; j<size; j++) {
				if(grid[i][j] != aAry[i] + bAry[j]) return false;
			}
		}
		
		return res;
	}
}

Measured memory_bytes: 22868
import java.io.{BufferedReader, InputStream, InputStreamReader}
import java.util.StringTokenizer

import scala.collection.mutable
import scala.util.Sorting
import math.{abs, max, min}

object Main {
  val MOD = 1000000007
  def solve(): Unit = {
    val sc = new InputReader(System.in)
    val N = sc.nextInt()
    val M = sc.nextInt()
    val x = Array.fill[Long](N)(sc.nextLong())
    val y = Array.fill[Long](M)(sc.nextLong())
    Sorting.quickSort(x)
    Sorting.quickSort(y)

    def p(x: Long, y: Long) = (x + y) % MOD
    def m(x: Long, y: Long) = x * y % MOD
    
    def sigma(a: Array[Long]): Long = {
      var sum: Long = 0
      val n = a.length
      a.indices foreach { i =>
        val j = if (i * 2 < n) i else n - 1 - i
        val c = p(m(j+1, n), -1 * m(j + 1, j)) // // 回数: (i+1)*n - i(i+1)
        sum = p(sum, m(c, a(i)))
      }
      sum
    }

    def diff(a: Array[Long]): Array[Long] = {
      (a zip a.drop(1)) map { case (x1, x2) => x2 - x1 }
    }

    val sigmaX = sigma(diff(x))
    val sigmaY = sigma(diff(y))

    println(m(sigmaX, sigmaY))
  }


  def main(args: Array[String]): Unit = {
    solve()
  }


  private class InputReader(val stream: InputStream) {
    private val reader = new BufferedReader(new InputStreamReader(stream), 32768)
    private var tokenizer: StringTokenizer = null

    def next: String = {
      while (tokenizer == null || !tokenizer.hasMoreTokens)
        tokenizer = new StringTokenizer(reader.readLine)
      tokenizer.nextToken
    }

    def nextInt(): Int = next.toInt
    def nextLong(): Long = next.toLong
    def nextChar(): Char = next.charAt(0)
  }

}


Measured memory_bytes: 90644
#include<iostream>
using namespace std;
int a[100010];
int main()
{
	int n;
	cin>>n;
	int sum=0;
	a[0]=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	a[n+1]=0;
	for(int i=1;i<=n+1;i++)
	{
		sum+=abs(a[i]-a[i-1]);
	}
	for(int i=1;i<=n;i++)
	{
		cout<<sum-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1])-abs(a[i+1]-a[i-1]))<<endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c;
  string s;
  in(s);
  b = s.size();
  a = 0;
  while(c == 0){
    if(s[a] == 'A')
      c++;
    else
      a++;
  }
  c--;
  while(c == 0){
    if(s[b - 1] == 'Z')
      c++;
    else
      b--;
  }
  out(b - a);
  memi;
}

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

int N = 200000;
int h[200005],n;
long long a[200005],BIT[200005];

int LS(int x){
	return x&-x;
}

void update(int x, long long val){
	for(int i = x; i<=N;i+=LS(i)){
		BIT[i] = max(BIT[i],val);
	}
}

long long query(int x){
	long long ans = 0;
	for(int i= x; i>=1;i-=LS(i)){
		ans = max(ans,BIT[i]);
	}
	return ans;
}


int main(){
	memset(BIT,0,sizeof BIT);
	scanf("%d",&n);
	for (int i = 0;i <n;i++){
		scanf("%d",&h[i]);
	}
	for(int i = 0;i <n;i++){
		scanf("%d",&a[i]);
	}
	
	long long ans = 0;
	
	for (int i = 0;i<n;i++){
		int val = h[i];
		long long maxi = query(val);
		update(val,a[i]+maxi);
		ans = max(ans, a[i]+maxi);
	}
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define ll long long int
#define p pair<ll,ll>
#define pp pair<pair<ll,ll>,ll>
#define fi first
#define se second
#define opti ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
const ll N = 1e6+6;
ll t,i,j,k,n,m,q;
int main()
{
    opti
        cin>>n;
        ll a[n+1];
        ll ans1 = 0,ans2=0;
        for(i=0;i<n;i++)
        {
            cin>>a[i];
        }
        map<ll,ll> ma1,ma2;
        for(ll i=0;i<n;i+=2){
            ma1[a[i]]++;
        }
        for(ll i=1;i<n;i+=2){
            ma2[a[i]]++;
        }
        map<ll,ll>::iterator it=ma1.begin();
        ll maxi = 0;
        ll ele = -1;
        for(it;it!=ma1.end();it++){
            if(it->second >maxi){
                maxi = it->second;
                ele = it->first;
            }
        }
        ans1 += maxi;
        maxi = 0;
        it = ma2.begin();
        for(it;it!=ma2.end();it++){
            if(it->second >maxi && it->first!=ele){
                maxi = it->second;
            }
        }
        ans1 += maxi;




        it = ma2.begin();
        maxi = 0;
        ele=-1;
        for(it;it!=ma2.end();it++){
            if(it->second >maxi && it->first!=ele){
                maxi = it->second;
                ele = it->first;
            }
        }
        ans2 += maxi;
        it = ma1.begin();
        maxi = 0;
        for(it;it!=ma1.end();it++){
            if(it->second >maxi && it->first!=ele){
                maxi = it->second;
            }
        }
        ans2 += maxi;
        cout<<n - max(ans1,ans2)<<endl;
    return 0;
}


Measured memory_bytes: 7296
n = int(input())
s = input()
q = int(input())


class SegmentTree:
    def __init__(self, a, func=max, one=-10 ** 18):
        self.logn = (len(a) - 1).bit_length()
        self.n = 1 << self.logn
        self.func = func
        self.one = one

        self.b = [self.one] * (2 * self.n - 1)
        for i, j in enumerate(a):
            self.b[i + self.n - 1] = j
        for i in reversed(range(self.n - 1)):
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_item(self, i):
        return self.b[i + self.n - 1]

    def update(self, index, x):
        i = index + self.n - 1
        self.b[i] = x
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def update_func(self, index, x):
        i = index + self.n - 1
        self.b[i] = self.func(self.b[i], x)
        while i != 0:
            i = (i - 1) // 2
            self.b[i] = self.func(self.b[i * 2 + 1], self.b[i * 2 + 2])

    def get_segment(self, l, r, i=0):
        j = i - (1 << ((i + 1).bit_length() - 1))+1
        length = 1 << (self.logn - (i + 1).bit_length() + 1)
        ll = j * length
        rr = (j + 1) * length
        if l <= ll and rr <= r:
            return self.b[i]
        elif rr <= l or r <= ll:
            return self.one
        else:
            return self.func(self.get_segment(l, r, i * 2 + 1),
                             self.get_segment(l, r, i * 2 + 2))


def get_int(s):
    abc = "abcdefghijklmnopqrstuvwxyz"
    return 1<<abc.index(s)


seg = SegmentTree([get_int(i) for i in s], int.__or__, 0)

for _ in range(q):
    q, i, j = input().split()
    if q == "1":
        seg.update(int(i) - 1, get_int(j))
    else:
        aa = seg.get_segment(int(i) - 1, int(j))
        ans = 0
        for i in range(26):
            if (aa >> i) & 1 == 1:
                ans += 1
        print(ans)


Measured memory_bytes: 79512
#include<bits/stdc++.h>
#define int long long
using namespace std;
constexpr int mod=1e9+7;
signed main(){
    int n;
    cin>>n;
    int ans=0;
    for(int i=1;i<n;i++)
        ans+=(n-1)/i;
    cout<<ans<<endl;
}


Measured memory_bytes: 3628
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,n) for(ll i##_len=(n) ,i=i##_len-1;i>=0;--i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define printd(val) std::cout<< #val" = " <<val<<"\n";
#include<bits/stdc++.h>
using ll = int;
using pii = std::pair<int,int>;
using namespace std;
template<class T>T chmin(T a,T b){if(a>b){a^=b;b^=a;a^=b;return 1;}return 0;}
template<class T>T chmax(T b,T a){if(a<b){a^=b;b^=a;a^=b;return 1;}return 0;}

int n;
vector<ll> h;
void input(){
    cin>>n;
    h.resize(n,0);
    rep(i,n) cin>>h[i];
}
void src(){
    bool can=true;
    rep(i,n-1){
        ll next =i+1;
        if(h[i]<h[next]) h[next]--;
        if(h[i]>h[next]){
            can=false;
            break;
        }
    }
    cout<< (can? "Yes":"No");
    return;
}

int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
    //ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        @SuppressWarnings("resource")
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0 ; i < n ; i++) {
            a[i] = sc.nextInt();
        }
        int count = 0;
        int idx = 1;
        for (int i = 0 ; i < n ; i++) {
            if (a[i] != idx) {
                count++;
            } else {
                idx++;
            }
        }
        if (count == n) {
            System.out.println(-1);
        } else {
            System.out.println(count);
        }
    }

}


Measured memory_bytes: 66120
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for (ll i=0; i<n; ++i)
#define all(c) begin(c),end(c)
#define PI acos(-1)
#define oo LLONG_MAX
template<typename T1, typename T2>
bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
template<typename T1, typename T2>
bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
/*

*/

struct Z{
  ll y;
  ll x;
  ll depth;
};

ll H, W, K, y, x, depth, xs, ys, xg, yg;
vector<ll> y_vec = {1, 0, -1, 0};
vector<ll> x_vec = {0, 1, 0, -1};
vector<vector<ll>> A;
auto comp = [](Z a, Z b){return a.depth > b.depth;};
priority_queue<Z, vector<Z>, decltype(comp)> Q{comp};

ll bfs(){
  while(!Q.empty()){
    Z now = Q.top(); Q.pop();
    y = now.y, x = now.x, depth = now.depth;
    if (y == yg && x == xg){
      while(!Q.empty())
        Q.pop();
      return A[yg][xg];
    }
    
    for(ll i=0; i<4; i++){
      Z next={y + y_vec[i], x + x_vec[i], depth};
      if (A[next.y][next.x] == -1) continue;
      if (A[next.y][next.x] <= depth) continue;
      A[next.y][next.x] = depth;
      Q.push(next);
    }
  
    for(ll i=-2; i<=2; i++){
      for(ll j=-2; j<=2; j++){
        Z next={y + i, x + j, depth + 1};
        if(A[next.y][next.x] == -1) continue;
        if(A[next.y][next.x] <= next.depth) continue;
        A[next.y][next.x] = next.depth;
        Q.push(next);
      }
    }
  }
  return oo;
}

//A[y][x], A(x,y)として管理
int main(){
  cin >> H >> W;
  cin >> ys >> xs >> yg >> xg;
  ys++;
  xs++;
  yg++;
  xg++;
  A.assign(H+4, vector<ll>(W+4, -1));
  for(int i=2; i<=H+1; i++){
    for(int j=2; j<=W+1; j++){
      char a; cin >> a;
      if (a == '#') continue;
      A[i][j] = oo;
    }
  }
  A[ys][xs] = 0;
  Z start = {ys, xs, 0};
  Q.emplace(start);
  ll ans = bfs();
  if(ans == oo) ans = -1;
  cout << ans << endl;
/*rep(i, H){
  rep(j, W){
    cout<<A[i+2][j+2];
  }
  cout << endl;
}*/
}


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

int N,K;
vector<int> v;

int main (){
	cin >> N >> K;
	int cnt = 0;
	
	for(int i=0;i<N;i++){
		int x;
		cin >> x;
		if(x >= K) cnt++;
	}
	cout << cnt << endl;
	return 0; 
}

Measured memory_bytes: 3588
#include <iostream>
#include <string>
using namespace std;
int m = 0;
string s;
int main() {
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    int count = 0;
    for (int j = i; j < s.length(); j++) {
      if (s[j] == 'A' || s[j] == 'T' || s[j] == 'G' || s[j] == 'C') {
        count++;
      } else {
        break;
      }
    }
    if (m < count) {
      m = count;
    }
  }
  cout << m << '\n';
  return 0;
}

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

const int mod = 998244353;
const int N = 305;

int dp[N][N][N];
vector<int> ones;
int one_cnt;
int K;

int solve(int var, int op, int pref) {
    if(op > K or op < 0) return 0;
    if(var == ones.size()) return pref == one_cnt;
    if(dp[var][op][pref] != -1) return dp[var][op][pref];
    int ans = 0;
    int kone = ones[var] - (var > 0 ? ones[var-1] : 0);
    for(int x = max(0, ones[var]-pref); x + pref <= one_cnt; x++) {
        int new_op = op+max(0, x-kone);
        ans += solve(var + 1, new_op , x+pref);
        if(ans >= mod) ans -= mod;
    }
    return dp[var][op][pref] = ans;
}


int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    string s;
    cin >> s >> K;
    s.insert(s.begin(), '0');
    s.push_back('0');
    vector<int> zeros;
    for(int i = 0; i < s.size(); i++) {
        if(s[i] == '0') zeros.push_back(i);
    }
    for(int i = 1; i < zeros.size(); i++) {
        int l = zeros[i-1]+1, r = zeros[i]-1;
        ones.push_back(max(0,r-l+1));
    }
//    for(int x : ones) {
//        cout << x << " ";
//    }
//    cout << endl;
    for(int x : ones) one_cnt += x;
    for(int i = 1; i < ones.size(); i++) {
        ones[i] += ones[i-1];
    }
    memset(dp, -1, sizeof dp);
    cout << solve(0, 0, 0) << endl;
    return 0;
}



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

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<ll,ll> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	
	VI cnt(5);
	const string mt ="MARCH";
	int n;
	cin >>n;
	rep(i, n){
		string s; cin >>s;
		int ps = mt.find(s[0]);
		if(ps == -1) continue;
		cnt[ps]++;
	}
	ll ans = 0;
	rep(i, 1<<5){
		if(__builtin_popcount(i) != 3) continue;
		ll pre = 1;
		rep(j, 5) if(i>>j &1) pre *= cnt[j];
		ans += pre;
	}
	cout << ans <<"\n";
	return 0;
}


Measured memory_bytes: 256
n = int(input())
li = []
work = []
for i in range(n):
    a,b = map(int, input().split())
    li.append((b,b-a,i))
    work.append(a)
li.sort()
now = 0
for bb,s,w in li:
    if now > s:
        print("No")
        exit()
    else:
        now += work[w]
print("Yes")

Measured memory_bytes: 94936
n = int(input())

d = {}
lst = ['AC', 'WA', 'TLE', 'RE']
for i in range(n):
    s = input()
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

for i in lst:
    if i in d:
        print(i, 'x', d[i])
    else:
        print(i, 'x 0')


Measured memory_bytes: 9200
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const int INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};

int main(){
  ll h,w; cin>>h>>w;
  ll ans;
  if(h==1||w==1)
  ans=1;
  else if(h%2==0){
    ans=w*h/2;
  }else{
    if(w%2==0) ans=w*h/2;
    else ans=h*(w-1)/2+h/2+1;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main(String[] arsg) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
		int count = Integer.parseInt(br.readLine());
		if(count == 0) break;
		
		String str[] = new String[count];
		str = br.readLine().split(" ");
		double[] s = new double[count];
		double sum = 0;
		for(int i = 0;i<count;i++){
			s[i] = Double.parseDouble(str[i]);
			sum += s[i];
		}
		double average = (double) sum/count;
		double SUM = 0;
		for(int i = 0;i<count;i++){
			SUM += Math.pow(s[i]-average,2);
		}
		double SUM1 = (double) SUM/count;
		System.out.println(Math.sqrt(SUM1));
		}
	}
}

Measured memory_bytes: 26204
# -*- coding: utf-8 -*-
A, B, C, K = map(int, input().split())


def calcFairness(A, B, K):
    if abs(A - B) > 10 ** 18:
        return 'unfair'
    else:
        return ((-1) ** ( K % 2)) * (A - B)


print(calcFairness(A, B, K))


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf (ll)(1e18)
#define mod 1000000007


int main()
{
    int t=1;
    //cin>>t;
    while( t-- )
    {
        string s;
        cin>>s;
        int ans=0;
        int ctr=0;

        for( int i=0 ; i<3 ; i++ )
        {
            if( s[i]=='R' )
                ctr++;
            else
            {
                ans=max( ans,ctr );
                ctr=0;
            }
        }
        ans=max( ans,ctr );
        cout<<ans;
    }

    return 0;
}












Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	string N;
  	cin>>N;
  	ll sum=0;	
  
  	for(int i=0;i<N.size();i++){
     	 sum+=N[i]-48;
    }
  
  	if(sum%9==0){
     	cout<<"Yes"<<endl; 
    }else{
     	cout<<"No"<<endl; 
    }
}

Measured memory_bytes: 3716
#include <iostream>
#include <vector>
#include <array>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>

// MARK: - header
namespace {
using namespace std;
using ll = long long;
using ull = unsigned long long;
}

// MARK: - answer

int X, Y, Z, K;
vector<ll> A, B, C;

void input() {
    cin >> X >> Y >> Z >> K;
    A.resize(X);
    for (auto& a : A)
        cin >> a;
    B.resize(Y);
    for (auto& b : B)
        cin >> b;
    C.resize(Z);
    for (auto& c : C)
        cin >> c;
}

bool cut_search(ll p, vector<ll>* sums = nullptr) {
    int cnt = 0;
    for (auto a : A) {
        for (auto b : B) {
            for (auto c : C) {
                ll sum = 0ll+a+b+c;
                if (sum < p)
                    break;
                cnt++;
                if (sums)
                    sums->push_back(sum);
                else if (cnt >= K)
                    return true;
            }
        }
    }
    return cnt >= K;
}

void solve() {
    sort(A.rbegin(), A.rend());
    sort(B.rbegin(), B.rend());
    sort(C.rbegin(), C.rend());
    ll l = 0, r = 0ll+A[0]+B[0]+C[0];
    ll p = 0;
    while (l <= r) {
        ll c = (l+r)/2;
        if (cut_search(c)) {
            p = c;
            l = c + 1;
        } else {
            r = c - 1;
        }
    }
    vector<ll> sums;
    cut_search(p, &sums);
    sort(sums.rbegin(), sums.rend());
    for (int i = 0; i < K; i++)
        cout << sums[i] << endl;
}

int main() {
    input();
    solve();
    
    return 0;
}



Measured memory_bytes: 133216