akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <float.h>　
#include <math.h>
using namespace std;

int main() {
int A,B,C,D;
float AA,CC;
  cin>>A>>B>>C>>D;
  AA=A/D;
  CC=C/B;
if(A%D!=0){AA++;}
if(C%B!=0){CC++;}
  
  if(AA>=CC){cout<<"Yes";}else{cout<<"No";}
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  ll a, b;
  cin >> a >> b;
  ll c = a *25/ 2 ;
  bool z = true;
  for (ll i = c-1; i <= c + b; i++){
    if(i*2/25==a&&i/10==b){
      z = false;
      print(i);
      break;
    }
  }
  if(z){
    print(-1);
  }
}


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

const int INF = 1e9+5;

int main(){
	int n;
	scanf("%d",&n);
	vector<int> dp(3);
	for(int i = 0; i < n; i++){
		vector<int> new_dp(3);
		vector<int> c(3);
		for(int j = 0; j < 3; j++)
			scanf("%d",&c[j]);

		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j != k)
					new_dp[k] = max(new_dp[k], dp[j] + c[k]);
			}
		}
		dp = new_dp;
	}
	cout<< max({dp[0],dp[1],dp[2]})<<endl;
	return 0;
}

Measured memory_bytes: 256
package main

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

const NIL = -1

type Node struct {
	parent, left, right int
}

type Deps []int
type Heights []int

type Tree struct {
	T []Node
	D Deps
	H Heights
}

func answer(reader io.Reader) string {
	var v, l, r, root int

	sc := bufio.NewScanner(reader)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())

	var tree Tree
	tree.T = make([]Node, n)
	for i := 0; i < n; i++ {
		tree.T[i].parent = NIL
	}

	for i := 0; i < n; i++ {
		sc.Scan()
		v, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		l, _ = strconv.Atoi(sc.Text())
		sc.Scan()
		r, _ = strconv.Atoi(sc.Text())
		tree.T[v].left, tree.T[v].right = l, r
		if l != NIL {
			tree.T[l].parent = v
		}
		if r != NIL {
			tree.T[r].parent = v
		}
	}

	for i := 0; i < n; i++ {
		if tree.T[i].parent == NIL {
			root = i
		}
	}
	tree.D = make(Deps, n)
	tree.H = make(Heights, n)

	tree.setDepth(root, 0)
	tree.setHeight(root)

	var out bytes.Buffer
	for i := 0; i < n; i++ {
		out.WriteString(tree.String(i))
	}

	return strings.TrimRight(out.String(), "\n")
}

func (t *Tree) setDepth(u, d int) {
	if u == NIL {
		return
	}
	t.D[u] = d
	t.setDepth(t.T[u].left, d+1)
	t.setDepth(t.T[u].right, d+1)
}

func (t *Tree) setHeight(u int) int {
	var h1, h2 int
	if t.T[u].left != NIL {
		h1 = t.setHeight(t.T[u].left) + 1
	}
	if t.T[u].right != NIL {
		h2 = t.setHeight(t.T[u].right) + 1
	}

	t.H[u] = h2
	if h1 > h2 {
		t.H[u] = h1
	}
	return t.H[u]
}

func (t *Tree) getSibling(u int) int {
	if t.T[u].parent == NIL {
		return NIL
	}
	if t.T[t.T[u].parent].left != u && t.T[t.T[u].parent].left != NIL {
		return t.T[t.T[u].parent].left
	}
	if t.T[t.T[u].parent].right != u && t.T[t.T[u].parent].right != NIL {
		return t.T[t.T[u].parent].right
	}
	return NIL
}

func (t *Tree) String(u int) string {
	var out bytes.Buffer
	out.WriteString(fmt.Sprintf("node %d: ", u))
	out.WriteString(fmt.Sprintf("parent = %d, ", t.T[u].parent))
	out.WriteString(fmt.Sprintf("sibling = %d, ", t.getSibling(u)))

	var deg int
	if t.T[u].left != NIL {
		deg++
	}
	if t.T[u].right != NIL {
		deg++
	}
	out.WriteString(fmt.Sprintf("degree = %d, ", deg))
	out.WriteString(fmt.Sprintf("depth = %d, ", t.D[u]))
	out.WriteString(fmt.Sprintf("height = %d, ", t.H[u]))

	if t.T[u].parent == NIL {
		out.WriteString("root\n")
	} else if t.T[u].left == NIL && t.T[u].right == NIL {
		out.WriteString("leaf\n")
	} else {
		out.WriteString("internal node\n")
	}

	return out.String()
}

func main() {
	fmt.Println(answer(os.Stdin))
}



