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

using namespace std;

int main(){
    // card array
    int n_row,n_col;
    cin >> n_row >> n_col;
    
    vector<vector<int>> A(n_row,vector<int>(n_col,0));
    vector<int> B(n_col,0);
    vector<int> C(n_row,0);

    for(int row = 0;row < n_row;row++){
        for(int col = 0;col < n_col;col++){
            cin >> A[row][col]; 
        }
    }

    for(int col = 0;col < n_col;col++){
        cin >> B[col]; 
    }

    for(int row = 0;row < n_row;row++){
        for(int col = 0;col < n_col;col++){
            C[row] += A[row][col]*B[col];
        }
        cout << C[row] << "\n";
    }
    
    return 0;   
}


Measured memory_bytes: 3212
#include<cstdio>
#include<utility>
typedef long long ll;
using namespace std;
pair<ll ,ll> e[100000];
ll g[100001];
ll s[100001];
ll ans[100001];

ll dfs(ll a){
    if(a==g[a]){
        return a;
    }
    g[a]=dfs(g[a]);
    return g[a];
}

int main(){
    ll n,m,a,b,l,r;
    scanf("%lld %lld",&n,&m);
    for(int i=0;i<m;i++){
        scanf("%lld %lld",&a,&b);
        e[i]=make_pair(a,b);
    }
    for(int i=0;i<=n;i++){
        g[i]=i;
        s[i]=1;
    }
    ans[m]=(ll)(n*(n-1))/2;
    for(int i=m-1;i>=0;i--){
        ans[i]=ans[i+1];
        l=dfs(e[i].first);
        r=dfs(e[i].second);
        if(l!=r){
            ans[i]+=(s[l]*(s[l]+1))/2;
            ans[i]+=(s[r]*(s[r]+1))/2;
            if(l<r){
                s[l]+=s[r];
                g[r]=l;
                ans[i]-=(s[l]*(s[l]+1))/2;
            }
            else{
                s[r]+=s[l];
                g[l]=r;
                ans[i]-=(s[r]*(s[r]+1))/2;
            }
        }
    }
    for(int i=1;i<=m;i++){
        printf("%lld\n",ans[i]);
    }
}

Measured memory_bytes: 5248
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 members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

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

incnv = [0]*m
incnv[m-1] = n*(n-1)//2
uf = UnionFind(n)

for i in range(m-1, 0, -1):
  if uf.same(E[i][0]-1, E[i][1]-1):
    incnv[i-1] = incnv[i]
  else:
    size_a = uf.size(E[i][0]-1)
    size_b = uf.size(E[i][1]-1)
    uf.union(E[i][0]-1, E[i][1]-1)
    incnv[i-1] = incnv[i] - size_a*size_b
    
[print(incnv[i]) for i in range(m)]


Measured memory_bytes: 114520
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(x, max(y, z))
#define MIN(x, y, z) min(x, min(y, z))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  string N;
  cin >> N;
  cout << N[0] << N.size() - 2 << N[N.size() - 1] << endl;
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
void ki(int C[],int D[],int p,const vector<vector<int>> &G){
    rep(i,G[p].size()){
       if(D[G[p][i]]==0){
         C[G[p][i]]+=C[p]; 
         D[G[p][i]]=1;
         ki(C,D,G[p][i],G); 
       } 
    }
}
int main() {
  int n,q,a,b;
  cin>>n>>q;
  vector<vector<int>> G(n);
  int C[n]={},D[n]={1};
  rep(i,n-1){
      cin>>a>>b;
      G[a-1].push_back(b-1);
      G[b-1].push_back(a-1);
  }
  rep(i,q){
      cin>>a>>b;
      C[a-1]+=b;
  }
  ki(C,D,0,G);
  rep(i,n)
    printf("%d\n",C[i]);
  return 0;
}

Measured memory_bytes: 27392
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;
int main(){
    bool flag=true;
    int a,b;cin>>a>>b;
    string s;cin>>s;
    for(int i=0;i<a;i++){
        if(s[i]=='-') flag=false;
    }
    if (s[a]!='-') flag=false;
    for(int i=a+1;i<s.size();i++){
        if (s[i]=='-') flag=false;
    }
    if (flag){
        cout << "Yes"<<endl;
    }else{
        cout << "No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <vector>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, d, ans = 0;
  scanf("%lld", &n);
  if(n >= 24) {
    printf("0");
    return 0;
  }
  ll cnt[12];
  for(i = 0; i < 12; ++i) cnt[i] = 0;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &d);
    if(!d) {
      printf("0");
      return 0; 
    }
    cnt[--d]++;
    if(cnt[d] == 3 || cnt[11] == 2) {
      printf("0");
      return 0;
    }
  }
  for(i = 0; i < (1 << 11); ++i) {
    ll min = 24;
    vector<ll> vec;
    vec.push_back(0), vec.push_back(24);
    for(j = 0; j < 12; ++j) {
      if(cnt[j] == 2) {
        vec.push_back(j + 1), vec.push_back(23 - j);
      } else if(cnt[j]) {
        if((1 << j) & i) vec.push_back(j + 1);
        else vec.push_back(23 - j);
      }
    }
    sort(vec.begin(), vec.end());
    for(j = 0; j < vec.size() - 1; ++j) if(vec[j + 1] - vec[j] < min) min = vec[j + 1] - vec[j];
    if(ans < min) ans = min;
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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; }

