akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x,n,mind=1000,ans=100; cin>>x>>n;
  vector<int> p(n); for(int i=0; i<n; i++) cin>>p[i];
  for(int i=0; i<=200; i++){
    if(count(p.begin(),p.end(),i)==0){
      int d=abs(x-i);
      if(mind>d){
        mind=d; ans=i;
      }
      else if(mind==d){
        ans=min(ans,i);
      }
    }
  }
  cout<<ans;
}

Measured memory_bytes: 3544
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i=(a); i<b; i++)
#define REP(i, n)    for(int i=0; i<(n); i++)
#define fst first
#define pb push_back
#define mp make_pair
#define ALL(obj) (obj).begin(), (obj).end()
using ul = unsigned long;
using ll = long long;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;

int a10(int x){
  return (x-1) - ((x-1)%10) +10;
}

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

  int a[5];
  cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];

  int last = min( min( min((a[0]-1)%10,(a[1]-1)%10), min((a[2]-1)%10,(a[3]-1)%10) ), (a[4]-1)%10 );

  int num;
  REP(i, 5){
    if( (last)==((a[i]-1)%10) ){
      num = i;
      break;
    }
  }

  int ans;
  if(a[num]%10!=0)
    ans = a10(a[0])+a10(a[1])+a10(a[2])+a10(a[3])+a10(a[4]) -(10-a[num]%10);
  else
    ans = a10(a[0])+a10(a[1])+a10(a[2])+a10(a[3])+a10(a[4]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char s[222222];
int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    if(len&1)
    {
        int tp=s[len/2+1],as=len;
        for(int i=(len+1)/2;i<=len;i++)
            if(s[i]!=s[len-i+1]|s[i]!=tp)
        {
            as=i-1;
            break;
        }
        printf("%d\n",as);
    }
    else
    {
        int tp=s[len/2],as=len;
        for(int i=len/2+1;i<=len;i++)
            if(s[i]!=s[len-i+1]||s[i]!=tp)
        {
            as=i-1;
            break;
        }
        printf("%d\n",as);
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=200005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	lli criba[MaxN];
	lli pre[MaxN];
	void solve(){
		lli N,Q,i,j,l,r,p;
		N=120000;
		for(i=2;i<=N;i++){
			if(criba[i])continue;
			for(j=i*2;j<=MaxN;j+=i){
				criba[j]=1;
			}
		}
		for(i=3;i<N;i++){
			p=0;
			if(!criba[i]&&(!criba[(i+1)/2]))p=1;
			//if(p==1&&i<100)cout<<i<<"\n";
			pre[i]=pre[i-1]+p;
		}
		cout<<"\n";
		cin>>Q;
		while(Q--){
			cin>>l>>r;
			cout<<pre[r]-pre[l-1]<<"\n";
		}
	}
int main(){
	cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}

Measured memory_bytes: 4088
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define rush() int T;scanf("%d",&T);while(T--)
#define mm(a,b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define sc(a) scanf("%d",&a)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define pf(a) printf("%d\n",a)
#define pf2(a,b) printf("%d %d\n",a,b)
#define p_f(a) printf("%d ",a)
#define pyn(a) if(a)puts("Yes");else puts("No");
#define fi first
#define se second
#define db double
#define ll long long
using namespace std;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f3f;
const db eps=1e-9;
int n,ans;
bool flag;
int main()
{
    cin>>n;
    rep(i,1,9){
        if(n%i==0&&(n/i>=1&&n/i<=9)){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

std::map<string, int> strs;

int main(int argc, char *argv[])
{
  int n;
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    int v = 1;
    auto it = strs.find(s);
    if(it != strs.end()){
      v = strs[s] + 1;
      strs.erase(s);
    }
    strs.insert(make_pair(s, v));
  }
  cin >> n;
  for(int i = 0; i < n; i++){
    string s;
    cin >> s;
    int v = -1;
    auto it = strs.find(s);
    if(it != strs.end()){
      v = strs[s] - 1;
      strs.erase(s);
    }
    strs.insert(make_pair(s, v));
  }


  int max_gain = 0;
  for(auto it = strs.begin(); it != strs.end(); it++){
    if(it->second > max_gain) max_gain = it->second;
  }
 

  cout << max_gain << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-12;
long double pi = acos(-1);



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

    int t;
    cin>>t;
    while(t--){
        ll n,a,b,c,d;
        cin>>n>>a>>b>>c>>d;
        ll ans = 1e18;
        queue<array<ll,2>> q;
        q.push({n,0});
        unordered_map<ll,ll> mp;
        while(q.size()){
            ll now = q.front()[0], cost = q.front()[1];
            q.pop();
            if(mp.count(now) && cost >= mp[now]) continue;
            mp[now] = cost;
            if(now<6e9){
                chmin(ans,cost+d*now);
            }
            //if(now==1)cerr << cost << "\n";
            for(ll i = -4;i<5;i++){
                ll ret = now + i;
                ll nc = cost + abs(i)*d;
                if(ret < 0)continue;
                if(ret == 0){
                    chmin(ans,nc);
                    continue;
                }
                if(-1<=i && i<=1 && ret % 2 == 0){
                    q.push({ret/2,nc+a});
                }
                if(-2<=i && i<=2 && ret % 3 == 0){
                    q.push({ret/3,nc+b});
                }
                if(ret % 5 == 0){
                    q.push({ret/5,nc+c});
                }
            }
        }
        cout << ans << "\n";
    }
    

}


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

int main(){
	string s1,s2;
	cin>>s1>>s2;

	sort(s1.begin(),s1.end());
	sort(s2.begin(),s2.end());
	reverse(s2.begin(),s2.end());

	cout<< (s1<s2?"Yes":"No") <<endl;

}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#include<math.h>
using namespace std;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1);
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
inline double ABS(double a){return max(a,-a);}
struct Pt {
	double x, y;
	Pt() {}
	Pt(double x, double y) : x(x), y(y) {}
	Pt operator+(const Pt &a) const { return Pt(x + a.x, y + a.y); }
	Pt operator-(const Pt &a) const { return Pt(x - a.x, y - a.y); }
	Pt operator*(const Pt &a) const { return Pt(x * a.x - y * a.y, x * a.y + y * a.x); }
	Pt operator-() const { return Pt(-x, -y); }
	Pt operator*(const double &k) const { return Pt(x * k, y * k); }
	Pt operator/(const double &k) const { return Pt(x / k, y / k); }
	double ABS() const { return sqrt(x * x + y * y); }
	double abs2() const { return x * x + y * y; }
	double arg() const { return atan2(y, x); }
	double dot(const Pt &a) const { return x * a.x + y * a.y; }
	double det(const Pt &a) const { return x * a.y - y * a.x; }
};
double tri(const Pt &a, const Pt &b, const Pt &c) { return (b - a).det(c - a); }
Pt pLL(Pt a, Pt b, Pt c, Pt d) {
	b = b - a; d = d - c; return a + b * (c - a).det(d) / b.det(d);
}
Pt hLP(Pt a,Pt b,Pt c){
	return pLL(a,b,c,c+(b-a)*Pt(0,1));
}
int cur;
char str[110];
struct wolf{
	Pt a;
	Pt b;
	int t;
};
wolf expr();
wolf term(){
	if(str[cur]=='('){
		cur++;
		wolf ret=expr();
		cur++;
		return ret;
	}
	int x=0;
	bool neg=false;
	if(str[cur]=='-'){cur++;neg=true;}
	while('0'<=str[cur]&&str[cur]<='9'){
		x*=10;x+=str[cur]-'0';cur++;
	}
	if(neg)x=-x;
	neg=false;
	cur++;
	int y=0;
	if(str[cur]=='-'){cur++;neg=true;}
	while('0'<=str[cur]&&str[cur]<='9'){
		y*=10;y+=str[cur]-'0';cur++;
	}
	if(neg)y=-y;
	wolf ret;
	ret.a=Pt((double)x,(double)y);
	ret.t=0;
	//printf("%d, %d\n",x,y);
	return ret;
}
wolf expr(){
	wolf ret=term();
	while(str[cur]=='@'){
		cur++;
		wolf tmp=term();
		if(ret.t<tmp.t){
			swap(ret,tmp);
		}
		wolf to;
		if(ret.t==0&&tmp.t==0){
			to.t=1;
			to.a=ret.a;
			to.b=tmp.a;
		}else if(ret.t==1&&tmp.t==0){
			to.t=0;
			Pt v=hLP(ret.a,ret.b,tmp.a);
			to.a=v+v-tmp.a;
		}else{
			to.t=0;
			to.a=pLL(ret.a,ret.b,tmp.a,tmp.b);
		}
		ret=to;
	}
	return ret;
}
int main(){
	while(1){
		scanf("%s",str);
		if(str[0]=='#')break;
		cur=0;
		wolf ret=expr();
		printf("%.12f %.12f\n",ret.a.x,ret.a.y);
	}
}

Measured memory_bytes: 1032
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

function main(input) {
  input = input.split('\n');
  k = parseInt(input[0]);
  s = input[1];
  if (s.length <= k) {
    console.log(s);
  } else {
    console.log(s.substring(0, k) + '...');
  }
}


Measured memory_bytes: 29608
package main

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

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Buffer(make([]byte, 64*1024*1024), 64*1024*1024)
  sc.Scan()
  N, _ := strconv.Atoi(sc.Text())
  sc.Scan()
  AS := strings.Split(sc.Text(), " ")
  cnt := 0
  flag := 0
  last := 0
  for i:=0; i<N; i++  {
    v, _ := strconv.Atoi(AS[i])
    if i!=0 {
      if flag == 0 {
        if v == last {} else if v > last {
          flag = 1
        } else {
          flag = -1
        }
      } else if flag > 0 {
        if v < last {
          cnt += 1
          flag = 0
        } else {}
      } else {
        if v > last {
          cnt += 1
          flag = 0
        } else {}
      }
    } else {
      cnt += 1
    }
    last = v
  }
  fmt.Println(cnt)
}


Measured memory_bytes: 6272
/* ex 9_1
   Sagzar1993 */

#include <stdio.h>
#include <stdlib.h>
//スタックに格納するデータの最大数
#define SIZE 1000

//スタックの定義
typedef struct stack{
    int size;
    int count;
    char data[SIZE];
    char *top;
} stack;

//スタックの初期化
void initialize_stack(stack *stk){
    stk->count = 0;
    stk->size = SIZE;
    stk->top = &(stk->data[SIZE]);
}

//データの追加
void push(stack *stk, char elem){
    if(stk->count >= stk->size){
        fprintf(stderr, "Error: stack overflow. (x=%c)\n", elem);
        exit(1);
    }
    else{
        stk->top--;
        *(stk->top) = elem;
        stk->count++;
    }
}

//データの取り出し
char pop(stack *stk){
    char latest;
    if(stk->count <= 0){
        fprintf(stdout, "Error: stack underflow.\n");
        exit(1);
    }
    else{
        latest = *(stk->top);
        stk->top++;
        stk->count--;
        return latest;
    }
}

int main(void){
    stack keyStk; //表示される文字を保存するスタック
    int i;
    char inputKey;
    //スタックを初期化
    initialize_stack(&keyStk);

    //１文字ずつ入力してスタックを操作
    while(1){
        scanf("%c", &inputKey);
        if(inputKey == '\n'){
            //文字列の最後に来たら終了
            break;
        }else if(inputKey != 'B'){
            //0か1ならスタックに文字を追加
            push(&keyStk, inputKey);
        }else if(keyStk.count > 0){
            //Bのとき、スタックが空でなければ最後に追加した文字を取り出し
            pop(&keyStk);
        }
    }
    //スタックの古い方から出力
    for(i = 0; i < keyStk.count; i++){
        printf("%c", keyStk.data[SIZE - 1 - i]);
    }
    printf("\n");
    return 0;
}

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

int main() {
    string n;
    cin>>n;
    int sum = 0;
    for(int i = 0 ; i < n.length() ; i++) {
        sum += (int)n[i] - 48;
    }
    

    if(sum%9 == 0)
    cout << "Yes";
    else
    cout<<"No";

    return 0;
}

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

int main() {
    int N;
    cin >> N;
    int D1,D2;
    int cnt = 0;
    bool hantei = false;

    for (int i=0;i<N;i++){
        cin >> D1 >> D2;

        if (D1 == D2){
            cnt++;
        }
        else{
            cnt = 0;
        }
        if (cnt == 3){
            hantei = true;
        }

    }
    if (hantei == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }


}


Measured memory_bytes: 3592
#include <stdio.h>

int main(void)
{
	int r,d,x[11]={0},i;
	
	scanf("%d %d %d",&r,&d,&x[0]);
	
	for(i=0;i<10;i++){
		x[i+1] = r * x[i] - d;
		printf("%d\n",x[i+1]);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <utility>
const int maxn = 100005;
using ll = long long;
const ll ha = 998244353LL;
ll fac[maxn], ifac[maxn];
ll pow_mod(ll a, ll b) {
  ll ans = 1, res = a;
  while(b) {
    if(1LL & b) ans = ans * res % ha;
    res = res * res % ha; b >>= 1;
  }
  return ans;
}
void process() {
  fac[0] = 1;
  const int N = 100000;
  for(int i = 1; i <= N; i ++) {
    fac[i] = fac[i - 1] * (ll)i % ha;
  }
  ifac[N] = pow_mod(fac[N], ha - 2LL);
  for(int i = N - 1; i >= 0; i --) {
    ifac[i] = (ll(i + 1)) * ifac[i + 1] % ha;
  }
}
ll C(int n, int m) {
  if(n >= 0) {
    if(n < m) return 0;
    ll ans = fac[n] * ifac[n - m] % ha;
    ans = ans * ifac[m] % ha;
    return ans;
  } else {
    if(m == 0) return 1;
    int t = -n;
    ll ans = fac[t + m - 1] * ifac[t - 1] % ha;
    ans = ans * ifac[m] % ha;
    if(1 & m) ans = ha - ans;
    return ans;
  }
}

ll up_v(int p, int c) {
  return C(c, p);
}
ll down_v(int p, int c) {
  ll ans = C(-c, p);
  if(1 & p) ans = ha - ans;
  return ans;
}

int main() {
  process();
  int k, n; scanf("%d%d", &k, &n);
  for(int i = 2; i <= 2 * k; i ++) {
    int up_c = 0, down_c = 0;
    for(int j = 1; j <= k; j ++) {
      if(j >= i) {
        down_c ++;
      } else {
        if((j * 2) == i) {
          up_c ++;
        } else if(j <= (i / 2)) {
          if((i - j) > k) {
            down_c ++;
          } else {
            down_c ++; up_c ++;
          }
        }
      }
    }
#ifdef LOCAL
    // printf("OGF of %d : %d, %d\n", i, up_c, down_c);
#endif
    ll ans = 0;
    for(int j = 0; j <= n; j ++) {
      ll delta = up_v(j, up_c) * down_v(n - j, down_c) % ha;
#ifdef LOCAL
      // printf("delta %d : %lld\n", j, delta);
#endif
      ans = (ans + delta) % ha;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 1792
/* Mashiro Shiina best girl */
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int a,b;
	cin >> a >> b;
	
	for (int i=1;i<=3;i++)
	if(a!=i && b!=i){
		cout << i << endl;
	}
}


Measured memory_bytes: 3656
n = int(input())
a =[0]+ list(map(int, input().split( )))
b =[0] + list(map(int, input().split( )))
c =[0] + list(map(int, input().split( )))

ans = 0 


for i in range(1,n):
    ans += b[a[i]]
    if a[i+1] == a[i]+1:
        ans += c[a[i]]
        #print(i,b[a[i]],c[a[i]],ans)
ans += b[a[n]]
   

print(ans)
        
         

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

#define EPS (1e-7)
#define INF (1<<27)
#define PI (acos(-1))

#define FOR(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define REP(i,n) FOR(i,0,n)

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;

int main() {
  int N, M, R; cin >> N >> M >> R;
  vector<int> r(R);
  REP(i,R) cin >> r[i];
  vector<vector<int>> d(N+1, vector<int>(N+1, INF));
  int a, b, c;
  REP(i,M) {
    cin >> a >> b >> c;
    d[a][b] = d[b][a] = c;
  }
  REP(k,N+1) REP(i,N+1) REP(j,N+1) chmin(d[i][j], d[i][k] + d[k][j]);
  ll ans = INF;
  whole(sort,r);
  do {
    ll sum = 0;
    REP(i,R-1) sum += d[r[i]][r[i+1]];
    chmin(ans, sum);
  } while(next_permutation(r.begin(), r.end()));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int a,b,c,d,e,f,g,h;
    string s,t;
    while(cin>>s){
        cin>>t;
        for(int i=0;i<t.size();i++){
            cout<<s[i];
            cout<<t[i];
        }
        if(s.size()>t.size())cout<<s[s.size()-1];
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

typedef struct{double x,y,z;} P;

const double R = 6378.1;
const double PI = acos(-1);


P calc(double a,double b){
  double z = R*sin(a);
  double x = R*cos(a)*cos(b),y=R*cos(a)*sin(b);
  return (P){x,y,z};
}

double dist(double a,double b,double c){
  return sqrt(a*a+b*b+c*c);
}

double rad(double sdist){
  double c = (R*R+R*R-sdist*sdist)/(2*R*R);
  return acos(c);
}

main(){
  
  while(true){
    P in[2];
    rep(i,2){
      double a,b;
      cin>>a>>b;
      if (a == -1)return false;
      a=a/180*PI;b=b/180*PI;
      in[i]=calc(a,b);
    }
    
    double sdist=dist(in[0].x-in[1].x,in[0].y-in[1].y,in[0].z-in[1].z);
    double trad =rad(sdist);
   

    double cdist=trad*R;
    printf("%.0lf\n",cdist);
    
  }
  return false;
}

Measured memory_bytes: 0
n, m = gets.chomp.split.map(&:to_i)
cnt = Array.new(n + 1, 0)
m.times do |_|
  l, r = gets.chomp.split.map(&:to_i)
  cnt[l - 1] += 1
  cnt[r] -= 1
end

(1..n).each do |i|
  cnt[i] += cnt[i - 1]
end

puts cnt.count(m)

Measured memory_bytes: 2556
def main():
    from sys import stdin
    def input():
        return stdin.readline().strip()

    n, c = map(int, input().split())
    channels = [[] for _ in range(c)]
    for _ in range(n):
        i, j, k = map(int, input().split())
        channels[k-1].append([i, j])

    programs = []
    for channel in channels:
        if channel == []:
            continue

        channel.sort()
        for i in range(len(channel)-1):
            if channel[i][1] == channel[i+1][0]:
                channel[i+1][0] = channel[i][0]
            else:
                programs.append(channel[i])
        programs.append(channel[-1])

    programs.sort()

    from heapq import heapify, heappushpop, heappush

    heap = [programs[0][1]]
    heapify(heap)
    for i in range(1, len(programs)):
        if heap[0] < programs[i][0]:
            heappushpop(heap, programs[i][1])
        else:
            heappush(heap, programs[i][1])
    
    print(len(heap))

main()

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

vector<ll> calc_divisor(ll n){
    vector<ll> res;
    for(ll i = 1LL; i*i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            ll j = n / i;
            if(i != j) res.push_back(j);
        }
    }
    //sort(res.begin(), res.end());
    sort(res.rbegin(), res.rend());
    return res;
}

int main(){
    ll n, m;
    cin >> n >> m;
    
    auto d = calc_divisor(m);
    ll ans;
    for(int i=0; i<d.size(); i++){
        if(m/d[i] >= n){
            ans = d[i];
            break;
        }
    }
    cout << ans << endl;
}


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

from collections import deque

k = int(input())

que = deque(reversed([i for i in range(1, 10)]))

x = -1
for _ in range(k):
    # print(f"loop: {_}")
    # print(f"que: {que}")
    x = que.pop()
    # print(f"x: {x}\n")
    if x % 10 != 0:
        que.appendleft(x * 10 + x % 10 - 1)
    que.appendleft(x * 10 + x % 10)
    if x % 10 != 9:
        que.appendleft(x * 10 + x % 10 + 1)

print(x)


Measured memory_bytes: 40816
N = int(input())
a = list(map(int, input().split()))
ans = [0] * 8
free = 0

for r in a:
    if r > 3199:
        free += 1
    else:
        ans[r // 400] = 1

min_ = max(sum(ans), 1)
#max_ = min(sum(ans) + free, 8)
max_ = sum(ans) + free
print(min_, max_)

Measured memory_bytes: 38384
S=input()
b,d="",0
t=False
for c in S:
    if t:
        d+=1
        #print(b+c)
        b=b+c
        t=not t
    elif len(b) == 2:
        d+=1
        #print(c)
        b=c
    else:
        if b!=c:
            #print(c)
            d+=1
            b=c
        else:
            b=c
            t=True
print(d)


Measured memory_bytes: 41692
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

int n, k, sol;
bool res[1000];
int main() {
    IOS; cin >> n >> k;
    for(int i=0; i<k; ++i) {
        int dd; cin >> dd;
        for(int j=0; j<dd; ++j) {
            int xx; cin >> xx;
            res[xx-1]=1;
        }
    }
    for(int i=0; i<n; ++i) {
        if(res[i]==0) ++sol;
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 3640
def check(n):
    i = 1
    while n > 0:
        n -= i
        if n == 0:
            return i
        i += 1
    return False


def solve(n):
    s = check(n)
    if s == False:
        print('No')
        return
    buf = [[s] + [0] * s for _ in range(s + 1)]
    t = s
    u = 1
    for i in range(s):
        buf[i][i + 1:i + t + 1] = list(range(u, u + t))
        for j in range(t):
            buf[i + j + 1][i + 1] = u + j
        u += t
        t -= 1
    print('Yes')
    print(s + 1)
    print('\n'.join(' '.join(map(str, b)) for b in buf))


n = int(input())
solve(n)


Measured memory_bytes: 14484
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc= new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int pattern = 0;
        for(int k = 0; k <= a; k++) {
            for(int i = 0; i <= b; i++) {
                for(int j = 0; j <= c; j++) {
                    int sum = 500 * k + 100 * i + 50 * j;
                    if(sum == x) pattern++;
                    if(sum > x)break;
                }
            }
        }
        System.out.println(pattern);
    }
}

Measured memory_bytes: 22868
#include<stdio.h>

int main(){
    int i,j,k,num1,first[10000],num2,second[10000],same=0;
    //一つ目の数列
    scanf("%d",&num1);
    for(int i=0;i<num1;i++){
        scanf("%d",&first[i]);
    }
/*
    //デバッグ
    for(int i=0;i<num1;i++){
        printf("%d ",first[i]);
    }
    */

    //二つ目の数列
    scanf("%d",&num2);
    for(i=0;i<num2;i++){
        scanf("%d",&second[i]);
    }
    /*
     //デバッグ
    for(i=0;i<num2;i++){
        printf("%d",second[i]);
    }
    printf("\n");
    */
     for(j=0;j<num2;j++){
         for(k=0;k<num1;k++){
           if(first[k]==second[j]){
            same++;
            break;
           }
         }
     }
    printf("%d\n",same);

    return 0;
}
/*
scanf()
for(i=0;i<n;i++){
    scanf k
    for(j=0;f[j] != k j++) sum++; 
}
*/


Measured memory_bytes: 2108
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DEBUG_OUTPUT_ENABLED 1
	#define DBG(X) dout << #X << "=" << (X) << '\n';
	#define SAY(X) dout << (X) << '\n';
#else
	#define DEBUG_OUTPUT_ENABLED 0
	#define DBG(X) 42;
	#define SAY(X) 42;
#endif

#define dout   debug::instance

using namespace std;

template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
namespace debug {
	struct DebugStream {
		private:
			bool is_first;
		public:
			DebugStream(bool _is_first): is_first(_is_first) {}
			template<typename T> DebugStream operator<<(const T& value) const {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				cout << value;
				return DebugStream(false);
			};

			template<typename T> DebugStream printArray(T* l, T* r) {
				assert(DEBUG_OUTPUT_ENABLED);
				if(is_first) cout << "[DBG] ";
				while(l != r) {
					cout << (*l);
					++l;
					if(l == r) {
						cout << '\n';
					} else {
						cout << ' ';
					}
				}
				return DebugStream(false);
			}
	};
	DebugStream instance(true);
};

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }
const int MAXN = (int)1e5 + 7;
int X, Y, A, B, C;
ll a[MAXN], b[MAXN], c[MAXN], answ;
void solve() {
	cin >> X >> Y >> A >> B >> C; answ = 0;
	for(int i = 0; i < A; ++i) cin >> a[i];
	for(int i = 0; i < B; ++i) cin >> b[i];
	for(int i = 0; i < C; ++i) cin >> c[i];
	vector<pll> ord;
	for(int i = 0; i < A; ++i) ord.emplace_back(a[i], 1);
	for(int i = 0; i < B; ++i) ord.emplace_back(b[i], 2);
	for(int i = 0; i < C; ++i) ord.emplace_back(c[i], 3);
	vector<int> eaten(4, 0);
	sort(ord.begin(), ord.end());
	reverse(ord.begin(), ord.end());
	for(int i = 0; i < A + B + C; ++i) {
		if(eaten[1] + eaten[2] + eaten[3] >= X + Y) continue;
		int t = ord[i].second;
		if(t == 1 && eaten[t] >= X) continue;
		if(t == 2 && eaten[t] >= Y) continue;
		++eaten[t];
		answ += ord[i].first;
	}
	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 12908
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// #include<deque>
// #include<multiset>
// #include<bitset>
// #include<cstring>
// #include<bits/stdc++.h>
// }}}
using namespace std;
using ll = long long;

int a[112345];

int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for(int i = 0; i < n; i++) cin >> a[i];
  sort(a, a + n);
  ll g = 0;
  for(int i = 0; i < n; i++) {
    ll t = a[i];
    if(i) t -= a[i-1];
    g ^= (n - i) * (t & 1);
  }
  cout << (g ? "first" : "second") << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  int N, X;
  std::cin >> N >> X;
  int t = 0, ans=N+1;
  for(int i = 0; i < N; ++i) {
    int L; std::cin >> L;
    t += L;
    if(t > X && ans > N) ans = i+1;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


struct Dice {
  int omote,ura,up,down,left,right;
  Dice(vector<int> &a){
    omote = a[0]; ura = a[5];
    up = a[4]; down = a[1];
    left = a[3]; right = a[2];
  }

  void operate(int &a,int &b,int &c,int &d){
    int buf = a;
    a = b; b = c; c = d; d = buf;
  }

  void rotate(char c){
    if (c == 'E') operate(omote, left, ura, right);
    if (c == 'N') operate(omote, down, ura, up);
    if (c == 'S') operate(omote, up, ura, down);
    if (c == 'W') operate(omote, right, ura, left);
    if (c == 'R') operate(down, right, up, left);
    if (c == 'L') operate(down, left, up, right);
  }
};

bool isidentical(Dice d1, Dice d2){
  bool ok = true;
  if (d1.omote != d2.omote ) ok = false;
  if (d1.ura != d2.ura ) ok = false;
  if (d1.up != d2.up ) ok = false;
  if (d1.down != d2.down ) ok = false;
  if (d1.left != d2.left ) ok = false;
  if (d1.right != d2.right ) ok = false;
  return ok;
}

bool check(Dice &d1, Dice &d2){
  // 同一性のチェック
  bool ok = false;
  rep(i, 6){
    char c = i % 2 == 0 ? 'N' : 'W';
    d2.rotate(c);
    ok = ok | isidentical(d1, d2);
    rep(j, 4){
      d2.rotate('L');
      ok = ok | isidentical(d1, d2);
    }
  }
  return ok;
}

int main() {
  int N; cin >>N;
  vector<int> tmp = {0,0,0,0,0,0};
  vector<Dice> ds(N, Dice(tmp));
  vector<int> a;
  rep(i, N){
    a.assign(6, 0); rep(i, 6) cin >>a[i];
    ds[i] = Dice(a);
  }
  bool ok = false;
  for (int i=0; i<N; i++){
    for (int j=i+1; j<N; j++){
      ok = ok | check(ds[i], ds[j]);
    }
  }
  cout <<(ok ? "No" : "Yes") <<endl;
}


Measured memory_bytes: 3152
#include<bits/stdc++.h>
#include<vector>
using namespace std;
#define MAX 200005
#define MOD 1000000007
#define INF 4000000000000000000
#define EPS 0.0000000000001
vector<int> Graph[MAX];
int H[MAX];
bool cnt[MAX];
int main()
{
    int N,M,i,j;
    scanf("%d %d",&N,&M);
    for(i=1;i<=N;i++)
    {
        scanf("%d",&H[i]);
    }
    int A,B;
    for(i=0;i<M;i++)
    {
        scanf("%d %d",&A,&B);
        Graph[A].push_back(B);
        Graph[B].push_back(A);
    }
    int ans=0;
    for(i=1;i<=N;i++)
    {
        for(j=0;j<Graph[i].size();j++)
        {
            if(H[Graph[i][j]]>=H[i]) break;
        }
        if(j==Graph[i].size())
        {
            ans++;
        }
    }
    printf("%d",ans);
    return 0;
}



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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi> vpi;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rsz resize
#define bk back()
#define pb push_back

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)
#define trav(x,a) for (auto& x: a)

const int MX  = 1e6+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

// FILE I/O
void setIn(string s) { freopen(s.c_str(),"r",stdin); }
void setOut(string s) { freopen(s.c_str(),"w",stdout); }
void setIO(string s = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); // fast I/O
    // cin.exceptions(cin.failbit);
    // throws exception when do smth illegal
    // ex. try to read letter into int
    if (sz(s)) { setIn(s+".in"), setOut(s+".out"); } // for USACO
}

int cnt[MX];

int32_t main() {

    setIO();

    int n; cin >> n;

    vi arr(n); trav(x,arr) cin >> x;
 
    sort(all(arr));

    trav(x,arr) {
        if (cnt[x] >= 2) continue; cnt[x]++;
    }

    bitset<MX+1> vis,ya; int res = 0;
    F0R(w,n) {
        int x = arr[w]; 
        if (ya[x]) continue;       
        if (!vis[x] && cnt[x] == 1) res++;
        if (!vis[x])
        for (int j = x; j < MX; j += x) vis[j] = true;  
        ya[x] = 1;
    }

    cout << res << "\n";

}


Measured memory_bytes: 8212
#include <bits/stdc++.h>
using namespace std;
int dp[305][305];
int s[305][305];
int c[305][305];
int n,k,mod;
inline int add(int a,int b)
{return (a+b>=mod?a+b-mod:a+b);}
int main (){
	int i,j,l;
	scanf ("%d%d%d",&n,&k,&mod);
	for (i=0;i<=k;i++) dp[1][i]=1;
	for (i=0;i<=k;i++) s[1][i]=(k-i+1)%mod;
	for (i=0;i<=n+1;i++)
	{c[i][0]=c[i][i]=1;
	for (j=1;j<i;j++)
	{c[i][j]=c[i-1][j-1]+c[i-1][j];
	c[i][j]=(c[i][j]>=mod?c[i][j]-mod:c[i][j]);
	}
	}
	for (i=2;i<=n+1;i++)
	{for (j=0;j<=k;j++)
	{for (l=1;l<i;l++)
	{int wys=1ll*c[i-2][l-1]*dp[i-l][j]%mod;
	wys=1ll*wys*s[l][j+1]%mod;
	dp[i][j]=add(dp[i][j],wys);
	}
	}
	s[i][k]=dp[i][k];
	for (j=k-1;j>=0;j--) s[i][j]=add(s[i][j+1],dp[i][j]);
	}
	printf ("%d\n",dp[n+1][0]);
	return 0;
}
	
	

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

using namespace std;

int main() {

	double a,b,x;
	cin >> a >> b >> x;

	double d,e;
	double res;
	if (x < b*a*a / 2) {
		e = x / a / b * 2;
		res = atan(b / e)/3.14159265354*180;
	}
	else {
		d = x / a / a * 2 - b;
		res = atan((b - d) / a) / 3.14159265354 * 180;
	}

	cout << setprecision(15) << res << endl;
}

Measured memory_bytes: 384
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;

	long ans = long.max;
	foreach (i; 1..N)
	{
		auto a = i;
		auto b = N - i;
		long cnt;
		while (a != 0)
		{
			cnt += a % 10;
			a   /= 10;
		}
		while (b != 0)
		{
			cnt += b % 10;
			b   /= 10;
		}
		ans = min(ans, cnt);
	}

	writeln(ans);
	stdout.flush();
	debug readln();
}


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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)

#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";REP(i, v.size())cout<<' '<<v[i];cout<<'\n'
#define ALL(a) (a).begin(), (a).end()

#define CHMIN(a, b) a=min((a), (b))
#define CHMAX(a, b) a=max((a), (b))

const ll MOD=1000000007ll;
// const ll MOD=998244353ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

ll sum[252521], dp1[252521], dp2[252521], dp3[252521];
ll INF=1e16;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int l;
	ll a[252521];
	cin>>l;
	bool ok=false;
	REP(i, l){
		cin>>a[i];
		if(a[i]){
			ok=true;
		}
		sum[i+1]=sum[i]+a[i];
	}
	if(!ok){
		cout<<0<<'\n';
		return 0;
	}
	dp1[0]=dp2[0]=dp3[0]=INF;
	ll ans=INF;
	REP(i, l){
		dp1[i+1]=min(dp1[i], sum[i])+(a[i]==0 ? 2 : a[i]&1);
		dp2[i+1]=min({dp1[i], dp2[i], sum[i]})+(~a[i]&1);
		dp3[i+1]=min({dp1[i], dp2[i], dp3[i], sum[i]})+(a[i]==0 ? 2 : a[i]&1);
		CHMIN(ans, min({dp1[i+1], dp2[i+1], dp3[i+1]})+sum[l]-sum[i+1]);
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 8960
#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 mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define umii            unordered_map<int,int>
#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 mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define rep(i,st,end)   for(int i=st;i<end;i++)
#define w(x)            int x; cin>>x; while(x--)
//mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void s_g_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

int32_t main()
{
	s_g_c();
	int l, r, d;
	cin >> l >> r >> d;
	int count = 0;
	for (int i = l; i <= r; i++)
	{
		if (i % d == 0)
			count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
 


int main(){
    int n,k;cin >> n >> k;
    if((n-2)*(n-1)<2*k){
        puts("-1");
        return 0;
    }
    int r = (n-2)*(n-1)/2 - k;
    cout << n-1+r << endl;
    for (int i = 1; i <= n-1; i++) {
        cout << 1 << " " << i+1 << endl;
    }
    for (int i = 2; i <= n-1; i++) {
        if(!r) return 0;
        for (int j = i+1; j <= n; j++) {
            if(!r) return 0;
            cout << i << " " << j << endl;
            r--;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	char s[10004];
	scanf("%d%s", &n, s);
	n %= 26;
	int len = strlen(s);
	for(int i = 0; i < len; ++i){
		printf("%c", (s[i] - 'A' + n) % 26 + 'A');
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;

// vector<p> cut(M);
// cut[i].second
// cut[i].first;
// REP(i,M){
//     int a,b;cin>>a>>b;
//     cut[i] = make_pair(b,a);//last first の順番
// }
// sort(cut.begin(),cut.end());

int main ()
{
    int max_len=0, cnt=0;

    int A,B,C,D,E;
    str S;
    cin>>S;
    int i=0;
    while(i<S.length()){

      while(i<S.length() && S[i] != 'A' && S[i] != 'G' && S[i] != 'C' && S[i] != 'T' ) i++;

      while(i<S.length() && (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') ){
        i++;
        cnt++;
      }

      max_len = max(max_len, cnt);
      cnt=0;
      i++;
    }

    cout<<max_len<<endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

int main() {
  int h, w; cin >> h >> w;
  if (h == 1 || w == 1) {
    cout << "1\n";
  } else {
    cout << 1LL * ((h + 1) / 2) * ((w + 1) / 2) + 1LL * (h / 2) * (w / 2) << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**7)

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

n = readint()
a = readints()

mod = 10**9+7
s = sum(a)
ans = 0

for i in range(n):
    s-=a[i]
    ans += a[i]*s
    ans %= mod

print(ans)


Measured memory_bytes: 92772
#include <cstdint>

template <::std::uint_least32_t Modulus> class modint {
	using u32 = ::std::uint_least32_t;
	using u64 = ::std::uint_least64_t;

public:
	using value_type = u32;
	value_type a;
	constexpr modint(const value_type x = 0) noexcept : a(x) {}
	constexpr value_type value() const noexcept { return a; }
	constexpr modint operator+(const modint &o) const noexcept {
		return a + o.a < Modulus ? modint(a + o.a) : modint(a + o.a - Modulus);
	}
	constexpr modint operator-(const modint &o) const noexcept {
		return modint(a < o.a ? a + Modulus - o.a : a - o.a);
	}
	constexpr modint operator*(const modint &o) const noexcept {
		return modint(static_cast<u64>(a) * o.a % Modulus);
	}
	constexpr modint operator/(const modint &o) const {
		return modint(static_cast<u64>(a) * (~o).a % Modulus);
	}
	modint &operator+=(const modint &o) noexcept {
		if ((a += o.a) >= Modulus)
			a -= Modulus;
		return *this;
	}
	modint &operator-=(const modint &o) noexcept {
		if (a < o.a)
			a += Modulus;
		a -= o.a;
		return *this;
	}
	modint &operator*=(const modint &o) noexcept {
		a = static_cast<u64>(a) * o.a % Modulus;
		return *this;
	}
	modint &operator/=(const modint &o) {
		a = static_cast<u64>(a) * (~o).a % Modulus;
		return *this;
	}
	modint operator~() const noexcept { return pow(Modulus - 2); }
	modint operator-() const noexcept { return a ? modint(Modulus - a) : *this; }
	modint &operator++() noexcept {
		if (++a == Modulus)
			a = static_cast<value_type>(0);
		return *this;
	}
	modint &operator--() noexcept {
		if (!a)
			a = Modulus;
		--a;
		return *this;
	}
	constexpr bool operator==(const modint &o) const noexcept { return a == o.a; }
	constexpr bool operator!=(const modint &o) const noexcept { return a != o.a; }
	constexpr bool operator<(const modint &o) const noexcept { return a < o.a; }
	constexpr bool operator<=(const modint &o) const noexcept { return a <= o.a; }
	constexpr bool operator>(const modint &o) const noexcept { return a > o.a; }
	constexpr bool operator>=(const modint &o) const noexcept { return a >= o.a; }
	constexpr explicit operator bool() const noexcept { return a; }
	constexpr explicit operator value_type() const noexcept { return a; }
	modint pow(u64 x) const noexcept {
		u64 t = a, u = 1;
		while (x) {
			if (x & 1)
				u = u * t % Modulus;
			t = (t * t) % Modulus;
			x >>= 1;
		}
		return modint(u);
	}
};

#include <iostream>
#include <string>
#include <vector>

int main(void) {
	using mint = modint<1000000007>;
	int n;
	std::string s;
	std::cin >> n >> s;
	mint dp[5003][5003] = {};
	dp[0][0] = 1;
	for (int i = 1;i <= n;++i) {
		dp[i][0] = dp[i - 1][1] * 2 + dp[i - 1][0];
		for (int j = 1;j <= i;++j) {
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j + 1] * 2;
		}
	}
	std::cout << dp[n][s.length()].a << std::endl;
	return 0;
}


Measured memory_bytes: 98048
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
  fastio
  ll n,k;
  cin>>n>>k;
  ll a[n];
  for(ll i=0; i<n; i++){
    cin>>a[i];
  }
  sort(a, a+n);
  ll dp[k+1];
  memset(dp, 0, sizeof(dp));
  for(ll i=1; i<=k; i++){
    if(i<a[0]){
      dp[i]=0;
    }
    else{
      for(ll j=0; j<n; j++){
        if(a[j]<=i){
          dp[i] = dp[i] || !dp[i-a[j]];
        }
      }
    }
  }
  if(dp[k]){
    cout<<"First\n";
  }
  else{
    cout<<"Second\n";
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int arr[n];

    for (int i = 0; i < n; i++) {
        cin >> arr[i];
    }
    for (int i = n - 1; i > 0; i--) {
        cout << arr[i] << " ";
    }
    cout << arr[0] << endl;
}



Measured memory_bytes: 3096
#pragma warning(disable:4786)
#pragma warning(disable:4996)
#include<list>
#include<bitset>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<functional>
#include<string>
#include<cstring>
#include<cstdlib>
#include<queue>
#include<utility>
#include<fstream>
#include<sstream>
#include<cmath>
#include<stack>
#include<assert.h>
using namespace std;

#define MEM(a, b) memset(a, (b), sizeof(a))
#define CLR(a) memset(a, 0, sizeof(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define ABS(X) ( (X) > 0 ? (X) : ( -(X) ) )
#define S(X) ( (X) * (X) )
#define SZ(V) (int )V.size()
#define FORN(i, n) for(i = 0; i < n; i++)
#define FORAB(i, a, b) for(i = a; i <= b; i++)
#define ALL(V) V.begin(), V.end()
#define IN(A, B, C)  ((B) <= (A) && (A) <= (C))

typedef pair<int,int> PII;
typedef pair<double, double> PDD;
typedef vector<int> VI;
typedef vector<PII > VP;

#define AIN(A, B, C) assert(IN(A, B, C))

//typedef int LL;
typedef long long int LL;
//typedef __int64 LL;

int main()
{
	int n;
	LL T;
	scanf("%d %lld", &n, &T);
	int end = 0;
	LL ans = 0;
	for (int i = 0; i < n; i++) {
		int t;
		scanf("%d", &t);
		ans += MIN((t + T - end), T);
		end = t + T;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 764
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"
#include "cmath"
#include "set"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  string s;
  cin >> s;
  cout << (s == "AAA" || s == "BBB" ? "No" : "Yes") << "\n";
}

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

const int maxn(2e5 + 5);
const int mod(1e9 + 7);
const int inv2((mod + 1) >> 1);

inline void inc(int &x, const int y) {  x = x + y >= mod ? x + y - mod : x + y;  }

inline void dec(int &x, const int y) {  x = x - y < 0 ? x - y + mod : x - y;  }

inline int add(const int x, const int y) {  return x + y >= mod ? x + y - mod : x + y;  }

inline int sub(const int x, const int y) {  return x - y < 0 ? x - y + mod : x - y;  }

inline int fpow(ll x, int y) {
	ll ret = 1;
	for (; y; y >>= 1, x = x * x % mod)
		if (y & 1) ret = ret * x % mod;
	return ret;
}

int B, W, fac[maxn], inv[maxn], pw[maxn], ipw[maxn], f[maxn], g[maxn];

inline int binom(int x, int y) {
	if (x < 0 || y < 0 || y > x) return 0;
	return (ll)fac[x] * inv[y] % mod * inv[x - y] % mod;
}

int main() {
	int i, mx = 2e5;
	fac[0] = fac[1] = inv[0] = inv[1] = pw[0] = ipw[0] = 1, ipw[1] = inv2, pw[1] = 2;
	for (i = 2; i <= mx; ++i) fac[i] = (ll)fac[i - 1] * i % mod, ipw[i] = (ll)ipw[i - 1] * inv2 % mod;
	for (i = 2; i <= mx; ++i) pw[i] = add(pw[i - 1], pw[i - 1]);
	for (i = 2; i <= mx; ++i) inv[i] = (ll)(mod - mod / i) * inv[mod % i] % mod;
	for (i = 2; i <= mx; ++i) inv[i] = (ll)inv[i - 1] * inv[i] % mod;
	scanf("%d%d", &B, &W);
	for (i = 1; i <= B + W; ++i) {
		f[i] = f[i - 1], g[i] = g[i - 1];
		inc(f[i], (ll)ipw[i] * binom(i - 1, B - 1) % mod);
		inc(g[i], (ll)ipw[i] * binom(i - 1, W - 1) % mod);
		printf("%d\n", add(g[i - 1], (ll)inv2 * sub(1, add(g[i - 1], f[i - 1])) % mod) % mod);
	}
    return 0;
}

Measured memory_bytes: 6912