akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<cstring>
#include<iostream>
 
#define FOR(i,a,b) for(i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
 
const int dx[4] = {0, 0, 1, -1}, dy[4] = {1, -1, 0, 0};
 
int main(){
    int N;
    while(scanf("%d", &N), N){
        int map[21][21];
        memset(map, 0, sizeof(map));
 
        int i, j;
        REP(i, N){
            int x, y;
            scanf("%d %d", &x, &y);
 
            map[y][x] = 1;
        }
 
        int m;
        scanf("%d", &m);
 
        int x = 10, y = 10, res = map[10][10];
        REP(i, m){
            char d;
            int l;
            std::cin >> d >> l;
         
            if(d == 'N'){
                d = 0;
            }else if(d == 'S'){
                d = 1;
            }else if(d == 'E'){
                d = 2;
            }else{
                d = 3;
            }
 
            REP(j, l){
                x += dx[d];
                y += dy[d];
 
                res += map[y][x];
                map[y][x] = 0;
            }
        }
 
        if(res == N){
            puts("Yes");
        }else{
            puts("No");
        }
    }

    return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
 
int main(){
    int N;
    cin >> N;

    ll ans = 1;
    for(int i=1;i<=N;i++){
        ans = ans*i;
        ans = ans % MOD;
    }
    
    cout << ans << endl;

}

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

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String strNum = br.readLine();
		System.out.printf("%.5f %.5f",(Double.parseDouble(strNum) * Double.parseDouble(strNum) * Math.PI), (2 * Double.parseDouble(strNum) * Math.PI));
	}

}

Measured memory_bytes: 17104
R,C,N = map(int,input().split())

edges = []

def convert(x,y):
  if y == 0:
    return x
  if x == R:
    return R+y
  if y == C:
    return R+C+R-x
  if x == 0:
    return R+C+R+C-y
  else:
    return -1


for i in range(N):
  a,b,c,d = map(int, input().split())
  
  p,q = convert(a,b),convert(c,d)
  if p >= 0 and q >= 0:
    edges.append((p,q) if p < q else (q,p))

edges.sort()

# print(edges)


stack = [R+R+C+C]
flag = 'YES'
for a,b in edges:
  while a >= stack[-1]:
    stack.pop()

  if b > stack[-1]:
    flag = 'NO'
    break
  else:
    stack.append(b)

print(flag)

Measured memory_bytes: 17160
#include <stdio.h>
#define swap(type, x, y)  do{ type t = x; x = y; y = t; }while(0)

void quick(int array[], int left, int right){
  int pl = left, pr = right;
  int x = array[(left + right) / 2];
  do{
    while(array[pl] < x)  pl++;
    while(array[pr] > x)  pr--;
    if(pl <= pr){
      swap(int, array[pl], array[pr]);
      pl++, pr--;
    }
  }while(pl <= pr);
  if(pl < right)  quick(array, pl, right);
  if(pr > left)  quick(array, left, pr);
}

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

  quick(a, 0, n-1);

  int ans = 1;
  for(int i=0; i<n-1; i++)
    if(a[i] == a[i+1])
      ans = 0;

  if(ans)  printf("YES\n");
  else  printf("NO\n");

  return 0;
}


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

using namespace std;
typedef long long ll;
typedef double ld;

ll n, k;
ll a[100010];
ll cou[100010];
ll all, bll;
ll sum;

int main(void)
{
	scanf("%lld", &n);
	
	for(ll i = 1 ; i <= n ; i++)
	{
		scanf("%lld", &a[i]);
		cou[a[i]]++;
		sum += a[i];
	}
	
	scanf("%lld", &k);
	
	while(k--)
	{
		scanf("%lld %lld", &all, &bll);
		
		cou[bll] += cou[all];
		sum += (bll - all) * cou[all];
		cou[all] = 0;
		
		printf("%lld\n", sum);
	}
	
	return 0;
}

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

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> A(N+1,0);
    for(int i=1; i<=N; i++) cin >> A[i];
    for(int i=1; i<=N; i++){
        A[i] = A[i] + A[i-1];
        A[i] = A[i]%M;
    }

    map<int,ll> mp;
    for(int i=0; i<=N; i++){
        mp[A[i]]++;
    }

    ll ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        ll a = itr -> second;
        ans += a*(a-1)/2;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4608
/*
मनस्वी म्रियते कामं कार्पण्यं न तु गच्छति ।
अपि निर्वाणमायाति नानलो याति शीतताम् ॥
*/

#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds;
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define ll long long int
#define ld long double
#define vi vector<int>
#define vl vector<ll>
#define v2i vector<vector<int>>
#define v2l vector<vector<ll>>
#define ppi pair<int,int>
#define ppl pair<ll,ll>
#define vpi vector<ppi>
#define vpl vector<ppl>
#define all(x) x.begin(),x.end()
#define ii int,int 
#define ff first    
#define ss second
#define forn(i,a,b) for(int i=a;i<b;i++)
#define forr(i,a,b) for(int i=a;i>=b;i--)
#define forv(i,m) for(auto i : m)
#define p2d(v) for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v) for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v) for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define imx INT_MAX
#define imn INT_MIN
#define inf 9000000000000000000
#define minf -inf
#define endl "\n"
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define sze size()
#define rvs reverse 
#define itr iterator 
#define pre cout<<fixed<<setprecision(10);
#define umap unordered_map
#define uset unordered_set
#define pi 3.141592653589793
#define MAXN 100005
#define test1(x) cout << #x " = " << x << endl;
#define test2(x,y) cout << #x " = " << x << " " << #y " = " << y << endl;
#define test3(x,y,z) cout << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
#define test4(w,x,y,z) cout << #w " = " << w << " " << #x " = " << x << " " << #y " = " << y << " " << #z " = " << z << endl;
const ll infinity = 9e18;