Measured memory_bytes: 1172
n,a,b,c = map(int,input().split())
l = [int(input()) for _ in range(n)]
ans = 10**6
for i in range(4**n):
  pattern = [0]*n
  for j in range(n):
    pattern[j] = ((i >> j*2) & 3)
  bamboo = [0]*4
  for j in range(n):
    bamboo[pattern[j]] += l[j]
  if bamboo[1]*bamboo[2]*bamboo[3]==0:
    continue
  time = pattern.count(1)*10+pattern.count(2)*10+pattern.count(3)*10-30+abs(bamboo[1]-a)+abs(bamboo[2]-b)+abs(bamboo[3]-c)
  if ans > time:
    ans = time
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
			using namespace std;
			#define ll long long
			#define mod 1000000007
			#define pll pair<long,long>
			#define se second
			#define fi first
			#define pb push_back
			#include <ext/pb_ds/assoc_container.hpp>
			#include <ext/pb_ds/tree_policy.hpp>
			using namespace __gnu_pbds;

			typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
			typedef tree<pll,null_type,less<pll>,rb_tree_tag,tree_order_statistics_node_update>pllordered_set;
			
			vector<string> mat;
			ll ans=INT_MAX;
			ll n,m;
			ll vis[105][105][105][2]={0};
			void dfs(ll r,ll c,ll ch,ll prev)
			{
				
				
				if(vis[r][c][ch][prev])
					return ;
				vis[r][c][ch][prev]=1;
				if(mat[r][c]=='#' && prev==0)
					ch+=1;
				if(mat[r][c]=='#')
					prev=1;
				else
					prev=0;
				//cout<<r<<" "<<c<<" "<<ch<<" "<<prev<<endl;
				if(r== (n-1) && c== (m-1))
				{
					
					ans=min(ans,ch);
				}
				
				if( r+1<n)
					dfs(r+1,c,ch,prev);
				if(c+1<m)
					dfs(r,c+1,ch,prev);
				
				
			} 
			int main()
			{
				
				cin>>n>>m;
				mat=vector<string> (n+1);
				for(ll i=0;i<n;i++)
					cin>>mat[i];
				dfs(0,0,0,0);
				cout<<ans;
			}
						
			


Measured memory_bytes: 17408
#include <iostream>
#include <math.h>
using namespace std;

int main(){
    int N,M;
    cin >> N >>M;
    int s[M],c[M];
    for(int i=0;i<M;i++){
        cin >> s[i]>>c[i];
    }

    for(int iNum=0;iNum<1000;iNum++){
        int count=0;
        for(int i=0;i<M;i++){
            int k=pow(10,N-s[i]);
            
            if(((iNum%(k*10))/k)==c[i]){
                count++;
            }
            
        }
        if(count==M){
            int r=pow(10,N-1);
          if(r!=1){
            if((iNum/r)==0){
                continue;
            }
          }
            cout <<iNum;
            return 0;
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 200000
#define DEFAULT -1000000000

int main(){
  int n, r[N], i;
  int min, max;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    scanf("%d", &r[i]);
  }

  max = DEFAULT;
  min = r[0];

  for(i=1;i<=n-1;i++){
    if(max < r[i]-min) max = r[i]-min;
    if(min > r[i]) min = r[i];
  }

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

  return 0;
}



Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N; cin>>N;
    vector<ll> L(N);
    vector<ll> R(N);
    rep(i,N) cin>>L[i]>>R[i];
    sort(ALL(L),greater<ll>());
    SORT(R);
    ll ans=0;
    ll mae=0;
    ll buf=0;
    rep(i,N){
        if(i%2==0){
            if(mae>=L[i/2]) break;
            buf+=L[i/2]-mae;
            mae=L[i/2];
        }
        else{
            if(mae<=R[i/2]) break;
            buf+=mae-R[i/2];
            mae=R[i/2];
        }
    }
    buf+=abs(mae);
    maxi(ans,buf);
    mae=0,buf=0;
    rep(i,N){
        if(i%2==1){
            if(mae>=L[i/2]) break;
            buf+=L[i/2]-mae;
            mae=L[i/2];
        }
        else{
            if(mae<=R[i/2]) break;
            buf+=mae-R[i/2];
            mae=R[i/2];
        }
    }
    buf+=abs(mae);
    maxi(ans,buf);
    cout<< ans <<"\n";

}

//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main()
{
  string s;
  cin >> s;
  int count = 0;

  if (s.at(0) == 'S' && s.at(1) == 'S' && s.at(2) == 'S')
    count = 0;
  else if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'R')
    count = 3;
  else if (s.at(0) == 'R' && s.at(1) == 'R' && s.at(2) == 'S' 
  || s.at(0) == 'S' && s.at(1) == 'R' && s.at(2) == 'R')
    count = 2;
  else
  {
    count = 1;
  }

  cout << count << endl;
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  if(N%2 == 0){
    cout << "0.5000000000" << endl;
  }
  else if(N == 1){
    cout << "1.0000000000" << endl;
  }
  else{
    cout << fixed << setprecision(10);
    cout << (double)(N+1)/(double)(2*N) << endl;
  }
}

Measured memory_bytes: 256
public class Main {
    public static void main(String args[]) {
        for(int i = 1; i <= 9; i++) {
            for(int j = 1; j <= 9; j++) {
                // ?¨??????????
                System.out.println(""+i+'x'+j+'='+(i*j));
            }
        }
    }
}

Measured memory_bytes: 24020
n = int(input())
h = list(map(int, input().split()))

cost = [float('inf') for _ in range(n)]
cost[0] = 0

for x in range(n):
    if x + 1 < n:
        cost[x + 1] = min(cost[x + 1], cost[x] + abs(h[x + 1] - h[x]))
    
    if x + 2 < n:
        cost[x + 2] = min(cost[x + 2], cost[x] + abs(h[x + 2] - h[x]))

print(cost[n - 1])

Measured memory_bytes: 13928
h, w = map(int, input().split())
S = [input() for _ in range(h)]

