akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n,k;
    cin >> n >> k;
    vi v(n);
    rep(i,n)cin >> v[i];
    vi d(n-1);
    rep(i,n-1)d[i] = v[i+1]-v[i]-1;
    sort(all(d));
    int ans = n;
    rep(i,n-k)ans += d[i];
    cout << ans << endl;
}



Measured memory_bytes: 4412
#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() {
    ll n;
    cin >> n;
    int n1=n;
    int sn=0;
    while(true){
        if(n/10==0){
            sn+=n;
            break;
        }
        else{
            sn+=n%10;
            n/=10;
        }
    }
    if(n1%sn==0) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"log"
	"os"
	"strconv"
)

func main() {
	n := readInt()
	if n >= 30 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	log.SetFlags(log.Lshortfile)
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readInt() int {
	return int(readInt64())
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func gcd(m, n int) int {
	for m%n != 0 {
		m, n = n, m%n
	}
	return n
}

func lcm(m, n int) int {
	return m / gcd(m, n) * n
}


Measured memory_bytes: 1776
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    //https://atcoder.jp/contests/abc141/tasks/abc141_a
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 整数の入力
            long n = long.Parse(Console.ReadLine());

            var a = 1000 - (n % 1000);

            Console.WriteLine(a == 1000 ? 0 : a);

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 27508
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int a, b, c; cin >> a >> b >> c;

  if (a > b) swap(a, b);
  if (a <= c && c <= b) {
    puts("Yes");
  } else {
    puts("No");
  }
  return 0;
}



Measured memory_bytes: 256
package main

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

func fill(s []int, x int) {
	for i := 0; i < len(s); i++ {
		s[i] = x
	}
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func readKey() [2]int {
	a := readInt()
	b := readInt()
	m := 0
	for i := 0; i < b; i++ {
		c := readInt()
		m |= 1 << uint(c-1)
	}
	return [2]int{a, m}
}

func main() {
	N := readInt()
	M := readInt()
	keys := make([][2]int, M)
	for i := 0; i < M; i++ {
		keys[i] = readKey()
	}

	dp := make([]int, 1<<uint(N))
	fill(dp, math.MaxInt64)

	dp[0] = 0
	maxM := 0
	for i := 0; i < M; i++ {
		a, m := keys[i][0], keys[i][1]
		for j := maxM; j >= 0; j-- {
			if dp[j] == math.MaxInt64 {
				continue
			}
			maxM = max(maxM, j|m)
			dp[j|m] = min(dp[j|m], dp[j]+a)
		}
	}
	if dp[(1<<uint(N))-1] == math.MaxInt64 {
		fmt.Println(-1)
	} else {
		fmt.Println(dp[(1<<uint(N))-1])
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 768
/// a.cpp

# include <stdio.h>
# include <bits/stdc++.h>
using namespace std;
const pair < int , int > DD[] = {{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};
# define fi cin
# define fo cout
# define x first
# define y second
# define ll long long
# define IOS ios_base :: sync_with_stdio(0);cin.tie(0)
# define p(v) cerr << #v << " = " << v << '\n'
# define p2(v) cerr << #v << " = " << (complex < __typeof(v.x) > (v.x,v.y)) << '\n'
# define vi vector < int >
# define vl vector < ll >
# define pll pair < ll , ll >
# define pii pair < int , int >
# define mp make_pair
# define db long double
# define fail puts("-1")
# define yes puts("YES")
# define no puts("NO")
# define PP puts("Possible")
# define II puts("Impossible")
# define vii vector < pii >
# define vll vector < pll >
# define pb push_back
# define pdd pair < db , db >
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
int main(void)
{
    #ifdef CF
    freopen("input","r",stdin);
    #endif // CF
    srand(time(0));
    fo << fixed << setprecision(7);
    cerr << fixed << setprecision(7);
    static char str[1 << 20];
    fi>>(str + 1);
    int n = strlen(str + 1);
    int ans = 1e9;
    for (char ch = 'a';ch <= 'z';++ch)
    {
        vi s;
        for (int i = 0;i < n;++i)
            s.pb(ch == str[i + 1]);
        if (*max_element(s.begin(),s.end()) == 0) continue;
        while (*min_element(s.begin(),s.end()) == 0)
        {
            for (int i = 0;i + 1 < s.size();++i)
                smax(s[i],s[i + 1]);
            s.pop_back();
        }
        smin(ans,(int)(n - s.size()));
    }
    fo << ans << '\n';
    cerr << "Time elapsed :" << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &&x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int dp[100005][3];
signed main() {
    int N;
    cin >> N;
    vector<vector<int>> abc(N);
    REP(i, N) {
        int a, b, c;
        cin >> a >> b >> c;
        abc[i] = {a, b, c};
    }

    REP(i, 3) dp[0][i] = abc[0][i];
    REPF(i, 1, N) {
        REP(j, 3) {
            REP(k, 3) {
                if (j == k) continue;
                chmax(dp[i][k], dp[i - 1][j] + abc[i][k]);
            }
        }
    }
    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return (0^_^0);
}



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

const int MAXN = 3e3 + 10, MOD = 1e9 + 7, I2 = (MOD + 1) / 2;

int n, Q;
int a[MAXN], P[MAXN][MAXN];

int main() {
	scanf("%d%d", &n, &Q);
	for (int i = 1; i <= n; ++i) scanf("%d", a + i);
	for (int i = 1; i <= n; ++i)
		for (int j = 1; j <= n; ++j) P[i][j] = a[i] > a[j];
	for (int i = 1, x, y; i <= Q; ++i) {
		scanf("%d%d", &x, &y), P[x][y] = P[y][x] = 1LL * (P[x][y] + P[y][x]) * I2 % MOD;
		for (int j = 1; j <= n; ++j) if (j != x && j != y) P[x][j] = P[y][j] = 1LL * (P[x][j] + P[y][j]) * I2 % MOD, P[j][x] = P[j][y] = 1LL * (P[j][x] + P[j][y]) * I2 % MOD;
	}
	int pro = 1, ans = 0;
	for (int i = 1; i <= Q; ++i) pro = pro * 2 % MOD;
	for (int i = 1; i <= n; ++i)
		for (int j = i + 1; j <= n; ++j) ans = (ans + P[i][j]) % MOD;
	printf("%d\n", 1LL * ans * pro % MOD);
	return 0;
}


Measured memory_bytes: 35584
def reverseDisits(n):
    s = ""
    while n > 0:
        s += str(n % 10)
        n //= 10
    return int(s)


a, b = map(int, input().split())
count = 0
for i in range(a, b + 1):
    if i == reverseDisits(i):
        count += 1

print(count)


Measured memory_bytes: 2940
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (int i = int(a); i <= int(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n, t, ans = 1;
    in >> n;
    REP(i, n){
        in >> t;
        ans = lcm(ans, t);
    }

    out << ans << endl;
}


Measured memory_bytes: 256
package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n > ans {
			ans = n
		}
	}
	return ans
}

func min(l []int) int {
	ans := l[0]
	for _, n := range l {
		if n < ans {
			ans = n
		}
	}
	return ans
}

func countWay(ss [][]int, h int, w int, si int, sj int) ([][]int, [][]int) {
	move := [][]int{[]int{0, 1}, []int{0, -1}, []int{1, 0}, []int{-1, 0}}
	start := ss[si][sj]
	if start == -1 {
		ss[si][sj] = 0
		start = 0
	}
	var q [][]int
	for _, m := range move {
		i, j := (si + m[0]), (sj + m[1])
		if i < 0 || h <= i {
			continue
		}
		if j < 0 || w <= j {
			continue
		}
		if ss[i][j] == -1 {
			ss[i][j] = start + 1
			q = append(q, []int{i, j})
		}
	}
	return ss, q
}

func count(s [][]int, h int, w int, si int, sj int) int {
	ss := make([][]int, h)
	for i := 0; i < h; i++ {
		si := make([]int, w)
		for j := 0; j < w; j++ {
			si[j] = s[i][j]
		}
		ss[i] = si
	}
	q := [][]int{{si, sj}}
	for len(q) != 0 {
		var qq [][]int
		for _, qi := range q {
			var qqq [][]int
			ss, qqq = countWay(ss, h, w, qi[0], qi[1])
			qq = append(qq, qqq...)
		}
		q = qq
	}
	l := make([]int, h)
	for i, si := range ss {
		l[i] = max(si)
	}
	return max(l)
}

func printMatrix(m [][]int) {
	for _, v := range m {
		fmt.Println(v)
	}
}

// main
func main() {
	sc.Split(bufio.ScanWords)
	h := nextInt()
	w := nextInt()
	s := make([][]int, h)
	for i := 0; i < h; i++ {
		si := make([]int, w)
		sij := next()
		for j := 0; j < w; j++ {
			if string(sij[j]) == "." {
				si[j] = -1
			} else {
				si[j] = -2
			}
		}
		s[i] = si
	}
	var l []int
	for k := 0; k < h*w; k++ {
		i := k / w
		j := k % w
		if s[i][j] == -1 {
			l = append(l, count(s, h, w, i, j))
		}
	}
	fmt.Println(max(l))
}


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

#define ll long long
#define pii pair<int, int>
#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=a; i<b; i++)
#define REPD(i, n) for (int i=n-1; i>=0; i--)
#define FORD(i, a, b) for (int i=a; i>=b; i--)
#define vi vector<int>
#define all(v) v.begin(), v.end()
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

using namespace std;

void solve() {
    int a;
    cin >> a;
    string s;
    cin >> s;
    if (a >= 3200) print(s);
    else print("red");
}

signed main() {
    solve();
}


Measured memory_bytes: 256
n = int(input())
S = []
ans = 0
a =0 
b = 0
both = 0
for _ in range(n):
    temp = input()
    ans += temp.count("AB")
    if temp[0] == "B" and temp[-1] == "A":
        both += 1
    elif temp[0] =="B":
        b += 1
    elif temp[-1] == "A":
        a += 1
if a==0 and b==0:
    print(ans+max(0,both-1))
elif a==0  or b == 0:
    print(ans + both if both > 0 else ans)
else:
    print(ans+min(a,b)+both)

Measured memory_bytes: 44008
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
llint Tow(int n) {//2のn乗
	if (n == 0)return 1;
	llint x = Tow(n / 2);
	x %= mod;
	x *= x;
	x %= mod;
	if (n % 2 == 1)x *= 10;
	x %= mod;
	return x;
}


int main(){
	int n;
	cin >> n;
	whei(int) a(n, hei(int)(3));
	rep(i, 0, n) {
		rep(j, 0, 3)cin >> a[i][j];
	}
	whei(int) dp(n+1, hei(int)(3,0));
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	rep(i, 0, n-1) {
		rep(j, 0, 3) {
			rep(k, 0, 3) {
				if (j != k)dp[i+1][j] = max(dp[i+1][j], dp[i][k] + a[i+1][j]);
			}
		}
	}
	int ans = 0;
	rep(i, 0, 3)ans = max(ans, dp[n-1][i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 11136
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);    //scanner
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();

        int ans=0;

        for(int i=0;i<a+1;i++){
            for(int j=0;j<b+1;j++){
                for(int k=0;k<c+1;k++){
                    if(500*i+100*j+50*k==x){
                        ans++;
                    }
                }
            }
        }

        System.out.println(ans);    // output
    }
}

Measured memory_bytes: 35528
from operator import itemgetter

N = int(input())
R = [tuple(map(int, input().split())) for _ in range(N)]
B = [tuple(map(int, input().split())) for _ in range(N)]
R = sorted(R, key=itemgetter(1), reverse=True)
B = sorted(B, key=itemgetter(0))

count = 0
for c, d in B:
    for a, b in R:
        if (a < c) & (b < d):
            count += 1
            R.remove((a, b))
            break
print(count)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>


using namespace std;

int main()
{
	int n;
	stack<int> s;
	while (scanf("%d", &n) != EOF)
	{
		if (n == 0)
		{
			printf("%d\n", s.top());
			s.pop();
		}
		else
		{
			s.push(n);
		}
	}

	return 0;
}

Measured memory_bytes: 0
import math

n = int(input())
k = int(input())

def f(n,k):
    l = len(str(n))
    if l < k:
        ans = 0
    elif k == 1:
        ans = 9 * (l-1)
        ans += n//(10**(l-1))
    elif l == k:
        t = 10 ** (k-1)
        ans = (n//t-1) * f(t-1, k-1) + f(n%t,k-1)
    else:
        ans =  math.factorial(l-1) // math.factorial(k) // math.factorial(l-1-k) * (9 ** k)
        t = n % (10**(l-1))
        ans += f(t,k-1) + f(10**(l-1)-1,k-1)* (n// (10**(l-1))-1)
    return ans

ans = f(n,k)

print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>

#define MAX 21

main(){
  char str[MAX];
  char r_str[MAX];
  int i, num;

  scanf("%s", str);

  for(num = 1 ; str[num] != '\0' ; num++)

  for(i = 0 ; i < num + 1 ; i++){
    r_str[i] = str[num - i];
  }

  r_str[num] = '\0';

  printf("%s\n", r_str);

  return 0;
}

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

using namespace std;

int main(){
    char S[11];
    scanf("\n%s", S);
    int count;
    int max_count = 0;
    for(int i = 0; S[i] != '\0'; i++){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            count = 1;
            for(int j = i + 1; S[j] != '\0'; j++){
                if(S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T'){
                    count++;
                }else{
                    break;
                }
            }
            max_count = max(max_count, count);
        }
    }

    printf("%d\n", max_count);

    return 0;
}

Measured memory_bytes: 128
"use strict";
function main(input) {
    const args = input.split(" ");

    const A = parseInt(args[0]);
    const B = parseInt(args[1]);

    let ans = '';

    if(A < 6) {
        ans = 0;
    } else if(A<=12) {
        ans = B /2;
    } else {
        ans = B;
    }

    console.log(ans)
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
N, K = map(int, input().split())
X = list(map(int, input().split()))
minval = 10000000000
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
X = [-x for x in X[::-1]]
for i in range(N-K+1):
    tmpval = abs(X[i]) + X[i+K-1] - X[i]
    if minval > tmpval:
        minval = tmpval
print(minval)

Measured memory_bytes: 14224
using System;
using System.Globalization;

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine().Trim();

        DateTime d;

        if (DateTime.TryParseExact(S, "yyMM", null, DateTimeStyles.None, out d) && DateTime.TryParseExact(S, "MMyy", null, DateTimeStyles.None, out d))
            Console.WriteLine("AMBIGUOUS");
        else if (DateTime.TryParseExact(S, "yyMM", null, DateTimeStyles.None, out d))
            Console.WriteLine("YYMM");
        else if (DateTime.TryParseExact(S, "MMyy", null, DateTimeStyles.None, out d))
            Console.WriteLine("MMYY");
        else
            Console.WriteLine("NA");
    }
}

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

#define rep(i, n) for(int i=0; i < n; i++)
#define REP(i, n, m) for(int i=n; i < m; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)

using namespace std;
using ll=long long;

const ll INF = 1LL << 60;

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;}



int main() {
  int k;cin>>k;
  string s;cin>>s;
  int n=s.size();
  if(n<=k)cout<<s;
  else cout<<s.substr(0,k)+"...";
}



Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    string nap;
    cin >> nap;
    if (nap.size() < 4)
    {
        cout << "No";
        return 0;
    }
    if (nap[0] == 'Y' && nap[1] == 'A' && nap[2] == 'K' && nap[3] == 'I')
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


Measured memory_bytes: 256
n, c = gets.chomp.split.map(&:to_i)

colors_diff = c.times.map do
 gets.chomp.split.map(&:to_i)
end

colors = (1..c).to_a.zip([0]*(1..c).to_a.size).to_h

zone0 = colors.dup
zone1 = colors.dup
zone2 = colors.dup

# zoneごとに、さらにcolorごとに何個有るか見ておく。
n.times do |i|
  row = gets.chomp.split.map(&:to_i)
  row.each_with_index do |attr, j|
    case (i + j + 2) % 3
    when 0
      zone0[attr] += 1
    when 1
      zone1[attr] += 1
    when 2
      zone2[attr] += 1
    end
  end
end

evaluations = []
(1..c).to_a.permutation(3) do |l, m, n|
  evaluation = zone0.reduce(0) do |sum, (k, v)|
    sum + colors_diff[k - 1][l - 1] * v
  end
  evaluation = zone1.reduce(evaluation) do |sum, (k, v)|
    sum + colors_diff[k - 1][m - 1] * v
  end
  evaluation = zone2.reduce(evaluation) do |sum, (k, v)|
    sum + colors_diff[k - 1][n - 1] * v
  end
  evaluations.push evaluation
end
puts evaluations.min


Measured memory_bytes: 2684
import java.util.Scanner;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    double w = sc.nextInt();
    double h = sc.nextInt();
    double x = sc.nextInt();
    double y = sc.nextInt();
    int b = 0;
    double a = w * h / 2;
    if(w / 2 == x && h / 2 == y){
      b = 1;
    }
   
    System.out.println(a + " " + b);
  }
}

Measured memory_bytes: 21844
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
#include <set>
using namespace std;

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


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

	int ans = 0;
	rep(i, N) {
		int l, r;
		cin >> l >> r;

		ans += r - l + 1;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
program ABC076B
    implicit none
    integer(8)::N,K,i
    integer(8)::result
    read(5,*)N,K

    do i=1,N
        if(i==1)then
            result=2**i+K*(N-i)
        else if(2**i+K*(N-i)<result)then
            result=2**i+K*(N-i)
        end if
    end do
    print'(i0)',result
end program ABC076B

Measured memory_bytes: 256
// AtCoder Beginner Contest 100
// C - *3 or /2
#include <bits/stdc++.h>
using namespace std;

#define IEF(i, s, t)    for(int i=s; i<t; i++)
#define NEF(i, s, t)    for(int i=s; i>=t; i--)
#define MAXN 100005
#define ll long long

int main(){
    ios_base::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll>arr(N);
    IEF(i, 0, N)
    {
        cin >> arr[i];
    }
    
    ll odd = 0, even = 0;
    IEF(i, 0, N)
    {
        if(arr[i] % 2 != 0)
            odd++;
    }
    
    if(odd == N)    cout << 0;
    else{
        IEF(i, 0, N){
            while(arr[i] % 2 == 0){
                even++;
                arr[i] /= 2;
            }
        }
        cout << even;
    }
    return 0;
}

Measured memory_bytes: 384
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();

		int ans = a - 2*b;
		if(ans < 0){
			ans = 0;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 21844
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		String op = sc.next();
		int b = Integer.parseInt(sc.next());
		if (op.equals("+"))
			System.out.println(a + b);
		else
			System.out.println(a - b);
	}
}

Measured memory_bytes: 21844
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a + 1):
    for j in range(b + 1):
        for k in range(c + 1):
            if x - 500 * i - 100 * j - 50 * k == 0:
                        ans += 1
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder_20190707_1
{    class Program
    {
        static void Main(string[] args)
        {
            long N = int.Parse(Console.ReadLine());

            long[] A = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();

            long max = A[0];
            long answer = 0;

            for(int i = 1; i < A.Length; i++)
            {
                if(A[i] > max)
                {
                    max = A[i];
                }
                else
                {
                    answer += max - A[i];
                }
            }

            Console.WriteLine(answer);
        }
    }
}

Measured memory_bytes: 47692
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <climits>

int main()
{
    long N;
    long a[100];
    std::cin >> N;
    for(long i=0; i<N; i++){
        std::cin >> a[i];
    }
    long count=0;
    for(long i=0; i<N; i+=2){
        if(a[i]%2==1){
            count++;
        }
    }
    std::cout << count << std::endl;
    return 0;
}

Measured memory_bytes: 3588
/*
     Author:Raghav Bansal
     IIIT Una
                  */
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define BOLT ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define X first
#define Y second
#define endl "\n"
using namespace std;
void solve() {
	int k;
	cin >> k;
	int ans = 0;
	for (int i = 1; i <= k; i++)
		for (int j = 1; j <= k; j++)
			for (int l = 1; l <= k; l++) {
				int g = i;
				g = __gcd(g, j);
				ans += __gcd(g, l);
			}
	cout << ans << endl;
}
int32_t main() {
	BOLT;
	int t;
	t = 1;
	while (t--)
	{
		solve();
	}
}

Measured memory_bytes: 3652
// https://atcoder.jp/contests/abc163/tasks/abc163_b
#include <iostream>
typedef long long ll;
using namespace std;

int main() {
    ll no_of_days, no_of_assignments;
    cin >> no_of_days >> no_of_assignments;

    ll total_assignment_time = 0LL;
    
    while (no_of_assignments--) {
        ll this_assignment;
        cin >> this_assignment;

        total_assignment_time += this_assignment;
    }

    ll ans = (no_of_days - total_assignment_time);
    if (ans < 0) {
        ans = -1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e9;
const ll mod = 1e9+7;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int d = a-b;
    if(c-d>=0){
        cout<<c-d<<endl;
    }else{
        cout<<0<<endl;
    }
}

Measured memory_bytes: 256
import random
A = list(map(int,input().split()))
N = list(map(int,input().split()))
C = ["E","W","S","N"]
for _ in range(10**5):
    i = random.choice(C)
    if i == "E":
        N[0],N[2],N[3],N[5] = N[3],N[0],N[5],N[2]
    elif i == "W":
        N[3],N[0],N[5],N[2] = N[0],N[2],N[3],N[5]
    elif i == "S":
        N[0],N[1],N[4],N[5] = N[4],N[0],N[5],N[1]
    else:
        N[4],N[0],N[5],N[1] = N[0],N[1],N[4],N[5]
    
    if A == N:
        print("Yes")
        exit()
print("No")


Measured memory_bytes: 8176
using System;
using System.Collections.Generic;

namespace AtcoderProgram
{
    class Program
    {
        static void Main(string[] args)
        {
            int count = 0;
            int countA = 0;
            int countB = 0;
            int both = 0;

            var strings = new List<string>();
            var num = int.Parse(Console.ReadLine());
            for (int i = 0; i < num; i++)
            {
                string line = Console.ReadLine();
                strings.Add(line);

                int index = 0;
                var length = line.Length;
                if (line.EndsWith("A")) countA++;
                if (line.StartsWith("B")) countB++;
                if (line.EndsWith("A") && line.StartsWith("B")) both++;

                while ((index = line.IndexOf("AB")) >= 0)
                {
                    index++;
                    count++;
                    if (index > length - 1) break;
                    line = line.Substring(index);

                }
            }

            count = count + Math.Min(countA, countB);
            if ((countA == both) && (countB == both) && both > 0) count--;

            Console.WriteLine(count);

        }


    }

}


Measured memory_bytes: 13664
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(I, a, b) for (int i = (a); i < (b); ++i)
using namespace std;
using ll = long long;

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  
  REP(i,n-1){
    if(s[i] != s[i+1]) ans++;
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 3724
/*
@Author
   Sujeet Kushwaha
*/
 
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
 
#define ll long long int
#define fast ios_base::sync_with_stdio(false)
#define fast_input cin.tie(NULL)
#define fast_output cout.tie(NULL)
#define vi vector<long long int> 
#define vp vector<pair<long long int ,long long int>>
#define pb push_back
#define mp make_pair
#define pp pop_back
#define iter vector<int>::iterator
#define pa pair<long long int ,long long int> 
#define f(a,b) for(int a=0;a<b;a++)
#define mod 1000000007
#define F first
#define S second
#define endl "\n"
#define sett set<long long int>
#define um unordered_map<ll,ll>
#define ordered_set tree<pa, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
ll mul(ll a,ll b)
{
	if(a>mod)
	 a-=mod;
	if(b>mod)
	 b-=mod;
	return (a%mod*b%mod)%mod;
}
ll add(ll a,ll b)
{
	ll res=a+b;
	if(res>=mod)
	{
      res-=mod;
	}
	return res;
}
// // ll sub(ll a,ll b)
// // {
// // 	ll res=a-b;
// // 	if(res<0)
// // 	 res+=mod;
// // 	return res;
// // }
ll powmod(ll a, ll b)
{
    ll res = 1;
    while (b) {
        if (b&1) {
            res =mul(res,a);
        }
        b >>= 1;
        a=mul(a,a);
    }
 
    return res;
}
 
ll modinv(ll a)
{
    return powmod(a, mod - 2);
}
 unordered_map<ll,ll>facti;
 ll fact(ll n)
 {
	if(n==0)return 1;
	if(n<=1)return 1;
	if(facti[n]!=0)return facti[n];
	return facti[n]=mul(n,fact(n-1));
 }
  ll ncr(ll n,ll r)
  {
        ll h=fact(n);
	ll v=fact(r);
	ll j=fact(n-r);
	v=mul(v,j);
	v=powmod(v,mod-2);
	return mul(h,v);
 }
// int fastread(){
//     int x=0;
//     int c = getchar_unlocked();
//     while(c<48)
//         c = getchar_unlocked();
//     while(c>=48){
//         x = x*10 + (c - 48);
//         c = getchar_unlocked();
//     }
//     return x;
// }
int ret(ll a[],ll n)
{
  ll a1[n];
  f(i,n)
  {
    a1[i]=i+1;
    // cout<<a[i]<<" "<<a1[i]<<endl;
  }
  ll ans=0;
  do
  {
    ll flag=1;
    for(int i=0;i<n;i++)
    {
      // cout<<a1[i]<<" ";
      if(a1[i]==a[i])
      {
        continue;
      }
      else
      {
        flag=0;
        break;
      } 
    }
    // cout<<endl;
    ans++;
    if(flag==1)
    {
      break;
    }
  }while(next_permutation(a1, a1 + n));
  return ans;
}
void solve()
{
  ll n;
  cin>>n;
  ll a[n];
  ll b[n];
  f(i,n)
  {
    cin>>a[i];
  }
  f(i,n)
  {
    cin>>b[i];
  }
  // cout<<ret(a,n)<<endl<<ret(b,n)<<endl;
  cout<<abs(ret(a,n)-ret(b,n));
}
int main() {
	fast;
	fast_input;
	fast_output;
	
	  solve();
	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	design := []rune{'S', 'H', 'C', 'D'}
	trump := make(map[rune][]bool)

	for _, d := range design {
		trump[d] = make([]bool, 13)
	}

	var n int
	fmt.Scan(&n)
	for i := 0; i < n; i++ {
		var d rune
		var r int

		fmt.Scanf("%c %d", &d, &r)
		trump[d][r-1] = true
	}

	for _, d := range design {
		for i, t := range trump[d] {
			if !t {
				fmt.Printf("%c %d\n", d, i+1)
			}
		}
	}
}



Measured memory_bytes: 1176
#include <iostream>

using namespace std;

class cQQ
{
public:
	void output();
};

void cQQ::output()
{
	for (int i = 1; i < 10; ++i)
	{
		for (int j = 1; j < 10; ++j)
		{
			cout << i << "x" << j << "=" << i * j << endl;
		}
	}
}

int main()
{
	cQQ cqq;
	cqq.output();

	return 0;
}

Measured memory_bytes: 3068
N, A, B, C = list(map(int,input().split()))
l = [int(input()) for _ in range(N)]

def dfs(i, a, b, c):
    if i == N:
        if a and b and c:
            return abs(a - A) + abs(b - B) + abs(c - C)
        else:
            return 10 ** 9 + 7
    else:
        ret1 = dfs(i + 1, a + l[i], b, c) + 10
        ret2 = dfs(i + 1, a, b + l[i], c) + 10
        ret3 = dfs(i + 1, a, b, c + l[i]) + 10
        ret4 = dfs(i + 1, a, b, c)
        ret = min(ret1, ret2, ret3, ret4)
        return ret
    
ans = dfs(0, 0, 0, 0)
print(ans - 30)

Measured memory_bytes: 42200
#include <stdio.h>

int main(void)
{
    int a, b, d, r;
    double f;
    
    scanf("%d%d", &a, &b);
    
    d = a / b;
    r = a % b;
    f = (double)a / b;
    
    printf("%d %d %f\n", d, r, f);

    return 0;
}

Measured memory_bytes: 636
// Problem Link: 
// Tutorial Link: 

#include<bits/stdc++.h>
 
using namespace std;
 
#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)
#define mod 1000000007

LL n, a[200005];

int main()
{
	FIO;
	cin >> n;
	rep(i,1,n) cin >> a[i];
	sort(a+1, a+n+1);
	reverse(a+1, a+n+1);
	LL cur = 1, cnt = 1, ans = 0;
	rep(i,2,n) {
		if(cnt == 0) {
			cnt = 2;
			cur++;
		}
		ans += a[cur];
		cnt--;
	}
	cout << ans << endl;
}

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

using namespace std;

int main()
{
    long long a, b, c;
    long long ans = 1e18 + 1e7;
    cin >> a >> b >> c;

    ans = min(ans, a * b * (c&1));
    ans = min(ans, a * c * (b&1));
    ans = min(ans, c * b * (a&1));

    cout << ans;

	return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath> 
#include<algorithm>
#define ll long long 
using namespace std;
const int maxn=500010, inf=1e9+233;
int n;
int a[233];

template<typename T>
inline void read(T &k)
{
    int f=1; k=0; char c=getchar();
    while(c<'0' || c>'9') c=='-'&&(f=-1), c=getchar();
    while(c<='9' && c>='0') k=k*10+c-'0', c=getchar();
    k*=f;
}

int main()
{
    for(int i=1;i<=4;i++) read(a[i]);
    sort(a+1, a+1+4);
    if(a[1]==1 && a[2]==4 && a[3]==7 && a[4]==9) puts("YES")    ;
    else puts("NO");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	vector<pii> a(n);
	rep(i,n) cin >> a.at(i).second >> a.at(i).first;
	sort(a.rbegin(),a.rend());
	map<int,bool> m;
	stack<int> s;
	ll sum=0,type=0;
	vector<ll> ans(n+1);
	rep(i,n){
		if(i<k){
			if(m[a.at(i).second]){
				sum+=a.at(i).first;
				s.push(a.at(i).first);
				ans[type]=sum;
			}
			else{
				sum+=a.at(i).first-type*type;
				type++;
				sum+=type*type;
				m[a.at(i).second]=true;
				ans[type]=sum;
			}
		}
		else{
			if(!m[a.at(i).second] && s.size()!=0){
				sum-=s.top()+type*type;
				type++;
				sum+=a.at(i).first+type*type;
				ans[type]=sum;
				s.pop();
				m[a.at(i).second]=true;
			}
			else ans[type]=sum;
		}
	}
	ll res=0;
	rep(i,n+1) res=max(res,ans[i]);
	cout << res << endl;
}

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


int n;
string s;
long long ans=0;

void F(long long x,long long y){
	if(x==n+1){
		ans+=y;
		return;
	}
	long long cur=0;
	for(long long i=x;i<=n;i++){
		cur=(10*cur)+(s[i]-'0');
		F(i+1, y+cur);
	}
}

int main(){
	cin >> s;
	n=s.size();
	s=' '+s;
	F(1,0);
	cout << ans << endl;
	return 0;
}

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

int main() {
  string s;
  cin >> s;

  vector<bool> c(26, false);
  bool flag = false;
  for (size_t i = 0; i < s.size(); ++i) {
    auto a = s[i] - 'a';
    if (c[a]) {
      cout << "no";
      flag = true;
      break;
    } else {
      c[a] = true;
    }
  }
  if (!flag) {
    cout << "yes";
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repn(i, n) for (int i = 0; i <= (int)(n); i++)
#define srep(i, l, n) for (int i = l; i < (int)(n); i++)
#define srepn(i, l, n) for (int i = l; i <= (int)(n); i++)
#define pb push_back 
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; }

const int MOD = 1000000007;
const int INF = 1e9;
#define PI 3.14159265369;
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
	ll n, k;
	cin >> n >> k;
	vector<int> a(n);
	rep(i,n) cin >> a[i];
	int roop, pre;
	vector<int> v(n+1, -1);
	v[1] = 0;
	vector<int> r;
	r.push_back(1);
	int now = 1;
	int cnt = 0;
	while(1) {
        cnt++;
		int next = a[now-1];
		if(v[next] == -1) {
			v[next] = cnt;
			r.push_back(next);
            now = next;
		}else{
			roop = cnt - v[next];
			pre = v[next];
			break;
		}
	}
	if(k < pre) cout << r[k] << endl;
	else {
		int ans = (k-pre)%roop+pre;
		cout << r[ans] << endl;
	}

}

Measured memory_bytes: 5868
#include <iostream>

//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <queue>
#include <bitset>
#include <tuple>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s)
{
    int v;
    istringstream sin(s);
    sin >> v;
    return v;
}
template <class T>
inline string toString(T x)
{
    ostringstream sout;
    sout << x;
    return sout.str();
}

//math
//-------------------------------------------
template <class T>
inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())

//repetition
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0, sizeof(a))

//debug
// #define dump(x) cerr << #x << " = " << (x) << endl;
// #define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
//                       << " " << __FILE__ << endl;

using node = pair<LL, LL>; // vert index, cost

using ll = long long;
const int limit = 100010;
using edge = struct
{
    int to;
    ll cost;
};

vector<edge> tree[limit];
ll depth[limit];

void dfs(int v, int p, ll d)
{
    depth[v] = d;
    for (auto &e : tree[v])
    {
        if (e.to == p)
            continue;
        dfs(e.to, v, d + e.cost);
    }
}

int main(void)
{
    int n;
    cin >> n;

    for (int i = 0; i < n - 1; ++i)
    {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        tree[a].push_back({b, c});
        tree[b].push_back({a, c});
    }

    int q, k;
    cin >> q >> k;
    k--;

    dfs(k, -1, 0);
    for (int i = 0; i < q; ++i)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        cout << depth[x] + depth[y] << endl;
    }
}


Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++) //for文マクロ
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P; //ペア　タイプでふ

