akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
map<int, int> Color[3];
map<pii, int> D;
int N, C;
int calc(vector<int> c)
{
    int res = 0;
    for (int i = 0; i < 3; i++)
    {
        for (const auto &val : Color[i])
        {
            res += D[mp(val.first, c[i])] * val.second;
            // cerr << val.first << " " << val.second << " " << c[i] << endl;
        }
        // cerr << "res = " << res << endl;
    }
    // cerr << endl;
    return res;
}
int main()
{
    cin >> N >> C;
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < C; j++)
        {
            int x;
            cin >> x;
            D[mp(i, j)] = x;
        }
    }
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            int idx = (i + j) % 3;
            int x;
            cin >> x;
            x--;
            Color[idx][x]++;
        }
    }
    int result = INF;
    for (int i = 0; i < C; i++)
    {
        for (int j = 0; j < C; j++)
        {
            for (int k = 0; k < C; k++)
            {
                vector<int> c = {i, j, k};
                if (i == j || j == k || i == k)
                {
                    continue;
                }
                result = min(result, calc(c));
            }
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

vector <int> ZAlgorithm(const string& S) {
    int N = S.size();
    vector<int> z(N);
    z[0] = -1;

    int l = 0, r = 0;
    for (int k = 1; k < N; k++) {
        if (k > r) {
            int i = 0;
            while (k + i < N && S[i] == S[k + i]) i++;
            l = k;
            r = k + i - 1;
            z[k] = i;
        } else if (z[k - l] < r - k + 1) {
            z[k] = z[k - l];
        } else if (z[k - l] >= r - k + 1) {
            int i = r - k + 1;
            while (k + i < N && S[i] == S[k + i]) i++;
            l = k;
            r = k + i - 1;
            z[k] = i;
        }
    }

    return z;
}

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

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        vector <int> len = ZAlgorithm(s.substr(i, n - i));
        for (int j = 1; j < len.size(); j++) {
            ans = max(ans, min(j, len[j]));
        }
    }

    cout << ans << "\n";
    return 0;
}

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

using namespace std;

#define endl "\n"

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

	int n, k;
	cin >> n >> k;
	vector<int> A(n);
	for(int &i : A) cin >> i;
	
	vector<bool> dp(k+1);
	
	for(int i= 1; i<= k; i++) {
		for(int j : A) {
			if( i>= j && !dp[i-j]){
				dp[i] = true;
			}	
		}
	}
	dp[k] ? cout << "First" : cout << "Second";
	cout << endl;

    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(c)  c.begin(), c.end()
#define llv vector< ll >
#define mp make_pair
#define endl "\n"
const int N = (int)3e3+10 ;
const int M = (int)1000000007; 

ll dp[N][N]  , a[N] ;
bool mark[N][N] = {} ;
ll check(int be , int en){
    if(mark[be][en])return dp[be][en] ;
    if(en==be+1){
       mark[be][en]=1 ;
       ll d = abs(a[en]-a[be]) ;
       return dp[be][en] = d ;
    }
    mark[be][en]=1 ;
    return dp[be][en] = max(a[be]-check(be+1 , en) , a[en]-check(be , en-1) ) ;
}

int main(){
    // #ifndef ONLINE_JUDGE
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    ll n , i ;
    cin >> n ;
    for(i=0 ; i<n; i++){
        cin >> a[i] ;
    }
    if(n==1)cout << a[0] ;
    else cout << check(0,n-1) ;

    return 0 ;
}

