akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    int sum = 0;
    vi a(n); for(auto& e : a) cin >> e, sum += e;
    int me = (sum + 1) / 2;

    const int M = (int)4e6 + 1;
    bitset<M> dp;
    dp[0] = 1;

    rep(i, n){
        dp |= (dp << a[i]);
    }

    int res = -1;
    rep(i, me, M){
        if(dp[i]){
            res = i;
            break;
        }
    }

    cout << res << endl;

    return 0;
}


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

int n; ll po=1;

ll diff(const string &s,const string &t){
    ll ns=stoll(s),nt=stoll(t);
    return min(abs(ns-nt),po-abs(ns-nt));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    n=S.size();
    for (int i=0;i<n;++i) po*=10;
    vector<int> perm(10);
    iota(perm.begin(),perm.end(),0);
    string ans; ll Max=0;
    do {
        string cnt="";
        for (int i=0;i<n;++i) cnt+='0'+perm[i];
        if (Max<diff(cnt,S)){
            Max=diff(cnt,S);
            ans=cnt;
        } else if (diff(cnt,S)==Max){
            if (stoll(cnt)<stoll(ans)) ans=cnt;
        }
    } while(next_permutation(perm.begin(),perm.end()));
    cout << ans << '\n';
}


Measured memory_bytes: 3220
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <complex>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <numeric>
#include <math.h>

#define user spaesk
#define pi acos(-1)
#define lli long long int
#define ld long double
#define ff first
#define ss second
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

string s, t;
lli n, m;

lli cache[3003][3003];

lli dp(lli i, lli j) {

    if(i == n || j == m)
        return 0;

    lli &ans = cache[i][j];

    if(ans != -1) {
        return ans ;
    }

    if(s[i] == t[j]) {
        ans = dp(i + 1, j + 1) + 1;
    }
    else {
        ans = max(dp(i + 1, j), dp(i, j + 1));
    }

    return ans ;

}

void print(lli i, lli j) {

    if(i == n || j == m) {
        return ;
    }

    lli cur = dp(i, j);

    if(s[i] == t[j]) {
        cout<<s[i];
        return print(i + 1, j + 1);
    }
    else {
        if(cur == dp(i + 1, j)) {
            return print(i + 1, j);
        }
        return print(i, j + 1);
    }

    return ;
}

void solve()
{

    cin>>s>>t;

    n = s.size();
    m = t.size();

    memset(cache, -1, sizeof cache);

    lli p = dp(0, 0);

//    cout<<p<<'\n';

    print(0, 0);

    cout<<'\n';
    return ;
}

/*
*/

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

    int t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}



Measured memory_bytes: 71040
#include<stdio.h>
#include<string.h>
int n, dis[105], a[105][105];
bool vst[105];
void dijkstra()
{
    memset(vst, 0, sizeof(vst));
    memset(dis, 0x3f3f3f3f, sizeof(dis));
    dis[0] = 0;
    for(int i = 0; i < n; i++)
    {
        int k = n;
        for(int j = 0; j < n; j++)
            if(!vst[j] && dis[k] > dis[j]) k = j;
        vst[k] = 1;
        for(int j = 0; j < n; j++)
            if(!vst[j] && dis[j] > dis[k] + a[k][j])
                dis[j] = dis[k] + a[k][j];
    }
}
int main()
{
    scanf("%d", &n);
    memset(a, 0x3f3f3f3f, sizeof(a));
    for(int i = 1; i <= n; i++)
    {
        int m, j;
        scanf("%d%d", &m, &j);
        while(j--){
            int k, t;
            scanf("%d%d", &k, &t);
            if(t < a[m][k]) a[m][k] = t;
        }
    }
    dijkstra();
    for(int i = 0; i < n; i++)
        printf("%d %d\n", i, dis[i]);
    return 0;
}


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

const ll MX = 1e18;
const long double PI = acos(-1);

int main()
{
    int n, k, R, S, P;
    string t;
    cin >> n >> k >> R >> S >> P >> t;
    ll point = 0;
    ll pre_point = 0;
    rep(i,n)
    {
        pre_point = point;
        
        if(t[i] == 'r')
            point += P;
        else if(t[i] == 's')
            point += R;
        else
            point += S;

        if(i-k >= 0)
            if(t[i] == t[i-k])
            {
                t[i] = 'a';
                point = pre_point;
            }   
    }
    pri(point);
        
    return 0;
}


Measured memory_bytes: 764
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main() {
	int n; cin >> n;
	set<int> d; for (int i = 0; i < n; i++) {
		int tmp; cin >> tmp;
		d.insert(tmp);
	}
	cout << d.size() << endl;

	return 0;
}

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

