akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  ll n, m;
  cin >> n >> m;
  
  ll a, b, c;
  vector<tuple<int, int, ll>> edge(m);
  vector<vector<ll>> dist(n, vector<ll>(n, INF));
  for (int i = 0; i < m; i++){
    cin >> a >> b >> c;
    a--; b--;
    edge[i] = make_tuple(a, b, c);
    dist[a][b] = c;
    dist[b][a] = c;
  }
  for (int i = 0; i < n; i++){
    dist[i][i] = 0;
  }


  

  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
      for (int k = 0; k < n; k++){
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
      }
    }
  }

  for (int i = 0; i < n; i++){
    for (int j = 0; j < n; j++){
//      cout << i << " " << j << " " << dist[i][j] << endl;
    }
  }

  ll res = 0;
  for (int i = 0; i < m; i++){
    int ok = 0;
    for (int j = 0; j < n; j++){
      for (int k = 0; k < n; k++){
        if (dist[j][k] == dist[j][get<0>(edge[i])] + dist[get<1>(edge[i])][k] + get<2>(edge[i]))
          ok = 1;
      }
    }
    if (!ok)
      res++;
  }

  cout << res << endl;

  return 0;
}


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

#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
typedef pair<int,int> P;

//-----------------------------------------------------------------------

int dy[]={-1,0,1,0};
int dx[]={0,-1,0,1};
const int INF=1e9;
int W,H;
int t[50][50][2];
int d[50][50];

bool isField(int y,int x){
    return (0<=y && y<H && 0<=x && x<W);
}
bool check(int y,int x,int dir){
    if(dir==0) return t[y-1][x][1];
    if(dir==1) return t[y][x-1][0];
    if(dir==2) return t[y][x][1];
    if(dir==3) return t[y][x][0];
}

int bfs(){
    REP(i,H) REP(j,W) d[i][j]=INF;
    d[0][0]=1;
    queue<P> que;
    que.push(P(0,0));

    while(!que.empty())
    {
	int y=que.front().first;
	int x=que.front().second;
	que.pop();
	if(y==H-1 && x==W-1) return d[H-1][W-1];
	REP(i,4){
	    int ny=y+dy[i], nx=x+dx[i];
	    if(isField(ny,nx) && !check(y,x,i) && d[ny][nx]==INF){
		d[ny][nx]=d[y][x]+1;
		que.push(P(ny,nx));
	    }
	}
    }
    return 0;
}

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

    while(cin>>W>>H,W){
	REP(i,H-1){
	    REP(j,W-1) cin>>t[i][j][0];
	    REP(j,W) cin>>t[i][j][1];
	}
	REP(j,W-1) cin>>t[H-1][j][0];

	cout<<bfs()<<endl;
    }
}


Measured memory_bytes: 3160
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

void solve(int a, int b, int k){
    set<int> ans;
    for (int i=a; i<a+k; ++i){
        if(a <= i && i <= b){
            ans.insert(i);
        }
    }
    for (int i=b; i>b-k; --i){
        if(a <= i && i <= b){
            ans.insert(i);
        }
    }
    for (int i : ans){
        cout << i << endl;
    }
    return;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, k;
    cin >> a >> b >> k;
    solve(a, b, k);
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef long double lb;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)

int main() {
    ll N;
    cin >> N;
    vector<lb> v(N);
    REP(i,N){
        cin >> v[i];
    }

    sort(v.begin(),v.end());
    lb result=v[0];
    for(ll i=1;i<N;i++){
        result = (result+v[i])/2;
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout<< (x) << " "
int main(){
    string s;cin>>s;sort(s.begin(),s.end());
    if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])co("Yes");
    else co("No");
}


Measured memory_bytes: 256
/// Containers Start
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
/// C Header Files
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <math.h>
#include <stdio.h>
/// Containers End

using namespace std;

/// Math Start
#define PI acos(-1.0)
#define Pi 3.141592653589793
#define EPS (1e-7)
#define INF (0x3f3f3f3f)
#define MAX_V 100100
/// Math End

/// Extra Start
#define nn '\n'
#define pb push_back
#define ull unsigned long long
#define ll long long
#define MOD 1000000007
#define sz(a) int((a).size())
#define space " "
#define All(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
/// Extra End

#define rep(i, n) for (int i = 0; i < n; i++)
#define Cini(a)                                                                \
    int a;                                                                     \
    cin >> a;
#define Cinii(a, b)                                                            \
    int a, b;                                                                  \
    cin >> a >> b;
#define Ciniii(a, b, c)                                                        \
    int a, b, c;                                                               \
    cin >> a >> b >> c;
#define Cins(s)                                                                \
    string s;                                                                  \
    cin >> s;
#define Cinss(s1, s2)                                                          \
    string s1, s2;                                                             \
    cin >> s1 >> s2;
#define Cinc(c)                                                                \
    char c;                                                                    \
    cin >> c;
/// Functions End

