akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n,a[100010][3],f[100010][3],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d%d%d",&a[i][0],&a[i][1],&a[i][2]);
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=2;j++)
		{
			for(int k=0;k<=2;k++)
			{
				if(k!=j) f[i][j]=max(f[i-1][k]+a[i][j],f[i][j]);
			}
		}
	}
	for(int i=0;i<=2;i++)
	{
		ans=max(ans,f[n][i]);
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 2560
from collections import deque
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import permutations,combinations
from collections import defaultdict,Counter
from pprint import pprint

def myinput():
    return map(int,input().split())

def mylistinput(n):
    return [ list(myinput()) for _ in range(n) ]

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col):
    data.sort(key=lambda x:x[col],reverse=False)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

n,m,s,t = myinput()
uvab = mylistinput(m)

# Dijkstra法(O(ElogV))
# edge[i] : iから出る道の[重み,行先]の配列
# import heapq
# def dijkstra_heap(n,s,edge):
#     #始点sから各頂点への最短距離
#     d = [float("inf")] * n
#     used = [True] * n # True:未確定
#     d[s] = 0
#     used[s] = False
#     edgelist = []
#     for e in edge[s]:
#         heapq.heappush(edgelist,e)
#     while len(edgelist):
#         minedge = heapq.heappop(edgelist)
#         # まだ使われてない頂点の中から最小の距離のものを探す
#         if not used[minedge[1]]:
#             continue
#         v = minedge[1]
#         d[v] = minedge[0]
#         used[v] = False
#         for e in edge[v]:
#             if used[e[1]]:
#                 heapq.heappush(edgelist,[e[0]+d[v],e[1]])
#     return d

