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

const long long N = 2e5 + 1;

pair<long long, long long> p[N];

#define nowr st, en, rt
#define lson st, (st + en) >> 1, rt << 1
#define rson ((st + en) >> 1) + 1, en, rt << 1 | 1

// struct {

long long x[N << 2], y[N << 2];
long long lg[N << 2];

void upd (long long v, long long st, long long en, long long rt) {
	x[rt] -= v;
	y[rt] += v;
	lg[rt] += v;
}

void pu (long long rt) {
	x[rt] = min(x[rt << 1], x[rt << 1 | 1]);
	y[rt] = max(y[rt << 1], y[rt << 1 | 1]);
}

void pd (long long st, long long en, long long rt) {
	upd(lg[rt], lson); upd(lg[rt], rson); lg[rt] = 0;
}

void modify (long long l, long long r, long long v, long long st, long long en, long long rt) {
	if (l > en || r < st) return;
	if (l <= st && en <= r) { upd(v, st, en, rt); return; }
	pd(nowr); modify(l, r, v, lson); modify(l, r, v, rson); pu(rt);
}

long long query_mn (long long l, long long r, long long st, long long en, long long rt) {
	if (l > en || r < st) return 1e18;
	if (l <= st && en <= r) return x[rt];
	pd(nowr); return min(query_mn(l, r, lson), query_mn(l, r, rson));
}

long long query_mx (long long l, long long r, long long st, long long en, long long rt) {
	if (l > en || r < st) return - 1e18;
	if (l <= st && en <= r) return y[rt];
	pd(nowr); return max(query_mx(l, r, lson), query_mx(l, r, rson));
}

void build (long long st, long long en, long long rt) {
	x[rt] = 0; lg[rt] = 0;
	if (st == en) { x[rt] = y[rt] = p[st].second; return; }
	build(lson); build(rson); pu(rt);
}

// } st;

int main () {
	long long n;
	scanf("%lld", &n);
	for (long long i = 1; i <= n; i ++) 
		scanf("%lld%lld", &p[i].first, &p[i].second);
	sort(p + 1, p + n + 1);

	build(1, n, 1);
	long long ans = 0;
	for (long long i = 2; i <= n; i ++) {
		modify(1, i - 1, p[i].first - p[i - 1].first, 1, n, 1);

		long long a = query_mn(1, i - 1, 1, n, 1);
		long long b = query_mx(1, i - 1, 1, n, 1);
		ans = max(ans, p[i].second - a);
		ans = max(ans, b - p[i].second);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 19240
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required
// iteration and input/output stream
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()) cout<<x[i]<<" "; cout<<endl;

#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)

using namespace std;

#define tc() int tcase; cin >> tcase ; rep(tc,1,tcase+1)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair

// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;

inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }

#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);

ll gcd(ll a,ll b){ return ((b==0)? a:gcd(b,a%b) ); }


int main()
{
    SYNC
    string s,t;
    cin>>s>>t;
    int cnt=0;
    rep(i,0,3)
    if(s[i]== t[i])
        cnt++;


    cout<<cnt;
}


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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define REP(i,n) for(ll i = 0;i < (ll)n;i++)
#define REPD(i,n) for(ll i = (ll)n - 1;i >= 0;i--)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};


int main(){
  
  int a,b;
  cin >> a >> b;
  int res = 0;
  for(int i = a;i <= b;i++){
    string s,t;
    s = t = to_string(i);
    reverse(ALL(t));
    if(s == t)res++;
  }
  cout << res << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 9223372036854775807LL
#define inf 1000000007
#define SYOU(x) setprecision(x+1)
#define lol long long
#define mp make_pair
#define fi first
#define se second
using namespace std;
lol abs(lol x,lol y){return(x>y?x-y:y-x);}
lol max(lol x,lol y){if(x>y)return x;return y;}
lol min(lol x,lol y){if(x<y)return x;return y;}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s,t,u;
    cin >>s>>t>>u;
    int a,b,c;
    a=b=c=0;
    char h='a';
    while(1){
      if(h=='a'){
	if(s.size()==a){
	  cout <<"A\n";
	  return 0;
	}
	h=s[a];
	a++;
      }else if(h=='b'){
	if(t.size()==b){
	  cout <<"B\n";
	  return 0;
	}
	h=t[b];
	b++;
      }else{
	if(u.size()==c){
	  cout <<"C\n";
	  return 0;
	}
	h=u[c];
	c++;
      }
    }
    return (0);
}


Measured memory_bytes: 256
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    n = int(input())
    word_dict={}
    for i in range(n):
        s = input().rstrip()
        if s not in word_dict:
            word_dict[s]=1
        else:
            word_dict[s]+=1
    m = int(input())
    for j in range(m):
        t= input().rstrip()
        if t in word_dict:
            word_dict[t]-=1
        else:
            word_dict[t]=-1

    if max(word_dict.values()) < 0:
        print(0)
    else:
        print(max(word_dict.values()))

if __name__=="__main__":
    main()

Measured memory_bytes: 9068
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

int a[10005];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> a[i];
	}

	ll sum = 0;
	REP(i, N)
	{
		int n = 0;
		int ai = a[i];
		while (ai % 2 == 0)
		{
			ai /= 2;
			n++;
		}
		sum += n;
	}

	cout << sum << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