/*
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define MODM(a,b,md) ((a%md)*(b%md))%md
#define MODA(a,b,md) ((a%md)+(b%md))%md
#define ull unsigned long long int
*/

/*
bool compare(int a,int b) {return a > b;}
bool compare1(ppi a,ppi b) {return a.ff > b.ff;}
bool compare2(ppi a,ppi b) {return a.ss < b.ss;}
ll Npower(ll a,ll b) {ll product = 1; while(b){if(b&1){product = product*a;}a = a*a;b = b>>1;} return product;}
ll power(ll a,ll b,ll md) {ll product = 1; while(b){if(b&1){product = MODM(product,a,md);}a = MODM(a,a,md);b = b>>1;} return product%md;}
bool isprime(ll n){if(n < 2) return 0; ll i = 2; while(i*i <= n){if(n%i == 0) return 0; i++;} return 1;}
ll GCD(ll a,ll b) {return b==0 ? a:GCD(b,a%b);}
ll LCM(ll a,ll b) {return (a/GCD(a,b))*b; }
*/


int main()
{
    fast

/*
    #ifndef ONLINE_JUDGE
        freopen("input.txt",  "r",  stdin);
        freopen("output.txt", "w", stdout);
    #endif
//*/

        
    ll a;
    ld b;
    cin>>a>>b;

    ll ans = ((ld)a*b);    
        
    cout<<ans;











    return 0;
}

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

using namespace std;

long long binom(long long a,long long b){
	long long res=1;
	if(a<b) return 0;
	for(int i=0;i<b;i++){
		res*=(a-i);
		res/=(i+1);
	}
	return res;
}
long long sol(string &str,int i,int k){
	int n=str.size();
	if(i==n){
		if(k==0) return 1;
		return 0;
	}
	if(k==0) return 1;
	if(str[i]=='0') return sol(str,i+1,k);
	
	long long ch=str[i]-'0';
	long long res=binom(n-i-1,k-1)*(ch-1);
	for(int j=1;j<k;j++) res*=9;
	res+=sol(str,i+1,k-1);//ch
	long long res2=binom(n-i-1,k);//0
	for(int j=0;j<k;j++) res2*=9;
	res+=res2;
	return res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin >> s;
	int k;
	cin >> k;
	
	int n=s.size();
	
	cout << sol(s,0,k) << "\n";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
  vector<int> A(3);
  for (int i = 0; i < 3; i++)
    cin >> A[i];
  sort(A.begin(), A.end());
  cout << A[2] - A[0] << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    vector<int> n(2);
    for(int i=0; i<2; ++i)
        cin >> n[i];

    vector<vector<int> > v(2);
    for(int i=0; i<2; ++i){
        v[i].resize(n[i]);
        for(int j=0; j<n[i]; ++j)
            cin >> v[i][j];
    }

    long long ans = 1;
    for(int i=0; i<2; ++i){
        long long tmp = 0;
        for(int j=1; j<n[i]; ++j){
            long long a = v[i][j] - v[i][j-1];
            a *= j;
            a %= MOD;
            a *= n[i] - j;
            a %= MOD;
            tmp += a;
            tmp %= MOD;
        }
        ans *= tmp;
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}


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

int main() {
    int N, K;
    string S;
    cin >> N >> K;
    cin >> S;
    switch (S.at(K-1))
    {
    case 'A':
        S.at(K-1) = 'a';
        break;
    case 'B':
        S.at(K-1) = 'b';
        break;
    case 'C':
        S.at(K-1) = 'c';
        break;
    default:
        break;
    }
    cout << S << "\n";
}

Measured memory_bytes: 256
// AOJ 1280: Slim Span
// 2017.10.22 bal4u@uu

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define MAX 100
/* UNION-FIND library */
int p[MAX], rank[MAX], pp[MAX];
void make_set(int x) { p[x] = x, rank[x] = 0; }
void link(int x, int y) {
	if (rank[x] > rank[y]) p[y] = x;
	else { p[x] = y; if (rank[x] == rank[y]) rank[y] = rank[y] + 1;	}
}
int find_set(int x) { if (x != p[x]) p[x] = find_set(p[x]);	return p[x]; }
void union_set(int x, int y) { link(find_set(x), find_set(y)); }

typedef struct { int x, y, w; } EDGE;
EDGE edge[5000], *end;
int f[10002], max;

int cmp(EDGE *a, EDGE *b) { return a->w - b->w; }

char buf[130], *b;
int getInt(void)
{
	int n = 0;
	if (*b == ' ') b++;
	n = 0; while (*b >= '0' ) n = (n<<3) + (n<<1) + (*b++ & 0xf);
	return n;
}

int main() 
{
	int n, m, i, j, k, ans, sz;
	EDGE *ep;

	for (j = 0; j < 100; j++)  pp[j] = j;
	while (fgets(b=buf, 128, stdin) && *b != '0') {
		n = getInt(), m = getInt();
		sz = sizeof(int)*n;
		for (ep = edge, k = m; k--; ep++) {
			fgets(b=buf, 128, stdin);
			ep->x = getInt()-1, ep->y = getInt()-1, ep->w = getInt();
		}
		end = ep;

		qsort(edge, m, sizeof(EDGE), cmp);
	
		ans = -1;
		for (i = 0; i < m; i++) {
			memcpy(p, pp, sz), memset(rank, 0, sz);
			for (k = 1, ep = edge+i; ep < end; ep++) {
				if (find_set(ep->x) != find_set(ep->y)) {
					union_set(ep->x, ep->y);
					if (++k == n) {
						if (ans < 0 || ep->w - edge[i].w < ans) {
							ans = ep->w - edge[i].w;
							if (ans == 0) goto done;
						}
						break;
					}
				}
			}
		}
done:	printf("%d\n", ans);
	}
	return 0; 
}

Measured memory_bytes: 1936
N, K = map(int, input().split())

trees = []
for i in range(N):
	trees.append(int(input()))

trees.sort()

min_height = trees[-1]

for i in range(N-K+1):
	tmp = trees[i+K-1] - trees[i]
	min_height = tmp if (tmp < min_height) else min_height

print(min_height)

Measured memory_bytes: 7388
// I need some holiday
// But I don't wish that everyday is holiday
// Because I didn't bear the pain
// Because it wasn't a true freedom
//         ——『イヤホンと蝉時雨』·Orangestar

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef unsigned int UI;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define MP make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }
template<typename T> inline T sqr(const T &val) { return val * val; }

