akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class CBoxesAndCandies {
public:
	void solve(istream& in, ostream& out) {
        ll n,x,ans = 0;
        in >> n >> x;
        vector<ll> a(n);
        rep(i,n) in >> a[i];
        rep(i,n-1){
            ll check = a[i] + a[i+1] - x;
            if(check > 0){
                ans += check;
                if(a[i+1] >= check) a[i+1] -= check;
                else a[i+1] = 0;
            }
        }
        out << ans << endl;
	}
};

int main() {
	CBoxesAndCandies solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <cstdio>
#include <string>
#include <iterator>
#include <vector>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main( ) {
    // freopen("B.01.in","r",stdin);
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    int n,m;
    char s[256];
    scanf("%d\n",&n);
    map<string,int> nmap;
    while (n--)
    {

        scanf("%s\n",s);
        nmap[s]++;
    }
    scanf("%d\n",&m);
    // map<string,int> mmap;
    while (m--)
    {
        scanf("%s\n",s);
        nmap[s]--;
    }
    int mx=INT32_MIN;
    trav(it, nmap){
        if(it.second>mx){
            mx=it.second;
        }
    }
    // mx = (mx<0)?0:mx;
    printf("%d\n",(mx<0)?0:mx);
    return 0;
}

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> d(k);
    vector<int> snuke(n, 0);
    rep(i, k){
        int d;
        cin >> d;
        rep(j, d){
            int temp;
            cin >> temp;
            temp--;
            snuke[temp]++;
        }
    }
    int ans = 0;
    rep(i, n){
        if(snuke.at(i) == 0){
            ans++;
        }
    }
    cout << ans <<endl;


    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
string s; int len;
int main()
{
    cin >> s;
    len = s.size();
    for(int i = 0; i < len; i++)
    {
        if(s[i] == 'C')
        {
            for(int j = i + 1; j < len; j++)
            {
                if(s[j] == 'F')
                {
                    return printf("Yes") - 3;
                }
            }
        }
    }
    return printf("No") - 2;
}

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

#define mp make_pair
#define pb push_back

#define int int64_t
#define ld long double

const int MOD = 1e9+7;
const int N = 1e6+5;

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

    int n;
    cin>>n;
    string s;
    cin>>s;

    int r=0, g=0, b=0;
    for(char c:s) {
        if(c=='R')
            r++;
        else if(c=='G')
            g++;
        else if(c=='B')
            b++;
    }
    int ans =r*g*b;
    for(int i=1;i<=n;i++) {
        for(int j=0;j+2*i<n;j++) {
            if(s[j]!=s[j+i]&&s[j+i]!=s[j+2*i]&&s[j+2*i]!=s[j]) {
                ans--;
            }
        }
    }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll h[100009];
ll dp[100009];
int main() {
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>h[i];
    memset(dp,0x3f, sizeof(dp));
    dp[1]=0;dp[2]=abs(h[2]-h[1]);
    for(int i=3;i<=n;i++){
        for(int j=i-1;j>=(i-k>0?i-k:1);j--)
            dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
    }
    cout<<dp[n]<<endl;
    return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,N,j) for(int i = (N-1);i >= (j);i--)
#define _rec(i,N,j) for(int i = (N);i >=(j);i--)
#define ALL(x) x.begin(),x.end()
#define MEM(a,n) memset(a,n,sizeof(a))
#define fst first
#define scd second
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

int get_int(){int x;scanf("%d",&x);return x;}
LL get_ll(){LL x;scanf("%lld",&x);return x;}
double get_db(){double x;scanf("%lf",&x);return x;}

