akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
using namespace std;
//typedef tree<pair<int,int>, null_type, less<pair<int,int>>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=1e6+4;
 
int main()
{	
	ll a; double b; cin>>a>>b;

	ll bb=round(b*100);

	//cout<<bb<<endl;

	a*=bb; a/=100;

	cout<<a;

    return 0;
}

Measured memory_bytes: 3664
#include <iostream>
#include <vector>
#include <cmath>

int main() {
        int n;
        std::cin >> n;
        std::vector<int> base2;

        auto it = 0;
        while (n) {
                base2.push_back(std::abs(n) % 2);
                n -= base2.back();
                n /= -2;
                ++it;
        }

        if (it == 0) {
                std::cout << 0 << std::endl;
        }
        else {
                while (it > 0) {
                        --it;
                        std::cout << base2[it];
                }
                std::cout << std::endl;
        }

        return 0;
}

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

main(){
	int n; cin>>n;
	int a[n];
	for(auto &it : a) cin>>it;
	
	int cnt = 0;
	for(int i=0; i<n-2; i++){
		for(int j=i+1; j<n-1; j++){
			for(int k=j+1; k<n; k++){
				if(a[i]!=a[j] && a[j]!=a[k] && a[k]!=a[i] && a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[k]+a[i]>a[j]) cnt++;
			}
		}
	}
	cout<<cnt;
}

Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
#include <climits>
#include <utility>
#include <deque>
#include <list>
#include <stdexcept>
using namespace std;