void rev(char *s)
{
	int l=strlen(s),i;
	for(i=0;i<l/2;i++)
	{
		char t=s[i];
		s[i]=s[l-1-i];
		s[l-1-i]=t;
	}
}
char T[4][8]={"dream","dreamer","erase","eraser"};
int main()
{
	int i=0,c=0,l;
	char s[100001];
	for(i=0;i<4;i++)
	{
		rev(T[i]);
	}
	scanf("%s",s);
	l=strlen(s);
	rev(s);
	while(c<l)
	{
		int k=-1;
		for(i=0;i<4;i++)
		{
			if(!strncmp(s+c,T[i],strlen(T[i])))
			{
				k=strlen(T[i]);
				break;
			}
		}
		if(k<0)
		{
			puts("NO");
			return 0;
		}
		c+=k;
	}
	puts("YES");
	return 0;
}

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

#include <vector>
#include <array>
#include <map>
#include <set>
#include <stack>
#include <queue>

#define int64 long long
using namespace std;

int main()
{
	int kk, size;
	string ss;
	cin >> kk >> ss;
	size = ss.length();
	if(size <= kk)
	{
		cout << ss << endl;
	}
	else
	{
		cout << ss.substr(0, kk) << "..." << endl;
	}
	return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes"  << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

class Dis{
  public:
  vector<ll> rank,p,siz;
  
  Dis(int s){
    rank.resize(s,0);
    p.resize(s,0);
    siz.resize(s,1);
    rep(i,s) makeSet(i);
  }
  
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }
  
  void unite(int x,int y){
    if(same(x,y)) return;
    link(findSet(x),findSet(y));
  }
  
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      siz[x]+=siz[y];
    }
    else{
      p[x]=y;
      siz[y]+=siz[x];
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  
  int findSet(int x){
    if(x != p[x]) p[x]=findSet(p[x]);
    return p[x];
  }
  
  ll size(int x){
    return siz[findSet(x)];
  }
};


int main(){
  ll n,m;
  cin>>n>>m;
  
  Dis ds=Dis(n);
  
  ll x,y;
  rep(i,m){
    cin>>x>>y;
    x--,y--;
    ds.unite(x,y);
  }
  
  ll ans=0;
  rep(i,n){
    ans=max(ans,ds.size(i));
  }
  cout<<ans<<endl;
  
  return 0;
}

Measured memory_bytes: 8012
#include<bits/stdc++.h>
using namespace std;
#define ll   long long int
#define T int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL)
#define PI 3.141592653589793238462643383


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

    if(n%1000 == 0) cout<<n%1000<<endl;
    else cout<<1000 - n%1000<<endl;

    


}











Measured memory_bytes: 3660
#include <iostream> 
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <stack>
#include <queue> 
using namespace std;
struct Node {
	Node *l,*r;
	int st,ed,sum;
}*root[501001],pool[26040404];
int tot,last[505050];
inline void Build(Node *&now,int st,int ed) {
	now = &pool[++tot];
	now->st = st;
	now->ed = ed;
	now->sum = 0;
	if (st == ed) {
		return ;
	}
	int mid = ((st+ed)>>1);
	Build(now->l,st,mid);
	Build(now->r,mid+1,ed);
}
inline Node* Add(Node *now,int pos) {
	Node *ret = &pool[++tot];
	ret->st = now->st;
	ret->ed = now->ed;
	ret->sum = now->sum+1;
	if (now->st == now->ed) {
		return ret;
	}
	if (now->l->ed >= pos) {
		ret->r = now->r;
		ret->l = Add(now->l,pos);
		return ret;
	}
	else {
		ret->l = now->l;
		ret->r = Add(now->r,pos);
		return ret;
	}
}
inline Node* minu(Node *now,int pos) {
	Node *ret = &pool[++tot];
	ret->st = now->st;
	ret->ed = now->ed;
	ret->sum = now->sum - 1;
	if (now->st == now->ed) {
		return ret;
	}
	if (now->l->ed >= pos) {
		ret->r = now->r;
		ret->l = minu(now->l,pos);
		return ret;
	}
	else {
		ret->l = now->l;
		ret->r = minu(now->r,pos);
		return ret;
	}
}
inline int getsum(Node *now,int st,int ed) {
	if (now->st > ed || now->ed < st)
		return 0;
	if (now->st >= st && now->ed <= ed) {
		return now->sum;
	}
	return getsum(now->l,st,ed) + getsum(now->r,st,ed);
}

template<class T> inline void read(T &x){
	x=0; char c=getchar(); int f=1;
	while (!isdigit(c)) {if (c=='-') f=-1; c=getchar();}
	while (isdigit(c)) {x=x*10+c-'0'; c=getchar();} x*=f;
}

int main() {
	int n;
	int q,li,ri;
	read(n);
	read(q);
	Build(root[0],1,n);
	int cc;
	for (int i = 1;i <= n; i++) {
		read(cc); 
		root[i] = Add(root[i-1],i);
		if (last[cc]) {
			root[i] = minu(root[i],last[cc]);
		}
		last[cc] = i;
	}
	for (int i = 1;i <= q; i++) {
		read(li);
		read(ri); 
		printf("%d\n",getsum(root[ri],li,ri));
	}
	return 0;
}
/*
3
12 6
aaabaabaaaab
3 3 4
2 3 2
7 8 3
3 4 2
1 4 2
8 12 1
1 1
a
1 1 1
12 6
aaabaabaaaab
3 3 4
2 3 2
7 8 3
3 4 2
1 4 2
8 12 1
1 1
a
1 1 1
*/


Measured memory_bytes: 662692
S = input()
N = len(S)
cnt = 0
S1 = S[:int((N-1)/2)]
S2 = S[int((N+1)/2):]
if S == S[::-1] and S1 == S1[::-1] and S2 == S2[::-1]:
    print("Yes")