template<typename T> int chmin(T &a,T b){if(a > b){a = b;return 1;}else return 0;}
template<typename T> int chmax(T &a,T b){if(a < b){a = b;return 1;}else return 0;}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {_for(i,0,v.size()) os << v[i] << " ";return os;}
template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){for(auto a:v) os << a <<" ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& v){os << v.fst <<" "<<v.scd << " ";return os;}
template<typename T1,typename T2>
ostream& operator<<(ostream& os,const map<T1,T2>& v){for(auto a:v) cout << a << endl;return os;}

static const int dx[8] = { -1,  0, 1, 0,  1, -1,  1, -1};
static const int dy[8] = {0,  1, 0,  -1,  1, -1, -1,  1};
const double pi  = acos(-1.0);
const double eps = 1e-8;
//const LL  INF  = 0x3f3f3f3f3f3f3f3f;
const int inf  = 0x3f3f3f3f;

const int maxn = 1e5+5;
const int mod = 1e9+7;

LL num[maxn];
LL N,K;
int dp[105][maxn][2];

int add(LL x,LL y){return (x+y)%mod;}
int mult(LL x,LL y){return (x*y)%mod;}

int main()
{
    cin >> N >> K;
    int s = sqrt(N);
    _rep(i,1,s){
        dp[0][i][0] = 1;
        if(i == s){
            dp[0][i][1] = (N/i - s);
        }
        else dp[0][i][1] = N/i - N/(i+1);
    }

    _for(i,0,K-1){
        int sum = 0;

        for(int j = 1;j <= s;j++){
            sum = add(sum,dp[i][j][0]);
            //cout << sum << endl;
            if(j == s){
                dp[i+1][j][1] = mult(sum,N/j - s);
            }else{
                dp[i+1][j][1] = mult(sum,N/j - N/(j+1));
            }
        }
        //cout << sum << endl;
        int sum2 = 0;
        for(int j = s; j >= 1;j--){
            dp[i+1][j][0] = add(dp[i+1][j][0],sum);
            sum2 = add(sum2 , dp[i][j][1]);

            dp[i+1][j][0] = add(dp[i+1][j][0],sum2);
        }
    }

    int ans = 0;

    _rep(i,1,s){
        ans = add(ans,dp[K-1][i][0]);
        ans = add(ans,dp[K-1][i][1]);
        //cout << dp[K-2][i][0] << endl;
        //cout << dp[K-2][i][1] << endl;

    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 76800
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#define inf 0x3f3f3f3f
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0' || ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0' && ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
int stack[20];
inline void write(int x)
{
	if(x<0){putchar('-');x=-x;}
    if(!x){putchar('0');return;}
    int top=0;
    while(x)stack[++top]=x%10,x/=10;
    while(top)putchar(stack[top--]+'0');
}
inline void pr1(int x){write(x),putchar(' ');}
inline void pr2(int x){write(x),puts("");}
queue<int>q;
struct node
{
	int x,y,c,next;
}a[400010];int len,last[200010],cur[200010]; 
inline void trins(int x,int y,int c)
{
	len++;
	a[len].x=x;a[len].y=y;a[len].c=c;
	a[len].next=last[x];last[x]=len;
}
inline void ins(int x,int y,int c){trins(x,y,c),trins(y,x,0);}
int st,ed,d[200010];
inline bool bfs()
{
	memset(d,0,sizeof(d));d[st]=1;
	q.push(st);
	while(q.empty()!=true)
	{
		int x=q.front();q.pop();
		for(int k=last[x];k;k=a[k].next)
		{
			if(!a[k].c)continue;
			int y=a[k].y;
			if(!d[y])d[y]=d[x]+1,q.push(y);
		}
	}
	if(!d[ed])return false;
	else return true;
}
inline int dinic(int x,int flow)
{
	if(x==ed)return flow;
	int sum=0;
	for(int &k=cur[x];k;k=a[k].next)
	{
		if(!a[k].c)continue;
		if(sum==flow)break;
		int y=a[k].y;
		if(d[y]==d[x]+1)
		{
			int uf=dinic(y,min(a[k].c,flow-sum));
			a[k].c-=uf,a[k^1].c+=uf;sum+=uf;
		}
	}if(!sum)d[x]=0;
	return sum;
}
int fa[2][100010],belong[2][100010];
inline int findfa(int id,int x)
{
	if(fa[id][x]!=x)fa[id][x]=findfa(id,fa[id][x]);
	return fa[id][x];
}
int p[2][100010];
int main()
{
    //freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	int n=read(),tot=0;
	for(int i=1;i<=n;i++)fa[0][i]=fa[1][i]=i;
	for(int i=1;i<=n;i++)
	{
		p[0][i]=read()+1;
		int fx=findfa(0,i),fy=findfa(0,p[0][i]);
		if(fx!=fy)fa[0][fx]=fy;
	}
	for(int i=1;i<=n;i++)if(findfa(0,i)==i)belong[0][i]=++tot;
	for(int i=1;i<=n;i++)
	{
		p[1][i]=read()+1;
		int fx=findfa(1,i),fy=findfa(1,p[1][i]);
		if(fx!=fy)fa[1][fx]=fy;
	}
	for(int i=1;i<=n;i++)if(findfa(1,i)==i)belong[1][i]=++tot;
	len++;st=0,ed=++tot;int ans=0;
	for(int i=1;i<=n;i++)
	{
		ans++;int f0=fa[0][i],f1=fa[1][i];
		if(p[0][i]==i)
		{
			if(p[1][i]!=i)ins(st,belong[1][f1],1);
			else ans--;
		}
		else if(p[1][i]==i)ins(belong[0][f0],ed,1);
		else
		{
			if(p[0][i]==p[1][i])ins(belong[0][f0],belong[1][f1],1),ins(belong[1][f1],belong[0][f0],1);
			else ins(belong[0][f0],belong[1][f1],1);
		}
	}
	while(bfs()==true)
	{
		for(int i=0;i<=tot;i++)cur[i]=last[i];
		ans-=dinic(st,inf);
	}
	pr2(ans);
	return 0;
}

Measured memory_bytes: 11776
N = int(input())
city_dict = {}
for i in range(N):
  S, P = input().split()
  if S in city_dict:
    city_dict[S].append({'num' : i, 'score' : int(P)})
    continue
  city_dict[S] = [{'num' : i, 'score' : int(P)}]
  
for city in sorted(city_dict):
  sorted_city_list = sorted(city_dict[city], key=lambda x : x['score'], reverse = True)
  for node in sorted_city_list:
    print(node['num']+1)

Measured memory_bytes: 3064
#include<iostream>
                using namespace std;
                int main(){
                 int M,N,i;
                 long long int T[110],P,X,sum[110],total=0;
                 cin>>N;
                 for(i=0;i<N;i++){
                  cin>>T[i];
                  total += T[i];
                 }
                 cin>>M;
                 for(i=0;i<M;i++){
                  cin>>P>>X;
                  P--;
                  sum[i] = total -T[P] + X;
                 }
                 for(i=0;i<M;i++){
                  cout<<sum[i]<<endl;
                }
                 return 0;
    }

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9
#define f first
#define s second

typedef long long ll;

using namespace std;

int main()

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

    int n, d;

	cin >> n >> d;

    d*=2, d++;

    cout << (n+d-1)/d;

    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  ll i,j,N,M,a,b,ans=0;
  string s,t="AC";cin>>s;
  rep(i,(ll)s.size()){
    if(s[i]==t[0]&&s[i+1]==t[1]){
      ans=1;
    }
  }
  if(ans){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#require 'pp'

n, m, k = gets.split.map(&:to_i)
a_n = gets.split.map(&:to_i)
b_n = gets.split.map(&:to_i)

sum_a = Array.new(n)
sum_b = Array.new(m)

sum_a[0] = a_n[0]
1.upto(n-1) do |i|
    sum_a[i] = sum_a[i-1] + a_n[i]
end

sum_b[0] = b_n[0]
1.upto(m-1) do |i|
    sum_b[i] = sum_b[i-1] + b_n[i]
end

sum_a.delete_if {|x| x > k }
sum_b.delete_if{|y| y > k}

max = [sum_a.length, sum_b.length].max

a = 0
b = sum_b.length - 1
while b >= 0 && a < sum_a.length
    x = sum_a[a] + sum_b[b] 
    if x > k
        b -= 1
    else
        # ok
        if a + b + 2 > max
            max = a + b + 2
        end
        a += 1
    end
end

a = sum_a.length - 1
b = 0
while a >= 0 && b < sum_b.length
    x = sum_a[a] + sum_b[b] 
    if x > k
        a -= 1
    else
        if a + b + 2 > max
            max = a + b + 2
        end
        b += 1
    end
end

puts max


Measured memory_bytes: 44576
import collections

def inputN(typ=str):
    return map(typ, raw_input().split())


N = inputN(int)[0]
v = inputN(int)

col0 = collections.Counter(v[::2])
col1 = collections.Counter(v[1::2])
X0 = col0.most_common()
X1 = col1.most_common()
#print X0
#print X1

if X0[0][0] == X1[0][0]:
    if len(X0) == 1 and len(X1) == 1:
        k0 = X0[0][1]
        k1 = 0
    elif len(X0) == 1:
        k0 = X0[0][1]
        k1 = X1[1][1]
    elif len(X1) == 1:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] >= X1[1][1]:
        k0 = X0[1][1]
        k1 = X1[0][1]
    elif X0[1][1] < X1[1][1]:
        k0 = X0[0][1]
        k1 = X1[1][1]
else:
    k0 = X0[0][1]
    k1 = X1[0][1]

print N - k0 - k1


Measured memory_bytes: 22172
N, M = map(int, input().split())
X = list(map(int, input().split()))
X = sorted(X)
Y = []

for i in range(M - 1):
	Y.append(X[i + 1] - X[i])
Y = sorted(Y, reverse = True)

print(max(X) - min(X) - sum(Y[0 : N - 1]))

Measured memory_bytes: 59048
s=gets.to_i
h = {}
h[s] = 1
2.upto(1000000) do |i|
#  puts s
  if s.odd?
    s = 3 * s + 1
  else
    s = s/2
  end
  if h.has_key?(s)
    puts i
    exit
  else
    h[s] = 1
  end
end


Measured memory_bytes: 1788
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func LCM(T *[][]int, D *[][]int, a, b int) int {
  for a != b {
    if (*D)[a][0] < (*D)[b][0] {
      b = (*D)[b][1]
    } else if (*D)[b][0] < (*D)[a][0] {
      a = (*D)[a][1]
    } else {
      a = (*D)[a][1]
      b = (*D)[b][1]
    }
  }
  return a
}

func Solve() {
  N := NextInt()
  T := make([][]int, N)
  for i := range T {
    T[i] = make([]int, 0)
  }
  for i := 1; i < N; i++ {
    AB := NextIntVec()
    a, b := AB[0] - 1, AB[1] - 1
    T[a] = append(T[a], b)
    T[b] = append(T[b], a)
  }
  D := make([][]int, N)
  for i := range D {
    D[i] = []int{0, i}
  }
  D[0][0] = 1
  Q := make([]int, N)
  pos := 1
  for _, q := range Q {
    for _, adj := range T[q] {
      if 0 < D[adj][0] { continue }
      D[adj][0] = D[q][0] + 1
      D[adj][1] = q
      Q[pos] = adj
      pos++
    }
  }
  M := NextInt()
  C := make([][]int, M)
  for i := range C {
    UV := NextIntVec()
    u, v := UV[0] - 1, UV[1] - 1
    C[i] = []int{u, v, LCM(&T, &D, u, v)}
  }
  cnt := 0
  for i := 1; i < 1 << uint(M); i++ {
    W := make([]int, N)
    j := i
    sign := -1
    for _, c := range C {
      if 0 < j % 2 {
        W[c[0]]++
        W[c[1]]++
        W[c[2]] -= 2
        sign *= -1
      }
      j /= 2
    }
    w := 0
    for j := N - 1; 0 < j; j-- {
      u := Q[j]
      if 0 < W[u] { w++ }
      W[D[u][1]] += W[u]
    }
    cnt += sign * (1 << uint(N - 1 - w))
  }
  Write(1 << uint(N - 1) - cnt)
  return
}

func main() {
  Solve()
  Output()
}

Measured memory_bytes: 9856
#include<bits/stdc++.h>
using namespace std;
char s[1000001];
signed main()
{
	int n,m;
	scanf("%d",&n);
	cin>>s+1;
	int ans=1;
	for(int i=2;i<=n;i++)
		if(s[i]!=s[i-1])
			ans++;
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int i,j,n,m,x,y,ans[2100],minn;
int main()
{
	scanf("%d%d%d",&n,&x,&y);
	for (i=1;i<n;i++)
	 for (j=i+1;j<=n;j++)
	  if (i>=y||j<=x)  ans[j-i]++;else
	  if (i<=x&&j>=y) ans[j-i-(y-x)+1]++;else
	  {
	  	minn=j-i;
	  	minn=min(minn,abs(i-x)+1+abs(j-y));
	  	minn=min(minn,abs(i-y)+1+abs(j-x));
	  	minn=min(minn,abs(j-y)+1+abs(i-x));
		minn=min(minn,abs(j-x)+1+abs(i-y)); 
		ans[minn]++;
	  }
	for (i=1;i<n;i++) printf("%d\n",ans[i]);
}

Measured memory_bytes: 3848
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define endl '\n'

using namespace std;

main()
{
    fast;
    int n,i;
    cin>>n;
    ll a[n];
    for (i=0;i<n;i++)
        cin>>a[i];
    ll tans1=0,tans2=0,tp1=0,tp2=0;
    for (i=0;i<n;i++)
    {
        tp1+=a[i];
        tp2+=a[i];
        if (i&1)
        {
            if (tp1>=0)
            {
                tans1+=(tp1+1);
                tp1=-1;
            }
            if (tp2<=0)
            {
                tans2+=(1-tp2);
                tp2=1;
            }
        }
        else
        {
            if (tp1<=0)
            {
                tans1+=(1-tp1);
                tp1=1;
            }
            if (tp2>=0)
            {
                tans2+=(tp2+1);
                tp2=-1;
            }
        }
    }
    cout<<min(tans1,tans2)<<endl;
}

Measured memory_bytes: 1024
/*
ツδ渉ーツシツδδδ仰フツδ債イツドツづ?全ツ点ツ甘板催?短ツ仰猟猟」ツづーツ仰?づ淞づ?つィツつォツづ慊つキツ。
ツつサツつオツつスツづァツ、ツ篠ゥツ閉ェツづ個陳ャツづーツづ?つアツづ可つキツづゥツつゥツづーツ考ツつヲツづ?、ツ堕シツづ個陳ャツづ可行ツつュツつスツづ淞づ個コツスツトツづーツ仰?づ淞づ慊つキツ。
ツ?ィツ禿アツ重ツδ仰ーツプ
ツ暗ェツ氾板渉ャツつウツつ「ツコツスツトツづ可づ按づ?つスツ陳ャツづーツ出ツ療債つオツづ慊つオツづ・ツつ、ツ。
 */
#include <iostream>
using namespace std;

#define INF 999999999

int n, m; //ツ陳ャツづ個青? ツ督ケツづ個青?
int t[12][12];

void init(){
  for(int i = 0; i < 12; i++){
    for(int j = 0; j < 12; j++){
      t[i][j] = INF;
    }
  }
}

void wf(){
  for(int k = 0; k < n; k++){
    for(int i = 0; i < n; i++){
      for(int j = 0; j < n; j++){
        if(i == j) continue;
        t[i][j] = min(t[i][j], t[i][k] + t[k][j]);
      }
    }
  }
}

int main(){
  while(cin >> m, m){
    n = 0;
    init();

    for(int i = 0; i < m; i++){
      int a, b, cost;
      cin >> a >> b >> cost;
      n = max(n, max(a + 1, b + 1));
      t[a][b] = t[b][a] = cost;
    }

    wf();

    int ans = 0;
    int ansCost = INF;

    for(int i = 0; i < n; i++){
      int cost = 0;

      for(int j = 0; j < n; j++){
        if(i == j) continue;
        cost += t[i][j];
      }

      if(ansCost > cost){
        ans = i;
        ansCost = cost;
      }
    }

    cout << ans << " " << ansCost << endl;
  }
}

Measured memory_bytes: 0
import math
n = int(input())
lis = list(map(int,input().split()))
li = [0 for _ in range(math.ceil(n / 2))]

for i in range(n):
  li[math.floor(lis[i] / 2)] += 1
for i in range(len(li)):
  if n % 2 == 1 and i == 0:
    if li[i] != 1:
      print("0")
      exit()
  else:
    if li[i] != 2:
      print("0")
      exit()
cou = 1
for i in range(math.floor(n/2)):
  cou *= 2
  cou %= (10 ** 9 + 7)
print(cou)

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

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n; lint k; cin >> n >> k;
  V<> a(n); for (auto&& e : a) cin >> e;
  map<int, int> mp;
  V<> nxt(n);
  for (int i = 2 * n - 1; i >= 0; --i) {
    if (i < n) nxt[i] = mp[a[i]];
    mp[a[i % n]] = i;
  }

  V<lint> vis(n, -1);
  V<> res;
  lint p = 0;
  bool first = true;
  while (p < n * k) {
    if (first and vis[p % n] != -1) {
      lint c = (p - vis[p % n]);
      p += (n * k - p) / c * c;
      first = false;
      continue;
    }
    vis[p % n] = p;
    lint q = p / n * n + nxt[p % n] + 1;
    if (q > n * k) {
      res.push_back(a[p++ % n]);
    } else {
      p = q;
    }
  }

  int m = res.size();
  for (int i = 0; i < m; ++i) cout << res[i] << " \n"[!(m + ~i)];
}

Measured memory_bytes: 14964
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(v) v.begin(), v.end()
#define ll long long
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<long long>;
using vvll = vector<vll>;

//snippets:tmp,cl,cvl,cs,co,coy,con,cov

int main(){
    ll n;
    cin >> n;
    ll m;
    cin >> m;
    if(n%2==1){
        rep(i,m){
            cout<<n/2-i<<" "<<n/2+1+i<<endl;
        }
    }else{
        rep(i,m-m/2){
            cout<<n/2-i<<" "<<n/2+1+i<<endl;
        }rep(i,m/2){
            cout<<2+i<<" "<<n-i<<endl;
        }
    }
}

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

using namespace std;

struct query{
    int c, x, u, v, id;
    bool operator < (query q) const{
        return c < q.c;
    }
};

struct edge{
    int e, c, v;
};

int N, Q, B = 315;
vector<edge> graph[100005];
vector<edge> typ[100005];
vector<query> qu;
int dist[100005], clr[100005], wt[100005], dep[100005];
int clrv[100005], clrc[100005];
int par[100005][18];
int ans[100005];

void dfs1(int n){
    for(auto e : graph[n]){
        if(e.e != par[n][0]){
            par[e.e][0] = n;
            dist[e.e] = dist[n] + e.v;
            clr[e.e] = e.c;
            wt[e.e] = e.v;
            dep[e.e] = dep[n] + 1;
            typ[e.c].push_back(e);
            dfs1(e.e);
        }
    }
}

void dfs2(int n, int c){
    if(clr[n] == c){
        clrv[n] += wt[n];
        clrc[n]++;
    }
    for(auto e : graph[n]){
        if(e.e != par[n][0]){
            clrv[e.e] = clrv[n];
            clrc[e.e] = clrc[n];
            dfs2(e.e, c);
        }
    }
}

void build(){
    for(int d = 1; d<17; d++){
        for(int n = 1; n<=N; n++){
            par[n][d] = par[par[n][d-1]][d-1];
        }
    }
}

int lca(int u, int v){
    if(dep[u] < dep[v]){
        swap(u, v);
    }
    for(int d = 16; d>=0; d--){
        if(dep[par[u][d]] >= dep[v]){
            u = par[u][d];
        }
    }
    if(u == v){
        return u;
    }
    for(int d = 16; d>=0; d--){
        if(par[u][d] != par[v][d]){
            u = par[u][d];
            v = par[v][d];
        }
    }
    return par[u][0];
}

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> N >> Q;
    for(int i = 1; i<N; i++){
        int a, b, c, v;
        cin >> a >> b >> c >> v;
        graph[a].push_back({b, c, v});
        graph[b].push_back({a, c, v});
    }
    dep[1] = 1;
    dfs1(1);
    build();
    for(int q = 1; q<=Q; q++){
        int c, x, u, v;
        cin >> c >> x >> u >> v;
        qu.push_back({c, x, u, v, q});
    }
    sort(qu.begin(), qu.end());
    int crntc = 0;
    for(auto q : qu){
        int top = lca(q.u, q.v);
        ans[q.id] = dist[q.u] + dist[q.v] - 2*dist[top];
        if(typ[q.c].size() <= B){
            for(auto e : typ[q.c]){
                if(dep[e.e] > dep[top] && (lca(e.e, q.u) == e.e || lca(e.e, q.v) == e.e)){
                    ans[q.id] -= wt[e.e];
                    ans[q.id] += q.x;
                }
            }
            continue;
        }
        if(q.c != crntc){
            crntc = q.c;
            dfs2(1, q.c);
        }
        ans[q.id] -= clrv[q.u] + clrv[q.v] - 2*clrv[top];
        ans[q.id] += q.x*(clrc[q.u] + clrc[q.v] - 2*clrc[top]);
    }
    for(int q = 1; q<=Q; q++){
        cout << ans[q] << "\n";
    }
}


Measured memory_bytes: 28084
#include <iostream>
#include <utility>
#include <stdint.h>

using namespace std;

const uint32_t MOD = 1000000007;

uint32_t COMB[2005][2005] = {0};

// uint32_t comb(uint32_t n, uint32_t r)
// {
//   if (COMB[n][r] != 0)
//     return COMB[n][r];
//   cerr << n << ' ' << r << endl;
//   cerr << COMB[n][r] << endl;
//   // else if (n==r || r==0)
//   //   return COMB[n][r] = 1;
//   // else {
//   //   return COMB[n][r] = (comb(n-1,r-1) + comb(n-1,r))%MOD;
//   // }
// }

void comb_init(uint32_t N)
{
  COMB[0][0] = 1;
  COMB[1][0] = 1;
  COMB[1][1] = 1;
  for (int n=1; n<=N; ++n) {
    for (int r=0; r<=N; ++r) {
      if (n==r || r==0)
	COMB[n][r] = 1;
      else
	COMB[n][r] = (COMB[n-1][r-1]+COMB[n-1][r])%MOD;
    }
  }

}

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

  comb_init(N);

  for (int k=1; k<=K; ++k)
    //cout << ((uint64_t)comb(N-K+1,k)*comb(K-1,k-1))%MOD << endl;
    cout << ((uint64_t)COMB[N-K+1][k]*COMB[K-1][k-1])%MOD << endl;

  return 0;
}


Measured memory_bytes: 15872
import java.util.Scanner;

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

	int n;
	int A[];
	public void run() {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		A = new int[n];
		for(int i=0; i<n; i++) {
			A[i]=sc.nextInt();
		}

		int ans=0;
		boolean cont=true;
		while(cont) {
			for(int i=0; i<n; i++) {
				if(A[i] % 2 == 0) {
					A[i] = A[i]/2;
				}else {
					cont=false;
					break;
				}
			}
			if(cont)ans++;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 22996
n, l = map(int, input().split())
apple = []
for i in range(n):
        apple.append(l+(i+1)-1)
pie = sum(apple)
piev2 = []
abs_pie = []
for i in apple:
        piev2.append(pie - i)
        abs_pie.append(abs(i))
num = 0
print(piev2[abs_pie.index(min(abs_pie))])

Measured memory_bytes: 3064
n = int(input())
a = [int(input()) for _ in range(n)]
sa = set(a)
max_a = max(sa)
max_c = a.count(max_a)

if max_c > 1:
    for _ in range(n):
        print(max_a)
else:
    sa.discard(max_a)
    sec_max_a = max(sa)
    for v in a:
        if v == max_a:
            print(sec_max_a)
        else:
            print(max_a)



Measured memory_bytes: 17164
#include <bits/stdc++.h>
#define pii pair<int, int>
#define PI acos(-1)

using namespace std;
using LL = long long;
constexpr int MAXN = 1e5 + 5;

int n, m, dis[MAXN], vis[MAXN], pre[MAXN];
vector<pii> G[MAXN];

priority_queue<pii, vector< pii >, greater< pii > >q;
inline void dijkstra(int s){
    memset(dis, 0x3f, sizeof(dis));
    q.push(make_pair(dis[s] = 0, s));
    while(!q.empty()){
        int cur = q.top().second;
        q.pop();
        if(vis[cur]) continue;
        for(auto i : G[cur]){
            int to = i.first, w = i.second;
            if(dis[to] > dis[cur] + w){
                pre[to] = cur;
                dis[to] = dis[cur] + w;
                q.push(make_pair(dis[to], to));
            }
        }
        vis[cur] = true;
    }
    for (int i = 2; i <= n; i++)
        if (dis[i] == 0x3f3f3f3f) {
            cout << "No" << endl;
            exit(0);
        }
    cout << "Yes" << endl;
    for (int i = 2; i <= n; i++)
        cout << pre[i] << endl;
}

int main() {
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v;
        cin >> u >> v;
        G[u].push_back(make_pair(v, 1)), G[v].push_back(make_pair(u, 1));
    }
    dijkstra(1);
    return 0;
}

Measured memory_bytes: 13600
def f(n):
  d=[]
  for i in range(1,int(n**0.5)+1):
    if n%i<1:
      d+=i,
      if i!=n//i:d+=n//i,
  return d[1:]
n=int(input())
a=f(n-1)
for i in f(n):
  m=n
  while m%i<1:m//=i
  if m%i<2:a+=i,
print(len(set(a)))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(cin>>n,n){
  int a[n];
  for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
  int p=100000000;
  for(int i=0;i<n-1;i++)p=min(p,a[i+1]-a[i]);
    cout<<p<<endl;
}
}

Measured memory_bytes: 3088
A, B, C = [int(i) for i in input().split(' ')]

week_reward = A * 7 + B

weeks, remain_rewards = divmod(C, week_reward)

remain_days = 0

if remain_rewards == 0:
    print(weeks * 7)
    exit(0)

for i in range(1, 7):
    if remain_rewards <= A * i:
        print(weeks * 7 + i)
        exit(0)

    if i == 6:
        print((weeks + 1) * 7)



Measured memory_bytes: 5604
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
int A[3];
int main(){
    cin >> A[0] >> A[1] >> A[2];
    sort(A,A+3);
    cout << ((A[0]==A[1])? A[2] : A[0]) << endl;
}

Measured memory_bytes: 256
a=int(input())
h,m=0,0
if int(a/(60**2))>0:
    h=int(a/(60**2))
a-=(60**2)*h

if int(a/60)>0:
    m=int(a/60)
a-=60*m
s=a
print(h,":",m,":",s,sep='')


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

int main() {
  int N;
  string a,one="",two="",thr="",fou="";
  
  cin >> N;
  
  while(N--){
    cin >> a;
    if(one==""){
      one=a;
    }else if(one!=a&&two==""){
      two=a;
    }else if((one!=a&&two!=a)&&thr==""){ 
      thr=a;
    }else if((one!=a&&two!=a)&&(thr!=a&&fou=="")){
      cout << "Four";
      break;
    }else if(N==0){
      cout << "Three";
    }
  }
}


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

int main() {
    int a , b , c ;
    scanf("%d %d %d" , &a , &b , &c ) ;
    if( a == b ) {
        cout << c << endl ;
    }
    else if( a == c ) {
        cout << b << endl ;
    }
    else {
        cout << a << endl ;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <climits>
#include <bitset>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int dx[]={-1, -1, -1, 0, 0, 0, 1, 1, 1};
int dy[]={-1, 0, 1, -1, 0, 1, -1, 0, 1};
map<ll, ll> m;
ll d[10];
vector<ll> v;

int main(){
	ll h, w;
	int n;
	cin >> h >> w >> n;
	ll a[n], b[n];
	for(int i=0; i<n; i++){
		cin >> a[i] >> b[i];
		a[i]--; b[i]--;
	}

	for(int i=0; i<n; i++){
		for(int j=0; j<9; j++){
			ll x=a[i]+dx[j], y=b[i]+dy[j];
			if(x<0 || x>=h || y<0 || y>=w) continue;
			m[x*w+y]++;
			v.push_back(x*w+y);
		}
	}
	sort(v.begin(), v.end());
	v.erase(unique(v.begin(), v.end()), v.end());

	for(int i=0; i<v.size(); i++){
		ll x=v[i]/w, y=v[i]%w;
		if(0<x && x<h-1 && 0<y && y<w-1){
			d[m[v[i]]]++;
		}
	}
	ll sum=0;
	for(int i=1; i<=9; i++) sum+=d[i];
	d[0]=(h-2)*(w-2)-sum;
	for(int i=0; i<10; i++) cout << d[i] << endl;
	return 0;
}

Measured memory_bytes: 65384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N, K;
        public long[] A;
        public long[] S, SPlus;
        public void Run()
        {
            {
                var line = Input.ReadIntArray();
                N = line[0];
                K = line[1];
            }

            A = Input.ReadLongArray();

            S = new long[N + 1];
            SPlus = new long[N + 1];

            // 区間和が半開区間でとれる
            for (int i = 0; i < N; i++)
            {
                S[i + 1] = S[i] + A[i];
                SPlus[i + 1] = SPlus[i] + Math.Max(A[i], 0);
            }

            long ret = long.MinValue;
            for (int i = 0; i < N; i++)
            {
                if (i + K > N) continue;
                long r = SPlus[N] - SPlus[0];
                r -= (SPlus[i + K] - SPlus[i]);
                r += Math.Max(0, S[i + K] - S[i]);

                ret = Math.Max(ret, r);
            }

            Console.WriteLine(ret);

        }
    }

    // libs ----------
    

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();            
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }
    
    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 32220
#include <stdio.h>

int main(void){
  int A[100][100]={0},b[100]={0},c[100]={0};
  int n,m,i,j;
  
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      scanf("%d",&A[i][j]);
    }
  }
  for(i=0;i<m;i++){
    scanf("%d",&b[i]);
  }
  for(i=0;i<n;i++){
    for(j=0;j<m;j++){
      c[i]+=A[i][j]*b[j];
    }
    printf("%d\n",c[i]);
  }
  return 0;
}

