akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define LL long long
typedef pair<int, int> pii;

template< typename T > inline void read(T &x)
{
    static char _c;
    static bool _f;

    x = 0;
    _f = 0;
    _c = getchar();

    while(_c < '0' || '9' < _c) {if(_c == '-') _f = true; _c = getchar();}
    while('0' <= _c && _c <= '9') {x = (x << 1) + (x << 3) + (_c & 15); _c = getchar();}
    if(_f) x = -x;
}

template < typename T > inline void Min(T &x, T y) {if(y < x) x = y;}
template < typename T > inline void Max(T &x, T y) {if(x < y) x = y;}


#define lowbit(x) ((x) & -(x))
#define lson l,mid,id<<1
#define rson mid+1,r,id<<1|1
#define ls id<<1
#define rs id<<1|1
#define MID(l,r) ((l)+(((r)-(l))>>1))
#define fi first
#define se second
#define mk make_pair
#define pb push_back

const int INF = 0x3f3f3f3f;
const double pi = (double) acos(-1.0);
const double eps = (double) 1e-8;
const int MOD = (int) 1e9 + 7;
//const int MOD = (int) 998244353;
const int maxn = (int) 1e5 + 20;
const int maxm = (int) 1e6 + 20;

inline int sig(double x) {return x < -eps ? -1 : eps < x;}
LL fp(LL a, LL n, LL MOD)
{
    if(n < 0) a = fp(a, MOD - 2, MOD), n = -n;
    LL res = 1; for(; n; n >>= 1, a = a * a % MOD) if(n & 1) res = res * a % MOD; return res;
}

int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

void work()
{
    int n;
    cin >>n;
    cout <<a[n - 1] <<endl;
}

int main(int argc, char **argv)
{
#ifdef yukihana0416
freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
#endif // yukihana0416
//    get_prime();
    int tc = 1;
//    read(tc);
    for(int ca = 1; ca <= tc; ca++)
    {
//        printf("Case #%d: ", ca);
        work();
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
int main() {
	int n,a,b,ap,bp;
	while(scanf("%d",&n),n) {
		ap=bp=0;
		for(int i=0;i<n;i++) {
			scanf("%d %d",&a,&b);
			if(a>b)ap+=a+b;
			else if(a<b)bp+=a+b;
			else ap+=a,bp+=b;
		}
		printf("%d %d\n",ap,bp);
	}
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
#define eb emplace_back
#define emp emplace
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 100010;

int dp[N], h[N];

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

	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> h[i];

	dp[1] = 0;
	dp[2] = abs(h[2]-h[1]);
	for (int i = 3; i <= n; i++) {
		dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout << dp[n] << endl;

	return 0;
}



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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()

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

    int N, X, Y; cin >> N >> X >> Y; --X; --Y;

    vector<int> ans(N);
    REP(i, N) FOR(j, i+1, N) {
        int dist = j - i;
        dist = min(dist, abs(i - X) + 1 + abs(j - Y));
        dist = min(dist, abs(i - Y) + 1 + abs(j - X));
        ++ans[dist];
    }
    FOR(i, 1, N) cout << ans[i] << '\n';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<string> v;
    v.push_back("");
    v.push_back(".,!? ");
    v.push_back("abc");
    v.push_back("def");
    v.push_back("ghi");
    v.push_back("jkl");
    v.push_back("mno");
    v.push_back("pqrs");
    v.push_back("tuv");
    v.push_back("wxyz");
    string s;
    int n;
    scanf("%d",&n);
    for(int k=0;k<n;k++) {
        cin>>s;
        int num=0,cnt=0;
        for(int i=0;i<s.size();i++) {
            if(s[i]=='0') {
                if(num) putchar(v[num][(cnt-1)%v[num].size()]);
                num=cnt=0;
            }else {
                num=s[i]-'0';
                cnt++;
            }
        }
        putchar('\n');
    }
}

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

int main(){
  int n;
  cin >> n;
  int ans = 0;
  int tmp;
  vector<int> tako(n);
  for(int i=0; i<n; i++){
    cin >> tmp;
    tako.at(i) = tmp;
  }
  for(int i=0; i<n; i++){
    for(int j=0; j<n; j++){
      ans += tako.at(i)*tako.at(j);
    }
    ans -= tako.at(i)*tako.at(i);
  }
  cout << ans/2 << endl;
}
    


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))
count_dict = {i:{} for i in range(2)}
#print(count_dict[0])
for i in range(2):
  for j in A[i::2]:
    if j not in count_dict[i]:
      count_dict[i][j] = 1
    else:
      count_dict[i][j] += 1

candidates = [sorted(count_dict[i].items(), key=lambda kv: kv[1], reverse=True)[:2] for i in range(2)]
candidates = [i[1]+j[1] for i in candidates[0] for j in candidates[1] if i[0] != j[0]]
no_move = max(candidates) if candidates != [] else len(A) // 2
print(N-no_move)


Measured memory_bytes: 18292
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

const ll MOD = 998244353;

ll powmod(ll a, ll n){
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

const int MAX = 2002002;
ll 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;
    }
}

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

