akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ss(x) (int) x.size()
#define cat(x) cout << #x << " = " << x << endl
 
using namespace std;

int n;

int query1(int nr, int l, int r) {
	cout << "? " << nr << " ";
	for(int i = l; i <= r; ++i) {
		cout << i << " ";
	}
	cout << endl;
	string x;
	cin >> x;
	return x[0] == 'R';
}

int query2(int nr, int l, int r) {
	cout << "? " << nr << " ";
	for(int i = 1; i <= l; ++i)
		cout << i << " ";
	for(int i = r; i <= 2 * n; ++i)
		cout << i << " ";
	cout << endl;
	string x;
	cin >> x;
	return x[0] == 'R';
}

int ans[200];
		

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	
	int beg = query1(1, 2, n);
	
	int l = 1;
	int r = n;
	
	while(l < r) {
		int m = (l + r + 1) / 2;
		if(query1(m, m + 1, m + n - 1) == beg)
			l = m;
		else
			r = m - 1;
	}
	
	for(int i = 1; i <= l; ++i) 
		ans[i] = query1(i, l + 1, l + n - 1);
	for(int i = l + 1; i < l + n; ++i)
		ans[i] = query2(i, l - 1, l + n + 1);
	for(int i = l + n; i <= 2 * n; ++i)
		ans[i] = query1(i, l + 1, l + n - 1);
	cout << "! ";
	for(int i = 1; i <= 2 * n; ++i) 
		cout << (ans[i] == 1 ? "R" : "B");
	
		
	
	return 0;
}


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