Measured memory_bytes: 648
N, a, b = map(int, input().split())
num = 0
sum = 0
res = 0

for n in range(1, N+1):
    sum = 0
    tmp = n
    while n != 0:
        sum += int(n % 10)
        n = int(n // 10)
    if a <= sum <= b:
        res += tmp

print(res)

Measured memory_bytes: 3060
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::make_pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

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

	lli A, B, C;
	lli ans=0;
	cin >> A >> B >> C;
	while(B>=A){
		B -= A;
		ans++;
		if(ans == C) break;
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;



int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	ll A, V;
    cin >> A >> V;
    ll B,W;
    cin >> B >> W;
    ll T;
    cin >> T;
    ll D=abs(A-B);
    ll D2=(V-W)*T;
    puts(D<=D2?"YES":"NO");

}	


Measured memory_bytes: 3608
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<iomanip>

using namespace std;

int main(void) {
	int a, b;
	cin >> a >> b;
	string s;
	cin >> s;
	for (int i = 0; i < a + b + 1; i++) {
		if (i == a) {
			if (s[i] != '-') {
				cout << "No";
				return 0;
			}
		}
		else {
			if (s[i] == '-') {
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [int(input()) for _ in range(N)]
total = sum(S)
if total % 10 != 0:
    print(total)
else:
    ans = list(filter(lambda x: x % 10 != 0, S))
    if len(ans):
        print(total - min(ans))
    else:
        print(0)


Measured memory_bytes: 2940
import sys
if __name__=="__main__":
    while True:
        try:
            st=raw_input()
            ans=[]
            for i,e in enumerate(st):
                if e=='@':
                    for j in range(1,int(st[i+1])):
                        ans.append(st[i+2])
                else :
                    if st[i-1]!='@':
                        ans.append(e)
            for e in ans:
                sys.stdout.write(e)
            print ""
        except EOFError: break
        

        
    

Measured memory_bytes: 6440
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////




int main() {

	ll N;
	cin >> N;

	ll L[MAX];
	repn(i, N) cin >> L[i];

	ll sum = 0;
	repn(i, N) sum += L[i];

	ll ans = 1;

	repn(i,N){
		if (L[i]*2 >= sum) { ans = 0; }
	}

	if (ans == 1) { cout << "Yes"; }
	else { cout << "No"; }

	

	system("PAUSE");
}

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

using namespace std;

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

Measured memory_bytes: 256
module AOJ_Volume0114;

import std.stdio,std.string,std.conv;

long gcd(long a,long b)
{
	if(a%b == 0) return b;
	else return gcd(b,a%b);
}

long lcm(long m,long n)
{
	if(m == 0 || n == 0) return 0;
	return (m/gcd(m,n))*n;
}

int main()
{
	while(true)
	{
		string[] s = readln.chomp.split(" ");
		long a[6];

		foreach(i;0..6) a[i] = s[i].to!int;

		if(a[0] == 0 && a[1] == 0 && a[2] == 0 && a[3] == 0 && a[4] == 0 && a[5] == 0) break;

		long x = 1,y = 1,z = 1,count_x = 1,count_y = 1,count_z = 1;

		while(true)
		{
			if((a[0]*x)%a[1] == 1) break;
			else
			{
				count_x++;
				x = (a[0]*x)%a[1];
			}
		}

		while(true)
		{
			if((a[2]*y)%a[3] == 1) break;
			else
			{
				count_y++;
				y = (a[2]*y)%a[3];
			}
		}

		while(true)
		{
			if((a[4]*z)%a[5] == 1) break;
			else
			{
				count_z++;
				z = (a[4]*z)%a[5];
			}
		}

		long ans = lcm(count_x,count_y);
		ans = lcm(ans,count_z);

		ans.writeln;
	}
	return 0;
}

Measured memory_bytes: 1068
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

#define FOR(i,a,b) for(ll i = (a);i<(b);i++)
#define REP(i,a) FOR(i,0,(a))
#define MP make_pair

int main() {
	int a,b;
	cin >> a >> b;
	if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
		cout << "Possible" << endl;
	}else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
<?php

$line = fgets(STDIN);

$lines = explode(" ", $line);

$lines[0] = trim($lines[0]);
$lines[1] = trim($lines[1]);

if ($lines[0] < $lines[1]){
    echo "a < b";
}elseif ($lines[0] > $lines[1]){
    echo "a > b";
}else{
    echo "a == b";
}
?>

Measured memory_bytes: 15448
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD 998244353
#define INF 93193111451418101
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll V;
const ll MAX_V = 1e5;
vector<ll> G[MAX_V], rG[MAX_V], vs; // vsは帰り順の並び
bool used[MAX_V];
int cmp[MAX_V];

void addEdge(int from, int to) {
  // 0-indexの場合
  G[from].pb(to);
  rG[to].pb(from);
}

void dfs(int v) {
  used[v] = true;
  for (auto &a : G[v]) {
    if (!used[a])
      dfs(a);
  }
  vs.pb(v);
}

void rdfs(int v, int k) {
  used[v] = true;
  cmp[v] = k;
  for (auto &a : rG[v]) {
    if (!used[a])
      rdfs(a, k);
  }
}

int scc() {
  memset(used, 0, sizeof(used));
  vs.clear();
  REP(v, V) {
    if (!used[v])
      dfs(v);
  }
  memset(used, 0, sizeof(used));
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]])
      rdfs(vs[i], k++);
  }
  return k;
}

ll m;
ll inCnt[20000], outCnt[20000];
int main() {
  cin >> V >> m;
  REP(i, m) {
    ll s, t;
    cin >> s >> t;
    addEdge(s, t);
  }
  int k = scc();
  //cout << k << endl;
  ll inZero = 0, outZero = 0;
  REP(i, V) {
    for (auto &a : G[i]) {
      if (cmp[a] != cmp[i]) {
        outCnt[cmp[i]]++;
        inCnt[cmp[a]]++;
      }
    }
  }
  if (k == 1) {
    cout << 0 << endl;
    return 0;
  }
  REP(i, k) {
    if (outCnt[i] == 0) {
      outZero++;
    }
    if (inCnt[i] == 0) {
      inZero++;
    }
  }
  cout << max(outZero, inZero) << endl;
}



Measured memory_bytes: 11176
from collections import Counter
n = int(input())
a = list(map(int, input().split()))
q = int(input())
counter = Counter(a)
sum_a = sum(a)

for _ in range(q):
  b, c = map(int, input().split())
  sum_a += (c - b) * counter[b]
  counter[c] += counter[b]
  counter[b] = 0

  print(sum_a)

Measured memory_bytes: 24192
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5,inf=2e9;
struct Node{
	int a,b;
	bool operator < (const Node &c){
		return 1ll*a*(c.b+1)>1ll*c.a*(b+1);
	}
}a[N];
int b[N],si1,si2;long long f[35];
int main(){
	int n,t,x,y;scanf("%d%d",&n,&t);
	for(int i=0;i<n;i++){
		scanf("%d%d",&x,&y);
		if(x)a[si1++]={x,y};
		else b[si2++]=y;
	}
	sort(a,a+si1);
	sort(b,b+si2);
	for(int i=1;i<31;i++)f[i]=inf;
	for(int i=0;i<si1;i++){
		for(int j=30;~j;j--){
			if(f[j]==inf)continue;
			f[j+1]=min(f[j+1],(f[j]+1)*(a[i].a+1)+a[i].b);
		}
	}
	int ans=0;
	for(int i=0;i<=30;i++){
		if(f[i]>t)break;
		ans=max(ans,i);
		for(int j=0;j<si2;j++){
			if((f[i]+=b[j]+1)>t)break;
			ans=max(ans,i+j+1);
		}
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 1792
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

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

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

int main() {
  int n, k, q, temp;
  cin >> n >> k >> q;
  vector<int> a(q);
  vector<int> point(n + 1);
  for (int i = 0; i < q; i++) {
    cin >> a[i];
    point[a[i]]++;
  }
  for (int i = 1; i <= n; i++) {
    if (point[i] <= q - k)
      printf("No\n");
    else
      printf("Yes\n");
  }
  return 0;
}

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

using namespace std;

int X, Y, n, m, k;
multiset <int> A, B;

int main() {
    cin >> X >> Y;
    cin >> n >> m >> k;
    for (int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        A.insert(x);
        if (A.size() > X) {
            A.erase(A.begin());
        }
    }
    for (int i = 1; i <= m; i++) {
        int x;
        cin >> x;
        B.insert(x);
        if (B.size() > Y) {
            B.erase(B.begin());
        }
    }
    for (int i = 1; i <= k; i++) {
        int x;
        cin >> x;
        if (A.size() < X) {
            A.insert(x);
            continue;
        }
        if (B.size() < Y) {
            B.insert(x);
            continue;
        }
        if (*A.begin() < *B.begin()) {
            A.insert(x);
            A.erase(A.begin());
        } else {
            B.insert(x);
            B.erase(B.begin());
        }
    }
    long long sum = 0;
    for (auto x : A)
        sum += x;
    for (auto x : B)
        sum += x;
    cout << sum << endl;
}


Measured memory_bytes: 8704
import sys
import os

def file_input():
    f = open('../Beginner_Contest_/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    S=input()
    if S == 'ABC':
        print('ARC')
    else:
        print('ABC')

if __name__ == '__main__':
    main()


Measured memory_bytes: 9032
# -*- coding: utf-8 -*-


from sys import stdin



############################################


# read data for n sequences.
n = stdin.readline().split()
a = int(n[0])
b = int(n[1])
c = int(n[2])
#data = [int(stdin.readline().rstrip()) for _ in range(n)]

if b > c and a < c:
    print("Yes")
elif c < a and b < c:
	print("Yes")
else:
	print("No")


Measured memory_bytes: 3064
import collections
from collections import deque

N,X,Y = map(int,input().split())

#辺のリスト
n = N
l_hen = [[i,i+1] for i in range(1,n)]+[[X,Y]]

#頂点のラベルリスト
l_chouten =list( set(sum(l_hen, [])) )

#G={頂点:[頂点に繋がっている点たち],... } を取得する
G = dict( [ (key,[]) for key in l_chouten]  )
for i in range(n):
   G[l_hen[i][0]].append(l_hen[i][1])

#無効グラフの場合両方から見ているので以下のコードも実行する
for i in range(n):
   G[l_hen[i][1]].append(l_hen[i][0])

'''
以上グラフの準備
'''
#seenとtodoの初期設定
l_seen = {i:False for i in l_chouten}
l_todo = []
dist = {i:-1 for i in l_chouten}
#距離の羅列用  
l_d =deque([])  

for point in range(1,N+1):
  #seenとtodoの初期設定
  for key in l_seen:
    l_seen[key] = 0
  l_todo = []  
  for key in dist:
    dist[key] = 0

  #seenに出発地点pを決めてやる、出発点の隣接リストもtodoに入れる
  p = point
  l_seen[p] = True #pはチェック済み
  for i in G[p]:
    l_seen[i] = True #pに隣接する頂点もチェック済み
  l_todo = l_todo + G[p] #pに隣接する頂点をtodoリストに追加
  l_todo = deque(l_todo)
  dist[p] = 0
  for i in G[p]:
    dist[i] = 1 #pに隣接する頂点とpとの距離を1とする
    l_d.append(dist[i])
  

  #探索
  while len(l_todo) != 0:
    #幅優先探索
    v = l_todo.popleft() #todoの左端つまりindex0から処理しているので
    for i in G[v]:
      #回り込まれて先越された時
      if l_seen[i] == True:
        continue
      else:
        l_seen[i] = True
        l_todo.append(i)
        dist[i]=dist[v]+1
        l_d.append(dist[i])
###
c = collections.Counter(l_d)
for i in range(1,N):
  print(c[i]//2)

Measured memory_bytes: 133920
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main() 
{
  int n; cin >> n;
  cout << n*800 - (n/15)*200 << endl;
  system("pause");
}

Measured memory_bytes: 504