ans = [[-1]*w for _ in range(h)]

dy = [-1, 1, 0, 0, -1, 1, -1, 1]
dx = [ 0, 0,-1, 1, -1, 1,  1,-1]

for i in range(h):
    for j in range(w):
        if S[i][j] == '#': continue
        ans[i][j] = 0
        for k in range(8):
            y = i + dy[k]
            x = j + dx[k]
            if y<0 or h<=y: continue
            if x<0 or w<=x: continue
            if S[y][x] == '#':
                ans[i][j] += 1

for i in range(h):
    for j in range(w):
        if ans[i][j] == -1:
            print('#',end='')
        else:
            print(ans[i][j],end='')
    print('')

# print(h,w)
# print(*S,sep='\n')
# print(*ans,sep='\n')


Measured memory_bytes: 9264
function seach(y,x){
   if(yx[y][x]=="*"){yx[y][x]=0;return;}
   var dy=[-1,-1,0];
   var dx=[-1,0,-1];
   var min=n;
   for(var i=0;i<3;i++){
      var yy=y+dy[i];
      var xx=x+dx[i];
      if(yy<0 || yy>=n || xx<0 || xx>=n){yx[y][x]=1;return;}
         min=Math.min(min,yx[yy][xx]);
      }
   yx[y][x]=min+1;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
while(true){
   var n=Arr.shift()-0;
   if(n==0)break;
   var max=0;
   var yx=[];
   for(var i=0;i<n;i++){
      var str=Arr.shift();
      yx.push(str.split(""));
   }
   for(var y=0;y<n;y++){
      for(var x=0;x<n;x++){
         seach(y,x);
         max=Math.max(max,yx[y][x]);
      }
   }
   console.log(max);
}

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

int main() {
    string a, b;
    cin >> a >> b;
    int n = stoi(a + b);
    rep(i, 10000) {
        if(n == pow(i, 2)) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i, n) cin >> s[i];

  int c0 = 0, c1 = 0, c2 = 0, c3 = 0;
  for (auto t : s) {
    rep(j, t.size()) if (t.substr(j, 2) == "AB") c0++;
    if (t.front() == 'B' && t.back() == 'A') c1++;
    if (t.front() == 'B' && t.back() != 'A') c2++;
    if (t.front() != 'B' && t.back() == 'A') c3++;
  }
  // int c;
  // if (c1 == 0) {
  //   c = min(c2, c3);
  // } else {
  //   if (c2 + c3 > 0) {
  //     c = c1 + min(c2, c3);
  //   } else {
  //     c = c1 - 1;
  //   }
  // }
  // cout << c0 + c << endl;
  if (c2 + c3 == 0) {
    cout << c0 + max(0, c1 - 1) << endl;
  } else {
    cout << min(c0 + c1 + c2, c0 + c1 + c3) << endl;
  }
  return 0;
}


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

public class Main {

	final static long MOD = 1000000007L;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static ArrayList<int[]> list = new ArrayList<>();
	public static void main(String[] args) throws Exception {


		String[] s = toStringArray(nextString());
		String[] t = toStringArray(nextString());
		Arrays.sort(s);
		Arrays.sort(t,Comparator.comparing(String::toString,Comparator.reverseOrder()));
		String ss="";
		for(int i=0;i<s.length;i++){
			ss+=s[i];
		}
		String tt="";
		for(int i=0;i<t.length;i++){
			tt+=t[i];
		}
		if(ss.compareTo(tt)<0){
			System.out.println("Yes");

		}else{
			System.out.println("No");
		}
	}


	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 27476
function main(input) {
  const inputList = input.split('');
  // const oneLine = inputList[0];
  var result = 'Good';
  for (var i = 0; i < (inputList.length - 1); i++) {
    if (inputList[i] === inputList[i + 1]) {
      result = 'Bad';
      break;
    }
  }
  console.log(result);
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 21064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
int main(void){
    string s;cin>>s;
    deque<char> q;
    for(char c:s)q.push_back(c);
    bool flip =false;
    int Q;cin>>Q;
    string t;
    rep(i,Q){
        int ty;
        cin>>ty;
        if(ty==1){
            flip=!flip;
        }else{
            int f;char c;
            cin>>f>>c;
            if(flip)f=3-f;
            if(f==1){
                q.push_front(c);
            }else{
                q.push_back(c);
            }
        }
    }
    if(flip) reverse(q.begin(),q.end());
    string ans;
    for(char c:q)ans+=c;
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef pair<ll,pll> plpll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const int INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

#define addm(X, Y) (X) = ((X) + ((Y) % mod) + mod) % mod


int n, m;
vector<vector<int>> g(1000000 + 6);

int ord[1000000 + 6], low[1000000 + 6];
bool visited[1000000 + 6];

vector<pair<int, int>> Bridges;
vector<int> Points;

void dfs(int now, int par, int &cnt) {
    visited[now] = true;
    ord[now] = cnt++;
    low[now] = ord[now];
    bool check = false;
    int outdeg = 0;
    for (auto nx : g[now]) {
        if (nx == par) continue;
        if (!visited[nx]) {
            outdeg++;
            dfs(nx, now, cnt);
            low[now] = min(low[now], low[nx]);
            //???????????????
            if (ord[now] < low[nx]) {
                Bridges.push_back({min(now, nx), max(now, nx)});
            }
            //??¢??????????????????
            if (par != -1 && !check && ord[now] <= low[nx]) {
                check = true;
                Points.push_back(now);
            }
        }
        else {
            low[now] = min(low[now], ord[nx]);
        }
    }
    //???????????????????????\?????¢????????¨???????????????
    if (par == -1 && outdeg >= 2) {
        Points.push_back(now);
    }
    return;
}

void lowlink (int n, vector<vector<int>>& g) {
    int cnt = 0;
    for (int i = 0; i < n; i++) {
        if (!visited[i]) {
            dfs(i, -1, cnt);
        }
    }
    sort(all(Bridges));
    sort(all(Points));
    return;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> m;
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    lowlink(n, g);
    /*
    rep(i, Bridges.size()) {
        cout << Bridges[i].fi << " " << Bridges[i].se << endl;
    }*/
    rep(i, Points.size()) {
        cout << Points[i] << endl;
    }
}

Measured memory_bytes: 28700
def game(word):
    if word=="r":return p,"p"
    elif word=="s":return r,"r"
    else:return s,"s"


n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=input()
ans=""

point=0
for i in range(n):
    num,word=game(t[i])
    if i<k:
        point +=num
        ans +=word
    else:
        if (t[i-k]==t[i] and ans[-k]!=word) or (t[i-k]!=t[i]):
            point +=num
            ans +=word
        else:
            ans +=t[i]

print(point)

Measured memory_bytes: 109676
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    if "AAA" in S or "BBB" in S:
        print(NO)
    else:
        print(YES)

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main(){
    int b , age;
    cin >>age >> b;
    if (age > 12){
        cout << b << endl;
    }
    else if (age > 5 && age < 13){
        cout << b / 2 << endl;
    }
    else{
        cout << 0 << endl;
    }
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]a){new Main();}public Main(){f(3,0);for(Scanner s=new Scanner(System.in);s.hasNext();){Object i=m.get(s.nextInt());System.out.println(i==null?0:i);}}Map<Integer,Integer>m=new HashMap<Integer,Integer>();void f(int n,int s){for(int i=0,r;i<10;i++){r=s+i;if(n<1)m.put(r,m.get(r)!=null?m.get(r)+1:1);else f(n-1,r);}}}

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

vector<ll> vec;

void dps(int depth, int goal, string str){

    //目標の桁数に到達
    if(depth == goal){
        ll number = stoll(str);
        vec.push_back(number);
        return;
    }
    char before = str[str.size() - 1];
    if(before != '0') {
        dps(depth + 1, goal, str + char(before - 1));
    }
    if(before != '9'){
        dps(depth + 1, goal, str + char(before + 1));
    }
    dps(depth + 1, goal, str + char(before));
}


int main(){
    int K;
    cin >> K;

    string str = "";
    // 1ケタ
    for(int i = 1; i < 10; i++){
        vec.push_back(i);
    }
//    for(int k = 2; k < 10; k++){
//        for(int i = 1; i < 10; i++) {
//            dps(1, 2, to_string(i));
//        }
//        cout << "::" << k << endl;
//    }

    // 2ケタ
    for(int i = 1; i < 10; i++) {
        dps(1, 2, to_string(i));
    }
    // 3ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 3, to_string(i));
    }
    // 4ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 4, to_string(i));
    }
    // 5ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 5, to_string(i));
    }
    // 6ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 6, to_string(i));
    }
    // 7ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 7, to_string(i));
    }
    // 8ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 8, to_string(i));
    }
    // 9ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 9, to_string(i));
    }
    // 10ケタ
    for(int i = 1; i < 10; i++){
        dps(1, 10, to_string(i));
    }
    sort(vec.begin(), vec.end());
    cout << vec[K - 1] << endl;




}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }
    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