int main(){
  ll x;
  cin >> x;
  if(x==3||x==5||x==7){
    print("YES");
  }
  else{
    print("NO");
  }
}

Measured memory_bytes: 256
//C
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

//C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>

//Others
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 int dx[8] = { -1,0,1,-1,1,-1,0,1 };
const int dy[8] = { 1,1,1,0,0,-1,-1,-1 };


//LOVE NyantakoGG	https://www.youtube.com/channel/UC6XdFs8T6Ei54O0FYl3PVVA


using namespace std;



int main() {
	int N;
	cin >> N;
	vector<long long>data(100);
	data[0] = 2;
	data[1] = 1;
	for (int i = 2; i < 100; i++) {
		data[i] = data[i - 1] + data[i - 2];
	}
	cout << data[N] << endl;
}


Measured memory_bytes: 256
import math
def is_integer_num(n):
    if isinstance(n, int):
        return True
    if isinstance(n, float):
        return n.is_integer()
    return False
N = list(map(str,input().split(' ')))
A = math.sqrt(int((N[0]+N[1])))
if is_integer_num(A):
  print('Yes')
else:
  print('No')

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

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

    if(N[0]=='7'||N[1]=='7'||N[2]=='7'){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

double calc_dist(pair<int, int> p1, pair<int, int> p2)
{
    return sqrt((p1.first - p2.first) * (p1.first - p2.first) + (p1.second - p2.second) * (p1.second - p2.second));
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> xys(n);
    for(int i=0; i<n; i++)
    {
        int x,y;
        cin >> x >> y;
        xys.at(i) = make_pair(x, y);
    }

    double sum_dist = 0.0;
    double n_kaijou = 1.0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            sum_dist += calc_dist(xys.at(i), xys.at(j));
            // cout << i << "   " << j << "   " << calc_dist(xys.at(i), xys.at(j)) << endl;
        }
        n_kaijou *= (i+1);
    }
    // cout << n_kaijou << endl;
    cout << setprecision(7) << sum_dist * 2 / n << endl;

    return 0;
}


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

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

	vector<long long> a(n);
	for (int i = 0; i < n; ++i) {
		cin >> a[i];
	}

	vector<long long> f(n);
	for (int i = 0; i < n; ++i) {
		cin >> f[i];
	}

	sort(a.begin(), a.end());
	sort(f.begin(), f.end());

	long long maxProduct = 0;
	for (int i = 0; i < n; ++i) {
		long long p = a[i] * f[n - i - 1];
		if (p > maxProduct) {
			maxProduct = p;
		}
	}

	long long start = 0;
	long long end = maxProduct;
	while (start < end) {
		long long lim = (start + end) / 2;
		long long count = 0;
		for (int i = 0; i < n; ++i) {
			if (a[i] * f[n - i - 1] > lim) {
				count += a[i] - lim / f[n - i - 1];
			}
		}

		if (count <= k) {
			end = lim;
		}
		else {
			start = lim + 1;
		}
	}

	cout << end;

	return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define FIO             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

int dp[3001][3001];
mk(arr, 3001, int);
int pre_sum[3001];

int max_sum(int i, int j)
{
	if (i > j)
		return dp[i][j] = 0;;

	if (dp[i][j] != 0)
		return dp[i][j];

	if (i == j)
		return dp[i][j] = arr[i];

	int curr_sum = pre_sum[j] - pre_sum[i - 1];
	return dp[i][j] += curr_sum - min(max_sum(i + 1, j), max_sum(i, j - 1));
}

int32_t main()
{
	FIO;

	int n; cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> arr[i];
		pre_sum[i] = pre_sum[i - 1] + arr[i];
	}

	cout << 2 * max_sum(1, n) - pre_sum[n] << endl;

	return 0;
}

Measured memory_bytes: 49968
N,M,X =map(int,input().split())
CA = [list(map(int,input().split())) for i in range(N)]

ans = float('inf')
for bit in range(1 << N):
    book = [0]*M
    cost = 0
    for i in range(N):
        if(bit >> i) & 1:
            cost += CA[i][0]
            for c in range(M):
                book[c] += (CA[i][c+1])
#    print(book)
    if all(X <= a for a in book):
        ans = min(ans,cost)
if ans == float('inf'):
    print(-1)
else:
    print(ans)

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