Measured memory_bytes: 78592
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
#define SWAP(a,b) (a+=b,b=a-b,a-=b)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT(' ');
}
int main(void)
{
  int N=IN(),A[N],B[N],j=0,did=-1;
  rep(i,N){A[i]=IN();}rep(i,N){B[i]=IN();}
  rep(i,N)
  {
    if(did!=A[i]){j=0;}
    if(A[i]==B[i])
    {
      for(;j<N;j++){if(A[j]!=A[i]&&B[j]!=A[i]){SWAP(B[i],B[j]);break;}}
      if(A[i]==B[i]){return puts("No"),0;}
    }
    did=A[i];
  }
  puts("Yes");rep(i,N){OUT(B[i]);}return puts(""),0;
}

Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,m,n) for (int i = m; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int x;
  cin >> x;
  ll L = lcm(x, 360);
  ll ans = L / x;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
int main(void) {
	int N;
	int i, d[100], c = 0;
	int m, n, tmp = 0;
	scanf("%d", &N);
	for (i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	for (m = 0; m < N; m++) {
		for (n = m + 1; n < N; n++) {
			if (d[m] > d[n]) {
				tmp = d[m];
				d[m] = d[n];
				d[n] = tmp;
			}
		}
	}
	for (i = 0; i < N - 1; i++) {
		if (d[i] != d[i + 1]) c++;
	}
	printf("%d\n", c + 1);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
#include<map>
#include<set>
#include<cmath>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int n, q;
vector<vector<int>> to;
vector<int> ans;
void dfs(int now,int par) {
    if(par!=-1){
	    ans[now] += ans[par];
    }
	rep(i, to[now].size()) {
		if (to[now][i] == par) continue;
		dfs(to[now][i], now);
	}
}

int main() {
	cin >> n >> q;
    to.resize(n);
    ans.resize(n);
	rep(i, n - 1) {
		int a, b;
		cin >> a >> b;
		to[a - 1].push_back(b - 1);
		to[b - 1].push_back(a - 1);
	}
    rep(i, q) {
		int p, x;
		cin >> p >> x;
		ans[p - 1] += x;
	}
	dfs(0, -1);
	rep(i, n) cout << ans[i] << endl;
}

Measured memory_bytes: 23552
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        long x = sc.NextInt();
        long y = sc.NextInt();

        long answer = Math.Abs(Math.Abs(x) - Math.Abs(y));

        if (x == 0)
        {
            if (y < 0)
            {
                answer++;
            }
        }
        else if (y == 0)
        {
            if (x > 0)
            {
                answer++;
            }
        }
        else if (x > 0 && y > 0)
        {
            if (x > y)
            {
                answer += 2;
            }
        }
        else if (x > 0 && y < 0)
        {
            answer++;
        }
        else if (x < 0 && y > 0)
        {
            answer++;
        }
        else if (x < 0 && y < 0)
        {
            if (x > y)
            {
                answer += 2;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 13140
#!/usr/bin/env python3
import sys


def solve(S: str, T: str):
    print(T+S)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#n, m, q = map(int, input().split())
#List = list(map(int, input().split()))
#req = [list(map(int, input().split())) for _ in range(q)]
#t = t[:-1]
#print(ans[j], end = "") 改行無しで出力
#[0]*n
#sort = sorted(a)[::-1] 降順
n, k = map(int, input().split())
a = list(map(int, input().split()))

for i in range(k, len(a)):
    if a[i] > a[i - k]:
        print("Yes")

    else:
        print("No")


Measured memory_bytes: 31724
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;

int discount(int a, int b) {
    return a / pow(2, b);
}

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

    int N, M;
    cin >> N >> M;
    vector<long> A(N);
    priority_queue<long> que;
    rep(i, N) {
        cin >> A[i];
        que.push(A[i]);
    }

    long n_max;
    for (int i = 0; i < M; i++) {
        n_max = que.top() / 2;
        que.pop();
        que.push(n_max);
    }

    long sum = 0;
    while(!que.empty()) {
        sum += que.top();
        que.pop();
    } 

    cout << sum << "\n";
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_h(const vector<T>& c, int n=INT_MAX)
{ rep(i, min(n, (int)c.size())) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define D1(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

template<class LENGTH_T>
void runlength(const string& s, vector<pair<char, LENGTH_T>>& rl)
{
    if (s.size() > 0) {
        LENGTH_T len = 1;
        char ch = s[0];
        for (int i = 1; i < s.size(); i++) {
            if (s[i] == ch) {
                len++;
            } else {
                rl.push_back(make_pair(ch, len));
                ch = s[i];
                len = 1;
            }
        }
        rl.push_back(make_pair(ch, len));
    }
}

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

    string S; cin >> S;
    ll K; cin >> K;

    vector<pair<char, int>> rl;
    runlength(S, rl);

    ll ans = 0;
    if (rl.size() == 1) {
        ans = rl[0].second * K / 2;
    } else {
        rep(i, rl.size()) {
            ans += rl[i].second / 2;
        }
        ans *= K;
        if (rl.front().first == rl.back().first) {
            ans -= (K-1) * (rl.front().second/2 + rl.back().second/2);
            ans += (K-1) * ((rl.front().second + rl.back().second)/2);
        }
    }
    cout << ans << endl;
}


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

int main() {

	int n;
	cin >> n;
	int a;
	map<int,int> mp;
	for(int i=0; i<n; i++) {
		cin >> a;
		mp[a]++;
	}

	int maxi = 0;     
	int temp;
	for(int i=0; i<100000; i++) {
		if(i==0) {
			temp = mp[0] + mp[1];
		}
		if(i == n-1) {
			temp = mp[n-1] + mp[n-2];
		}
		else {
			temp = mp[i-1] + mp[i] + mp[i+1];
		}
		if(temp > maxi)
			maxi = temp;

	}
	cout << maxi << endl;
	return 0;
}


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

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

    vector<int> b;
    vector<int> c;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        if (i % 2 == 1) b.push_back(a);
        else c.push_back(a);
    }

    /*
    for (int i = 0; i < b.size(); i++) {
        cout << b[i] << " ";

    }
    cout << endl;
    for (int i = 0; i < c.size(); i++) {
        cout << c[i] << " ";
    }
    cout << endl;
    */

    vector<int> d;
    if (n % 2 == 1) {
        reverse(b.begin(), b.end());
        for (int i = 0; i < b.size(); i++) {
            d.push_back(b[i]);
        }
        for (int i = 0; i < c.size(); i++) {
            d.push_back(c[i]);
        }
    }
    else {
        reverse(c.begin(), c.end());
        for (int i = 0; i < c.size(); i++) {
            d.push_back(c[i]);
        }
        for (int i = 0; i < b.size(); i++) {
            d.push_back(b[i]);
        }
    }

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

    return 0;
}

Measured memory_bytes: 3824
#include<bits/stdc++.h>
using namespace std;
#define oo (long long)1e18
#define ll long long
#define setdp memset(dp,-1,sizeof(dp))
const ll mod = 1e9+7;
void _IOS(){ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);}
#define PI 3.14159265359
int n,l,r,x;
    int b[200009],a[200009];
int main()
{
    cin>>n>>x;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n+1);
    for(int i=1;i<=x;i++)
        ans+=a[i];
    cout<<ans;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define pes first
#define val second
#define ll long long

using namespace std;

int const MMM = 105;
int n , m;
pair < ll , ll > arr[MMM];
ll dp[100099];

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

    cin >> n >> m;
    for(int i = 1 ; i <= n ; i++)
        cin >> arr[i].first >> arr[i].second;
    for(int i = 1 ; i <= n ; i++)
    {
        for(int j = m ; j >= arr[i].pes ; j--)
        {
            dp[j] = max(dp[j] , dp[j - arr[i].pes] + arr[i].val);
        }
    }
    cout << dp[m];

    return 0;
}


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

const int N = 1000005;

int main ()
{
    i64 a[3], k;
    cin >> a[0] >> a[1] >> a[2] >> k;
    sort(a, a + 3);
    for (int i = 1; i <= k; ++i) a[2] <<= 1;
    cout << a[0]  + a[1] + a[2]<< endl;
    return 0;
}


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


//vector<vector<int>> z(n,vector<int>(2));

int main(){
int n,m;
cin>>n>>m;
vector<int> used(n,0);
vector<int> S(n,0);
int ans=0;
//cout<<used[0]<<'c';
rep(i,m){
  int s,c;
  cin>>s>>c;
  s--;
  if (s+c==0 & n>1)ans=-1;
  if (used[s]==0){
    S[s]=c;
  }
  else {
    if (S[s]!=c) ans=-1;
  }
  used[s]=1;

}
//  cout<<S[0]<<'n'<<S[1]<<'n'<<S[2]<<'n'<<endl;
//if (S[0]==0 & n>1)ans=-1;
if (S[0]==0 & n>1) S[0]=1;
if (ans==0){
  if (n==1) ans+=S[0];
  if (n==2) ans+=S[0]*10+S[1];
  if (n==3) ans+=S[0]*100+S[1]*10+S[2];
}

cout<<ans;

}


Measured memory_bytes: 256
// 世界は変わらない
#include <bits/stdc++.h>
#define int long long int
#define eb emplace_back
#define vi vector<int>
#define pii pair<int, int>
#define ff first
#define ss second

using namespace std;

void solve()
{
    unordered_map<string, int> f;
    int n;
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        f[s]++;
    }
    cout << "AC x " << f["AC"] << '\n';
    cout << "WA x " << f["WA"] << '\n';
    cout << "TLE x " << f["TLE"] << '\n';
    cout << "RE x " << f["RE"] << '\n';
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    solve();
    return 0;
}

Measured memory_bytes: 3612
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)


