akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define N 100000
int CanLay(int n, int k, int m, int weight[]);
int CanLay(int n, int k, int m, int weight[]){
    int i;
    int sum = 0;
    int num = 1;
  
    for(i = 0; i < n; i++){
        if(weight[i] > m) return 0;
        sum += weight[i];
        if(sum > m){
            sum = weight[i];
            num++;
        }
    }
    if(num <= k) return 1;
    
    else return 0;
}
 
int main(){
  int i,n,k,l,m,r;
  int weight[N];
  
  scanf("%d %d",&n,&k);
  
  for(i=0;i<n;i++) scanf("%d",&weight[i]);
  l = 0;
  r = 10000*n/k;
    while(1){
        m = (l + r) / 2;
        if(l == m) break;
        if(CanLay(n, k, m, weight)) r = m;      
        else l = m;
      }
    printf("%d\n", r);
    return 0;
}

Measured memory_bytes: 988
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD=1000000007;
ll n;
ll a[1000005];
bool y[1000005];
bool x=false;
bool X=false;
ll gcd(ll a,ll b){
    if(b%a==0) return a;
    else return gcd(b%a,a);
}
ll p[100000];
ll pp=0;
map<ll,ll> prime_factor(ll n){
    map<ll,ll> res;
    for(ll i=2;i*i<=n;i++){
        bool w=true;
        while(n%i==0){
            res[i]++;
            n=n/i;
            if(w){
                w=false;
                p[pp]=i;
                pp++;
            }
        }
    }
    if(n!=1){
        res[n]=1;
        p[pp]=n;
        pp++;
    }
    return res;
}
int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    if(n<10000000){
        for(int i=0;i<n;i++){
            pp=0;
            map<ll,ll> k=prime_factor(a[i]);
            for(int j=0;j<pp;j++){
                if(y[p[j]]){
                    X=true;
                    break;
                }else{
                    y[p[j]]=true;
                }
            }
            if(X){
                break;
            }
        }
        if(X){
            
        }else{
            cout<<"pairwise coprime"<<endl;
            return 0;
        }
    }
    ll g=a[0];
    for(int i=1;i<n;i++){
        g=gcd(g,a[i]);
    }
    if(g==1){
        cout<<"setwise coprime"<<endl;
    }else{
        cout<<"not coprime"<<endl;
    }
    
}


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

int main(){
	int str,k = 0;
  string s;
  long long r = 0,g = 0,b = 0;
  cin >> str >> s;
  for(auto s1 : s){
 	if(s1 == 'R'){
		++r;
    }else if(s1 == 'G'){
      ++g;
    }else{
      ++b;
    }
  }
  long long ans = r* g* b;
  long long sub = 0;
    for (int i = 0;i < str;++i) {
        for (int j = i+1;j < str;++j) {
            if (s[i] == s[j]) continue;
            k = j*2-i;
            if (k >= str || s[k] == s[i] || s[k] == s[j]) continue;
            ++sub;
        }
    }

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

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

int main() {
  int N,A,B;  A = 0; B = 0;
  cin >> N;
  vector<int> vec(N);
  for(int i=0; i < N; i++)
   cin >> vec.at(i);
  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  for(int i=0; i < N; i++){
    if(i%2==0)
     A = A + vec.at(i);
    
    else
     B = B + vec.at(i);
  }

  cout << A-B << endl;   
}


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

struct UnionFind {
    vector<int> size, parents;
    UnionFind(int n){
        size.resize(n,0);
        parents.resize(n,0);
        for(int i = 0; i < n; i++){
            makeTree(i);
        }
    }
    void makeTree(int x){
        parents[x] = x;
        size[x] = 1;
    }
    bool isSame(int x, int y){return findRoot(x) == findRoot(y);}
    void unite(int x, int y){
        x = findRoot(x);
        y = findRoot(y);
        if(size[x] > size[y]){
            parents[y] = x;
            size[x] += size[y];
        }else{
            parents[x] = y;
            size[y] += size[x];
        }
    }
    int findRoot(int x){
        if(x != parents[x]){
            parents[x] = findRoot(parents[x]);
        }
        return parents[x];
    }
    int treeSize(int x){return size[findRoot(x)];}
};

struct Edge{int u, v, cost;};

bool comp(const Edge &e1, const Edge &e2){return e1.cost < e2.cost;}

vector<Edge> edges;
int V, E;

int kruskal(){
    sort(edges.begin(), edges.end(), comp);
    UnionFind uf = UnionFind(V);
    int res = 0;
    for(int i = 0; i < E; i++){
        Edge e = edges[i];
        if(!uf.isSame(e.u, e.v)){
            uf.unite(e.u, e.v);
            res += e.cost;
        }
    }
    return res;
}

int main(){
    cin >> V >> E;
    rep(i,E){
        int s, t, w;
        cin >> s >> t >> w;
        Edge e = {s, t, w};
        edges.push_back(e);
    }
    int ans = 0;
    ans = kruskal();
    cout << ans << endl;
}


Measured memory_bytes: 4516
import java.util.Scanner;

public class Main {
        public static void main(String[] args) {
                Scanner scan = new Scanner(System.in);

                long A = scan.nextLong();
                long V = scan.nextLong();
                long B = scan.nextLong();
                long W = scan.nextLong();
                long T = scan.nextLong();

                scan.close();

                boolean isCatch = false;

                long distance;

                if (A > B) {
                	distance = A - B;
                } else {
                	distance = B - A;
                }

                long hayasaNoSa = V - W;

                if (distance <= hayasaNoSa * T) {
                	isCatch = true;
                }

                if (isCatch) {
                	System.out.println("YES");
                } else {
                	System.out.println("NO");
                }

        }

}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int x,y;
    cin>>x>>y;
    int ans = -1;
    for(int i=1;i<=1000000;++i)
    {
        int first = i * 0.08;
        int second = i * 0.1;
        if(first==x && second==y){
            ans = i;
            break;
        }
    }
    cout<<ans;
}



Measured memory_bytes: 256
n, m = map(int, input().split())
x = [0 for i in range(n)]
y = [0 for i in range(m)]
st = input().split()
for i in range(n):
    x[i] = int(st[i])
st = input().split()
for i in range(m):
    y[i] = int(st[i])

p = 10 ** 9 + 7

X = 0; Y = 0
for i in range(n):
    X += x[i]*(2*i-n+1)
    X = X % p