signed main(void)
{
	int N;
	cin >> N;
	int n, m, maxi;
	vector<int> a(N);

	rep(i, N) cin >> a[i];
	sort(a.rbegin(), a.rend());
	n = a[0];
	m = a[N - 1];
	maxi = a[N - 1];
	for(int i = 1; i < N; i++)
	{
		int tmp;
		tmp = min(n - a[i], a[i]);
		if (tmp > maxi)
		{
			maxi = tmp;
			m = a[i]; 
		}
	}
	cout << n << " " << m << endl;
	return 0;
}


Measured memory_bytes: 640
s = input()
n = len(s)

if s!=s[::-1]:
    print("No")
    exit()

s2 = s[:(n-1)//2]
if s2!=s2[::-1]:
    print("No")
    exit()

s3 = s[(n+3)//2-1:]
if s3!=s3[::-1]:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define watch(x) cout << #x << " is " << x << endl;
#define print(a, l, r)          \
	for (int i = l; i < r; i++) \
		cout << a[i] << (i == (r - 1) ? endl : " ");
const long long M = 1000000007;
int main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	long long n;
	cin >> n;
	long long a[n];

	long long mn = 100000000000000;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		mn = min(mn, a[i]);
	}
	while (true)
	{
		bool done = false;
		for (int i = 0; i < n; i++)
		{
			if (a[i] != mn && a[i] != 0)
			{
				if (a[i] > mn)
				{
					a[i] = a[i] % mn;
					if (a[i] > 0)
						mn = min(mn, a[i]);
					//watch(a[i]);
				}
				else
					a[i] = 0;

				done = true;
			}
		}
		if (!done)
			break;
	}
	for (int i = 0; i < n; i++)
	{
		if (a[i] > 0)
		{
			cout << a[i] << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
using namespace std;

int main() {
  int a,b,c;
  int rec = 0,hy = 0;
  while(~scanf("%d", &a)) {
    scanf(",%d,%d", &b, &c);
    if(a == b) hy++;
    if(a*a + b*b == c*c) rec++;
  }

  printf("%d\n%d\n", rec, hy);
}

Measured memory_bytes: 0
s = input()
num_a = 0
num_ab = 0
val = 0
for i in range(len(s)):
    if s[i] == 'A':
        num_a += 1
    elif s[i] == 'B':
        num_ab = num_a
        num_a = 0
    else:
        if num_a == 0:
            val += num_ab
            num_a = num_ab
            num_ab = 0
        else:
            num_a = 0
            num_ab = 0
print(val)

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

int main()
{
    double xa, ya, xb, yb, xc, yc, xd, yd;

    while( cin >> xa >> ya >> xb >> yb >> xc >> yc >> xd >> yd )
    {
        xa *= 100000; ya *= 100000; xb *= 100000; yb *= 100000;
        xc *= 100000; yc *= 100000; xd *= 100000; yd *= 100000;
        long long lxa = (long long)xa; long long lya = (long long)ya; long long lxb = (long long)xb; long long lyb = (long long)yb;
        long long lxc = (long long)xc; long long lyc = (long long)yc; long long lxd = (long long)xd; long long lyd = (long long)yd;

        //cout <<  lxa << " " << lya << " " << lxb << " " << lyb << " " << lxc << " " << lyc << " " << lxd << " " << lyd << " " << endl;
        long long xab = lxb - lxa, yab = lyb - lya;
        long long xcd = lxd - lxc, ycd = lyd - lyc;

        long long inner_product = xab * xcd + yab * ycd;
        //long long inner_product = (xb*xd+xa*xc+yb*yd+ya*yc) - (xb*xc+xa*xd+yb*yc+ya*yd);

        //cout << inner_product << endl;

        if( inner_product == 0 )
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }
    return 0;
}


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

using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;

//入力
int N;
Graph G;

//resは答え
vector<int> res;

//vをcに塗る。pはvの親
void dfs(int v,int p,int c){
	res[v]=c;
  	for(auto e:G[v]){
    	if(e.first == p)continue;
    	if(e.second & 1)dfs(e.first, v, 1-c);
      	else dfs(e.first,v,c);
    }
}

int main(){
	cin >> N;
  	G.assign(N,vector<Edge>());
	for(int i = 0; i < N - 1 ; ++i){
    	int u,v,w;
      	cin >> u >> v >> w;
    	--u,--v;
    	G[u].push_back(Edge(v,w));
  		G[v].push_back(Edge(u,w));  
    }
  	res.assign(N,0);
  	dfs(0,-1,1);
  	for(auto v:res)cout << v << endl;
}
  


Measured memory_bytes: 8960
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    rep(i, 2, MAX){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}

ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

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

    COMinit();

    ll N, M, K;
    cin >> N >> M >> K;

    ll distSum = 0LL;

    rep(d, 1, N) {
        distSum += d * (N-d) * M * M;
        distSum %= MOD;
    }
    rep(d, 1, M) {
        distSum += d * (M-d) * N * N;
        distSum %= MOD;
    }

    ll res = distSum * COM(N*M-2, K-2) % MOD;
    cout << res << endl;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
using namespace std;
// define
#define endl "\n"
#ifdef LOCAL
#define lout cerr
#else
ostream devnull(0);
#define lout devnull
#endif
#define AMULET \
  cin.tie(0);  \
  ios::sync_with_stdio(false);
// https://github.com/kurokoji/.cpp-Template/blob/master/template/template2.cpp
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...)                                 \
  GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1) \
  (__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, d) rep5(i, a, n, d, <)
#define rep5(i, a, n, d, o) for (auto i = decltype(n)(a), _n = (n); i o _n; i += (d))

#define rrep(...)                                    \
  GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1) \
  (__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, -1)