else :
    print("No")

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    string S;
    cin >> S;
    cout << ( S[0] == 'Y' && S[1] == 'A' && S[2] == 'K' && S[3] == 'I' ? "Yes" : "No" ) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N,M;
  cin >> N;
  cin >> M;
  //vector<long long> vec(N);
  //for (int i=0;i<N;i++) {
   //cin >> vec.at(i);
  //}
 if (N==M) {cout << "Yes" << endl;}
 else {cout << "No" << endl;}
}

Measured memory_bytes: 256
package main

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

func main() {
	io := NewIo()
	defer io.Flush()
	n := io.NextInt()
	for i := 0; i < n; i++ {
		s, t := io.NextLine(), io.NextLine()
		io.Println(f(s, t))
	}
}

func f(s, t string) string {
	for i := len(s) - 1; i >= 0; i-- {
		switch s[i] {
		case 'C':
			t = strings.Join([]string{t[1:], string(t[0])}, "")
		case 'J':
			t = strings.Join([]string{string(t[len(t)-1]), t[:len(t)-1]}, "")
		case 'E':
			if len(t)%2 == 1 {
				t = strings.Join([]string{t[len(t)/2+1:], string(t[len(t)/2]), t[:len(t)/2]}, "")
			} else {
				t = strings.Join([]string{t[len(t)/2:], t[:len(t)/2]}, "")
			}
		case 'A':
			r := []rune(t)
			for i, n := 0, len(r); i < n/2; i++ {
				r[i], r[n-i-1] = r[n-i-1], r[i]
			}
			t = string(r)
		case 'M':
			r := []rune(t)
			for i := 0; i < len(r); i++ {
				if '0' <= r[i] && r[i] < '9' {
					r[i]++
				} else if r[i] == '9' {
					r[i] = '0'
				}
			}
			t = string(r)
		case 'P':
			r := []rune(t)
			for i := 0; i < len(r); i++ {
				if '0' < r[i] && r[i] <= '9' {
					r[i]--
				} else if r[i] == '0' {
					r[i] = '9'
				}
			}
			t = string(r)
		}
	}
	return t
}

// I/O template
type Io struct {
	reader    *bufio.Reader
	writer    *bufio.Writer
	tokens    []string
	nextToken int
}

func NewIo() *Io {
	return &Io{
		reader: bufio.NewReader(os.Stdin),
		writer: bufio.NewWriter(os.Stdout),
	}
}

func (io *Io) Flush() {
	err := io.writer.Flush()
	if err != nil {
		panic(err)
	}
}

func (io *Io) NextLine() string {
	var buff []byte
	for {
		line, isPrefix, err := io.reader.ReadLine()
		if err != nil {
			panic(err)
		}
		buff = append(buff, line...)
		if !isPrefix {
			break
		}
	}
	return string(buff)
}

func (io *Io) Next() string {
	for io.nextToken >= len(io.tokens) {
		line := io.NextLine()
		io.tokens = strings.Fields(line)
		io.nextToken = 0
	}
	s := io.tokens[io.nextToken]
	io.nextToken++
	return s
}

func (io *Io) NextInt() int {
	i, err := strconv.Atoi(io.Next())
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) NextFloat() float64 {
	i, err := strconv.ParseFloat(io.Next(), 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *Io) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}

func (io *Io) Printf(format string, a ...interface{}) {
	fmt.Fprintf(io.writer, format, a...)
}

func (io *Io) PrintIntSlice(a []int) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func (io *Io) PrintStringSlice(a []string) {
	b := make([]interface{}, 0, len(a))
	for _, x := range a {
		b = append(b, x)
	}
	io.Println(b...)
}

func Log(name string, value interface{}) {
	fmt.Fprintf(os.Stderr, "%s=%+v\n", name, value)
}

func ExampleIo() {
	io := NewIo()
	defer io.Flush()
	a := make([]int, 0, 3)
	a[0], a[1], a[2] = io.NextInt(), io.NextInt(), io.NextInt()
	io.Println(a)
	io.PrintIntSlice(a)
	Log("io", a)
}



Measured memory_bytes: 1080
mod = 10 ** 6 + 3


class Combi():
    def __init__(self, N, mod):
        self.power = [1 for _ in range(N+1)]
        self.rev = [1 for _ in range(N+1)]
        self.mod = mod
        for i in range(2, N+1):
            self.power[i] = (self.power[i-1]*i) % self.mod
        self.rev[N] = pow(self.power[N], self.mod-2, self.mod)
        for j in range(N, 0, -1):
            self.rev[j-1] = (self.rev[j]*j) % self.mod

    def com(self, K, R):
        if K < R:
            return 0
        else:
            return ((self.power[K])*(self.rev[K-R])*(self.rev[R])) % self.mod

    def pom(self, K, R):
        if K < R:
            return 0
        else:
            return (self.power[K])*(self.rev[K-R]) % self.mod

    def powe(self, K):
        return self.power[K]

    def rev_powe(self, K):
        return self.rev[K]


combi = Combi(mod-1, mod)


def rev(X):
    return pow(X, mod-2, mod)