signed main(){
    COMinit();
    ll n,m,k;
    cin >> n >> m >> k;
    if(n==1){
        cout<< m <<endl;
        return 0;
    }
    if(m==1){
        if(n-1==k) cout << 1 << endl;
        else cout << 0 << endl;
        return 0;
    }
    ll ans=0;
    for(ll i=0;i<=k;i++){
        if(n-1<i) break;
        ll res=(m*powmod(m-1,n-1-i))%MOD;
        res*=COM(n-1,i); res%=MOD;
        ans+=res; ans%=MOD;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 50564
// https://atcoder.jp/contests/abc085/tasks/abc085_d
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, h;
    cin >> n >> h;
    vector<pii> v(n);
    REP(i, n) cin >> v[i].first >> v[i].second;
    sort(ALL(v));

    // 最大の攻撃力
    int maxv = v[n - 1].first;
    sort(ALL(v), [](const pii &a, const pii &b) {
        // 降順ソート
        return a.second > b.second;
    }); //比較関数をラムダ式で作る
    auto up = upper_bound(ALL(v), maxv, [](const int n, const pii &a) {
        // nより大きい最初の要素を探す
        return n > a.second;
    });
    // nより大きい要素は邪魔なので消す
    v.erase(up, v.end());

    int cnt = 0, pos = 0;
    while (h > 0) {
        if (pos >= (int)v.size()) {
            cnt += ceil((double)h / maxv);
            break;
        } else if (maxv > v[pos].second) {
            h -= maxv;
        } else {
            h -= v[pos].second;
            pos++;
        }
        cnt++;
    }
    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <bitset>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (ll i = a; i < n; i++)
#define repm(i, a, n) for (ll i = a; i >= n; i--)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vs vector<string>
#define vii vector<vector<int>>
#define vll vector<ll>
#define vllll vector<vector<ll>>
#define vd vector<double>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define reverse_v(a) reverse(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    (c) ? (cout << "Yes" << endl) : (cout << "No" << endl);
}

void Print(bool c)
{
    (c) ? (cout << "YES" << endl) : (cout << "NO" << endl);
}

//最小公倍数
template <typename T>
T gcd(T a, T b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

//最大公約数
template <typename T>
T lcm(T a, T b)
{
    return a * b / gcd(a, b);
}
//セカンドキー->ファーストキーの順ソート
bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

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

int eve(int x)
{
    if (x % 400 == 0)
        return 1;
    if (x % 100 == 0)
        return 0;
    if (x % 4 == 0)
        return 1;
    return 0;
}

int main(void)
{
    ll n;
    string s;
    cin >> n >> s;

    map<char, ll> mp;
    for (auto c : s)
        mp[c]++;
    ll ans = 1;
    for (auto x : mp)
    {
        ans *= x.second + 1;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstring>
using namespace std;
int main(){
	char a[10086000],b[10086000];
	int sum;
	cin>>a;
	sum=strlen(a);
	sum-=1;
	for(int i=0;a[i]!='\0';i++){
		if(a[i]=='b') b[sum]='d';
		if(a[i]=='d') b[sum]='b';
		if(a[i]=='p') b[sum]='q';
		if(a[i]=='q') b[sum]='p';
		sum--;
	}
	if(strcmp(a,b)==false){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
} 

Measured memory_bytes: 4352
#include<iostream>

using namespace std;

int main(){

    int n;
    bool isPossible = false;

    scanf("%d", &n);
    for(int i = 1; i < 10; i++){
        for(int j = 1; j < 10; j++){
            if((i * j) == n){
                isPossible = true;
                break;
            }
        }
        if(isPossible){
            break;
        }
    }
    if(isPossible){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>
#include <algorithm>
#include <tuple>
#include <set>
#include <functional>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;

    vector<int> sumsA(s.size() + 1, 0);
    vector<int> sumsC(s.size() + 1, 0);

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'A' && s[i+1] == 'C') {
            sumsA[i+1]++;
            sumsC[i+2]++;
        }
    }

    for (int i = 0; i < s.size(); i++) {
        sumsA[i + 1] += sumsA[i];
        sumsC[i + 1] += sumsC[i];
    }


    for (int i = 0; i < q; i++) {
        int l, r;
        cin >> l >> r;
        cout << sumsC[r] - sumsA[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1792
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define MOD 998244353
#define REP(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288
double dot(complex<double> a, complex<double> b) {
	return a.real() * b.real() + a.imag() * b.imag();
}
double gyaku_dot(complex<double> a, complex<double> b) {
	return a.real() * b.imag() - a.imag() * b.real();
}
double leng(complex<double> a) {
	return sqrt(a.real()*a.real() + a.imag()*a.imag());
}
double angles(complex<double> a, complex<double> b) {
	double cosine = dot(a, b) / (leng(a) * leng(b));
	double sine = gyaku_dot(a, b) / (leng(a) * leng(b));
	double kaku = acos(cosine);
	if (sine <= 0) {
		kaku = 2 * Ma_PI - kaku;
	}
	return kaku;
}
vector<int> convex_hull(vector<complex<double>> a) {
	vector<int> ans;
	double now_minnest = a[0].real();
	int now_itr = 0;
	REP(i, a.size()) {
		if (now_minnest > a[i].real()) {
			now_minnest = a[i].real();
			now_itr = i;
		}
	}
	ans.push_back(now_itr);
	complex<double> ba(0, 1);
	while (true) {
		int now_go = 0;
		double now_min = 0;
		int starter = ans[ans.size() - 1];
		for (int i = 0; i < a.size(); ++i) {
			if (i != starter) {
				double goa = angles(ba, a[i] - a[starter]);
				if (goa > now_min) {
					now_min = goa;
					now_go = i;
				}
			}
		}
		if (now_go == ans[0]) break;
		ans.push_back(now_go);
		ba = complex<double>(a[now_go] - a[starter]);
	}
	return ans;
}
long long size_of_beaf[2000] = {};
long long size_of_all[2000] = {};
long long calc(long long a, long long b) {
	if (a == 0) {
		assert(b == 0 || b == 1);
		if (b == 0) return 0;
		return 1;
	}
	if (b <= 1) return 0;
	b--;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b);
	}
	long long ans = size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	ans++;
	if (b <= size_of_all[a - 1]) {
		return calc(a - 1, b) + size_of_beaf[a-1] + 1LL;
	}
	ans += size_of_beaf[a - 1];
	b -= size_of_all[a - 1];
	b--;
	assert(b == 0);
	return ans;
}
int main(){
#define int long long
	long long n, x;
	cin >> n >> x;
	size_of_beaf[0] = 1;
	size_of_all[0] = 1;
	for (int i = 0; i < n+1; ++i) {
		size_of_beaf[i + 1] = size_of_beaf[i] * 2 + 1;
		size_of_all[i + 1] = size_of_all[i] * 2 + 3;
	}
	cout << calc(n, x) << endl;
	return 0;
}

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

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

  ll A; cin >> A;
  ll B; cin >> B;
  ll M; cin >> M;

  vector<ll> AA(A);
  ll sa = 1e9;
  for (ll i = 0; i < A; i++) {
    cin >> AA[i];
    sa = min(sa, AA[i]);
  }

  vector<ll> BB(B);
  ll sb = 1e9;
  for (ll i = 0; i < B; i++) {
    cin >> BB[i];
    sb = min(sb, BB[i]);
  }

  ll ans = sa + sb;
  for (ll i = 0; i < M; i++) {
    ll x, y, c;
    cin >> x >> y >> c;
    ans = min(ans, AA[x - 1] + BB[y - 1] - c);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
int main(void){
	int D,N;
	scanf("%d",&D);scanf("%d",&N);
	
	int a[100];
	int i;
	for(i=0;i<100;i++){
		a[i] = i+1;
	}
	if(D==0){
		if(N==100){
			printf("%d",101);
		}else{
			printf("%d",a[N-1]);
		}
	}else if(D==1){
		if(N==100)	printf("10100");
		else	printf("%d",a[N-1]*100);
	}else{
		if(N==100)	printf("1010000");
		else	printf("%d",a[N-1]*10000);
	}
	
	return 0;}

Measured memory_bytes: 128
import           Control.Monad
import           Data.Maybe
import           Data.List
import qualified Data.ByteString.Char8         as BS

tuplify2 (x : y : _) = (x, y)
tuplify2 _           = undefined

--Input functions with ByteString
readInt = fst . fromJust . BS.readInteger
readIntTuple = tuplify2 . map readInt . BS.words
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntNList n = map readIntList <$> replicateM (fromIntegral n) BS.getLine
getIntMatrix = map readIntList . BS.lines <$> BS.getContents
getIntTuple = readIntTuple <$> BS.getLine
getIntNTuples n = map readIntTuple <$> replicateM (fromIntegral n) BS.getLine
getIntTuples = map readIntTuple . BS.lines <$> BS.getContents

main = do
    (a, b) <- getIntTuple
    print $ solve a b


solve a b = maximum [a + b, a - b, a * b]


Measured memory_bytes: 380
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int[] A = new int[N];
        int[] B = new int[N];

        for(int i=0; i<N; i++){
            int tmp = scanner.nextInt();
            A[i] = tmp;
            B[i] = tmp;
        }

        Arrays.sort(A);

        int first = A[N-1];
        int second = A[N-2];

        for(int i=0; i<N; i++){
            if(B[i] == first){
                System.out.println(second);
            }else{
                System.out.println(first);
            }
        }
    }
}


Measured memory_bytes: 88604
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>
#include <climits>
#include <deque>
#include <bitset>
#include <cassert>
#include <ctime>
using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
const int dy[]={-1,0,1,0},dx[]={0,1,0,-1};
// adjust problem by problem
const double EPS=1e-8;
const double PI=acos(-1.0);
#ifdef __GNUC__
int popcount(int n){return __builtin_popcount(n);}
int popcount(ll n){return __builtin_popcountll(n);}
#endif
#ifndef __GNUC__
template<class T> int popcount(T n){int cnt=0;while(n){if(n%2)cnt++;n/=2;}return cnt;}
#endif
template<class T>int SIZE(T a){return a.size();}
template<class T>string IntToString(T num){string res;stringstream ss;ss<<num;return ss.str();}
template<class T>T StringToInt(string str){T res=0;for(int i=0;i<SIZE(str);i++)res=(res*10+str[i]-'0');return res;}
template<class T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<class T>T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> void PrintSeq(T &a,int sz){for(int i=0;i<sz;i++){cout<<a[i];if(sz==i+1)cout<<endl;else cout<<' ';}}
bool EQ(double a,double b){return abs(a-b)<EPS;}
void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}
vector<string> split(string str,char del){
  vector<string> res;
  for(int i=0,s=0;i<SIZE(str);i++){
    if(str[i]==del){if(i-s!=0)res.push_back(str.substr(s,i-s));s=i+1;}
    else if(i==SIZE(str)-1){res.push_back(str.substr(s));}
  }
  return res;
}

int ins[10001];
int outs[10001];

int main(){

  int N,M;
  cin>>N>>M;
  for(int i=0;i<N;i++)
    cin>>ins[i]>>outs[i];
  int now=M;
  int ans=M;
  bool isErr=false;
  for(int i=0;i<N;i++){
    now+=ins[i];
    now-=outs[i];
    ans=max(ans,now);
    if(now<0)isErr=true;
  }
  if(isErr)cout<<0<<endl;
  else cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
int main(){
  float n;
  float c=0;
  float prob;
  cin>>n;
  int i;
  for(i=1;i<=n;i++){
    if(i%2!=0)
      c++;
  }
  prob=(float)c/(float)n;
  printf("%0.9f",prob);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 1000000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
void init(){
  cin.tie(0);
  ios::sync_with_stdio(false);
}




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;


vector<int> b;
bool binary_graph(UG es){
  b.resize(es.size());
  b[0]=1;
  queue<int> q;
  q.push(0);
  while(!q.empty()){
    int x=q.front();
    q.pop();
    for(auto e:es[x]){
      if(b[e]==0){
        b[e]=-1*b[x];
        q.push(e);
      }
      else if(b[e]*b[x]==1)
        return false;
    }
  }
  return true;
}

int main(){
  ll n,m;
  cin>>n>>m;
  UG es(n);
  rep(i,m){
    int a,b;
    cin>>a>>b;
    a--;
    b--;
    es[a].PB(b);
    es[b].PB(a);
  }

  if(binary_graph(es)){
    ll x=count(all(b),1);
    ll y=count(all(b),-1);
    cout<<x*y-m<<endl;
  }
  else
    cout<<n*(n-1)/2-m<<endl;
}


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

#define int long long
#define endl '\n'

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r" , stdin);
    freopen("output.txt", "w", stdout);
    #endif
    
    int n; cin>>n;
    cout<< (n+999)/1000*1000 - n;
}

Measured memory_bytes: 3608
#define _CRT_SECURE_NO_WARNINGS // #pragma warning(disable:4996)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <sstream>
#include <cmath>
#include <set>
#include <map>
using namespace std; 

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define mp(a,b) make_pair(a,b)
#define all(a) a.begin(),a.end()
#define len(x) ((int)(x).size())
#define tmax(a,b,c) max((a),max((b),(c)))
#define tmin(a,b,c) min((a),min((b),(c)))
#define debug(x) cerr << #x << " is " << x << endl;

typedef pair<int, int> Pii;
typedef vector<int> Vi;
typedef vector<vector<int> > VVi;
typedef long long ll;
const int inf = 2e9;
const ll ll_inf = 1e17;
const int mod = 1e9 + 7;
const long double eps = 1e-10;

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

	const int x = 195;
	const int mx = 200;

	rep(i,0,n) {
		int y, m, d, sum = 0;
		cin >> y >> m >> d;

		if (y==1000 && m==1 && d==1) {
			cout << 0 << endl;
			continue;
		}

		// y+1, 1m, 1d
		if (y % 3) { // noramal
			if (m % 2) { // dai
				sum += 21 - d;
				d = 1;
				m = m % 10 + 1;
			}
			else { // syou
				sum += 20 - d;
				d = 1;
				m = m % 10 + 1;
			}

			if (m > 1) {
				while (m < 11) {
					if (m % 2) {
						sum += 20;
						m++;
					}
					else {
						sum += 19;
						m++;
					}
				}
			}
			m = 1;
			y++;
		}
		else { // all dai
			sum += 21 - d;
			m = m % 10 + 1;
			d = 1;
			if (m > 1) {
				sum += (11 - m) * 20;
				m = 1;
			}
			y++;
		}
		//debug(sum);
		if (y==1000 && m==1 && d==1) {
			cout << sum << endl;
			continue;
		}

		int l = 1000 - y;
		sum += l * x;
		sum += (l+2)/3 * 5;
		cout << sum << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <stack>
using namespace std;
static const int N=100;
static const int WHITE=0;
static const int GRAY=1;
static const int BLACK=2;

//??¶????????°
int n;
//?????\??????
int M[N][N];
//??°?????¶???????¢????
int color[N];
//??\??¶????????°??¶???
int d[N];
//??\??¶???????????¶???
int f[N];
//??¶???
int tt;
//???????????????????????????????????????
//?????¨?????????????????¨????????\??????????????????
int nt[N];

//????????????????????????u?????????v
int next(int u){
    for(int v=nt[u];v<n;v++){
        nt[u]=v+1;
        if(M[u][v]&&color[v]==WHITE)
            return v;
    }
    return -1;
}

//??¨????????°?????±?????????????´¢
void dfs_visit(int r){
    for(int i=0;i<n;i++)
        nt[i]=0;

    stack<int> S;
    S.push(r);
    color[r]=GRAY;
    //?????°??¶???
    d[r]=++tt;

    while(!S.empty()){
        int u=S.top();
        int v=next(u);
        if(v!=-1){
            color[v] = GRAY;
            d[v] = ++tt;
            S.push(v);
        }
        else{
            //????????????
            S.pop();
            color[u]=BLACK;
            f[u]=++tt;
        }
    }
}

void dfs(){
    //????§????
    for(int i=0;i<n;i++)
        nt[i]=0,color[i]=WHITE;
    tt=0;

    //??\????????????u?????????????????±?????????????´¢
    for(int u=0;u<n;u++)
        if(color[u]==WHITE)
            dfs_visit(u);

    for(int i=0;i<n;i++)
        cout<<i+1<<" "<<d[i]<<" "<<f[i]<<endl;
}

int main(){
    int u,k,v;

    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;

    for(int i=0;i<n;i++){
        cin>>u>>k;u--;
        for(int j=0;j<k;j++){
            cin>>v;v--;
            M[u][v]=1;
        }
    }

    dfs();
}

Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
 
int main(){
 
  string S;
  cin >> S;
 
  int N = (int)S.size();
 
  //求める合計
  long long total = 0;
 
  //1つの式の値
  long long value;
  string smemo;
 
  for( int tmp = 0; tmp < ( 1<<(N-1) ); tmp++){
    
      //初期値
      value = 0;
      smemo = "";
      smemo += S[0];
      for( int i = 0; i < N-1; i++){
         
         if( tmp & (1<<i) ){
            value += stol(smemo);
            smemo = "";
         }
        smemo += S[i+1];
      }
      value += stol(smemo);
      total += value;
  }
 
  cout << total << endl;
  return 0;
 
}

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

int main()
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    int counter = 0;
    string s;

    cin >> s;

    for (char& c : s)
    {
        if (c == '1') counter++;
    }

    cout << counter << endl;


    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

#define MAX_N (1000000000)

int main(void) {
  int64_t S;
  scanf("%ld", &S);

  int64_t x1 = 0;
  int64_t y1 = 0;
  int64_t x2 = MAX_N;
  int64_t y2 = 1;
  int64_t x3 = (MAX_N - (S % MAX_N)) % MAX_N;
  int64_t y3 = (S + x3) / MAX_N;

  printf("%ld %ld %ld %ld %ld %ld\n", x1, y1, x2, y2, x3, y3);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
 
int main(void)
{
    int m,n,a[1001],i,j,sum,max;
      
    while(scanf("%d %d",&n,&m))
	{
        if(m==0&&n==0)
        break;
        for(i=0;i<n;i++)
		{
            scanf("%d",&a[i]);
        }
        max=0;
        for(i=0;i<n;i++)
		{
            for(j=i+1;j<n;j++)
			{
                sum=a[i]+a[j];
                if(sum>max&&sum<=m)
                max=sum;
            }
        }
        if(max==0)
        printf("NONE\n");
        else
        printf("%d\n",max);
    }
    return 0;
}


Measured memory_bytes: 2140
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long a,b,c,d,e=0,f,i,g[100000001],h=100000000000,j,m,n,x=0,k,y=1,y1,y2,y3,y4,y5,y6,y7,y8,y9,y10,y11,y12,y13,y14,y15,y16,y17,y18,y19,y20,y21,y22,y23,y24,y25,x1;
    string s,s2="Yes";
    cin>>a;
    if(a%10==3){
        cout<<"bon";
        return 0;
    }
    if(a%10==2||a%10==4||a%10==5||a%10==7||a%10==9){
        cout<<"hon";
        return 0;
    }
    if(a%10==0||a%10==1||a%10==6||a%10==8){
        cout<<"pon";
        return 0;
    }
}

Measured memory_bytes: 3628
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <map>
#include <set>
#define INF (2000000000)
#define MOD (1000000007)
using namespace std;

typedef vector<int> VI;
typedef vector<int>::iterator VII;
typedef vector<double> VD;
typedef vector<double>::iterator VDI;
typedef pair<int, int> P;


bool ma[20][20][20][20];
int dp[20][20];

int main()
{
	int n;
	scanf("%d", &n);
	for (int ca = 0; ca < n; ca++){
		memset(ma, false, sizeof(ma));
		memset(dp, 0, sizeof(dp));
		
		int gx, gy;
		scanf("%d %d", &gx, &gy);
		gx++; gy++;
		
		int p;
		scanf("%d", &p);
		for (int i = 0; i < p; i++){
			int x1, y1, x2, y2;
			scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
			x1++; y1++; x2++; y2++;
			if (x1 > x2) swap(x1, x2);
			if (y1 > y2) swap(y1, y2);
			
			ma[x1][y1][x2][y2] = true;
		}
		
		dp[1][1] = 1;
		for (int i = 1; i <= gx; i++){
			for (int j = 1; j <= gy; j++){
				if (!ma[i - 1][j][i][j]){
					dp[i][j] += dp[i - 1][j];
				}
				if (!ma[i][j - 1][i][j]){
					dp[i][j] += dp[i][j - 1];
				}
			}
		}
		
		if (dp[gx][gy]){
			printf("%d\n", dp[gx][gy]);
		}
		else {
			puts("Miserable Hokusai!");
		}
	}
	
	return 0;
}

Measured memory_bytes: 1360
import java.util.*;
class Main
{
  public static void main(String args[])
  {
    Scanner sc= new Scanner(System.in);
    int n=sc.nextInt();
    int p=sc.nextInt();
    int ll=n*2;
    int ul=4*n;
    if(p%2!=0)
      System.out.println("No");
    else if(p>=ll && p<=ul)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 35688
#include <stdio.h>
#include <vector>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>
#include <bitset>
#include <map>
#include <set>
#include <tuple>
#include <string.h>
#include <math.h>
#include <random>
#include <functional>
#include <assert.h>
#include <math.h>
#define all(x) (x).begin(), (x).end()
#define xx first
#define yy second

using namespace std;

using i64 = long long int;
using ii = pair<int, int>;
using ii64 = pair<i64, i64>;

int main()
{
	int n;
	scanf("%d", &n);
	vector<int> a(n), b(n);

	for (int i = 0; i < n; i++)
		scanf("%d", &a[i]);

	priority_queue<ii> q;

	for (int i = 0; i < n; i++)
	{
		scanf("%d", &b[i]);
		q.emplace(b[i], i);
	}

	i64 ans = 0;
	while (!q.empty())
	{
		auto top = q.top();
		q.pop();

		if (top.xx == a[top.yy])
			continue;

		int l = b[(top.yy + n - 1) % n];
		int r = b[(top.yy + 1) % n];
		int m = max(l, r);
		int dec = l + r;

		int t = (b[top.yy] - m + 1 + dec - 1) / dec;
		if (l == a[(top.yy + n - 1) % n] && r == a[(top.yy + 1) % n])
			t = (b[top.yy] - a[top.yy] + dec - 1) / dec;

		b[top.yy] -= t * dec;

		if (b[top.yy] < a[top.yy])
		{
			printf("-1\n");
			return 0;
		}

		q.emplace(b[top.yy], top.yy);
		ans += t;
	}

	printf("%lld\n", ans);

	return 0;
}


Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int n, m, a[1000][1000];

int main(){
    cin >> n >> m;
    string ss = "";
    for (int i = 1; i <= m; i++) ss += '.';
    string s;
    vector<string> v;
    for (int i = 1; i <= n; i++){
        cin >> s;
        if (s != ss) v.push_back(s);
    }
    //for (int i = 0; i < v.size(); i++) cout << v[i] << endl;
    for (int i = 0; i < m; i++){
        bool dd = true;
        for (int j = 0; j < v.size(); j++){
            if (v[j][i] == '#') dd = false;
        }
        if (dd){
            for (int j = 0; j < v.size(); j++) v[j][i] = ' ';
        }
    }
    for (int i = 0; i < v.size(); i++){
        for (int j = 0; j < m; j++){
            if (v[i][j] != ' ') cout << v[i][j];
        }
        cout << endl;
    }    
    
}

Measured memory_bytes: 256
N = int(input())
s = ""
while True:
    p = N // (-2)
    q = N % (-2)
    if N < 0 and q != 0:
        p += 1
        q = 1
    if N > 0 and q != 0:
        p += 1
        q = 1

    s += str(q)
    if p == 0:
        break

    N = p

print(s[::-1])




Measured memory_bytes: 3060
public class Main {

  private static void solve() {
    long a = nl();
    String[] s = next().split("\\.");

    long b;
    if (s.length == 1) {
      b = Long.parseLong(s[0]) * 100;
    } else if (s[1].length() == 1) {
      b = Long.parseLong(s[0]) * 100 + Long.parseLong(s[1]) * 10;
    } else {
      b = Long.parseLong(s[0]) * 100 + Long.parseLong(s[1]) * 1;
    }

    long ret = a * b / 100;
    System.out.println(ret);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 36832
fn input_pair<T: std::str::FromStr + Copy> () -> (T, T) {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let arr: Vec<_> = s.trim().split_whitespace().flat_map(str::parse).collect();
    (arr[0], arr[1])
}

fn main() {
    let (k, x) = input_pair::<usize>();
    println!("{}", if k * 500 >= x { "Yes" } else { "No" });
}


Measured memory_bytes: 2056
#include"iostream"
using namespace std;

int main()
{
	int n;
	cin >> n;
	int div = 0;
	int ans = 0;
	for (int j = 1; j < n + 1; j = j + 2)
	{
		for (int i = 1; i < j + 1; i++)
		{
			if (j%i == 0)
			{
				div++;
			}
		}
		if (div == 8)
		{
			ans++;
		}
		div = 0;
	}
	cout << ans << endl;
}
	

Measured memory_bytes: 256
import sys
from collections import *
from heapq import *
from fractions import gcd
import itertools
import math
import numpy as np

sys.setrecursionlimit(10**6)

def InMap(): return list(map(int, input().split(' ')))
def In(): return int(input())
def InS(): return input()


N = In()
S = set(InMap())
print("YES" if N == len(S) else "NO")


Measured memory_bytes: 35112
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    for (auto& a : A) {
        cin >> a;
    }
    vector<ll> cnt(N + 1, 0);
    rep(i, 1, N + 1) {
        ll pos = i - A[i - 1] + 1;
        if (pos <= 0) {
            continue;
        }
        ++cnt[pos];
    }
    ll ans = 0;
    rep(i, 1, N + 1) {
        if (i + A[i - 1] + 1 > N) {
            continue;
        }
        ans += cnt[i + A[i - 1] + 1];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6364
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;
#define mem(a,n) memset(a,n,sizeof(a))
typedef long long ll;
const ll N=205;
const double eps=1e-6;
const int mod=1e9+7;
int MIN,sum;
int c[10][10],a[N][N];
bool vis[N][N];
int dfs(int x,int sum)
{
    if(x == 1) return MIN=sum;
    for(int i=0; i<10; i++)
    {
        if(x!=i&&sum+c[x][i] < MIN)
        {
            vis[x][i]=1;
            dfs(i,sum + c[x][i]);
            vis[x][i]=0;
        }
    }
}
int main()
{
    int h,w;
    while(~scanf("%d%d",&h,&w))
    {
        mem(vis,0);
        for(int i=0; i<10; i++)
            for(int j=0; j<10; j++)
                scanf("%d",&c[i][j]);
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
                scanf("%d",&a[i][j]);
        int ans=0;
        for(int i=0; i<h; i++)
            for(int j=0; j<w; j++)
            {
                if(a[i][j]!=-1&&a[i][j]!=1)
                {
                    MIN=c[a[i][j]][1];
                    dfs(a[i][j],0);
                    int tmp=MIN;
                    ans += tmp;
                }
            }
        printf("%d\n",ans);
    }
    return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);
string s[10] ;
ll n  , m , k ;
ll solve(vector<ll>tmp) {
    ll i , j ;
    string t[10] ;
    for (i = 0 ; i< n; i++) t[i] = s[i] ;
    ll sz = tmp.size() ;
    for (i = 0 ; i<sz ; i++) {
        //   cout << tmp[i] << ' ' ;
        if (tmp[i]<10) {
            for(j = 0 ; j< m ; j++) {
                t[tmp[i]][j] = '.' ;
            }
        }
        else {
            for (j = 0 ; j< n ; j++)
                t[j][tmp[i]-10] = '.' ;
        }
    }
    ll cnt = 0 ;
    for (i = 0 ; i< n; i++) for (j = 0 ; j< m ; j++) if (t[i][j]=='#') cnt++ ;
  // cout << cnt <<  endl ;
    return cnt==k ;
}
int main() {
 //   __


    cin >> n >> m >> k;
    ll i , j ;
    for (i = 0; i< n ; i++) cin >> s[i] ;

    vector<ll>v ;
    ll ans = 0 ;
    for (i = 0 ; i< n; i++) v.pb(i) ;
    for (i  = 0 ; i< m ; i++) v.pb(10+i) ;
    ll sz = v.size() ;
    for (i = 0 ; i< (1<<sz); i++) {
        vector<ll>tmp ;
        for (j = 0 ; j<sz ; j++) {
           if (i & (1<<j)) tmp.pb(v[j]) ;
        }
        ans+=solve(tmp) ;
       // cout << ans << ' ' ;

    }
    cout << ans << endl ;

    return 0 ;
}


Measured memory_bytes: 3628
#include <iostream>

inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}

inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)

  unsigned gap_num = 11, count = 0;
  while(gaps[--gap_num] > n);

  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);

  std::cout << (gap_num+1) << '\n';

  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';

  std::cout << count << '\n';
}

int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}

Measured memory_bytes: 5100
#include <iostream>
#include <vector>
int main(){
    int N;
    std::cin >> N;
    std::vector<int> H(N);
    for(int i = 0; i < N; i++){
        std::cin >> H[i];
    }
    int max = -1;
    for(int i = 0; i < N; i++){
        int cnt = 0;
        for(int j = i; j < N - 1; j++){
            if(H[j+1] <= H [j])cnt++;
            else break;
        }
        if(cnt > 0)
            i += cnt - 1;   
        if(cnt > max) max = cnt;
    }
    std::cout << max << std::endl;
    return 0;
}

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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
#define repp(i, start, to) for (li i = (li)(start); i < ((li)(to)); i++)


string a = "ATCG";

inline bool ok(char c) {
	rep(i, 4) {
		if (c == a[i])return true;
	}
	return false;
}

int main() {
	string s;
	cin >> s;
	li res = 0;
	li num = 0;
	for (auto c : s) {
		if (ok(c)) {
			num++;
		} else {
			num = 0;
		}
		res = max(res, num);
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a,b,c,x,i,j,k,cnt=0;
    scanf("%d%d%d%d",&a,&b,&c,&x);
    for(i=0;i<=a;i++){
        for(j=0;j<=b;j++){
            for(k=0;k<=c;k++){
                if(i*500+j*100+k*50==x) cnt++;
            }
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
a=list(map(int,input().split()))
a.sort()
A=a[0]
B=a[1]
C=a[2]
cnt=0
while A<B:
    A+=2
    cnt+=1
if A!=B:
    B+=1
    C+=1
    cnt+=1
while A<C:
    A+=1
    cnt+=1
print(cnt)


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

int main(){
    int n, q, t; cin >> n >> q;
    string name;
    queue<pair<string, int> > Q;

    for (int i=0; i < n; i++){
        cin >> name >> t;
        Q.push(make_pair(name, t));
    }

    pair<string, int> u;
    int alltime=0;

    while( !Q.empty() ){
        u=Q.front();
        t=u.second;
        Q.pop();
        if( t <= q ){
            alltime+=t;
            cout << u.first << " " << alltime << endl;
        }else{
            alltime+=q;
            u.second-=q;
            Q.push(u);
        }
        

    }

}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long ll;
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;}
typedef pair<int,int> P;


int main(){
    int n; cin >> n;
    vector<int>a(n+1),b(n);
    rep(i,n+1)cin>>a[i];
    rep(i,n)cin>>b[i];
    
    ll sum=0;
    rep(i,n){
        sum+=min(a[i],b[i]);
        b[i]-=a[i];
        if(b[i]>0){
            sum+=min(b[i],a[i+1]);
            a[i+1]-=b[i];
            if(a[i+1]<0)a[i+1]=0;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define debug(x) cerr<<#x<<": "<<x<<endl
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(),x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,0,n) cin>>h[i];
    vector<int> dp(n);
    rep(i,1,n) {
        dp[i] = INT_MAX;
        for(int j=i-1;j>=i-k && j>=0; --j) {
            dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
        }
    }
    cout<<dp[n-1]<<"\n";
}


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

ll N, X, M;

void solve()
{
	set<ll> seen;
	ll cur = X;
	vector<ll> v;
	while((int)v.size()<N){
		if(seen.count(cur)) break;
		seen.insert(cur);
		v.push_back(cur);
		(cur *= cur)%=M;
	}
	ll res = 0;
	if((int)v.size()>=N) res=accumulate(v.begin(),v.end(),0LL);
	else{
		const int n = v.size();
		int idx=0;
		while(v[idx]!=cur) idx++;
		const int L = n-idx;
		for(int i=0;i<idx;++i) res+=v[i];
		N-=idx;
		res += (N/L)*accumulate(v.begin()+idx,v.end(),0LL);
		N%=L;
		int i=idx;
	    while(N>0) res+=v[i++], N--;
	}
	cout<<res<<'\n';
}

int main()
{
	cin >> N >> X >> M;
	solve();
	return 0;
}

Measured memory_bytes: 5992
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数
static FILE *szpFpI;											// 入力

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 人数・対戦場数 - 取得
	int liHCnt, liVCnt;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liHCnt, &liVCnt);

	// 隙間なし
	int liCnt = (liVCnt + 1) / 2;
	int liMax = liCnt * 2;
	for (i = 0; i < liCnt; i++) {
		sprintf(lc1Buf, "%d %d\n", i + 1, liMax - i);
		fOutLine(lc1Buf);
	}

	// 隙間あり
	liCnt = liVCnt - liCnt;
	liMax++;
	int liMax2 = liMax + liCnt * 2;
	for (i = 0; i < liCnt; i++) {
		sprintf(lc1Buf, "%d %d\n", liMax + i, liMax2 - i);
		fOutLine(lc1Buf);
	}

	return 0;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

bool a[10];
int n,x,ans,temp;

int main() {
    scanf("%d",&n);
    while (n--) {
        scanf("%d",&x);
        if (x<400&&!a[1]) a[1]=true,ans++;
        if (x>=400&&x<800&&!a[2]) a[2]=true,ans++;
        if (x>=800&&x<1200&&!a[3]) a[3]=true,ans++;
        if (x>=1200&&x<1600&&!a[4]) a[4]=true,ans++;
        if (x>=1600&&x<2000&&!a[5]) a[5]=true,ans++;
        if (x>=2000&&x<2400&&!a[6]) a[6]=true,ans++;
        if (x>=2400&&x<2800&&!a[7]) a[7]=true,ans++;
        if (x>=2800&&x<3200&&!a[8]) a[8]=true,ans++;
        if (x>=3200) temp++;
    }
    printf("%d %d\n",max(ans,1),ans+temp);
    return 0;
}
/**
 *                    _ooOoo_
 *                   o8888888o
 *                   88" . "88
 *                   (| -_- |)
 *                    O\ = /O
 *                ____/`---'\____
 *              .   ' \\| |// `.
 *               / \\||| : |||// \
 *             / _||||| -:- |||||- \
 *               | | \\\ - /// | |
 *             | \_| ''\---/'' | |
 *              \ .-\__ `-` ___/-. /
 *           ___`. .' /--.--\ `. . __
 *        ."" '< `.___\_<|>_/___.' >'"".
 *       | | : `- \`.;`\ _ /`;.`/ - ` : | |
 *         \ \ `-. \_ __\ /__ _/ .-` / /
 * ======`-.____`-.___\_____/___.-`____.-'======
 *                    `=---='
 *
 * .............................................
 *          佛祖保佑             永无BUG
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s,t;
	cin>>s>>t;
	int pos=-1;
	for(int i=0;i<s.size();i++)
	{
		int j;
		for(j=i;j<i+t.size();j++)
		{
			if(!(s[j]==t[j-i] || s[j]=='?'))
			break;
		}
		if(j==i+t.size())
		pos=i;
	}
	
	if(pos==-1)
	cout<<"UNRESTORABLE";
	else
	{
		for(int i=pos;i<pos+t.size();i++)
		{
			s[i]=t[i-pos];
		}
		for(int i=0;i<s.size();i++)
		{
			if(s[i]=='?')
			s[i]='a';
		}
	cout<<s;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);
  
  int K,siz;
  string S,result="";
  cin >> K;
  cin >> S;
  siz = S.size();
  if(siz<=K){
    result = S;
  } 
  else{
    result = S.erase(K) + "...";
  }
  cout << result << endl;

  return 0;
}

Measured memory_bytes: 3604