for i in range(m):
    Y += y[i]*(2*i-m+1)
    Y = Y % p

print((X*Y) % p)


Measured memory_bytes: 24444
import re
s = input()
sub = re.sub('BC', 'X', s)

ans = 0
a = 0
for i in range(len(sub)):
    if sub[i] == 'A':
        a += 1
    elif sub[i] == 'X':
        ans += a
    else:
        a = 0

print(ans)

Measured memory_bytes: 5480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {

			int a = sc.nextInt();
			String op = sc.next();
			int b = sc.nextInt();
			int ans = 0;

			if(op.equals("?"))
				break;
			if(op.equals("+")) {
				ans = a + b;
			} else if(op.equals("-")) {
				ans = a - b;
			} else if(op.equals("*")) {
				ans = a * b;
			} else if(op.equals("/")) {
				ans = a / b;
			}

			System.out.println(ans);
			//sc.close();

		}

	}

}

Measured memory_bytes: 26096
n=int(input())
l=[list(map(int,input().split())) for i in range(n)]
L=[]
for j in range(n):
  L.append([l[j][0]+l[j][1],j])
L.sort()
L.reverse()
c=0
for k in range(n):
  if k%2==0:
    c+=l[L[k][1]][0]
  else:
    c-=l[L[k][1]][1]
print(c)

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

#define int ll
typedef long long ll;

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define ALL(s) (s).begin(),(s).end()
#define ALLn(s,n) s,s+n
#define F first
#define S second
#define pb push_back
#define tc(t) int t; cin >> t; while(t--)
#define _ ios_base::sync_with_stdio(false); cin.tie(NULL);
#define D1(x) { cerr << " [" << #x << ": " << x << "]\n"; }
#define D2(x) { cerr << " [" << #x << ": "; for(auto it:x) cerr << it << " "; cerr << "]\n"; }

const ll MOD = 1e9 + 7;
const ll MAXN = 1e6 + 7;
const ll INF = LONG_LONG_MAX;

bool cmp(int a, int b) {
	return a > b;
}

void solve() {
	string s,t;
	cin >> s >> t;

	int sz = s.size();
	int cnt = 0;
	for(int i = 0; i < sz; ++i) if(s[i]!=t[i]) cnt++;

	cout << cnt << '\n';
}

int32_t main() {_
	
#ifndef ONLINE_JUDGE
	freopen("in", "r", stdin);
	freopen("out", "w", stdout);
#endif

	// tc(t)
		solve();
	cerr << "[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
}



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

using namespace std;
const int N = 1e5 + 1, MOD = 1e9 + 7;

struct Point {
	int x, y, i;
	bool operator<(Point p) const {
		if (x == p.x) {
			return y < p.y;
		}
		return x < p.x;
	}
};

int mpA[N], mpB[N];
Point a[N], b[N];
int n;
set<pair<int, int>> segmentsX, segmentsY;
void doStuff(int index, set<pair<int, int>> &segments) {
	auto rit = segments.upper_bound({index, index});
	if (rit != segments.begin() && index == prev(rit)->second + 1) {
		auto p = *prev(rit);
		segments.erase(prev(rit));
		++p.second;
		segments.insert(p);
	} else if (rit != segments.end() && index == rit->first - 1) {
		auto p = *rit;
		segments.erase(rit);
		--p.first;
		segments.insert(p);
	} else {
		segments.insert({index, index});
	}
	rit = segments.upper_bound({index, index});
	if (rit != segments.begin() && rit != segments.end() && prev(rit)->second == rit->first) {
		auto p = *prev(rit);
		segments.erase(prev(rit));
		p.second = rit->second;
		segments.erase(rit);
		segments.insert(p);
	}
}

long long prim(int root) {
	bool vis[N] = {};
	priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q; // cost 	node
	q.push({0, root});
	long long result = 0;
	while (q.size()) {
		pair<int, int> cur = q.top();
		q.pop();
		if (vis[cur.second]++)
			continue;
		result += cur.first;
		int indexA = mpA[cur.second], indexB = mpB[cur.second];
		
		doStuff(indexA, segmentsX);
		doStuff(indexB, segmentsY);
		
		auto it = prev(segmentsX.upper_bound({indexA, 1e9}));
		int leftA = it->first - 1, rightA = it->second + 1;
		if (0 <= leftA && leftA < n) {
			q.push({abs(a[indexA].x - a[leftA].x), a[leftA].i});
		}
		if (0 <= rightA && rightA < n) {
			q.push({abs(a[indexA].x - a[rightA].x), a[rightA].i});
		}
		it = prev(segmentsY.upper_bound({indexB, 1e9}));
		int leftB = it->first - 1, rightB = it->second + 1;
		if (0 <= leftB && leftB < n) {
			q.push({abs(b[indexB].x - b[leftB].x), b[leftB].i});
		}
		if (0 <= rightB && rightB < n) {
			q.push({abs(b[indexB].x - b[rightB].x), b[rightB].i});
		}
	}
	return result;
}

int main() {
//#ifndef ONLINE_JUDGE
//	freopen("input.in", "r", stdin);
//#endif
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d %d", &a[i].x, &a[i].y);
		a[i].i = i;
		b[i] = {a[i].y, a[i].x, i};
	}
	sort(a, a + n);
	sort(b, b + n);
	for (int i = 0; i < n; ++i)
		mpA[a[i].i] = i, mpB[b[i].i] = i;
	printf("%lld\n", prim(0));
	return 0;
}

