akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>
#include <string>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int N;
void dfs(int pos, int used, const std::string &S) {
  if (pos == N) {
    std::cout << S << '\n';
    return;
  }
  for (int i: range(0, used)) {
    dfs(pos + 1, used, S + char('a' + i));
  }
  dfs(pos + 1, used + 1, S + char('a' + used));
}

int main() {
  std::cin >> N;
  dfs(1, 1, "a");
  return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {
		
	// }
	int n, W;
	cin >> n >> W;
	vector<int> weights(n), values(n);
	for (int i = 0; i < n; i++) {
		cin >> weights[i] >> values[i];
	}
	vector<vector<int>> max_sum(n + 1, vector<int> (W + 1, 0));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= W; j++) {
			max_sum[i][j] = max_sum[i - 1][j];
			if (j - weights[i - 1] >= 0) {
				max_sum[i][j] = max(max_sum[i][j], values[i - 1] + max_sum[i - 1][j - weights[i - 1]]);
			}
		}
	}
	cout << max_sum[n][W] << endl;

	return 0;
}

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

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define erep(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9+7;

typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
typedef long long i64;

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

  int n;
  cin >> n;
  rep(i, 0, n) {
    int x, y, b, p;
    cin >> x >> y >> b >> p;
    int ans = x * b + y * p;
    if(b >= 5 && p >= 2) ans *= 0.8;
    else {
      int tmp = max(b, 5) * x + max(p, 2) * y;
      tmp *= 0.8;
      ans = min(ans, tmp);
    }
    cout << ans << endl;
  }
}



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

int main() {

  char c = 'a';
  cin >> c;

  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o'){
    cout << "vowel" << endl;
  }

  else{
    cout << "consonant" << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    ll H,W,N;
    cin >> H >> W >> N;
    map<P, int> mp;
    rep(i,0,N){
        int y,x;
        cin >> y >> x;
        y--,x--;
        rep(j,-1,2)rep(k,-1,2){
            if(y + j < 1 || y + j >= H-1 || x + k < 1 || x + k >= W-1)continue;
            mp[P(y + j, x + k)]++;
        }
    }
    ll cnt[10] = {(H-2) * (W-2)};
    ll sum = 0;
    for(auto pp:mp){
        cnt[pp.second]++;
    }
    rep(i,1,10)sum += cnt[i];
    cnt[0] -= sum;
    rep(i,0,10)cout << cnt[i] << endl;
}

Measured memory_bytes: 56448
#include <iostream>
using namespace std;
int n, a[10000000];
inline int search(int key) {
	int l = 0;
	int r = n;

	while (r > l) {
		int mid = (l + r) / 2;
		if (a[mid] == key)
			return 1;
		else if (a[mid] < key)
			l = mid + 1;
		else if (a[mid] > key)
			r = mid;
	}
	return 0;
}
int main() {
	const int num = 10001;
	int q, key, sum=0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> key;
		if (search(key)) sum++;
		
	}
	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 3392
#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
#define N 500007
#define pb push_back;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
#define mod 998244353

int main()
{
    FAST;
    char c;
    cin>>c;
    if(c>='A'&&c<='Z')
    {
        cout<<"A";
    }
    else
    {
        cout<<"a";
    }
}

Measured memory_bytes: 3644
// Think twice, Code once
// 1SAC
#include<bits/stdc++.h>
using namespace std;
 
/*============================ DEBUGGING =============================*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
/*============================= DEFINES ==============================*/
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
/*============================== TYPEDEFS ============================*/
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef long double ld;
/*============================ START FROM HERE =======================*/
 
int main(){
	FIO
	
	int k,x;cin >> k >> x;
	if(x <= k*500)cout << "Yes";
	else cout << "No\n";
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#define SF scanf
#define PF printf
#define MAXN 300010
#define MOD 998244353
using namespace std;
typedef long long ll;
ll a,b,m;
int n;
ll fac[MAXN],inv[MAXN];
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}
ll C(ll n,ll m){
	if(n<m)
		return 0;
	return fac[n]*inv[m]%MOD*inv[n-m]%MOD;
}
ll query(ll x,ll y){
	ll res=0;
	return C(n,x)*C(n,y)%MOD;
}
int main(){
	SF("%d%lld%lld%lld",&n,&a,&b,&m);
	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=fac[i-1]*i%MOD;
	inv[n]=fsp(fac[n],MOD-2);
	for(int i=n;i>=1;i--)
		inv[i-1]=inv[i]*i%MOD;
	ll ans=0;
	for(ll i=0;i<=n;i++){
		ll sa=a*i;
		if(sa<=m&&(m-sa)%b==0){
			ll j=(m-sa)/b;
			if(max(i,j)>n)
				continue;
			ans=(ans+query(i,j))%MOD;
		}
	}
	PF("%lld",ans);
}