namespace fastIO
{
	const int MAX_BUFFER_SIZE = 1 << 16;

	char buffer[MAX_BUFFER_SIZE], *cur = buffer, *ed = buffer;

	inline char getc() { return cur == ed && (ed = (cur = buffer) + fread(buffer, 1, MAX_BUFFER_SIZE, stdin), cur == ed) ? EOF : *cur++; }
}
using fastIO::getc;

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getc());
	for(; !isdigit(ch); ch = getc()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getc()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

inline char *read_str(char *s)
{
	register char ch(getc());
	while(!isgraph(ch)) ch = getc();
	for(; isgraph(ch); ch = getc()) *s++ = ch;
	*s = '\0';
	return s;
}

// END tpl.

const int MAXN = (int) 1e5;

int n;

int x[MAXN + 5], d[MAXN + 5];

int m;
LL K;

int p[MAXN + 5];

inline void input()
{
	n = read<int>();
	for(int i = 1; i <= n; ++i) x[i] = read<int>(), d[i] = x[i] - x[i - 1];
	m = read<int>(), K = read<LL>();
	for(int i = 1; i <= n; ++i) p[i] = i;
	for(int i = 1; i <= m; ++i)
	{
		int t = read<int>();
		swap(p[t], p[t + 1]);
	}
}

inline void solve()
{
	static int vis[MAXN + 5], q[MAXN + 5];

	for(int i = 1; i <= n; ++i) if(!vis[i])
	{
		int l = 0;
		for(int j = i; !vis[j]; j = p[j]) vis[j] = 1, ++l;

		int u = i, v = i;
		for(int j = 0; j < K % l; ++j) v = p[v];
		while(1)
		{
			q[u] = v;
			u = p[u], v = p[v];
			if(u == i) break;
		}
	}

	static int d0[MAXN + 5];
	static LL y[MAXN + 5];

	for(int i = 1; i <= n; ++i) d0[i] = d[q[i]], y[i] = y[i - 1] + d0[i];
	for(int i = 1; i <= n; ++i) printf("%lld\n", y[i]);
}

int main()
{
#ifdef K_ON
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}




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

int main() {
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0; i<n; i++) cin>>a[i];
  for(int i=0; i<n; i++) cin>>b[i];

  int count[n+1];
  for(int i=0; i<n+1; i++) count[i]=0;
  for(int i=0; i<n; i++) {
    count[a[i]]++;
    count[b[i]]++;
  }

  int ma = *max_element(count, count+n+1);
  if(ma>n) {
    cout<<"No"<<endl;
    return 0;
  }

  // int maxnum = max_element(count, count+n) -count;


  int change = n-1;
  int fchange = 0;
  int prev = a[0];
  if(a[0]==b[0]) {
    swap(b[0], b[change]);
    change--;
  }
  for(int i=1; i<n; i++) {
    if(a[i]!=prev) {
      prev = a[i];
      change = n-1;
      fchange = 0;
    }
    
    if(a[i]==b[i]) {
      if(b[i]!=b[change] && b[i]!=a[change]) {
        swap(b[i],b[change]);
        change--;
      }
      else if(b[i]!=b[fchange] && b[i]!=a[fchange]) {
        swap(b[i],b[fchange]);
        fchange++;
      }
      else {
        fchange++;
        i--;
      }
    }
  }

  cout<<"Yes"<<endl;
  for(int i=0; i<n-1; i++) cout<<b[i]<<' ';
  cout<<b[n-1]<<endl;


  return 0;
}

Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};



signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int n;
	while(cin >> n, n) {
		int A = 0, B = 0;
		rep(i, n) {
			int a, b;
			cin >> a >> b;
			if(a > b) A += a + b;
			else if(a < b) B += a + b;
			else A += a, B += b;
		}
		cout << A << " " << B << endl;
	}
	return 0;
}


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