def comb(n):
    return (n * (n - 1)) // 2


n, m = list(map(int, input().split()))
ABs = [list(map(int, input().split())) for _ in range(m)]

results = []
fuben = comb(n)
results.append(fuben)

uf = UnionFind(n)

for i in range(m)[::-1]:
    a, b = ABs[i]
    a -= 1
    b -= 1
    if uf.same(a, b):
        results.append(fuben)
    else:
        tmp = comb(uf.size(a)) + comb(uf.size(b))
        uf.union(a, b)
        fuben = fuben + tmp - comb(uf.size(a))
        results.append(fuben)

for result in results[-2::-1]:
    print(result)


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

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair <ll,ll> pii;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rept(i,x,y) for(int i=x;i<=y;i++)
#define per(i,x,y) for(int i=x;i>=y;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define fi first
#define se second
#define mes(a,b) memset(a,b,sizeof a)
#define mp make_pair
#define dd(x) cout<<#x<<"="<<x<<" "
#define de(x) cout<<#x<<"="<<x<<"\n"
#define debug() cout<<"I love Miyamizu Mitsuha forever.\n"
const int inf=0x3f3f3f3f;
const int maxn=510;
int dis[maxn][maxn],in[maxn][maxn];
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
deque<pii> q;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	rept(i,1,n)
		rept(j,1,n)
		{
			dis[i][j]=min( min(i-1,n-i),min(j-1,n-j) );
			in[i][j]=1;
		}
	int ans=0;
	rep(iii,0,n*n)
	{
		int id;
		cin>>id;
		int x=(id-1)/n+1,y=id-(x-1)*n;
//		dd(x);de(y);
		ans+=dis[x][y];
		in[x][y]=0;
		while(!q.empty()) q.pop_front();
		q.push_front(mp(x,y));
		while(!q.empty())
		{
			pii point=q.front();q.pop_front();
			int d=dis[point.fi][point.se];
			if(in[point.fi][point.se]) d++;
			rep(i,0,4)
			{
				int x=point.fi+dx[i],y=point.se+dy[i];
				if(x<=0||x>n||y<=0||y>n||dis[x][y]<=d) continue;
				dis[x][y]=d;
				if(in[point.fi][point.se]) q.push_back(mp(x,y));
				else q.push_front(mp(x,y));
			}
		}
	}
	cout<<ans<<"\n";
	return 0;
}

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