Measured memory_bytes: 4864
#include <stdio.h>
double fabs(double a){return (a<0)?-a:a;}
double a,t,h;
int n;
void Main(){
    scanf("%d",&n);
    scanf("%lf%lf",&t,&a);
    double d = 1e10;
    int Ans = 0;
    for(int i = 1;i<=n;i++){
        scanf("%lf",&h);
        double tp = t-(h*0.006);
        // printf("%lf ",tp);
        if(d>fabs(a-tp)){
            Ans = i;
            d = fabs(a-tp);
        }
    }
    printf("%d\n",Ans);
}
int main(){
    Main();
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define RI register int
int a[250005],x[505],n;
struct node{int v,x;}t[505];
bool cmp(node k1,node k2) {return k1.x<k2.x;}
int main()
{
	int x;scanf("%d",&n);
	for(RI i=1;i<=n;++i) scanf("%d",&x),a[x]=i,t[i]=(node){i,x};
	sort(t+1,t+1+n,cmp);
	int j=1;
	for(RI i=1;i<=n;++i) {
		for(RI k=1;k<=t[i].v-1;++k) {
			while(j<n*n&&a[j]) ++j;
			if(a[j]||j>t[i].x) {puts("No");return 0;}
			a[j]=t[i].v;
		}
	}
	for(RI i=1;i<=n;++i) {
		for(RI k=t[i].v+1;k<=n;++k) {
			while(j<n*n&&a[j]) ++j;
			if(a[j]||j<t[i].x) {puts("No");return 0;}
			a[j]=t[i].v;
		}
	}
	puts("Yes");
	for(RI i=1;i<=n*n;++i) printf("%d ",a[i]);
	return 0;
}

Measured memory_bytes: 2176
//Author:- Yatin Patel
//Mail:- yatinpatel.gt@gmail.com

#include <bits/stdc++.h>
#define FILEIN ifstream fin;fin.open("input.txt");
#define FILEOUT ofstream fout;fout.open("output.txt");

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}

#define FAST ios::sync_with_stdio(false);ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

#define ll long long
#define ld long double
#define pb push_back
#define ff first
#define ss second

#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define minQueue priority_queue<ll,vector<ll>,greater<ll> >
#define maxQueue priority_queue<ll,vector<ll>,less<ll> > 

#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define RFOR(i,a,b) for(ll i=a;i>b;i--)
#define FILL(a,b) memset((a),(b),sizeof((a)))

#define MOD 1000000007
#define INF LONG_MAX
#define MINF LONG_MIN

ll power(ll x, unsigned ll y){
    if (y == 0)
        return 1;
    else if (y%2 == 0)
        return power(x, y/2)*power(x, y/2);
    else
        return x*power(x, y/2)*power(x, y/2);
}

//#define fin cin
//#define fout cout

int main(){

    FAST;
    ll n;
    cin>>n;
    vector<vector<ll> > v(n);
    for(ll i=0;i<n;i++){
        vector<ll> tmp;
        for(ll j=0;j<3;j++){
            ll tp;
            cin>>tp;
            tmp.pb(tp);
        }
        v[i] = tmp;
    }

    ll dp[n][3];
    for(ll i=0;i<n;i++){
        for(ll j=0;j<3;j++){
            dp[i][j] = 0;   
        }
    }

    for(ll i=0;i<3;i++){
        dp[n-1][i] = v[n-1][i];
    }

    for(ll i=n-2;i>=0;i--){
        dp[i][0] = v[i][0] + max(dp[i+1][1],dp[i+1][2]);
        dp[i][1] = v[i][1] + max(dp[i+1][0],dp[i+1][2]);
        dp[i][2] = v[i][2] + max(dp[i+1][0],dp[i+1][1]);
    }

    cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));

    return 0;
}






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

#define ll long long
#define ar array
 
using namespace std;

int main() {

    int p, q, r, res;
    
    cin >> p >> q >> r;
    
    res = max(max(p, q), r);
    
    cout << p+q+r-res << endl;

    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	sc = initScanner(os.Stdin)
	N := scanInt(sc)
	S := scanString(sc)

	fmt.Println(resolve(S, N))
}

func resolve(S string, N int) int {
	s := strings.Split(S, "")

	x, max := 0, 0
	for _, v := range s {
		if v == "I" {
			x++
			if x > max {
				max = x
			}
		} else if v == "D" {
			x--
		}
	}

	return max
}

// --------------- BASE DEFINITIONS ---------------

const (
	initialBufSize = 100000
	maxBufSize     = 1000000
)

var sc *bufio.Scanner

