akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

int main() {
  int ts,th,as,ah,counter=0;
  cin>>th>>ts>>ah>>as;
  while(1) {
    if(counter%2==0) {
      ah-=ts;
    }
    else {
      th-=as;
    }
    counter++;
    if(th<=0) {
      cout<<"No"<<endl;
      break;
    }
    else if(ah<=0) {
      cout<<"Yes"<<endl;
      break;
    }
  }
}


Measured memory_bytes: 3516
#include <stdio.h>                                                              
#include <ctype.h>                                                              
                                                                                
int main(){                                                                     
  int size = 10;                                                                
  char s1[size+5],s2[size+5],s3[size+5];                                        
  scanf("%s%s%s",s1,s2,s3);                                                     
                                                                                
  //translate to Capital                                                        
  printf("%c%c%c\n",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));              
                                                                                
  return 0;                                                                     
}           

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <functional>

using namespace std;

typedef long long int ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll, int> pli;
typedef std::pair<ll, ll> pll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

typedef pair<double, double> P;



vector<P> get(vector<P> p)
{
	vector<P> a;
	a.push_back(p[0]);
	REP(i, p.size() - 1)
	{
		P p0 = p[i];
		P p1 = p[i + 1];
		P v((-p0.first + p1.first) / 3, (-p0.second + p1.second) / 3);
		P p2 = P(p0.first + v.first, p0.second + v.second);
		a.push_back(p2);
		P v2(v.first*0.5 - v.second*0.5*sqrt(3), v.first*0.5*sqrt(3) + v.second*0.5);
		a.push_back(P(p2.first + v2.first, p2.second + v2.second));
		a.push_back(P(p2.first + v.first, p2.second + v.second));
		a.push_back(p1);
	}
	return a;
}

int main()
{
	int N;
	cin >> N;
	vector<P> p;
	p.push_back(P(0, 0));
	p.push_back(P(100, 0));
	REP(i, N)
	{
		p = get(p);
	}

	REP(i, p.size())
	{
		cout << OF64 << p[i].first << " " << p[i].second << endl;
	}
	return 0;
}


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


signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    cout << fixed << setprecision(20);

    ll n;
    cin>>n;
    ll p[n],q[n];
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i=0;i<n;i++){
        cin>>q[i];
    }
    vector<int> v(n);
    for(int i=0;i<n;i++){
        v[i] = i+1;
    }
    int a,b;
    int cnt =0;
    do{
        cnt++;
        bool x=true;
        bool y=true;
        for(int i=0;i<n;i++){
            if(v[i]!=p[i]) x = false;
            if(v[i]!=q[i]) y = false;
        }
        if(x) a = cnt;
        if(y) b = cnt;
    }while(next_permutation(v.begin(),v.end()));
    int ans  = abs(a-b);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int qan[2][100002];
int a[100002];
vector <pair<int,int> > v[2];
int main() {
	int n;
	cin >>n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		qan[i %2][a[i]]++;
	}
	for (int j = 1; j <= 100000; j++) {
		v[0].push_back(make_pair(-qan[0][j], j));
		v[1].push_back(make_pair(-qan[1][j], j));
	}
	sort(v[0].begin(), v[0].end());
	sort(v[1].begin(), v[1].end());
	int ans = n + v[0][0].first +v[1][0].first;
	if(v[0][0].second == v[1][0].second) {
		ans = min(n + v[0][1].first +v[1][0].first, n + v[0][0].first +v[1][1].first);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define vi vector<int>
#define ppi pair<int,pi>
#define ld long double
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << end
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end) ; i += 1 - 2 * ((begin) > (end)))
#define nl cout<<"\n";
#define endl "\n"
#define par(a,n) f(i,0,n) cout<<a[i]<<" "; nl
//void prt(int x) {cerr << x;}
#define vv(n,m) vector <vector <int> > v(n, vector <int> (m));

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... brgs>
void err(istream_iterator<string> it, T a, brgs... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);	
}
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
typedef pair<int,int> pii;
typedef vector<pii> vpii;
const int mod = 1000000007;
const int N = 3e5;

int kadane(int*a, int n);
bool isPrime(int n);
int mpow(int a, int b);

void solve(){
  int n;
  cin>>n;
  int a[n];
  f(i,0,n) cin>>a[i];
  int dp[n];
  dp[0]=0;
  dp[1]=abs(a[1]-a[0]);
  f(i,2,n){
      dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]), dp[i-2]+abs(a[i-2]-a[i]));
  }
 // par(dp,n);
  cout<<dp[n-1]<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
        
}

int mpow(int a, int b){ /* pow(a, b) % m */
  int m=mod;
  int x=1;
  while (b>0){
    if (b&1){
      x=(x * a) % m;
    }
    a=(a*a) % m; /* compute the next power of 2 */
    b>>=1; /* this is equivalent to b = floor(b / 2) */
  }
  return x;
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 

int kadane(int*a, int n){
    int max_so_far = INT_MIN, max_ending_here = 0;
    f(i,0,n){
        max_ending_here+=a[i];
        max_so_far = max(max_so_far, max_ending_here);
        if(max_ending_here<0) max_ending_here=0;
    }
    return max_so_far;
}

Measured memory_bytes: 5092
from sys import stdin
import queue

H, W = [int(x) for x in stdin.readline().rstrip().split()]
maze = [stdin.readline().rstrip().split()[0] for _ in range(H)]

ans = 0

for h in range(H):
    for w in range(W):
        if maze[h][w] == '#':
            continue
        else:
            q = queue.Queue()
            q.put((h, w, 0))
            visited = [[-1] * W for _ in range(H)]
            visited[h][w] = 0
            while q.qsize() > 0:
                temp = q.get()
                temp_h = temp[0]
                temp_w = temp[1]
                temp_d = temp[2]
                ans = max(ans, visited[temp_h][temp_w])
                if temp_h + 1 < H and maze[temp_h + 1][temp_w] == '.' and visited[temp_h + 1][temp_w] < 0:
                    visited[temp_h + 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h + 1, temp_w, temp_d + 1))
                if temp_h - 1 >= 0 and maze[temp_h - 1][temp_w] == '.' and visited[temp_h - 1][temp_w] < 0:
                    visited[temp_h - 1][temp_w] = visited[temp_h][temp_w] + 1
                    q.put((temp_h - 1, temp_w, temp_d + 1))
                if temp_w + 1 < W and maze[temp_h][temp_w + 1] == '.' and visited[temp_h][temp_w + 1] < 0:
                    visited[temp_h][temp_w + 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w + 1, temp_d + 1))
                if temp_w - 1 >= 0 and maze[temp_h][temp_w - 1] == '.' and visited[temp_h][temp_w - 1] < 0:
                    visited[temp_h][temp_w - 1] = visited[temp_h][temp_w] + 1
                    q.put((temp_h, temp_w - 1, temp_d + 1))