#define rrep4(i, a, n, d) rep5(i, (a)-1, n, d, >=)

#define dump(x) lout << #x << " = " << x << endl;
// alias
typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
// func
template <class C>
inline void vcin(C &c);
template <class C, class D>
inline void vcin(C &c, D &d);
template <class C>
inline void vcout(const C &c, const string separate = "\n");
template <class T = int>
inline T in();

int w, h;
int cnt;
char c[20][20];

void dfs(int x, int y);

void solve()
{
  while (true)
  {
    cin >> w >> h;
    if (w == 0 && h == 0)
    {
      break;
    }

    int sx, sy;

    rep(j, h) rep(i, w)
    {
      cin >> c[i][j];
      lout << i << "," << j << " ";
      dump(c[i][j]);
      if (c[i][j] == '@')
      {
        sx = i,
        sy = j;
      }
    }
    dump(sx);
    dump(sy);

    cnt = 0;

    dfs(sx, sy);

    cout << cnt << endl;
  }
}

void dfs(int x, int y)
{
  if (x < 0 || y < 0 || x >= w || y >= h || c[x][y] == '#')
    return;

  cnt++;
  dump(x);
  dump(y);

  c[x][y] = '#';

  dfs(x - 1, y);
  dfs(x + 1, y);
  dfs(x, y - 1);
  dfs(x, y + 1);

  return;
}

signed main()
{
  AMULET
  solve();
  return 0;
}

template <class C>
inline void vcin(C &c)
{
  for (auto &a : c)
  {
    cin >> a;
  }
}
template <class C, class D>
inline void vcin(C &c, D &d)
{
  for (auto it1 = c.begin(), it2 = d.begin(); it1 != c.end() && it2 != d.end(); it1++, it2++)
  {
    cin >> *it1 >> *it2;
  }
}
template <class C>
inline void vcout(const C &c, const string separate)
{
  for (auto it = c.begin(); it != c.end(); it++)
  {
    if (it != c.begin())
      cout << separate;
    cout << *it;
  }
}
template <class T = int>
inline T in()
{
  T x;
  cin >> x;
  return (x);
}



Measured memory_bytes: 3120
#include<iostream>
#include<string>
using namespace std;
int main(){
    string w;
    string t;
    cin >>w;
    int i;
    for(i=0;i<w.size();i++){
        if('A'<=w[i]&&w[i]<='Z') w[i]+='a'-'A';
    }
    int j=0;
    cin >> t;
    while(t!="END_OF_TEXT"){
        for(i=0;i<t.size();i++){
            if('A'<=t[i]&&t[i]<='Z') t[i]+='a'-'A';
        }
        if(w==t) j++;
        cin >>t;
    }
    cout << j << endl;
    return 0;
}


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


#define all(x) (x).begin(),(x).end()

#define FOR(i,x,n)for(int i=(x);i<(n);i++)
#define FOR_R(i,x,n) for(int i=(n-1);i>=(x);i--)
#define REP(i, n) FOR(i, 0, n)
#define REP_R(i, n) FOR_R(i, 0, n)

using ll = long long;
typedef long long ll;
typedef long long int64;
typedef long long lint;
typedef long long lli;



//bit

const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000




////////////////////////////////////////////////////////////////
	 