func initScanner(r io.Reader) *bufio.Scanner {
	buf := make([]byte, initialBufSize)

	sc := bufio.NewScanner(r)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	return sc
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func scanIntSlice(sc *bufio.Scanner, n int) []int {
	is := make([]int, n)
	for i := 0; i < n; i++ {
		is[i] = scanInt(sc)
	}

	return is
}

func scanString(sc *bufio.Scanner) string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1784
x, k, d = map(int, input().split())

if abs(x) >= d * k:
    print(abs(x) - d * k)
else:
    if (k - abs(x)//d) % 2 == 0:
        print(abs(x) - d * (abs(x)//d))
    else:
        print(abs(abs(x) - d * (abs(x)//d + 1)))

Measured memory_bytes: 9176
import math
import random
import sys
import heapq
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, UserString
from functools import lru_cache, cmp_to_key
from itertools import (chain, combinations, combinations_with_replacement,
                       permutations, product)

sys.setrecursionlimit(10**7)
input = sys.stdin.readline
MAX_INT = 2**62-1


def main():
    k = int(input())
    queue = deque(list(range(1,10)))
    x = 0
    while k > 0:
        # print(queue)
        k -= 1
        x = queue.popleft()
        tail = x % 10
        if x % 10 != 0:
            queue.append(10*x + tail - 1)
        queue.append(10*x + tail)
        if x % 10 != 9:
            queue.append(10*x + tail + 1)
    print(x)

    

if __name__ == "__main__":
    main()


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

int main(){
  int n, m;
  cin >> n >> m;
  int ans = pow(2,m)*(m*1900+(n-m)*100);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
N, L = map(int, input().split())

apples = []
zerochk = False
taste_sum = 0
for i in range(N):
    taste = L + i
    apples.append(taste)
    taste_sum += taste
    if taste == 0: zerochk = True


minval = 100

if zerochk:

    print('{}'.format(taste_sum))

elif L > 0:

    print('{}'.format(taste_sum - apples[0]))

else: # zerochk == True and L < 0

    for i in range(1, len(apples)):
        minval = min(minval, abs(apples[i]))

    ans = 0
    if taste_sum < 0:
        ans = abs(taste_sum) - abs(minval)
        ans *= -1
    else: # taste_sum >= 0
        ans = taste_sum - abs(minval)
    print('{}'.format(ans))






Measured memory_bytes: 3064
class Dice(object):
    def __init__(self, top, south, east, west, north, bottom):
        self.top = top
        self.south = south
        self.east = east
        self.west = west
        self.north = north
        self.bottom = bottom

    def get_top(self):
        return self.top
    
    def rotate(self, directions):
        for direction in directions:
            if direction == 'S':
                self.prev_top = self.top
                self.top = self.north
                self.north = self.bottom
                self.bottom = self.south
                self.south = self.prev_top
            elif direction == 'E':
                self.prev_top = self.top
                self.top = self.west
                self.west = self.bottom
                self.bottom = self.east
                self.east = self.prev_top
            elif direction == 'W':
                self.prev_top = self.top
                self.top = self.east
                self.east = self.bottom
                self.bottom = self.west
                self.west = self.prev_top
            elif direction == 'N':
                self.prev_top = self.top
                self.top = self.south
                self.south = self.bottom
                self.bottom = self.north
                self.north = self.prev_top
 
dice = Dice(*map(int,input().split()))
dice.rotate(input())
print(dice.get_top())

Measured memory_bytes: 7756
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
int main(void)
{
  int S, h, m, s;
  cin >> S;
  h = S / 3600;
  m = S % 3600 / 60;
  s = S % 60;
  cout << h << ":" << m << ":" << s << endl;
}


Measured memory_bytes: 3108
n = int(input())
a = []
b = []
for i in range(n):
    p,q = map(int,input().split())
    a.append(p)
    b.append(q)

ab = zip(b,a)
ab = sorted(ab)
b,a = zip(*ab)

val = 0
ans  = "Yes"
for i in range(n):
    val +=a[i]
    if val > b[i]:
        ans = "No"
        break
print(ans)

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

typedef long long ll;
typedef pair<int, int> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    vector<vector<map<int, ll>>> dp(N+1, vector<map<int, ll>>(2));
    vector<vector<map<int, bool>>> flg(N+1, vector<map<int, bool>>(2));
    dp[0][0][0] = 0;

    rep(i, N) {
        rep(j, 2) {
            for (auto &p : dp[i][j]) {
                int k = p.first, ni = i+1, nk = k;
                rep(nj, 2) {
                    if (j && nj) continue;
                    if (nj) nk++;
                    
                    if (nk < (ni-1)/2 || (ni+1)/2 < nk) continue;

                    if (nj) {
                        if (dp[ni][nj].count(nk)) chmax(dp[ni][nj][nk], dp[i][j][k] + A[i]);
                        else dp[ni][nj][nk] = dp[i][j][k] + A[i];
                    } else {
                        if (dp[ni][nj].count(nk)) chmax(dp[ni][nj][nk], dp[i][j][k]);
                        else dp[ni][nj][nk] = dp[i][j][k];
                    }
                }
            }
        }
    }

    ll ans = max(dp[N][0][N/2], dp[N][1][N/2]);
    cout << ans << endl;
}

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

using ll = long long;
static const ll MOD = 1e9 + 7;

// 繰り返し自乗法(x^nをmで割った余り) O(logn)
ll power(ll x, ll n, ll m) {
  ll res = 1;
  if(n > 0){
    res = power(x, n / 2, m);
    if(n % 2 == 0) res = (res * res) % m;
    else res = (((res * res) % m) * x) % m;
  }
  return res;
}

// 組合せを素数で割った値を求める
const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for(int i = 2; i < MAX; i++){
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

// 二項係数計算
long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

// 階乗
ll factorial(int n) {
  if(n == 0) return 1;
  return (n * factorial(n - 1)) % MOD;
}
ll rest(int n, int r) {
  ll keep = 1, now = n;
  for(int i = 0; i < r; i++){
    keep *= now;
    now--;
    keep %= MOD;
  }
  return keep;
}
// 階乗を利用した組合せ
ll nCr(int n, int r) {
  if (n < r) return 0;
  if (n < 0 || r < 0) return 0;
  return /*factorial(n) **/ (finv[r] * rest(n, r) % MOD) % MOD;
}



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll n, a, b;
  cin >> n >> a >> b;
  
  ll ans = power(2, n, MOD);
  ans += MOD * 3;
  ans -= 1;
  
  COMinit();
  
  ans -= nCr(n, a);
  ans -= nCr(n, b);
  ans %= MOD;
  
  cout << ans << '\n';
}

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

using namespace std;

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

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

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define re(i,n) for(i=0;i<n;i++)
#define bre(i,n) for(i=n;i>0;i--)
#define rep(i,l,r) for(i=l;i<r;i++)
#define brep(i,l,r) for(i=r;i>l;i--)
const int inf=1145141919810893;
const int mod=998244353;
using namespace std;
template<class T>bool chmin(T &a,const T &b){
	if(a>b){
		a=b;
		return true;
	}
	return false;
}
template<class T>bool chmax(T &a,const T &b){
	if(a<b){
		a=b;
		return true;
	}
	return false;
}
template<class T>void debug(T *a,int l,int r,const char *name){
	for(int i=l;i<r;i++)
		cout<<name<<"["<<i<<"]="<<a[i]<<endl;
}
template<int H,int W>int wa(int x1,int y1,int x2,int y2,int(&p)[H][W]){
	return p[y2][x2]-p[y2][x1]-p[y1][x2]+p[y1][x1];
}
struct Unif{
	vector<int> e;
	vector<int> rank;
	Unif(int n):e(n,-1),rank(n,1){}
	void uni(int a,int b){
		if(e[a]!=-1)
			uni(e[a],b);
		else if(e[b]!=-1)
			uni(a,e[b]);
		else{
			if(a==b)
				return;
			int ra=rank[a],rb=rank[b];
			if(ra>=rb){
				e[b]=a;
				if(ra==rb)
					rank[a]++;
			}
			else
				e[a]=b;
		}
	}
	bool find(int a,int b){
		if(e[a]!=-1)
			return find(e[a],b);
		else if(e[b]!=-1)
			return find(a,e[b]);
		else
			return a==b;
	}
	int num(int a){
		if(e[a]!=-1)
			return num(e[a]);
		else
			return a;
	}
};
int A,B,C,D,N,M,K,S,T,H,W,Q,X,Y;
int aa[114514],bb[114514];
int *p=aa+1,*q=bb+1,r[114514],s[114514];
signed main(){
	int i,j,k;
	cin>>N>>C;
	re(i,N)
		cin>>p[i]>>q[i];
	rep(i,1,N+1){
		r[i]=r[i-1]+q[i-1];
		s[i]=s[i-1]+q[N-i];
	}
	p[N]=C;
	int ans=0;
	int left=0;
	re(i,N+1){
		if(r[i]-p[i-1]*2>r[left]-p[left-1]*2)
			left=i;
		chmax(ans,r[left]-p[left-1]*2+s[N-i]-(C-p[i]));
	}
	left=0;
	re(i,N+1){
		if(r[i]-p[i-1]>r[left]-p[left-1])
			left=i;
		chmax(ans,r[left]-p[left-1]+s[N-i]-(C-p[i])*2);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3328
from collections import defaultdict

dic = defaultdict(int)
N = int(input())
for i in range(N):
    S = input()
    dic[S] += 1
candidate = list(zip(*sorted(dic.items(), key=lambda x: (-x[1], x[0]))))
for i in range(len(candidate[0])):
    if candidate[1][i] != candidate[1][0]:
        exit()
    print(candidate[0][i])


Measured memory_bytes: 57948
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void solveRGBCards() throws IOException {
		int r;
		int g;
		int b;
		String line;
		String[] split;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		line = br.readLine();
		split = line.split(" ");
		r = Integer.parseInt(split[0]);
		g = Integer.parseInt(split[1]);
		b = Integer.parseInt(split[2]);
		if ((g * 10 + b) % 4 == 0) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}

		br.close();
	}

	public static void main(String[] args) {
		try {
			solveRGBCards();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;


namespace StartFinish
{
 
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                //?????????
                int[] mfr = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int m = mfr[0];
                int f = mfr[1];
                int r = mfr[2];
                if (m == -1 && f == -1 && r == -1)
                {
                    break;
                }
                int sum = m + f;

                //?????¶????????????
                if (m == -1 || f == -1)
                {
                    Console.WriteLine("F");
                    continue;
                }else if (sum >= 80)
                {
                    Console.WriteLine("A");
                    continue;
                }else if (65 <= sum && sum < 80)
                {
                    Console.WriteLine("B");
                    continue;
                }else if (50 <= sum && sum < 65)
                {
                    Console.WriteLine("C");
                    continue;
                }else if (30 <= sum && sum < 50)
                {
                    if (r >= 50)
                    {
                        Console.WriteLine("C");
                        continue;
                    }else
                    {
                        Console.WriteLine("D");
                        continue;
                    }
                }else
                {
                    Console.WriteLine("F");
                }
            }
        }
    }
}

Measured memory_bytes: 9256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
ll INFL = 1000000000000000010;//10^18 = 2^60
int INF = 1000000000;//10^9
ll MOD  = 1000000007;
//vector<int> dy = {0,0,1,-1};
//vector<int> dx = {1,-1,0,0};
ll dp[100010];
int main(void){
	ll N, M;
	cin >> N >> M;
	set<ll> set;
	for(int i = 0; i < M; i++){
		ll x;
		cin >> x;
		set.insert(x);
	}
	ll ans = 0;
	dp[0] = 1;
	for(int i = 1; i <= N; i++){
		if(i-2 >= 0){
			if(set.count(i) == 0){
				dp[i] = dp[i-1] + dp[i-2];
				dp[i] %= MOD;
			}
		}else{
			if(set.count(1) == 0){
				dp[1] = dp[0];
			}
		}
	}
	cout << dp[N] % MOD << endl;

}


Measured memory_bytes: 4992
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int N;
int A[1000];
bool used[1000];
void construct(vector<int> seq) {
  assert(!seq.empty());
  for (int x : seq) used[x] = true;
  vector<int> cur;
  rep(i, N) cur.pb(used[i]);
  vector<int> op;
  while (!cur.empty() && cur.back()  == 0) op.pb(cur.size()-1), cur.pop_back();
  while (!cur.empty() && cur.front() == 0) op.pb(0), cur.erase(cur.begin());
  //for (int x:cur)cout<<x;cout<<"\n";
  while (cur.size() > 1) {
    bool ok = false;
    rep(i, (int)cur.size()-2) if (cur[i] == 0 && cur[i+1] == 0 && cur[i+2] == 0) {
      op.pb(i+1);
      rep(_, 2) cur.erase(cur.begin()+i);
      ok = true;
      break;
    }
    if (ok) continue;
    break;
  }
  // 101010101
  while (cur.size() > 1) {
    assert(cur.size()>=3&&cur[0]&&!cur[1]&&cur[2]);
    op.pb(1);
    rep(_, 2) cur.erase(cur.begin());
  }
  cout << op.size() << "\n";
  for (int x : op) cout << x+1 << "\n";
}

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  rep(i, N) cin >> A[i];
  P mx = P(-INF, -1);
  rep(i, N) mx = max(mx, P(A[i], i));
  if (mx._1 <= 0) {
    cout << mx._1 << "\n";
    construct({mx._2});
  }
  else {
    long long m = 0;
    rep(parity, 2) {
      long long s = 0;
      for (int i=parity; i<N; i+=2) if (A[i] > 0) s += A[i];
      m = max(m, s);
    }
    assert(m>0);
    rep(parity, 2) {
      vector<int> seq;
      long long s = 0;
      for (int i=parity; i<N; i+=2) if (A[i] > 0) s += A[i], seq.pb(i);
      if (m == s) {
         cout << m << "\n";
         construct(seq);
         return 0;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin >> a >> b;
  int N = stoi(to_string(a) + to_string(b));
  bool res = false;
  for (int i = 0; i < N; i++) if (i * i == N) res = true;
  cout << (res ? "Yes" : "No");
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX 10000
#define NIL -1

typedef struct Node
{
  int p;
  int l;
  int r;
} node;

node T[MAX];
int n;

void preParse(int u);
void inParse(int u);
void postParse(int u);

int main(void)
{
  int i;
  int v;
  int l,r;
  int root;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
      T[i].p=NIL;
    }

  for(i=0;i<n;i++)
    {
      scanf("%d%d%d",&v,&l,&r);

      T[v].l=l;
      T[v].r=r;

      if(l!=NIL)
	{
	  T[l].p=v;
	}
   
      if(r!=NIL)
	{
	  T[r].p=v;
	}
    }

  for(i=0;i<n;i++)
    {
      if(T[i].p==NIL)
	{
	  root=i;
	}
    }

  puts("Preorder");
  preParse(root);
  putchar('\n');
  puts("Inorder");
  inParse(root);
  putchar('\n');
  puts("Postorder");
  postParse(root);
  putchar('\n');

  return 0;
}

void preParse(int u)
{
  if(u==NIL)
    {
      return;
    }
 
  printf(" %d",u);

  preParse(T[u].l);
  preParse(T[u].r);

}

void inParse(int u)
{
  if(u==NIL)
    {
      return;
    }
 
  inParse(T[u].l);
 
  printf(" %d",u);
 
  inParse(T[u].r);
}


void postParse(int u)
{
  if(u==NIL)
    {
      return;
    }

  postParse(T[u].l);
  postParse(T[u].r);
 
  printf(" %d",u);
}



Measured memory_bytes: 2104
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>

using namespace std;



int main() {
	ios::sync_with_stdio(false);

	string past, present;
	cin >> past >> present;

	int ans = 0;

	for (int i = 0; i < 3; ++i) {
		if (past[i] == present[i]) {
			++ans;
		}
	}

	cout << ans;

	return 0;
}

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

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

#ifdef NEAL_DEBUG
#define dbg(...) cerr << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif


int main() {
    ios::sync_with_stdio(false);
#ifndef NEAL_DEBUG
    cin.tie(nullptr);
#endif

    string T;
    cin >> T;

    for (char &ch : T)
        if (ch == '?')
            ch = 'D';

    cout << T << '\n';
}


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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vs = vector<string>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

bool solve(int n, int m, int k) {
	if (n * m == k) {
		return true;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			if (i * (m - j) + j * (n - i) == k) {
				return true;
			}
		}
	}

	return false;
}

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

	int n, m, k;
	cin >> n >> m >> k;

	cout << (solve(n, m, k) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>

int main()
{
    int N;
    std::cin >> N;
    
    constexpr int MAX = 4010;
    std::vector<int> a(N), s(MAX);
    for (int i = 0; i < N; i++) {
        std::string in;
        std::cin >> in;
        a[i] = (stoi(in.substr(0, 1)) * 1000 + stoi(in.substr(2)));
        s[a[i]] += 1;
    }
    
    for (int i = 1; i < MAX; i++) {
        s[i] += s[i - 1];
    }
    
    for (int i = 0; i < N; i++) {
        int d = s[a[i]] - (a[i] > 0 ? s[a[i] - 1] : 0);
        int w = (a[i] > 0 ? s[a[i] - 1] : 0);
        std::cout << (d - 1) + w * 3 << std::endl;
    }        
    return 0;
}

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

double a, b, h, m, t, ans;

int main(){
    cin >> a >> b >> h >> m;
    h = 30*h + 0.5*m;
    m = 6*m;
    t = min(abs(h - m), 360-abs(h - m));
    ans = sqrt(a*a + b*b - 2*a*b*cos(t*M_PI/180.0));
    cout << fixed << setprecision(15) << ans;
}

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

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

    int output;
    output = N % 1000;

    if (output != 0) {
        output = 1000 - output;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3596
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
//#include<cstdio>
//#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

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


	//int N = getint(), W = getint();
	int N, W;
	cin >> N >> W;

	ll dp[100001] = {};
	rep(i, N) {
		int w;
		int v;
		cin >> w >> v;
		for (int j = W; j >= w; j--) {
			dp[j] = max(dp[j], dp[j - w] + v);
		}
	}

	printf("%lld", dp[W]);

	Would you please return 0;
}

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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first

const int MAX_N=2*10e5+5;
int n,mx=-1;
string s[MAX_N];
map<string,int> mp;
set<string> ss;

int main(){
  cin >> n;
  for(int i=0;i<n;++i){
    cin >> s[i];
    ++mp[s[i]];
    mx=max(mx,mp[s[i]]);
  }
  for(int i=0;i<n;++i){
    if(mp[s[i]]==mx){
        ss.insert(s[i]);
    }
  }
  for(auto it:ss){
    cout << it << endl;
  }
  return 0;
}


Measured memory_bytes: 50176
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long int ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000;

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

Measured memory_bytes: 256
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18);
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
//-std=gnu++17
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 main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n=s.size();
    s+=s;
    rep(i,n){
        if(t==s.substr(i,n))return yes,0;
    }
    no;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n,a,b;
    cin >> n >> a >> b;
    int cnt = 0;
    int bcnt = 0;
    rep(i,n){
        char s;
        cin >> s;
        if(s == 'c')cout << "No" << endl;
        else if(cnt >= a+b)cout << "No" << endl;
        else if(s == 'b' && bcnt >= b)cout << "No" << endl;
        else if(s == 'a'){
            cout << "Yes" << endl;
            cnt++;
        }
        else if(s == 'b'){
            cout << "Yes" << endl;
            cnt++;
            bcnt++;
        }
    }


    return 0;
}

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

#define int long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define dbg(x) cerr << #x << ": " << x << endl;
#define dbg2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define dbg3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define dbgB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

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<typename T>
void print1(T begin, T end) {
  while (begin != end) {
    cout << (*begin) << " ";
    *begin++;
  }
  cout << endl;
}

template<typename T>
void print2(T Array, int height, int width) {
  for (int i = 0; i < height; i++) {
    for (int j = 0; j < width; j++) {
      cout << " " << Array[i][j];
    }
    cout << endl;
  }
}

void print() { std::cerr << endl; }
template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cerr << head << " ";
  print(std::forward<Tail>(tail)...);
}

template<class T>
void Add(T &a, const T &b, const T &mod=1000000007) {
  int val = ((a % mod) + (b % mod)) % mod;
  if (val < 0) { val += mod; }
  a = val;
}

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

const int INF = 1e18;

int A, B, Q;
vector<int> s, t;

int solve(int x) {
  // Right, Leftはxより右にあるか左にあるか
  // abs取るのは、値が見つからなかったときの処理をINFで統一させたいから(-INFあるとめんどい）
  int sRight = *lower_bound(all(s), x);
  int sLeft = *(upper_bound(all(s), x) - 1);
  int tRight = *lower_bound(all(t), x);
  int tLeft = *(upper_bound(all(t), x) - 1);

  int ret = INF;

  // (s, t) -> x -> (t, s)
  chmin(ret, abs(x - min(sLeft, tLeft)));

  // s -> x -> t {
  chmin(ret, abs(min(x - sLeft, tRight - x) + abs(sLeft - tRight)));

  // t -> x -> s {
  chmin(ret, abs(min(x - tLeft, sRight - x) + abs(sRight - tLeft)));

  // x -> (s, t) -> (t, s)
  chmin(ret, abs(max(sRight - x, tRight- x)));

  return ret;
}

signed main() {
  cin >> A >> B >> Q;
  s.resize(A);
  t.resize(B);
  for (int i = 0; i < A; i++) {
    cin >> s[i];
  }
  for (int i = 0; i < B; i++) {
    cin >> t[i];
  }

  // 番兵を設置すると値が見つからなかったときの処理が楽になる
  s.push_back(INF);
  s.push_back(-INF);
  t.push_back(INF);
  t.push_back(-INF);
  sort(all(t));
  sort(all(s));

  while (Q--) {
    int x;
    cin >> x;
    int ans = solve(x);
    dbg(ans)
    cout << solve(x) << endl;
  }

  return 0;
}

Measured memory_bytes: 2912
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;


int main(){
  int n;
  cin >> n;
  vvll edge(n, vll(0));
  for(int i = 0; i < n; i++){
    ll u, k;
    cin >> u >> k;
    u--;
    for(int j = 0; j < k; j++){
      ll v;
      cin >> v;
      v--;
      edge.at(u).push_back(v);
    }
  }

  vector<Pll> d(n);
  for(int i = 0; i < n; i++){
    d.at(i).first = INF;
    d.at(i).second = (ll)i;
  }
  d.at(0).first = 0;

  priority_queue<P, vector<P>, greater<P>> que;
  que.push(make_pair(0,0));

  while(!que.empty()){
    P p = que.top(); que.pop();

    if(d.at(p.second).first < p.first) continue;

    for(int i = 0; i < edge.at(p.second).size(); i++){
      ll v = edge.at(p.second).at(i);
      if(d.at(v).first > p.first + 1LL){
        d.at(v).first = p.first + 1LL;
        que.push(d.at(v));
      }  
    }
  }

  for(int i = 0; i < n; i++){
    if(i == 0) continue;
    if(d.at(i).first == INF) d.at(i).first = -1;
  }

  for(int i = 0; i < n; i++){
    cout << i+1 << ' ' << d.at(i).first << endl;
  }

}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<ll,ll> pint;

const int INF=1000100010;
const int MAX_N=102;
struct edge{
    int to,cap,rev;
    edge(int to,int cap,int rev):
    to(to),cap(cap),rev(rev){}
    };

vector<edge> g[MAX_N];
int dist[MAX_N];
int used[MAX_N];
void add_edge(int src,int dst,int cap){
    g[src].pb(edge(dst,cap,g[dst].size()));
    g[dst].pb(edge(src,cap,g[src].size()-1));
}
void bfs(int s){
    memset(dist,-1,sizeof(dist));
    queue<int> q;
    dist[s]=0;
    q.push(s);
    while(!q.empty()){
        int v=q.front();q.pop();
        rep(i,g[v].size()){
            edge &e=g[v][i];
            if(e.cap>0&&dist[e.to]<0){
                dist[e.to]=dist[v]+1;
                q.push(e.to);
            }
        }
    }
}
int dfs(int v,int t,int f){
    if(v==t) return f;
    used[v]=true;
    rep(i,g[v].size()){
        edge &e=g[v][i];
        if(e.cap>0&&dist[v]<dist[e.to]){
            int d=dfs(e.to,t,min(f,e.cap));
            if(d>0){
                e.cap-=d;
                g[e.to][e.rev].cap+=d;
                return d;
            }
        }
    }
    return 0;
}
int max_flow(int s,int t){
    int flow=0;
    while(1){
        bfs(s);
        if(dist[t]<0) return flow;
        memset(used,0,sizeof(used));
        int f;
        while((f=dfs(s,t,INF))>0){
            flow+=f;
        }
    }
}
vector<edge> g2[MAX_N];
int main(){
    int k,n,m;
    int a,b,c;
    cin>>k>>n>>m;
    bool flag=false;
    rep(i,m){
        cin>>a>>b>>c;
        add_edge(a,b,c);
        if(a==0&&b<=k||b==0&&a<=k) flag=true;
    }
    if(flag){
        cout<<"overfuro"<<endl;
        return 0;
    }
    int s=n+k+1;
    FOR(i,1,k+1){
        add_edge(s,i,INF);
    }
    int cur=max_flow(s,0);
    //cout<<cur<<endl;
    int mx=0;
    rep(i,s+1) g2[i]=g[i];
    rep(i,s+1){
        rep(j,g[i].size()){
            if(g[i][j].cap==0){
                g[i][j].cap=INF;
                mx=max(mx,max_flow(s,0));
                rep(l,s+1) g[l]=g2[l];
            }
        }
    }
    if(cur+mx>=INF) cout<<"overfuro"<<endl;
    else cout<<cur+mx<<endl;
    return 0;
}


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

int memo[100001];

int mod(int a)
{
    if(a<0)
     return (-1*a);
      return a;
}
int fun(int x,int k,int* arr)
{
    if(x==1)
     return 0;
    if(memo[x]!=-1)
     return memo[x];
     int minn=1e9;
    for(int i=1;i<=k;i++)
    {
        if((x-i)<1)
         break;
        minn=min(minn,fun(x-i,k,arr)+mod(arr[x]-arr[x-i]));
    }
    return memo[x]=minn;
}
int main()
{
    memset(memo,-1,sizeof(memo));
    int n,k;
    cin>>n>>k;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    {
        cin>>arr[i];
    }
    cout<<fun(n,k,arr)<<"\n";
    return 0;
}

Measured memory_bytes: 8832
//package beg_165;
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner a = new Scanner(System.in);
		long b = a.nextLong();
		
		int i=0;
		long total=100;
		while (total<b) {
			long c =  total/100;
			total=total+c;
			//System.out.println(total);
			i++;
		}
		System.out.println(i);
	}

}


Measured memory_bytes: 35864
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
int f[1<<15],p[1<<15];
int main()
{
	const int mod=1e9+7;
	int i,k,s,t,o,n=gi(),m=gi(),e[15]={},w;
	const int all=(1<<n)-1;
	while (m--) k=gi()-1,e[k]|=1<<(gi()-1);
	for (i=p[0]=1;i<1<<n;i++) p[i]=(p[i^(i&-i)]<<1)%mod;
	
	f[0]=1;
	for (s=0;s<1<<n;s++)
		if (f[s])
			for (o=s^all,t=o;t;(--t)&=o) {
				if ((t&3)==3) continue;
				w=f[s];
				for (i=0;i<n;i++)
					if (s>>i&1) {
						if (!(e[i]&t)) break;
						w=1LL*w*(p[e[i]&t]-1)%mod;
					} else if (t>>i&1) w=1LL*w*p[e[i]&s]%mod;
				if (i==n) (f[s|t]+=w)%=mod;
			}
	printf("%d\n",f[all]);
	return 0;
}


Measured memory_bytes: 512