/// Debug Start
#define deb(x) cout << #x << ": " << x << endl
#define deb2(x, y) cout << #x << ": " << x << '\t' << #y << ": " << y << endl
#define deb3(x, y, z)                                                          \
    cout << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": "   \
         << z << endl
/// Debug End

int dx[] = {-1, 0, 1, 0};
int dy[] = {0, -1, 0, 1};

/**>>>>>>>>>>>>>>>>>>> END <<<<<<<<<<<<<<<<<<**/

/// template

int main(void) {
    cin.sync_with_stdio(false);
    cin.tie(0);
    ll a, b, c;
    cin >> a >> b >> c;
    if (b > c - 1) {
        cout << b + c << nn;
    } else {
        c = c - (b + 1);
        if (c > a) {
            cout << 2 * b + 1 + a << nn;
        } else {
            cout << 2 * b + 1 + c << nn;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
signed main(){
  int N,K; cin>>N>>K;
  int ans=0;
  if(K==0)
    ans=N*N;
  else{
  REP(i,K+1,N){
    ans+=N/i*(i-K);
    int k=max(0LL,N%i-K+1);
    ans+=k;
  }
  }
  cout<<ans<<endl;
  }




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

long long lcm(long long a, long long b) {
    long long x = a * b;
    if (a < b) {
        long long tmp = a;
        a = b;
        b = tmp;
    }
    
    long long r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return x/b;
}

int main(void){
    long long N, M;
    cin >> N >> M;
    
    vector<long long> a(N);
    for (int i = 0; i < N; i++)
        cin >> a[i];
    long long min_kobai = 1;
    int div2count = 0;
    bool flag = false;
    for (int i = 0; i < N; i++) {
        min_kobai = lcm(min_kobai, a[i]);
        int x = a[i];
        if (i == 0) {
            while (x % 2 == 0) {
                div2count++;
                x /= 2;
            }
        }
        else {
            if (x < (int)pow(2, div2count) || x % (int)pow(2, div2count) != 0 || x % (int)pow(2, div2count+1) == 0) {
                flag = true;
            }
        }
    }
    
    if (flag || div2count == 0) {
        cout << "0" << endl;
    }
    else {
        min_kobai = min_kobai / 2;
        long long result = (M / min_kobai + 1) / 2;
        cout << result << endl;
    }
}

Measured memory_bytes: 1024
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cctype>
#include<unordered_map>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<iomanip>
#include<sstream>
#include<cstdlib>
#include<ctime>
#include<list>
#include<deque>
#include<bitset>
#include<fstream>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint()
{
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//
const int maxn=1e5+5;
vector<int>G[maxn];
int n,m,res=INF;
priority_queue<iiii,vector<iiii >,greater<iiii > >pq;
unordered_map<int,int>dis[maxn];
unordered_map<int,vector<int> >g[maxn];
//
iiii mp(int x,int y,int z)
{
	return make_pair(x,make_pair(y,z));
}
int main()
{
	n=getint();m=getint();
	rep(i,m)
	{
		int x=getint()-1,y=getint()-1,z=getint();
		G[x].push_back(z);
		G[y].push_back(z);
		g[x][z].push_back(y);
		g[y][z].push_back(x);
	}
	dis[0][0]=0;
	pq.push(mp(0,0,0));
	while(!pq.empty())
	{
		int len=pq.top().F;
		pii u=pq.top().S;
		pq.pop();
		if(dis[u.F][u.S]<len)continue;
		if(u.S!=0&&(dis[u.F].find(0)==dis[u.F].end()||dis[u.F][0]>len))
		{
			dis[u.F][0]=len;
			pq.push(mp(len,u.F,0));
		}
		if(!u.S)
		{
			for(int i:G[u.F])
			{
				if(dis[u.F].find(i)!=dis[u.F].end()&&dis[u.F][i]<=len+1)continue;
				dis[u.F][i]=len+1;
				pq.push(mp(len+1,u.F,i));
			}
		}
		else
		{
			for(int to:g[u.F][u.S])
			{
				if(dis[to].find(u.S)!=dis[to].end()&&dis[to][u.S]<=len)continue;
				dis[to][u.S]=len;
				pq.push(mp(len,to,u.S));
			}
		}
	}
	for(pii i:dis[n-1])res=min(res,i.S);
	if(res==INF)res=-1;
	printf("%d\n",res);
	return 0;
}


Measured memory_bytes: 79892
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define endl "\n"
#define pii pair<int,int> 
#define ff first
#define ss second
#define mii map<int,int>
#define si set<int>
#define sti stack<int>
#define qi queue<int>
#define vi vector<int>
#define pq priority_queue<int>
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//const int M=1e9+7;

int power(int n,int x,int M){
	if(x==0) return(1);
	int y=power(n,x/2,M);
	y=(y*y)%M;
	if(x%2==0) return(y);
	else return((y*n)%M);
}

void solve(){
	int n;
	cin>>n;
	string s; cin>>s;
	int bits=0;
	for(auto x:s) if(x=='1') bits++;
	int x1=0,x2=0;
	if(bits-1>0){
		for(int i=0;i<s.size();i++){if(s[i]=='1') x1=(power(2,n-i-1,bits-1)+x1)%(bits-1);}
	}
	for(int i=0;i<s.size();i++){if(s[i]=='1') x2=(power(2,n-i-1,bits+1)+x2)%(bits+1);}
	for(int i=0;i<s.size();i++){
		int x=0;
		if(s[i]=='1'){
			if(bits-1==0){cout<<0<<endl;continue;}
			else{
				x=(x1+(bits-1)-power(2,n-i-1,bits-1))%(bits-1);
			}
		}
		else{
			x=(x2+power(2,n-i-1,bits+1))%(bits+1);
		}
		int ans=1;
		while(x!=0){
			int y=__builtin_popcount(x);
			x%=y;
			ans++;
		}
		cout<<ans<<endl;
	}
}

int32_t main(){
	int t=1;
	//cin>>t;
	while(t--){
		solve();	
	}
}

Measured memory_bytes: 3736
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,e)for(int i=0;i<e;i++)
#define grade(a) cout << a << endl
using namespace std;

int main(){
    int i;
    char s[1200];
    fgets(s,1200,stdin);
    int l = strlen(s)-1;
    s[l] = '\0';
    rep(i,l){
        if(islower(s[i]))s[i] = toupper(s[i]);
        else if(isupper(s[i]))s[i] = tolower(s[i]);
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 3080
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {

    string S;
    cin >> S;
    string out = "ARC";
    if(S=="ARC") out = "ABC";
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3628
# coding: utf-8
# Your code here!
cost=list(map(int,input().split()))

for i in range(4):
    cost[i]/=2**(i-2)
    if i!=3:
        cost[i]=int(cost[i])
    
N=int(input())

if min(cost)==cost[3]:
    temp=int(cost[3]*2)
    print(((N//2)*temp+(N%2)*min(cost[:3])))
else:
    print((min(cost)*N))

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

#define rep(countName, left, right, up) for (ll countName = left; countName < right; countName += up)
#define rev(countName, right, left, down) for (ll countName = right - 1; countName >= left; countName -= down)

auto solve1(int n, int k, string s)
{
    string str = s;
    str[k - 1] += 'a' - 'A';
    return str;
}

auto solve2(int n, int k, string s)
{
    string str = s;

    if (str[k - 1] == 'A')
    {
        str[k - 1] = 'a';
    }
    else if (str[k - 1] == 'B')
    {
        str[k - 1] = 'b';
    }
    else if (str[k - 1] == 'C')
    {
        str[k - 1] = 'c';
    }

    return str;
}

auto solve3(int n, int k, string s)
{

    for (int i = 0; i < n; i++)
    {
        if (i == (k - 1))
        {
            cout << (char)(s[i] + ('a' - 'A'));
        }
        else
        {
            cout << s[i];
        }
    }
    cout << endl;
}

int main(void)
{

    int n, k;
    string s;

    cin >> n >> k >> s;

    //cout << solve1(n, k, s) << endl;
    //cout << solve2(n, k, s) << endl;
    solve3(n, k, s);

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>

int cum[100001];

int main()
{
  int n, k;
  char s[100001];
  scanf("%d%d%s", &n, &k, s);
  int blk[100000];
  int* dst = blk;
  for (char *p = s; *p;)
  {
    char* q = p;
    while (*p && *p == *q) ++p;
    *dst++ = p - q;
  }
  int nblk = dst - blk;
  for (int i = 0; i < nblk; ++i)
  {
    cum[i + 1] = cum[i] + blk[i];
  }

  int ans = 0;
  if (*s == '0')
  {
    ans = cum[std::min(2 * k, nblk)];
  }
  for (int i = ('1' - *s); i < nblk; i += 2)
  {
    ans = std::max(ans, cum[std::min(i + 2 * k + 1, nblk)] - cum[i]);
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;



int32_t main(){
	IOS
	int n,m;cin>>n>>m;
	vector<int>g[n+1];
	for(int i=1;i<=m;i++){
		int u,v;cin>>u>>v;
		g[u].push_back(v);
		//g[v].push_back(u);
	}
	int s,t;cin>>s>>t;
	int dis[n+1][3],inq[n+1][3];
	for(int i=0;i<=n;i++){
		for(int j=0;j<3;j++){
			dis[i][j]=1e15;
			inq[i][j]=0;
		}
	}
	dis[s][0]=0;
	queue<pair<int,int>>q;
	q.push({s,0});
	inq[s][0]=1;
	while( q.size() ){
		int u = q.front().first , x = q.front().second; q.pop(),inq[u][x]=0;
		for(auto v:g[u]){
			if( dis[v][(x+1)%3] > dis[u][x] + 1){
				dis[v][(x+1)%3] = dis[u][x] + 1;
				if( !inq[v][(x+1)%3] ){
					q.push({v,(x+1)%3});
					inq[v][(x+1)%3]=1;
				}
			}
		}
	}
	cout << ( dis[t][0]/3 < 1e10 ? dis[t][0]/3 : -1 ) << endl;
}
/*
 * long long or int?
 * index out of bound?
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 13736
#include<stdio.h>
long long s=0,n,m,i,j,k,d[3][110],r[3][110],rr[3][110],c[110][110][110],b;
int main(){
	scanf("%d %d",&n,&m);
	for(i=0;i<n*2;i++){
		for(j=0;j<3;j++){
			scanf("%d",&d[j][i]);
			for(k=i;k&&d[j][r[j][k-1]]>d[j][i];k--)r[j][k]=r[j][k-1];
			r[j][k]=i;
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<3;j++)rr[j][r[j][i]]=i;
	}
	for(i=0;i<n;i++){
		for(j=0;j<8;j++){
			b=0;
			for(k=j;k;k/=2)b+=k%2;
			c[rr[0][i*2+(j/1%2)]][rr[1][i*2+(j/2%2)]][rr[2][i*2+(j/4%2)]]=1-(b%2*2);
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[i][j][k+1]+=c[i][j][k];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[i][k+1][j]+=c[i][k][j];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++)c[k+1][i][j]+=c[k][i][j];
		}
	}
	for(i=0;i<n*2;i++){
		for(j=0;j<n*2;j++){
			for(k=0;k<n*2;k++){
				if(c[i][j][k]>=m)s+=(d[0][r[0][i+1]]-d[0][r[0][i]])
						   *(d[1][r[1][j+1]]-d[1][r[1][j]])
						   *(d[2][r[2][k+1]]-d[2][r[2][k]]);
			}
		}
	}
	printf("%lld\n",s);
	return 0;
}

Measured memory_bytes: 10932
def main():
    buf = input()
    buflist = buf.split()
    N = int(buflist[0])
    x = int(buflist[1])
    buf = input()
    buflist = buf.split()
    a = list(map(int, buflist))
    eaten = 0
    for i in range(1,len(a)):
        need_to_eat = a[i-1] + a[i] - x
        if need_to_eat <= 0:
            continue
        else:
            eaten += need_to_eat
            if need_to_eat > a[i]:
                a[i-1] -= need_to_eat - a[i]
                need_to_eat = a[i]
            a[i] -= need_to_eat
    print(eaten)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15516
#include<cstdio>
#include<algorithm>
using namespace std;

int getMaxVlue(int [][2], int , int );

int main(){

  int n,w;
  scanf("%d%d",&n,&w);
  int data[n+1][2];
  for(int i=1;i<=n;i++)
    scanf("%d%d",&data[i][0],&data[i][1]);
  printf("%d\n",getMaxVlue(data,n,w));

  return 0;
}

int getMaxVlue(int data[][2], int n, int w)
{

  int dp[w+1];
  for(int i=0;i<=w;i++)
    dp[i]=0;

  for(int i=1;i<=n;i++)
    for(int j=1;j<=w;j++)
      if(j-data[i][1]>=0)
        dp[j]=max(dp[j],dp[j-data[i][1]]+data[i][0]);
  return dp[w];
}

Measured memory_bytes: 1064
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()


int main()
{
	ll d, g;
	cin >> d >> g;

	vector<pair<ll, ll>> p(d);
	for (int i = 0; i < d; i++)
	{
		ll a, b;
		cin >> a >> b;

		p.at(i).first = a;
		p.at(i).second = b;
	}

	ll res = inf;
	for (int bit = 0; bit < (1 << d); bit++)
	{
		ll sum = 0;
		ll cnt = 0;
		for (int i = 0; i < d; i++)
		{
			if (bit & (1 << i))
			{
				cnt += p.at(i).first;
				sum += 100 * (i + 1) * p.at(i).first + p.at(i).second;
			}
		}

		if (sum >= g)
		{
			res = min(res, cnt);
		}
		else
		{
			for (int i = d - 1; i >= 0; i--)
			{
				if (bit & (1 << i))
				{
					continue;
				}
				else
				{
					for (int j = 0; j < p.at(i).first; j++)
					{
						if (sum >= g)
						{
							break;
						}
						sum += 100 * (i + 1);
						cnt++;
					}
				}
			}
			res = min(res, cnt);
		}
	}

	cout << res << endl;
}

Measured memory_bytes: 256
n = int(input())
print('Yes' if n > 3 and (
    (n % 4 == 0) or (n >= 7 and (n - 7) % 4 == 0) or
    (n >= 14 and (n - 14) % 4 == 0) or (n >= 21 and (n - 21) % 4 == 0)
) else 'No')


Measured memory_bytes: 2940
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ll h, w; cin >> h >> w;
    vvl c(10, vl(10, 0));
    REP(i, 10) REP(j, 10){
        cin >> c[i][j];
    }
    vvl a(h, vl(w, 0)); REP(i, h) REP(j, w) cin >> a[i][j];
    
    REP(k, 10){
        REP(i, 10) REP(j, 10){
            c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
        }
    }
    
    ll ans = 0;
    REP(i, h) REP(j, w){
        if(a[i][j] == -1) continue;
        ans += c[a[i][j]][1];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long int
#define INF INT_MAX
#define mod
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
bool sortbysec(const pair<ll,ll> &a,const pair<ll,ll> &b){return (a.second < b.second);}
ll gcd(ll a, ll b){if(a==0)return b;return gcd(b % a, a);}
int main()
{
	chutiyaap;
	ll n,k,res=0;
	cin>>n>>k;
	for(ll i=0;i<n;i++)
	{
		ll x;cin>>x;
		if(x>=k)res++;
	}
	cout<<res;
}


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

int eulerPhi(int n) {
  int ans = n;
  for(int i = 2; i * i <= n; ++i) {
    if(n % i == 0) {
      ans -= ans / i;
      while(n % i == 0) {
        n /= i;
      }
    }
  }
  if(n > 1) ans -= ans / n;
  return ans;
}

int main() {
  int n;
  cin >> n;
  cout << eulerPhi(n) << endl;
  return 0;
}

Measured memory_bytes: 3112
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
bool ok=false;
//ll fct[1000004];
set<ll>st;
void f(ll x)
{
    if(ok)
     return;
     for(ll i=1;i*i<=x;i++)
     {
         if(x%i==0)
         {
             ll a=i;
             ll b=x/i;
             if(a==b)
             {
                 a=i;
                 b=1;
             }
             if(a!=1)
             {
                 if(st.find(a)!=st.end())
                 {
                     ok=true;
                     return;
                 }
                 else
                 st.insert(a);
             }
             
             if(b!=1)
             {
                 if(st.find(b)!=st.end())
                 {
                     ok=true;
                     return;
                 }
                 else
                 st.insert(b);
             }
             
         }
     }
}


int main()
{
   ll n;
   cin>>n;
   vector<ll>v(n);
   for(ll i=0;i<n;i++)
   cin>>v[i];
   ll gcd=v[0];
   f(v[0]);
   for(ll i=1;i<n;i++)
   {
       gcd=__gcd(gcd,v[i]);
       f(v[i]);
       
   }
   if(!ok)
   cout<<"pairwise coprime"<<endl;
   else if(gcd==1)
   cout<<"setwise coprime"<<endl;
   else
   cout<<"not coprime"<<endl;
   
   
   
   
   
}

Measured memory_bytes: 11104
import sys
input=sys.stdin.readline

N = int(input())

def is753(s):
    return all(s.count(c) > 0 for c in "753")

a = []
def f(s):
    if int(s) > N:
        return
    if is753(s):
        a.append(s)
    for c in "753":
        f(str(int(s+c)))
f("0")
#print(a)

ans = 0
for s in a:
    ans += 1 if is753(s) else 0

print(ans)


Measured memory_bytes: 4860
#include <iostream>
#include <sstream>
#include <stdio.h>
#include<vector>
#include<climits>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<functional>
#include <numeric>
#include <map>
#define FORi(N) for(int i=0;i<N;++i)
#define FORj(N) for(int j=0;j<N;++j)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
ll gcd(ll m,ll n){
  if(n==0)return abs(m);
  return(gcd(n,m%n));
}
void putYN(bool b){
  if(b){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
}
int main(){
  ll N,Q;
  string S;
  cin>>N>>Q>>S;
  vector<ll> l(Q),r(Q);
  FORi(Q){
    cin>>l[i]>>r[i];
  }
  vector<ll> AC;
  FORi(S.size()-1){
    if(S[i]=='A'&&S[i+1]=='C')AC.push_back(i+1);
  }
  auto comp=[](ll a,ll b){return a<b;};
  FORi(Q){
    auto itr1 = lower_bound(AC.begin(),AC.end(),l[i]);
    auto itr2 = lower_bound(AC.begin(),AC.end(),r[i]);
    ll num = distance(itr1,itr2);
  	cout<<num<<endl;
  }
  return 0;
}


Measured memory_bytes: 3000
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (auto&& e : a) cin >> e;
  V<> l(n), r(n);
  l[0] = a[0];
  for (int i = 1; i < n; ++i) l[i] = max(l[i - 1], a[i]);
  r.back() = a.back();
  for (int i = n - 2; i >= 0; --i) r[i] = max(r[i + 1], a[i]);
  for (int i = 0; i < n; ++i) {
    cout << max(i ? l[i - 1] : 0, i + 1 < n ? r[i + 1] : 0) << '\n';
  }
}

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

#define pb push_back
#define ll long long int
#define mpi map<int, int>
#define vi vector<int>
#define si set<int>
#define pii pair<int, int>
#define vpi vector<pii>
#define vs vector<string>
#define pri priority_queue<int>
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define For(i, n) for (int i = 0; i < n; i++)
#define Ford(i, a, b) for (int i = a; i >= b; i--)
#define Rep(i, x, y) for (int i = x; i <= y; i++)
#define mem(a, b) memset(a, b, sizeof(a))
#define fastio                    \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)

double tick()
{
    static clock_t oldt, newt = clock();
    double diff = 1.0 * (newt - oldt) / CLOCKS_PER_SEC;
    oldt = newt;
    return diff;
}

int main()
{
    int n;
    cin >> n;
    if (n % 10 == 7 || (n / 10) % 10 == 7 || (n / 100) % 10 == 7)
        cout << "Yes\n";
    else
        cout << "No\n";
    cerr << "execution time is: " << tick() << "\n";
}


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

int main(){
int N=0;
int a,b,c;
string y="YES";
string n="NO";
cin>>N;
for(int i=0;i<N;i++){
cin>>a>>b>>c;
if(a*a+b*b==c*c||a*a-b*b==c*c||b*b-a*a==c*c){cout<<y<<endl;}
else{cout<<n<<endl;}
}
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
int main(){
    int h,w; cin >> h >> w;
    vector<vector<char>> S(h,vector<char>(w));

    rep(i,h){
        rep(j,w){
            cin >> S[i][j];
        }
    }
    rep(i,h){
        rep(j,w){
            if(S[i][j] == '#'){
                continue;
            }else{
                char cnt = '0';
                if(i != 0 && S[i-1][j] == '#'){
                    cnt++;
                }
                if(i != h-1 && S[i+1][j] == '#'){
                    cnt++;
                }
                if(j != 0 && S[i][j-1] == '#'){
                    cnt++;
                }
                if(j != w-1 && S[i][j+1] == '#'){
                    cnt++;
                }
                if(i != 0 && j != 0 && S[i-1][j-1] == '#'){
                    cnt++;
                }
                if(i != h-1 && j != w-1 && S[i+1][j+1] == '#'){
                    cnt++;
                }
                if(i != h-1 && j != 0 && S[i+1][j-1] == '#'){
                    cnt++;
                }
                if(i != 0 && j != w-1 && S[i-1][j+1] == '#'){
                    cnt++;
                }

                S[i][j] = cnt;
            }
        }
    }
    rep(i,h){
        rep(j,w){
            cout << S[i][j];
            if(j == w-1){
                cout << endl;
            }
        }
    }
}




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

using pll = pair<long, long>;
constexpr long MOD = 1000000007;

struct UnionFind {
	//自身が親であれば、その集合に属する頂点数に-1を掛けたもの
	//そうでなければ親のid
	vector<long> r;

	explicit UnionFind(long N) {
		r = vector<long>(N, -1);
	}

	long root(long x) {
		if (r[x] < 0) return x;
		return r[x] = root(r[x]);
	}

	bool unite(long x, long y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;
		if (r[x] > r[y]) swap(x, y);
		r[x] += r[y];
		r[y] = x;
		return true;
	}

	long size(long x) {
		return -r[root(x)];
	}
};

int main() {
	long n, m; cin >> n >> m;
	UnionFind UF(n);
	for (long i = 0; i < m; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		UF.unite(a, b);
	}

	long ans = 0;
	for (long i = 0; i < n; i++) {
		ans = max(ans, UF.size(i));
	}

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


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

int main(){
    int N; cin>>N;
    vector<int> h(N);
    for(int i=0;i<N;i++) cin>>h[i];

    int res=0;
    while(true){
        if(*max_element(h.begin(),h.end())==0)break;

        int i=0;
        while(i<N){
            if(h[i]==0)++i;
            else{
                res++;
                while(i<N && h[i]>0){
                    h[i]--;
                    i++;
                }
            }
        }
    }
    cout<<res<<endl;
}

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

int main() {
  const int mod = 1000000007;
  int n;
  cin >> n;
  uint64_t ans = 1;
  map<int, int> s;
  s[-1] = 3;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    ans *= s[a - 1];
    ans %= mod;
    s[a - 1]--;
    s[a]++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<long long>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    auto f = [](int n) {
        if (~n&1) return n/2;
        else return 3*n+1;
    };

    int s;
    cin >> s;
    set<int> a;
    for (int i = 1; ; i++) { 
        if (i == 1) a.insert(s);
        else {
            s = f(s);
            if (a.count(s)) {
                cout << i << endl;
                return 0;
            } else {
                a.insert(s);
            }
        }
    }
}

Measured memory_bytes: 256
while True:
    n,k = map(int, input().split())
    if n == k == 0:
        break
    s = [int(x) for x in input().split()]
    for _ in range(n):
        b = [int(x) for x in input().split()]
        for i in range(k):
            s[i] -= b[i]
    print("Yes" if min(s) >= 0 else "No")

Measured memory_bytes: 7716
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;


int main()
{
    int N;
    string s;
    cin >> N >> s;
    int ans = 0;

    for(int i = 0;i < N;i++)
    {
        if(s.substr(i, 3) == "ABC")
        {
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> N >> M >> K;
    vector<ll> a(N), b(M);
    cin >> a;
    cin >> b;
    vector<ll> sb(M);
    sb[0] = b[0];
    REPS(i, M - 1) {
        sb[i] = sb[i - 1] + b[i];
    }
    auto itr = upper_bound(ALL(sb), K);
    ans = itr - sb.begin();
    dump(sb);
    dump(ans);
    REP(i, N) {
        K -= a[i];
        if (K < 0) {
            break;
        }
        auto itr = upper_bound(ALL(sb), K);
        ans = max(ans, (ll)(itr - sb.begin() + i + 1));
    }
    cout << ans << endl;
}

Measured memory_bytes: 8012
import heapq
from collections import deque
from enum import Enum
import sys
import math
from _heapq import heappush, heappop
import copy
from test.support import _MemoryWatchdog

BIG_NUM = 2000000000
HUGE_NUM = 99999999999999999
#MOD = 1000000007
MOD = 10000
EPS = 0.000000001
sys.setrecursionlimit(100000)


while True:

    N,M = map(int,input().split())
    if N == 0 and M == 0:
        break

    table = [list(map(float,input().split())) for _ in range(N)]

    dp = [[0]*N for _ in range(M)]
    for i in range(N):
        dp[0][i] = 1.0

    for i in range(1,M): #回数のループ
        for k in range(N):
            for p in range(N):
                dp[i][p] = max(dp[i][p],dp[i-1][k]*table[k][p])

    ans = 0.0
    for i in range(N):
        ans = max(ans,dp[M-1][i])

    print("%.2f"%(ans))


Measured memory_bytes: 14528
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	int a,b;
	cin >> a >> b;
	if (a < b) {
		cout << std::string(b, '0'+a) << endl;
	}
	else {
		cout << std::string(a, '0'+b) << endl;
	}
  return 0;
}


Measured memory_bytes: 256
using System;

namespace b
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();

            var maxCnt = 0;
            for(var i = 0; i < s.Length; i++){
                for(var j = 0; i + j < s.Length; j++){
                    if(s[i + j] != 'A' && s[i + j] != 'G' && s[i + j] != 'C' && s[i + j] != 'T'){
                        break;
                    }else{
                        maxCnt = Math.Max(maxCnt, j + 1);
                    }
                }
            }

            Console.WriteLine(maxCnt);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>

int main()
  {
  int A, N;
  scanf( "%d", &N );
  scanf( "%d", &A );
  if( N%500 <= A )
     {
       printf( "Yes\n" );
    }
  else
    {
    printf( "No\n" );
    }
  return 0;
  }


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

using namespace std;

int main(void){
    long long a, v;
    cin >> a >> v;
    
    long long b, w;
    cin >> b >> w;
    
    long long t;
    cin >> t;
    
    if (v <= w){
        cout << "NO" << endl;
        return 0;
    }
    
    long long dist = abs(a-b);
    long long speed = v - w;
 
    for (int i = 0; i < t; i++){
        dist -= speed;
        if (dist <= 0){
            cout << "YES" << endl;
            return 0;
        }
    }
    
    cout << "NO" << endl;
    return 0;
}


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

int n, a[100004];
long long lsum[100004], rsum[100004];
priority_queue<int,vector<int>,greater<int>> l;
priority_queue<int,vector<int>,less<int>> r;

int main() {
	ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n;
	int t;
	memset(lsum,0,sizeof(lsum));
	memset(rsum,0,sizeof(rsum));
	for(int i = 0;i<n;i++)
	{
		cin>>t;
		l.push(t);
		lsum[0] += t;
	}
	for(int i = 0;i<n;i++)	cin>>a[i];
	for(int i = 0;i<n;i++){
		cin>>t;
		r.push(t);
		rsum[n] += t;
	}
	for(int i = 0;i<n;i++){
		int x = l.top();
		lsum[i+1] = lsum[i];
		if(x<a[i]){
			l.pop();
			l.push(a[i]);
			lsum[i+1] += a[i]-x;
		}
	}
	for(int i = n-1;i>=0;i--){
		int x = r.top();
		rsum[i] = rsum[i+1];
		if(x>a[i]){
			r.pop();
			r.push(a[i]);
			rsum[i] += a[i]-x;
		}
	}
	long long ans = lsum[0]-rsum[0];
	for(int i = 1;i<=n;i++){
		ans = max(ans,lsum[i] - rsum[i]);
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 3320
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		BitSet multiple = new BitSet(1000002);
		BitSet bs = new BitSet(1000002);

		for (int i = 0; i < N; i++) {
			int a = Integer.parseInt(sc.get());
			if (bs.get(a)) multiple.set(a);
			bs.set(a);
		}

		for (int i = bs.nextSetBit(0); i >= 0; i = bs.nextSetBit(i + 1)) {
			for (int j = i + i; bs.nextSetBit(j) >= 0; j += i) {
				bs.clear(j);
			}
		}

		bs.andNot(multiple);

		System.out.println(bs.cardinality());
	}
}

class Main {
	public static void main(String... args) {
		System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		var reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
		System.out.flush();
	}
}

Measured memory_bytes: 53776
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>

int main()
{
	int n;
	int d, min, max;
	long long sum;

	scanf("%d%d", &n, &d);
	sum = min = max = d;
	while (--n > 0) {
		scanf("%d", &d);
		if (d < min) min = d;
		if (d > max) max = d;
		sum += d;
	}
	printf("%d %d %lld\n", min, max, sum);
	return 0;
}



Measured memory_bytes: 2108
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        String[] lines = getStdin();
        String str = lines[0];
        String[] num = str.split(" ");
        
        String tmp = num[0];
        String tmp1 = num[1];
        String tmp2 = num[2];
        num[0] = num[1];
        num[1] = tmp;
        num[0] = num[2];
        num[2] = tmp1;

        for (int i = 0; i < num.length; i++){
            System.out.print(num[i] + " ");
        }
        
   
    
    
        
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}


Measured memory_bytes: 38652
#include <stdio.h>
int main(){
int a;
int b;
int c;
int f;
scanf("%d %d %d %d",&a,&b,&c,&f);
int d,e;
d=a-b;
e=c-f;
if(d>0&&e>0) printf("%d",b+f);
else
if(d>0&&e<=0) printf("%d",b+c);
else
if(d<=0&&e>0) printf("%d",a+f);
else printf("%d",a+c);



return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>
#include <cmath>
#include <set>

using ll = long long;

class Myset{
public:
  ll offset;
  std::multiset<ll> st;
  Myset(){
    offset = 0;
  }
  void _insert(ll val){
    st.insert(val - offset);
  }
  int size(){
    return st.size();
  }
  ll front(){
    return *st.begin() + offset;
  }
  ll back(){
    return *st.rbegin() + offset;
  }
  void pop_back(){
    std::multiset<ll>::iterator it = st.end();
    it--;
    st.erase(it);
  }
  void pop_front(){
    std::multiset<ll>::iterator it = st.begin();
    st.erase(it);
  }
  void shift(ll val){
    offset += val;
  }
};

class Slope{
public:
  ll a;
  ll b;
  Myset f1, f2;
  Slope(){
    a = b = 0;
  }
  int size(){
    return f1.size() + f2.size();
  }

  void _insert(ll val){
    if(0 == f2.size() || val < f2.front())
      f1._insert(val);
    else
      f2._insert(val);
  }

  void balance(){
    while(a < f2.size()){
      f1._insert(f2.front());
      f2.pop_front();
    }
    while(f2.size() < a){
      f2._insert(f1.back());
      f1.pop_back();
    }
  }

  void minrange(ll val){
    f1.shift(-val);
  }
  void minrange2(ll val){
    b -= val * a;
    f2.shift(val);
  }
};

void _add(Slope &x, Slope &y){
  if(x.size() < y.size())
    std::swap(x, y);
  x.a += y.a;
  x.b += y.b;
  while(0 < y.f1.size()) {
    x._insert(y.f1.back());
    y.f1.pop_back();
  }
  while(0 < y.f2.size()){
    x._insert(y.f2.back());
    y.f2.pop_back();
  }
}

int main()
{
  int n;
  std::cin >> n;

  Slope basic;

  for(int i = 1;i <= n; i++){
    int x, y, l;
    std::cin >> x >> y;
    l = y - x;
    basic.balance();
    basic.minrange(l);
    Slope curr;
    curr.a = 1;
    curr.b = -x;
    curr._insert(x);
    curr._insert(x);
    _add(basic, curr);

    basic.balance();
    basic.minrange2(l);
  }

  basic.balance();

  ll result = basic.b;
  while(0 < basic.f2.size()){
    result += basic.f2.back();
    basic.f2.pop_back();
  }

  std::cout << result;
  return 0;
}


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

using namespace std;

int main(){
  int n;
  cin >> n;
  
  vector<int> a(n);
  
  int alice = 0;
  int bob = 0;
  
  for(int i = 0 ; i < n ; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  for(int i = 0 ; i < n ; i++){
    if(i%2 == 0) alice += a.back();
    else bob += a.back();
    
    a.pop_back();
  }
  
  cout << alice - bob << endl;
  
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
s = set(a)

d = {}
for i in s:
    d[i] = 0
for i in a:
    d[i] += 1

ans = 0
for i in d:
    c = d[i]
    if c < i:
        ans += c
    elif c >= i:
        ans += c - i
print(ans)

Measured memory_bytes: 27116
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define eb              emplace_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mpii            map<int,int>
#define mpsi            map<string,int>
#define mpss            map<string,string>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int>>
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define all(v)          v.begin(),v.end()
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x

#define deb(x)          cout<<"("<<#x<<")"<<"----->"<<x<<"\n"
#define clr(ar)         memset(ar,0,sizeof(ar))
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define sz 100009
#define si(x) scanf("%lld",&x)
#define sii(x,y) scanf("%lld %lld",&x,&y)
#define out(x) printf("%lld\n",x)
#define spc  printf(" ")
#define line printf("\n")
#define mod 1000000007
#define pf printf
int32_t main()
{
	int i,n,cs,test,m,k,j,q,u,v,w;
	si(n);
  	n = n^1;
  	out(n);


return 0;
}





Measured memory_bytes: 3824