#define MAX_N 100000

int n,k;
vector<int> G[MAX_N];
int color[MAX_N];
bool colored[MAX_N];

void dfs(int now, int cnt){
    color[now] = cnt;
    colored[now] = true;
    int t = 2;
    if(now == 0) t = 1;
    REP(i,G[now].size()){
        if(!colored[G[now][i]]){
            dfs(G[now][i], k - t);
            t++;
        }
    }
}

signed main(){
    cin >> n >> k;
    int a,b;
    REP(i,n - 1){
        cin >> a >> b;
        a--;
        b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    dfs(0, k);
    Mint<> ans = 1;
    REP(i,n){
        ans *= color[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 9728
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  int ans;
  if(K<A){
    ans = K;
  }
  else if(K<A+B){
    ans=A;
  }
  else{
    ans = A+(-1)*(K-A-B);
  }
  cout << ans << endl;
}
    

Measured memory_bytes: 3620
import Foundation
func C() {
    let N = Int(readLine()!)!
    let MAX = 100
    var memo = Array(repeating: 0, count: N+1)
    for x in 1...MAX{
        for y in 1...MAX{
            for z in 1...MAX{
                let a = pow(Double(x), 2.0) + pow(Double(y), 2.0) + pow(Double(z), 2.0)
                let b = x*y + y*z + z*x
                let c = Int(a) + b
                if c > N {
                    continue
                }
                memo[c] += 1
            }
        }
    }
    for i in 1...N{
        print(memo[i])
    }
}

C()


Measured memory_bytes: 12884
#include <bits/stdc++.h>
using namespace std;
// #define int long long
// #define double long double
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); ++i)
#define repeq(i,a,b) for(int i=(int)(a); i<=(int)(b); ++i)
#define rrep(i,a,b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define rrepeq(i,a,b) for(int i=(int)(a); i>=(int)(b); --i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
template<typename T> using Graph = vector<vector<T>>;
template<typename T> using Spacial = vector<vector<vector<T>>>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename T> using greater_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const int MOD = 1e9+7;
const int MOD2 = 998244353;
// const double EPS = 1e-9;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
string interval[2] = {" ", "\n"}; // {" ", "\n"}

template<typename T> struct is_plural : false_type{};
template<typename T1, typename T2> struct is_plural<pair<T1, T2>> : true_type{};
template<typename T> struct is_plural<vector<T>> : true_type{};
template<typename T> struct is_plural<complex<T>> : true_type{};
template<> struct is_plural<string> : true_type{};

template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << " " << p.second; }
template<typename T> istream &operator>>(istream &is, vector<T> &vec) { for(auto itr = vec.begin(); itr != vec.end(); ++itr) is >> *itr; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec) { if(vec.empty()) return os; bool pl = is_plural<T>(); os << vec.front(); for(auto itr = ++vec.begin(); itr != vec.end(); ++itr) os << interval[pl] << *itr; return os; }