class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] strs = br.readLine().split(" ");
    int A = Integer.parseInt(strs[0]);
    int B = Integer.parseInt(strs[1]);
    if (A * B % 2 == 0) {
      System.out.println("No");
    } else {
      System.out.println("Yes");
    }
  }
}

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

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

    bool red[n];
    red[0] = true;
    for (int i = 1; i < n; i++) {
        red[i] = false;
    }
    int num[n];
    for (int i = 0; i < n; i++) {
        num[i] = 1;
    }

    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        if (red[x]) {
            red[y] = true;
            if (num[x] == 1) red[x] = false;
        }
        num[x]--;
        num[y]++;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (red[i]) ans++;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
[p, rank] = [[], []]
[n, q] = list(map(int, input().split()))
w = [0 for i in range(n)]

def findSet(x):
    global p
    if x != p[x]:
        pre_parent = p[x]
        p[x] = findSet(p[x])
        w[x] += w[pre_parent]
    return p[x]

def makeSet(x):
    global p, rank
    p.append(x)
    rank.append(0)


def link(x, y, z):
    global p, rank, w
    if rank[x] > rank[y]:
        p[y] = x
        w[y] = z
    else:
        p[x] = y
        w[x] = -z
        if rank[x] == rank[y]:
            rank[y] += 1

def relate(x, y, z):
    global w
    root_x = findSet(x)
    root_y = findSet(y)
    z += w[x]
    z -= w[y]
    link(root_x, root_y, z)

def same(x, y):
    if findSet(x) == findSet(y):
        return 1
    else:
        return 0   
   
def difference(x, y):
    if same(x, y) == 1:
        global w
        return w[y] - w[x]
    else:
        return "?"     

for i in range(n):
    makeSet(i)

for i in range(q):
    data = list(map(int, input().split()))
    if data[0] == 0:
        relate(data[1], data[2], data[3])
    else:
        print(difference(data[1], data[2]))



Measured memory_bytes: 11412
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> Pi; typedef map<int,int> MPi; typedef pair<Int,Int> Pl;
const int mod = 1000000007;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) v.begin(),v.end()
#define Pr(type) priority_queue<type>
#define gPr(type) priority_queue<type,vector<type>,greater<type>>
#define V(type) vector<type>
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


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

	string s; cin>>s; stack<bool> st;
	for (int i = 0; i < s.size(); i++){
		if(s[i]=='S')st.push(true);
		else{
			if(st.empty())st.push(false);
			else if(st.top())st.pop();
			else st.push(false);
		}
	}
	cout<<st.size()<<'\n';
}

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

using namespace std;

int n;
int q[10001];


int main(){
	scanf("%d", &n);
	int min_q = 1000001, max_q=-1000001;
	long long int sum =0;
	
	for(int i=0; i<n; ++i){
		scanf("%d", &q[i]);
		min_q = min(min_q, q[i]);
		max_q = max(max_q, q[i]);
		sum = sum + q[i];
	}
	
	printf("%d %d %lld\n", min_q, max_q, sum);
}



Measured memory_bytes: 2732
package main

import (
	"fmt"
	"strings"
)

func main() {
	var n string
	fmt.Scan(&n)
	slice := string2slice(n)
	if isGoodInteger(slice) {
		fmt.Print("Yes")
	} else {
		fmt.Print("No")
	}
}

func string2slice(s string) []string {
	return strings.Split(s, "")
}

func isGoodInteger(strs []string) bool {
	if strs[0] == strs[1] {
		if strs[1] == strs[2] {
			return true
		}
	}

	if strs[1] == strs[2] {
		if strs[2] == strs[3] {
			return true
		}
	}
	return false
}


Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main ()
{
	int t;
	cin >> t;
	for (int u = 0; u < t; u++)
	{
		int n = 0,a[100];
		cin >> n;

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

		for (int i = 0; i < n - 1; i++)
		{
			if (a[i] <= a[i + 1])
			{
				if (p < a[i + 1] - a[i])
				{
					p = 0;
					p = a[i + 1] - a[i];
				}
			}
			else
			{
				if (o < a[i] - a[i + 1])
				{
					o = 0;
					o = a[i] - a[i + 1];
				}
			}
		}

		cout << p << " " << o << endl;
	}
}


Measured memory_bytes: 3080
#include <bits/stdc++.h>
 
using namespace std;
 
#define xx         first
#define yy         second
#define pb         push_back
#define mp         make_pair
#define LL         long long
#define inf        INT_MAX/3
#define mod        1000000007ll
#define PI         acos(-1.0)
#define linf       (1ll<<60)-1
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define REP(I,N)   FOR(I,0,N)
#define For(I,N)   for(int I=1;I<=(N);I++)
#define ALL(A)     ((A).begin(), (A).end())
#define set0(ar)   memset(ar,0,sizeof ar)
#define vsort(v)   sort(v.begin(),v.end())
#define setinf(ar) memset(ar,126,sizeof ar)
#define SZ(X) ((int)(X.size()))
#define LG(X) ((int)(X.length()))
#define CL(X) (X).clear()
#define MAXEL(A,B) (*max_element(A,B))
#define MINEL(A,B) (*min_element(A,B))
#define ROPEN(X) freopen(X,"r",stdin)
#define WOPEN(X) freopen(X,"w",stdout)
#define BG(X) (X.begin())
#define EN(X) (X.end())
#define VI vector<int>
#define PII pair<int,int>
 
//cout << fixed << setprecision(20) << p << endl;
 