Measured memory_bytes: 7796
#include<bits/stdc++.h>
#define int long long
#define out(x) cerr << #x << " = " << x << "\n"
using namespace std;
typedef long long ll;
//by piano
template<typename tp> inline void read(tp &x) {
  x = 0;char c = getchar();bool f = 0;
  for(; c < '0' || c > '9'; f |= (c == '-'), c = getchar());
  for(; c >= '0' && c <= '9'; x = (x << 3) + (x << 1) + c - '0', c = getchar());
  if(f) x = -x;
}
const int N = 2e6 + 2333, inf = 1e16 + 233, mo = 1e9 + 7;
struct P {
  int x, v;
}p[N];
int n, v[N], a[N], M, L[N], R[N], b[N];
inline bool cmp_x(P a, P b) {return a.x < b.x || a.x == b.x && a.v < b.v;}
inline int Qmin(int s, int t, int ans = inf) {
  if(s > t) return ans;
  for(s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
    if(~s & 1) ans = min(ans, a[s ^ 1]);
    if(t & 1) ans = min(ans, a[t ^ 1]);
  }return ans;
}
inline int Qmax(int s, int t, int ans = 0) {
  if(s > t) return ans;
  for(s += M - 1, t += M + 1; s ^ t ^ 1; s >>= 1, t >>= 1) {
    if(~s & 1) ans = max(ans, b[s ^ 1]);
    if(t & 1) ans = max(ans, b[t ^ 1]);
  }return ans;
}
vector<int> vec[N];
int tr[N];
inline void U(int &x, int y) {for(x += y; x >= mo; x -= mo);}
inline void A(int u, int v) {for(; u <= n; u += u & -u) U(tr[u], v);}
inline int Q(int u) {int ans = 0; if(u <= 0) return 0; for(; u >= 1; u -= u & -u) U(ans, tr[u]); return ans;}
inline int GetSum(int s, int t) {return ((Q(t) - Q(s - 1)) % mo + mo) % mo;}
inline void f__k() {
  static int x[N], v[N];
  for(int i = 1; i <= n; i ++)
    x[i] = p[i].x, v[i] = p[i].v;
  sort(x + 1, x + n + 1);
  sort(v + 1, v + n + 1);
  for(int i = 1; i <= n; i ++)
    p[i].v = lower_bound(v + 1, v + n + 1, p[i].v) - v,
      p[i].x = lower_bound(x + 1, x + n + 1, p[i].x) - x;
}

main() {
//  freopen("1.in", "r", stdin);
//  freopen("30.out", "w", stdout);
  read(n);
  for(int i = 1; i <= n; i ++)
    read(p[i].x), read(p[i].v);
  f__k();
  sort(p + 1, p + n + 1, cmp_x);
  for(M = 1; M <= n + 1; M ++);
  memset(a, 68, sizeof(a));
  for(int i = 1; i <= n; i ++)
    a[i + M] = b[i + M] = p[i].v;
  for(int i = M; i; i --) {
    a[i] = min(a[i << 1], a[i << 1 | 1]);
    b[i] = max(b[i << 1], b[i << 1 | 1]);
  }
  for(int i = 1; i <= n; i ++) {
    L[i] = Qmin(i, n), R[i] = Qmax(1, i);
    vec[R[i]].push_back(L[i]);
    // cout << L[i] << " " << R[i] << " " << p[i].x << " " << p[i].v << "\n";
    p[i].x = R[i];
    p[i].v = L[i];
  }
  int ans = 0;
  sort(p + 1, p + n + 1, cmp_x);
  for(int i = 1; i <= n; i ++) {
    int l = p[i].v, r = p[i].x, res = 0;
    if(l == 1) ++ res;
    U(res, GetSum(max(1ll, l - 1), r));
    A(r, res);
  }
  cout << GetSum(n, n) << "\n";
}

Measured memory_bytes: 98176
#include <iostream>
#include <cmath>
#include <algorithm>

using namespace std;

int main() {

	int n, a, b;
	cin >> n >> a >> b;

	int MAX, MIN;

	MIN = 0;
	if (n - (a + b) < 0) {
		MIN = a + b - n;
	}
	MAX = min(a, b);

	cout << MAX << ' ' << MIN << endl;

	return 0;
}

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

int main(void) {
	int a, b, n,x;

	std::cin >> n >> a >> b;
	if (a*n >= b) {
		std::cout << b;
	}else if (a*n < b) {
		std::cout << a*n;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
    
        double r = scan.nextDouble();
        double f1;
        double f2;
        f1 = r * r * Math.PI;
        f2 = 2 * r * Math.PI;
        System.out.printf("%f %f\n", f1,f2);
        
        
        
       
        }
    }
    
        


Measured memory_bytes: 28288
#include <bits/stdc++.h>
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define debug(x) cout<<#x<<":"<<x<<" "
#define all(a) (a).begin(), (a).end()
#define cast static_cast
#define vi vector<int>
#define v vector
#define p pair
#define push_back pb
#define mkae_pair mk
typedef long long int ll;
using namespace std;
ll modF=1e9+7;
ll INF=1e11;

void solve(){
	int n;
	cin>>n;
	if(n%1000!=0)
		cout<<1000-n%1000<<"\n";
	else{
		cout<<0<<"\n";
	}
}	

int main(){
	boost_io;
	solve();
	return 0;
}


Measured memory_bytes: 3644
k,n = list(map(int, input().split()))
a = list(map(int, input().split()))

a0 = a[-1]
ans = [a[0] - (a0 -k)]
a0 = a[0]
for i in a[1:]:
    ans.append(i - a0)
    a0 = i

print(k - max(ans))

Measured memory_bytes: 87628
#include<stdio.h>
#include<limits.h>
#include<list>
struct S{int s,e,i;}s;
typedef std::list<S>L;
int main()
{
	int n,x,y,z;
	char c;
	L l;
	L::iterator i;
	while(scanf("%d",&n),n)
	{
		l.clear();
		s.s=s.e=s.i=INT_MAX;
		l.push_back(s);
		while(n--)
		{
			scanf(" %c%d",&c,&x);
			if(c=='W')
			{
				scanf("%d",&y);
				for(i=l.begin(),z=0;y>0;)
				{
					if(z>=i->s)z=i->e+1,++i;else
					{
						s.s=z;
						s.i=x;
						if(y <= i->s-z)						s.e=z+y-1,y=0;
						else s.e=i->s-1,y-=s.e-s.s+1;
						i=l.insert(i,s);
					}
				}
			}
			else if(c=='D')
			{
				for(i=l.begin();i!=l.end();)
					if(i->i==x)i=l.erase(i);
					else++i;
			}
			else
			{
				for(i=l.begin();i!=l.end();++i)
					if(i->s<=x&&x<=i->e){printf("%d\n",i->i);goto E;}
				puts("-1");
E:;
			}
		}
		puts("");
	}
	return 0;
}

Measured memory_bytes: 904
#include <iostream>

using namespace std;