int main()
{
	cout << fixed << setprecision(6);
	int n;
	cin >> n;

	int a;
	pair<int, int> max1 = make_pair(-1, 0), max2 = make_pair(-1, 0);
	for (int i = 0; i < n; ++i) {
		cin >> a;
		if (max1.second < a) {
			max2 = max1;
			max1 = make_pair(i, a);
		}
		else if (max2.second < a) {
			max2 = make_pair(i, a);
		}
	}

	for (int i = 0; i < n; ++i) {
		cout << (max1.first == i ? max2.second : max1.second) << endl;
	}
	

	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>


#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;

lli mod197 = 1000000007LL;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

lli g(lli a) {

	lli result = 0;

	for (lli i = 40; i >= 1; i--) {
		lli t = (1LL << i);

		if (a & t) {
			if (((a & (t - 1)) + 1) % 2) {
				result |= t;
			}
		}
	}

	if (((a & 3) == 2) || ((a & 3) == 1)) {
		result |= 1;
	}

	return result;
}

lli y(lli a) {
	lli result = 0;

	for (lli i = 0; i <= a; i++) {
		result = result xor i;
	}

	return result;
}

lli w(lli a, lli b) {
	lli result = 0;

	for (lli i = a; i <= b; i++) {
		result = result xor i;
	}

	return result;
}

int main(void) {

	lli A, B;
	cin >> A >> B;

	if (A == 0) {
		COUT(g(B));
	}
	else {
		COUT((g(A - 1) xor g(B)));
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=505;
ll n,m;
char s[N][N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>m;
    for(ll i=0;i<n;i++)cin>>s[i];
    for(ll i=0;i<n;i++){
        cout<<"#";
        for(ll j=1;j<m-1;j++){
            if(i%2==0 || s[i][j]=='#')cout<<'#';
            else cout<<'.';
        }
        cout<<".\n";
    }
    cout<<"\n";
    for(ll i=0;i<n;i++){
        cout<<".";
        for(ll j=1;j<m-1;j++){
            if(i%2==1 || s[i][j]=='#')cout<<'#';
            else cout<<'.';
        }
        cout<<"#\n";
    }
}



Measured memory_bytes: 1024
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
template <class T>
using ordered_set = __gnu_pbds::tree<T, __gnu_pbds::null_type, less<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;
template <class T>
using ordered_multiset = __gnu_pbds::tree<T, __gnu_pbds::null_type, less_equal<T>, __gnu_pbds::rb_tree_tag, __gnu_pbds::tree_order_statistics_node_update>;

#define PI atan2(0, -1)
#define EPS 1e-9
#define INF 5e18
#define MOD 1000000007

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

int N, M;
long long fac [2000010], inv [2000010];

long long modInverse(long long a, long long m){ //Assume That a and m are relatively prime to each other
    long long m0 = m, t, q;
    long long x0 = 0ll, x1 = 1ll;
    while(a > 1ll){
        // q is quotient
        q = a/m;
        t = m;
        // m is remainder now, process same as
        // Euclid's Algorithm
        m = a%m, a = t;
        t = x0;
        x0 = x1-q*x0;
        x1 = t;
    }
    // Make x1 positive
    if(x1 < 0) x1 += m0;
    return x1;
}

long long perm(int x, int y){
    return (fac[x]*inv[x-y])%MOD;
}

long long choose(int x, int y){
    return (perm(x, y)*inv[y])%MOD;
}

int main(){
    //freopen("sort.in", "r", stdin); freopen("sort.out", "w", stdout);
    ios_base::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(10);
    cin >> N >> M; fac[0] = inv[0] = 1;
    for(int i = 1; i <= 500000; i++){
        fac[i] = (fac[i-1]*i)%MOD;
        inv[i] = modInverse(fac[i], MOD);
    }
    long long sum = 0;
    for(int i = 0; i <= N; i++){
        long long add = (perm(M-i, N-i)*choose(N, i))%MOD;
        if(i&1) sum = (sum-add+MOD)%MOD;
        else sum = (sum+add)%MOD;
        //cout << sum << endl;
    }
    sum = (sum*perm(M, N))%MOD;
    cout << sum << '\n';
    return 0;
}

/******************************
Kateba ii dake no hanashi darou
Success is only a victory away
- No Game No Life Opening
******************************/

Measured memory_bytes: 11388
#include<stdio.h>
int main()
{
	int a;
	int b;
    int c;
   while(~scanf("%d%d%d",&a,&b,&c)){
		if(a==5&&b==5&&c==7||a==5&&b==7&&c==5||a==7&&b==5&&c==5){
			printf("YES\n");
		}
		else{
			printf("NO\n");
		} 
	}
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A,B,C;
    cin >> A >> B >> C;
    int ans;
    ans = max({A,B,C}) - min({A,B,C});
    cout << ans << endl;
}


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

int main() {
	string s;
	cin >> s;
	int k;
	cin >> k;
	for (int i = 0; i < s.size(); i++) {
		int x = 'z' - s[i];
		if (k > x && s[i] != 'a') {
			k -= x + 1;
			s[i] = 'a';
		}
	}
	k %= 26;
	s.back() += k;
	if (s.back() > 'z') {
		s.back() = s.back() - 'z' - 1 + 'a';
	}
	cout << s << endl;
	return 0;
}

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

using namespace std;

const int MOD = 2019;
const int MAX = 2e5+10;

inline int add(int a, int b) {
	return (a + b) % MOD;
}

inline int mul(int a, int b) {
	return (a * b) % MOD;
}

int dp[2][MOD];

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

	string s;
	cin >> s;
	int n = s.length();
	int cur = 0;
	long long ans = 0;
	dp[cur][s[0]-'0'] = 1;
	for(int i = 0; i < n-1; i++) {
		dp[(cur+1)%2][s[i+1]-'0'] = 1;
		for(int j = 0; j < 2019; j++) {
			int val = add(mul(j, 10), s[i+1]-'0');
			dp[(cur+1)%2][val] += dp[cur][j];
		}
		for(int i = 0; i < MOD; i++) dp[cur][i] = 0;
		cur = (cur+1)%2;
		ans += dp[cur][0];
	}
	cout << ans << '\n';
	// for(int i = 0; i < n; i++) {
	// 	for(int j = 0; j < 20; j++) {
	// 		cout << dp[i][j] << ' ';
	// 	}
	// 	cout << '\n';
	// }
	// long long ans = 0;
	// for(int i = 0; i < n; i++) ans += dp[i][0];
	// cout << ans << '\n';

	return 0;
}


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

namespace AtCoder.ABC113.D
{
    class Program
    {
        static void Main()
        {
            var sc = new Scanner();
            var N = sc.Nextint();
            var M = sc.Nextint();
            var C = sc.Nextint();
            var B = sc.Arrayint(M);
            var A = Enumerable.Range(0, N)
                .Select(_ => sc.Arrayint(M))
                .ToArray();

            var correctCount = A.Select(Ai => Enumerable.Range(0, M).Aggregate(0,
                    (sum, j) => sum += Ai[j] * B[j],
                    sum => sum + C))
                .Where(val => val > 0)
                .Count();
            Console.WriteLine(correctCount);
        }
    }

    class Scanner
    {
        string[] s;
        long i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string Next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return Next();
            i = 0;
            return s[i++];
        }

        public int Nextint()
        {
            return int.Parse(Next());
        }
        public int[] Arrayint(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = Nextint() + add;
            }
            return Array;
        }

        public long NextLong()
        {
            return long.Parse(Next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextLong() + add;
            }
            return Array;
        }

        public double NextDouble()
        {
            return double.Parse(Next());
        }

        public double[] ArrayDouble(long N, double add = 0)
        {
            double[] Array = new double[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDouble() + add;
            }
            return Array;
        }

        public decimal NextDecimal()
        {
            return decimal.Parse(Next());
        }

        public decimal[] ArrayDecimal(long N, decimal add = 0)
        {
            decimal[] Array = new decimal[N];
            for (long i = 0; i < N; i++)
            {
                Array[i] = NextDecimal();
            }
            return Array;
        }
    }
}


Measured memory_bytes: 13524
#pragma warning (disable:4996)
#include"bits/stdc++.h"
#include<cassert>
#define int long long
#define MRE assert(0);
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
const long long mod = 1000000007;
const long long inf = 1e17;
typedef pair<int, int> P;
struct edge {
	int to, id;
};
int a[105][105];
int match[205]; bool used[205];
vector<int>ans[205],ans2[205];
vector<int>G1[105][105];
vector<int>G[205];

void add_edge(int u, int v) {
	G[u].push_back(v);
	G[v].push_back(u);
}