template <class T> inline T bigmod(T p,T e,T M){
    LL ret = 1;
    for(; e > 0; e >>= 1){
        if(e & 1) ret = (ret * p) % M;
        p = (p * p) % M;
    } return (T)ret;
}
template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template <class T> inline T modinverse(T a,T M){return bigmod(a,M-2,M);}


int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	int n;
	cin>>n;
	vector<int>v(n),c(n);
	REP(i,n){
		cin>>v[i];
	}
	REP(i,n){
		cin>>c[i];
	}
	int res=0;
	REP(i,n){
		if(v[i]>c[i])res+=v[i]-c[i];
	}
	cout<<res;
	return 0;
}


Measured memory_bytes: 256
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors
n = int(input())
ans = 0
for i in make_divisors(n):
    if i != 1:
        x = n
        flag = True
        while flag:
            x //= i
            if x % i != 0:
                flag = False
        if x % i == 1:
            ans += 1
ans += len(make_divisors(n-1))-1
print(ans)

Measured memory_bytes: 3316
abc096b = do
    [a,b,c] <- readArray getLine
    n <- readLn::IO Int
    let mx = maximum [a,b,c]
    print $ sum[a,b,c] + mx * (pow2 n -1)
        where pow2 0 = 1
              pow2 x = pow2 (x-1) * 2

main = abc096b

readArray::IO String -> IO[Int]
readArray = fmap $ map read . words

Measured memory_bytes: 508
# ABC089C - March
from itertools import combinations


def main():
    n = int(input())
    lst = [input().rstrip()[0] for _ in range(n)]
    cand = [lst.count(s) for s in "MARCH"]
    ans = sum(x * y * z for x, y, z in combinations(cand, 3))
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3888
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
bool A[100];
int main() {
    init();
    ll N,K;
    cin >> N >> K;
    rep(i,K){
        ll k;
        cin >> k;
        rep(j,k){
            ll a;
            cin >> a;
            A[a - 1] = true;
        }
    }

    ll cnt = 0;
    rep(i, N) if (!A[i]) cnt++;
    cout << cnt << endl;
}

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

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n;
    cin >> n;

    map< s64, int > m;
    vs64 a(n);
    rep (i, n)
    {
        cin >> a[i];
        ++m[a[i]];
    }

    sort(a.begin(), a.end(), greater<s64>());

    s64 ans = 0;
    rep (i, n)
    {
        s64 target = 1;
        while (target <= a[i]) target <<= 1;
        if (m[target - a[i]] == 0)
        {
            continue;
        }

        if (a[i] * 2 == target)
        {
            if (m[a[i]] > 1)
            {
                m[a[i]] -= 2;
                ++ans;
            }
        }
        else if (m[a[i]] > 0 && m[target - a[i]] > 0)
        {
            --m[a[i]];
            --m[target - a[i]];
            ++ans;
        }
    }

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



Measured memory_bytes: 26880
from collections import deque
INF = 1001001001
di = [-1, 0, 1, 0]
dj = [ 0,-1, 0, 1]

H, W = map(int, input().split())
S = [input() for _ in range(H)]
# print(S)

ans = 0
for si in range(H):
    for sj in range(W):
        if (S[si][sj] == '#'): continue
        dist = [[INF]*W for _ in range(H)]
        dist[si][sj] = 0
        q = deque([(si, sj)])
        while len(q) > 0:
            i, j = q.popleft()
            for dir in range(4):
                ni = i + di[dir]
                nj = j + dj[dir]
                if (ni<0 or ni>=H or nj<0 or nj>=W): continue
                if (S[ni][nj] == '#'): continue
                if (dist[ni][nj] != INF): continue
                q.append((ni, nj))
                dist[ni][nj] = dist[i][j] + 1
        for i in range(H):
            for j in range(W):
                if dist[i][j] == INF: continue
                ans = max(ans, dist[i][j])
print(ans)


Measured memory_bytes: 3316
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)




























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


Measured memory_bytes: 3620
"use strict";
function I(t,i){this._s=t.split("\n"),this._c=0,this._l=0,this._f=i||Number}I.prototype.a=function(t){var i=this._s[this._l];if(i){var s=i.trim().split(" "),h=s[this._c];return this._c++,s.length===this._c&&(this._c=0,this._l++),t?t(h):this._f(h)}},I.prototype.l=function(t){var i=this._s[this._l];if(i)return this._c=0,this._l++,i.split(" ").map(t||this._f)},module.exports=I;
function Queue(e){this._queue=e?e.slice():[],this._tail=this._queue.length,this._head=0,this._maxLength=1000000000}Queue.prototype.enqueue=function(e){this._tail+1===this._head||0===this._head&&this._tail===this._maxLength-1?console.error("===queue overflow==="):(this._queue[this._tail]=e,this._tail+=1,this._tail===this._maxLength&&(this._tail=0))},Queue.prototype.dequeue=function(){if(this._tail!==this._head){var e=this._queue[this._head];return this._head+=1,this._head===this._maxLength&&(this._head=0),e}console.error("===queue underflow===")},Queue.prototype.size=function(){var e=this._tail-this._head;return e<0&&(e+=this._maxLength),e};