def count_div(L, R, D):
    return not bool(R//D - (L-1)//D)


def solve():
    x, d, n = map(int, input().split())
    if d % (mod) == 0:
        print(pow(x,n,mod))
        return
    elif d % (mod) != 0:
        y = rev(d)*x
        if count_div(y, y+n-1, mod):
            y = y % mod
            ans = pow(d, n, mod)*combi.powe(y+n-1) * combi.rev_powe(y)*y
            print(ans % mod)
            return
        else:
            ans = 0
            print(ans % mod)
            return


def main():
    Q = int(input())
    for i in range(Q):
        solve()


if __name__ == "__main__":
    main()


Measured memory_bytes: 208528
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cstring>
#include<string>
#include<map>
#include<iostream>
using namespace std;
int a[1000010];
int n,h,w,k,bit;
string t;
char ch[10][10];
map<string , int> mp;
int r[10],c[10];
int all;
int sel[20];
int main(){
    //freopen("sort.in","r",stdin);
    //freopen("sort.out","w",stdout);
    while (scanf("%d %d %d",&h,&w,&k)!=EOF) {
        all = 0;
        bit = h+w;
        for (int i=0;i<h;i++)
        {
            scanf("%s",ch[i]);
        }
        int ans=0;
        for (int i=0;i<(1<<bit);i++) {
            int x = i;
            for (int j=0;j<bit;j++) {
                sel[j]=x%2;
                x/=2;
            }
            int cnt = 0;
            for (int a=0;a<h;a++) {
                for (int b=0;b<w;b++)
                    if (sel[a]!=0&&sel[h+b]!=0&&ch[a][b]=='#')
                        cnt++;
            }
            ans += (cnt==k);
        }
        printf("%d\n",ans);
    }
    return 0;
}


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

using namespace std;

#define int long long

const int MAXN = 2e3 + 7;

int dp[MAXN][MAXN];

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i].first;
        a[i].second = i;
    }
    sort(a.begin(), a.end());
    reverse(a.begin(), a.end());
    dp[0][0] = 0;
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j <= i; ++j)
        {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i].first * abs(n - 1 - (i - j) - a[i].second));
            dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + a[i].first * abs(a[i].second - j));
        }
    }
    int ans = 0;
    for (int i = 0; i < n; ++i)
    {
        ans = max(ans, dp[n][i]);
    }
    cout << ans << endl;
    return 0;
}


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

char getGrade(int m,int f,int r){
    int sum=m+f;
    char grade;
    if (m==-1||f==-1){
        grade='F';
        
    }else if (80<=sum){
     grade='A';
    }else if (65<=sum&&sum<80){
     grade='B';
    }else if (50<=sum&&sum<65){
     grade='C';
    }else if (30<=sum&&sum<50){
     if (50<=r) grade='C';
     else grade='D';
    }else if (sum<30){
     grade='F';
    }
    
    return grade;
}