int main()
{
	int count[101] = {0};
	int a;
	
	while ( cin >> a ) count[a]++;
	
	int max_freq = 0;
	for (int i=1; i<=100; i++) {
		if (max_freq < count[i]) max_freq = count[i];
	}
	for (int i=1; i<=100; i++) {
		if (count[i] == max_freq) cout << i << endl;
	}
	
	return 0;
}

Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
inline int read()
{
   int s=0,w=1;
   char ch=getchar();
   while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
   while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
   return s*w;
}
inline void write(int x)
{
    if(x<0)
	{
    	putchar('-');
		x=-x;
	}
    if(x>9)
		write(x/10);
    putchar(x%10+'0');
}
int main()
{
	ios::sync_with_stdio(false);
	int a,b,c,d,x,y;
	a=read();
	b=read();
	c=read();
	d=read();
	x=a*b;
	y=c*d;
	if(x>y) write(x);
	else write(y);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<ll,ll>;
#define For(i,a,b)  for(int i=a;i<=b;i++)
#define Forr(i,a,b) for(int i=a;i>=b;i--)
#define F first
#define S second
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define bpc __builtin_popcount
#define MOD (ll)(1e9+7)
#define INF (1e18)
#define EPS (1e-6)
#define NATHANLEE_IS_EVIL_AND_ELECTRIC true
#define int ll
#ifdef LOCAL_TEST
#define debug(...) do{\
	cerr<<__PRETTY_FUNCTION__<<" - "<<__LINE__<<\
	" : ("#__VA_ARGS__<<") = ";\
	_OUT(__VA_ARGS__);\
}while(0)
template<typename T>void _OUT(T x){cerr<<x<<"\n";}
template<typename T,typename...I>void _OUT(T x,I ...tail){cerr<<x<<", ";_OUT(tail...);}
#else
#define debug(...)
#endif
void INIT(){
#ifdef LOCAL_TEST
	freopen("D:\\input.in","r",stdin);
	freopen("D:\\output.out","w",stdout);
	freopen("D:\\error.out","w",stderr);
#endif
	ios::sync_with_stdio(!NATHANLEE_IS_EVIL_AND_ELECTRIC);
	cin.tie(0);
}

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; }
ll fpow(ll b,ll p){
	b%=MOD;
	ll ans=1;
	while(p>0){
		if(p&1) ans=(ans*b)%MOD;
		p/=2;
		b=(b*b)%MOD;
	}
	return ans;
}

int dp[22][2100000];
bool ok[21][21];

int32_t main() {
	INIT();
	//code...
	int n; cin>>n;
	For(i,0,n-1) For(j,0,n-1){
		cin>>ok[i][j];
	}
	dp[0][0]=1;
	For(i,1,(1<<n)-1) dp[0][i]=0;
	For(i,1,n) For(mask,0,(1<<n)-1){
		dp[i][mask]=0;
		if(__builtin_popcount(mask)==i) For(j,0,n-1){
			if(ok[i-1][j] && (mask&(1<<j))) dp[i][mask]+=dp[i-1][mask^(1<<j)];
			dp[i][mask]%=MOD;
		}
	}
	cout<<dp[n][(1<<n)-1]<<"\n";
	return 0;
}

Measured memory_bytes: 364068
n, k = tuple(map(int, input().split()))
arr = [0 for i in range(n)]
sums = 0
for i in range(n):
    inp = int(input())
    arr[i] = inp

arr.sort()

sa = 1000000000
for i in range(n-k+1):
    newsa = arr[i+k-1] - arr[i]
    if newsa < sa:
        sa = newsa

print(sa)


Measured memory_bytes: 7428
import java.util.Scanner;

public class Main {
  public static void main (String[] args) {
    Scanner in = new Scanner(System.in);
    
    while (in.hasNext()) {
      int N = in.nextInt();
      int f = 0;

      for (int i = 0; i < N; ++i) {
        f += in.nextInt() - 1;
      }

      System.out.println(f);
    }
  }
}

Measured memory_bytes: 27624
#include <iostream>
#include <cstdio>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];

int main()
{
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ll ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = d;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (d - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            ans2 -= a[i][t[i]];
            for(ll j = 1; j <= 26; j++)
            {
                ans += (d - b[j]) * c[j];
            }
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = d;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (d - b[j]) * c[j];
        }
        ans += a[i][t[i]];
        printf("%lld\n", mi);
    }
    return 0;
}


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

int main(){
  ll n;
  cin>>n;
  vector<ll> h(n);
  rep(i,n){
    cin>>h.at(i);
  }
  vector<ll> v(n);
  rep(i,n-1){
    v.at(i) = h.at(i)-h.at(i+1);
  }
  int ans=0,sum=0;
  rep(i,n-1){
    if (v.at(i)>=0){
      sum++;
    }
    else{
      ans = max(sum,ans);
      sum=0;
    }
  }
  ans = max(sum,ans);
  cout << ans << endl;
}

Measured memory_bytes: 1792
// RAM RAM

#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define ppb pop_back
#define vi vector<int>
#define mp make_pair
#define arrayin(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define N 55

using namespace std;
 


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

    int h,w;cin>>h>>w;
    char pic[h+1][w+1];
    for(int i=1;i<=h;i++){
    	for(int j=1;j<=w;j++){
    		cin>>pic[i][j];
    	}
    }
    char pic2[2*h+2][w+1];

    for(int i=1;i<=2*h;i++){
    	for(int j=1;j<=w;j++){
    		int r=(i+1)/2;
    		int c=j;
    		pic2[i][j]=pic[r][c];
    	}
    }

    for(int i=1;i<=2*h;i++){
    	for(int j=1;j<=w;j++){
    		cout<<pic2[i][j];
    	}cout<<endl;
    }

	return 0;
}

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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b,c,d;
    Scd2(a,b);
    Scd2(c,d);
  
  
    

    printf("%d\n", (a-c)*(b-d) );


    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int LinearSearch(int);

int ori[10000],n; 

int main()
{
  int i,j,key[500],m,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&ori[i]);
  }

  scanf("%d",&m);
   for(j=0;j<m;j++){
    scanf("%d",&key[j]);
    count+=LinearSearch(key[j]);
   }

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

   return 0;

}

int LinearSearch(int key)
{
  int i;
  
  i=0;
  ori[n]=key;
  while(ori[i]!=key){
    i++;
    if(i==n) return 0;
  }
  return 1;
}
     



Measured memory_bytes: 2108
from sys import stdin


def main():
    _in = [_.rstrip() for _ in stdin.readlines()]
    T =     _in[0]   # type:str
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    T = T.replace('?','D')
    #cnt = T.count('PD') + T.count('D')
    # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(T)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63404