bool CoutYN(bool a, string y = "Yes", string n = "No") { cout << (a ? y : n) << "\n"; return a; }

template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

long long modpow(int a, long long n, int mod = MOD) { long long ret = 1; do { if(n & 1) ret = ret * a % mod; a = 1LL * a * a % mod; } while(n >>= 1); return ret; }

template<typename T> T GCD(T a, T b) { return b ? GCD(b, a%b) : a; }
template<typename T> T LCM(T a, T b) { return a / GCD(a, b) * b; }

template<typename T1, typename T2> bool CompareBySecond(pair<T1, T2> a, pair<T1, T2> b) { return a.second != b.second ? a.second < b.second : a.first < b.first; }
template<typename T1, typename T2> bool CompareByInverse(pair<T1, T2> a, pair<T1, T2> b) { return a.first != b.first ? a.first < b.first : a.second > b.second; }


/* -------- <templates end> -------- */


void solve() {
  int x; cin >> x;
  cout << 1 - x << endl;
}


/* -------- <programs end> -------- */


signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <cstring>
#include <string>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>

using namespace std;

int main() {
    int N, X;
    int count = 0;
    cin >> N >> X;
    int m[N];
    for (int i = 0; i < N; i++) {
        cin >> m[i];
    }
    for (int i = 0; i < N; i++) {
        X -= m[i];
    }
    sort(m, m + N);

    count = N + X / m[0];

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
int main() {
	int n;

	cin >> n;
	for (int i = 1; i <= 9; i++) {
		for (int j = 1; j <= 9; j++) {
			if (i * j == n) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}

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

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

    long int cnt[100001] = {};
    long int a, sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a;
        sum += a;
        cnt[a]++;
    }
    long int q;
    cin >> q;
    long int b, c;
    for(int i = 0; i < q; i++){
        cin >> b >> c;
        sum += (c - b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << sum << endl;
    }

}

Measured memory_bytes: 4412
S=gets.chomp

az = (?a..?z).to_a
if S == az.reverse.join
    puts -1
else
    c = (az - S.chars)[0]
    if c
        puts S+c
    else
        25.downto(1) do |i|
            c = ((S[i].next..?z).to_a - S[0..i].chars)[0]
            if c
                puts S[0..i-1]+c
                exit
            end
        end
        puts S[0].next
    end
end


Measured memory_bytes: 3836
import java.io.*;

public class Main{
  public static void main(String[] args) {
    try {
      BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
      int n, i = 0;
      String result = "Three", in;
      n = Integer.parseInt(reader.readLine());

      char a[] = new char[n];

      in = reader.readLine();

      while(i < n){
        a[i] = in.charAt(i);
        i = ++i;
      }

      for (i = 0; i < n ; i++ ) {
        if (a[i] == 'Y'){
          result = "Four";
        }
      }
      System.out.println(result);
    }
    catch (Exception e) {
      
    }
  }
}

Measured memory_bytes: 23252
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	static Scanner sc = new Scanner(System.in);
	private static final char[] ROMA = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
	private static final int[] ROMA_NUM = {1, 5, 10, 50, 100, 500, 1000};

	public static void main(String[] args) {
		Map<Character, Integer> roma_num = new HashMap<Character, Integer>();
		for(int $ = 0; $ < ROMA.length; $++) {
			roma_num.put(ROMA[$], ROMA_NUM[$]);
		}

		while(sc.hasNext()) {
			String str = sc.next();
			char[] roma = str.toCharArray();

			int num = 0;
			int number = 0;
			int ans = 0;

			for(int $ = roma.length - 1; $ >= 0; $--) {
				number = num;
				num = roma_num.get(roma[$]);

				if(number > num) {
					ans -= num;
				} else {
					ans += num;
				}

			}

			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 26220
#include <iostream>
using namespace std;
int main(){
	int a[3][3];
	bool f[3][3] = {};
	int n;
	int b;
	for(int i = 0;i <= 2;i++){
		cin >> a[i][0] >> a[i][1] >> a[i][2];
	}
	cin >> n;
	for(int i = 0;i <= n-1;i++){
		cin >> b;
		for(int j = 0;j <= 2;j ++){
			for(int k = 0;k <= 2;k++){
				if(a[j][k] == b){
					f[j][k] = 1;
				}
			}
		}
	}
	for(int i = 0;i <= 2;i++){
		if(f[i][0] && f[i][1] && f[i][2]){
			cout << "Yes";
			return 0;
		}
		if(f[0][i] && f[1][i] && f[2][i]){
			cout << "Yes";
			return 0;
		}
	}
	if(f[0][0] && f[1][1] && f[2][2]){
		cout << "Yes";
		return 0;
	}
	if(f[2][0] && f[1][1] && f[0][2]){
		cout << "Yes";
		return 0;
	}
	cout << "No";


	return 0;
}


Measured memory_bytes: 256
a,b = map(int,input().split())
A = a%4
ans1 = 0
for i in range(A):
    ans1 = ans1^(a-i-1)
B = (b+1)%4
ans2 = 0
for i in range(B):
    ans2 = ans2^(b-i)
print(ans1^ans2)

Measured memory_bytes: 9180
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;

int keta(int num) {
	int result = 1;
	while (true) {

		if (num < 10)return result;

		num /= 10;
		result++;
	}



}

int main() {
	int a, b,c;
	while (cin >> a >> b) {
		printf("%d\n", keta(a + b));

	}
	

	//system("pause");
	return 0;
}


Measured memory_bytes: 3208
n,k = map(int,input().split())
x = list(map(int,input().split()))
ans = 10**9
  
for i in range(n-k+1):
  if x[k-1+i]*x[i] < 0:
    if x[k-1+i] <= abs(x[i]) :
      temp = 2*x[k-1+i] - x[i]
    elif abs(x[i]) < x[k-1+i]:
      temp = x[k-1+i] - 2*x[i]
      
  elif (0 <= x[i]):
    temp = x[k+i-1]

  elif (x[k+i-1] <= 0):
    temp = -x[i]
    
  if temp < ans:
    ans = temp
    
print(ans)

Measured memory_bytes: 14844
def read_list(t): return [t(x) for x in input().split()]
def read_line(t): return t(input())
def read_lines(t, N): return [t(input()) for _ in range(N)]

def rec(state, v):
    if dp[state][v] >= 0:
        return dp[state][v]
    if (1 << V) - 1 == state and v == 0:
        dp[state][0] = 0
        return 0

    ret = INF
    for to, cost in edge[v]:
        if not (state >> to & 1):
            ret = min(ret, rec(state | 1 << to, to) + cost)
    dp[state][v] = ret
    return ret

INF = 1<<27
V, E = read_list(int)
edge = [[] for _ in range(V)]
for _ in range(E):
    fr, to, cost = map(int, input().split())
    edge[fr].append((to, cost))

dp = [[-1] * V for _ in range(1<<V)]
print(dp[0][0] if rec(0, 0) != INF else -1)

Measured memory_bytes: 17036
//kruskal tree
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
using namespace std;
#define M 9999
int parent[M],a[M],b[M];
pair<double,int>node[M];
int root(int a){return parent[a]==a?a:parent[a]=root(parent[a]);}
int unite(int a,int b){
	int x=root(a),y=root(b);
	if(x==y)return 0;
	parent[x]=y;
	return 1;
}
int main(){
	int i,j,k,m,n,q;
	double x,y,z,r,t;
	for(;scanf("%d",&n),n;){
		vector<vector<double> >v;
		for(i=0;i<n;i++)scanf("%lf%lf%lf%lf",&x,&y,&z,&r),v.push_back({x,y,z,r}),parent[i]=i;
		for(q=m=i=0;i<n;i++)for(j=i+1;j<n;j++){
			for(x=k=0;k<3;k++)x+=(t=v[i][k]-v[j][k])*t;
			x=sqrt(x)-v[i][3]-v[j][3];
			if(x<=0){if(unite(i,j))q++;}
			else a[m]=i,b[m]=j,node[m].first=x,node[m++].second=m;
		}
		sort(node,node+m);
		for(x=i=0;i<m&&q<n-1;i++)if(unite(a[node[i].second],b[node[i].second]))x+=node[i].first,q++;
		printf("%.3f\n",x);
	}
}

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

typedef long long ll;
const int N = 100005;

int n,q;
ll a[N];
string s[N];

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s[i]>>a[i];
	}
	string x;
	cin>>x;
	ll ans = 0;
	for(int i=n-1;i>=0;i--){
		if(s[i] == x)break;
		ans += a[i];
	}
	cout<<ans;
	
	
	return 0;
}



Measured memory_bytes: 6748
#include<stdio.h>
int main(void){
	int i,j,n;
	bool judge[1000000]={0};
	
	for(i=3; i<1000000; i++)if(i % 2 == 0)judge[i] = 1;
	
	for(i=3; i<500000; i+=2){
		if(judge[i]==0){
			for(j=i*2;j<1000000;j+=i){
				if(j % i == 0){
					judge[j]=1;
				}
			}
		}
	}
	
	while(scanf("%d",&n) != EOF){
		int count=0;
		for(i=2;i<=n;i++){
			if(judge[i]==0)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

Measured memory_bytes: 0
def resolve():
	# 夏休みの日数
	N = int(input())
	# 日ごとの行動A,B,Cによって得られる幸福度
	ABC = [
		map(int, input().split())
		for _ in range(N)
	]
	# 今日行動A,B,Cをする事で得られる、幸福度の累計
	Va, Vb, Vc = ABC.pop()
	for _ in range(N-1):
		a, b, c = ABC.pop()
		Va, Vb, Vc = max(Vb, Vc) + a, max(Va, Vc) + b, max(Va, Vb) + c
	print(max(Va, Vb, Vc))
resolve()

Measured memory_bytes: 54424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  double n,d;cin>>n>>d;
  vector<vector<double>> x(n,vector<double>(d));
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<d;j++){
      cin>>x[i][j];
    }
  }
  ll ans=0;
  //caricurate
  for(i=0;i<n;i++){
    for(j=i+1;j<n;j++){
      double njo=0;
      for(int k=0;k<d;k++){njo+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);}
      
      //cout<<njo<<endl;
      njo=sqrt(njo);
      if(ceil(njo) == floor(njo)){ans++;}
    }
  }
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 256
A,B,M=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=min(a)+min(b)
for i in range(M):
    x,y,c=map(int,input().split())
    x-=1; y-=1
    point=a[x]+b[y]-c
    ans=min(point,ans)
print(ans)

Measured memory_bytes: 18612
#include <math.h>
#include <stdio.h>
int main(int argc, const char * argv[])

{
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
       tmp=a;
       a=b;
       b=tmp;
    }
    if(a<c){
       tmp=a;
       a=c;
       c=tmp;
    }
   if(b<c){
       tmp=b;
       b=c;
       c=tmp;
    }
    printf("%d %d %d\n",c,b,a);
    return 0;
}

Measured memory_bytes: 596
import java.util.*;
public class Main {
	public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
		// get a integer
		String a = sc.nextLine();
		a = a.toUpperCase();

		StringBuilder str = new StringBuilder();
	    for (int i = 0; i < 4; i++)
	    	str.append(a.charAt(i));
	    str.append(' ');
	    for (int i = 4; i < 12; i++)
	    	str.append(a.charAt(i));
	    System.out.println(str);
    }
}