bool dfs(int v) {
	used[v] = true;
	for (int i : G[v]) {
		int u = i, w = match[u];
		if (w < 0 || !used[w] && dfs(w)) {
			match[v] = u; match[u] = v; return true;
		}
	}
	return false;
}

void matching(int n) {
	rep(i, n)G[i].clear();
	rep(i, n) {
		rep(j, n) {
			if (G1[i][j].size())add_edge(i, n+j);
		}
	}
	memset(match, -1, sizeof(match));
	rep(i, n) {
		if (match[i] < 0) {
			memset(used, 0, sizeof(used));
			dfs(i);
		}
	}
	rep(i, n) {
		ans[i].push_back(G1[i][match[i] - n][0]);
		G1[i][match[i] - n].erase(G1[i][match[i] - n].begin());
	}
}

signed main() {
	int n, m; cin >> n >> m;

	rep(i, n) {
		rep(j, m) {
			cin >> a[i][j];
			G1[i][(a[i][j]-1)/m].push_back(a[i][j]);
		}
	}

	rep(i,m)matching(n);
	rep(i, n) {
		rep(j, m) {
			if (j)cout << ' '; cout << ans[i][j];
		}cout << endl;
	}
	rep(j, m) {
		vector<int>s;
		rep(i, n)s.push_back(ans[i][j]);
		sort(s.begin(), s.end());
		rep(i, n)ans2[i].push_back(s[i]);
	}
	rep(i, n) {
		rep(j, m) {
			if (j)cout << ' '; cout << ans2[i][j];
		}cout << endl;
	}
}

Measured memory_bytes: 6912
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    ll n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i,n) cin >> p[i];
    rep(i,n) p[i]++;
    double ans = 0.0, tmp = 0.0;
    queue<double> q;
    for (int i = 0; i < n; i++) {
        tmp += p[i];
        q.push(p[i]);
        if (q.size() > k) {
            tmp -= q.front();
            q.pop();
        }
        if (q.size() == k) {
            ans = max(ans, tmp);
        }
    }
    printf("%.10f\n", ans/2.0);
    return 0;
}


Measured memory_bytes: 5424
#include <stdio.h>
#define MAX 100
int main(){
    int n;
    int ans=0;
    char s[MAX];
    scanf("%d %s", &n, s);
    for (int i = 0; i <n ; ++i) {
        if(s[i]=='A' && s[i+1]=='B'&& s[i+2]=='C'){
            ans++;
        }
    }
    printf("%d", ans);
}

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N;
int x[220], y[220];
int tw[220];
int mod = 998244353;