print(ans)


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

int main()
{
    int N;
    cin >> N;

    int H[N];
    for (int i = 0; i < N; i++)
    {
        cin >> H[i];
    }

    int max = H[0];
    int count = 1;
    for (int i = 1; i < N; i++)
    {
        if (max <= H[i])
        {
            count++;
            max = H[i];
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
    int main()
        {
            int H,W,w,h;
            // 整数の入力
            scanf("%d %d", &H, &W);
            // スペース区切りの整数の入力
            scanf("%d %d",&h, &w);
            // 出力
            printf("%d", H * W - H * w - h * W +  h * w);
            return 0;
    }

Measured memory_bytes: 128
def calc_largest_rect_in_hist(heights):
    heights.append(0)
    stack = []
    left = [0] * len(heights)
    ans = 0
    for i, height in enumerate(heights):
        while stack and heights[stack[-1]] >= height:
            idx = stack.pop()
            ans = max(ans, (i - left[idx] - 1) * heights[idx])
        left[i] = stack[-1] if stack else -1
        stack.append(i)
    return ans


def aoj():
    input()
    print(calc_largest_rect_in_hist([int(x) for x in input().split()]))


if __name__ == "__main__":
    aoj()



Measured memory_bytes: 16636
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")

using namespace std;

typedef long long ll;

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>pb_ds;

#define IN freopen("in.txt","r",stdin)
#define OUT freopen("out.txt","w",stdout)
#define pi pair<int,int>
#define F first
#define S second
#define pb push_back
#define pp pop_back
#define mod 1000000007
#define pai acos(-1)
#define N 100005

ll Weight[N],Profit[N],dp[2][N];

int main ()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   int n,w;cin>>n>>w;
   for(int i=1;i<=n;i++){
      cin>>Weight[i]>>Profit[i];
   }
   fill(dp[0],dp[0]+2*N,-INT_MAX*105);
   dp[(n+1)%2][0]=0;
   for(int i=n;i>=1;i--){
      for(int s=0;s<=w;s++){
         ll op1=dp[(i+1)%2][s];
         ll op2=(s-Weight[i]>=0)?Profit[i]+dp[(i+1)%2][s-Weight[i]]:0ll;
         dp[i%2][s]=max(op1,op2);
      }
   }
   ll ans=0;
   for(int i=0;i<=w;i++) ans=max(ans,dp[1][i]);
   cout<<ans<<"\n";
   return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

// int main()
// {
//   ll N;
//   cin >> N;
//   ll ans = 0;
//   ll IN = N;
//   for (ll i = 2; i * i <= N; i++) {
//     ll d = i;
//     while(IN % d == 0) {
//       IN /= d;
//       d *= i;
//       ans++;
//     }
//   }
//   if (IN != 1) {
//     ans++;
//   }

//   cout << ans << endl;

//   return 0;
// }

int main()
{
  ll N;
  cin >> N;
  ll ans = 0;
  ll IN = N;
  vector<ll> vec;
  for (ll i = 2; i * i <= N; i++) {
    int x = 0;
    ll d = i;
    while(IN % d == 0) {
      IN /= d;
      x++;
    }
    vec.push_back(x);
  }
  if (IN != 1) {
    vec.push_back(1);
  }
  REP(i, vec.size()) {
    int j = 1;
    
    while(j <= vec[i]) {
      vec[i] -= j;
      ans++;
      j++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 11664
#include <iostream>
#include <ctime>
#include <cstdlib>
#include <vector>
using namespace std;

int main()
{
    int n, x, br = 2;
    cin >> n >> x;
    if (x == 1 || x == n * 2 - 1)
    {
        cout << "No";
        return 0;
    }
    cout << "Yes" << endl;
    for (int i = 0; i < n * 2 - 1; i++)
    {
        if (i == (n * 2 - 1) / 2 - 1)
        {
            cout << n * 2 - 1 << endl;
        }
        else if (i == (n * 2 - 1) / 2)
        {
            cout << x << endl;
        }
        else if (i == (n * 2 - 1) / 2 + 1)
        {
            cout << 1 << endl;
        }
        else
        {
            if (br == x) br++;
            cout << br << endl;
            br++;
        }
    }
    return 0;
}


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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) < (m); ++(i))

constexpr int INF = 1e9;
//constexpr ll INF = 1LL<<61;
constexpr ll mod = 1e9+7;

int main(){
  int N, M, K;
  cin >> N >> M >> K;
  vector<ll> A(N), B(M), Asum(N+1, 0), Bsum(M+1, 0);
  REP(i, N){
    cin >> A[i];
    Asum[i+1] = Asum[i] + A[i];
  }
  REP(i, M){
    cin >> B[i];
    Bsum[i+1] = Bsum[i] + B[i];
  }
  int ans = 0;
  REP(i, N+1){
    if(Asum[i] > K) continue;
    int ok = 0, ng = M+1;
    while(abs(ok-ng) > 1){
      int mid = (ok+ng) / 2;
      if(Asum[i] + Bsum[mid] <= K){
        ok = mid;
      }
      else{
        ng = mid;
      }
    }
    ans = max(ans, i + ok);
  }
  cout << ans << endl;

  return 0;
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}*/

/*vector<int> find_dividers(int x) {
    vector<int> dividers;

    for (int i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (i * i != x) {
                dividers.push_back(x / i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

/*map<ll, ll> mp;
ll ans(ll v, ll u, ll w) {
    ll total = 0;
    while (v != u) {
        if (v > u) {
            total += mp[v];
            mp[v] += w;
            v /= 2;
        } else {
            total += mp[u];
            mp[u] += w;
            u /= 2;
        }
    }
    return total;
}*/

void solve() {
    int n, x, t;
    cin >> n >> x >> t;
    int ans = 0, cur = 0;
    while (cur < n) {
        ans += t;
        cur+=x;
    }
    cout << ans << endl;
}

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

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

    return 0;
}


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

using namespace std;

#define MAX 55

signed main(){
  int dxy[4] = {0,0,1,-1};
  int H, W;

  string field[MAX];

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

  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      bool flag = false; 

      if(field[i][j] == '.') continue;
      for(int k = 0; k < 4; k++){
	int nx = j + dxy[k], ny = i + dxy[3-k];

	if(nx < 0 || nx >= W || ny < 0 || ny >= H) continue;

	if(field[ny][nx] == '#'){
	  
	  flag = true;
	  break;
	}
      }

      if(flag == false){
	cout<<"No"<<endl;
	return 0;
      }
    }
  }

  cout<<"Yes"<<endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
using namespace std;
const int MAXN = 100005;
const int NIL = -1;

int n;
vector<int>G[MAXN];
int color[MAXN];

void dfs(int s, int c)
{
	stack<int> S;
	S.push(s);
	color[s] = c;
	while(!S.empty())
	{
		int u = S.top(); S.pop();
		for(int i = 0; i < G[u].size(); i++)
		{
			int v = G[u][i];
			if(color[v] == NIL)
			{
				color[v] = c;
				S.push(v);
			}
		}	
	}
}

void AssighColor()
{
	int id = 1;
	for(int i = 0; i < n; i++)
		color[i] = NIL;
	for(int i = 0; i < n; i++)
	{
		if(color[i] == NIL)
			dfs(i, id++);
	}
}

int main()
{
	int s, t, m, q;
	cin >> n >> m;
	for(int i = 0; i < m; i++)
	{
		cin >> s >> t;
		G[s].push_back(t);
		G[t].push_back(s);
	}
	
	AssighColor();
	
	cin >> q;
	for(int i = 0; i < q; i++)
	{
		cin >> s >> t;
		if(color[s] == color[t])
			cout << "yes" << endl;
		else
			cout << "no" << endl;
	}
	return 0;
}


Measured memory_bytes: 9024
#include <bits/stdc++.h>
#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 REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

ll mfac(ll n) {
  if (n == 1) return 1;
  return n*mfac(n-1)%mod;
}

int main () {
  ll n, m;
  cin >> n >> m;

  ll ans;
  if (m<n-1||n+1<m) {
    ans = 0;
  }
  else {
    int c;
    if (m == n-1) c = 1;
    else if (m == n) c = 2;
    else c = 1;

    ans = mfac(n)*c%mod;
    ans *= mfac(m);
    ans %= mod;
  }

  cout << ans << endl;
}

Measured memory_bytes: 1792
import java.util.*;
public class Main {

	public void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			//ハッシュを用意する
			HashMap<Integer,Long> list = new HashMap<Integer,Long>();
			//入力順を記憶する配列
			ArrayList<Integer> inputlist = new ArrayList<Integer>();
			for(int i=0; i < n; i++){
				int num = sc.nextInt();
				long sales = sc.nextLong();
				long price = sc.nextLong();
				long sum = sales * price;
				//すでにあるのならカウント追加
				if(list.containsKey(num)){
					list.put(num, (list.get(num) + sum ));
				}
				else{
					list.put(num, sum);
					//配列に格納
					inputlist.add(num);
				}
			}

			boolean flg = false;
			for(int key: inputlist){
				if(list.get(key) >= 1000000){
					System.out.println(key);
					flg = true;
				}
			}
			if(!flg){
				System.out.println("NA");
			}

			n = sc.nextInt();
		}

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

	}

}