Measured memory_bytes: 9680
#include <stdio.h>
#include <math.h>

int main(){
    double a,b,c;
    double S,L,h;
    scanf("%lf%lf%lf",&a,&b,&c);
    
    
    h=b*sin(c*acos(-1)/180);
    S=a*h/2;
    L=sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(c*acos(-1)/180))+a+b;
    
    printf("%f\n%f\n%f\n",S,L,h);
    return 0;
}


Measured memory_bytes: 2052
require 'prime'
a = [*1..gets.to_i].inject(Hash.new{0}){|a, b| b.prime_division.each{|k,v| a[k] += v}; a}.values.map(&:succ).select{|a| a >= 3}
ans = 0r
[
  [3,5,5],
  [3,25],
  [5,15],
  [75]
].each do |b|
  a.permutation(b.length).each do |c|
    z = true
    (0...b.length).each do |i|
      if b[i] > c[i]
        z = false
        break
      end
    end
    ans += (b.length == 3 ? 1/2r : 1r) if z
  end
end
p ans.to_i

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

using namespace std;
using pii = pair<int, int>;

int main()
{
    while (true) {
        int t, p, r;
        cin >> t >> p >> r;
        if (t == 0 and p == 0 and r == 0) {
            break;
        }
        vector<vector<int>> wa(t, vector<int>(p, 0));
        vector<pair<pii, int>> score(t, make_pair(make_pair(p, 0), 0));
        for (int i = 0; i < t; i++) {
            score[i].second = i;
        }

        for (int i = 0; i < r; i++) {
            int tid, pid, tim;
            string str;
            cin >> tid >> pid >> tim >> str;
            tid--, pid--;
            if (str == "CORRECT") {
                score[tid].first.second += tim + 1200 * wa[tid][pid];
                score[tid].first.first--;
            } else {
                wa[tid][pid]++;
            }
        }

        sort(score.begin(), score.end());
        for (const auto& s : score) {
            cout << s.second + 1 << " " << p - s.first.first << " " << s.first.second << endl;
        }
    }


    return 0;
}