int main(){
    int m,f,r;
    while(1){
        cin>>m>>f>>r;
        if (m==-1&&f==-1&&r==-1) break;
        cout<<getGrade(m,f,r)<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	ll n;
	cin>>n;
	vector<int> a(n), b(n), c(n);
	rep(i,n)cin>>a[i];
	rep(i,n)cin>>b[i];
	rep(i,n)cin>>c[i];
	sort(all(a));
	sort(all(c));
	ll ans = 0LL;
	rep(i,n){
		int mid = b[i];
		ll cnt_a, cnt_c;
		auto itr = lower_bound(all(a), mid);
		cnt_a = distance(a.begin(), itr);
		itr = upper_bound(all(c), mid);
		cnt_c = n - distance(c.begin(), itr);
		ans += cnt_a*cnt_c;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1408
import java.util.*;

import static java.lang.Math.min;

/**
 * Problem C: Brave Princess Revisited
 */
public class Main {

	static final int INF = 1 << 29;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while (sc.hasNext()) {

			int N, M, L;
			N = sc.nextInt();
			M = sc.nextInt();
			L = sc.nextInt();
			if ((N | M | L) == 0) break;

			Map<Integer, List<Edge>> G = new HashMap<>();

			for (int i = 0; i < M; i++) {
				int A, B, D, E;
				A = sc.nextInt();
				B = sc.nextInt();
				D = sc.nextInt();
				E = sc.nextInt();
				G.putIfAbsent(A, new ArrayList<>());
				G.putIfAbsent(B, new ArrayList<>());
				G.get(A).add(new Edge(B, D, E));
				G.get(B).add(new Edge(A, D, E));
			}

			int[][] D = new int[N + 1][L + 1];
			boolean[][] V = new boolean[N + 1][L + 1];

			for (int i = 0; i < D.length; i++) Arrays.fill(D[i], INF);
			D[1][L] = 0;

			while (true) {

				int s = -1, l = -1, min = INF;

				for (int i = 1; i <= N; i++) {
					for (int j = 0; j <= L; j++) {
						if (!V[i][j] && D[i][j] < min) {
							min = D[i][j]; s = i; l = j;
						}
					}
				}

				if (min == INF) break;
				V[s][l] = true;

				for (Edge e : G.get(s)) {
					for (int i = 0; i <= L; i++) {
						D[e.to][i] = min(D[e.to][i], D[s][i] + e.enemy);
						if (i >= e.distance) {
							D[e.to][i - e.distance] = min(D[e.to][i - e.distance], D[s][i]);
						}
					}
				}
			}

			int min = INF;

			for (int i = 0; i <= L; i++) {
				min = Math.min(min, D[N][i]);
			}

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

class Edge {

	int to, distance, enemy;

	public Edge(int to, int distance, int enemy) {
		this.to = to;
		this.distance = distance;
		this.enemy = enemy;
	}
}

Measured memory_bytes: 66916
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#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 ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int a[3];
    REP(i,3){
        cin >> a[i];
    }
    sort(a,a+3);
    cout << a[2]*10+a[1]+a[0] << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect

NUM_LETTER = 26

def solve():
    s = list(raw_input())
    t = list(raw_input())
    Ns = len(s)
    # Create charDict
    charDict = [[] for i in range(NUM_LETTER)]
    for i in range(Ns):
        charDict[ord(s[i]) - ord('a')].append(i)
    # print charDict
    # Search
    ret = 0
    pk_1 = -1
    for i in range(len(t)):
        hashCharDict = ord(t[i]) - ord('a')
        # print "hashCharDict: " + str(hashCharDict)
        if len(charDict[hashCharDict]) == 0:
            ret = -1
            break
        else:
            ind = bisect.bisect(charDict[hashCharDict], pk_1)
            if ind == len(charDict[hashCharDict]):
                ret += Ns - pk_1
                pk_1 = charDict[hashCharDict][0]
                ret += pk_1
            else:
                ret += charDict[hashCharDict][ind] - pk_1
                pk_1 = charDict[hashCharDict][ind]
        # print "ret: " + str(ret)
    print ret

if __name__ == '__main__':
    solve()


Measured memory_bytes: 47372
N = int(input())
mlist = list(map(int,input().split()))

s = 1
for i in range(N):
    if mlist[i] == 0:
        print(0)
        s = 0
        break
    elif s > 0:
        s *= mlist[i]

    if s > 10 ** 18:
        s = -1
if i == N-1 and s != 0:
    print(s)

Measured memory_bytes: 88096
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define MAX(a,b) a=a>b?a:b
#define MIN(a,b) a=a<b?a:b
#define REP(i,x,n) for(int i=x;i<n;i++)
#define REPR(i,x,n) for(int i=n-1;i>=x;i--)
#define pb  push_back
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLr(obj) (obj).rbegin(), (obj).rend()
#define endl "\n"
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll MOD = 1e9 + 7;



int main(){
  ll x,y,a,b,c;
  vector<P>p,q,r;
  cin>>x>>y>>a>>b>>c;
  rep(i,a){
    ll d;cin>>d;
    p.pb(P(d,0));
  }
  rep(i,b){
    ll d;cin>>d;
    p.pb(P(d,1));
  }
  rep(i,c){
    ll d;cin>>d;
    p.pb(P(d,2));
  }
  sort(ALLr(p));
  ll X=0,Y=0,Z=0,i=0,ans=0;
  while(X+Y+Z<x+y){
    if(p[i].S==0){
      if(X<x){
        ans+=p[i].F;
        X++;
      }
    }
    if(p[i].S==1){
      if(Y<y){
        ans+=p[i].F;
        Y++;
      }
    }
    if(p[i].S==2){
      ans+=p[i].F;
      Z++;
    }
    i++;
  }
  cout<<ans<<endl;

}


Measured memory_bytes: 10604
#include <stdio.h>
#include <stdlib.h>
int sort(const void *a,const void *b){return *(int*)a-*(int*)b;}
int main(void){
    int n,k,ans=1e9;
    scanf("%d%d",&n,&k);
    int h[n];
    for (int i=0; i<n; i++){
        scanf("%d",&h[i]);
    }
    qsort (h,n,sizeof(int),sort);
    for (int i=0; i<n-k+1; i++){
        ans=ans<(h[i+k-1]-h[i])?ans:(h[i+k-1]-h[i]);
    }
    printf("%d\n",ans);
	return 0 ;
}


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

int const MAXN = 2000;

int ans[MAXN], X, Y, N, tmp[MAXN];

int main() {
  std::cin >> N >> X >> Y;
  std::fill_n(ans, N, 0);
  // 1.
  int n = N - (Y-X - 1);
  for(int i = 1; i < n; ++i) ans[i] = n-i;
  // 2.
  int m = Y - X + 1;
  for(int i = 1; i*2 < m; ++i) ans[i] += m;
  if(m%2 == 0) ans[m/2] += m/2;
  --ans[1];
  std::fill_n(tmp, m, 0);
  for(int i = X+1; i <= Y-1; ++i) ++tmp[std::min(i-X, Y+1-i)];
  for(int j = 1; j < X; ++j) {
    for(int i = 1; i <= m; ++i) ans[j+i] += tmp[i];
  }
  for(int j = Y+1; j <= N; ++j) {
    int d = j-Y;
    for(int i = 1; i <= m; ++i) ans[d+i] += tmp[i];
  }
  for(int i = 1; i < N; ++i) std::cout << ans[i] << std::endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n,s;
           n=int.Parse(Console.ReadLine());
            s = 0;
            for (int i = 1; i <= n; i++)
                s = s + i;
            Console.WriteLine(s);
            Console.ReadKey();
        }
    }
}


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

using ll = long long;

using namespace std;
int main() {
  ll n, k;
  cin >> n >> k;

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

  vector<ll> root(n);
  root[0] = 1;

  ll t = a[root[0] - 1];
  ll ix = 0;

  for (ll i = 0; i < n; i++) {
    t = a[root[i] - 1];
    if (t == 0) {
      t = root[i] - 1;
      ix = i;
      break;
    }
    a[root[i] - 1] = 0;
    root[i + 1] = t;
  }

  ll x;
  for (ll i = 0; i < ix + 1; i++) {
    if (root[i] == root[ix]) {
      x = i;
      break;
    }
  }
  // cout << x << endl;
  ll bef = x;
  ll loop = ix - x;
  // cout << bef << " " << loop << endl;

  if (k < bef) {
    cout << root[k] << endl;
  } else {
    ll p = ((k - bef) % loop) + bef;
    cout << root[p] << endl;
  }
  return 0;
}

Measured memory_bytes: 6396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
 
int main() {
  int a,b;
  cin >> a >> b;
  
  int ans=0;
  
  if(a < 2*b){
    ans = 0;
  }
  else{
    ans = a - 2*b;
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 764
import java.util.Scanner;
import java.util.Set;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        int tap = 1;
        int cnt = 0;
        while(tap<b){
            cnt++;
            tap += (a-1);
        }
        System.out.println(cnt);
    }
}

Measured memory_bytes: 21844
from collections import deque
S = str(input())
Q = int(input())
query = [ input().split() for _ in range(Q) ]

tag = False
que = deque([S])

for i in range(Q):
    if query[i][0] == str(1):
        if tag == False:
            tag = True
        else:
            tag = False
    elif query[i][0] == str(2):
        if query[i][1] == str(1):
            if tag == False:
                que.appendleft(query[i][2])
            else:
                que.append(query[i][2])
        else:
            if tag == False:
                que.append(query[i][2])
            else:
                que.appendleft(query[i][2])
ans = "".join(que)
if tag == True:
    ans = ans[::-1]
print(ans)


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

const int N = 1e5 + 7;

int f(int x)
{
	int res = 0;
	while (x)
		res += x % 10, x /= 10;
	return res;
}

int main()
{
	ios::sync_with_stdio(false);

	int n; cin >> n;
	int ans = 1000000;
	for (int i=1; i<n; i++)
		ans = min(ans, f(i) + f(n-i));	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace  std;
#define LL long long
const int mod = 1e9+7;
const int N = 2e5+55;
int to[200];
int x[N],y[N];
int l;
void f(char s[],int num[])
{
	int cnt=0;
	memset(to,0,sizeof to);
	for(int i=0;i<l;i++){
		if(to[s[i]]==0)
			to[s[i]]=++cnt;
		num[i]=to[s[i]];
	}
}

int main()
{
	char s1[N],s2[N];
	cin>>s1>>s2;
	l=strlen(s1);
	f(s1,x);
	f(s2,y);
	for(int i=0;i<l;i++){
		if(x[i]!=y[i]){
			printf("No\n");
			return 0;
		}
	}
	printf("Yes\n");
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(){
	int house[4][3][10];
	int b,f,r,v;
	int i,n,j,k;
	
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				house[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d %d %d %d",&b,&f,&r,&v);
		house[b-1][f-1][r-1] += v;
	}
	for(i=0;i<4;i++){
		for(j=0;j<3;j++){
			for(k=0;k<10;k++){
				printf(" %d",house[i][j][k]);
			}
			printf("\n");
		}
		if(3-i){
		printf("####################\n");
		}
	}
}

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

#ifdef LOCAL
#include "debug.h"
#else
#define DEBUG(...)
#endif

template <class T, class Op = multiplies<T>>
constexpr T power(T a, long long n, Op op = Op(), T e = {1}) {
  assert(n >= 0);
  while (n) {
    if (n & 1) e = op(e, a);
    if (n >>= 1) a = op(a, a);
  }
  return e;
}

template <unsigned M> struct modular {
  using m = modular;
  static constexpr unsigned mod = M;
  unsigned v;
  modular(long long x = 0) : v((x %= mod) < 0 ? x + mod : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((int)(v += b.v - mod) < 0) v += mod; return *this; }
  m& operator-=(m b) { if ((int)(v -= b.v) < 0) v += mod; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % mod; return *this; }
  m& operator/=(m b) { return *this *= power(b, mod - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
};

using mint = modular<power(10, 9) + 7>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (auto&& e : a) cin >> e;
  sort(rbegin(a), rend(a));
  vector dp(n + 1, vector<mint>(m + 1));
  dp[0][0] = 1;
  for (int e : a) {
    vector ndp(n + 1, vector<mint>(m + 1));
    for (int c = 0; c <= n; ++c) {
      for (int x = 0; x <= m; ++x) {
        if (dp[c][x] == 0) continue;
        if (x + e <= m) {
          ndp[c + 1][x + e] += dp[c][x] * (c + 1);
        }
        ndp[c][x] += dp[c][x] * (x - c * (e - 1));
        for (int y = 1; y < e and x + y <= m; ++y) {
          ndp[c][x + y] += dp[c][x] * (2 * c);
        }
        if (c < 2 or e < 2) continue;
        for (int y = 0; y <= e - 2 and x + y <= m; ++y) {
          ndp[c - 1][x + y] += dp[c][x] * ((e - y - 1) * (c - 1));
        }
      }
    }
    swap(dp, ndp);
  }
  mint res;
  for (int c = 0; c <= n; ++c) {
    res += dp[c][m];
  }
  cout << res.v << '\n';
}


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

public class Hello
{
    public static void Main()
    {
        int num = int.Parse(Console.ReadLine());
        int[] x = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int[] y = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();

        double[] diff = new double[num];

        for (int i = 0; i < num; i++)
        {
            diff[i] = Math.Abs(x[i] - y[i]);
        }

        // p1-p3
        for (double i = 1.0; i < 4.0; i++)
        {
            double sum = 0;

            foreach (double n in diff)
            {
                sum += Math.Pow(n, i);
            }

            double d = Math.Pow(sum, 1.0/i);
            Console.WriteLine(d.ToString("F6"));
        }

        // ???????¨????
        Console.WriteLine(diff.Max().ToString("F6"));
    }
}

Measured memory_bytes: 9756
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include <deque>

using namespace std;
typedef long long ll;

ll N, D, X[11][11] = {}, ans = 0;

int main() {
	cin >> N >> D;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= D; j++)cin >> X[i][j];
	}
	for (int i = 1; i < N; i++) {
		for (int j = i + 1; j <= N; j++) {
			double dis = 0;
			ll sum = 0;
			for (int k = 1; k <= D; k++) {
				sum += (X[i][k] - X[j][k])*(X[i][k] - X[j][k]);
			}
			dis = sqrt(sum);
			if (ceil(dis) == floor(dis))ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;

int main(){

    int x;
    cin>>x;

    int ans=0;
    if(x<600)ans=8;
    else if(x<800)ans=7;
    else if(x<1000)ans=6;
    else if(x<1200)ans=5;
    else if(x<1400)ans=4;
    else if(x<1600)ans=3;
    else if(x<1800)ans=2;
    else ans=1;

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

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define int long
#define ll long long
#define MOD (int)1000000007 
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int gcd(int a,int b){return b ? gcd(b,a%b) : a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}

main() {
    int N; cin >> N;
    map<int,int> m;
    rep(i,N){
        int a; cin >> a;
        m[a]++;
    }
    bool can = true;
    if(N%2==0){
        for(auto p:m){
            if(p.first%2==1 && p.second==2);
            else {can = false; break;}
        }
    }
    else {
        for(auto p:m){
            if(p.first==0 && p.second==1 ||
            p.first%2==0 && p.second==2);
            else {can = false; break;}
        }
    }
    if(can){
        ll ans=1;
        rep(i,N/2) ans=ans*2%MOD; 
        cout << ans << endl;
    }
    else cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 4224
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

int n;
cin>>n;
int rem=n%10;
if(rem==3)cout<<"bon";
else if(rem==0||rem==1||rem==6||rem==8)cout<<"pon";
else cout<<"hon";

    return 0;
  }


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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

int main(){
  FAST();

  int n;
  cin >> n;
  vi h(n);
  REP(i, 0, n)  cin >> h[i];

  int ans = 0, largest = 0;
  REP(i, 0, n){
      if (h[0] <= h[i] && h[i] >= largest){
        ans++;
        largest = h[i];
      }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<queue>
#include<map>
#include<stdio.h>
#include<string.h>
#include<string>
#include<string>
#include<set>
#include<stdlib.h>
#include<bitset>
#include<algorithm>
using namespace std;
#define ll long long
int n;
vector<int>v;
int main() {
#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
#endif // !ONLINE_JUDGE
	scanf("%d", &n);
	bool ans = false;
	int sum = 0, x;
	for (int i = 0; i < n; ++i) {
		scanf("%d", &x);
		if (x % 10 != 0)
			ans = true;
		sum += x;
		v.push_back(x);
	}
	if (!ans) 
		cout << 0 << endl;
	else if (sum % 10 != 0)
		cout << sum << endl;
	else {
		sort(v.begin(), v.end());
		for(int i=0;i<v.size();++i)
			if (v[i] % 10 != 0) {
				sum -= v[i];
				break;
			}
		cout << sum << endl;
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <unordered_map>
#include <math.h>
#include <cctype>
#include <stack>
using namespace std;
#define _USE_MATH_DEFINES

int main() {
	string c;
	stack<int> s;
	int a, b;
	while (cin >> c) {
		if (c == "+") {
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a + b);
		}
		else if (c == "-") {
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(b-a);
		}
		else if (c == "*") {
			a = s.top();
			s.pop();
			b = s.top();
			s.pop();
			s.push(a * b);
		}
		else {
			s.push(atoi(c.c_str()));
		}
	}
	cout << s.top() << endl;
}

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

int main() {
    int N,X;
    cin >> N >> X;
    int L[N];
    int d = 0;
    int count = 1;
    for(int i = 0; i < N; i++){
        cin >> L[i];
    }
    for(int i = 0; i < N; i++){
        d += L[i];
        if(d <= X)
        count++;
    }
    cout << count << endl;

}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cstdlib>
#define rep(i,n) for(int i = 0;i<(n);i++);
#define all(a) (a).begin(),(a).end()
using namespace std;
using ld = long double;
using ll = long long;
const ll INF = 10010010010;
typedef pair<ll, ll> P;
const ll mod = 1000000007;
ll gcd(ll a, ll b) {//a>b
	if (a < b)swap(a, b);
	if (a % b == 0) return b;
	else return gcd(b, a % b);
}

int main() {
	ll N;
	cin >> N;
	ll M;
	cin >> M;
	ll ans = 0;
	if (N == 1 )ans += 300000;
	else if (N == 2 )ans += 200000;
	else if (N == 3 )ans += 100000;
	if (M == 1)ans += 300000;
	else if (M == 2)ans += 200000;
	else if (M == 3)ans += 100000;
	if (N == 1 && M == 1)ans += 400000;
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    char x, y;
    cin >> x >> y;
    
    if(x < y){
        cout << "<" << endl;
    }else if(y < x){
        cout << ">" << endl;
    }else{
        cout << "=" << endl;
    }
    
    return 0;
}


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

int main(){

string A, B, C;
cin >> A >> B >> C;

int sum_size = A.size() + B.size() + C.size();
int trun = 0; //0 1 2
			  //a b c
int A_HP = A.size(), B_HP = B.size(), C_HP = C.size();
char vic;

	for(int i = 0; i < sum_size; i++)
	{
		//勝ち確定
		if(A_HP == 0 && trun == 0){
			vic = 'A';
			break;	
		}else if(B_HP == 0 && trun == 1){
			vic = 'B';
			break;
		}else if(C_HP == 0 && trun == 2){
			vic = 'C';
			break;
		}
		

		//Aのターン
		if(trun == 0)
		{
			
			
			if(A.at(A.size() - A_HP) == 'a')
			{	
				trun = 0;
			}else if(A.at(A.size() - A_HP) == 'b'){
				trun = 1;	
			}else if(A.at(A.size() - A_HP) == 'c'){
				trun = 2;	
			}
		A_HP--;
		continue;
		}
		
		//Bのターン
		if(trun == 1)
		{
			
			
			if(B.at(B.size() - B_HP) == 'a')
			{	
				trun = 0;
			}else if(B.at(B.size() - B_HP) == 'b'){
				trun = 1;	
			}else if(B.at(B.size() - B_HP) == 'c'){
				trun = 2;	
			}
		
		B_HP--;
		continue;
		}
		
		//Cのターン
		if(trun == 2)
		{
			
			
			if(C.at(C.size() - C_HP) == 'a')
			{	
				trun = 0;
			}else if(C.at(C.size() - C_HP) == 'b'){
				trun = 1;	
			}else if(C.at(C.size() - C_HP) == 'c'){
				trun = 2;	
			}
		
		C_HP--;
		continue;
		}

	}
 cout << vic << endl;
}


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

using namespace std;
using ll = long long;
using IP = pair<int, int>;

const ll INF = 1LL << 62;
#define atcoder(int)1e9+7
#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back

ll gcd(ll a, ll b) {//最大公約数
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	return (a / gcd(a, b))*b;
}

int main(){

	int n, m,ans = 0;
	int a = 1;

	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		a *= 2;
	}
	
	ans += (1900 * m + (n-m) * 100)* a;

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define reps(i,x) for(ll i=1;i<=(ll)(x);i++)
#define rrep(i,x) for(ll i=((ll)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(ll)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
int x[100];
int y[100];
int h[100];
int main() {
  int x;
  vector<int> vc ={7,5,3};
  cin >> x;
  if(find(vc.begin(), vc.end(), x) != vc.end()){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }
}



Measured memory_bytes: 256
def LI(): return list(map(int, input().split()))
def LI_(): return list(map(lambda x: int(x) - 1, input().split()))


def convert(nums):
    # print('conv', [2**i for i in nums])
    return sum([2**i for i in nums])


def is_on(ons, bulb, p):
    return bin(ons & bulb).count('1') % 2 == p

def is_all_on(ons, bulbs, ps):
    res = True
    for bulb, p in zip(bulbs, ps):
        # print(ons, bulb, is_on(ons, bulb, p))
        res &= is_on(ons, bulb, p)
    return res


n, m = LI()
k, s = [], []
for _ in range(m):
    _input = LI_()
    s.append(convert(_input[1:]))
    # print('s', _input[1:])

p = LI()

res = 0
for ons in range(2**n):
    res += is_all_on(ons, s, p)

print(res)


Measured memory_bytes: 3064
K = int(input())

def gcd(a, b):
  if b == 0:
    return a
  return gcd(b, a % b)


gcds = [[0 for _ in range(K + 1)] for _ in range(K + 1)]

for i in range(1, K + 1):
  for j in range(1, K + 1):
    gcds[i][j] = gcd(i, j)

s = 0
for i in range(1, K + 1):
  for j in range(1, K + 1):
    for k in range(1, K + 1):
      s += gcds[gcds[i][j]][k]

print(s)


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

int main(int argc, char const *argv[])
{
	int h,w,a,b;
	cin>>h>>w>>a>>b;
	for (int i = 0; i < h; ++i)
	{
		if (i<b)
		{
			for (int j = 0; j < w; ++j)
			{
				if (j<a)
				{
					cout<<0;
				}
				else
				{
					cout<<1;
				}
			}
		}
		else
		{
			for (int j = 0; j < w; ++j)
			{
				if (j<a)
				{
					cout<<1;
				}
				else
				{
					cout<<0;
				}
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 1280
using System;

class Program
{
  static void Main(string[] args)
  {
    int[] t = new int[3];
    string[] str = Console.ReadLine().Split(' ');
    t[0] = int.Parse(str[0]);
    t[1] = int.Parse(str[1]);
    t[2] = int.Parse(str[2]);

    int n5 = 0;
    int n7 = 0;

    for(int i = 0; i<3; i++) {
      if (t[i] == 5) {
        n5++;
      } else if (t[i] == 7) {
        n7++;
      }
    }

    if (n5 == 2 && n7 == 1) {
      Console.Write("YES");
    } else {
      Console.Write("NO");
    }
  }
}

Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<ll, int> P;
#define MOD (1000000007ll)

ll sq(ll x){
	return x*x;
}

int main(void){
	int cnt[26],i;
	string w;
	bool ans = true;
	fill(cnt,cnt+26,0);
	cin >> w;
	for(i = (w.length()-1); i>=0; --i){
		++cnt[w[i]-'a'];
	}
	for(i=0; i<26; ++i){
		if(cnt[i]%2){
			ans = false;
			break;
		}
	}
	cout << ((ans)?"Yes":"No") << endl;
	return 0;
}

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


int main(void) {
    int64_t A;
    string B;
    string aft = "";
    int64_t b,ans;
    int decimal = 0;
    cin >> A >> B;

    for(int i=0;i<B.size();i++) {
        if(B[i] == '.') {
            decimal = 1;
        } else {
            if(decimal) {
                decimal++;
            }
            aft += B[i];
        }
    }

    if(decimal == 0)decimal = 1;
    for(int i=decimal;i<3;i++) {
        aft += '0';
    }

//    b = strtol(&aft[0], NULL, 0);
    b = stoi(aft);
    ans = A * b;

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


Measured memory_bytes: 3628
import numpy as np
import scipy.sparse as sps
import scipy.misc as spm
import collections as col
import functools as func
import itertools as ite
import fractions as frac
import math as ma
import copy as cp
import sys
def sinput(): return sys.stdin.readline().strip()
def iinput(): return int(sinput())
def imap(): return map(int, sinput().split())
def fmap(): return map(float, sinput().split())
def iarr(): return list(imap())
def farr(): return list(fmap())
def sarr(): return sinput().split()

n,l = imap()
s = []
for i in range(n): s.append(sinput())

ans = "".join(sorted(s))
print(ans)


Measured memory_bytes: 19744