function main(input) {
  var o = new I(input);

  var n = o.a();

  var adj = Array(n+1).fill().map(() => []);
  adj[0] = undefined;
  for (var i = 0; i < n - 1; i ++) {
    var a = o.a();
    var b = o.a();

    adj[a].push(b);
    adj[b].push(a);
  }


  var queue = new Queue([1]);
  var color = [];
  var dis = [];
  color[1] = "black";
  dis[1] = 0;
  while (queue.size() > 0) {
    var v = queue.dequeue();
    adj[v].forEach(u => {
      if (color[u] !== "black") {
        queue.enqueue(u);
        dis[u] = dis[v] + 1;
        color[u] = "black";
      }
    })
  }

  var max = -1;
  var maxV;
  for (var i = 1; i < dis.length ; i++) {
    if (dis[i] > max) {
      max = dis[i];
      maxV = i;
    }
  }

  var queue = new Queue([maxV]);
  var color = [];
  var dis = [];
  color[maxV] = "black";
  dis[maxV] = 0;
  while (queue.size() > 0) {
    var v = queue.dequeue();

    adj[v].forEach(u => {
      if (color[u] !== "black") {
        queue.enqueue(u);
        dis[u] = dis[v] + 1;
        color[u] = "black";
      }
    })
  }

  var diameter = 0;
  for (var i = 1; i < dis.length ; i++) {
    if (dis[i] > diameter) {
      diameter = dis[i];
    }
  }

  console.log(diameter % 3 === 1 ? "Second" : "First");
}


main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 127484
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