import static 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();

		while(n--!=0){
			String max = "";
			String min = "";

			char[] c = sc.next().toCharArray();
			sort(c);

			for(int i = 0;i < c.length;i++){
				min += c[i];
				max += c[c.length-1-i];
			}
			System.out.println(Integer.parseInt(max)-Integer.parseInt(min));
		}
	}
}

Measured memory_bytes: 25792
N,M,V,P = list(map(int,input().split()))
A = list(map(int,input().split()))

A.sort(reverse  = True)

B = [0]
b = 0

for i in range(N):
    b+=A[i]
    B.append(b)

count = 0

def bisect(x,l,r):
    if A[l]<=x:
        return l-1
    elif A[r]>x:
        return r
    while r-l > 1:
        if A[(l+r)//2]>x:
            l = (l+r)//2
        else:
            r = (l+r)//2
    return l

for i in range(N):
    if i <= N-V+P-1:
        if A[i]+M>=A[P-1]:
            count+=1
    else:
        if A[i]+M>=A[P-1]:
            """
            index = bisect(A[i]+M,0,i-1)
            if index==-1:
                if (i*(A[i]+M) - B[i])%(V-(N-i)) == 0:
                    if (i*(A[i]+M) - B[i])//(V-(N-i)) >= M:
                        count+=1
                        print(A[i])
                else:
                    if (i*(A[i]+M) - B[i])//(V-(N-i)) >= M-1:
                        count+=1
                        print(A[i])
            else:
                if ((i-index-1)*(A[i]+M) - (B[i]-B[index+1]))%(V-(N-i)-(index+1)) == 0:
                    if ((i-index-1)*(A[i]+M) - (B[i]-B[index+1]))//(V-(N-i)-(index+1)) >= M:
                        count+=1
                        print(A[i])
                else:
                    if ((i-index-1)*(A[i]+M) - (B[i]-B[index+1]))//(V-(N-i)-(index+1)) >= M-1:
                        count+=1
                        print(A[i])
            """
            #print("x",A[i])
            #print(((i-P+1)*(A[i]+M) - (B[i]-B[P-1])))
            #print((V-(N-i)-(P-1)))
            if ((i-P+1)*(A[i]+M) - (B[i]-B[P-1]))%(V-(N-i)-(P-1)) == 0:
                if ((i-P+1)*(A[i]+M) - (B[i]-B[P-1]))//(V-(N-i)-(P-1)) >= M:
                    count+=1
            else:
                if ((i-P+1)*(A[i]+M) - (B[i]-B[P-1]))//(V-(N-i)-(P-1)) >= M:
                    count+=1

print(count)

Measured memory_bytes: 63768
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <deque>
#define ll long long

using namespace std;

vector<int>A;
int k;


vector<int> CountingSort() {
	vector<int>C(k + 1, 0);
	for (int i = 0; i < A.size(); i++) {
		C[A[i]]++;
	}
	for (int i = 1; i <= k; i++) {
		C[i] = C[i - 1] + C[i];
	}
	vector<int>B(A.size());
	for (int i = A.size() - 1; i >= 0; i--) {
		B[C[A[i]] - 1] = A[i];
		C[A[i]]--;
	}
	return B;
}

int main() {
	int N; cin >> N;
	A.assign(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		k = max(k, A[i]);
	}

	vector<int> B = CountingSort();
	for (int i = 0; i < B.size(); i++) {
		if (i != 0) cout << " ";
		cout << B[i];
	}
	cout << endl;



	return 0;
}





Measured memory_bytes: 18416
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(size_t i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(size_t i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF INT_MAX/2
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
template<typename T> pair<vector<T>,int> getAuto() {int N; cin >> N; pair<vector<T>, int> rt;rt.first.resize(N);rt.second = N;REP(i, N) cin >> rt.first[i];return rt;}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }

int main() {
	int W, a, b;
	cin >> W >> a >> b;
	if (a > b)swap(a, b);
	IfeOut(a + W > b, 0,b-(a+W));

}



Measured memory_bytes: 256
// I make this just for fun because i'm done
// Aimi Haraguni >> Konomi Suzuki >> Yui >>  Ikimono Gakari >> Garnidelia >> Kalafina >> Eir Aoi.   .. dude? 
// problems that involves any kind of persistent data structures are the best of the best, are not them?
 
// #pragma GCC optimize ("Ofast,unroll-loops")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
 
#define pb push_back
#define ff  first
#define ss second
#define tm1 first
#define tm2 second.first
#define tm3 second.second
#define sz(x) ll(x.size())
#define fill(x, v) memset(x, v, sizeof(x))
#define all(v) (v).begin(), (v).end()
#define FER(i,a,b) for(ll i=ll(a); i< ll(b); ++i)
#define IFR(i,a,b) for(ll i=ll(a); i>=ll(b); --i )
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
 
#define N 2010
// #define M 19
 
#define mod 2019
#define mod1 1000000007
#define mod2 1000000009
#define bas 987625403
#define sqr(x) (x)*(x)  
#define INF 2000000000000000000
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef pair<ll, ll> ii;
typedef pair<ll, ii > tri;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef tree<pair<ll, ll>, null_type, less<pair<ll, ll>>, rb_tree_tag, tree_order_statistics_node_update> set_t;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
#define trace(...) fff(#__VA_ARGS__, __VA_ARGS__)
 
template<typename t> void fff(const char* x, t&& val1){
    cout<<x<< " : "<<val1<<endl;
}
template<typename t1, typename... t2> void fff(const char* x, t1&& val1, t2&&... val2){
    const char* xd=strchr(x+1, ',');
    cout.write(x, xd-x)<<" : "<<val1<<" | ";
    fff(xd+1, val2...);
}

inline ll bp(ll a, ll n, ll m){
	if(!n) return 1LL%m;
	if(n&1) return (a*bp(a, n-1, m))%m;
	ll x = bp(a, n>>1, m);
	return sqr(x)%m;
}

ll dp[1<<18];
int main(){
	fastio;
	dp[0]=1;
	FER(i, 1, 2e5+2) dp[i]=(dp[i-1]*10)%mod;
	string s; cin>>s;
	ll n=sz(s);
	map<ll, ll> m;
	ll ans = 0, resp = 0;
	IFR(i, n-1, 0){
		ll coe = s[i]-'0';
		ll expo = n-1-i;
		// trace(coe, dp[expo]);
		ans = ((coe * dp[expo])%mod + ans)%mod;
		// trace(i, ans);
		m[ans]++;
	}
	// for(auto xd: m) trace(xd.ff, xd.ss);
	ans = 0;
	IFR(i, n-1, 0){
		ll need = (mod + ans + mod)%mod;
		// need = (need *dp[n-1-i])%mod;
		// trace(i, need);
		resp += m[need];
		ll coe = s[i]-'0';
		ll expo = n-1-i;
		ans = ((coe*dp[expo])%mod + ans)%mod;
		// trace(ans, i);
		m[ans]--;
		if(!m[ans]) m.erase(ans);
	}
	// trace(ans);
	ll aea = (mod-ans + mod)%mod;
	// trace(aea);
	// for(auto xd: m) trace(xd.ff, xd.ss);
	cout<<resp<<"\n";
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<ll(n);i++)
#define YESNO(T) if(T){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define yesno(T) if(T){cout<<"yes"<<endl;}else{cout<<"no"<<endl;}
#define YesNo(T) if(T){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
const double pi = 3.14159265358979;



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

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

    ll x = 0;
    for (ll i = 0; i < n; i++){
        x = x^a[i];
    }

    for (ll i = 0; i < n; i++){
        cout << (x^a[i]) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 4696
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
d,x = inpl()
a = inpln(n)
cnt = 0
for i in range(n):
    for j in range(10000):
        tmp = a[i] * j + 1
        if tmp <= d:
            cnt += 1
        else:
            break
print(cnt+x)

Measured memory_bytes: 39536
#include <stdio.h>

#define MOD_BY 998244353

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int sub(int a, int b) {
	return b == 0 ? a : add(a, MOD_BY - b);
}

#define KI_MAX 212345

int ki[KI_MAX];

void ki_add(int idx, int value) {
	idx++;
	while (idx < KI_MAX) {
		ki[idx] = add(ki[idx], value);
		idx += idx & -idx;
	}
}

int ki_sum(int idx) {
	int ret = 0;
	if (idx < 0) return 0;
	idx++;
	if (idx >= KI_MAX) idx = KI_MAX - 1;
	while (idx > 0) {
		ret = add(ret, ki[idx]);
		idx -= idx & -idx;
	}
	return ret;
}

/* [s, e] */
int ki_sum2(int s, int e) {
	return sub(ki_sum(e), ki_sum(s - 1));
}

int N, K;
int L[16], R[16];

int main(void) {
	int i;
	if (scanf("%d%d", &N, &K) != 2) return 1;
	for (i = 0; i < K; i++) {
		if (scanf("%d%d", &L[i], &R[i]) != 2) return 1;
	}
	ki_add(N, 1);
	for (i = N - 1; i >= 1; i--) {
		int mofu = 0;
		int j;
		for (j = 0; j < K; j++) {
			mofu = add(mofu, ki_sum2(i + L[j], i + R[j]));
		}
		ki_add(i, mofu);
	}
	printf("%d\n", ki_sum2(1, 1));
	return 0;
}


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

using namespace std;

typedef long long int LL;
typedef int ll;
typedef string str;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef stringstream strs;

#define X first
#define Y second
#define PB push_back
#define For(i,a,b) for (int i=a;i<b;i++)
#define Ford(i,a,b) for (int i=a;i>=b;i--)
#define smax(a,b) a=max(a,b)
#define smin(a,b) a=min(a,b)
#define SZ(a) ((ll)a.size())
#define ER(a) cout << #a << ' ' << a << endl
#define LB(a,n,x) (lower_bound(a,(a)+(n),x)-(a))

const ll M=2e5+5,LG=19,SM=2000+5,inf=1e9+1;
ll mod=1e9+7;

str z[3]={"Positive","Negative","Zero"};

void ret(ll x)
{
    cout << z[x] << '\n';
    exit(0);
}

int main()
{
	ios::sync_with_stdio(0);
    ll a,b;
    cin >> a >> b;
    if (a>0)
        ret(0);
    if (b<0)
    {
        if ((b-a)%2)
            ret(0);
        ret(1);
    }    
    ret(2);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

var scanner = bufio.NewScanner(os.Stdin)

func scanLine() []int {
	var s []int
	scanner.Scan()
	for _, v := range strings.Split(scanner.Text(), " ") {
		i, _ := strconv.Atoi(v)
		s = append(s, i)
	}
	return s
}

func main() {
	scanner.Buffer([]byte{}, 1000000000)

	var n int
	fmt.Scan(&n)

	a := scanLine()
	b := scanLine()
	c := scanLine()

	sort.Ints(a)
	sort.Ints(b)
	sort.Ints(c)

	ans := 0
	for _, v := range b {
		aIndex := sort.Search(n, func(i int) bool { return a[i] >= v }) - 1
		bIndex := sort.Search(n, func(i int) bool { return c[i] > v })
		ans += (aIndex + 1) * (n - bIndex)
	}
	fmt.Println(ans)
}


Measured memory_bytes: 14720
def s():
 n=int(input())+1
 e=[input().split()for _  in[0]*~-n]
 p=[int(e[0][0])]+list(int(x[1])for x in e)
 m=[[0]*n for _ in[0]*n]
 for i in range(n):
  for r in range(n-i-1):
   c=r+i+1
   for j in range(r+1,c):
    x=m[r][j]+m[j][c]+p[r]*p[j]*p[c]
    if not 0<m[r][c]<x:m[r][c]=x
 print(m[r][c])
if'__main__'==__name__:s()


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

int n, m;

int main() {
    cin >> n;
    cout << n << ": ";
    m=n;
    for (int i=2; i*i<=m; i++) {
        if (m%i == 0) {
            cout << i << " ";
            m/=i;
            i-=1;
        }
    }
    cout << m << endl;
}


Measured memory_bytes: 3124
#include<bits/stdc++.h>
#define fi first
#define f first
#define se second
#define s second
#define vi_a vector<int>a;
#define p_b push_back
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define m_p make_pair
#define fast_io cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
#define all(x) x.begin(),x.end()
#define pw(x) (1ll << x)
#define sz(x) (int)x.size()
#define endl "\n"
#define rall(x) x.rbegin(),x.rend()
#define len(a) (ll)a.size()
#define rep(x,l,r) for(ll x=l;x<r;x++)
using namespace std;
ld eps = (ld)1 / 1e15;
ll inf = 1e18, mod2 = 998244353, mod1 = 1e9 + 7;
ll sqr(ll a) { return a * a; }
ll qb(ll a) { return a * a * a; }
ll gcd(ll a, ll b) { return !a ? b : gcd(b % a, a); }
ll binpow(ll a, ll b, ll mod) { return b ? (b % 2 ? (a * (sqr(binpow(a, b / 2, mod)) % mod)) % mod : sqr(binpow(a, b / 2, mod)) % mod) : 1; }
ll binmult(ll a, ll b, ll mod) { return b ? (b % 2 ? (2 * binmult(a, b / 2, mod) + a) % mod : (2 * binmult(a, b / 2, mod)) % mod) : 0; }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
const ll to[5]={0,4,6,7,9};
const ll N=1e3+1e2;
const ll R=1e4;
//ll columns[N][26];
//ll str[N][26];
//pll cool[N][N];
signed main(){
    fast_io;
    ll a,b;
    cin>>a>>b;
    ll ans=0;
    ans+=((a-1)*a)/2;
    ans+=((b-1)*b)/2;
    cout<<ans;
    return 0;
}


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

int main() {
  long n;

  cin >> n;

  for (long i = sqrt(n); i > 0; i--) {
    if (n % i == 0) {
      cout << n / i + i - 2;
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long dfs(long h){//hのモンスターを倒す攻撃回数
  if(h==1)return 1;
  return 1+2*dfs(h/2);
}
int main(){
  long H;cin>>H;
  cout<<dfs(H);
}

Measured memory_bytes: 256
m = []
f = []
r = []
while(1):
    a,b,c = map(int,raw_input().split())
    if a == -1 and b == -1 and c == -1:
        break
    else:
        m.append(a)
        f.append(b)
        r.append(c)

for i in range(len(m)):
    if m[i] == -1 or f[i] == -1:
        print "F"
    elif m[i] + f[i] >= 80:
        print "A"
    elif m[i] + f[i] >= 65:
        print "B"
    elif m[i] + f[i] >= 50 or r[i] >= 50:
        print "C"
    elif m[i] + f[i] >= 30:
        print "D"
    else:
        print "F"


Measured memory_bytes: 4660
#include<iostream>
#include<stdio.h>
#include<stdlib.h>

using namespace std;
int ans;
int floppy[31];
int initial[] = {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 4, 4, 4, 6, 6, 6, 5, 5, 5, 3, 3, 3, 3, 3, 3, 3, 3, 3};

void change1(){
  swap(floppy[7], floppy[22]);
  swap(floppy[8], floppy[23]);
  swap(floppy[9], floppy[24]);
  swap(floppy[13], floppy[18]);
  swap(floppy[10], floppy[12]);
}

void change2(){
  swap(floppy[3], floppy[22]);
  swap(floppy[6], floppy[25]);
  swap(floppy[9], floppy[28]);
  swap(floppy[12], floppy[19]);
  swap(floppy[13], floppy[15]);
}

void change3(){
  swap(floppy[1], floppy[28]);
  swap(floppy[2], floppy[29]);
  swap(floppy[3], floppy[30]);
  swap(floppy[15], floppy[16]);
  swap(floppy[19], floppy[21]);
}

void change4(){
  swap(floppy[1], floppy[24]);
  swap(floppy[4], floppy[27]);
  swap(floppy[7], floppy[30]);
  swap(floppy[16], floppy[18]);
  swap(floppy[10], floppy[21]);
}

void solve(int k){
  int i, count=0;
  for(i=1; i<=30; i++){
    if(floppy[i]==initial[i])count+=1;
  }
  if(count==30)ans = min(ans, k);
  if(ans<=k)return ;

  change1();
  solve(k+1);
  change1();
  if(ans<=k)return ;

  change2();
  solve(k+1);
  change2();
  if(ans<=k)return ;

  change3();
  solve(k+1);
  change3();
  if(ans<=k)return ;

  change4();
  solve(k+1);
  change4();
  if(ans<=k)return ;
}

int main(){
  int N, i;
  cin >> N;
  while(N--){
    for(i=1; i<=30; i++)cin >> floppy[i];
    ans = 8;
    solve(0);
    cout << ans << endl;
  }
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int last = 0,ans = 0;
  bool boo = true;
  for(int i=0; i<S.size()-1; i++){
    if(S[i] != S[i+1]){
      boo = false;
    }
  }
  if(boo == true){
    cout << 0 << endl;
    return 0;
  }
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'R'){
      last++;
    }
  }
  for(int i=0; i<last; i++){
    if(S[i] == 'W'){
      ans++;
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 3704
nhw = input()

nhw = nhw.split(" ")
nhw = [int(x) for x in nhw]

count = 0

for i in range(nhw[0]):
  ab = input()
  ab = ab.split(" ")
  ab = [int(x) for x in ab]
  if ab[0] >= nhw[1] and  ab[1] >= nhw[2] :
    count +=1
print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s,t;
  cin>>s>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
    if(s.at(i)!=t.at(i)){
      s.at(i)=t.at(i);
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3832
#include <iostream>

using namespace std;

int main() {
    string str1, str2;
    cin >> str1 >> str2;
    
    for(int i=0; i<str1.size()+str2.size(); i++) {
        if(i%2==0) {
            cout << str1[i/2];
        } else {
            cout << str2[i/2];
        }
    }
    cout << endl;


    return 0;
    
}

Measured memory_bytes: 256
using System;

namespace XCubic
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			//??\??????
			var x = int.Parse(Console.ReadLine());
			//?????????????±???????
			double dPow = System.Math.Pow(x, 3);
			Console.WriteLine (dPow);
		}
	}
}

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

typedef long long ll;

int main()
{
    int m, n;
    while(cin >> n >> m && n && m) {
        vector<int> p(n);
        for(int i = 0; i < n; i++)
            cin >> p[i];
        
        sort(p.begin(), p.end(), greater<int>());
        
        int sum = 0;
        for(int i = 0; i < n; i++) 
            if(i / m == n / m || i % m != m - 1)
                sum += p[i];
        cout << sum << endl;
    }
}

Measured memory_bytes: 0
#include <bits/stdc++.h> 
using namespace std;
#define     mod             1e9+7
#define     ll              long long
#define     mp              make_pair
#define     t()             int test;cin>>test;while(test--)
#define     setbits(x)      __builtin_popcountll(x)
#define     si              set<int>
#define     ii              pair<int,int>
#define     vi              vector<int>
#define     que_max         priority_queue <int>
#define     que_min         priority_queue <int, vi, greater<int>>
#define     IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define     endl            '\n'

/*
	For Debugging we have define TRACE.
*/

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
        //use cerr if u want to display at the bottom
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif  

const int N = 1e7 + 5;
int a[N];
int reach [10000001];

void solve(){
	int n;
	cin>>n;
	ll sum = 1;
	for(int i=2;i<=n;i++){
		for(int j=i;j<=n;j+=i){
			a[j]++;
		}
		sum += 1ll*i*(a[i]+1);
	}
	cout<<sum;
}
 
int32_t main()
 
{  
    #ifndef ONLINE_JUDGE
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif

    IOS;

    solve();


}

Measured memory_bytes: 42704
#include<stdio.h>
#include<iostream>
using namespace std;
int main(){
  int h,w,i,j;
  char s='#',x='.';
  while(1){
    cin>>h>>w;
    if(h==0&&w==0) break;
    else if(h==w&&h%2!=0||w%2!=0){
      for(i=0;i<h;i++){
	if(i%2==0){
	  for(j=0;j<w;j++){
	    if(j%2!=0){
	      cout<<x;
	    }
	    else {
	      cout<<s;
	    }
	  }
	  printf("\n");
	}
	else{
	  for(j=0;j<w;j++){
	    if(j%2!=0){
	      cout<<s;
	    }
	    else {
	      cout<<x;
	    }
	  }
	  printf("\n");
	}
      }
    }
    else{
      for(i=0;i<h;i++){
	if(i%2==0){
	  for(j=0;j<w;j++){
	    if(j%2!=0){
	      cout<<s;
	      cout<<x;
	    }
	  }	  
	  printf("\n");
	}
	else{
	  for(j=0;j<w;j++){
	    if(j%2!=0){
	      cout<<x;
	      cout<<s;
	    }
	  }
	  printf("\n");
	}
      }
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3012
#include<iostream>
using namespace std;
 
int main(){
    int month[]={31,29,31,30,31,30,31,31,30,31,30,31};
    int sum[13];
    char *week[]={"Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday"};
    int m,d;
    sum[0]=0;
    for(int i=1;i<=12;i++)sum[i] = sum[i-1]+month[i-1];
    while(cin>>m>>d,m||d)cout<<week[(sum[m-1]+d-1)%7]<<endl;
    return 0;
}

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

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

long long int n,m,x,k,d,i,index,flag,count=0,result,odd,even,sum=0,temp;
cin>>n;
long long int a[200005];
for(i=1;i<=n;i++)
{
    cin>>a[i];
    if(a[i]%2==1 && i%2==1)
    {
        count++;
    }
}
cout<<count<<endl;

    return 0;
}


Measured memory_bytes: 3640
#include <iostream>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <sstream>
#include <string>
#include <cstdlib>
using namespace std;

template <class T> int streamvar(std::istream& in, T& var)
{
    if (!in) {
        cerr << "invalid istream" << endl;
        return 1;
    }
    in >> var;
    if (in.fail()) {
//cerr << "no var" << endl;
        return 1;
    }
    return 0;
}
template <class T> int streamvec(std::istream& in, std::vector<T> &v)
{
    v.clear();
    string s;

    if (!in) {
        cerr << "invalid istream" << endl;
        return 1;
    }
    getline(in, s);
    if (in.fail()) {
        cerr << "no line" << endl;
        return 1;
    }
    istringstream is(s);
    while (1) {
        T tmp;
        is >> tmp;
        if (is.fail())
            break;
        v.push_back(tmp);
    }
    return 0;
}

int main(void)
{
    int n;
    while (!streamvar(cin, n)) {
        int counter = 0;
        for (int a = 0; a < 10; a++) 
            for (int b = 0; b < 10; b++) 
                for (int c = 0; c < 10; c++) 
                    for (int d = 0; d < 10; d++) 
                        if (a + b + c + d == n)
                            counter++;
        cout << counter << endl;
    }
    return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
int f(int a,int b,int x){return (x?(x-1?a*b:a-b):a+b);}
int r[4];
int main(){
	while(cin>>r[0]>>r[1]>>r[2]>>r[3]&&r[0]){
		lol(q,99){string z="+-*";
			lol(i,3)lol(j,3)lol(k,3){
				if(f(f(r[0],r[1],i),f(r[2],r[3],k),j)==10){
					cout<<"("<<r[0]<<z[i]<<r[1]<<")"<<z[j]<<"("<<r[2]<<z[k]<<r[3]<<")\n";
					goto l;
				}
				if(f(f(f(r[0],r[1],i),r[2],j),r[3],k)==10){
					cout<<"(("<<r[0]<<z[i]<<r[1]<<")"<<z[j]<<r[2]<<")"<<z[k]<<r[3]<<"\n";
					goto l;
				}
			}
			if(q%6==5)swap(r[0],r[1]);
			else if(q%2==1)swap(r[1],r[2]);
			else swap(r[2],r[3]);
		}cout<<"0"<<endl;
		l:;
	}
	return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
int main(){
  int n, maxlen;
  char a[10001], b[10001];

  cin >> n;
  for(int ii = 0 ; ii < n ; ii++){
    string ans = "";
    scanf("%s %s", a, b);
    
    maxlen = max(strlen(a), strlen(b));

    reverse(a, a+strlen(a));
    reverse(b, b+strlen(b));
    
    for(int i = strlen(a) ; i < 10001 ; i++){
      a[i] = '0';
    }
    for(int i = strlen(b) ; i < 10001 ; i++){
      b[i] = '0';
    }

    int tmp, tmp2 = 0;

    for(int i = 0 ; i < maxlen ; i++){
      tmp = (a[i] - '0') + (b[i] - '0') + tmp2;
      
      if(i == maxlen - 1){
	if(tmp >= 10){
	  tmp2 = 1;
	  tmp -= 10;
	  ans += tmp + '0';
	  ans += '1';
	}
	else ans += tmp + '0';
      }

      else if(tmp >= 10){
	tmp2 = 1;
	tmp -= 10;
	ans += tmp + '0';
      }
      else if(tmp <= 9){
	ans += tmp + '0';
	tmp2 = 0;
      }
    }

    reverse(ans.begin(), ans.end());

    int size = ans.size();

    if(size > 80 || maxlen > 80) cout << "overflow" << endl;
    else cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 0