int main() {
	long long N, M;
	cin >> N >> M;
	vector<pair<pair<long long, long long>, long long> > V(M);
	vector<vector<long long> > G(N);
	vector<long long> Par(N, -1);
	vector<long long> Back;
	vector<long long> ANS(N);
	vector<long long> COUNT(N, 0);
	for (int i = 0; i < M; i++) {
		cin >> V[i].first.first >> V[i].first.second;
		V[i].first.first--, V[i].first.second--;
		G[V[i].first.first].push_back(V[i].first.second);
		G[V[i].first.second].push_back(V[i].first.first);
		V[i].second = -1;
	}
	if (M % 2 == 1) {
		cout << -1 << endl;
		return 0;
	}
	Par[0] = 0;
	queue<long long> Q;
	Q.push(0);
	while (!Q.empty()) {
		long long P = Q.front();
		Back.push_back(P);
		Q.pop();
		for (int NP : G[P]) {
			if (Par[NP] == -1) Par[NP] = P, Q.push(NP);
		}
	}
	reverse(Back.begin(), Back.end());
	for (int i = 0; i < M; i++) {
		long long S = V[i].first.first, T = V[i].first.second;
		if (Par[S] != T && Par[T] != S) {
			cout << S + 1 << " " << T + 1 << endl;
			V[i].second = 0;
			COUNT[S]++;
		}
	}
	for (int i = 0; i < N - 1; i++) {
		long long P = Back[i];
		long long Q = Par[P];
		if (COUNT[P] % 2 == 0) {
			cout << Q + 1 << " " << P + 1 << endl;
			COUNT[Q]++;
		}
		else {
			cout << P + 1 << " " << Q + 1 << endl;
			COUNT[P]++;
		}
	}
}

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

using namespace std;
typedef long long 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 FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

void solve() {
  int max = 0;
  string ans = "", str;
  cin >> str;
  REP(i, str.length()) {
    if (str[i] == 'A' || ans.length() != 0) {
      ans += str[i];
    }
    if (str[i] == 'Z' && ans.length() != 0) {
      if (ans.length() > max) {
        max = ans.length();
      }
    }
  }
  cout << max << endl;
}
signed main() {
  solve();

  return 0;
}

Measured memory_bytes: 776
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, *LR = map(int, read().split())

    ans = 0
    for l, r in zip(*[iter(LR)] * 2):
        ans += r - l + 1

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9196
import java.util.*;

class Main {
	Scanner sc;
	String N;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.next();
		int ans = 0;
		int carry = 0;
		for (int i = N.length()-1; i >= 0; i--) {
			int d = N.charAt(i) - '0' + carry;
			int n = (i>0)?N.charAt(i-1)-'0':0;
			if (d > 5 || (d == 5 && n > 4)) {
				carry = 1;
				ans += 10-d;
			} else {
				carry = 0;
				ans += d;
			}
		}
		System.out.println(ans+carry);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}
	


Measured memory_bytes: 34848
S = input()

n = 0
w = 0
s = 0
e = 0
for si in S:
    if si == 'N':
        n += 1
    elif si == 'W':
        w += 1
    elif si == 'S':
        s += 1
    else:
        e += 1


ans = False
if (n and s) or (not n and not s):
    if (w and e) or (not w and not e):
        ans = True

if ans:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define rep(i,a,b) for(int i=a; i<b; i++)
#define dep(i,a,b) for(int i=a; i>=b; i--)
#define ALL(x)	(x).begin(), (x).end()
using namespace std;
const long long INF = 1e18 , MAXN =1e5, MOD = 1e9 + 7,N=1000010;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s1,s2;cin>>s1>>s2;
	for (int i=0;i<(int)s1.length();i++)
		if (s1[i]!=s2[i]){
			cout<<"No\n";
			return 0;
		}
	cout<<"Yes\n";
return 0;
}
//ghmru


Measured memory_bytes: 3648
n =int(input())
sp = []
for i in range(n):
  s,p = map(str, input().split())
  sp.append([s,int(p),i+1])
sp.sort(key= lambda x:x[1] ,reverse=True)
sp.sort(key= lambda x:x[0] )

for e in sp:
  print(e[2])

Measured memory_bytes: 3060
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);

int n,v,a[200111],nxt[20][200111],pre[20][200111],k,v2[20],dp1[1<<20],dp2[1<<20];
bool ans[200111];

int main()
{
	get2(n,v);
	int tmp=v;
	while(tmp)
	{
		v2[k++]=tmp;
		tmp>>=1;
	}
	v2[k++]=0;reverse(v2,v2+k);
	for(int i=1;i<=n;i++)get1(a[i]);
	for(int i=0;i<k;i++)
	{
		nxt[i][n+1]=n+1;pre[i][0]=0;
		for(int j=1,j2;j<=n;j=j2)
		{
			j2=j+1;
			while(j2<=n&&a[j2]-a[j2-1]<=v2[i])j2++;
			for(int t=j;t<j2;t++)
			{
				nxt[i][t]=j2;
				pre[i][t]=j-1;
			}
		}
	}
	
	for(int i=0;i<(1<<k-1);i++)
	{
		dp1[i]=1;
		dp2[i]=n;
	}
	for(int i=0;i<(1<<k-1);i++)
	{
		for(int j=0;j<k-1;j++)if(((i>>j)&1)==0)
		{
			dp1[i^(1<<j)]=max(dp1[i^(1<<j)],nxt[j][dp1[i]]);
			dp2[i^(1<<j)]=min(dp2[i^(1<<j)],pre[j][dp2[i]]);
		}
	}
	if(dp1[(1<<k-1)-1]==n+1)
	{
		for(int i=1;i<=n;i++)puts("Possible");
		return 0;
	}
	int all=(1<<k-1)-1;
	for(int i=0;i<(1<<k-1);i++)if(dp2[all^i]<nxt[k-1][dp1[i]])ans[dp1[i]]=1;
	for(int i=1;i<=n;i=nxt[k-1][i])
	{
		for(int j=i;j<nxt[k-1][i];j++)
		{
			if(ans[i])puts("Possible");
			else puts("Impossible");
		}
	}
	return 0;
}

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