# Dijkstra法(O(ElogV))
# edge[i] : iから出る道の[重み,行先]の配列
# 高速化版 
import heapq
def dijkstra_heap(n,s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

g1 = [ [] for _ in range(n) ]
g2 = [ [] for _ in range(n) ]
for i in range(m):
    u = uvab[i][0] - 1
    v = uvab[i][1] - 1
    a = uvab[i][2]
    b = uvab[i][3]
    g1[u].append([a,v])
    g1[v].append([a,u])
    g2[u].append([b,v])
    g2[v].append([b,u])
# print(g1)
# print(g2)

d1 = dijkstra_heap(n,s-1,g1)
d2 = dijkstra_heap(n,t-1,g2)
# print(d1)
# print(d2)

yen = 10**15
ans = -1*float("inf")
ls_ans = [0]*n
for i in reversed(range(n)):
    snuke = yen - d1[i] - d2[i] 
    ans = max(ans,snuke)
    ls_ans[i] = ans

for i in range(n):
    print(ls_ans[i])

Measured memory_bytes: 130136
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main() {
    int A, B, K;
    cin >> A >> B >> K;

    //
    int n_small = A, n_big = max(A, B-K+1);
    int k_small = K, k_big = K;
    while ((k_small > 0 && k_big > 0)  && (A <= n_small && n_small <= B) && (A <= n_big && n_big <= B)) {
        if(n_small == n_big){
            n_small++;
            k_small--;
        }else if(n_small < n_big) {
            cout << n_small << endl;
            n_small++;
            k_small--;
        }else{
            cout << n_big << endl;
            n_big++;
            k_big--;
        }



    }

    // n_small
    while ((k_small > 0)  && (A <= n_small && n_small <= B) ) {
        cout << n_small << endl;
        n_small++;
        k_small--;
    }

    // n_big
    while ((k_big > 0) && (A <= n_big && n_big <= B)) {
        cout << n_big << endl;
        n_big++;
        k_big--;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())

ttl = n
ans = []

memo = -2
memo2 = 1

while(abs(ttl)>0):
    if ttl%memo != 0:
        ttl -= memo2
        ans.append(1)
    else:
        ans.append(0)

    memo *= (-2)
    memo2 *= (-2)

if n == 0:
    print(0)
else:
    for i in range(1,len(ans)+1):
        print(ans[-i],end = "")
    print()

Measured memory_bytes: 3064
h, w = gets.split.map(&:to_i)
s = Array.new(h + 1).map{Array.new(w + 1, 0)}
(1..h).map do |i|
  c = 0
  l = 1
  b = gets.chomp.bytes
  (1..w).map do |j|
    if b[j - 1] == 46
      l = j if c == 0
      c += 1
    elsif c > 0
      (l...j).map do |k|
        s[i][k] = c
      end
      c = 0
    end
    if j == w && c > 0
      (l..j).map do |k|
        s[i][k] = c
      end
    end
  end
end
ans = 0
(1..w).map do |j|
  c = 0
  l = 1
  (1..h).map do |i|
    if (s[i][j] > 0)
      l = i if c == 0
      c += 1
    elsif c > 0
      (l...i).map do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
      c = 0
    end
    if i == h && c > 0
      (l..i).map do |k|
        ans = s[k][j] + c if ans < s[k][j] + c
      end
    end
  end
end
puts ans - 1

Measured memory_bytes: 169156
#include <bits/stdc++.h>
 
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define INF 999999999
#define MOD 1000000007
 
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
 
int iy[]={0, 0, 1, -1};
int ix[]={1, -1, 0, 0};
 
int n, m;
string s;

int main(){
	cin >> s;
	for(int i=0;i<4;i++){
		if(s[i]=='+'){
			n++;
		}else{
			n--;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
set<int> apb[30];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n;
	string s;
	cin >> n >> s;
	for (int i = 0; i < n; ++i) {
		apb[s[i] - 'a'].insert(i);
	}
	int q;
	cin >> q;
	while (--q > -1) {
		int x;
		cin >> x;
		if (x == 1) {
			int i;
			char c;
			cin >> i >> c;
			--i;
			apb[s[i] - 'a'].erase(i);
			s[i] = c;
			apb[s[i] - 'a'].insert(i);
		} else {
			int l, r;
			cin >> l >> r;
			--r, --l;
			int cnt = 0;
			for (int i = 0; i < 26; ++i) {
				auto a = apb[i].upper_bound(l - 1);
				auto b = apb[i].upper_bound(r);
				if (a != b) {
					++cnt;
				}
			}
			cout << cnt << '\n';
		}
	}
}

Measured memory_bytes: 24220
#include <bits/stdc++.h>
#include <string>
#define INF 100000
using namespace std;
int H, W, N,K;
int sx, sy;
typedef long long ll;
int main(){
    cin >> N >> K ;
    vector<int>h(N);
    int ans =0;
    for(int i=0;i<N;i++){
        int tmp;
        cin >> tmp;
        if(tmp >= K) ans++;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 640
n = int(input())
ls = [0] + list(map(int, input().split())) + [0]
ds = [abs(a - b) for a, b in zip(ls, ls[1:])]
total = sum(ds)
for i in range(1, n + 1):
    prev = ls[i - 1]
    curr = ls[i]
    next_ = ls[i + 1]
    if prev <= curr <= next_ or prev >= curr >= next_:
        print(total)
    else:
        d = abs(next_ - prev)
        print(total + d - ds[i] - ds[i - 1])

Measured memory_bytes: 14048
#include<bits/stdc++.h>
using namespace std;
#define all(x) x.begin(),x.end()
#define EPS (int)1e-9
typedef long long ll;
typedef vector<int> vi;
#define sz(v)		((int)((v).size()))
#define OO 0x3f3f3f3f
#define  ed  '\n'
#define watch(x) cerr << '>' << #x << ':' << x << '\n';
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline int two(int n) { return 1 << n; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
#define IOS std::ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
const ll mod=1e18+9;
int main(){
//freopen("input.txt" , "r" , stdin); 
//freopen("output.txt" , "w" , stdout);
IOS;
char arr[5];
arr[0]='0';
arr[1]='1';
arr[2]='B';
string s,ans="";
cin>>s;
int n=s.size();
for (int i = 0; i < n; ++i)
{
	if(s[i]==arr[0])ans+=arr[0];
	else if(s[i]==arr[1])ans+=arr[1];
	else if(!ans.empty())ans.erase(ans.end()-1);
}
cout<<ans;
return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
		 while(sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			int d = sc.nextInt();
			int e = sc.nextInt();
			int ans = 0;
			if(a<0) {
				ans = d + Math.abs(a)*c + b*e;
			}
			else {
				if(a==0)
					ans += d;
				ans += (b-a)*e;
			}
			System.out.println(ans);
	  }	 
	}
}


Measured memory_bytes: 26124
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
#define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    int n, m;
    cin>>n>>m;
    vector<string> a(n);
    vvl dp(n, vector<ll> (m));
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<m;i++){
        if(a[0][i]=='#')
            break;
        dp[0][i]=1;
    }
    for(int i=0;i<n;i++){
        if(a[i][0]=='#')
            break;
        dp[i][0]=1;
    }
    for(int i=1;i<n;i++){
        for(int j=1;j<m;j++){
            if(a[i][j]!='#')
                dp[i][j] = (dp[i-1][j]+dp[i][j-1])%mod;
        }
    }
    cout<<dp[n-1][m-1]<<endl;
    return 0;
}


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

vector<long long> f(200001);

long long power(long long x, long long y, long long mod)
{
    long long ret = 1;
    while(y > 0)
    {
        if (y & 1)
        {
            ret = (ret * x) % mod;
        }
        x = (x * x) % mod;
        y >>= 1;
    }
    return ret;
}

long long func(long long count, long long x)
{
    if (count == 0)
    {
        return 1;
    }
    else if (x % count == 0)
    {
        return 1;
    }
    else
    {
        return 1 + f[x % count];
    }
}

int main(void)
{
    for (long long i = 1; i < 200001; i++)
    {
        long long count = 0;
        long long X = i;
        while(X > 0)
        {
            if(X & 1)
            {
                count ++;
            }
            X >>= 1;
        }
        f[i] = func(count, i);
    }
    long long N;
    cin >> N;
    string X;
    cin >> X;
    long long count = 0;
    for (long long i = 0; i < X.size(); i++)
    {
        if (X[i] == '1')
        {
            count++;
        }
    }
    long long num1 = 0;
    for (long long j = 0; j < X.size(); j++)
    {
        if (X[j] == '1' && count != 1)
        {
            num1 += power(2,X.size()-1-j, count-1);
        }
    }
    long long num0 = 0;
    for (long long j = 0; j < X.size(); j++)
    {
        if (X[j] == '1')
        {
            num0 += power(2,X.size()-1-j, count+1);
        }
    }
    for (long long i = 0; i < X.size(); i++)
    {
        long long answer;
        if (X[i] == '1')
        {
            if (count - 1 == 0)
            {
                answer = 0;
            }
            else
            {
            answer = func(count - 1, num1 - power(2,X.size()-1-i, count-1));
            }
        }
        else
        {
            
            answer = func(count + 1, num0 + power(2,X.size()-1-i, count+1));
        }
        cout << answer << endl;
    }
}

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  int p,q,r;cin>>p>>q>>r;
  cout<<min(min(p+q, q+r),p+r)<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(){
char str[1001],mei[10],q[1001],abc[1001];
int kazu,a,b,j,i,ba,k,l;
 
 
 
scanf("%s",str);
scanf("%d",&kazu);
 
 
 
for(i=0;i<kazu;i++){
scanf("%s %d %d",mei,&a,&b);
 
 
    if(mei[2]=='p'){
        scanf("%s",q);
        for(k=0;k<(b-a+1);k++){
            str[a+k]=q[k];}
        }
 
 
 
 
 
    if(mei[2]=='v'){
        ba=strlen(str);
            strncpy(abc,str,ba);
            for(j=0;j<=b-a;j++){
            str[j+a]=abc[b-j];}
}
 
 
if(mei[0]=='p'){
    for(l=a;l<=b;l++){
        printf("%c",str[l]);
        }
        puts("");
        }
         
 
 
 
 
 
}
 
return 0;
}


Measured memory_bytes: 2108
#include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_INT = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int check(vector<bool> &v, int from, int to)
{
  int i;
  for (i = from + 1; i*i <= to && i*i < sz(v); i++) {
    if (v[i]) {
      for (int j = 2; i*j < sz(v); j++) {
        v[i*j] = false;
      }
    }
  }
  return i - 1;
}

int count(vector<bool> &v, int to)
{
  int res = 0;
  repab (i, 2, to+1) {
    if (i >= sz(v))
      break;
    if (v[i])
      res++;
  }
  return res;
}

int main(int argc, char **argv)
{
  const int prime_max=1000000;
  vector<bool> v(prime_max, true);
  int done;

  int n;
  done = 1;
  while (cin >> n) {
    done = check(v, done, n);
    cout << count(v, n) << endl;
  }
  return 0;
}

Measured memory_bytes: 1316
#include <iostream>
#include<string>

using namespace std;

long long GCD(long long C,long long D){
    long long temp;
    while(C%D!=0){
        temp = D;
        D = C % D;
        C = temp;
    }
    return D;
    
}



long long LCM(long long C,long long D){
    return C*D/GCD(C,D);
}


int main(void){
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(C<D)swap(C,D);
    
    long long target = LCM(C,D);
    long long start=A/target;
    if(A%target!=0)start++;
    long long end=B/target;
    long long uraAns = end - start + 1;    
    
    
    long long startC=A/C;
    long long endC=B/C;
    if(A%C!=0)startC++;
    long long uraAnsC = endC - startC + 1;
    
    long long startD=A/D;
    long long endD=B/D;
    if(A%D!=0)startD++;
    long long uraAnsD = endD - startD + 1;   
    
    long long ans = B - A + 1 - (uraAnsC+uraAnsD-uraAns);
    
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
    ll n;
    ll ans=0;
    cin >>n;
    cout<<(n-1)*(n)/2<<endl;
}

Measured memory_bytes: 256
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,len[10],a[10],tot,lc,ans,z[100],zhy;
bool compare(){
	if(lc==0) return 0;
	if(lc<tot) return 1;
	for(int i=lc;i>=1;i--)
		if(a[i]!=len[i])
			return a[i]<len[i];
	return 1;
}
bool cz(){
	z[5]=z[7]=z[3]=0;
	for(int i=1;i<=lc;i++)
		z[a[i]]++;
	return z[5]&&z[7]&&z[3];
}
void dfs(int x){
	lc=x-1;
	if(a[1]==3&&a[2]==7&&a[3]==5&&lc==3)
		zhy=1;
	if(compare()&&cz())
		ans++;
	if(x>tot) return;
	a[x]=5;
	dfs(x+1);
	a[x]=7;
	dfs(x+1);
	a[x]=3;
	dfs(x+1);
}
int main(){
//	freopen(".in","r",stdin);
	scanf("%d",&n);
	while(n){
		len[++tot]=n%10;
		n/=10;
	}
	dfs(1);
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
using ll = long long;
int INF = 1000000009;
int mod = 1000000007;
struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint &operator+=(const mint a)
    {
        if ((x += a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        if ((x += mod - a.x) >= mod)
            x -= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1)
            a *= *this;
        return a;
    }
    mint inv() const
    {

        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};
mint dp[105][4][4][4];
int main()
{
    int n;
    cin >> n;
    dp[0][3][3][3] = 1;
    int cnt = 0;
    rep(i, n)
    {
        rep(j,4)rep(k,4)rep(l,4)rep(nc,4){
            if(k == 0 && l == 1 && nc == 2)continue;
            if(k == 0 && l == 2 && nc == 1)continue;
            if(k == 1 && l == 0 && nc == 2)continue;
            if(j == 0 && k == 1 && nc == 2)continue;
            if(j == 0 && l == 1 && nc == 2)continue;
            (dp[i + 1][k][l][nc] += dp[i][j][k][l]);
        }
    }
    mint ret = 0;
    rep(j, 4) rep(k, 4) rep(l, 4) (ret += dp[n][j][k][l]);
    cout << ret.x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <vector>
/* 変数i を n回繰り返すマクロ */
#define rep(i,n) for (int i = 0;i < (n);i++)
/* 配列の初期化 fill(array, 0); すべて0に初期化 */
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill( (T*)array, (T*)(array+N), val );}
using namespace std;
int main()
{
    int n;
    int x[110];

    cin >> n;

    rep(i,n){
        cin >> x[i];
    }

    int min_cal = INT_MAX;
    for(int i = 1;i <= 100;i++){
        int cal = 0;
        for(int j = 0;j < n;j++){
            cal += pow(x[j] - i,2);
        }
        if(min_cal > cal){
            min_cal = cal;
        }
    } 

    cout << min_cal << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

class Main {

    // Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        solve(N);
    }

    static void solve(long N){
        System.out.println((int)Math.pow(N, 3));
    }
}


Measured memory_bytes: 21844
//在 POJ 和小白菜中，该库禁用！
//在 USACO中请用文件。
#include<bits/stdc++.h>
using namespace std;
char a,b;
int main(){
	cin>>a>>b;
	if(a>b) cout<<">"<<endl;
	else if(a==b) cout<<"="<<endl;
	else cout<<"<"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 5;
const ll maxn = 5005;
ll m, n, t, T, k, a[N], st[N*4], kq[N], d[N], ans, u, v, tong;
string s, ss;
struct dang
{
    ll pos, val, l, r;
};
dang b[N];
bool so(const dang& x, const dang& y)
{
    return (x.r < y.r) || (x.r == y.r && x.l < y.l);
}
priority_queue<ll> pr;
bool check(ll u)
{
    ll tt = 0;
    if(u <= 0)return true;
    for(int i = 1; i <= n; i ++)
    {
        tt += max((a[i] + u - 1) / u - 1, 0ll);
    }
    if(tt <= k)return true;
    else return false;
}
void build(ll id, ll l, ll r)
{
    if(l > u || r < u)return;
    if(l == r)
    {
        st[id] += v;
        return;
    }
    ll mid = (l + r) / 2;
    build(id*2, l, mid);
    build(id*2+1, mid+1, r);
    st[id] = st[id*2] + st[id*2+1];

}
ll get(ll id, ll l ,ll r)
{
    if(u > r || v < l)return 0;
    if(u <= l && r <= v)return st[id];
    ll mid = (l + r) / 2;
    return get(id*2, l, mid) + get(id*2+1, mid+1, r);
}
void sol()
{
    cin >> n >> m;
    for(int i = 1; i <= n; i ++)
    {
        cin >> a[i];
    }
    for(int i = 1; i <= m; i ++)
    {
        cin >> b[i].l >> b[i].r;
        b[i].pos = i;
    }
    sort(b+1, b+1+m, so);
    int j = 1;
    for(int i = 1; i <= n; i ++)
    {
        if(d[a[u]] != 0)
        {
            u = d[a[i]];
            v = -1;
            build(1, 1, n);
        }
        d[a[i]] = i;
        u = i;
        v = 1;
        build(1, 1, n);
        while(b[j].r == i && j <= m)
        {
            u = b[j].l, v = b[j].r;
            kq[b[j].pos] = get(1, 1, n);
            ++j;
        }
    }
    for(int i = 1; i <= m; i ++)cout << kq[i] <<'\n';


}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //cin >> T; while(T -- > 0)
    sol();
}


Measured memory_bytes: 39368
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> d(3);
    rep(i,3) cin >> d[i];
    vector<P> q;
    rep(i,n){
        string s;
        cin >> s;
        int a = 0, b = 1;
        if(s == "AB") a = 0, b = 1;
        if(s == "AC") a = 0, b = 2;
        if(s == "BC") a = 1, b = 2;
        q.emplace_back(a, b);
    }
    string ans;
    auto add = [&](int a, int b){
        d[a]++;
        d[b]--;
        ans += 'A' + a;
    };
    q.emplace_back(0, 1);
    rep(i,n){
        int a = q[i].first;
        int b = q[i].second;
        if(!d[a] && !d[b]){
            cout << "No" << endl;
            return 0;
        }
        if(!d[a]){
            add(a, b);
        }
        else if(!d[b]){
            add(b, a);
        }
        else{
            int na = q[i+1].first;
            int nb = q[i+1].second;
            if(a == na || a == nb){
                add(a, b);
            }
            else{
                add(b, a);
            }
        }
    }
    cout << "Yes" << endl;
    rep(i,n) cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 4268
from itertools import product
from collections import deque
import sys
readline = sys.stdin.readline
write = sys.stdout.write
def solve():
    MOD = 10**9 + 9
    N, M = map(int, readline().split())

    K = 3*N
    fact = [1]*(K+1)
    rfact = [1]*(K+1)
    r = 1
    for i in range(1, K+1):
        fact[i] = r = r * i % MOD
    rfact[K] = r = pow(fact[K], MOD-2, MOD)
    for i in range(K, 0, -1):
        rfact[i-1] = r = r * i % MOD

    pr6 = [1]*(N+1)
    base = pow(6, MOD-2, MOD)
    r = 1
    for i in range(N):
        pr6[i+1] = r = base * r % MOD

    mp = {}
    G = [[] for i in range(M*2)]
    cur = 0
    m = 0
    E = []
    for i in range(M):
        a, b, c = map(int, readline().split())
        if a not in mp:
            mp[a] = cur
            cur += 1
        ma = mp[a]
        if b not in mp:
            mp[b] = cur
            cur += 1
        mb = mp[b]
        if c == 0:
            G[ma].append(mb)
            G[mb].append(ma)
        else:
            E.append((ma, mb))
            m += 1
    L = cur
    cr = 0
    lb = [-1]*L
    sz = []
    zz = []
    cc = [0, 0, 0]
    u = [0]*L
    que = deque()
    for i in range(L):
        if u[i]:
            continue
        que.append(i)
        vs = []
        u[i] = 1
        while que:
            v = que.popleft()
            vs.append(v)
            for w in G[v]:
                if u[w]:
                    continue
                u[w] = 1
                que.append(w)
        s = len(vs)
        if s > 3:
            write("0\n")
            return
        for v in vs:
            lb[v] = cr
        sz.append(s)
        zz.append(vs)
        cc[s-1] += 1
        cr += 1
    used = [0]*(1 << m)
    ans = 0
    def dfs(state, c, lb, cc):
        nonlocal ans
        if used[state]:
            return
        used[state] = 1
        x = cc[0] + (K - L); y = cc[1]
        if x >= y:
            k = (x - y) // 3
            if c & 1 == 0:
                ans += fact[x] * pr6[k] * rfact[k] % MOD
            else:
                ans -= fact[x] * pr6[k] * rfact[k] % MOD
        cc0 = [0]*3
        for i in range(m):
            if state & (1 << i):
                continue
            p, q = E[i]
            pl = lb[p]; ql = lb[q]
            if pl != ql:
                s = sz[pl] + sz[ql]
                if s > 3:
                    continue
                cc0[:] = cc
                cc0[sz[pl]-1] -= 1
                cc0[sz[ql]-1] -= 1
                cc0[s-1] += 1

                nl = len(sz)
                vs = zz[pl] + zz[ql]
                for v in vs:
                    lb[v] = nl
                sz.append(s)
                zz.append(vs)

                dfs(state | (1 << i), c+1, lb, cc0)

                for v in zz[pl]:
                    lb[v] = pl
                for v in zz[ql]:
                    lb[v] = ql
            else:
                dfs(state | (1 << i), c+1, lb, cc)
    dfs(0, 0, lb, cc)
    ans %= MOD
    write("%d\n" % ans)
solve()


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

int main() {
  	int n,count=0;
  	cin >> n;
  	int t[n],x[n],y[n];
  	cin >> t[0] >> x[0] >> y[0];
  	if ((abs(x[0]+y[0])<=t[0])&&(abs(x[0]+y[0])%2==t[0]%2)) count++;
  	for (int i=1;i<n;i++){
    	cin >> t[i] >> x[i] >> y[i];
      	if ((abs(x[i]-x[i-1]+y[i]-y[i-1])<=t[i]-t[i-1])&&(abs(x[i]-x[i-1]+y[i]-y[i-1])%2==(t[i]-t[i-1])%2)) count++;
    }
  	if(count==n)cout <<"Yes" <<endl;
  	else cout << "No" << endl;
}

Measured memory_bytes: 1408
#include"bits/stdc++.h"

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
	ll n, c, k,t,cnt=0,sec=0,ans=0;
	cin >> n >> c >> k;
	vector<ll>cust(n);
	rep(i, n)cin >> cust[i];
	sort(all(cust));
	rep(i, n) {
		if (i == n - 1) {
			ans++;
			break;
		}
		if (cnt == 0) {
			sec = cust[i] + k;
			cnt++;
		}
		if (cnt == c) { cnt = 0; ans++; continue; }
		if (i < n-1 &&cust[i + 1] <= sec) {
			cnt++;
		}
		else {
			cnt = 0;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3952
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
sa = [0]
a.unshift(0)
a << 0
res = 0
(n+1).times do |i|
    tmp = (a[i] - a[i+1]).abs
    sa << tmp
    res += tmp
end

1.upto(n-1) do |i|
    puts res - sa[i] - sa[i+1] + (a[i-1] - a[i+1]).abs
end
puts res - sa[n] - sa[n+1] + (a[-3]).abs

Measured memory_bytes: 13316
n,a,b = map(int,input().split())
s = input()
p = 0
pb = 0 
for i in range(n):
    if s[i] == "a":
        if p<(a+b):
            p += 1
            print("Yes")
        else:
            print("No")
    if s[i] == "b":
        if p<(a+b) and pb<b:
            p += 1
            pb += 1
            print("Yes")
        else:
            print("No")
    if s[i] == "c":
        print("No")

Measured memory_bytes: 4016
/* 
	  WHEN YOU DONT FEEL LIKE DOING IT ,
	  THATS THE TIME YOU GOTTA DO IT
	*/	  
	#include <bits/stdc++.h>
	using namespace std;
		     
	#define ll long long int
	#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
		     
	#define mp make_pair
	#define pb push_back
	#define ld long double
	#define F first
	#define S second
	const ll N =(1e6);  
	const ll mod = (1e9+7);
	
	//int arr[N];

	int main(){
	fast;
	int n ;
	cin >> n ;
	cout<<pow(n , 3);
}

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

class AB {

    static string S;
    static void Main() {
        S = Console.ReadLine();
        int length = S.Length;
      for(int i = 0; i < length - 1; i++) {
            if (S[i] == S[i + 1]) {
                
                Console.WriteLine((i+1).ToString() + " " + (i + 2).ToString());
                return;
            }
            if (i != length - 2) {
                if (S[i] == S[i + 2]) {
                    Console.WriteLine((i + 1).ToString() + " " + (i + 3).ToString());

                    return;
                }
            }
           
        }
        Console.WriteLine("-1 -1");
    }
   
}




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

#define ll long long
#define pb push_back

using namespace std;

const int N = 55, mod = 1e9 + 7;

void add (ll &a, ll b) {
    a = (a + b) % mod;
}

void mult (ll &a, ll b) {
    a = (a * b) % mod;
}

int n;
ll k, ok[N][N], answer;

struct Matrix {
    vector <vector <ll>> t;
    Matrix () {
        t.resize (N, vector <ll> (N));
    }
    Matrix operator * (Matrix b) {
        Matrix c = Matrix ();
        for (int i = 0;i < n;i ++) {
            for (int j = 0;j < n;j ++) {
                for (int k = 0;k < n;k ++) {
                    add (c.t[i][k], (t[i][j] * b.t[ j][k]) % mod);
                }
            }
        }
        return c;
    }
};
Matrix m, ans, in;
Matrix binpow (ll k) {
    if (k == 0)return in;
    Matrix a = binpow (k / 2);
    a = a * a;
    if (k % 2 == 1) {
        a = a * m;
    }
    return a;
}

int main () {
    cin >> n >> k;
    vector <vector <ll>> can (n, vector <ll> (n));
    for (int i = 0;i < n;i ++) {
        for (int j = 0;j < n;j ++) {
            cin >> can[i][j];
            m.t[i][j] = can[i][j];
        }
    }
    for (int i = 0;i < n;i ++) {
        in.t[i][i] = 1;
    }
    ans = binpow (k);
    for (int i = 0;i < n;i ++) {
        for (int j = 0;j < n;j ++) {
            add (answer, ans.t[i][j]);
        }
    }
    cout << answer;
    return 0;
}


Measured memory_bytes: 384
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
#include<cstdlib>
#include<ctime>
#include<vector>
using namespace std;

int main(){

 int n;
 cin>>n;

 int a[n];
 int probe=1;
 for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            if(a[i]%3!=0&&a[i]%5!=0){
                probe=0;
                break;
            }
        }
 }

if(probe==1){
    cout<<"APPROVED"<<endl;
}else{
    cout<<"DENIED"<<endl;
}

return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <chrono>
#include <random>
#include <time.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define vec vector<int>
#define vecll vector<ll>
#define vecstr vector<string>
#define vecch vector<char>
#define vecpii vector<pii>
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}

string strin(){string s;cin>>s;return s;}
char chin(){char c;cin>>c;return c;}
ll lin() {ll x;scanf("%lld",&x);return x;}

int main(){
    int w=in(),a=in(),b=in();
    cout<<max(0,max(b-a-w,a-b-w))<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

struct Dinic {
    typedef long long flow_type;
    struct edge {
        int src, dst;
        flow_type capacity, flow;
        size_t rev;
    };
    int n;
    vector<vector<edge>> adj;
    Dinic(int n) : n(n), adj(n) { }
    void add_edge(int src, int dst, flow_type capacity) {
        adj[src].push_back({src, dst, capacity, 0, adj[dst].size()});
        adj[dst].push_back({dst, src, 0, 0, adj[src].size()-1});
    }
    flow_type max_flow(int s, int t) {
        vector<int> level(n), iter(n);
        function<int(void)> levelize = [&]() { // foward levelize
            level.assign(n, -1); level[s] = 0;
            queue<int> Q; Q.push(s);
            while (!Q.empty()) {
                int u = Q.front(); Q.pop();
                if (u == t) break;
                for (auto &e: adj[u]) {
                    if (e.capacity > e.flow && level[e.dst] < 0) {
                        Q.push(e.dst);
                        level[e.dst] = level[u] + 1;
                    }
                }
            }
            return level[t];
        };
        function<flow_type(int, flow_type)> augment = [&](int u, flow_type cur) {
            if (u == t) return cur;
            for (int &i = iter[u]; i < adj[u].size(); ++i) {
                edge &e = adj[u][i], &r = adj[e.dst][e.rev];
                if (e.capacity > e.flow && level[u] < level[e.dst]) {
                    flow_type f = augment(e.dst, min(cur, e.capacity - e.flow));
                    if (f > 0) {
                        e.flow += f;
                        r.flow -= f;
                        return f;
                    }
                }
            }
            return flow_type(0);
        };
        for (int u = 0; u < n; ++u) // initialize
            for (auto &e: adj[u]) e.flow = 0;

        flow_type flow = 0;
        while (levelize() >= 0) {
            fill(iter.begin(),iter.end(), 0);
            for (flow_type f; (f = augment(s, INF)) > 0; )
                flow += f;
        }
        return flow;
    }
};

int main() {
  int N;cin >> N;
  Dinic g(N+2);
  ll ans = 0;
  repeat(i,N){
    ll a;
    cin >> a;
    if(a<=0){
      g.add_edge(0,i+1,-a);
    }else{
      g.add_edge(i+1,N+1,a);
      ans+=a;
    }
  }
  for(int i=1;i<=N;i++){
    for(int j=2*i;j<=N;j+=i){
      g.add_edge(i,j,INF);
    }
  }
  ans -= g.max_flow(0,N+1);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
C_MAX = 30

a = list(map(int, input().split()))

t = 0
while t < C_MAX + 1 and (sum(1 for x in a if x % 2 == 1) == 0):
    t += 1
    a = list(int((sum(a) - x) / 2) for x in a)

if t > C_MAX:
    t = -1

print(t)


Measured memory_bytes: 2940
#include "bits/stdc++.h"
#include<unordered_map>
#pragma warning(disable:4996)
using namespace std;

const int My_Inf=2147483647;
const long long int My_LInf=9223372036854775807;

int main() {
	while (1) {
		int N, T, L, B; cin >> N >> T >> L >> B;
		if (!N)break;
		vector<int>masu(N+1,0);
		for (int i = 0; i < L; ++i) {
			int l; cin >> l;
			masu[l] = -1;
		}
		for (int i = 0; i < B; ++i) {
			int l; cin >> l;
			masu[l] = 1;
		}
		vector<vector<double>>dp(T + 2, vector<double>(N + 1, 0));
		dp[0][0] = 1;
		for (int i = 0; i < T; ++i) {
			for (int j = 0; j < N; ++j) {
				for (int k = 1; k <= 6; ++k) {
					int nmasu = j + k;
					if (nmasu > N)nmasu = 2 * N - nmasu;
					if (masu[nmasu] == -1) {
						dp[i + 2][nmasu] += dp[i][j] / 6;
					}
					else if (masu[nmasu] == 1) {
						dp[i + 1][0] += dp[i][j] / 6;
					}
					else {
						dp[i + 1][nmasu] += dp[i][j] / 6;
					}
				}
			}
			dp[i + 1][N] += dp[i][N];
		}
		double ans = dp[T][N];
		cout << fixed<<setprecision(10)<<ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3312
from itertools import product

N, K = map(int, input().split(" "))

"""
i%K == 0 ならその数同士で条件に合う数列を作れる
i%K == K//2 ならその数同士で条件に合う数列を作れる(Kが偶数の場合)
これらは条件によって導ける
"""

count = (N//K)**3
if K%2 == 0:
	count += (N//K + (N%K >= K//2))**3
print(count)


Measured memory_bytes: 3060
N=int(input())
A=list(map(int,input().split()))
mod=1000000007

ans=1
fin=[-1,-1,-1]
for i in range(N):
  c=0
  for j in range(3):
    if fin[j]==A[i]-1:
      c+=1
      if c==1:
        fin[j]=A[i]
  ans=(ans*c)%mod
  
print(ans)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

ll gcd(ll a, ll b) {
    if(a < b) gcd(b, a);
    ll r;

    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

int main(int argc, char const *argv[]) {
    int n;
    cin >> n;

    vector<ll> a;

    for (int i = 0; i < n; ++i) {
        ll tmp;
        cin >> tmp;
        a.push_back(tmp);
    }

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

    ll min = LONG_LONG_MAX;
    ll sum = 0;

    for (int j = 0; j < n-1; ++j) {
        if (a.at(j) * (-1) + a.at(j + 1) * (-1) > 0) {
            a.at(j) *= -1;
            a.at(j + 1) *= -1;
        }
    }

    for (int k = 0; k < n; ++k) {
        sum += a.at(k);
    }


    cout << sum << endl;
    return 0;

}


Measured memory_bytes: 1400
n = int(input())
h = list(map(int, input().split()))
inf = 1001001001
dp = [inf for _ in range(n + 1)]

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


Measured memory_bytes: 52720
# ???????????????????????¢??°
def eval(m, f, r):
    if m == -1 or f == -1:
        return "F"
    elif m + f >= 80:
        return "A"
    elif 65 <= m + f < 80:
        return "B"
    elif 50 <= m + f < 65:
        return "C"
    elif 30 <= m + f < 50:
        if r >= 50:
            return "C"
        else:
            return "D"
    elif m + f < 30:
        return "F"


while 1:
    mfr = input().split()
    m = int(mfr[0])
    f = int(mfr[1])
    r = int(mfr[2])

    if m == -1 and f == -1 and r == -1:
        break
    else:
        print(eval(m, f, r))

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

int main() {
  int N; cin >> N;
  int F[N][10]; for (int i=0; i<N; i++) for (int j=0; j<10; j++) cin >> F[i][j];
  int P[N][11]; for (int i=0; i<N; i++) for (int j=0; j<11; j++) cin >> P[i][j];

  int result = -1 * pow(2,31);
  for (int bit=1; bit<(1<<10); bit++) {
    int sum = 0;
    for (int i=0; i<N; i++) {
      int x = 0;
      for (int j=0; j<10; j++) { if ( bit & (1<<j) && F[i][j] == 1 ) x += 1; }
      sum += P[i][x];
    }
    if (result<sum) result = sum;
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;

int main(){
	int n;
	scanf("%d", &n);
	vector<double> x(n), y(n);
	for(int i = 0; i < n; ++i){
		scanf("%lf%lf", &x[i], &y[i]);
	}
	double ratio = 0.5;
	double px = 0, py = 0, mr = 0;
	while(ratio > 1e-12){
		for(int t = 0; t < 50; ++t){
			mr = 0;
			int k = 0;
			for(int i = 0; i < n; ++i){
				double d = hypot(px - x[i], py - y[i]);
				if(mr < d){
					mr = d;
					k = i;
				}
			}
			px += ratio * (x[k] - px);
			py += ratio * (y[k] - py);
		}
		ratio /= 1.4;
	}
	printf("%.9f\n", mr);
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){
    int h,w,k;
    cin>>h>>w>>k;
    int wh[h][w];

    rep(i,h){
        rep(j,w){
            char a;
            cin>>a;
            if(a=='.'){
                wh[i][j]=0;
            }else{
                wh[i][j]=1;
            }
        }
    }
    int ans = 0;

    for(int i=0;i<1<<h;i++){


        for(int j=0;j<1<<w;j++){

            int sum = 0;
            int wh2[h][w];
            rep(ii,h){
                rep(jj,w){
                    wh2[ii][jj]=wh[ii][jj];

                }

            }

            if(i!=0){
                for(int il = 0;il<h;il++){
                    if(1&(i>>il)){
                        for(int kk=0;kk<w;kk++){wh2[il][kk]=2;}
                    }
                }

            }
//            cout<<"ccc"<<endl;
//            rep(ii,h){
//                rep(jj,w){
//                    cout<<wh2[ii][jj];
//                }
//                cout<<endl;
//            }
//            cout<<"dd"<<endl;



            if(j!=0){

               // for(int kk=0;kk<h;kk++){wh2[kk][jk]=2;}
                for(int il = 0;il<w;il++){
                    if(1&(j>>il)){
                        for(int kk=0;kk<h;kk++){wh2[kk][il]=2;}
                    }
                }
            }

//            cout<<"aaaaaa"<<endl;
//            rep(ii,h){
//                rep(jj,w){
//                    cout<<wh2[ii][jj];
//                }
//                cout<<endl;
//            }
//            cout<<"bbbbb"<<endl;

            rep(ii,h){
                rep(jj,w){
                    if(wh2[ii][jj]==1)sum++;
                   // cout<<wh2[ii][jj];
                }
               // cout<<endl;
            }

            if(sum==k){ans++;}

        }

    }
    cout<<ans<<endl;







    
return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

int main(){
	int a, b; scanf("%d%d", &a, &b);
	if((a-b)%2) printf("IMPOSSIBLE\n");
	else printf("%d\n", (a+b)/2);
}


Measured memory_bytes: 256
N, X, Y = map(int, input().split())
counter = {i: 0 for i in range(1, N)}

for i in range(1, N+1):
    for j in range(i+1, N+1):
        counter[min(j-i, abs(X-i)+1+abs(j-Y), abs(Y-i)+1+abs(j-X))] += 1
for i, v in counter.items():
    print(v)


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

typedef vector<vector<char> > field_t;
typedef pair<int, int> point_t;

point_t operator+(const point_t &lhs, const point_t &rhs)
{
  point_t p = { lhs.first + rhs.first, lhs.second + rhs.second };
  return p;
}

bool operator==(const point_t &lhs, const point_t &rhs){
  return (lhs.first == rhs.first) && (lhs.second == rhs.second);
}

bool is_in_field(int col, int row, const point_t &point)
{
    const int c = point.second;
    const int r = point.first;
    return (0 <= c && c < col) && (0 <= r && r < row); 
}

int solve(int col, int row, field_t &field, const point_t &start, const point_t &goal)
{
  vector<vector<int>> memo;
  for(int i = 0; i < row; ++i) {
    vector<int> v(col, 0); 
    memo.push_back(v);
  }   

  const point_t points[] = { 
    { -1, 0 }, { 1, 0 }, { 0, -1 }, { 0, 1 },
  };  

  queue<point_t> q;
  q.push(start);

  while( !q.empty() ) {
    point_t cur = q.front(); q.pop();

    if(cur == goal) {
      return memo[cur.first][cur.second];
    }

    for(const auto &point : points) {
      point_t next = cur + point;
      if( is_in_field(col, row, next) ) {
        const char s = field[next.first][next.second];
        if(s == '.' || s == 'g') {
          if(memo[next.first][next.second] == 0) {
            q.push(next);
            memo[next.first][next.second] = memo[cur.first][cur.second] + 1;
          }
        }
      }
    }
  }
  return -1;
}

int main() {
  int H, W;
  cin >> H >> W;

  point_t start, goal;
  field_t field;

  for (int i = 0; i < H; i++) {
    vector<char> v;
    for (int j = 0; j < W; j++) {
      char c;
      cin >> c;
      v.push_back(c);
    }
    field.push_back(v);
  }
  int ans = 0;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (field[i][j] == '.') {
        point_t start;
        start.first = i;
        start.second = j;

        for (int k = 0; k < H; k++) {
          for (int l = 0; l < W; l++) {
              if (field[k][l] == '.') {
                point_t goal;
                goal.first = k;
                goal.second = l;
                if (start != goal) {
                  int tmp;
                  tmp = solve(W, H, field, start, goal);
                  if (ans < tmp) {
                    ans = tmp;
                  }
                }
              }
          }
        }
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256