int main(){

	string a;
  	cin >>a;
  	FOR(i,0,a.size()-1){if(i%2==1)continue; if(a[i]!='h'||a[i+1]!='i'){cout << "No" << endl; return 0;}}
  	if(a.size()%2==1){cout << "No" << endl;return 0;}
	cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = list(map(int, input().split()))

a = [0] * n
a[1] = abs(h[0] - h[1])
for i in range(2, n):
    w1 = a[i-1] + abs(h[i-1] - h[i])
    w2 = a[i-2] + abs(h[i-2] - h[i])
    a[i] = min(w1, w2)
print(a[n-1])

Measured memory_bytes: 13980
s = gets.chomp
min = s.size - 1

if s.each_char.uniq.size == 1
  puts 0
  exit
end

[*'a'..'z'].each do |c|
  str = s.dup

  (s.size - 1).times do |i|
    (str.size - 1).times do |j|
      str[j] = c if str[j] == c || str[j + 1] == c
    end

    str.chop!

    if str.count(c) == str.size
      min = [i + 1, min].min
      break
    end
  end
end

puts min

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

int main(){
 long long N,d,p,ans,k;
cin>>N;
  ans=0;
vector<long long>a(N),b(N-1),c(N);
  for(int i=0;i<N-1;i++){
    cin>>b[i];
  }
  a[0]=b[0];
  a[N-1]=b[N-2];
  if(N>=3){
    for(int i=1;i<N-1;i++){
    a[i]=min(b[i],b[i-1]);
  }
  }
  for(int i=0;i<N;i++){
    ans+=a[i];
}
  cout<<ans<<endl;
}

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

int main() {
  string n, ans;
  int sum = 0;
  
  cin >> n;
    
  for(int i=0;i<n.size();i++){
    sum = sum + (int)(n[i]-'0');
  }
  
  if(sum%9==0){
    ans = "Yes";
  } else{
    ans = "No";
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 3748
import sys
t, h = 0, 0
for line in sys.stdin:
    try:
        a, b, c = line.split(",")
        if not int(a) ** 2 + int(b) ** 2 - int(c) ** 2:
            t += 1
        elif int(a) == int(b):
            h += 1
    except:
        break
print(t)
print(h)

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

int main() {
  int N, C=0;
  string B;
  cin >> N;
  map<string, int> A;
  rep(i, N){
    cin >> B;
    A[B]++;
    if(A[B]>=2) C=1;
  }
  if(C==1) cout << "NO" << endl;
  else cout << "YES" << endl;
}

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


int exc(string s)
{
	if(s=="Vacant") return 0;
	if(s=="Male")return 1;
	if(s=="Female")return 2;
	return -1;
}
int main()
{
	int N;
	cin>>N;
	vector<int> table(N,-1);
	cout<<0<<endl;
	string s;
	cin>>s;
	table[0]=exc(s);
	if(table[0]==0)return 0;
	cout<<N-1<<endl;
	cin>>s;
	table[N-1]=exc(s);
	if(table[N-1]==0)return 0;
	int head=0;
	int tail=N-1;
	rep(cnt,18)
	{
		int mid=(head+tail)/2;
		if(table[mid]!=-1)
		{
			if(head>=N/2)
			{
				head=0;
				tail=(N-1)/2;
			}
			else
			{
				head=(N-1)/2;
				tail=N-1;
			}
		}
		cout<<mid<<endl;
		cin>>s;
		table[mid]=exc(s);
		if(table[mid]==0) break;
		if(((mid-head)%2==0&&table[head]==table[mid])||((mid-head)%2==1&&table[head]!=table[mid]))
		{
			head=mid;
		}
		else
		{
			tail=mid;
		}
	}
	return 0;
}


Measured memory_bytes: 1236
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define TDARRAY(int,a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
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;}

ll a,b,q;
const ll INF = 1e11;
int main(){
    cin >> a >> b >> q;
    vector<ll> s(a);
    vector<ll> t(b);
    vector<ll> x(q);
    REP(i,a){
        cin >> s[i];
    }
    REP(i,b){
        cin >> t[i];
    }
    REP(i,q){
        cin >> x[i];
    }
    REP(i,q){
        ll s1,s2;
        if(x[i]>s.back()){
            s1 = s.back();
            s2 = INF;
        }else{
            if(x[i]<s.front()){
                s1 = -INF;
                s2 = s.front();
            }else{
                auto itr = lower_bound(all(s),x[i]);
                s2 = *itr;
                auto itr2 = next(itr,-1);
                s1 = *itr2;
            }
        }
        ll t1,t2;
        if(x[i]>t.back()){
            t1 = t.back();
            t2 = INF;
        }else{
            if(x[i]<t.front()){
                t1 = -INF;
                t2 = t.front();
            }else{
                auto itr = lower_bound(all(t),x[i]);
                t2 = *itr;
                auto itr2 = next(itr,-1);
                t1 = *itr2;
            }
        }
        ll res = LLONG_MAX;
        chmin(res,x[i]-min(s1,t1));
        chmin(res,max(s2,t2)-x[i]);
        chmin(res,t2-s1+x[i]-s1);
        chmin(res,t2-s1+t2-x[i]);
        chmin(res,s2-t1+x[i]-t1);
        chmin(res,s2-t1+s2-x[i]);
        put(res);
    }
}


Measured memory_bytes: 3712
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt(); //枚数
	int alice = 0; //アリスの合計点
	int bob = 0; //ボブの合計点
	ArrayList<Integer> cardList = new ArrayList<>();
	for(int i=0; i<num; i++){
		cardList.add(sc.nextInt());
	}
	//降順でソート
	Collections.sort(cardList, Collections.reverseOrder());
	
	int turn=1;
	for(int card:cardList){
		if(turn%2 == 1){
			alice = alice+card;
		}else{
			bob = bob+card;
		}
		turn++;
	}
	System.out.println(alice - bob);
  }
}

Measured memory_bytes: 22352
#include <stdio.h>
int main(){
	int n;
	scanf("%d",&n);
	if(n==0||n==1){
		printf("1\n");
		return 0;
	}
	int data[n+1];
	int i;
	data[0]=1;
	data[1]=1;
	for(i=2;i<=n;i++){
		data[i]=data[i-1]+data[i-2];
	}
	printf("%d\n",data[n]);
	return 0;
}

Measured memory_bytes: 596
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;


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

  int ans = n * 800 - (n / 15 * 200);
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
#include<vector>
#include<cmath>
#include<iomanip>
#include<iostream>
using namespace std;

#define PI 3.1415926535

typedef struct {
    double x;
    double y;
} POINT;

vector<POINT> plist;

void kock(int n, POINT p1, POINT p2)
{
    if (n == 0) return;
    POINT s, t, u;
    s = POINT{(p1.x * 2 + p2.x) / 3, (p1.y * 2 + p2.y) / 3};
    t = POINT{(p1.x + p2.x * 2) / 3, (p1.y + p2.y * 2) / 3};
    u = POINT{
        (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3) + s.x,
        (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3) + s.y
    };

    kock(n-1, p1, s);
    plist.push_back(s);
    kock(n-1, s, u);
    plist.push_back(u);
    kock(n-1, u, t);
    plist.push_back(t);
    kock(n-1, t, p2);
}

int main(int, char**)
{
    int n;
    cin >> n;

    POINT s = POINT{0.0f, 0.0f};
    POINT e = POINT{100.0f, 0.0f};
    plist.push_back(s);
    kock(n, s, e);
    plist.push_back(e);
    cout << setprecision(10);
    for (POINT p : plist)
        cout << p.x << " " << p.y << endl;

    return 0;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
ll mod=1e9+7;

int main(){
  ll n,k;
  cin>>n>>k;
  ll a=n%k;
  ll b=k-a;
  cout<<min(a,b)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 998244353
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<ll, ll>
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division

const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
// 出力は.xで！！！！

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
  int n,m,k; cin >> n >> m >> k;
  mint fun=m;
  rep(i,n){
    fun*=m-1;
  }
    mint tmp=0;
    int now=0;
    combination c(n+1);
  if(m==1 && k==n-1){
    cout << 1 << endl;
    return 0;
  }
  else if(m==1){
    cout << 0 << endl;
    return 0;
  }

    while(k>=now){
        tmp+=c(n-1,now)*(fun/(m-1));
        now++;
        fun/=m-1;
      }
    cout << tmp.x << endl;
return 0;
}


Measured memory_bytes: 6428
//author : Simanta Turja
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int r;
    scanf("%d", &r);
    if ( r < 1200 ) {
        puts("ABC");
    }
    else if ( r < 2800 ) {
        puts("ARC");
    }
    else {
        puts("AGC");
    }
    return 0;
}

Measured memory_bytes: 256
K, N = list(map(int, input().rstrip().split()))
l = [int(i) for i in input().rstrip().split()]
dist = [0 for i in range(N)]

for i in range(N):
    if i == 0:
        dist[i] = l[i] + K - l[-1] 
    else:
        dist[i] = l[i] - l[i - 1]

result = K - max(dist)
print(result)


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

// AtCorder用のTemplate
namespace Atcoder{
    public class main{

        // 標準入力用汎用関数
        static string readString(){return Console.ReadLine();}
        static int readInteger(){return int.Parse(Console.ReadLine());}
        static long readLong(){return long.Parse(Console.ReadLine());}
        static double readDouble(){return double.Parse(Console.ReadLine());}
        static decimal readDecimal(){return decimal.Parse(Console.ReadLine());}

        static List<char> readCharL(char separator=' '){return Console.ReadLine().Split(separator).Select((x) => Convert.ToChar(x)).ToList();}
        static List<string> readStringL(char separator=' '){return Console.ReadLine().Split(separator).ToList();}
        static List<int> readIntegerL(char separator=' '){return Console.ReadLine().Split(separator).Select((x) => int.Parse(x)).ToList();}

        static void print<T>(T args){Console.WriteLine(args);}
        static void printL<T>(List<T> _list){Console.WriteLine(string.Join(",", _list));}

        public static void Main(string[] args)
        {
            var tmp = readIntegerL();
            int N = tmp[0]; // 軒数
            int M = tmp[1]; // 買い求める本数
            var _list = new List<List<int>>();

            // 1本A円の栄養ドリンクをB本まで買うことができる
            foreach(var i in Enumerable.Range(0, N))
            {
                var store = readIntegerL();
                _list.Add(store);
            }
            _list.Sort((a, b) => a[0] - b[0]);
            long counter = 0;
            long summary = 0;
            /* 
            while(M > counter)
            {
            */
                foreach(var i in _list)
                {
                    if(counter >= M)
                    {
                        break;
                    }
                    for(var j = 0; i[1] > j; j++)
                    {
                        if(counter >= M)
                        {
                            break;
                        }
                        summary += i[0];
                        counter++;
                    }
                }
                Console.WriteLine(summary);
            // }
        }
    }
}


Measured memory_bytes: 29604
#include <stdio.h>

int main(void)
{
	int n, i, s, f, a, b;
	
	scanf("%d", &n);
	while(n--){
		scanf("%d", &a);
		b = 0;
		f = 1;
		
		for (i = 1; i < 10; i++){
			scanf("%d", &s);
			
			if (a < s){
				a = s;
			}
			else if (b < s){
				b = s;
			}
			else {
				f = 0;
			}
		}
		
		if (f){
			printf("YES\n");
		}
		else {
			printf("NO\n");
		}
	}
	
	return (0);
}

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

int main() {
  int n;
  cin>>n;
  vector<int> x(n);
  for(int &X: x) cin>>X;
  sort(x.begin(),x.end());
  long long ans;
  for(int i=x[0];i<=x[n-1];i++){
    long long sum=0;
    for(int j=0;j<n;j++){
      sum+=(i-x[j])*(i-x[j]);
    }
    if(i==x[0]) ans=sum;
    ans=min(ans,sum);
  }
  cout<<ans<<endl;
}
      

Measured memory_bytes: 256
n=int(input())
b=list(map(int, input().split()))

if n==2:
    print(b[0]*2)
elif n==3:
    a=[]
    a.append(b[0])
    a.append(min(b[0],b[1]))
    a.append(b[1])
    print(sum(a))
else:
    a = []
    a.append(b[0])
    for i in range(1,n-1):
        a.append(min(b[i-1],b[i]))
        
    a.append(b[-1])
    print(sum(a))

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

int main() {
    ll n, k;
    cin >> n >> k;
    vector<double> p(n);
    rep(i, n) {
        double pi;
        cin >> pi;
        p[i] = (1.0 + pi) / 2.0;
    }
    double sum = 0.0, ans = 0.0;
    for (int i = 0; i < n; i++) {
        sum += p[i];
        if (i >= k) {
            sum -= p[i - k];
        }
        ans = max(ans, sum);
    }
    printf("%.6f\n", ans);
}

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

int a,b,c;

int main()
{
    scanf("%d %d %d",&a,&b,&c);
    int t = c-(a-b);
    if(t < 0)
        printf("0\n");
    else
        printf("%d\n",c-(a-b));
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define int long long
typedef long long ll;
using namespace std;
const int MOD = 1000000007;
const int INF = 1010000000;
const double EPS = 1e-10;
const array<pair<int,int>,4> fd{make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 

signed main(){
  string s;int n;cin>>s;n = s.length();
  int g = 0, p = 0, ans = 0;
  rep(i,n){
    if(p < g){
      p++;
      if(s[i] == 'g')ans++;
    }else{
      g++;
      if(s[i] == 'p')ans--;
    }
  }
  cout << ans << endl;
}

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


def solve(r: int):
    print(3*r*r)
    return


# Generated by 1.1.4 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()
    r = int(next(tokens))  # type: int
    solve(r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
  int k, x;
  cin >> k >> x;
  int left = x - k + 1;
  int right = x + k - 1;
  if (left < -1000000) {
    left = -1000000;
  }
  
  if (right > 1000000) {
    right = 1000000;
  }
  
  for (int i = left; i <= right; ++i) {
    cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
X = int(input())
if 400 <= X and X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <=1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)


Measured memory_bytes: 9172
#include<bits/stdc++.h>
using namespace std;
const int N = 100005;
int n, M[N];
int main()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        int a;
        scanf("%d", &a);
        if (a == i)
            M[i] = 1;
    }
    int r = 1, tot = 0;
    for (int i = 1; i <= n; i++)
        if (M[i])
        {
            r = i;
            while (M[r])
                r ++;
            tot += (r - i + 1) >> 1;
            i = r;
        }
    return !printf("%d\n", tot);
}

Measured memory_bytes: 640
while pair = gets
  a, b, c, d, e, f = pair.split(' ')
  a = a.to_f
  b = b.to_f
  c = c.to_f
  d = d.to_f
  e = e.to_f
  f = f.to_f

  base = a * e - b * d
  x = (c * e - f * b) / base;
  y = (a * f - c * d) / base;

  puts '%.3f' % (x + 0).to_s << ' ' << '%.3f' % y.to_s
end

Measured memory_bytes: 6140
n=int(input())
a=list(map(int,input().split()))
b=sorted(a)
if b[(int(n/2)-1)]==b[int((n/2))]:
  print(0)
else:
  c=b[int((n/2)-1)]
  d=b[int((n/2))]
  e=len(list(range(c,d)))
  print(e)



Measured memory_bytes: 14556
#include <bits/stdc++.h>
using namespace std ;
int main() {
	long long n , a , b ;
	cin >> n >> a >> b ;
	if(a == 0 && b == 0) {
		cout << 0 << endl ;
		return 0 ;
	}
	long long s = a + b ;
	long long tmp = n % s ;
	if(tmp >= a) tmp = a ;
	cout << n / s * a + tmp ;
	return 0 ;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define FOR(i,m,n) for(int (i)=m;(i)<n;(i)++)




int main(){
    
    int a,b,c;
    cin>>a>>b>>c;
    if(b/a>=c)cout<<c<<endl;
    else cout<<b/a<<endl;
    return 0;

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define EM 100000000
using namespace std;
using LL = long long;
using P = pair<LL, LL>;
LL LINF = 1e18;
int INF = 1e9;
LL mod = 1e9+7;
using vint = vector<int>;
using vLL = vector<LL>;
using vvint = vector<vector<int>>;
using vvLL = vector<vector<LL>>;
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; }

int main(){
	int N;
	cin >> N;
	vector<vector<char>>	s(N, vector<char>(N));
	for(int i = 0;i < N;i++)	for(int j = 0;j < N;j++)	cin >> s[i][j];
	int ans = 0;
	int a, b;
	int d = 0;
	for(int p = 0;p < 2;p++){
		for(int i = 0;i < N;i++){
			if(p == 0){a = 0;b = i;}
			else	{a = i;b = 0;}
			bool f = true;
			for(int j = 0;j < N;j++){
				for(int k = j+1;k < N;k++){
					if(s[(j-a+N)%N][(k-b+N)%N] != s[(k-a+N)%N][(j-b+N)%N]){f = false;}
				}
			}
			if(f){ans += N-i;if(i == 0){d = N-i;}}
		}
	}
	cout << (ans-d) << endl;
}

Measured memory_bytes: 384
K = input()
min_val,max_val=input().split(' ')
if(int(K)==1):
    print('OK')
else:
    list_val=list(range(int(min_val),int(max_val)+1))
    list_val = list(map( lambda x:x%int(K),list_val))
    if (0 in list_val):
        print('OK')
    else:
        print('NG')


Measured memory_bytes: 9180
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		
		if(B % A ==0) {
        	System.out.println(A+B);
		}
		else {
        	System.out.println(B-A);
		}
	}
}


Measured memory_bytes: 22740
#include<bits/stdc++.h>
#include<iostream>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<queue>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
#define mod 1000000007
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
string s;
int main(){
	ios::sync_with_stdio(0);
	cin>>s;
	cout<<s.substr(0,3);
	re 0;
}

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

int main() {
    int a,b,m;
    int mina = INT_MAX;
    int minb = INT_MAX;
    cin >> a >> b >> m;
    vector<int> reizouko(a),densirenzi(b);
    for(int i = 0; i < a; i++){
        cin >> reizouko.at(i);
        mina = min(mina,reizouko.at(i));
    }
    for(int i = 0; i < b; i++){
        cin >> densirenzi.at(i);
        minb = min(minb,densirenzi.at(i));
    }

    int ans = mina + minb;
    for(int i = 0; i < m; i++){
        int x,y,c;
        cin >> x >> y >> c;
        ans = min(ans,reizouko.at(x-1)+densirenzi.at(y-1)-c);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<pi, int> pii;
typedef pair<pi, pi> pipi;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int H, W, N;
char g[1024][1024];
int dy[] = {0,-1,0,1}, dx[] = {-1,0,1,0};

int main(){
  scanf("%d%d%d", &H, &W, &N);
  rep(i, H) scanf("%s", g[i]);

  int y, x;
  rep(i, H) rep(j, W) if(g[i][j] == 'S') y = i, x = j;

  queue<pipi>q;
  q.push(MP(MP(y, x), MP(1, 0))); // y, x, hp, time
  map<pi, int>m;
  m[MP(y, x)] = 1;

  while(!q.empty()){
    pipi p = q.front(); q.pop();

    int hp = p.S.F;
    if(g[p.F.F][p.F.S] - '0' == hp){
      while(!q.empty()) q.pop();
      m.clear();
      hp++;
    }

    if(hp > N){
      printf("%d\n", p.S.S);
      break;
    }

    rep(d, 4){
      int ny = p.F.F+dy[d], nx = p.F.S+dx[d];
      if(ny < 0 || ny >= H || nx < 0 || nx >= W || g[ny][nx] == 'X' || m.find(MP(ny, nx)) != m.end()) continue;
      q.push(MP(MP(ny, nx), MP(hp, p.S.S+1)));
      m[MP(ny, nx)] = 1;
    }
  }
  return 0;
}

Measured memory_bytes: 30232
from heapq import heappush, heappop

N = int(input())
q = []

for i in map(int, input().split()):
    heappush(q, i)

for _ in range(N-1):
    a = heappop(q)
    b = heappop(q)
    c = (a+b)/2
    heappush(q, c)

ans = heappop(q)
print(ans)

Measured memory_bytes: 3060