using namespace std;

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

void Main()
{
	int a, b;
	cin >> a >> b;
	if(a < b){
		cout << "a < b" << endl;
	}else if(a > b){
		cout << "a > b" << endl;
	}else{
		cout << "a == b" << endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}



Measured memory_bytes: 3128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=1<<30;
const int mod=1e9+7;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    vector<int> h(n);
    rep(i,n){
      cin >> h[i];
    }
    vector<bool> c(n,true);
    rep(i,m){
      int a,b;cin >> a >> b;
      a--,b--;
      if(h[a]>=h[b]){
        c[b]=false;
      }
      if(h[a]<=h[b]){
        c[a]=false;
      }
    }
    int ans=0;
    rep(i,n){
      if(c[i]){
        ans++;
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3728
from collections import Counter

N = int(input())
A = [int(x) for x in input().split()]
d = Counter(A)
Q = int(input())

s = sum(map(lambda k: k * d[k], d))
for i in range(Q):
  B, C = [int(x) for x in input().split()]

  s += (C - B) * d[B]
  d[C] = d.get(C, 0) + d[B]
  d[B] = 0
  
  print(s)

Measured memory_bytes: 24156
#include <iostream>
#include <string>
using namespace std;
string s;
int main() {
    cin>>s;
    if (s == "SUN")cout<<7<<endl;
    else if (s == "MON")cout<<6<<endl;
    else if (s == "TUE")cout<<5<<endl;
    else if (s == "WED")cout<<4<<endl;
    else if (s == "THU")cout<<3<<endl;
    else if (s == "FRI")cout<<2<<endl;
    else if (s == "SAT")cout<<1<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<math.h>
int main()
{
    int n,a[5][200],i,j,sum=0,k=1,sumax,sum1;
    scanf("%d",&n);
    for(i=1;i<=2;i++)
    {
        for(j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    sum=a[1][1],sumax=a[1][1];
    for(i=1;i<=1;i++)
    {
        for(j=2;j<=n;j++)
        {

            if(a[i][j]>=a[i+1][j-1])
            {

            }
            else
            {
                sum1=sum;
                for(k=j-1;k<=n;k++)
                {
                    sum1=sum1+a[i+1][k];
                }
                if(sumax<sum1)
                    sumax=sum1;
            }
            sum=sum+a[i][j];
        }
        sum=sum+a[2][n];
        if(sum>sumax)
            sumax=sum;
    }
    printf("%d\n",sumax);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long n; cin>>n;
  
  long A[n];
  rep(i,n) cin>>A[i];
  
  long sum=0;
  rep(i,n) sum+=A[i];
  
  long memo=0;
  long num=0;
  
  rep(i,n) {
    memo+=A[i];
  
    if(memo>sum/2){
      num=max(i,0);
      break;
    }
  }
  
  long m1,m2;
  
  m1= abs(memo*2-sum);
  
  memo=memo- A[num];
  m2= abs(memo*2-sum);
  
    cout<<min(m1,m2)<<endl;
}

Measured memory_bytes: 1792
import java.util.*;

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

        long n = sc.nextInt();
        long ans = power(10,n) - power(9, n) - power(9, n) + power(8, n);
        ans %= 1000000007;
        ans = (ans + 1000000007) % 1000000007;

        System.out.println(ans);
    }

    static long power(long x, long n, int mod) {
        if (n == 0) {
            return 1;
        }
        long result = power(x, n / 2, mod);
        result = result * result % mod;
        if (n % 2 == 1) {
            result = result * x % mod;
        }
        return result;
    }

    static long power(long x, long n) {
        return power(x, n, 1000000007);
    }
}


Measured memory_bytes: 35616
import java.util.*;

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

    int dn = 1;
    for(int i = 0;i < d;i++){
      dn *= 100;
    }
    if(n < 100){
      System.out.println(dn * n);
    }else{
      System.out.println(dn * n + dn * 1);
    }
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
const double EPS=1e-8;
typedef vector<double>vec;
typedef vector<vec>mat;
inline double ABS(double a){return max(a,-a);}
vec gauss_jordan(const mat &A,const vec &b){
	int n=A.size();
	int m=A[0].size();
	mat B(n,vec(m+1));
	for(int i=0;i<n;i++)
		for(int j=0;j<m;j++)B[i][j]=A[i][j];
	for(int i=0;i<n;i++)B[i][m]=b[i];
	for(int i=0;i<m;i++){
		int pivot=i;
		for(int j=i;j<n;j++){
			if(ABS(B[j][i])>ABS(B[pivot][i]))pivot=j;
		}
		swap(B[i],B[pivot]);
		if(ABS(B[i][i])<EPS){
			return vec();
		}
		for(int j=i+1;j<=m;j++)B[i][j]/=B[i][i];
		for(int j=0;j<n;j++){
			if(i!=j){
				for(int k=i+1;k<=m;k++)B[j][k]-=B[j][i]*B[i][k];
			}
		}
	}
	for(int i=m;i<n;i++)if(ABS(B[i][m])>EPS)return vec();
	vec x(m);
	for(int i=0;i<m;i++)x[i]=B[i][m];
	return x;
}
char in[1000];
int q[110][20];
int p[110][20];
int r[110];
int c[110];
int main(){
	int a,b;
	bool fi=false;
	while(scanf("%d",&a),a){
		if(fi)printf("\n");
		fi=true;
		scanf("%d",&b);
		for(int i=0;i<a;i++)r[i]=0;
		for(int i=0;i<b;i++)c[i]=0;
		int t=0;
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)q[i][j]=-1;
		for(int i=0;i<a+1;i++)for(int j=0;j<b+1;j++){
			scanf("%s",in);
			if(in[0]=='?'){
				q[i][j]=t++;
				r[i]=1;
				c[j]=1;
			}else{
				sscanf(in,"%d",&p[i][j]);
			}
		}
		if(t>a+b){
			printf("NO\n");continue;
		}
		int sk=0;
		for(int i=0;i<a;i++)sk+=r[i];
		for(int i=0;i<b;i++)sk+=c[i];
		mat A(sk,vec(t));
		vec B(sk);
		int ind=0;
		for(int i=0;i<a;i++){
			if(!r[i])continue;
			B[ind]=p[i][b];
			for(int j=0;j<b;j++){
				if(~q[i][j])A[ind][q[i][j]]=1;
				else B[ind]-=p[i][j];
			}
			ind++;
		}
		for(int i=0;i<b;i++){
			if(!c[i])continue;
			B[ind]=p[a][i];
			for(int j=0;j<a;j++){
				if(~q[j][i])A[ind][q[j][i]]=1;
				else B[ind]-=p[j][i];
			}
			ind++;
		}
		vec x=gauss_jordan(A,B);
		if(x.size()==0){
			printf("NO\n");continue;
		}
		for(int i=0;i<x.size();i++)printf("%.0f\n",x[i]);
	}
}

Measured memory_bytes: 1248
import java.util.*;

public class Main{
	
	class C implements Comparable<C>{
		String s;
		int p;
		public C(String s, int p) {
			this.s = s;
			this.p = p;
		}
		public int compareTo(C o) {
			return o.p - this.p;
		}
		
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		boolean isfirst = true;
		while(true){
			int n = sc.nextInt();
			if(n == 0) break;
			if(! isfirst){
				System.out.println();
			}
			else{
				isfirst = false;
			}
			
			C [] data = new C[n];
			for(int i = 0; i < n; i++){
				String s = sc.next();
				int nowp = sc.nextInt() * 3 + sc.nextInt() * 0 + sc.nextInt() * 1;
				data[i] = new C(s, nowp);
			}
			Arrays.sort(data);
			for(int i = 0; i < n; i++){
				System.out.println(data[i].s + ","+data[i].p);
			}
		}
	}

	private void debug(Object... o) { System.out.println("debug = " + Arrays.deepToString(o)); }

	public static void main(String[] args) {
		new Main().doit();
	}
}

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

int main(){
    int n,k;
    cin >> n >> k;
    ll h[n],dp[n];
    for(int i = 0;i < n;i ++){
        cin >> h[i];
    }
    dp[0] = 0;
    for(int i = 1;i < n;i ++){
        ll m = 1e9;
        for(int j = 1;j < min(k,i)+1;j ++){
            if(abs(h[i]-h[i-j])+dp[i-j]<m) m = abs(h[i]-h[i-j])+dp[i-j];
        }
        dp[i] = m;
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    vll X(N);
    rep(i, N) cin >> X[i];

    ll ans = LINF;
    REP(P, 1, 101) {
        ll cost = 0;
        rep(i, N) {
            cost += (P - X[i]) * (P - X[i]);
        }
        ans = min(cost, ans);
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  int n, ti, pti;
  cin>>n;
  ti=0;
  pti=0;
  int pa;
  cin >> pa;
  while(pa%2 == 0){
      pa/=2;
      pti++;
    }
  for(int i = 1; i<n; i++){
    int a;
    cin>>a;
    while(a%2 == 0){
      a/=2;
      ti++;
    }
    if(pti<=ti){
      ti=0;
    }
    else{
      pti=ti;
    }
  }
  cout<<pti;
}

Measured memory_bytes: 256
N = gets.chomp.to_i

if N < 10
  puts N

elsif N < 100
  puts 9

elsif N < 1000
  ans = 9 + N - 99
  puts ans
elsif N < 10000
  puts 909
elsif N < 100000
  ans = 909 + N - 9999
  puts ans
else
  puts 90909
end

Measured memory_bytes: 1788
#include "bits/stdc++.h"
using namespace std;

int main() {
	int N;
	long long C;
	cin >> N >> C;
	vector <long long >X(N);
	vector <long long >Y(N);
	vector<long long>V(N);
	vector<long long>W(N);
	for (int i = 0; i < N; ++i) {
		cin >> X[i] >> V[i];
		Y[N - 1 - i] = C - X[i];
		W[N - 1 - i] = V[i];
	}
	vector<long long>R(N);
	vector<long long>L(N);
	vector<long long>Vsum(N);
	vector<long long>Wsum(N);
	//左先用
	{
		long long memo = 0;
		for (int i = 0; i < N; ++i) {
			if (0 != i) {
				Vsum[i] = Vsum[i - 1] + V[i];
			}
			else {
				Vsum[i] = V[i];
			}
			memo = max(memo, Vsum[i] - X[i]);
			R[i] = memo;
		}
	}
	//右先用
	{
		long long memo = 0;
		for (int i = 0; i < N; ++i) {
			if (0 != i) {
				Wsum[i] = Wsum[i - 1] + W[i];
			}
			else {
				Wsum[i] = W[i];
			}
			memo = max(memo, Wsum[i] - Y[i]);
			L[i] = memo;
		}
	}
	long long ans = 0;
	ans = max(ans, R[N - 1]);
	ans = max(ans, L[N - 1]);
	for (int i = 1; i < N; ++i) {
		ans = max(ans, Wsum[N - 1 - i] - 2 * Y[N - 1 - i] + R[i - 1]);
	}
	for (int i = 1; i < N; ++i) {
		ans = max(ans, Vsum[N - 1 - i] - 2 * X[N - 1 - i] + L[i - 1]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 9596
//Author rahuliitkgp

/*A thing of beauty is a joy forever,
Its loveliness increases,
it will never pass into nothingness.*/
//Men at Work :)

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int ll;

#define setbits(x)      __builtin_popcountll(x)
#define mod             1000000007
#define ps(x,y)         fixed<<setprecision(y)<<x
#define w(x)            int x; cin>>x; while(x--)
mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());

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

void cpp(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

ll power(ll a, ll b, ll M){
    if(b==0) return 1;
    if(b%2==0) return power((a*a)%M, b/2, M);
    return (a*power(a, b-1, M))%M;
}

int main(){
    cpp();
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll bitsOn = 0;
    for(ll i=0; i<s.size(); i++){
        if(s[i]-'0'){
            bitsOn++;
        }
    }
    ll numModMP1=0;
    ll numModMM1=0;
    bitsOn++;
    for(ll i=s.size()-1; i>=0; i--){
        if(s[i]=='1'){
            numModMP1+=power(2, (s.size()-1-i), bitsOn);
            numModMP1%=bitsOn;
        }
    }
    numModMP1=(numModMP1+bitsOn)%bitsOn;
    bitsOn--;
    if(bitsOn>1){
        bitsOn--;
        for(ll i=s.size()-1; i>=0; i--){
            if(s[i]=='1'){
                numModMM1+=power(2, (s.size()-1-i), bitsOn);
                numModMM1%=(bitsOn);
            }
        }
        numModMM1=(numModMM1+(bitsOn))%(bitsOn);
        bitsOn++;
    }
    vector<ll> dp(200002);
    dp[1]=1;
    for(ll i=2; i<dp.size(); i++){
        ll x = setbits(i);
        dp[i] = 1+dp[((i%x)+x)%x];
    }
    for(ll i=0; i<s.size(); i++){
        if(s[i]=='0'){
            ll y = bitsOn+1;
            ll x = ((numModMP1 + power(2, (s.size()-1-i), y))%y+y)%y;
            cout<<(dp[x]+1)<<endl;
        }
        else{
            if(bitsOn==1){
                cout<<0<<endl;
            }
            else{
                ll y = bitsOn-1;
                ll x = ((numModMM1 - power(2, (s.size()-1-i), y))%y+y)%y;
                cout<<dp[x]+1<<endl;
            }
        }
    }
    return 0;
}





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

using namespace std;

const int N=1e5+5;
typedef long long ll;
set<int> s,s2;
int a[N];
int main()
{
    int n,ans=0;
    cin >> n;
    for(int i=105;i<=n;i++)
    {
        int t=0;
        if(i%2)
        for(int j=1;j<=i;j++) if(i%j==0) t++;
        if(t==8) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define end(x) prev(x.end());
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

template<class T> void umin(T &a, T b) { a = min(a, b); }
template<class T> void umax(T &a, T b) { a = max(a, b); }

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

const int mod = 1e9+7;
const int N = 1e5+5;

ll a[N],ans,n,x;

void solve(){
	cin>>n>>x;
	forn(i,n)cin>>a[i];
	for(int i=2;i<=n;++i){
		if(a[i-1]+a[i]<=x)continue;
		else{ 
			ll xx=a[i-1]+a[i]-x;
			ans+=xx;		
			a[i]=max(0ll,a[i]-xx);
		}
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 998244353;


ll gcd(ll x, ll y) {
	if (y == 0) return x;
	return gcd(y, x%y);
}


int main() {
	
	ll a, b;
	cin >> a >> b;
	ll c = gcd(a, b);

	ll i = 1;
	VLL d;
	for (; i*i < c; i++) {
		if (c%i == 0) {
			d.push_back(i);
			d.push_back(c / i);
		}
	}
	if (i*i == c) {
		d.push_back(i);
	}
	sort(ALL(d));

	ll ans = 0;
	int m = d.size();
	VLL e;
	e.push_back(1);
	FOR(j, 1, m) {
		bool check = true;
		for (ll k : e) {
			if (gcd(k, d[j]) != 1)check = false;
		}
		if (check)e.push_back(d[j]);
	}
	cout << e.size() << endl;


}




Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rfor(i,a,b) for(ll (i) = (a); (i) > (b); --(i))
#define ll long long
#define mod (1000000007)
#define YES cout << "YES" << endl;
#define Yes cout << "Yes" << endl;
#define yes cout << "yes" << endl;
#define NO cout << "NO" << endl;
#define No cout << "No" << endl;
#define no cout << "no" << endl;
#define all(x) (x).begin(),(x).end()

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

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

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    for (ll d = 1; d <= k; ++d) {
        r *= n--;
        r /= d;
    }
    return r;
}

int main()
{
    ll n,sum = 0,sign,ans1 = 0,ans2 = 0;//sign 1 = Plus,2 = minus
    cin >> n;
    vector<ll> a(n);
    rep0(i, n)cin >> a[i];
    sign = 1;
    rep0(i, n){
        sum += a[i];
        if(sum == 0){
            if(sign == 1){
                ++sum;
                ++ans1;
            }else{
                --sum;
                ++ans1;
            }
        }else{
            if(sum > 0 && sign == 2){
                ans1 += abs(sum) + 1;
                sum = -1;
            }else if(sum < 0 && sign == 1){
                ans1 += abs(sum) + 1;
                sum = 1;
            }
        }
        (sign == 2)? sign = 1:sign = 2;
    }
    sign = 2;
    sum = 0;
    rep0(i, n){
        sum += a[i];
        if(sum == 0){
            if(sign == 1){
                ++sum;
                ++ans2;
            }else{
                --sum;
                ++ans2;
            }
        }else{
            if(sum > 0 && sign == 2){
                ans2 += abs(sum) + 1;
                sum = -1;
            }else if(sum < 0 && sign == 1){
                ans2 += abs(sum) + 1;
                sum = 1;
            }
        }
        (sign == 2)? sign = 1:sign = 2;
    }
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 1024
// B
import java.util.*;
//package hoge; のようなパッケージ宣言は提出前に除く
//インポート文など
public class Main { //クラス名はMain
    public static void main(String[] args) {
        //コード
        Scanner sc = new Scanner(System.in);
        int n = 0;
        String a = "";
        String b = "";
        String c = "";
        while (sc.hasNextInt()){
            n = Integer.parseInt(sc.next());
            a = sc.next();
            b = sc.next();
            c = sc.next();
        }
        if (a.equals(b) && a.equals(c)) System.out.println("0");
        else {
            char[] cha = a.toCharArray();
            char[] chb = b.toCharArray();
            char[] chc = c.toCharArray();
            int count = 0;
            for(int i = 0; i < n ; i++) {
                if(chb[i] == chc[i] && cha[i] == chc[i] && cha[i] == chc[i]) continue;
                if(cha[i] != chb[i]) count = count + 1;
                if(cha[i] != chc[i]) count = count + 1;
                if(chb[i] == chc[i]) count = count - 1;
            }
            System.out.println(count);
        } 
    }
}

Measured memory_bytes: 22740
import java.math.BigInteger;
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {
     static final long MOD = 1000000007;

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

        int N, A, B;
        long[] X = new long[100002];

        N = scanner.nextInt();
        A = scanner.nextInt();
        B = scanner.nextInt();

        for (int i = 0; i < N; i++) {
            X[i] = scanner.nextLong();
        }

        long ans = 0;
        for (int i = 1; i < N; i++) {
            if((X[i] - X[i - 1]) * A < B){
                ans += (X[i] - X[i - 1]) * A;
            }else{
                ans += B;
            }
        }

        System.out.println(ans);


    }





}




Measured memory_bytes: 47064
import sys
numbers = []

for i in range(3):
    for number in list(map(int, input().split())):
        numbers.append(number)

hits = []
N = int(input())
for _ in range(N):
    hits.append(int(input()))

lines = [
    [0, 1, 2],
    [3, 4, 5],
    [6, 7, 8],
    [0, 3, 6],
    [1, 4, 7],
    [2, 5, 8],
    [0, 4, 8],
    [2, 4, 6],
]

for line in lines:
    a, b, c = line
    if numbers[a] in hits and numbers[b] in hits and numbers[c] in hits:
        print('Yes')
        sys.exit()
        
print('No')

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

int main(){
    int n;
    cin >> n;
    if(n < 3*5*7)
        cout << 0 << endl;
    else if(n < 3*5*9)
        cout << 1 << endl;
    else if(n < 3*5*11)
        cout << 2 << endl;
    else if(n < 3*7*9)
        cout << 3 << endl;
    else if(n < 3*5*13)
        cout << 4 << endl;
    else
        cout << 5 << endl;
    return 0;
}


Measured memory_bytes: 256
N,K=map(int,input().split())
D=list(map(int,input().split()))

import re 
L=[0,1,2,3,4,5,6,7,8,9]
D=set(D)
L=set(L)
L_D =list(L-D)

while True:
    Value=N
    S_value=str(Value)
    for j in range(len(L_D)):
        S_value=re.sub('{}'.format(L_D[j]),'',S_value)
    if S_value=='':
        print('{}'.format(Value))
        exit(0)
    N+=1

Measured memory_bytes: 3188
from typing import Dict


class Node():
    left = None
    right = None
    parent = None
    char = ''
    value = 0

    def __init__(self, char: str = '', value: int = 0) -> None:
        self.char = char
        self.value = value


def get_coded_str_len(node: Node, base_str: str) -> int:
    if node.char:
        # Return the length of the coded string.
        return len(base_str) * node.value
    else:
        coded_str_len = 0
        if node.left:
            coded_str_len += get_coded_str_len(node.left, base_str + '0')
        if node.right:
            coded_str_len += get_coded_str_len(node.right, base_str + '1')
        return coded_str_len


if __name__ == "__main__":
    input_str = input()
    char_dict: Dict[str, int] = {}
    for s in input_str:
        if s in char_dict:
            char_dict[s] += 1
        else:
            char_dict[s] = 1

    nodes = [Node(char=k, value=v) for k, v in char_dict.items()]
    # Sort in the ascending order.
    nodes.sort(key=lambda x: x.value)

    if 1 == len(nodes):
        node = Node()
        node.left = nodes.pop(0)  # type: ignore
        nodes.append(node)
    else:
        while 1 != len(nodes):
            node = Node()
            node.left = nodes.pop(0)  # type: ignore
            node.right = nodes.pop(0)  # type: ignore
            node.value = node.left.value + node.right.value  # type: ignore
            nodes.append(node)
            # Sort in the ascending order.
            nodes.sort(key=lambda x: x.value)

    print(f"{get_coded_str_len(nodes[0], '')}")



Measured memory_bytes: 7384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

const int M=2019;
string s;

int main(){
	cin>>s;
	vi dp(M);
	ll res=0;
	for(int i=0;i<s.size();i++){
		vi DP(M);
		int t=s[i]-'0';
		DP[t]++;
		for(int j=0;j<M;j++) DP[(10*j+t)%M]+=dp[j];
		dp=DP;
		res+=dp[0];
	}
	cout<<res<<endl;
}

Measured memory_bytes: 3744
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#define REP(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long int LL;
typedef vector<int> VI;

int main() {
  int N, K;
  cin >> N >> K;
  string S;
  cin >> S;
  int s[100000], e[100000], sC = 0, eC = 0;
  s[sC++] = 0; e[eC++] = 0;
  REP(i, N) {
    if(S[i] == '1' && (i==0 || S[i-1]=='0')) {
      s[sC++] = i;
    }
    if(S[i] == '1' && (i==N-1 || S[i+1]== '0')) {
      e[eC++] = i+1;
    }
  }
  s[sC++] = N; e[eC++] = N;
  
  if(K >= sC) {
    cout << N << endl;
    return 0;
  }
  int max = 0;
  REP(i, sC-K) {
    if(e[i+K] - s[i] > max) {
      max = e[i+K] - s[i];
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
  
int main() {
  int h,w;
  cin >> h >> w;
  rep(i,w+2) cout << "#";
  cout << endl;
  rep(i,h) {
    string s;
    cin >> s;
    cout << "#" << s << "#" << endl;;
  }
  rep(i,w+2) cout << "#";
  cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
int main(void){
    int n,q;
    string s;
    cin>>n>>q>>s;
    int AC[100010]={};
    for(int i=0;i<n-1;i++){
        AC[i+1]=AC[i];
        if(s[i]=='A'&&s[i+1]=='C'){
            AC[i+1]++;
        }
    }
    for(int i=0;i<q;i++){
        int L,R;
        cin>>L>>R;
        L--,R--;
        if(L==0) cout<<AC[R]<<endl;
        else cout<<AC[R]-AC[L]<<endl;
    }
}

Measured memory_bytes: 1408
while True:
    m, f, r = map(int, input().split())
    total = m + f
    if m == f == r == -1:
        break
    if (m == -1) | (f == -1):
        print("F")
    elif 80 <= total:
        print("A")
    elif 65 <= total < 80:
        print("B")
    elif 50 <= total < 65:
        print("C")
    elif 30 <= total < 50:
        if 50 <= r:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")


Measured memory_bytes: 5596
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<vector>
#define N 5010
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
priority_queue<pii> q;
vector<int> g[N];int vis[N],a[N];
int gcd(int a,int b) { return a?gcd(b%a,a):b; }
int dfs(int x,int n)
{
	for(int y=1;y<=n;y++)
		if(!vis[y]&&gcd(a[x],a[y])>1)
			vis[y]=1,dfs(y,n),g[x].push_back(y);
	return 0;
}
int main()
{
	int n;scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);while(!q.empty()) q.pop();
	for(int i=1;i<=n;i++)
		if(!vis[i]) vis[i]=1,dfs(i,n),q.push(mp(a[i],i));
	while(!q.empty())
	{
		int x=q.top().second;
		q.pop(),printf("%d ",a[x]);
		for(int i=0;i<(int)g[x].size();i++)
			q.push(mp(a[g[x][i]],g[x][i]));
	}
	return !printf("\n");
}


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

int main()
{
    long long n;
    cin >> n;
    cout << n << ":";
    long long tmp = n;
    long long p = 2;
    while (p * p <= n)
    {
        if (tmp % p == 0)
        {
            cout << " " << p;
            tmp /= p;
        }
        else
        {
            ++p;
        }
    }
    if (tmp != 1)
        cout << " " <<tmp;
    cout << endl;
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

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

  ll h, w, n;
  cin >> h >> w >> n;

  h = max(h, w);

  cout << ((n + h - 1) / h) << en;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <queue>
#include <functional>
#include <cstring>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using ll = long long;

int main() {
	int N;
	std::vector<int> a;

	cin >> N;
	a.resize(3 * N);
	for (int i = 0; i < 3 * N; ++i) {
		cin >> a[i];
	}

	ll sum1 = 0, sum2 = 0;
	std::vector<ll> split_num1(N + 1), split_num2(N + 1);
	std::priority_queue<int, std::vector<int>, std::greater<int> > fwd;
	std::priority_queue<int> bck;

	for (int i = 0; i < N; ++i) {
		sum1 += a[i];
		fwd.push(a[i]);
	}

	split_num1[0] = sum1;

	for (int i = N; i < 2 * N; ++i) {
		fwd.push(a[i]);
		sum1 = sum1 + a[i] - fwd.top();
		fwd.pop();
		split_num1[i - N + 1] = sum1;
	}

	for (int i = 2 * N; i < 3 * N; ++i) {
		sum2 += a[i];
		bck.push(a[i]);
	}

	split_num2[N] = sum2;

	for (int i = 2 * N - 1; i >= N; --i) {
		bck.push(a[i]);
		sum2 = sum2 + a[i] - bck.top();
		bck.pop();
		split_num2[i - N] = sum2;
	}

	ll ans = -ll(1e18);

	for (int i = 0; i <= N; ++i) {
		ans = std::max(ans, split_num1[i] - split_num2[i]);
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 4088
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int k, x;
    cin >> k >> x;
    int l = x - k + 1;
    if (l < -1000000) l =  -1000000;
    int r = x + k - 1;
    if (r > 1000000) l = 1000000;
    for (int i = l; i <= r; i++) {
        if (i == l) cout << l;
        else cout << " " << i;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(String(myOut));

function main(){
  var n = next();
  var l = next();
  var a = nexts(n);
  var x = -1;
  var ans = [];
  for(var i = 1; i < n; i++){
    if(a[i]+a[i-1] >= l){
      x = i;
      break;
    }else ans.push(i);
  }
  if(x === -1)return "Impossible";
  for(var i = n-1; i >= x; i--)ans.push(i);
  console.log("Possible");
  return ans.join("\n");
}

Measured memory_bytes: 32972
// 2015/03/09 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;

		if(n==0)
			break;

		int y;
		cin >> y;

		int b_max = 0;
		double g_max = 0.0;

		for(int i=0; i<n; i++){
			int b, r, t;
			cin >> b >> r >> t;

			double g;

			if(t==1){
				g = 1.0+((double)(y*r))/100.0;
			}
			else{
				g = 1.0;
				for(int j=0; j<y; j++){
					g *= (1.0+((double)r)/100.0);
				}
			}

			if(g>g_max){
				b_max = b;
				g_max = g;
			}
		}

		cout << b_max << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define pb push_back
#define vl vector<long long>
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
long long INF = 1e10;

int main(){
    ll n;cin >> n;
    ll mar[5]; rep(5) mar[i]=0;
    vector<string> a(n);
    rep(n){
        cin >> a[i];
        switch(a[i][0]){
            case 'M':mar[0]++; break;
            case 'A':mar[1]++; break;
            case 'R':mar[2]++; break;
            case 'C':mar[3]++; break;
            case 'H':mar[4]++; break;
            default: break;
        }
    }
    vector<string> S(1 << 5); //2進数にした文字列を格納するstring
    for (int i = 0; i < 1<<5; i++)
    {
        for (int j = 0; j < 5; j++)
        {
            int x = 1 << j;
            x &= i;
            S[i].push_back('0' + (x >> j)); 
        }
    }
    long long ans = 0;
    for(int i = 0;i < 1<<5;i++){
        int c = 0;
        for(int j = 0;j < 5;j++){
            if(S[i][j] == '1') c++;
        }
        if(c == 3){
            ll res = 1;
            for(int j = 0;j < 5;j++){
                if(S[i][j] == '1') res *= mar[j];
            }
            ans += res;
        }
    }
    cout << ans << endl;
}

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

ll n, m;
ll a[30];

using ll = long long;
ll mod_pow(ll x, ll n, ll mod)
{
    ll res = 1;
    while (n > 0)
    {
        if (n & 1)
            (res *= x) %= mod;
        (x *= x) %= mod;
        n >>= 1;
    }
    return res;
}

int main()
{
    string s;
    cin >> n >> s;
    ll ans = 2;
    a[s[0] - 'a']++;
    for (int i = 1; i < n; i++)
    {
        a[s[i] - 'a']++;
        ans += ans * mod_pow(a[s[i] - 'a'], mod - 2, mod);
        ans %= mod;
    }
    ans--;
    cout << ans % mod << endl;
}

Measured memory_bytes: 512
#include <iostream>

int main(void)
{
    int a, b, c;
    std::cin >> a >> b >> c;
    bool flag = ((a + b) == c) || ((a + c) == b) || ((b + c) == a);
    std::cout << (flag ? "Yes" : "No") << std::endl;
    return 0;
}


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

using namespace std;


#define MAXN 301
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n, m;
  vector<int> v[MAXN];
  cin >> n >> m;
  for (int i = 0; i < n; ++i) {
    int a[MAXN];
    for (int j = 0; j < m; ++j) {
      cin >> a[j];
      a[j]--;
    }
    for (int j = m-1; j >= 0; --j) {
      v[i].push_back(a[j]);
    }
  }
  int ans = MAXN+1;
  for (int i = 0; i < m; ++i) {
    int cur[MAXN] = {};
    for (int j = 0; j < n; ++j) {
      cur[v[j].back()]++;
    }
    int mx = 0;
    int mxj = 0;
    for (int j = 0; j < m; ++j) {
      if (cur[j]>mx) {
        mx = cur[j];
        mxj = j;
      }
    }
    for (int j = 0; j < n; ++j) {
      v[j].erase(find(v[j].begin(), v[j].end(), mxj));
    }
    ans = min(ans, mx);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 896