Measured memory_bytes: 13000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for (int i=a; i<b; ++i)
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll N;
    cin >> N;
    vector <ll> A(N);
    vector <ll> count(1e5+1, 0);
    ll sum=0;
    loop(i,0,N) {
        cin >> A[i];
        sum+=A[i];
        count[A[i]]++;
    }
    ll Q;
    cin >> Q;
    while (Q--)
    {
        ll b,c;
        cin >> b >> c;
        // sum -= count[b]*b;
        sum += count[b]*(c-b);
        count[c]+=count[b];
        count[b]=0;
        cout << sum << "\n";
    }
    return 0;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using ll = long long;
const ll MOD=1e9+7;
const long long INF = 1LL<<60;

int main() {
    ll n,a,b;
    cin >> n >> a >> b;

    cout << (n/(a+b))*a + min(a,n%(a+b)) << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=100005;
typedef long long ll;
int n,a[3][N];
int t[N+5];
int lowbit(int x){return x&-x;}
int z[3],p[N];
int flip[2],rev[2];
void Modify(int x,int d){
    while(x<=N){
        t[x]+=d;
        x+=lowbit(x);
    }
}
int Query(int x){
    int res=0;
    while(x){
        res+=t[x];
        x-=lowbit(x);
    }
    return res;
}
int main()
{
    scanf("%d",&n);
    for(int i=0;i<3;i++)
        for(int j=1;j<=n;j++)
            scanf("%d",&a[i][j]);
    for(int i=1;i<=n;i++){
        z[0]=a[0][i],z[1]=a[1][i],z[2]=a[2][i];
        sort(z,z+3);
        if(z[2]%3!=0||z[0]+1!=z[1]||z[1]+1!=z[2]||z[1]!=a[1][i]){
            puts("No\n");
            return 0;
        }
        int j=z[2]/3;
        if((i-j)%2!=0){
            puts("No\n");
            return 0;
        }
        rev[i%2]^=a[0][i]>a[2][i];
        p[j]=i;
    }
    for(int i=1;i<=n;i+=2){
        int now=p[i]+(i/2+Query(p[i]))*2;
        Modify(p[i],1);
        if((abs(i-now)/2)%2==1)
            flip[i%2]^=1;
    }
    memset(t,0,sizeof t);
    for(int i=2;i<=n;i+=2){
        int now=p[i]+(i/2-1+Query(p[i]))*2;
        Modify(p[i],1);
        if((abs(i-now)/2)%2==1)
            flip[i%2]^=1;
    }
    if(rev[0]==flip[1]&&rev[1]==flip[0])
        puts("Yes");
    else
        puts("No");
}


Measured memory_bytes: 2176
N = int(input())
count = 0
result = False
for i in range(N):
    D1, D2 = map(int, input().split(" "))
    if D1 == D2:
        count = count + 1
        if count >= 3:
            result = True
    else:
        count = 0
if result:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 9168
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    while(1){
	int n,m;
	cin>>n>>m;
	if( n == 0 )break;
	map<int,int> h;
	map<int,int> w;
	vector<int> a(n),b(m);
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<m;i++)cin>>b[i];
	for(int i=0;i<n;i++){
	    int sum = 0;
	    for(int j=0;i+j<n;j++){
		sum += a[i+j];
		h[ sum ]++;
	    }
	}
	for(int i=0;i<m;i++){
	    int sum = 0;
	    for(int j=0;i+j<m;j++){
		sum += b[i+j];
		w[ sum ]++;
	    }
	}
	int cnt = 0;
	for(auto it:h){
	    cnt += it.second*w[it.first];
	}
	cout<<cnt<<endl;
    }
    return 0;
}