int main()
{
    int a, b;
    cin >> a >> b;
    cout << a + b / 2;
}

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

int main() {
    int n, l;
    scanf("%d %d", &n, &l);
    vector<int> len(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &len[i]);
    }

    int pick = -1;
    for (int i = 0; i + 1 < n; ++i) {
        if (len[i] + len[i + 1] >= l) {
            pick = i;
            break;
        }
    }
    if (pick == -1) {
        printf("Impossible\n");
        return 0;
    }

    printf("Possible\n");
    for (int i = 0; i < pick; ++i) {
        printf("%d\n", i + 1);
    }
    for (int i = n - 2; i > pick; --i) {
        printf("%d\n", i + 1);
    }
    printf("%d\n", pick + 1);
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
int main(){
    int n;
    vector<int> v1, v2;
    int a, b, c, d;
    cin >> n;
    int x, y;
    for(int i = 0; i < n; i++){
        cin >> x >> y;
        v1.push_back(x+y);
        v2.push_back(x-y);
    }
    // for_each(v1.begin(), v1.end(), [](int ele){cout << ele<< endl;});
    // for_each(v2.begin(), v2.end(), [](int ele){cout << ele<< endl;});
    int ans = max(*max_element(v1.begin(), v1.end()) - *min_element(v1.begin(), v1.end()), *max_element(v2.begin(), v2.end()) - *min_element(v2.begin(), v2.end()));
    cout << ans << endl;
}