int main()
{
	int n;
	cin >> n;
	if (n == 1)
	{
		cout << "Hello World" << endl;
		return 0;
	}
	int a, b;
	cin >> a >> b;
	cout << a + b << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
typedef complex<double> P;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 29;
static const LL LL_INF = 1ll << 60;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

#ifdef WIN32
#define dump(x) cout << #x << " = " << (x) << "\n"
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n"
#else
#define dump(x)
#define debug(x)
#endif

struct edge {
	int to;
	int cost;
	edge( int t, int c ) {
		to = t;
		cost = c;
	}
};
int n;
int r[ 10 ][ 10 ];
vector<edge> e[ 10 ];

void dijkstra( int s ) {
	fill( r[ s ], r[ s ] + 10, INF );
	priority_queue< PII, vector<PII>, greater<PII> > que;
	que.push( PII( s, 0 ) );
	while ( que.size() ) {
		int to = que.top().first;
		int cost = que.top().second;
		que.pop();
		if ( r[ s ][ to ] < cost ) {
			continue;
		}
		r[ s ][ to ] = cost;
		for ( int i = 0; i < e[ to ].size(); i++ ) {
			if ( r[ s ][ e[ to ][ i ].to ] > cost + e[ to ][ i ].cost ) {
				r[ s ][ e[ to ][ i ].to ] = r[ e[ to ][ i ].to ][ s ] = cost + e[ to ][ i ].cost;
				que.push( PII( e[ to ][ i ].to, cost + e[ to ][ i ].cost ) );
			}
		}
	}
}

int main() {
#ifdef WIN32
	printf( "Debug Mode\n" );
#endif
	while ( ~scanf( "%d", &n ) && n ) {
		for ( int i = 0; i < 10; i++ ) {
			e[ i ].clear();
		}
		int m = 0;;
		for ( int i = 0; i < n; i++ ) {
			int s, g, c;
			scanf( "%d %d %d", &s, &g, &c );
			m = max( max( s, g ), m );
			dump( m );
			e[ s ].push_back( edge( g, c ) );
			e[ g ].push_back( edge( s, c ) );
		}
		for ( int i = 0; i < 10; i++ ) {
			if ( e[ i ].size() ) {
				m = i;
			}
			else {
				break;
			}
		}
		int ans_cost = INF;
		int ans_t = 0;
		for ( int i = 0; i <= m; i++ ) {
			dijkstra( i );
		}
		for ( int i = 0; i <= m; i++ ) {
			int cost = 0;
			for ( int j = 0; j <= m; j++ ) {
				cost += r[ i ][ j ];
			}
			if ( ans_cost > cost ) {
				ans_cost = cost;
				ans_t = i;
			}
		}
		printf( "%d %d\n", ans_t, ans_cost );
	}
	return 0;
}

Measured memory_bytes: 1192
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;
#define MAX_N 100



int main()
{
	int n,maxWeight;
	cin>>n>>maxWeight;
	int *value = new int[n];
	int *weight = new int[n];
	vector<vector<int>> dp(n+1,vector<int>(maxWeight+1));
	rep(i,n+1){
		rep(j,maxWeight+1) dp[i][j] = 0;
	}
	rep(i,n){
		cin>>value[i]>>weight[i];
	}
	for(int i = 1; i <= n; i++){
		for(int j = 0; j <= maxWeight; j++){
			if( j >= weight[i-1]){
				dp[i][j] = max(dp[i-1][j],dp[i-1][j-weight[i-1]] + value[i-1]);
			}else{
				dp[i][j] = dp[i-1][j];
			}
		}
	}
	int ans = 0;
	rep(j,maxWeight+1){
		ans = max(ans,dp[n][j]);
	}
	cout<<ans<<endl;
	return 0;
}




Measured memory_bytes: 6860
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
const int MAX = 1000001;
const long long int MOD = 1000000007;

long long int fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main(){
	long long int N,ans=0;
	cin>>N;
	long long int ten[N+1],nine[N+1],eight[N+1];
	ten[0]=nine[0]=eight[0]=1;
	
	COMinit();
	
	for(int i=1;i<=N;i++){
		ten[i]=ten[i-1]*10%MOD;
		nine[i]=nine[i-1]*9%MOD;
		eight[i]=eight[i-1]*8%MOD;
	}
	ans=(ten[N]-nine[N]+MOD)%MOD;
	for(int i=1;i<=N;i++){
		ans=(ans-eight[N-i]*COM(N,i)+MOD)%MOD;
	}
	cout<<ans;
	return 0;
}

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

const int maxn = 2e5 + 7;

int n, a[maxn];
 
int main() {
	scanf("%d", &n);
	
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
	}
	
	int l = 1, xor_sum = 0;
	ll ans = 0;
	for (int r = 1; r <= n; ++r) {
		while (xor_sum & a[r]) {
			xor_sum ^= a[l];
			++l;
		}
		xor_sum ^= a[r];
		ans += (ll)r - l + 1;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main(){
  long long n,k;
  cin>>n>>k;
  long long res=0;
  for(long long i=k;i<=n+1;++i){
    long long first=i*(i-1)/2;
    long long final=(n*2-i+1)*i/2;
    long long add=final-first+1;
    res=(res+add)%1000000007;
  }
  cout<<res<<endl;
  return 0;
}

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

int main()
{
    int a[4];
  	cin>>a[0]>>a[1]>>a[2];
  	sort(a,a+3);
  	int k;
  	cin>>k;
  	for(int i=0 ; i<k ; ++i)
    a[2]*=2;
	cout<<a[0]+a[1]+a[2]<<endl;
  	return 0;
}

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

int main() {
  int N;
  int num;
  int fx = 0;
  int digit = 0;
  int i;
  int x = 10;
  int count = 0;
  
  cin >> N;
  num = N;
  while (num != 0) {
  	num /= 10;
    digit++;
  }
  
  for (i = 0; i < digit; i++) {
	fx = fx + ((N % x) / (x / 10));
    x *= 10;
  }

  if (N % fx == 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] A = new int[N][3];
		boolean ok = true;
		for(int i = 0; i < N; i++) {
			A[i][0] = sc.nextInt();
			A[i][1] = sc.nextInt();
			A[i][2] = A[i][1] - A[i][0];
		}
		Arrays.sort(A, (x,y) -> x[1]-y[1]);
		long time = 0;
		for(int i = 0; i < N; i++) {
			if(time > A[i][2]) {
				ok = false;
				break;
			}
			time += A[i][0];
		}
		System.out.println(ok ? "Yes" : "No");
	}

}


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

int main(){
  int D;
  cin >> D;
  if(D==22) cout << "Christmas Eve Eve Eve" << endl;
  else if(D==23) cout << "Christmas Eve Eve" << endl;
  else if(D==24) cout << "Christmas Eve" << endl;
  else cout << "Christmas" << endl;
}

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

using namespace std;

int main(){

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    s[k-1] = tolower(s[k-1]);

    cout << s << '\n';

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const char White = '.';
    const char Black = '#';
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var n = int.Parse(input.ReadLine());
        var s = input.ReadLine();
        
        var wcount = new int[n];
        var bcount = new int[n];

        for(int i=0; i<n; i++) {
            var c = s[i];
            wcount[i] = (i > 0 ? wcount[i - 1] : 0) + (c == White ? 1 : 0);
            bcount[i] = (i > 0 ? bcount[i - 1] : 0) + (c == Black ? 1 : 0);
        }

        int min = int.MaxValue;

        for(int i=0; i<n; i++) {
            var co = bcount[i] + (wcount.Last() - wcount[i]);
            min = Math.Min(min, co);
        }

        min = Math.Min(min, wcount.Last()); //all w
        min = Math.Min(min, bcount.Last()); //all b

        return min;
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 13408
IDENTIFICATION DIVISION.
      PROGRAM-ID. 056A.
      DATA DIVISION.
      WORKING-STORAGE SECTION.
      01 INP PIC X(3).
      01 A   PIC X(1).
      01 B   PIC X(1).
      
      PROCEDURE DIVISION.
      ACCEPT INP.
      UNSTRING INP DELIMITED  BY " "
      INTO 	A
      		B.

      IF A = "H" 
         IF B = "H"
      	    DISPLAY "H"
         ELSE
      	    DISPLAY "D"
      	 END-IF
      ELSE
      	 IF B = "H"
      	    DISPLAY "D"
         ELSE
			DISPLAY "H"
         END-IF
      END-IF.
      
      STOP RUN.

Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[200005],b[200005];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	int ans = 0;
	for(int i=28;i>=0;i--){
		vector<int>z,o;
		for(int j=1;j<=n;j++){
			if(((b[j]>>i)&1)){
				o.pb(b[j]%(1<<i));
			}
			else{
				z.pb(b[j]%(1<<i));
			}
		}
		SORT(o); SORT(z);
		bool flag = 0;
		for(int j=1;j<=n;j++){
			if(((a[j]>>i)&1)){
				int v = a[j]%(1<<i);
				int ee = POSL(z,(1<<i)-v); //[0,ee)
				int f = POSL(o,(1<<i)-v); //[f,INF)
				if(ee%2 == 1) flag^=1;
				if((o.size()-f)%2 == 1) flag^=1;
			}
			else{
				int v = a[j]%(1<<i);
				int ee = POSL(z,(1<<i)-v); //[ee,INF)
				int f = POSL(o,(1<<i)-v); //[0,f)
				if(f%2 == 1) flag^=1;
				if((z.size()-ee)%2 == 1) flag^=1;
			}
		//	cout<<flag<<endl;
		}
		if(flag) ans += (1<<i);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3756
#include<iostream>
#include <algorithm>
#include<string>
#include <numeric>
#include<math.h>
#include <bits/stdc++.h>
using namespace std;

int main(void) {
    int n;
    cin>>n;
    if(n%2==0)cout<<n<<endl;
    else cout<<n*2<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    string s;
    cin >> s;
    ll n = s.size();
    ll k;
    cin >> k;

    vector<pair<char, int>> a;
    int cur = 1;
    for (int i = 1; i < n; ++i) {
        if (s[i] == s[i-1]) {
            ++cur;
        } else {
            a.emplace_back(s[i-1], cur);
            cur = 1;
        }
    }
    a.emplace_back(s.back(), cur);

    ll ans;
    if (a.size() == 1) {
        ll len = n * k;
        ans = len/2;
    } else {
        ans = 0;
        for (int i = 1; i < a.size()-1; ++i) {
            ans += a[i].second/2;
        }
        ans *= k;
        if (a.front().first == a.back().first) {
            ans += a.front().second/2;
            ans += a.back().second/2;
            ll l = a.front().second + a.back().second;
            ans += (l/2)*(k-1);
        } else {
            ans += (a.front().second/2) * k;
            ans += (a.back().second/2) * k;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
//2020.1.22
//s1270188 xxxmk2
//icpc_2019 pre2

#include<stdio.h>
#define N 50
#define LONG 1000

//global
char data[N][N+1], input[LONG+1];
int x, y, h, w;

//prototype
int find(char,int,int);

int main(){
  int i, sum;

  while(1){
    //input
    scanf("%d %d",&h,&w);
    if(h==0 && w==0) break;
    for(i=0;i<h;i++) scanf(" %s",data[i]);
    scanf(" %s",input);

    //count
    for(i=sum=x=y=0;input[i]!='\0';i++) sum+=find(input[i],x,y);
    
    //output
    printf("%d\n",sum);
  }
  
  return 0;
}



int find(char a,int xx,int yy){
  int i, j, cnt=0;

  for(i=0;i<h;i++){
    for(j=0;j<w;j++) if(data[i][j]==a) break;
    if(j<w) break;
  }

  if(xx<i) cnt+=i-xx;
  else cnt+=xx-i;

  if(yy<j) cnt+=j-yy;
  else cnt+=yy-j;

  x=i;
  y=j;
  
  return cnt+1;
}



Measured memory_bytes: 2040
# region header
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos, pi, e
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
N = ri()
p = ri_()
ans = 0
for i in range(1, N - 1):
    if p[i - 1] < p[i] < p[i + 1] or p[i + 1] < p[i] < p[i - 1]:
        ans += 1
print(ans)


Measured memory_bytes: 63724
#include <iostream>
#include <vector>

uint32_t root(std::vector<uint32_t>& forest, uint32_t x) {
  return forest[x] == x ? x : forest[x] = root(forest, forest[x]);
}

bool judge(std::vector<uint32_t>& forest, uint32_t x, uint32_t y) {
  return root(forest, x) == root(forest, y);
}

void unite(std::vector<uint32_t>& forest, std::vector<uint32_t>& rank,
           uint32_t x, uint32_t y) {
  x = root(forest, x);
  y = root(forest, y);
  if (x != y) {
    if (rank[x] <= rank[y])
      forest[x] = y;
    else
      forest[y] = x;
    if (rank[x] == rank[y]) rank[x]++;
  }
  return;
}

int main() {
  uint32_t N = 0, Q = 0;
  std::cin >> N >> Q;

  std::vector<uint32_t> parent(N), rank(N, 0);
  for (uint32_t i = 0; i < N; i++) parent[i] = i;

  uint32_t P = 0, A = 0, B = 0;
  for (size_t i = 0; i < Q; i++) {
    std::cin >> P >> A >> B;
    if (P == 0) {
      unite(parent, rank, A, B);
    } else {
      std::cout << (uint32_t)judge(parent, A, B) << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 3300
n = int(input())
a = [int(a) for a in input().split()]




#%%
ave = sum(a)/len(a)

least_dif = 99999
ans = 0
for i, num in enumerate(a):
    dif = abs(num - ave)
    if dif < least_dif:
        least_dif = dif
        ans = i

print(ans)

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  
  bool flag = false;
  if(a==5 && b==5 && c==7) flag = true;
  if(a==5 && b==7 && c==5) flag = true;
  if(a==7 && b==5 && c==5) flag = true;
  
  if(flag) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  
  return 0;
}

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

int main(){
  int n;
  while(cin >> n){
    if(n==0)break;

    int A = 0, B = 0, a, b;
    for(int i=0;i<n;i++){
      cin >> a >> b;
      if(a > b) A += a+b;
      else if(a < b) B += a+b;
      else A += a, B += b;
    }

    cout << A << " " << B << endl;
  }
}

Measured memory_bytes: 1160
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include<vector>
#include<iomanip>
#include<map>
#include <queue>
#include<cmath>
#include<cstdio>
#include<iomanip>


using namespace std;
using ll = long long int; 

int main(void){

    int n, m;
    cin>>n>>m;

    int table[n][m];

    for(int i=0;i<m;i++){
        int s, c;
        cin>>s>>c;

        table[i][0] = s;
        table[i][1] = c;

    }

    int start = 0;
    if(n!=1) start = pow(10, n-1);
    
    for(int num = start;num<pow(10, n);num++){
        bool piv = true;

        if(n==3){
            for(int i=0;i<m;i++){
                int temp;
                if(table[i][0]==1){
                    temp = num/100;
                }else if(table[i][0]==2){
                    temp = (num/10)%10;
                }else{
                    temp = num%10;
                }
                if(table[i][1] != temp){
                    piv = false;
                }
            }
        }else if(n==2){
            for(int i=0;i<m;i++){
                int temp;
                if(table[i][0]==1){
                    temp = num/10;
                }else{
                    temp = num%10;
                }

                if(table[i][1] != temp){
                    piv = false;
                }
            }
        }else{
            for(int i=0;i<m;i++){
                int temp;
                temp = num;
                if(table[i][1] != temp){
                    piv = false;
                }
            }
        }
        if(piv){
            cout<<num<<endl;
            return 0;
        }
    }
    cout<<"-1"<<endl;

    return 0;

}

Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

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

static const double eps = 1e-8;

int main(){

	int b,r,g,c,s,t;
	while(~scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t)){
		if(b==r && r==g && g==c && c==s && s==t && t==0) break;
		int big = -3 * b + 15 * b + (15 - 2) * b * 5;
		int bar = -3 * r + 15 * r + (15 - 2) * r * 3;
		int sum = 100 + big + bar -3 * g + 7 * g + (-3 * c + 2 * c) + (-3 * s)
			-3 * (t-(b+b*5)-(r+r*3)-g-c-(s*2));
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
/**
 * Created by abhishek on 7/31/2016.
 */
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(br.readLine());
        int a = Integer.parseInt(st.nextToken());
        int b = Integer.parseInt(st.nextToken());
        if(a > 0){
            System.out.println("Positive");
            return;
        }
        if(a <= 0 && b >= 0){
            System.out.println("Zero");
        return;
        }
        if(b < 0){
            int temp = b - a + 1;
            if(temp % 2 == 0)System.out.println("Positive");
            else System.out.print("Negative");
        }
    }
}


Measured memory_bytes: 7892
import math

n = int(input())
th = int(math.sqrt(n))
ans = [0 for _ in range(n)]
for x in range(1,th+1):
  for y in range(1,th+1):
    for z in range(1,th+1):
      tmp = x**2 + y**2 + z**2 + x*y + y*z + z*x
      if tmp <= n:
        ans[tmp-1] += 1
for i in ans:
  print(i)

Measured memory_bytes: 74668
#include <stdio.h>
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n, i, j, se, ss;
    cin>>n;
    ll ch[n];
    
    for(i=0;i<n;i++)
    cin>>ch[i];
    
    i=0;
    j=n-1;
    se=ch[j];
    ss=ch[i];
    
    while(j-i!=1)
    {
        if(ss<se)
        {i++;
        ss=ss+ch[i];
        
        }
        else
        {
        j--;
        se=se+ch[j];
        }
    }
    cout<<abs(ss-se);
}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#define MAXA 100000
#define MAX 20000000000
#define s(i) scanf("%d", &(i))
#define p(i) printf("%d", (i))
#define ps() printf(" ") 
#define rer(i,j,k) for((i)=(j);(i)<(k);++(i))
#define ret(i,j,k) for((i)=(j);(i)>(k);--(i))
using namespace std;


int main(){
	int i, sum = 0, m,n;
	cin >> n;
	rer(i,0,n){
		cin >> m;
		sum += (m-1);
	}
	cout << sum << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(int i=0; i<n; i++)
using namespace std;

int main(){
  int N;
  cin >> N;
  bool F[N][10];
  rep(i, N)
    rep(j, 10)
    cin >> F[i][j];
  int P[N][11];
  rep(i, N)
    rep(j, 11)
    cin >> P[i][j];
  //入力終わり

  int count[N];
      
  int sum, max = -1000000000;
  for(int bit=1; bit<(1<<10); bit++){
    //sumとcountの初期化
    sum = 0;
    rep(i, N)
      count[i] = 0;

    //10個の時間帯について
    rep(i, 10){
      //それぞれの時間帯で店を開けるとき
      if(bit & (1<<i) ){
	//店jも開けていれば
	rep(j, N){
	  if(F[j][i] == true)
	    //店jのカウント
	    count[j]++;
	}// j roop
      }// if
    } //i roop

    //利益の計算
    rep(i, N)
      sum += P[i][count[i] ];

    //最大値の更新
    if(max < sum)
      max = sum;

  } //bit roop

  //解答
  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
s1=raw_input()
s2=raw_input()

def check(s1_top, s1, s2):
    for s2_idx, c in enumerate(s2):
        if c != s1[(s1_top + s2_idx) % len(s1)]:
            return False
    return True

l=[]    
for i, c in enumerate(s1):
    if c == s2[0]:
        if check(i, s1, s2):
            print "Yes"
            sys.exit(0)

print "No"

Measured memory_bytes: 4216
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//edit
class Solve {
public:
    void solve() {
        Int n;
        string S, T;
        cin >> n >> S >> T;
        string U;
        for (int i = 0; i < n; ++i) {
            U += S[i];
            U += T[i];
        }
        cout << U << endl;
    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


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

// begin fast read template by CYJian (source: https://www.luogu.com.cn/paste/i11c3ppx)

namespace io {
	const int __SIZE = (1 << 21) + 1;
	char ibuf[__SIZE], *iS, *iT, obuf[__SIZE], *oS = obuf, *oT = oS + __SIZE - 1, __c, qu[55]; int __f, qr, _eof;
	#define Gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, __SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	inline void flush () { fwrite (obuf, 1, oS - obuf, stdout), oS = obuf; }
	inline void gc (char &x) { x = Gc(); }
	inline void pc (char x) { *oS ++ = x; if (oS == oT) flush (); }
	inline void pstr (const char *s) { int __len = strlen(s); for (__f = 0; __f < __len; ++__f) pc (s[__f]); }
	inline void gstr (char *s) { for(__c = Gc(); __c < 32 || __c > 126 || __c == ' ';)  __c = Gc();
		for(; __c > 31 && __c < 127 && __c != ' '; ++s, __c = Gc()) *s = __c; *s = 0; }
	template <class I> inline bool gi (I &x) { _eof = 0;
		for (__f = 1, __c = Gc(); (__c < '0' || __c > '9') && !_eof; __c = Gc()) { if (__c == '-') __f = -1; _eof |= __c == EOF; }
		for (x = 0; __c <= '9' && __c >= '0' && !_eof; __c = Gc()) x = x * 10 + (__c & 15), _eof |= __c == EOF; x *= __f; return !_eof; }
	template <class I> inline void print (I x) { if (!x) pc ('0'); if (x < 0) pc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10; while (qr) pc (qu[qr --]); }
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} using io::pc; using io::gc; using io::pstr; using io::gstr; using io::gi; using io::print;

// end fast read template by CYJian

#define iter(i, a, b) for(int i=(a); i<(b); i++)
#define rep(i, a) iter(i, 0, a)
#define rep1(i, a) iter(i, 1, (a)+1)
#define log(a) cerr<<"\033[32m[DEBUG] "<<#a<<'='<<(a)<<" @ line "<<__LINE__<<"\033[0m"<<endl
#define all(a) a.begin(), a.end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
 
using ll=long long;
using pii=pair<int, int>;
//#define int ll
const int MOD = 1000000007;

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    double v; cin >> v;
	cout << setprecision(20) << fixed << v*v*v/27 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s,t;cin >> s >> t;
  reverse(all(s));
  YESNO(s==t);
  return 0;
}


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...)
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;
/*}}}*/


void solve(){

    int n;
    cin >> n;

    vector<pii>a(n);
    rep (i, 0, n){
        cin >> a[i].first;
        a[i].second = i+1;
    }

    sort(all(a));

    rep(i,0,n){
        cout << a[i].second << " \n"[i==(n-1)];
    }

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  vector<int> A, B;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    if (a > 0) {
      A.emplace_back(a);
    } else {
      B.emplace_back(a);
    }
  }

  vector<pair<int, int>> P;
  auto f = [&](int a, int b) {
    P.emplace_back(make_pair(a, b));
    return a - b;
  };

  int res = 0;
  if ((int)A.size() == N || (int)B.size() == N) {
    if ((int)A.size() == N) {
      sort(A.begin(), A.end());

      for (int i = 0; i < N - 2; i++) {
        int a = f(A[i], A[i + 1]);
        A[i + 1] = a;
      }

      res = f(A[N - 1], A[N - 2]);
    } else {
      sort(B.begin(), B.end(), greater<int>());

      for (int i = 0; i < N - 1; i++) {
        int b = f(B[i], B[i + 1]);
        B[i + 1] = b;
      }

      res = B[N - 1];
    }
  } else {
    int a = A[0];
    for (int i = 1; i < (int)A.size(); i++) {
      B[0] = f(B[0], A[i]);
    }

    for (int i = 0; i < (int)B.size(); i++) {
      a = f(a, B[i]);
    }

    res = a;
  }

  cout << res << '\n';
  for (int i = 0; i < (int)P.size(); i++) {
    cout << P[i].first << " " << P[i].second << '\n';
  }
  return 0;
}


Measured memory_bytes: 3444
import itertools as it
import collections as col
import heapq as hq
import sys
import copy as cp
sys.setrecursionlimit(10**9)
args = sys.argv


def dump_impl(*objects):
    print(*objects, file=sys.stderr)
def dump_dummy(*objects):
    print(*objects, file=sys.stderr)
    
dump = dump_impl if len(args) == 2 and args[1] == "DEBUG" else dump_dummy

N = int(input())
S =[input() for i in range(N)]

D={'M':[],'A':[],'R':[],'C':[],'H':[]}
for Si in S:
    if Si[0] in D:
        D[Si[0]].append(Si)

dump(D)

ans=0
for x in it.combinations("MARCH", 3):
    x0,x1,x2=x
    dump(x0,x1,x2)
    ans += len(D[x0])*len(D[x1])*len(D[x2])
print(ans)


Measured memory_bytes: 98136
n=int(input())
a=list(map(int,input().split()))
r=0
ret=0
flag=0
# 尺取り法
# 区間内に「同じビットが2回以上使われない」というルールを設ければ、またその時に限りイコールが成立します。
for l in range(n):
    while r<n and flag&a[r]==0:
        flag|=a[r]
        r+=1
    ret+=r-l
    flag^=a[l]
print(ret)

Measured memory_bytes: 23560
N = gets.to_i
blues = N.times.map{gets.chomp.to_s}
M = gets.to_i
reds = M.times.map{gets.chomp.to_s}
ans = []
blues.each do |blue|
    count = blues.count(blue) - reds.count(blue)
    count < 0 ? ans << 0 : ans << count
end
puts ans.max


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
	int h1,m1,h2,m2,k,m;
	cin>>h1>>m1>>h2>>m2>>k;
	if(m2>=m1)
		m=(h2-h1)*60+m2-m1;
	else
	    m=(h2-h1)*60-(m1-m2);
	if(m>k) cout<<m-k;
	else cout<<0;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)
#define RREP(i, n) for (ll i = (n) - 1; i >= 0; --i)
#define ALL(v) (v).begin(), (v).end()
template<class T>
using reverse_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main(){
    ll n;
    cin >> n;
    ll ans = 0;
    for(ll d = 1; d <= n; ++d){
        const ll m = n / d;
        ans += d * (m * (m + 1) / 2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3600
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

int main(){
  int N;
  /* read input */
  scanf("%d", &N); // read int
  
  // N = abc then
  if(N <= 111* (N/100)){ // N <= aaa
    printf("%d", 111* (N/100));
  }
  else{ // N > aaa
    printf("%d", 111*((N/100)+1));
  }
  return 0;
}


Measured memory_bytes: 128
#include <cstdio>

int main(int argc, char *argv[]) {
	int sum;
	while (true) {
		fscanf(stdin, "%d", &sum);
		if (sum==0) break;
		int tmp, hits=0;
		for (int i = 0; i < sum/4; i++) {
			scanf("%d", &tmp);
			hits+=tmp;
		}
		printf("%d\n", hits);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main(){
  int D;
  cin >> D;
  vector<int> c(26);
  for (int i = 0; i < 26; i++){
    cin >> c[i];
  }
  vector<vector<int>> s(D, vector<int>(26));
  for (int i = 0; i < D; i++){
    for (int j = 0; j < 26; j++){
      cin >> s[i][j];
    }
  }
  long long v = 0;
  vector<int> last(26, -1);
  for (int i = 0; i < D; i++){
    int t;
    cin >> t;
    t--;
    v += s[i][t];
    last[t] = i;
    for (int j = 0; j < 26; j++){
      v -= c[j] * (i - last[j]);
    }
    cout << v << endl;
  }
}

Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>

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

/* a と b の最大公約数を返す関数 */
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

int main()
{
	string S, T;
	string sub;
	cin >> S >> T;

	sub = T.substr(0, S.length());
	if ((T.length() == (S.length() + 1)) &&
		S == sub)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}

  	return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define REP(i,n) rep(i,0,n)

void solve() 
{
    vector<int>g(4,0);
    REP(i,6){
        int a;cin>>a;a--;
        g[a]++;
    }
    REP(i,4){
        if(g[i]==0||g[i]==3){cout<<"NO"<<endl;return;}
    }cout<<"YES"<<endl;
}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define FOR(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
using namespace std;

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

    int a, b;
    cin >> a >> b;
    string s(b, char(a + '0'));
    string t(a, char(b + '0'));
    cout << min(s, t) << endl;
}

Measured memory_bytes: 256
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#define ll long long
 
int main(){
  ll int h,w,ans=0;
  scanf("%lld%lld",&h,&w);
  if(h==1 || w==1){
    printf("1");
    return 0;
  }
  else if(h%2==0 || w%2==0){
    ans = w*h/2;
    printf("%lld",ans);
    return 0;
  }

  else{
    ans = h*w/2+1;
    printf("%lld",ans);
    return 0;
  }
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define pb(x) push_back(x)
#define int long long

int N;
vector<int> A;

signed main(void){
	cin >> N;
	rep(i, N){
		int a;
		cin >> a;
		A.pb(a);
	}

	SORT(A);
	vector<int> ans;
	int pre=0;
	int max1=0;
	int max2=0;
	rep(i,N){
		if(pre==A.back()){
			ans.pb(pre);
			pre=0;
		}else{
			pre=A.back();
		}
		if(ans.size()>=2){
			max1=ans.back();
			ans.pop_back();
			max2=ans.back();
			break;
		}
		A.pop_back();
	}

	cout << max1*max2 << endl;

	return 0;
}

Measured memory_bytes: 1400
from collections import Counter

n = int(input())
lst = [int(i) for i in input().split()]

even = Counter(lst[0::2]).most_common(2) + [(0, 0)]
odd = Counter(lst[1::2]).most_common(2) + [(0, 0)]

if even[0][0] != odd[0][0]:
    print(n - (even[0][1] + odd[0][1]))
else:
    print(n - max(even[0][1] + odd[1][1], even[1][1] + odd[0][1]))


Measured memory_bytes: 15588
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  int n;
  cin >> n;
  vector<int> ans;
  if(n == 0) {
    cout << 0;
  } else if(n > 0) {
    while(n > 0) {
      if(n % 4 == 0) {
        ans.push_back(0);
        ans.push_back(0);
      } else if(n % 4 == 1) {
        ans.push_back(1);
        ans.push_back(0);
      } else if(n % 4 == 2) {
        ans.push_back(0);
        ans.push_back(1);
        n += 2;
      } else if(n % 4 == 3) {
        ans.push_back(1);
        ans.push_back(1);
        n++;
      }
      n /= 4;
    }
    if(*ans.rbegin() == 0) {
      ans.erase(ans.end() - 1);
    }
  } else {
    n *= -1;
    while(n > 0) {
      if(n % 4 == 0) {
        ans.push_back(0);
        ans.push_back(0);
      } else if(n % 4 == 1) {
        ans.push_back(1);
        ans.push_back(1);
      } else if(n % 4 == 2) {
        ans.push_back(0);
        ans.push_back(1);
      } else if(n % 4 == 3) {
        ans.push_back(1);
        ans.push_back(0);
        n++;
      }
      n /= 4;
    }
  }
  reverse(ans.begin(), ans.end());
  for(const auto &p : ans) {
    cout << p;
  }
  cout << '\n';
  return 0;
}

Measured memory_bytes: 3628
scores = []
while True:
    score = list(map(int, input().split()))
    if score[0] == -1 and score[1] == -1 and score[2] == -1:
        break
    else:
        scores.append(score)

for i in scores:
    mid_exam = i[0]
    final_exam = i[1]
    re_exam = i[2]
    total = i[0] + i[1]
    if mid_exam == -1 or final_exam == -1:
        print("F")
    elif total >= 80:
        print("A")
    elif total in range(65, 80):
        print("B")
    elif total in range(50, 65):
        print("C")
    elif 30 <= total < 50:
        if re_exam >= 50:
            print("C")
        else:
            print("D")
    elif total < 30:
        print("F")

Measured memory_bytes: 7732
#include<bits/stdc++.h>
using namespace std;
   
const int NMAX=40;
const int WMAX=400;
const int INF=1e9;
int dp[NMAX+1][WMAX+1][WMAX+1];
 
signed main()
{
  int N,X,Y; cin>>N>>X>>Y;
  vector<int> a(N),b(N),c(N);
  for(int i=0;i<N;i++){
    cin>>a[i]>>b[i]>>c[i];
  }
 
  for(int i=0;i<=N;i++){
    for(int j=0;j<=WMAX;j++){
      for(int k=0;k<=WMAX;k++){
        dp[i][j][k]=INF;
      }
    }
  }
  dp[0][0][0]=0;
 
  for(int i=0;i<N;i++){
    for(int j=0;j<=WMAX;j++){
      for(int k=0;k<=WMAX;k++){
        if(dp[i][j][k]==INF) continue;
        
        dp[i+1][j][k]=min(dp[i+1][j][k],dp[i][j][k]);
        dp[i+1][j+a[i]][k+b[i]]=min(dp[i+1][j+a[i]][k+b[i]],dp[i][j][k]+c[i]);
      }
    }
  }
  
  int ans=INF;
  for(int k=1;;k++){ 
    if(k*X<=WMAX and k*Y<=WMAX){
      ans=min(ans,dp[N][k*X][k*Y]);
    }else break;
  }
  cout<<(ans==INF? -1:ans)<<endl;
 
  return 0;
}


Measured memory_bytes: 25984
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
stack<ll>q;
int main()
{
    cin>>n;
    if(n==0)
    {
        printf("0\n");
        return 0;
    }
    while(n)
    {
        if(n>0)
        {
            ll t=n;
            n/=(-2);
            q.push(t-n*(-2));
        }
        else
        {
            ll t=n;
            n/=(-2);
            if(n*(-2)>t) n++;
            q.push(t-n*(-2));
        }
    }
    while(!q.empty()) printf("%lld",q.top()),q.pop();
    printf("\n");
}


Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric, std.container, std.range;

void main()
{
    auto Q = readln.chomp.to!int;
    foreach (_; 0..Q) {
        auto ab = readln.split.to!(long[]);
        auto A = ab[0];
        auto B = ab[1];
        if (A > B) swap(A, B);

        if (A == B || A+1 == B) {
            writeln(2*(A-1));
            continue;
        }

        auto c = sqrt((A*B).to!double).to!long;
        if (c^^2 == A*B) --c;
        if (c * (c+1) >= A*B) {
            writeln(2*(c-1));
        } else {
            writeln(2*c-1);
        }
    }
}

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if(a + b > c + d) cout << "Left\n";
    else if(a + b < c + d) cout << "Right\n";
    else cout << "Balanced\n";
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    ll ans = 0;
    rep(i, 60)
    { //桁ごとにやる
        ll p = 0, q, tmp;
        rep(j, n)
        {
            if (a[j] & (1LL << i)) //(a[j]&(1<<i))←LLつけたらAC　or　a[j] >> i & 1
                p++;
        }
        q = n - p;
        tmp = p * q % MOD;
        rep(j, i) tmp = tmp * 2 % MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}

//bit全探索時なんかに元がll型なら1LLとしないとオーバーフローの可能性？

Measured memory_bytes: 5616
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

int Root(int x, vector<int> &root)
{
    if (x == root[x]) return x;
    return root[x] = Root(root[x], root);
}

void Merge(int v, int u, vector<int> &root, vector<int> &sz)
{
    v = Root(v, root), u = Root(u, root);
    if (v == u) return;
    if (sz[v] < sz[u])
    {
        sz[u] += sz[v];
        root[v] = u;
    }
    else
    {
        sz[v] += sz[u];
        root[u] = v;
    }
}

int ok(int x, int n)
{
    return 0 <= x && x < n;
}

const int N = 400000;
ll w[31][N];

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n, t, c;
    cin >> n >> c;
    forn(i, n)
    {
        int a, b, c;
        cin >> a >> b >> c; c--;
        a--;
        for (int j = a; j < b; j++)
        {
            w[c][j] = 1;
        }
    }
    int ans = 0;
    forn(i, N)
    {
        int r = 0;
        forn(j, c) r += w[j][i];
        ans = max(ans, r);
    }
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 83072
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w; cin>>h>>w;
  int mat1[h][w];
  for(int i=0; i<h; ++i){
    for(int j=0; j<w; ++j){
      char c; cin>>c;
      if( c == '.') mat1[i][j] = 0;
      else mat1[i][j] = 1;
    }
  }
  for(int i=0; i<h; ++i){
    bool can_erase = true;
    for(int j=0; j<w; ++j){
      if( mat1[i][j]  == 1){
        can_erase = false; break;
      }
    }
    if( can_erase){
      for(int j=0; j<w; ++j){
        mat1[i][j] = 2;
      }
    }
  }
  for(int j=0; j<w; ++j){
    bool can_erase = true;
    for(int i=0; i<h; ++i){
      if( mat1[i][j]  == 1){
        can_erase = false; break;
      }
    }
    if( can_erase){
      for(int i=0; i<h; ++i){
        mat1[i][j] = 2;
      }
    }
  }
  for(int i=0; i<h; ++i){
    bool exit_enter = false;
    for(int j=0; j<w; ++j){
      if( mat1[i][j]  == 2) continue;
      else if( mat1[i][j] == 0){
        cout<<'.'; exit_enter = true;
      }
      else {
        cout<< '#'; exit_enter = true;
      }
    }
    if(exit_enter) cout<<endl;
  }
  return 0;
}
  


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

int main() {
    vector<int> a(5),b(5);
    int mini=10,temp_i,time=0,index=0,count=0;
    rep(i,5) {
        cin>>a[i];
        b[i]=a[i]%10;
        if (b[i]%10!=0) {
            mini=min(mini,b[i]);
            if (mini==b[i]) temp_i=i;
        }
    }
    while(true) {
        if (time%10==0&&count!=4) {
            if (index!=temp_i) {
                time+=a[index];
                index++;
                count++;
            } else {
                index++;
            }
        } else if(time%10==0&&count==4) {
            break;
        } else {
            time++;
            continue;
        }
    }
    time+=a[temp_i];
    cout<<time<<endl;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::collections::BTreeMap;

#[fastout]
fn main() {
    input! {
        n: usize,
        k: i64,
        q: usize,
        a: [i64; q]
    };

    let a: Vec<i64> = a.iter().map(|x| x - 1).collect();
    let mut map = BTreeMap::new();

    for i in a.iter() {
        let count = map.entry(i.to_string()).or_insert(0);
        *count += 1;
    }

    for i in 0..n {
        let x = map.get(&i.to_string());
        if x == None {
            if k - q as i64 > 0 {
                println!("Yes")
            } else {
                println!("No")
            }
        } else {
            let value = x.unwrap();
            if k - (q as i64 - value) > 0 {
                println!("Yes")
            } else {
                println!("No")
            }
        }
    }
}


Measured memory_bytes: 9292