Measured memory_bytes: 34324
function main(input) {
  const R = parseInt(input.split(" ")[0], 10);
  if(R<1200){
    console.log("ABC");
  }else if(R<2800){
    console.log("ARC");
  }else{
    console.log("AGC");
  }
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 7372
#include <iostream>
#include <algorithm>
using namespace std;
#define MAX 10000
#define NIL -1
 
struct Node{int left, parent, right;};
Node node[MAX];
int depth[MAX], height[MAX], n, root;
 
void setDepth(int n, int d){
  depth[n] = d;
  if(node[n].left != NIL) setDepth(node[n].left, d + 1);
  if(node[n].right != NIL) setDepth(node[n].right, d + 1);
}
 
int setHeight(int n){
  int lh = 0, rh = 0;
  if(node[n].left != NIL) lh = setHeight(node[n].left) + 1;
  if(node[n].right != NIL) rh = setHeight(node[n].right) + 1;
  return height[n] = max(lh, rh);
}
 
int getSibling(int n){
  int p = node[n].parent;
  if(p == NIL) return NIL;
  else if(node[p].left != n) return node[p].left;
  else return node[p].right;
}
 
int getDegree(int n){
  return (node[n].left != NIL) + (node[n].right != NIL);
}
 
void printNodeInf(int n){
  cout << "node " << n << ": ";
  cout << "parent = " << node[n].parent << ", ";
  cout << "sibling = " << getSibling(n) << ", ";
  cout << "degree = " << getDegree(n) << ", ";
  cout << "depth = " << depth[n] << ", ";
  cout << "height = " << height[n] << ", ";
  if(n == root) cout << "root" << endl;
  else if(node[n].left == NIL && node[n].right == NIL) cout << "leaf" << endl;
  else cout << "internal node" << endl;
}
 
int main(void){
  cin >> n;
 
  for(int i = 0; i < n; i++) node[i].parent = node[i].left = node[i].right = NIL;
 
  for(int i = 0; i < n; i++){
    int id, l, r;
    cin >> id >> l >> r;
    node[id].left = l;
    node[id].right = r;
    if(l != NIL) node[l].parent = id;
    if(r != NIL) node[r].parent = id;
  }
 
  for(int i = 0; i < n; i++) if(node[i].parent == NIL) root = i;
 
  setDepth(root, 0);
  setHeight(root);
 
  for(int i = 0; i < n; i++) printNodeInf(i);
  return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
#define TE 2e5
using namespace std;
using ll = long long;
using ldb = long double;

typedef struct {
	int s, t, c;
}pro_t;

bool cmp(const pro_t& a, const pro_t& b) {
	return a.s < b.s ;
}
int main() {
	int N, C; cin >> N >> C;
	vector<pro_t> pro(N);
	vector<vector<int>> ch(31, vector<int>(TE + 2));

	for (int i = 0; i < N; i++) {
		 cin >> pro[i].s >> pro[i].t >> pro[i].c;	
	}	
	sort(pro.begin(), pro.end(),cmp);	
	for (int i = 0; i < N; i++) {
		int s = pro[i].s, t = pro[i].t, c = pro[i].c;
		if (ch[c][s + 1] == -1)ch[c][s + 1]++;
		else ch[c][s]++;
		if (ch[c][t] == 1)ch[c][t]--;
		else  ch[c][t + 1]--;
	}
	int ans = 1;
	vector<int> im(31);
	for (int i = 1; i <= 2e5; i++) {
		int temp = 0;
		for (int j = 1; j <= 30; j++) {
			im[j] += ch[j][i];
			temp += im[j];
		}
		ans = max(ans, temp);
	}
	cout << ans << endl;
}


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int A, B, C;
	cin >> A >> B >> C;
	int K;
	cin >> K;

	int abcMAX = max({ A,B,C });
	for (int i = 0; i < K; i++) {
		abcMAX *= 2;
	}
	cout << abcMAX + A + B + C - max({ A,B,C }) << endl;

	return 0;
}

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

using namespace std;

typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;

constexpr int MAXN = 100, MAXV = 1000, MAXW = 1000000000, INF = INT_MAX - MAXW;

int dp[MAXN * MAXV + 2];

int main() {
	int N, W;
	cin >> N >> W;
	fill(dp + 1, dp + N * MAXV + 1, INF);
	int k = 0;
	for(int i = 0; i < N; i++) {
		int w, v;
		cin >> w >> v;
		for(int j = k + v; j >= v; j--) {
			dp[j] = min(dp[j], dp[j - v] + w);
			if(dp[j] <= W)
				k = max(k, j);
		}
	}
	cout << k << endl;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;

ll dp[3005][3005][2];
bool mark[3005][3005][2];
int arr[3005];

ll solve(int i, int j, int move)
{
  if(i > j)
    return 0;
  ll &ans = dp[i][j][move];
  if(mark[i][j][move])
    return ans;
  mark[i][j][move] = 1;
  if(move == 0)
  {
    return ans = max(arr[i] + solve(i + 1, j, 1), arr[j] + solve(i, j - 1, 1));
  }
  else
  {
    return ans = min(solve(i + 1, j, 0) - arr[i], solve(i, j - 1, 0) - arr[j]);
  }
}

int main()
{
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> arr[i];
  cout << solve(0, n - 1, 0);
  return 0;
}


Measured memory_bytes: 158208
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.StringTokenizer;

public class Main{ // 

	public static void main(String args[]) {
		ConsoleScanner cin = new ConsoleScanner();
		PrintWriter cout = new PrintWriter(System.out);
		solve(cin, cout);
		cout.flush();
	}

	static long now() {
		return System.currentTimeMillis();
	}

	static void trace(Object... objects) {
		assert null != System.out.format("trace:%s\n", Arrays.deepToString(objects));
	}

	private static void solve(ConsoleScanner cin, PrintWriter cout) {
		// assert solve(1) == 1;

		int n = cin.nextInt();

		int[][] abs = new int[n - 1][];
		for (int i = 0; i < abs.length; i++)
			abs[i] = new int[] { cin.nextInt(), cin.nextInt() };

		long start = now();

		boolean ans = solve(n, abs);
		if (ans)
			cout.println("Fennec");
		else
			cout.println("Snuke");

		trace("elapsed", now() - start);
	}

	private static boolean solve(int n, int[][] abs) {
		// BFS
		int[] vis = new int[n + 1];
		Arrays.fill(vis, -1);
		int FEN = 1;
		int SNU = 2;
		List<List<Integer>> adj = new ArrayList<>();
		for (int i = 0; i < n + 1; i++)
			adj.add(new ArrayList<>());
		for (int[] ab : abs) {
			adj.get(ab[0]).add(ab[1]);
			adj.get(ab[1]).add(ab[0]);
		}
		ArrayDeque<Integer> q = new ArrayDeque<>();
		// Fennec先攻
		q.add(1);
		vis[1] = FEN;
		// Snuke後攻
		q.add(n);
		vis[n] = SNU;
		while (!q.isEmpty()) {
			int v = q.poll();
			for (int u : adj.get(v)) {
				if (vis[u] != -1)
					continue;
				vis[u] = vis[v];
				q.add(u);
			}
		}
		long fen = Arrays.stream(vis).filter(x -> x == FEN).count();
		long snu = Arrays.stream(vis).filter(x -> x == SNU).count();
		return fen > snu;
	}

	static class ConsoleScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");

		String next() {
			try {
				while (!st.hasMoreElements())
					st = new StringTokenizer(br.readLine());
				return st.nextToken();
			} catch (IOException e) {
				throw new AssertionError(e);
			}
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 55096
use std::collections::HashMap;
use scanner::Scanner;

fn main() {
    let mut sc = Scanner::new();
    let n: usize = sc.read();
    let m: usize = sc.read();
    let gcm = (n * m) / gcd(n, m);

    let s: HashMap<usize, char> = sc.read::<String>().chars().enumerate().map(|(i, x)| (i * gcm / n + 1, x)).collect();
    let t: Vec<_> = sc.read::<String>().chars().enumerate().map(|(i, x)| (i * gcm / m + 1, x)).collect();

    for (i, e) in t {
        match s.get(&i) {
            Some(x) => if *x != e {
                println!("-1");
                return;
            },
            _ => (),
        }
    }

    println!("{}", gcm);
}

fn gcd(a: usize, b: usize) -> usize {
    if a % b == 0 {
        b
    } else {
        gcd(b, a % b)
    }
}

mod scanner {
    pub struct Scanner<'a> {
        s: String,
        words: ::std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new() -> Scanner<'a> {
            let s = String::new();
            let words = unsafe { ::std::mem::transmute(s.split_whitespace()) };
            Scanner { s: s, words: words }
        }

        pub fn read<T: ::std::str::FromStr>(&mut self) -> T {
            match self.words.next() {
                Some(x) => x.parse().ok().unwrap(),
                None => {
                    self.load();
                    self.read()
                }
            }
        }

        fn load(&mut self) {
            self.s.clear();
            ::std::io::stdin().read_line(&mut self.s).unwrap();
            self.words = unsafe { ::std::mem::transmute(self.s.split_whitespace()) };
        }
    }
}


Measured memory_bytes: 10492
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
 
using namespace std;
const int MAX_N = 100000;
long long N, M, A[MAX_N];
long long dp[MAX_N + 1];
 
void solve() {
    long long res = 0;
    unordered_map<long long, long long> mp;
 
    for (int i = 0; i < N; i++) {
        dp[i + 1] = (dp[i] + A[i]) % M;
        mp[dp[i + 1]] = mp[dp[i + 1]] + 1;
    }
 
    for (auto const &val: mp) {
        res += val.second * (val.second - 1) / 2;
        if (val.first == 0) {
            res += val.second;
        }
    }
 
    printf("%lld\n", res);
}
 
int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 4876
#include <bits/stdc++.h>
#define FOR(i, l, r) for(ll i = l; i < r; i++)
#define rep(i, N) FOR(i, 0, N)
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<ll> vl;
const ll MOD = round(1e9+7);

int main() {
    int N; cin >> N;
    vi A(N); rep(i,N) cin >> A[i];
    int Q; cin >> Q;
    vl B(Q),C(Q); rep(i,Q) cin >> B[i] >> C[i];

    map<int, ll> mp;
    ll sum = 0;
    rep(i,N) mp[A[i]]++;
    rep(i,N) sum += A[i];

    queue<ll> ans;
    rep(i,Q){
        if(mp[B[i]] > 0){
            sum += (C[i]*mp[B[i]] - B[i]*mp[B[i]]);
            mp[C[i]] += mp[B[i]];
            mp[B[i]] = 0LL;
        }
        ans.push(sum);
    }

    while(!ans.empty()){
        cout << ans.front() << "\n";
        ans.pop();
    }
    return 0;
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for(ll i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    map<ll, ll> T;
    for(ll i=2; i<=N; i++){
        for(auto p : prime_factor(i)) {
            // cout << p.first << ":" << p.second << endl;
            T[p.first] += p.second;
            T[p.first] = T[p.first] % MOD;
        }
    }
    
    ll ans = 1;
    for(auto iter=T.begin(); iter!=T.end(); iter++){
        // cout << iter->first << " " << iter->second << endl;
        ans = ans * (iter->second + 1) % MOD;
        ans = ans % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K,ans=1e9;
  cin>>N>>K;
  vector<int> a(N);
  for(int i=0;i<N;i++) cin>>a[i];
  sort(a.begin(),a.end());
  for(int i=0;i<N-K+1;i++)ans=min(ans,a[i+K-1]-a[i]);
  cout<<ans<<endl;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
#include<algorithm>
using namespace std;
const int N=8005;
typedef long long ll;
const ll mod=998244353;

int power_mod(int a,int b)
{
	int ans=1;
	while (b) 
	{
		if (b&1) ans=(ll)ans*a%mod;
		a=(ll)a*a%mod;
		b>>=1;
	}
	return ans;
}
inline void MOD(int &x) {if (x>=mod) x-=mod;}


int n,m;

int dp[N*4],t[N*4],tmp[N*4];

int om[N*4],on[N*4],rev[N*4],len;
void init(int n)
{
	int l=0;
	len=1;
	while (len<n) len<<=1,l++;
	
	int g=power_mod(3,(mod-1)/len),inv=power_mod(g,mod-2);
	for (int i=0;i<len;i++) 
	{
		om[i]= i==0 ?1:(ll)om[i-1]*g%mod;
		on[i]= i==0 ?1:(ll)on[i-1]*inv%mod;
		rev[i]=(rev[i>>1]>>1)|((i&1)<<l-1);
	}
}
void ntt(int *a,int *om,int n)
{
	for (int i=0;i<n;i++) if (rev[i]>i) swap(a[i],a[rev[i]]);
	for (int len=2;len<=n;len<<=1) 
		for (int m=len/2,x,i=0;i<n;i+=len) 
			for (int j=0;j<m;j++) 
			{
				x=(ll)om[n/len*j]*a[i+j+m]%mod;
				MOD(a[i+j+m]=a[i+j]-x+mod);
				MOD(a[i+j]+=x);
			}
}
void dft(int *a) {ntt(a,om,len);}
void idft(int *a) 
{
	ntt(a,on,len);
	int inv=power_mod(len,mod-2);
	for (int i=0;i<len;i++) a[i]=(ll)a[i]*inv%mod;
}
int jc[N],ny[N];

int C(int n,int m) 
{
	return (ll)jc[n]*ny[m]%mod*ny[n-m]%mod;
}
int main()
{
	scanf("%d%d",&n,&m);
	init(n*2+1);
	
	jc[0]=jc[1]=ny[0]=ny[1]=1;
	for (int i=2;i<=n+2;i++) jc[i]=(ll)jc[i-1]*i%mod,ny[i]=(mod-mod/i)*ny[mod%i]%mod;
	for (int i=2;i<=n+2;i++) ny[i]=(ll)ny[i-1]*ny[i]%mod;
	

	for (int i=0;i<=n;i++) dp[i]=1;
	//dft(dp);idft(dp);
	//for (int i=0;i<=n;i++) printf("%d ",dp[i]);
	
	for (int i=2;i<=m;i++) 
	{
		for (int j=0;j<=n;j++) tmp[j]=(ll)dp[j]*ny[j]%mod,t[j]=ny[j+2];t[0]=0;
		for (int j=n+1;j<len;j++) tmp[j]=t[j]=0;
		
		dft(tmp),dft(t);
		for (int j=0;j<len;j++) tmp[j]=(ll)tmp[j]*t[j]%mod;
		idft(tmp);
		
		for (int j=0;j<=n;j++) 
			dp[j]=((ll)dp[j]*(j*(j+1)/2+1)+(ll)tmp[j]*jc[j+2])%mod;
			//,printf("dp[%d][%d]=%d\n",i,j,dp[j]);
	}
	int ans=0;
	for (int i=0;i<=n;i++) ans=((ll)dp[i]*C(n,i)+ans)%mod;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 640
import qualified Data.IntMap as M
import Data.Maybe
import Data.List

import Debug.Trace
_t x = traceShow x x

concatIntList :: Integral a => [a] -> a
concatIntList xs = go (length xs - 1) xs 0
  where
    go _ [] sum     = sum
    go n (x:xs) sum = go (n-1) xs (sum + x * 10^n)

solve :: Int -> [(Int,Int)] -> Int
solve n sc = maybe (-1) go2 $ go sc M.empty
  where
    go [] m = Just m
    go ((i,v):xs) m
      | n >= 2 && i == 1 && v == 0 = Nothing
      | otherwise =
          case M.lookup i m of
              Nothing -> go xs (M.insert i v m)
              Just vv -> if vv == v
                           then go xs (M.insert i v m) else Nothing
    go2 m = let l = map (\i -> fromMaybe 0 (M.lookup i m)) [1..n]
             in rep0 l
    rep0 xs = let (s1,s2) = span (==0) xs
                  ss = if n == 1
                          then [0]
                          else (1 : replicate (length s1 - 1) 0) ++ s2
               in case s1 of
                   [] -> concatIntList xs
                   otherwise -> concatIntList ss

main :: IO ()
main = do
    [n,m] <- map read . words <$> getLine :: IO [Int]
    sc <- map ((\[a,b] -> (a,b)) . (map read . words))
        . lines <$> getContents :: IO [(Int,Int)]
    print $ solve n sc

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int xmin = 0, xmax = w;
    int ymin = 0, ymax = h;

    for(int i = 0; i < n; i++) {
        int x, y, a;
        cin >> x >> y >> a;

        switch(a) {
            case 1:
                if(xmin < x) xmin = x;
                break;
            case 2:
                if(xmax > x) xmax = x;
                break;
            case 3:
                if(ymin < y) ymin = y;
                break;
            case 4:
                if(ymax > y) ymax = y;
        }
    }

    if(xmax < xmin || ymax < ymin) cout << 0 << endl;
    else cout << (xmax - xmin) * (ymax - ymin) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int k;
    cin >> k;
    int a[1000001];
    a[1] = 7%k;
    for (int i = 2; i <= k; ++i){
        a[i] = (a[i-1]*10 + 7) % k;
    }
    
    for(int i = 1; i <= k; ++i){
        if(a[i] == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
}


Measured memory_bytes: 7548
#include <iostream>
#include <string>

using namespace std;
int main() {
  int n, k;
  string s, c;
  cin >> n >> s >> k;
  
  c = s[k-1];
  for (int i=0; i<s.length(); i++) {
    if(s[i]!=c[0]) s[i]='*';
  }
  
  cout << s << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;



int main() {
	string s; cin >> s;
	int ans = 0;
	for (int j = 0; j < (int)s.size(); j++) {
		int cnt = 0;
		for (int i = j; i < (int)s.size(); i++) {
			if (s[i] == 'C' || s[i] == 'G' || s[i] == 'T' || s[i] == 'A') cnt++;
			else break;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
ans = [[0 for i in range(10)] for i in range(12)]  # ans[桁数][はじめの数字]
anscount = [[0 for i in range(10)] for i in range(12)]
ansnum = []
# print(ans)
count = 9

import bisect

for i in range(10):
    ans[1][i] = 1
    anscount[1][i] = i
# print(anscount)

j = 0

while count < n:
    for i in range(10):
        if i == 0:
            ans[j + 2][i] = ans[j + 1][i] + ans[j + 1][i + 1]
        elif i == 9:
            ans[j + 2][i] = ans[j + 1][i - 1] + ans[j + 1][i]
            count += ans[j + 2][i]
        else:
            ans[j + 2][i] = ans[j + 1][i - 1] + ans[j + 1][i + 1] + ans[j + 1][i]
            count += ans[j + 2][i]
        anscount[j + 2][i] = count
    # print(anscount)
    # print(ans)
    j += 1
# print(anscount)
# print(ans)

keta = j + 1
hajime = bisect.bisect_left(anscount[keta], n)
# print(anscount[keta])
# print(hajime)
# print(ans[keta-1])
num = anscount[keta][hajime - 1]
sa = n - num
# print(keta,hajime,sa)
ansnum.append(hajime)

count = 0

for i in reversed(range(1, keta)):
    if hajime != 0:
        if sa <= ans[i][hajime - 1]:
            hajime -= 1
        elif sa <= ans[i][hajime - 1] + ans[i][hajime]:
            hajime += 0
            sa -= ans[i][hajime - 1]
        else:
            sa -= (ans[i][hajime - 1] + ans[i][hajime])
            hajime += 1
    else:
        if sa <= ans[i][hajime]:
            hajime += 0
        else:
            sa -= ans[i][hajime]
            hajime += 1
    ansnum.append(hajime)
    # print(i, hajime, sa)
    # print(ansnum)

count = 0
sa = 1
for i in reversed(ansnum):
    count += i * sa
    sa *= 10
print(count)
# 3234566667
# 956なら99999

Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<vector<P>> Graph;


int main(){

  int n,m;
  cin >> n >> m;
  
  int time = m*1900 + (n-m)*100;
  
  cout << time*(1 << m) << endl;
  

 return 0;
}

Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - LCS
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 3000;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

char s[MAX_N + 4], t[MAX_N + 4], ans[MAX_N];
int dp[MAX_N + 1][MAX_N + 1];
int pis[MAX_N + 1][MAX_N + 1], pjs[MAX_N + 1][MAX_N + 1];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", s, t);
  int m = strlen(s), n = strlen(t);
  //printf("%d %d\n", m, n);

  memset(dp, -1, sizeof(dp));
  dp[0][0] = 0;
  pis[0][0] = pjs[0][0] = -1;

  for (int i = 0; i <= m; i++)
    for (int j = 0; j <= n; j++) {
      if (i < m && j < n && s[i] == t[j] && dp[i + 1][j + 1] < dp[i][j] + 1) {
	dp[i + 1][j + 1] = dp[i][j] + 1;
	pis[i + 1][j + 1] = i, pjs[i + 1][j + 1] = j;
      }
      if (i < m && dp[i + 1][j] < dp[i][j]) {
	dp[i + 1][j] = dp[i][j];
	pis[i + 1][j] = i, pjs[i + 1][j] = j;
      }
      if (j < n && dp[i][j + 1] < dp[i][j]) {
	dp[i][j + 1] = dp[i][j];
	pis[i][j + 1] = i, pjs[i][j + 1] = j;
      }
    }

  int k = 0;
  for (int i = m, j = n; i > 0 || j > 0;) {
    int i0 = pis[i][j], j0 = pjs[i][j];
    if (i0 < i && j0 < j) ans[k++] = s[i0];
    i = i0, j = j0;
  }

  for (int i = k - 1; i >= 0; i--) putchar(ans[i]);
  putchar('\n');
  return 0;
}


Measured memory_bytes: 105856
while True:
    # 入力
    n, x = (int(i) for i in input().split())
    # 終了条件
    if n==0 and x==0:
        break
    # メインの処理、xとnはそんなに大きな数ではないので愚直なアルゴリズムを実装する
    out = 0     # 出力する結果、初期値0
    for i in range(1,n-1):
        for j in range(i+1,n):
            for k in range(j+1, n+1):
                if i+j+k==x:
                    out += 1
    print(out)
    


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

def main():
    S = input()
    ans = 0
    if 'RRR' in S:
        ans = 3
    elif 'RR' in S:
        ans = 2
    elif 'R' in S:
        ans = 1

    print(ans)


if __name__ == "__main__":
    main()


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

int main()
{
  ll n, m; cin>>n>>m;
  vector<ll> v(n, 0);
  vector<ll> w(n, 0);
  rep(i, n) cin>>v[i]>>w[i];
  vector<vector<ll>> dp(n+1, vector<ll>(m+1, 0));
  rep(i, n) for (int j=0; j<=m; j++) {
    dp[i+1][j] = dp[i][j];
    if (j >= w[i]) dp[i+1][j] = max(dp[i][j], max(dp[i+1][j-w[i]], dp[i][j-w[i]])+v[i]);
  }
  cout << dp[n][m] << endl;

  return 0;
}



Measured memory_bytes: 10732
#include<iostream>
using namespace std;
 
int main(){
  int n;
 
  while(cin >> n && n){
    int res = 0,k=0,tmp = 1;
    while(n){
      res += ((n%10)+10)%10 * tmp;
      if(n%10<0)n-=10;
      
      tmp *= 10;
      n /= -10;
      k++;
    }
    cout << res << endl;
  }
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
const ll INF = 1e18L+5;
const int mx = 2e5+7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b){
  return (ll)a * b % mod;
}

void max_self(ll& a, ll b){
  a = max(a,b);
}
int main(){
    int n;
    scanf("%d", &n);

    int base = 1;
    while(base <= n) {
        base *= 2;
    }
    // base is the smallest power of 2 that is not smaller than n
    vector<ll> tree(2 * base);

    vector<int> h(n), a(n);
    for(int i = 0; i < n; ++i) {
        scanf("%d", &h[i]);
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }
    vector<ll> dp(n + 1);
    // dp[i] - the max total beauty so far if the last taken flower has height i
    for(int flower = 0; flower < n; ++flower) {

        // max dp[i] for i in [0, h[flower]-1]
        int x = h[flower] + base;
        ll best = 0;
        while(x > 1) {
            if(x % 2 == 1) {
                max_self(best, tree[x-1]);
            }
            x /= 2;
        }
        dp[h[flower]] = best + a[flower];

        for(int i = base + h[flower]; i >= 1; i /= 2) {
            max_self(tree[i], dp[h[flower]]);
        }

        //~ for(int i = 0; i < h[flower]; ++i) {
            //~ max_self(dp[h[flower]], dp[i] + a[flower]);
        //~ }
    }
    ll answer = 0;
    for(int i = 0; i <= n; ++i) {
        max_self(answer, dp[i]);
    }
    printf("%lld\n", answer);



}


Measured memory_bytes: 7424
h, w = map(int, input().split())
n = int(input())
A = list(map(int, input().split()))

ans = []
for i, a in enumerate(A):
  index = i + 1
  for _ in range(a):
    ans.append(index)
  
m = [[0 for _ in range(w)] for _ in range(h)]
cnt = 0
for i in range(h):
  if i % 2 == 0:
    for j in range(w):
      m[i][j] = ans[cnt]
      cnt += 1
  else:
    for j in range(w-1,-1,-1):
      m[i][j] = ans[cnt]
      cnt += 1
  print(" ".join(map(str, m[i])))


Measured memory_bytes: 9488
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,n,maxi=0,f=0,mini=INF,sum=0;
    cin>>a>>b>>c>>n;
    if(a<c) swap(a,c);
    if(a<b) swap(a,b);
    REP(i,0,3001){
        if(i*a>n) continue;
        if(i*a+b*(3000-i)+c*(3000-i)<n) continue;
        REP(j,0,3001-i){
            if(i*a+j*b>n) continue;
            REP(k,0,3001-i-j){
        if(a*i+b*j+c*k==n) {
            sum++;
            break;
        }
    }
        
    }    
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3624