Measured memory_bytes: 5064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> b >> a;
  string s[b];
	for(int i=0;i<b;i++){
      cin >> s[i];
	}
	sort(s, s+b);
	for(int i=0;i<b;i++){
		cout << s[i];
	}
}


Measured memory_bytes: 256
N,M = map(int,input().split())
#ks[i][0]がk_i
ks = [[int(i) for i in input().split()]for i in range(M)]
p=list(map(int,input().split()))
ans=0
for i in range(2**N):
    flag=0
    #Onoff[i]=0はスイッチiのOFFを、=1はONを表す
    OnOff = [0]*N
    for j in range(N):
        if (i>>j) & 1:
            OnOff[j]=1
    
    for j in range(M):
        count=0
        for l in range(1,len(ks[j])):
            if(OnOff[ks[j][l]-1]==1):
                count+=1
        if(p[j]==0 and count%2==0):
            flag+=1
        elif(p[j]==1 and count%2==1):
            flag+=1
        else:
            pass
    
    if(flag==len(p)):
        ans+=1
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		// argumentの取得
		Scanner s = new Scanner(System.in);
      
        int x = s.nextInt();
		String y = s.next();
      
        StringBuilder sb = new StringBuilder(); //戻り値
      
        //System.out.println("length= " + y.length());
        
        for (int i=0; i<y.length();i++){
          if ((y.charAt(i) + x) > 90) {
            sb.append((char) (y.charAt(i) + x -26)); 
          } else {
            sb.append((char) (y.charAt(i) + x)); 
          }
        }
      
		// 戻り値の返却
		//System.out.println((char) 65); 
        System.out.println(sb); 
	
	} 
}