signed main() {
    tw[0] = 1;
    for (int i = 1; i < 220; i++) {
        tw[i] = tw[i - 1] * 2 % mod;
    }
    cin >> N;
    for (int i = 0; i < N; i++)cin >> x[i] >> y[i];

    int ans = (tw[N] - N - 1 + mod) % mod;

    for (int i = 0; i < N; i++) {
        for (int j = i + 1; j < N; j++) {
            int cur = 0;
            for (int k = j + 1; k < N; k++) {
                if ((x[i] - x[j]) * (y[i] - y[k]) == (x[i] - x[k]) * (y[i] - y[j])) cur++;
            }
            (ans += mod - tw[cur]) %= mod;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<string>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<math.h>
#include<utility>
using namespace std;


int main(){
    string a, b;
    cin >> a >> b;

    string numstr = a+b;
    int num = stoi(numstr);

    for(int i=1;i<=100100;i++){
        if(num == i*i) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include<math.h>
int main()
{
    int a,b,c,d,x;
    scanf("%d%d%d",&x,&a,&b);
    c=abs(x-a);
    d=abs(x-b);
    if(c<d)
    printf("A");
    else
    printf("B");
	}

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

using namespace std;

typedef long long  ll;

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

    int m, min_n, max_n;

    while (cin >> m >> min_n >> max_n, m) {
        vector<int> p(m);
        for (int i = 0; i < m; ++i)
            cin >> p[i];
        sort(p.begin(), p.end(), greater<int>());

        int n = 0, gap = 0;
        for (int i = min_n; i <= max_n; ++i) {
            int tmp_gap = p[i - 1] - p[i];
            if (gap <= tmp_gap) {
                gap = tmp_gap;
                n = i;
            }
        }

        cout << n << endl;
    }

    return 0;
}

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

using namespace std;

int h, w;

bool isIn(int x, int y){
    return 0 <= x && x < h && 0 <= y && y < w;
}

int main(){
    int t;
    cin >> t;
    for(int q=0; q < t; q++){
        if(q) cout << endl;
        string s = "^><v";
        int direction, mx, my;
        int dx[4] = {1, 0, 0, -1};
        int dy[4] = {0, 1, -1, 0};
        cin >> h >> w;
        string field[h];
        for(int i=0; i < h; i++){
            cin >> field[i];
            for(int j=0; j < field[i].size(); j++) if(s.find(field[i][j]) != -1){mx = i; my = j, direction = s.find(field[i][j]); field[i][j] = '.';}
        }
        int n; cin >> n;
        string c; cin >> c;

        for(int i=0; i < c.size(); i++){
            if(c[i] == 'U'){
                direction = 0;
                if(isIn(mx-1, my) && field[mx-1][my] == '.')mx--;
            }
            if(c[i] == 'D'){
                direction = 3;
                if(isIn(mx+1, my) && field[mx+1][my] == '.')mx++;
            }
            if(c[i] == 'L'){
                direction = 2;
                if(isIn(mx, my-1) && field[mx][my-1] == '.')my--;
            }
            if(c[i] == 'R'){
                direction = 1;
                if(isIn(mx, my+1) && field[mx][my+1] == '.')my++;
            }
            if(c[i] == 'S'){
                for(int j=1; ; j++){
                    if(!isIn(mx-j*dx[direction], my+j*dy[direction])) break;
                    if(field[mx-j*dx[direction]][my+j*dy[direction]] == '#') break;
                    if(field[mx-j*dx[direction]][my+j*dy[direction]] == '*'){
                        field[mx-j*dx[direction]][my+j*dy[direction]] = '.';
                        break;
                    }
                }
            }
        }
        field[mx][my] = s[direction];
        for(int i=0; i< h; i++) cout << field[i] << endl;
    }
}

Measured memory_bytes: 1212
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound, __gcd, count, find, next_permutation
#include <bitset>    // bitset
#include <deque>     // deque
#include <iomanip>   // setprecsion
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <utility>   // pair, make_pair
#include <vector>    // vector

#include <cassert> // assert
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>  // abs, sin, cos, tan
#include <ctime> // clock

// __builtin_popcountll

using namespace std;
using Graph = vector<vector<int>>;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

void Main()
{
  str s; cin >> s;
  vc flag = {'A', 'C', 'T', 'G'};
  ll ans = 0;
  ll tmp = 0;
  for(ll i = 0;i < s.size();i++)
  {
    bool can = false;
    rep(k, 4) if(s[i] == flag[k]) can = true;
    if(can) tmp++;
    else tmp = 0;
    ans = max(ans, tmp);
  }
  cout << ans << endl;
  return;
}

//前処理
int main()
{
  int ti = clock();
  srand((unsigned)time(NULL));
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  //cout << setfill('0') << internal << setw(4); //0埋め４桁
  Main();
  //cout << 1.0 * (clock() - ti) / CLOCKS_PER_SEC << endl; // 実行時間計測
  return 0;
}

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

typedef long long ll;

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

    int n; cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;i++) cin >> a[i];
    int ans = 10000000;
    for(int i=-100;i<=100;i++){
        int cost = 0;
        for(int j=0;j<n;j++){
            cost += (a[j]-i)*(a[j]-i);
        }
        ans = min(ans,cost);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    N = int(input())
    X = list(map(int, input().split()))
    sorted_X = sorted(X)
    overall_med = (sorted_X[N//2 - 1] + sorted_X[N//2]) // 2
    for x in X:
        if x <= overall_med:
            print(sorted_X[N//2])
        else:
            print(sorted_X[N//2 - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 104924
//Littleboy123 Template 1.7
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

//pragmas

// #pragma comment(linker, "/stack:200000000")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")


typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef pair<ll, ll> pll;
typedef unsigned long long int ull;
typedef long double ld;
typedef unsigned long long ull;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define TC(n) cout << "Case #" << (n) << ": "
#define DEBUG(x) cout << "DEBUG " << #x << ' ' << x << '\n';
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>

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

void infile(){
    freopen("output.out", "r", stdin);
}

void outfile(){
    freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
    if(b == 0)
        return 1;
    if(b == 1)
        return a;
    ll tmp = modex(a, b/2, mod);
    tmp = (tmp * tmp) % mod;
    if(b & 1)
        tmp = (tmp * a) % mod;
    return tmp;
}

//End of template

ll n, k;
ll arr[200005];

bool bisa(ll mid){
    ll cnt = 0;
    FOR(i, 0, n){
        if(arr[i] <= mid)
            continue;
        cnt += (arr[i]-1LL)/mid;
    }
    return cnt <= k;
}

ll binser(ll l, ll r){
    if(l == r){
        if(bisa(l)){
            return l;
        }
        return -1;
    }
    ll mid = l + (r-l)/2LL;
    if(bisa(mid)){
        return binser(l, mid);
    }
    return binser(mid+1, r);
}

int main(){
    init();

    cin >> n >> k;
    FOR(i, 0, n){
        cin >> arr[i];
    }
    ll ans = binser(1, 1000000000LL);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5176
//Volume0-0046
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		//declare
		float h,
		      max = 0,
		      min = Float.MAX_VALUE;

        //input
        Scanner sc = new Scanner(System.in);
        while(sc.hasNext()){
        	h = sc.nextFloat();

        	//calculate
        	if(max < h){max = h;}
        	if(min > h){min = h;}
        }

        //output
        System.out.println(max - min);
	}
}

Measured memory_bytes: 18700
N = int(input())
h = list(map(int, input().split()))

ans = 0
while True:
    state = 0
    for i in range(N):
        if state == 0 and h[i] > 0:
            state += 1
            h[i] -= 1
            ans += 1
        elif state == 1 and h[i] > 0:
            h[i] -= 1
        elif state == 1 and h[i] == 0:
            state = 2
            break
    if state == 0:
        break
print(ans)


Measured memory_bytes: 39664
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	int n; cin >> n;
	long long T; cin >> T;
	long long sum = 0;
	long long p; cin >> p;
	for (int i = 1; i < n; i++){
		long long t; cin >> t;
		sum += min(t - p, T);
		p = t;
	}
	cout << sum+T << endl;
}

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

int main() {
  
  long long N;
  cin >> N;
  string S;
  cin >> S;
  long long sum = 0;
  long long r_num=0;
  long long g_num=0;
  long long b_num=0;
  for(long long i=0; i<N; i++){
    if(S[i]=='R'){
      r_num++;
    }else if(S[i]=='G'){
      g_num++;
    }else{
      b_num++;
    }
  }
  sum = r_num*g_num*b_num;
  
  for(long long i=0; i<N-2; i++){
    for(long long j=i+1; j<N-1; j++){
      if(2*j-i<N){
        if(S.at(i)!=S.at(j) && S.at(i)!=S.at(2*j-i) && S.at(j)!=S.at(2*j-i)){
          sum--;
        }
      }
    }
  }

  cout << sum << endl;
}


Measured memory_bytes: 3640
S = input()
T = input()

R = [-1] * 26
R2 = [-1] * 26

alpha2num = lambda c: ord(c) - ord('a')

flag = 1

for i in range(len(S)):
  si = alpha2num(S[i])
  ti = alpha2num(T[i])
  
  
  if(R[si] < 0):
    R[si] = ti
    
  if(R2[ti] < 0):
    R2[ti] = si
    
  if(R[si] >= 0):
    if(R[si] != ti):
      flag = 0
      print('No')
      break
      
  if(R2[ti] >= 0):
    if(R2[ti] != si):
      flag = 0
      print('No')
      break
    
if(flag == 1):
  print('Yes')

Measured memory_bytes: 3632
#include<iostream>
#include <cstring>
#include<stdio.h>
#include <cctype>

using namespace std;

char s1[11],s2[11],s3[11];
int a,b,c,j,k,loop,i,temp = 0;

int main()
{
    cin>>s1;
    cin>>s2;
    cin>>s3;

    a = strlen(s1);
    b = strlen(s2);
    c = strlen(s3);

    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)
    {
            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])
            {
                printf("YES\n");
            }
            else
            {
                printf("NO\n");
            }
    }
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int A[3];
    scanf("%d %d %d", &A[0], &A[1], &A[2]);
    int sum = A[0] + A[1] + A[2];
    
    if (sum >= 22) 
    {
        printf("bust");
    } else 
    {
        printf("win");
    }

    return 0;
}

Measured memory_bytes: 1732
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <list>
#include <ctime>
#include <sstream>
#include <queue>
#include <stack>
#include <bitset>
#include <numeric>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
#define FOR(x, b, e) for(int x=(b); x<=(e); ++x)
#define FORD(x, b, e) for(int x=((int)(b))-1; x>=(e); --x)
#define REP(x, n) for(int x=0; x<(n); ++x)
#define ALL(c) c.begin(),c.end()
#define SIZE(x) ((int)((x).size()))
#define PB push_back
#define ST first
#define ND second
#define mp(x,y) make_pair(x,y)
#define DEBUG 1
#define debug(x) {if (DEBUG)cerr <<#x <<" = " <<x <<endl; }
#define debugv(x) {if (DEBUG) {cerr <<#x <<" = "; FOREACH(it, (x)) cerr <<*it <<", "; cout <<endl; }}
typedef short int sint;

const int N = 50;
const int GR = 50;
int n,m;
vector<pair<int,pair<int, int>>> za[N];
int s;
int c[N], d[N];
ll dist[N];
ll di[N][N * GR];

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> s;
	REP(i, m) {
		int u,v,a,b;
		cin >> u >> v >> a >> b;
		--u, --v;
		za[u].PB(mp(v, mp(a, b)));
		za[v].PB(mp(u, mp(a, b)));
	}
	REP(i, n) cin >> c[i] >> d[i];
	if (s >= n * GR) {
		// we dont ever need to wait 
		REP(i, n) dist[i] = -1;
		dist[0] = 0;
		priority_queue<pair<ll, int>> Q;
		Q.push(mp(0, 0));
		while (!Q.empty()) {
			auto p = Q.top(); Q.pop();
			if (dist[p.ND] != -p.ST) {
				continue;
			}
			for (auto edge : za[p.ND]) {
				int v = edge.ST;
				ll val = edge.ND.ND;
				if (dist[v] == -1 || dist[v] > dist[p.ND] + val) {
					dist[v] = dist[p.ND] + val;
					Q.push(mp(-dist[v], v));
				}
			}
		}
		FOR(i, 1, n - 1) {
			cout << dist[i] << endl;
		}
	} else {
		// s < n * 50
		REP(i, n) REP(j, n * GR) {
			di[i][j] = -1;
		}
		di[0][s] = 0;
		priority_queue<pair<ll, pii>> Q;
		Q.push(mp(0, mp(0, s)));
		while (!Q.empty()) {
			auto przod = Q.top(); Q.pop();
			ll czas = -przod.ST;
			int vert = przod.ND.ST;
			int scount = przod.ND.ND;
			if (di[vert][scount] != czas) {
				continue;
			}
			// printf("  at vert %d, at time: %lld with %d coins\n", vert, czas, scount);
			for (auto edge : za[vert]) {
				int v = edge.ST;
				int cost = edge.ND.ST;
				int zajmuje = edge.ND.ND;
				if (cost > scount) {
					continue;
				}
				if (di[v][scount - cost] == -1 || di[v][scount - cost] > czas + zajmuje) {
					di[v][scount - cost] = czas + zajmuje;
					Q.push(mp(-di[v][scount - cost], mp(v, scount - cost)));
				}
			}
			if (scount + c[vert] < n * GR && (di[vert][scount + c[vert]] == -1 || di[vert][scount + c[vert]] > czas + d[vert])) {
				di[vert][scount + c[vert]] = czas + d[vert];
				Q.push(mp(-di[vert][scount + c[vert]], mp(vert, scount + c[vert])));
			}
		}
		FOR(i, 1, n - 1) {
			ll res = di[i][0];
			FOR(j, 1, n * GR - 1) {
				if (di[i][j] != -1) {
					if (res == -1 || res > di[i][j]) {
						res = di[i][j];
					}
				}
			}
			cout << res << endl;
		}
	}
}

Measured memory_bytes: 6288
#include<bits/stdc++.h> 
using namespace std; 
#define ll long long int 
string multiply(string num1, string num2) 
{ 
    int len1 = num1.size(); 
    int len2 = num2.size(); 
    if (len1 == 0 || len2 == 0) 
    return "0"; 
  
    // will keep the result number in vector 
    // in reverse order 
    vector<int> result(len1 + len2, 0); 
  
    // Below two indexes are used to find positions 
    // in result.  
    int i_n1 = 0;  
    int i_n2 = 0;  
      
    // Go from right to left in num1 
    for (int i=len1-1; i>=0; i--) 
    { 
        int carry = 0; 
        int n1 = num1[i] - '0'; 
  
        // To shift position to left after every 
        // multiplication of a digit in num2 
        i_n2 = 0;  
          
        // Go from right to left in num2              
        for (int j=len2-1; j>=0; j--) 
        { 
            // Take current digit of second number 
            int n2 = num2[j] - '0'; 
  
            // Multiply with current digit of first number 
            // and add result to previously stored result 
            // at current position.  
            int sum = n1*n2 + result[i_n1 + i_n2] + carry; 
  
            // Carry for next iteration 
            carry = sum/10; 
  
            // Store result 
            result[i_n1 + i_n2] = sum % 10; 
  
            i_n2++; 
        } 
  
        // store carry in next cell 
        if (carry > 0) 
            result[i_n1 + i_n2] += carry; 
  
        // To shift position to left after every 
        // multiplication of a digit in num1. 
        i_n1++; 
    } 
  
    // ignore '0's from the right 
    int i = result.size() - 1; 
    while (i>=0 && result[i] == 0) 
    i--; 
  
    // If all were '0's - means either both or 
    // one of num1 or num2 were '0' 
    if (i == -1) 
    return "0"; 
  
    // generate the result string 
    string s = ""; 
      
    while (i >= 0) 
        s += std::to_string(result[i--]); 
  
    return s; 
} 
  
// Driver code 
int main() 
{ 
    string str1; 
    string str2,s;
    cin>>str1>>s;
    for(ll i=0;i<s.length();i++)
    {if(s[i]=='.'){continue;}
	str2.push_back(s[i]);}
	string ans=multiply(str1, str2);
	if(ans.length()<=2)cout<<0;
	else
	for(ll i=0;i<ans.length()-2;i++)
	cout<<ans[i];
    return 0; 
} 

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y, ans = -1;
    cin >> x >> y;
    for(int i = 10; i <= 1009; i++) {
        if((i*8)/100 == x && i/10 == y) {
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    string s,ans="No";
    cin>>s;
    if(s[0]-'7'==0 || s[1]-'7'==0||s[2]-'7'==0)ans="Yes";
    cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <iostream>

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

    if (N == 1) {
        std::cout << "Hello World" << std::endl;
        return 0;
    }

    int A, B;
    std::cin >> A >> B;

    std::cout << (A+B) << std::endl;
    return 0;
}

Measured memory_bytes: 384
class Main{public static void main(String[]z)throws Exception{String s;for(byte[]b=new byte[73];System.in.read(b)>-1;)for(char i=64;i++<71;)if((s=new String(b)).lastIndexOf(49)-s.indexOf(49)==new int[]{10,27,3,17,11,19,9}[i-65])System.out.println(i);}}

Measured memory_bytes: 10000
import sys
n, m = map(int, input().split())
image = []
temp = []
match = False
for i in range(n):
  image.append(input())
for i in range(m):
  temp.append(input())
for i in range(n):
  for j in range(n - m + 1):
    if (temp[0] == image[i][j : j + m]):
      match = True
      for k in range(1, m):
        if (i + k >= n):
          match = False
          break
        elif (temp[k] != image[i + k][j : j + m]):
          match = False
          break
      if (match == True):
        print('Yes')
        sys.exit()
print('No')

Measured memory_bytes: 3064
S=input()
max_count=0
for i in range(len(S)):
    if S[i] in ['A','C','G','T']:
        j=0
        while S[i+j] in ['A','C','G','T']:
            max_count=max(max_count,j+1)
            j+=1
            if i+j==len(S):
                break
print(max_count)


Measured memory_bytes: 2940
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

n = onem()

a,b = m()

p = l()
c = 0
co = 0
coo = 0

for i in range(n):
    if p[i] <= a:
        c += 1
    elif p[i] <= b:
        co += 1
    else:
        coo += 1
print(min(c,co,coo))











Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll,ll> P;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
ll c,d,e,f,p,t,ans=0;
 
 
ll n,m,r;
vector<P> gragh[30000];
vl used(30000,0);
priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
 
void input(void){
    cin>>n>>m;
    rep(i,m){
        cin>>c>>d>>e;
        gragh[c].push_back(make_pair(d,e));
        gragh[d].push_back(make_pair(c,e));
    }
}
 
ll solve(void){
    used[1]=1;
    rep(i,gragh[1].size()){
        pq.emplace(gragh[1][i].second,gragh[1][i].first);
    }
    while(!pq.empty()){
        c=pq.top().first;
        d=pq.top().second;
        pq.pop();
        if(used[d]==0){
        	used[d]=1;
            ans+=c;
            //cout<<d<<" "<<ans<<endl;
            rep(i,gragh[d].size()){
                pq.emplace(gragh[d][i].second,gragh[d][i].first);
            }
        }
    }

    return ans;
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    cout<<solve()<<endl;
}


Measured memory_bytes: 13144
#include<iostream>
#include<vector>
using namespace std;
int main(){
    int n;
    cin>>n;
    const long long int mod=1e9+7;
    vector<int>v(n);
    for(int i=0;i<n;i++)
    {
        cin>>v[i];
    }
    unsigned long long int suffix_sum=0;
    unsigned long long int result=0;
    unsigned long long int answer=0;
    for(int j=n-1;j>=0;j--){

        answer=v[j];
        suffix_sum%=mod;
        answer*=suffix_sum;
        suffix_sum+=v[j];
        answer%=mod;
        result+=answer;
    }
    cout<<result%mod;
}

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

typedef long long i64;

#define MAX_S_LEN 100
char S[MAX_S_LEN + 10];

int main()
{
    cin >> S;
    int len = strlen(S);
    int hug = 0;
    for (int i = 0; i < len / 2; ++i){
      if (S[i] != S[len - 1 - i])
        ++hug;
    }
    cout << hug << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

#define mp(a,b) make_pair(a, b)
#define __builtin_popcount __builtin_popcountll

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 (a>b) { a=b; return 1; } return 0; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
    os<<"["; for(const auto &it : t) {if(it!=t.begin()) os<<","; os<<it;} os<<"]"; return os;
}
template<class T> ostream& operator<<(ostream &os, const set<T> &t) {
    os<<"{"; for(const auto &it : t) {if(it!=t.begin()) os<<","; os<<it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const map<S, T> &t) {
    os<<"{"; for(const auto &it : t) {if(it!=t.begin()) os<<","; os<<it;} os<<"}"; return os;
}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class S, class T> pair<S,T> operator+(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first+t.first, s.second+t.second);}
template<class S, class T> pair<S,T> operator-(const pair<S,T> &s, const pair<S,T> &t){ return pair<S,T>(s.first-t.first, s.second-t.second);}

const int INF = 1<<28;
const double EPS = 1e-8;
const int MOD = 1000000007;


int T, n, m;

ll solve() {
    cin >> n;
    map<ll, int> mp;
    for (int i = 0; i < n; ++i) {
        ll x;
        cin >> x;
        mp[x] ++;
    }
    ll p = -1;
    for(auto it = mp.rbegin(); it != mp.rend(); ++ it) {
        ll l = it->first;
        int c = it->second;
        if (c > 1) {
            if(p != -1){
                return p * l;
            }
            if(c >= 4) {
                return l * l;
            }
            p = l;
        }
    }
    return 0;
}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cmath>
using namespace std;

typedef long long ll;

int main(){
  ll a;
  while(cin >> a, a){
    string ans = ""; 
    ll m, n;
    while(a != 0){
      n = a / (-10);
      m = a % (-10);
      //cout << "n = " << n << ", m = " << m << endl;
      if(m < 0) m += 10, n += 1;
      ans += m + '0';
      a = n;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1200
import java.util.*

fun main(args: Array<String>) {
	val sc = Scanner(System.`in`)
	val n = sc.nextInt()

	val t = Array(n) { 0 }
	for (i in 0 until n) {
		t[i] = sc.nextInt()
	}

	val m = sc.nextInt()
	val ans = Array(m) { 0 }

	for (j in 0 until m) {
		val p = sc.nextInt()
		val x = sc.nextInt()

		ans[j] = t.sum() - t[p - 1] + x
	}
	println(ans.joinToString("\n"))
}


Measured memory_bytes: 36088
# include <bits/stdc++.h>
using namespace std;
# define lli long long int
# define MOD 1000000007

vector<int> g[100001];
lli dp[100001][2];

lli findAll(int x, int col, int par){

    if(dp[x][col] != -1){
        return dp[x][col];
    }

    bool leaf = true;

    lli k1 = 1, k2 = 1;
    for(auto nbr : g[x]){
        if(nbr != par){
            leaf = false;
            k1 *= findAll(nbr, 0, x);
            k1 %= MOD;
            if(col == 0){
                k2 *= findAll(nbr, 1, x);
                k2 %= MOD;
            }
        }
    }

    if(leaf){
        return 2 - col;
    }

    lli ans;
    if(col == 0)
        ans = k1 + k2;
    else
        ans = k1;
    ans %= MOD;
    return dp[x][col] = ans;

}

void solve(){
    int n;
    cin >> n;
    memset(dp, -1, sizeof(dp));
    for(int i = 0; i < n - 1; i++){
        int x, y;
        cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << findAll(1, 0, -1) << "\n";
}


int main(){
    solve();
}


Measured memory_bytes: 17596
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        String S = sc.next();
        
        Pattern p = Pattern.compile("^[0-9]{" + A + "}-[0-9]{" + B + "}$");
        Matcher m = p.matcher(S);
        boolean result = m.matches();
        
        if(result == true){
             System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

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

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [a, b] <- getIntList
  print $ lcm a b

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;
 
signed main(){
    while(1){
        int n;
        cin >> n;
        if(n == 0) break;
        int ans = 0;
        int now = 0;
        int pre = 0;
        rep(i, 0, n){
            string s;
            cin >> s;
            if(s == "lu") now += 2;
            if(s == "ru") now += 1;
            if(s == "ld") now -= 2;
            if(s == "rd") now -= 1;
            if(now == 3 && pre == 0){
                ans++;
                pre = 1;
            }else if(now == 0 && pre == 1){
                ans++;
                pre = 0;
            }
        }
        cout << ans << endl;
    }
}

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

int main()
{
        int m, f, r;

        while(cin>>m>>f>>r){
                if( m==-1 && f==-1 && r==-1 ){break;}
                else if( m==-1 || f==-1 ){ cout<<"F"<<endl; }
                else if( m+f >= 80 )            { cout<<"A"<<endl; }
                else if( m+f >= 65 && m+f < 80 ){ cout<<"B"<<endl; }
                else if( m+f >= 50 && m+f < 65 ){ cout<<"C"<<endl; }
                else if( m+f >= 30 && m+f < 50 ){
                        if( r >= 50 ){ cout<<"C"<<endl; }
                        else{ cout<<"D"<<endl; }}
                else{ cout <<"F"<<endl; }
        }
                                
        return 0;
}

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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e,f;cin >> a >> b >> c >> d >> e >> f;
	int ansa=0,ansb=0,x,y;
	double con=0,carcon=0;
	rep(i,31){
		rep(j,31){
			x=100*a*i+100*b*j;
			if(x==0) continue;
			if(x>f) continue;
			for(int k=0;c*k<=x/100*e;++k){
				for(int l=0;c*k+d*l<=x/100*e;++l){
					y=c*k+d*l;
					if(x+y>f) continue;
					carcon=100*100*y/(x+y);
					if(carcon>con){
						con=carcon;
						ansa=x+y;
						ansb=y;
					}
				}
			}
		}
	}
	if(ansa==0 && ansb==0) cout << 100*a << " " << 0 << endl;
	else cout << ansa << " " << ansb << endl;
}

Measured memory_bytes: 384
require "prime"

n = gets.chomp.to_i
arr = gets.chomp.split.map(&:to_i)

#ダブってるか
hash = {}
arr.each do |a|
	hash[a] = hash.has_key?(a) ? false : true
end
arr = arr.uniq.sort
pri = Array.new(arr[arr.length-1]+1, true)
#p arr
cnt = 0
arr.each do |a|
	#a = arr[i]
	aa = a
	cnt += 1 if pri[a] && hash[a]
	# puts "-----a=#{a} ok------" if pri[a] && hash[a]
	# print "#{i} "
	# ma = []
	# pri.each_with_index{|a, i| ma << i if a}
	# p ma

	next if !pri[a]
	while aa < pri.length 
		pri[aa] = false
		aa += a
	end
end

puts cnt

Measured memory_bytes: 48288
N = int(input())
a = [0]+list(map(int,input().split()))
b = [0]*(N+1)
b[-1] = a[-1]
for i in range(N-1,0,-1):
    hoge = a[i]
    for j in range(i,N+1,i):
        hoge += b[j]
    b[i] = hoge%2
print(sum(b))
for i in range(N+1):
    if b[i] == 1:
        print(i,end = " ")

Measured memory_bytes: 7076
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val s = n.toString().map { it.toString().toInt() }.sum()
    if (n % s == 0) {
        println("Yes")
    } else {
        println("No")
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 29348