Measured memory_bytes: 3072
#!/usr/bin/env ruby

require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.chomp.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

A, B = get_ints

if A <= 8 && B <= 8
  puts 'Yay!'
else
  puts ':('
end


Measured memory_bytes: 14492
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using System.Globalization;

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

            if (Math.Abs(a[1] - a[2]) <= a[0])
            {
                Console.WriteLine("0");
            }
            else
            {
                Console.WriteLine(Math.Abs(a[1] - a[2]) - a[0]);
            }
        }
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime> 
#include <memory.h>
#include <assert.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18 + 1;

int main() {
    ll r, D, x;
    cin >> r >> D >> x;

    for(int i = 0; i < 10; i++) {
        x = r * x - D;
        cout << x << endl;
    }

    return 0;
}

Measured memory_bytes: 256
/*
    JAI JAGANNATH!
*/
//@Author : zanj0
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
#define ff              first
#define ss              second
#define pb              push_back
#define mp              make_pair
#define pii             pair<lli,lli>
#define vi              vector<lli>
#define mii             map<lli,lli>
#define pqb             priority_queue<lli>
#define pqs             priority_queue<lli,vi,greater<lli> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            lli x; cin>>x; while(x--)
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<lli, null_type, less<lli>, rb_tree_tag, tree_order_statistics_node_update> pbds;
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;

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

}
void solve() {
	lli ret = 0;
	lli a;
	cin >> a;
	lli temp = a;
	for (lli i = 1; i <= 3; i++) {
		ret += temp;
		temp *= a;
	}
	cout << ret << endl;
}
int main()
{
	zanj0();
	solve();
	return 0;
}