Measured memory_bytes: 23764
import heapq

h, w, a, b = map(int, input().split())

right = a*h - b*w
ex = 2*a - w
ey = 2*b - h
x = 0
y = 0
error = True
for i in range(h+1):
    for j in range(w+1):
        if ex * i - ey * j == right:
            x = i
            y = j
            error = False
            break

if error == True:
    exit()
lp = []
for i in range(w-y):
    heapq.heappush(lp, (b-h, i))
for i in range(w-y, w):
    heapq.heappush(lp, (-b, i))
lit = [[0] * w for _ in range(h)]

for i in range(h):
    point = a
    if i < h - x:
        point = w-a
    popped = []
    for j in range(point):
        score, jx = heapq.heappop(lp)
        lit[i][jx] = 1
        if score+1 < 0:
            popped.append((score+1, jx))
    for score, jx in popped:
        heapq.heappush(lp, (score, jx))
    print(''.join(map(str, lit[i])))


Measured memory_bytes: 69468
using System;

namespace ABC064
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');

            var r = int.Parse(input[0]);
            var g = int.Parse(input[1]);
            var b = int.Parse(input[2]);

            var result = (r * 100) + (g * 10) + b;

            if (result % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


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

int main(){
  int N, M, X, A[100], left, right;
  left = 0;
  right = 0;
  std::cin >> N >> M >> X;
  for (int i = 0; i < M; i++) {
    std::cin >> A[i];
    if (A[i] < X) {
      left += 1;
    }
    else {
      right += 1;
    }
  }
  std::cout << std::min(left, right) << std::endl;
}

Measured memory_bytes: 3660
N,K=map(int,input().split())
D=[int(x) for x in input().split()]
D=set(D)
kouho=N
while(1):
    lenkouho=len(str(kouho))
    flag=1
    for i in range(lenkouho):
        if int(str(kouho)[i]) in D:
            flag=0
    if flag==1:
        print(kouho)
        break
    kouho+=1


Measured memory_bytes: 9132