int digit_sum(int n){
   if(n < 10)  return n;
   return digit_sum(n/10) + n%10;
}

int main(void){
   
   int N,S;
   cin >> N;
   S = digit_sum(N);
   
   if(N % S == 0){
       cout << "Yes" << endl;
   }
   else{
       cout << "No" << endl;
   }
}

Measured memory_bytes: 3560
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long
#define mod107 1000000007
#define rep(i, n) for (int i = 0; i < n; ++i)
using Graph = vector<vector<int>>;
#define grepq priority_queue<double, std::vector<double>, std::greater<double>>
#define all(v) v.begin(), v.end()
#define PI acos(-1)

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;
}
const ll INF = 10010001010;
const int inf = 1000034000;

typedef tuple<string, int, int> TUP;

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

int main()
{
    cout<<fixed << setprecision(16);
    int N, K;
    cin >> N >> K;
    long double ans = 0;
    for (int i = 1; i <= N;i++)
    {
        ll mul = 0;
        for (int j = i; j < K;)
        {
            j *= 2;
            mul++;
        }
        //cout << mul << endl;
        ans += (long double)(1.0 / N) * (long double)(1.0 / pow(2, mul));
        //cout << ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4168
class Divisors
	def divisors_count(input)
		divisors = Array.new
		for i in 1..input[2]
			divisors << i if input[2]%i == 0
		end
		divisor_range = (input[0]..input[1]).to_a
		puts (divisors & divisor_range).length
	end
end

input = gets.split.map(&:to_i)

Divisors.new.divisors_count(input)

Measured memory_bytes: 6668
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <iostream>
#include <fstream>
#include <chrono>

using namespace std;

const int DIV = 998244353;

int main(int argc, char *argv[]) {
#ifdef VLAD_LOCAL
    ifstream in("in.txt");
    auto start = std::chrono::steady_clock::now();
#else
    istream &in = cin;
#endif
    int k;
    in >> k;
    int r = 7 % k;
    int result = 1;
    std::vector<char> was(k, 0);
    while (r != 0) {
        was[r] = 1;
        r = ((r * 10) + 7) % k;
        result++;
        if (was[r]) {
            result = -1;
            break;
        }
    }
    printf("%d\n", result);
#ifdef VLAD_LOCAL
    auto end = std::chrono::steady_clock::now();
    double seconds = (double)std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() / 1000;
    printf("%.3lf seconds\n", seconds);
#endif
	return 0;
}


Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll INF = 1LL<<60;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    bool ok = false;
    ll tmp = 0;
    ll cnt;
    vector<ll> vec(N);
    for (ll i = 0;i<N;i++) {
        ll a; cin >> a;
        vec.at(i) = a-1;
    }
    for (ll i = 0;i<N+1;i++) {
        ll next = vec.at(tmp);
        if (next == 1) {
            ok = true;
            cnt = i+1;
            break;
        }
        tmp = next;
        
    }
    if (ok) cout << cnt << endl;
    else cout << -1 << endl;

}

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

int main()
{
    int n,m;
    cin>>n>>m;\
    int mark[n+1],check[n+1];
    memset(mark,0,sizeof(mark));
    memset(check,0,sizeof(check));
    vector<int>v;
    while(m--)
    {
        int p;
        cin>>p;
        v.push_back(p);
    }
    for(int i=v.size()-1;i>=0;i--)
    {
        if(check[v[i]]==0)
        {
            check[v[i]]=1;
            cout<<v[i]<<endl;
        }
        mark[v[i]]=1;
    }
    for(int i=1;i<=n;i++)
    {
        if(mark[i]==0)
            cout<<i<<endl;
    }
}

Measured memory_bytes: 5060
# -*- coding: utf-8 -*-
A = int(input())
B = int(input())

if A == 1 and B == 2 or A == 2 and B == 1:
    print(3)
elif A == 1 and B == 3 or A == 3 and B == 1:
    print(2)
elif A == 2 and B == 3 or A == 3 and B == 2:
    print(1)


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace B___ATCoder
{
    class Program
    {
        static void Main (string[] args)
        {
            var s = Console.ReadLine ();
            var a = 0;
            var b = new List<int>
            {
                0
            };
            for (var i = 0; i < s.Length; i++)
            {
                if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
                {
                    a++;
                    if (i == s.Length - 1)
                    {
                        b.Add (a);
                    }
                }
                else
                {
                    if (a != 0)
                    {
                        b.Add (a);
                        a = 0;
                    }
                }
            }
            Console.WriteLine (b.Max ());
        }
    }
}

Measured memory_bytes: 13268
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  vector<vector<P>> a(n);
  rep(i, n) {
    vector<P>& denotes = a[i];
    ll a_size;
    cin >> a_size;
    rep(j, a_size) {
      ll x, y;
      cin >> x >> y;
      --x; // 0-indexed
      denotes.emplace_back(x, y);
    }
  }

  ll ans = 0;
  // check all case. 2^15
  rep(i, 1ll<<n) {
    vector<int> states(n); // 0 is false, 1 is true
    rep(j, n) {
      if ((i>>j) & 1) { // consider j is true.
        states[j] = 1;
      }
    }
    // printvec(states);
    // cout << (ll)__builtin_popcount(i) << endl;

    bool is_ok = true;
    rep(j, n) {
      if ((i>>j) & 1) { // consider j is true.
        for (P& p : a[j]) {
          ll x = p.first;
          ll y = p.second;
          // cout << "j: " << j << endl;
          // cout << "x: " << x << endl;
          // cout << "y: " << y << endl;
          // cout << "states[x]: " << states[x] << endl;
          if (states[x] != y) { // invalid
            is_ok = false;
            break;
          }
        }
      }
    }
    // cout << "is_ok: " << is_ok << endl;
    if (is_ok) { // this condition is ok
      ans = max(ans, (ll)__builtin_popcount(i));
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <string>
using namespace std;
int main(void){
    std::string s = "";
    std::string ATGC = "ATGC";
    int flag[10] = {};
    cin >> s;
    for (int i = 0;i < s.size();i++){
        for (int j = 0;j < 4;j++){
            if(s[i] == ATGC[j]){
                flag[i] = 1;
                break;
            }
        flag[i] = 0;
        }
    }
    int ans = 0,current = 0;
    for (int k = 0;k < 10;k++){
        if(flag[k] == 1){
            current++;
            ans = max(current,ans);
        }
        else{
            current = 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
using P = pair<Int, Int>;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
#define debug2(x, y) cout << #x << ": " << x << ", " << #y << ": " << y << endl;
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

template <class T>
class UnionFind
{
private:
    int groups;

public:
    vector<T> data;
    UnionFind(int sz)
    {
        data.assign(sz, -1);
        this->groups = sz;
    }
    bool unite(T x, T y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        groups--;
        return (true);
    }
    T find(T k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }
    T size(T k) { return (-data[find(k)]); }
    int getGroups() { return this->groups; }
};

void solve()
{
    Int N, M; cin >> N >> M;
    UnionFind<Int> uf(N);
    for(int i = 0; i < M; i++)
    {
        Int A, B; cin >> A >> B;
        A--, B--;
        uf.unite(A, B);
    }

    Int max_size = 0;
    for(int i = 0; i < N; i++)
    {
        max_size = max(max_size, uf.size(i));
    }

    cout << max_size << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}


Measured memory_bytes: 4780
#include <iostream>
#include <vector>
#include <cmath>
#include <string>

class P3 {
	private:
		std::vector<int> digits;
		bool flag_of;
	public:
		P3() { flag_of = false; }
		P3(int n) { 
			digits.resize(n);
			for(int i = 0; i < n; ++i) {
				digits[i] = 0;
			}
			flag_of = false;
		}
		~P3() {}
		void operator =(P3 n) {
			this->digits = n.digits;
		}
		P3 operator ++() {
			this->digits[0] += 1;
			for(int i = 0; i < digits.size(); ++i) {
				if(digits[i] == 3) {
					digits[i] = 0;
					if(i < digits.size() - 1) digits[i+1] += 1;
					else flag_of = true;
				}
			}
			return *this;
		}
		long long eval() {
			long long ret = 0;
			for(int i = 0; i < digits.size(); ++i) {
				ret += (digits[i] * 2 + 3) * std::pow(10, i);
			}
			return ret;
		}
		bool is_of() { return flag_of; }
};

bool is_753(int n) {
	std::string s_n = std::to_string(n);
	int n3 = 0, n5 = 0, n7 = 0;
	for(int i = 0; i < s_n.size(); ++i) {
		if(s_n[i] == '3') ++n3;
		else if(s_n[i] == '5') ++n5;
		else if(s_n[i] == '7') ++n7;
	}
	if(n3 >= 1 && n5 >= 1 && n7 >= 1) return true;
	else return false;
}

int main(void) {
	// input
	long long n;
	std::cin >> n;
	
	int n753 = 0;
	for(int i_digit = 1; i_digit < 10; ++i_digit) {
		P3 p(i_digit);
		for(; p.is_of() == false; ++p ) {
			 if(p.eval() <= n && is_753(p.eval()) == true) n753 += 1;
		}
	}

	std::cout << n753 << std::endl;
	return 0;
}


Measured memory_bytes: 256
import math
def distance(x1,x2,y1,y2):
  d=math.sqrt((x1-x2)**2+(y1-y2)**2)
  return d

n=int(input())
zahyou=[]
for i in range(n):
  a=list(map(int,input().split(" ")))
  zahyou.append(a)

list=[]
for i in range(n):
  for j in range(n):
    k=distance(zahyou[i][0],zahyou[j][0],zahyou[i][1],zahyou[j][1])
    list.append(k)

s=sum(list)/n
print(s)


    
    
  
  

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



int main(void)
{
	int i;
	int length;
	char str[5000+1];

	fgets(str, sizeof(str), stdin);
	length = strlen(str);
	if(str[length - 1] == '\n'){
		str[length - 1] = '\0';
	}
	
	for(i = 0; i < length; i++){
		str[i] = toupper(str[i]);
	}
	printf("%s\n",str);
	
	return 0;
}

Measured memory_bytes: 520
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define x first
#define y second
#define sz(a) (int)a.size()
#define rep(i, a, n) for(int i = a; i < n; i++)
#define dec(i, a, n) for(int i = a; i >= n; i--)
#define clr(a,v) memset(a,v,sizeof(a))
#define all(a) a.begin(),a.end()
#define N 100010 // 1e5
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector <int> vi;

const ll mod = 1e9 + 7;
ll x[N], y[N];

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	rep(i,0,n) scanf("%lld", &x[i]);
	rep(i,0,m) scanf("%lld", &y[i]);
	//sort(x,x+n);sort(y,y+n);
	ll ans=0;
	rep(i,0,n) {
		ans += ((x[i] * (ll)(i))  -  (x[i] * (ll)(n-i-1)))%mod;
		ans%=mod;
	}
	ll ans1=0;
	rep(i,0,m) {
		ans1 += ((y[i] * (ll)(i)) - (y[i] * (ll)(m-i-1)))%mod;
		ans1%=mod;
	}

	printf("%lld\n", (ans*ans1)%mod);
}


Measured memory_bytes: 1792
X,K,D=map(int,input().split())
kai = 0
xy = abs(X)
if xy >= K*D:
    kotae = abs(xy-(K*D))
if xy < K*D:
    kai, mod = divmod(xy, D)
    ds = kai*D
    if (K-kai)%2==0:
        kotae = abs(xy-ds)
    if (K-kai)%2!=0:
        kouho1 = abs(xy-ds-D)
        kouho2 = abs(xy-ds+D)
        if kouho1>=kouho2:
            kotae = kouho2
        if kouho1<kouho2:
            kotae = kouho1
print(kotae)

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

using namespace std;

int main() {
  int N;
  scanf("%d", &N);
  for (int I = 0; I < N; I++) {
    char s[16];
    int a, i;
    scanf("%s", s);
    sort(s, s+8);
    sscanf(s, "%d", &i);
    reverse(s, s+8);
    sscanf(s, "%d", &a);
    printf("%d\n", a - i);
  }
  return 0;
}

Measured memory_bytes: 0
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]
if ((x in a)and(y in a)) or ((x in b)and(y in b)) or ((x in c)and(y in c)):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 62;

int main() {
  //
  ll n;
  cin >> n;
  vector<pll> a(n);
  rep(i, n) {
    ll tmp;
    cin >> tmp;
    a[i] = {tmp, i};
  }
  sort(ALL(a));
  rep(i, n) {
    cout << a[i].second + 1;
    if (i < n - 1)
      cout << " ";
    else
      cout << endl;
  }

  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int e=a*b;
  int f=c*d;
  if(e<f){
    cout<<f<<endl;
  }
  else if(e>f){
    cout<<e<<endl;
  }
  else{
    cout<<e<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
typedef long long ll;

int main()
{
    int a,b,ans;
    scanf("%d",&a);

    b=a;
    ans=a;
    a=a*b;
    ans=ans+a;
    a=a*b;
    ans=ans+a;

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


    return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long n,k;cin>>n>>k;
    long long f=n-1;
    vector<long long> start(n+1),end(n+1);
    start[0]=0,end[0]=n;
    
    // cout<<start[0]<<" ";
    for(long long i=1;i<=n;i++){
        start[i]=i+start[i-1];
        // cout<<start[i]<<" ";
    }
    // cout<<endl;
    
    // cout<<end[0]<<" ";
    for(long long i=1;i<=n;i++){
        end[i]=end[i-1]+f;
        // cout<<end[i]<<" ";
        f--;
    }
    // cout<<endl;
    long long ans=0;
    for(long long i=k;i<=n+1;i++){
        ans=(ans + end[i-1]-start[i-1]+1)%1000000007;
    }
    cout<<ans;
}

Measured memory_bytes: 6376
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int n,k;
  cin >> n>> k;
  ll x[n];
  for(int i=0 ; i<n ; i++){
    cin >> x[i];
  }
  ll ans = 1e18;
  for(int i=0 ; i+k-1<n ; i++){
    ll left = x[i], right = x[i+k-1];
    ans = min(ans, min(abs(right),abs(left))+(right-left) );
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
num = list(map(int, list(input())))
p, m = "+", "-"
for op1 in [p, m]:
    for op2 in [p, m]:
        for op3 in [p, m]:
            x = num[0]
            if op1 == p:
                x += num[1]
            else:
                x -= num[1]
            if op2 == p:
                x += num[2]
            else:
                x -= num[2]
            if op3 == p:
                x += num[3]
            else:
                x -= num[3]

            if x == 7:
                print(
                    "{}{}{}{}{}{}{}=7".format(
                        num[0], op1, num[1], op2, num[2], op3, num[3]
                    )
                )
                sys.exit()
            else:
                pass

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){ //for debug
    ll n = vec.size();
    cout << "------------------------------------\n" ;
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
    cout << "------------------------------------\n" ;
}

void pr2d(vector<vector<ll>> vec){ // for debug
    ll h = vec.size();
    ll w = vec.at(0).size();
    cout << "------------------------------------\n" ;
    rep(i,h){
        rep(j,w){
            cout << vec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
    cout << "------------------------------------\n" ;
}

int main(){
    ld a,b,c; cin >>a >> b >> c ;
    if(sqrt(a)+sqrt(b)+1e-14<sqrt(c)){
        cout << "Yes" ;
    }else{
        cout << "No";
    }
}

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

int main(){
	vector<int> a,b;
	int n,m;
	cin>>n;
	lp(i,n){
		int hoge;
		cin>>hoge;
		a.push_back(hoge);
	}
	cin>>m;
	lp(i,m){
		int hoge;
		cin>>hoge;
		b.push_back(hoge);
	}
	vector<int> ans;
	set_intersection(a.begin(),a.end(),b.begin(),b.end(),inserter(ans,ans.end()));
	for_each(ans.begin(),ans.end(),[](int hoge){ cout<<hoge<<endl;});
	return 0;
}


Measured memory_bytes: 5224
process.stdin.resume();
process.stdin.setEncoding('utf8');

// 標準入力取込
var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

// 解答
function main(inputs){

    // 桁数
    var digit = Number(inputs[0].split(" ")[0]);
    // 入力した組み合わせ数
    var conv = Number(inputs[0].split(" ")[1]);
    // 選ばれた数値リスト
    var list = ['','',''];
    var answer = 0;
    
    // 各桁数の整数の指定がない場合
    if (conv == 0) {

        switch (digit) {
            case 2:
                answer = 10;
                break;
            case 3:
                answer = 100;
                break;
            default:
                break;
        }

        return console.log(answer);
    }

    // 入力値格納
    for (var i = 1; i < inputs.length; i++) {

        var tagetDigit = inputs[i].split(" ")[0] - 1;
        var num = inputs[i].split(" ")[1];
        
        // 同じ桁数で複数の数値が指定された場合、エラー
        if (list[tagetDigit] != '' && list[tagetDigit] != num) {

            return console.log(-1);
        }

        if (list[tagetDigit] == '') {

            list[tagetDigit] = num;
        }
    }

    for (var i = 0; i < digit; i++) {

        if (i === 0 && list[i] === '0' && digit != 1) {

            return console.log(-1);
        }

        if (list[i] === '') {

            if (i === 0) {

                list[i] = 1;
            }

            if (i > 0) {

                list[i] = 0;
            }
        }
    }

    switch (digit) {
        case 3:
            answer = Number(list[0]) * 100
                   + Number(list[1]) * 10
                   + Number(list[2]);
            break;
        case 2:
            answer = Number(list[0] * 10)
                   + Number(list[1]);
            break;
        default:
            answer = Number(list[0]);
                break;
        
    }

    console.log(answer);
}


Measured memory_bytes: 7500
#include<stdio.h>
int main(void)
{
	int a,b,d,r;
	double f;
	scanf("%d""%d",&a,&b);
	d=a/b;
	r=a%b;
	f=(double)a/(double)b;
	printf("%d %d %lf\n",d,r,f);
	

return 0;
}

Measured memory_bytes: 636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int N, M;
string s;
vector<vector<int> > G;
vector<set<int> > haveA, haveB; // 繋がってるAの頂点、Bの頂点情報
vector<bool> del;
void rec(int v) {
  if(del[v]) return;
  if(haveA[v].empty() || haveB[v].empty()) {
    del[v] = true;
    for(int to : G[v]) {
      haveA[to].erase(v);
      haveB[to].erase(v);
      rec(to);
    }
  }
  
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> N >> M >> s;
  G.resize(N+1);
  haveA.resize(N+1);
  haveB.resize(N+1);
  del.resize(N+1, false);
  FOR(i,0,M) {
    int a, b;
    cin >> a >> b;
    G[a].push_back(b);
    if(s[b-1]=='A') {
      haveA[a].insert(b);
    } else {
      haveB[a].insert(b);
    }
    G[b].push_back(a);
    if(s[a-1]=='A') {
      haveA[b].insert(a);
    } else {
      haveB[b].insert(a);
    }
  }
  FOR(i,1,N+1) {
    if(!del[i]) rec(i);
  }
  FOR(i,1,N+1) {
    if(!del[i]) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 45776
#include <iostream>
#include <utility>
#include <iomanip>
#include <cmath>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
typedef long long ll;
using namespace std;
const int N = 2e5 + 5;
const int MOD = 1000000007;

int main()
{
    string a;
    cin >> a;
    if (a[a.length() - 1] != 's')
    {
        cout << a + 's' << endl;
    }
    else
    {
        cout << a + "es" << endl;
    }
}


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

int main(){
  while(1){
    int n;
    cin >> n;
    if(n == 0){
      break;
    }
    vector<int> a(n);
    long long sum = 0;
    for(int i=0; i<n; i++){
      cin >> a[i];
      sum += a[i];
    }
    int ans=0;
    for(int i=0; i<n; i++){
      if(sum >= a[i]*n){
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3092