Measured memory_bytes: 3652
/*
        _            _                  _            _       _     _         _   _          _          _             _        
       / /\         / /\               / /\         / /\    / /\  /\ \      /\_\/\_\ _     /\ \       /\ \     _    /\ \      
      / /  \       / /  \             / /  \       / / /   / / /  \ \ \    / / / / //\_\   \ \ \     /  \ \   /\_\ /  \ \     
     / / /\ \__   / / /\ \           / / /\ \__   / /_/   / / /   /\ \_\  /\ \/ \ \/ / /   /\ \_\   / /\ \ \_/ / // /\ \_\    
    / / /\ \___\ / / /\ \ \         / / /\ \___\ / /\ \__/ / /   / /\/_/ /  \____\__/ /   / /\/_/  / / /\ \___/ // / /\/_/    
    \ \ \ \/___// / /  \ \ \        \ \ \ \/___// /\ \___\/ /   / / /   / /\/________/   / / /    / / /  \/____// / / ______  
     \ \ \     / / /___/ /\ \        \ \ \     / / /\/___/ /   / / /   / / /\/_// / /   / / /    / / /    / / // / / /\_____\ 
 _    \ \ \   / / /_____/ /\ \   _    \ \ \   / / /   / / /   / / /   / / /    / / /   / / /    / / /    / / // / /  \/____ / 
/_/\__/ / /  / /_________/\ \ \ /_/\__/ / /  / / /   / / /___/ / /__ / / /    / / /___/ / /__  / / /    / / // / /_____/ / /  
\ \/___/ /  / / /_       __\ \_\\ \/___/ /  / / /   / / //\__\/_/___\\/_/    / / //\__\/_/___\/ / /    / / // / /______\/ /   
 \_____\/   \_\___\     /____/_/ \_____\/   \/_/    \/_/ \/_________/        \/_/ \/_________/\/_/     \/_/ \/___________/    
                                                                                                                              
*/
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for(int i = 0;i < (n);++i)

#define endl '\n'
#define pb emplace_back
#define mkp make_pair
#define p_q priority_queue
#define INF 2000000000
#define PI 3.1415926

const int dx[]={1,0,-1,0}, dy[]={0,-1,0,1};
const int dx_8[]={1,1,0,-1,-1,-1,0,1}, dy_8[]={0,-1,-1,-1,0,1,1,1};
const long long MOD = 1e9+7;

// typedef long long ll;
#define int long long

template <typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}

int cmb[52][52];

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

  int N, A, B, v[50]; cin >> N >> A >> B;
  REP(i, N) cin >> v[i];
  sort(v, v+N); reverse(v, v+N);

  REP(i, 51) REP(j, i+1){
    if(i == 0) cmb[i][j] = 1;
    else if(j == 0 or j == i) cmb[i][j] = 1;
    else cmb[i][j] = cmb[i-1][j-1]+cmb[i-1][j];
  }

  int cnt = 0, tmp = v[0], sum = 0;
  REP(i, A){
    sum += v[i];
    if(v[i] != tmp){
      cnt = 0; tmp = v[i];
    }
    cnt++;
  }
  printf("%f\n", (double)sum/(double)A);
  if(cnt == A){
    tmp = v[0], cnt = 0;
    REP(i, N){
      if(v[i] != tmp) break;
      cnt++;
    }
    int ans = 0;
    for(int i = A; i <= min(B, cnt); i++) ans += cmb[cnt][i];
    cout << ans << endl;
  } else {
    int count = 0;
    REP(i, N) if(v[i] == tmp) count++;
    cout << cmb[count][cnt] << endl;
  }

  return 0;
}

Measured memory_bytes: 256
from sys import stdin


if __name__ == "__main__":
    _in = [_.rstrip() for _ in stdin.readlines()]
    N, A, B = list(map(int,_in[0].split(' ')))  # type:list(int)
    # vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
    cnt = 0
    for n in range(N+1):
        _sum = sum(list(map(int,list(str(n)))))
        if A <= _sum <= B:
            cnt += n
    ## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    print(cnt)


Measured memory_bytes: 42092
#include "bits/stdc++.h"
using namespace std;
#define long int64_t

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

	int N, K;
	cin >> N >> K;

	if( N <= K ) {
		cout << '0' << endl;
		return 0;
	}

	priority_queue<int> H;
	for( int i = 0; i < N; ++i ) {
		int x;
		cin >> x;
		H.push( x );
	}

	long ans = 0;
	while( !H.empty() ) {
		if( K > 0 ) {
			K -= 1;
		}
		else {
			ans += H.top();
		}

		H.pop();
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1400