def solve():
  A, B, C, D = map(int, input().split())
  A = A - 1
  CD = C * D // gcd(C, D)
  num_C = (B // C) - (A // C)
  num_D = (B // D) - (A // D)
  num_CD = (B // CD) - (A // CD)
  return B - A - num_C - num_D + num_CD

print(solve())


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

int main(){
    int n;
    cin>>n;
    int card[4][13]={};
    for(int i=0;i<n;i++){
        string suit;
        int num;
        cin>>suit>>num;
        
        if(suit=="S")card[0][num-1]=1;
        if(suit=="H")card[1][num-1]=1;
        if(suit=="C")card[2][num-1]=1;
        if(suit=="D")card[3][num-1]=1;
    }
    
    string str[4]={"S","H","C","D"};
    for(int i=0;i<4;i++){
        for(int j=0;j<13;j++){
            if(card[i][j]==1)continue;
            cout<<str[i]<<" "<<j+1<<endl;
            
        }
    }
        
    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
using namespace std;
int mp[21][21];
void drop(int x,int y,int size){
  if(size==1)mp[y][x]++,mp[y+1][x]++,mp[y-1][x]++,mp[y][x+1]++,mp[y][x-1]++;
  if(size==2 || size==3)
    for(int i=-1;i<=1;i++)
      for(int j=-1;j<=1;j++) mp[y+i][x+j]++;
  if(size==3) mp[y+2][x]++,mp[y-2][x]++,mp[y][x+2]++,mp[y][x-2]++;
}
int main() {
  int x,y,size;
  while(scanf("%d,%d,%d",&x,&y,&size) != EOF) drop(x+10,y+10,size);
  int cnt=100,mxsize=0;
  for(int i=10;i<20;i++)
    for(int j=10;j<20;j++)
      if(mp[i][j] != 0)cnt--,mxsize=max(mxsize,mp[i][j]);
  cout << cnt <<endl<<mxsize<<endl;
  return 0;
}

Measured memory_bytes: 1208
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

bool serch(vector<int> &a, int q){
    for(int i=0; i<a.size(); i++){
        if(a[i] == q) return true;
    }
    return false;
}

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

    int q; cin >> q;
    vector<int> t(q);
    for(int i=0; i<q; i++) cin >> t[i];

    int ans = 0;
    for(int i=0; i<q; i++){
        if(serch(a, t[i])) ans++;
    }

    cout << ans << endl;

}


Measured memory_bytes: 3112
read n
read S
ans=0
for i in `seq $n`;do
	s=(`echo ${S:0:$i}|grep -o .|sort -u`)
	t=(`echo ${S:$i}|grep -o .|sort -u`)
	cnt=0
	for c in ${s[@]};do
		for d in ${t[@]};do
			if [ $c = $d ];then
				cnt=$[cnt+1]
				break
			fi
		done
	done
	ans=$[ans<cnt?cnt:ans]
done
echo $ans


Measured memory_bytes: 2884
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
using namespace std;
struct Node
{
    int key;
    Node *p,*l,*r;
};
Node *root,*NIL;
void insert(int k)
{
    Node *y=NIL;
    Node *x=root;
    Node *z;
    z=(Node*)malloc(sizeof(Node));
    z->key=k;
    z->l=NIL;
    z->r=NIL;
    while(x!=NIL)
    {
        y=x;
        if(z->key<x->key)
            x=x->l;
        else
            x=x->r;
    }
    z->p=y;
    if(y==NIL)
    {
        root=z;
    }
    else
    {
        if(z->key<y->key)
        {
            y->l=z;
        }
        else
        {
            y->r=z;
        }
    }
}
void zx(Node *u)
{
    if(u==NIL)return;
    zx(u->l);
    printf(" %d",u->key);
    zx(u->r);
}
void qx(Node *u)
{
    if(u==NIL)return;
    printf(" %d",u->key);
    qx(u->l);
    qx(u->r);

}
int main()
{
    int n,k;
    scanf("%d",&n);
    string c;
    for(int i=1;i<=n;i++)
    {
        cin>>c;
        if(c=="insert")
        {
            scanf("%d",&k);
            insert(k);
        }
        else if(c=="print")
        {
            zx(root);
            printf("\n");
            qx(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 26716
#include<bits/stdc++.h>
#define inf 1<<29
#define linf 1e16
#define eps (1e-8)
#define mod 1000000007
#define pi acos(-1)
#define phi (1.0+sqrt(5))/2.0
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<int,double> pid;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int k,s,ans=0;
  cin>>k>>s;
  FOR(x,0,k+1){
    FOR(y,0,k+1){
      int z=s-x-y;
      if(0<=z && z<=k)ans++;
    }
  }
  cout<<ans<<endl;

  return 0;
}



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

typedef vector<pair<int,int> > pr;
const int H_MX = 100000001;

int N;
pr v;
vector<int> prime;
unsigned int bset[H_MX/32+1] = {0};

bool get_b(int i){
	int bank = i / 32;
	int ofs = i % 32;
	return bset[bank] & (1<<ofs);
}
void set_b(int i){
	int bank = i / 32;
	int ofs = i % 32;
	bset[bank] |= (1<<ofs);
}

void hurui(){
	for(int i = 2; i < H_MX; i++){
		if(get_b(i) == false){
			prime.push_back(i);
			for(int j = i; j < H_MX; j+=i){
				set_b(j);
			}
		}
	}
}

void factor(int n,pr &p){
	for(int i = 0; i < prime.size(); i++){
		bool first = true;
		while(n % prime[i] == 0){
			if(first){
				p.push_back(make_pair(prime[i],1));
			}
			else{
				p[p.size()-1].second++;
			}
			n /= prime[i];
			first = false;
		}
		if(n <= 1) return;
	}
}
int calc(int n,const pr &p){
	long long S = 1;
	for(int i = 0; i < p.size(); i++){
		long long tmp = 0;
		for(int j = 0; j <= p[i].second; j++){
			tmp += pow(p[i].first,j);
		}
		S *= tmp;
		if(S - n > n){
			return n+1;
		}
	}
	return (int)(S - n);
}


int main(){
	hurui();
	while(cin >> N,N != 0){
		v = pr();
		factor(N,v);
		int S = calc(N,v);
		if(N == S){
			cout << "perfect number" << endl;
		}
		else if(N > S){
			cout << "deficient number" << endl;
		}
		else{
			cout << "abundant number" << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 47772
n, k = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7

plus = []
minus = []
for i in a:
    if i > 0: plus.append(i)
    if i < 0: minus.append(i)

ans = 1
if k > len(plus) + len(minus):
    ans = 0
elif len(minus) == 0:
    plus.sort(reverse=True)
    for i in range(k):
        ans = (ans * plus[i]) % mod
elif len(plus) == 0:
    if k % 2 == 0:
        minus.sort()
        for i in range(k):
            ans = (ans * minus[i]) % mod
    else:
        if n != len(minus):
            ans = 0
        else:
            minus.sort(reverse=True)
            for i in range(k):
                ans = (ans * minus[i]) % mod
elif k == len(plus) + len(minus) and (len(minus) % 2) == 1:
    if n != k:
        ans = 0
    else:
        for x in plus:
            ans = (ans * x) % mod
        for y in minus:
            ans = (ans * y) % mod
else:
    plus.sort(reverse=True)
    minus.sort()
    i, j = 0, 0
    if k % 2 == 1:
        ans = plus[0]
        i = 1
    while i + j < k:
        tmp_p = plus[i] * plus[i + 1] if i <= len(plus) - 2 else 1
        tmp_m = minus[j] * minus[j + 1] if j <= len(minus) - 2 else 1
        if tmp_p >= tmp_m:
            ans = (ans * (tmp_p % mod)) % mod
            i += 2
        else:
            ans = (ans * (tmp_m % mod)) % mod
            j += 2
print(ans)


Measured memory_bytes: 31776
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
  int N, tmp, sum = 0;
  cin >> N;
  int V[N], C[N];
  for(int i = 0; i < N; ++i)
    cin >> V[i];
  for(int i = 0; i < N; ++i) {
    cin >> tmp;
    V[i] -= tmp;
  }
  for(int i = 0; i < N; ++i)
    if(V[i] < 0) continue;
    else sum += V[i];
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#  --*-coding:utf-8-*--

def f(C, N):
    return chr((ord(C) + N - 65)%26 + 65)

def main():
    N = int(input())
    S = input()
    
    print(''.join([f(C, N) for C in S]))


if __name__ == '__main__':
    main()


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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

ll n,a[200000],b[200000];

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

	cin>>n;
	REP(i,n) cin>>a[i];
	REP(i,n) cin>>b[i];

	int ans=0;
	REP(i,30) {
		ll c[n],d[n];
		ll cnt=0;
		ll mod=(1<<i);
		REP(j,n) c[j]=b[j]%(2*mod),d[j]=a[j]%(2*mod);
		sort(c,c+n);sort(d,d+n);
		//REP(j,n) cout<<BIT(c[j],4)<<' ';
		//cout<<endl;
		REP(j,n) {
			//int tar=a[j]%(2*mod);
			ll tar=d[j];
			if(tar<mod) cnt+=lower_bound(c,c+n,mod-tar)-c;
			cnt+=(lower_bound(c,c+n,3*mod-tar)-lower_bound(c,c+n,2*mod-tar));
		}
		if((n*n-cnt)&1) ans|=mod;
	}
	cout<<ans<<endl;


	return 0;
}


Measured memory_bytes: 6528
//Md. Shajibul Islam..
//East West University, CSE Department'19

#include<bits/stdc++.h>
using namespace std;
#define FAST       ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define loop(i,n)        for(int i=0;i<n;i++)
#define CASE_PRINT       cout<<"Case "<<C<<": "
#define ll               long long
#define ld               long double
#define Pi               2*acos(0.0) // acos(-1.0)

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

    int cnt=0;
    int x=0;
    x+=n;
    while(n>0)
    {
        n-=1000;
        cnt++;
    }

    int a = cnt*1000;
    cout<<a-x<<endl;
}



Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>

#define MAXINUM   ( 100 + 1 )

using namespace std;

/** Application main entry point. */
int main (
  int     argc,
  char  * argv[ ]
  )
{
  int input[ MAXINUM ] = { 0 };
  int countMax = 0;

  while ( true )
  {
    int __tmp;
    
    if ( !( cin >> __tmp ) ) break;
    countMax = max ( countMax, ++input[ __tmp ] );
  }
  if ( countMax == 0 )  return ( 0 );

  for ( int i = 0; i < MAXINUM; ++i )
  {
    if ( input[ i ] == countMax )
    {
      cout << i << endl;
    }
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod ll(1e9+7)
ll exp(ll a,ll b)
{
	if(b==0)
	 return 1;
	if(b%2==0){
		return exp(a*a%mod,b/2);
	}
	return a*exp(a*a%mod,(b-1)/2)%mod;
}
int main()
{
	int s;
	cin>>s;
	vector<ll>dp(2001);
	dp[0]=1;
	for(int i=3; i<=s; i++){
		for(int j=3; j<=i; j++){
			dp[i]=(dp[i]+dp[i-j])%mod;
		}
	}
	cout<<dp[s];
	return 0;
	
}

Measured memory_bytes: 3608
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int[] l = new int[N];
		for (int i = 0; i < l.length; i++) {
			l[i] = sc.nextInt();
		}
		Arrays.sort(l);
		int sum = 0;
		for(int i = 0;i < K;i++){
			sum += l[N - 1 - i];
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 21972
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int x1, x2, y1, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	int x = x2 - x1;
	int y = y2 - y1;
	cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;
}

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

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

  int a = 0, b = 0;
  rep (i, sz(s)) {
    if ((s[i] == '0' && i % 2 == 0) || (s[i] == '1' && i % 2 == 1)) a++; // 101010...
    if ((s[i] == '1' && i % 2 == 0) || (s[i] == '0' && i % 2 == 1)) b++; // 010101...
  }

  cout << min(a, b) << endl;
}


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

string t[16]={"KIHBR", "KIHBRA", "KIHBAR", "KIHBARA", "KIHABR", "KIHABRA", "KIHABAR", "KIHABARA", "AKIHBR", "AKIHBRA", "AKIHBAR", "AKIHBARA", "AKIHABR", "AKIHABRA", "AKIHABARA"};

int main(){
    string s;
    cin >> s;
    bool flag = false;
    for(int i=0;i<16;++i){
        if(s == t[i]){
            flag = true;
            break;
        }
    }
    if(flag)cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


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

namespace agc030_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

            var a = list[0];
            var b = list[1];

            var hogelist = new List<hoge>();
            for(int i = 0; i < b; i++){
                text = Console.ReadLine();
                list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

                var item = new hoge();

                item.a = list.Skip(1).ToList();

                hogelist.Add(item);
            }

            text = Console.ReadLine();
            list = text.Split(' ').ToList().Select(x => int.Parse(x)).ToList();

            for(int i = 0; i < list.Count; i++){
                hogelist[i].answer = list[i];
            }

            var pattern = Math.Pow(2, a);

            var sw = new List<int>();
            for(int i = 0; i < a; i++){
                sw.Add(0);
            }

            var allon = 0;
            for(int i = 0; i < pattern; i++){
                var bin = Convert.ToString(i, 2);
                var remain = a - bin.Length;
                if (remain > 0){
                    bin = new string('0', remain) + bin;
                } 

                for (int j = 0; j < a; j++){
                    var onoff = int.Parse(bin.Substring(j, 1));
                    sw[j] = onoff;
                }

                var isFind = false;
                foreach(var item in hogelist){
                    var total = 0;
                    foreach(var lampsw in item.a){
                        total = total + sw[lampsw - 1];
                    }

                    var md = total % 2;

                    if (item.answer != md){
                        isFind = true;
                        break;

                    }

                }

                if (isFind == false){
                    allon++;
                }


            }

            Console.WriteLine(allon);
        }
    }

    class hoge{      
        public List<int> a;

        public int answer;
    }
}


Measured memory_bytes: 13396
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    int i = S.length();
    while (i > 0) {
      if (i-7 >= 0 && S.substring(i-7, i).equals("dreamer")) {
        i -= 7;
      } else if (i-6 >= 0 && S.substring(i-6, i).equals("eraser")) {
        i -= 6;
      } else if (i-5 >= 0
                 && (S.substring(i-5, i).equals("erase")
                     || S.substring(i-5, i).equals("dream"))) {
        i -= 5;
      } else {
        break;
      }
    }
    System.out.println(i == 0 ? "YES" : "NO");
  }
}

Measured memory_bytes: 28076
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

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


Measured memory_bytes: 256