akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()
#define chmin(a,b) a=min(a,b);
#define chmax(a,b) a=max(a,b);

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int N;
int C[509],S[509],F[509];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>N;
    rep(i,N-1) cin>>C[i]>>S[i]>>F[i];
    
    rep(i,N-1){
        rep(k,i+1){
            if(S[k]<S[i]) S[k]=S[i];
            if(S[k]%F[i]==0){
                S[k]+=C[i];
            }else{
                S[k]=(S[k]/F[i]+1)*F[i]+C[i];
            }
        }
    }
    
    rep(i,N)cout1(S[i])
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define NIL -1

typedef struct tree {
  int p,l,r;
}tax;
tax T[N];

int main()
{
  int n,i,j,k,id,center,temp1,temp2;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    T[i].p=T[i].l=T[i].r=NIL;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&center);
      T[center].p=id;
      if(j==0) T[id].l=center;
      else T[temp1].r=center;
      temp1=center;
    }
  }
  
  for(i=0;i<n;i++){
    id=0;
    k=0;
    temp1=T[i].p;
    temp2=T[i].l;
    
    while(temp1!=NIL){
      k++,temp1=T[temp1].p;
    }
    
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,k);
    
    if(T[i].p==NIL) printf("root, [");
    else if(T[i].l!=NIL) printf("internal node, [");
    else printf("leaf, [");
    
    while(temp2!=NIL){
      if(id==0){
	printf("%d",T[i].l);
	id=1;
      }else printf(", %d",temp2);
      temp2=T[temp2].r;
    }
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 3760
package main

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

func main() {
	scanner := makeScanner(8192)
	n := eGetInt(scanner)
	var sum int64
	for i := 1; i <= n; i++ {
		if i%3 == 0 {
		} else if i%5 == 0 {
		} else if i%15 == 0 {
		} else {
			sum += int64(i)
		}
	}
	fmt.Println(sum)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
const (
	TooLarge = math.MaxInt64
	TooSmall = math.MinInt64
)

func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeCharScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanRunes)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func pow(a, n int) int {
	if n == 0 {
		return 1
	}
	if n == 1 {
		return a
	}
	if n%2 == 1 {
		return pow((a*a), n/2) * a
	}
	return pow((a * a), n/2)
}
func powMod(a, n, mod int) int {
	if n == 0 {
		return 1 % mod
	}
	if n == 1 {
		return a % mod
	}
	if n%2 == 1 {
		return powMod((a*a)%mod, n/2, mod) * a % mod
	}
	return powMod((a*a)%mod, n/2, mod)
}

func factoricalMod(n, count, mod int) int {
	if count == 1 {
		return n % mod
	}
	return (n % mod) * (factoricalMod(n-1, count-1, mod)) % mod
}

func combinationMod(n, a, mod int) int {
	x := factoricalMod(n, a, mod)
	y := factoricalMod(a, a, mod)
	y = powMod(y, mod-2, mod)
	return ((x % mod) * (y % mod)) % mod
}
func countBitOfOn(i, numbits int) int {
	count := 0
	var bit uint64
	for bit = 0; bit < uint64(numbits); bit++ {
		t := 1 << bit
		if i&t > 0 {
			count++
		}
	}
	return count
}

type ints []int

func ToString(slice []int) string {
	format := fmt.Sprint(slice)
	return fmt.Sprint(format[1 : len(format)-1])
}


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

int keta(long long n){
  return n<10?1:1+keta(n/10);
}

int main(){
  long long N;
  cin >> N;
  long long a=1;
  for (long long i=1;i*i<=N;i++){
    if (N%i==0) a=i;
  }
  long long b=N/a;
  cout << keta(b) << endl;
}


Measured memory_bytes: 256
use std::io;

fn main() {
    let mut buffer = String::new();
    io::stdin().read_line(&mut buffer).unwrap();
    buffer.clear();
    io::stdin().read_line(&mut buffer).unwrap();
    let xs: Vec<i32> = buffer
        .split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect();
    let mut ys = Vec::with_capacity(3 * xs.len());
    for x in xs.into_iter() {
        ys.push(x);
        ys.push(x+1);
        ys.push(x-1);
    }
    ys.sort();
    let mut m = 0;
    let mut prev = &ys[0];
    let mut cnt = 0;
    for i in 0..ys.len() {
        if &ys[i] == prev {
            cnt += 1;
        } else {
            if m < cnt {
                m = cnt
            }
            prev = &ys[i];
            cnt = 1;
        }
    }    
    println!("{}", m);
}

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

namespace ConsoleApp1
{
    class Program
    {

        static void Main(string[] args)
        {
            var ks = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var k = ks[0];
            var s = ks[1];

            var count = 0;
            

            for(int x = 0; x <= k; x++)
            {
                for(int y =0;y <=k; y++)
                {
                    if (s - (x + y) >= 0 && s - (x + y) <= k)
                    {
                        count++;
                    }
                }
            }

            Console.WriteLine(count);

        }
        

    }
    

    

}


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

int main() {
  int N, M;
  cin >> N;
  vector<string> blue(N);
  rep(i, N) {
    cin >> blue.at(i);
  }
  cin >> M;
  vector<string> red(M);
  rep(i, M) {
    cin >> red.at(i);
  }
  
  int ans = 0;
  rep(i, N) {
    int tmpans = 0;
    rep(j, N) {
      if (blue.at(i) == blue.at(j)) {
        tmpans++;
      }
    }
    rep(k, M) {
      if (blue.at(i) == red.at(k)) {
        tmpans--;
      }
    }
    if (tmpans > ans) {
      ans = tmpans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import math
from math import *
for i in range(int(raw_input())):
    (x1, y1, x2, y2, x3, y3) = map(float, raw_input().split())
    a1 = 2 * (x2 - x1)
    b1 = 2 * (y2 - y1)
    c1 = x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2
    a2 = 2 * (x3 - x1)
    b2 = 2 * (y3 - y1)
    c2 = x1 ** 2 - x3 ** 2 + y1 ** 2 - y3 ** 2
    xp = (b1 * c2 - b2 * c1) / (a1 * b2 - a2 * b1)
    yp = (c1 * a2 - c2 * a1) / (a1 * b2 - a2 * b1)
    r = sqrt((x1 - xp) ** 2 + (y1 - yp) ** 2)
    print '%.3f %.3f %.3f' % (xp, yp, r)

Measured memory_bytes: 5068
#include <bits/stdc++.h>
using namespace std;
#define _                             \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
typedef long long int ll;

const int mod = 1e9+7;

int main() {
	ll n;
	cin>>n;
	
	ll a[n+1];
	
	for(int i=0;i<n;i++)
		cin>>a[i];
		
	vector<vector<pair<ll,ll>>> dp(n+1,vector<pair<ll,ll>>(n+1,{0,0}));
	
	for(int i=0;i<n;i++)
		dp[i][i] = {a[i],0};
	
	for(int i=n-1;i>=0;i--)
	{
		for(int j=i+1;j<n;j++)
		{
			if(j==i+1)
			{	
				dp[i][j].first = a[i]+a[j];
				dp[i][j].second = a[i]+a[j];
			
			}
			else
			{	
				ll temp1=LONG_LONG_MAX,temp2=LONG_LONG_MAX;
				
				for(int k= i+1;k<=j;k++)
				{
					if(dp[k][j].second+dp[i][k-(1)].second+dp[k][j].first+dp[i][k-(1)].first<temp2)
					{
						temp2 = dp[k][j].first+dp[i][k-(1)].first+dp[k][j].second+dp[i][k-(1)].second;
						temp1 = dp[k][j].first+dp[i][k-(1)].first;
					}
				}
				dp[i][j] = {temp1,temp2};
				//dp[i][j].second = max(dp[i][j-1].second+dp[i][j-1].first+a[j] , dp[i+1][j].second+dp[i+1][j].first+a[i]);
				//dp[i][j].first = max(dp[i][j-1].first+a[j] , dp[i+1][j].first+a[i]);
			
			}
		}
	}
	
	
	
	cout<<dp[0][n-1].second;
    return 0;
}


Measured memory_bytes: 2816
import numpy as np
N = int(input())
P = []
Q = []
for i in range(N):
    P.append(list(map(int, input().split())))
    Q.append(sum(P[-1])%2)
if 1 in Q and 0 in Q:
    print(-1)
else:
    P = np.array(P)
    arm = [2**i for i in range(33)]
    if Q[0] == 0:
        arm.append(1)
    arm.reverse()
    print(len(arm))
    print(' '.join([str(n) for n in arm]))
    check2 = []
    for i in range(N):
        x = P[i, 0]
        y = P[i, 1]
        check = [[x, y]]
        STR = []
        for j in range(len(arm)):
            d = arm[j]
            if abs(x) > abs(y):
                if x > 0:
                    x = x-d
                    STR.append('R')
                else:
                    x = x+d
                    STR.append('L')
            else:
                if y > 0:
                    y = y-d
                    STR.append('U')
                else:
                    y = y+d
                    STR.append('D')
            check.append([x, y])
        if x == 0 and y == 0:
            check2.append('Yes')
        else:
            check2.append('No')

        print(''.join(STR))

Measured memory_bytes: 12908
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    int a,k,i,j,n,mx=0,ct=1,sum=0,ans;
    string s;
    cin >> s;
    if(s[0]=='R')
    {
        if(s[1]=='R')
            if(s[2]=='R')
                ans = 3;
            else
                ans = 2;
        else
            ans = 1;
    }
    else if(s[1]=='R')
        if(s[2]=='R')
            ans = 2;
        else
            ans = 1;
    else if(s[2]=='R')
        ans=1;
    else
        ans=0;
    cout <<ans<<endl;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
   // cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll MOD = 1000000007;
const ll INF = 10000000000000;
#define all(v) v.begin(), v.end()

int main(){
  ll N,M;
  cin >> N >> M;
  vector<vector<ll>> dp(M,vector<ll>((ll)pow(2,N),INF));
  rep(i,M) dp.at(i).at(0)=0;
  rep(i,M){
    ll a,b;
    cin >> a >> b;
    vector<ll> c(b);
    rep(j,b) cin >> c.at(j);
    ll t=0;
    rep(j,b){
      t+=(ll)pow(2,c.at(j)-1);
    }
    if(i==0){
      dp.at(i).at(t)=a;
      continue;
    }
    rep(j,(ll)pow(2,N)){
      dp.at(i).at(j)=min(dp.at(i).at(j),dp.at(i-1).at(j));
      if(t!=j){
        dp.at(i).at(t|j)=min(dp.at(i).at(t|j),dp.at(i-1).at(j)+a);
      }
    }
  }
  if(dp.at(M-1).at((ll)pow(2,N)-1)==INF){
    cout << -1 << endl;
  }else{
    cout << dp.at(M-1).at((ll)pow(2,N)-1) << endl;
  }
}

Measured memory_bytes: 32256
house = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n=int(input())
for x in range(n):
    a,b,c,d=map(int,input().split())
    house[a-1][b-1][c-1]+=d
for i in range(4):
    for j in range(3):
        for k in range(10):
            print(f' {house[i][j][k]}',end="")
        print()
    if int(i)<3: print("#"*20)



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

#define mp make_pair
#define pb push_back
typedef pair<int,int> p;

int main()
{
  int w,h,d=0,n,x,y,a;
  cin>>w>>h>>n;
  vector<p> v(w*h);
  for(int i=0;i<w;i++)
    for(int j=1;j<=h;j++)
      v[d++] = mp(i,j);
  //cout<<d<<"\n";
  while(n--)
  {
    cin>>x>>y>>a;
    vector<int> er;
    switch(a)
    {
      case 1:{
        for(int i=0;i<v.size();i++)
        {
          if(v[i].first<x)
            er.pb(i);
        }
        for(int i=0;i<er.size();i++)
          v.erase(v.begin()+er[i]-i);

        er.clear();
            break;}
      case 2:{
      for(int i=0;i<v.size();i++)
      {
        if(v[i].first>=x)
          er.pb(i);
      }
      for(int i=0;i<er.size();i++)
        v.erase(v.begin()+er[i]-i);

      er.clear();

            break;}
      case 3:{
      for(int i=0;i<v.size();i++)
      {
        if(v[i].second<=y)
          er.pb(i);
      }
      for(int i=0;i<er.size();i++)
        v.erase(v.begin()+er[i]-i);

      er.clear();
            break;}
      case 4:
      {for(int i=0;i<v.size();i++)
      {
        if(v[i].second>y)
          er.pb(i);
      }
      for(int i=0;i<er.size();i++)
        v.erase(v.begin()+er[i]-i);

      er.clear();
            break;
          }
    }
  }
  /*for(auto i:v)
    cout<<i.first<<" "<<i.second<<"\n";*/
  cout<<v.size()<<"\n";

  return 0;
}


Measured memory_bytes: 384
import scala.collection.mutable
import scala.collection.mutable.ArrayBuffer
import scala.io.StdIn._

object Main extends App {
  val Array(v, e) = readLine.trim.split(' ').map(_.toInt)
  val nodes = Array.fill(v){ArrayBuffer[Edge]()}
  for (_ ← 0 until e) {
    val Array(u, v, c) = readLine.trim.split(' ').map(_.toInt)
    nodes(u).append(new Edge(v, c))
    nodes(v).append(new Edge(u, 0))
    nodes(u).last.pair = nodes(v).last
    nodes(v).last.pair = nodes(u).last
  }
  val depth = Array.fill(v){0}
  val searching = Array.fill(v){0}
  var flow = 0
  var hasFlow = true
  while(hasFlow) {
    hasFlow = false
    bfs()
    var f = dfs(0)
    while(f != -1) {
      hasFlow = true
      flow += f
      f = dfs(0)
    }
  }
  println(flow)
  def bfs(): Unit = {
    val queue = mutable.Queue(0)
    depth.indices.foreach(i ⇒ depth(i) = -1)
    searching.indices.foreach(i ⇒ searching(i) = 0)
    depth(0) = 0
    while (queue.nonEmpty) {
      val current = queue.dequeue()
      for (Edge(to, flow) ← nodes(current) if flow > 0 && depth(to) == -1) {
        depth(to) = depth(current) + 1
        queue.enqueue(to)
      }
    }
  }
  def dfs(current: Int, min: Int = Int.MaxValue): Int = {
    if (current == v - 1) min
    else {
      var result = -1
      while (result == -1 && searching(current) < nodes(current).length) {
        val Edge(to, flow) = nodes(current)(searching(current))
        if (flow > 0 && depth(current) < depth(to)) {
          result = dfs(to, math.min(flow, min))
        }
        if (result == -1) {
          searching(current) += 1
        }
      }
      if (result != -1) {
        nodes(current)(searching(current)).flow -= result
        nodes(current)(searching(current)).pair.flow += result
      }
      result
    }
  }
  case class Edge(to: Int, var flow: Int) {
    private var mPair: Option[Edge] = None
    def pair: Edge = mPair.get
    def pair_=(edge: Edge): Unit = mPair = Some(edge)
  }
}



Measured memory_bytes: 46960
"""
author : halo2halo
date : 2, Feb, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

mod = 10 ** 9 + 7

H,W = map(int, readline().split())
S=read().decode('Utf8').split()
for i in S:
    print(i)
    print(i)


Measured memory_bytes: 3060
#include <iostream>
#include<deque>
typedef long long int ll;

using namespace std;

int main()
{
    int N;
    cin>>N;
    deque<ll> p;
    while(N--)
    {
        int numhah;
        cin>>numhah;
        switch (numhah)
        {
            case 0:
            int opr;
            cin>>opr;
            ll num;
            cin>>num;
            if(opr==1)p.push_back(num);
            else p.push_front(num);
                break;
            case 1:
                int num1;
                cin>>num1;
                cout<<p.at(num1)<<endl;
                break;
            case 2:
                int num2;
                cin>>num2;
                if(num2==0)p.pop_front();
                else p.pop_back();
                break;
            default:break;
        }
    }
}



Measured memory_bytes: 6168
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStreamReader;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */
public class Main {
	public final static double MAX_T = 1000000;
	public final static double MIN_T = 0;
	public static int s = 0;

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskC solver = new TaskC();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskC {

		public class Node {
			int index;
			ArrayList<Node> edges = new ArrayList<>();
		}

		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int n = in.nextInt();
			int m = in.nextInt();
			Node[] nodes = new Node[n];
			for (int i = 0; i < n; i++) {
				nodes[i] = new Node();
				nodes[i].index = i;
			}

			for (int i = 0; i < m; i++) {
				int u = in.nextInt() - 1;
				int v = in.nextInt() - 1;
				nodes[u].edges.add(nodes[v]);
				nodes[v].edges.add(nodes[u]);
			}
			ArrayList<Node> q = new ArrayList<>();
			ArrayList<Node> q1 = new ArrayList<>();
			q.addAll(nodes[0].edges);
			for (Node n1 : q) {
				q1.addAll(n1.edges);
			}
			out.println(q1.contains(nodes[n - 1]) ? "POSSIBLE" : "IMPOSSIBLE");

		}

	}

	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public double nextFloat() {
			return Double.parseDouble(next());
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
}


Measured memory_bytes: 88664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
// Welcome to my source code!

const int MOD = 998244353;

ll dp[3005][3005];

int main() {
    int n, s;
    cin >> n >> s;
    int a[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i <= n; i++) dp[i][0] = 1;
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= s; j++) {
            if (j >= a[i]) dp[i + 1][j] += dp[i][j - a[i]];
            dp[i + 1][j] += dp[i][j];
            dp[i + 1][j] %= MOD;
        }
        ans += dp[i + 1][s];
        ans %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define bug1( x ) {cerr << (#x) <<"="<< x << endl;}
#define bug2( x , y ) {cerr << (#x) <<"="<< (x) << "    " << (#y) << "="<< (y) << endl;}
#define bug3( x , y , z ) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << endl;}
#define bug4( x , y , z , w) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << endl;}
#define bug5( x , y , z , w ,p) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << endl;}
#define bug6( x , y , z , w ,p , q) {cerr << (#x) <<"="<<(x) << "    " << (#y) <<"="<< (y) << "    " << (#z) <<"="<< (z) << "    " << (#w) <<"="<< w << "    " << (#p) <<"="<< p << "    " << (#q) <<"="<< q << endl;}
#define bugn( x , n ) {cerr << (#x) <<":";for(int i=0;i<n;i++)cerr << x[i] <<"  "; cerr << endl;}
#define bugnm( x , n , m ) {cerr << (#x)<<endl;for(int i=0;i<n;i++){cerr << "Row #" << i<< ":";for(int j=0;j<m;j++)cerr << x[i][j] << "   ";cerr << endl;}}
typedef long long ll;
typedef long double ld;
using namespace std;

const int maxn = 1e4+10;
int dp[maxn];
int32_t main(){
	IOS
	for(int i=0;i<maxn;i++){
		dp[i]=1e18;
	}
	dp[0]=0;
	int h,n;cin>>h>>n;
	for(int i=0;i<n;i++){
		int a,b;cin>>a>>b;
		for(int j=0;j<maxn;j++){
			int idx = min( j+a , maxn-1 );
			dp[idx]=min(dp[idx],dp[j]+b);
		}
	}
	int ans = 1e18;
	for(int i=h;i<maxn;i++){
		ans=min(ans,dp[i]);
	}
	cout<<ans;
	
	
	
}
 
/*
 * long long or int?
 * index out of bound? 
 * Tested on own test case?corner?
 * Make more general solution.
 * Read Read Read Read ....
 */


Measured memory_bytes: 3712
def countingsort(A, n, k):
    B = [None for _ in range(n+1)]
    C = [0 for _ in range(k+1)]

    for j in range(0, n):
        C[A[j]] += 1

    for i in range(1, k+1):
        C[i] = C[i] + C[i-1]

    for j in range(n-1, -1, -1):
        B[C[A[j]]] = A[j]
        C[A[j]] -= 1

    return B

if __name__ == "__main__":
    n = int(input())
    A = list(map(int, input().split()))
    k = max(A)

    print(' '.join(map(str, countingsort(A, n, k)[1:])))



Measured memory_bytes: 231712
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000
int main() {
    int n,k,x,ans=0;
    cin>>n>>k;
    vector<int> p;
    for (int i=0; i<n; i++) {
        cin>>x;
        p.push_back(x);
    }
    sort(p.begin(), p.end());
    for(int i=0;i<k;i++) ans += p[i];
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3608
#abc 042 c
def dfs(i,s):
    if i==n_keta:
        if s>=n:
            kouho.append(s)
        return 0
    for j in range(len(like)):
        dfs(i+1,s+like[j])
    return 0

n,k=input().split()
d=list(map(int,input().split()))
like=[]
for i in range(10):
    if i not in d:
        like.append(str(i))
kouho=[]
n_keta=len(n)
dfs(0,"")
ans=""
if kouho==[]:
    if like[0]=="0":
        ans+=like[1]
    else:
        ans+=like[0]
    for i in range(n_keta):
        ans+=like[0]
else:
    ans=min(kouho)
print(ans)     

Measured memory_bytes: 3064
#include<cstdio>
 
int a,b;
 
signed main(){
	scanf("%d%d",&a,&b);
	if(!a){
		if(b!=100)
			printf("%d\n",b);
		else
			printf("%d\n",b+1);
		return 0;
	} else if(a==1){
		if(b!=100)
			printf("%d00",b);
		else
			printf("%d00",b+1);
		return 0;
	} else{
		if(b!=100)
			printf("%d0000",b);
		else
			printf("%d0000",b+1);
		return 0;
	}
}

Measured memory_bytes: 128
//abc141_c.cpp
//Sun Sep 15 20:57:56 2019

#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#include <set>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

int main(){
	int n,k,q;
	cin >> n >> k >> q;

	int seikai[n];
	fill(seikai,seikai+n,0);
	int a[q];
	for (int i=0;i<q;i++){
		int temp;
		cin >> temp;
		temp--;
		seikai[temp]++;
	}

	for (int i=0;i<n;i++){
		if (seikai[i]>q-k){
			cout << "Yes" << endl;
		}else {
			cout << "No" << endl;
		}
	}

}

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

int main(){
    int N;
    cin >> N;
     vector<float> V(N);
     for (int i=0;i<N;i++){
         cin >> V.at(i);
     }

     std::sort(V.begin(),V.end());

     int i = 1;

     float now = (V.at(0) + V.at(1))/2;

     //cout << "totyu " << now << endl;

     V.erase(V.begin(),V.begin() + 2);

     while(i <= N - 2){
         i++;
        //cout << "imano_sento " << V.at(0) << endl;
         now = (now + V.at(0))/2;
         //cout << "totyu " << now << endl;
         V.erase(V.begin());
     }

     cout << now << endl;

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>//"Compiler options:"???"-lm"??¨??\???
#include <stdlib.h>

int main(void){
    int n,i;
    double d[5];
    scanf("%d",&n);
    int x[n],y[n];
    for(i=0;i<n;i++){
        scanf("%d ",&x[i]);
    }
     for(i=0;i<n;i++){
        scanf("%d ",&y[i]);
    }
    //p=1?????¨???
    d[1]=0;
    for(i=0;i<n;i++){
        d[1] += abs(x[i]-y[i]);
    }
    //p=2?????¨???
    d[2]=0;
    double u=0;
    for(i=0;i<n;i++){
        u += abs(x[i]-y[i])*abs(x[i]-y[i]);
    }
    d[2] = sqrt(u);
    //p=3?????¨???
    d[3]=0;
    u=0;
    for(i=0;i<n;i++){
        u += abs(x[i]-y[i])*abs(x[i]-y[i])*abs(x[i]-y[i]);
    }
    d[3] = cbrt(u);
    //??????
    for(i=1;i<=3;i++){
        printf("%f\n",d[i]);
    }
    //p???????????¨???
    double lim = 0;
    u = 0;
    for(i=0;i<n;i++){
        u = abs(x[i]-y[i]);
        if(lim < u){
            lim = u;
        }
    }
    //??????
    printf("%f\n",lim);
    return 0; /*0?????????*/
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    long long d;
    int ans = 0;
    cin >> n >> d;
    for (int i = 0; i < n; i++) {
        long long x, y;
        cin >> x >> y;
        if (x * x + y * y <= d * d)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
import java.util.*;
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] s = br.readLine().split("\\s");
        long N = Long.parseLong(s[0]);
        long W = Long.parseLong(s[1]);
        long[][] ws = new long[(int)N][2];
        for(int i=0;i<N;++i){
            s = br.readLine().split("\\s");
            ws[i][0] = Long.parseLong(s[0]);
            ws[i][1] = Long.parseLong(s[1]);
        }
        
        long[][] dp = new long[(int)N+1][(int)W+1];
        long max_val = 0,minw = ws[0][0];
        
        for(int i=0;i<ws.length;++i) minw = Math.min(minw,ws[i][0]);
        
        for(int i=0;i<N;++i){
            for(int j=(int)minw;j<=W;++j){
                if(j - ws[i][0] >= 0) dp[i+1][j] = Math.max(dp[i][j-(int)ws[i][0]] + ws[i][1],dp[i][j]);
                else dp[i+1][j] = dp[i][j];
                max_val = Math.max(max_val,dp[i+1][j]);
            }
        }
        
        System.out.println(max_val);
    }    
}


Measured memory_bytes: 126292
# -*- coding: utf-8 -*-

N = int(input())
AList = list(map(int, input().split()))

AList.sort()
AList.reverse()

alice = 0
bob = 0

count = 0
for a in AList :
    if (count % 2) == 0 :
        alice += a
    else :
        bob += a
    count += 1

print(alice-bob)

Measured memory_bytes: 3060
#include<stdio.h>
void main(){
  char str[6];
  int i;
  int q=0;

  scanf("%s\n",str );

  if(str[2]==str[3]){
    q++;
  }
  if(str[4]==str[5]){
    q++;
  }

  if(q==2){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}


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

#define debug(x) cout << #x" = " << x;

#define st first
#define nd second

using namespace std;
using namespace placeholders;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

const int MAXN = 2E3 + 10;

int n;
int a[MAXN], vis[MAXN];
vector<int> E[MAXN];

vector<int> DFS(int u){
	static int temp[MAXN];
	vis[u] = true;
	vector<int> ret;
	for (int v, i = 0; i < E[u].size(); ++i){
		if (vis[v = E[u][i]])
			continue;
		vector<int> res = DFS(v);
		merge(ret.begin(), ret.end(), res.begin(), res.end(), temp, greater<int>());
		ret = vector<int>(temp, temp + ret.size() + res.size());
	}
	ret.insert(ret.begin(), a[u]);
	return ret;
}

int main(){
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i){
		scanf("%d", a + i);
		for (int j = 1; j < i; ++j)
			if (__gcd(a[i], a[j]) > 1)
				E[i].push_back(j), E[j].push_back(i);
		E[0].push_back(i);
	}
	for (int i = 0; i <= n; ++i)
		sort(E[i].begin(), E[i].end(), [](int l, int r){return a[l] < a[r];});
	vector<int> ans = DFS(0);
	for (int i = 1; i <= n; ++i)
		printf("%d%c", ans[i], "\n "[i < n]);
	return 0;
}


Measured memory_bytes: 16768
#include <iostream>

int main(int argc, char const* argv[])
{
  int i, j;

  for (i = 1; i <= 9; i++) {
    for (j = 1; j <= 9; j++) {
      std::cout << i << "x" << j << "=" << i * j << std::endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1116
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
int a[22][22];
LL dp[(1 << 21)];
const LL mod = 1e9 + 7;

int main(){
    cin >> n;
    REP(i, n)REP(j, n)cin >> a[i][j];
    dp[0] = 1;
    REP(bit, (1 << n)){
        int i = popcnt(bit);
        REP(j, n){
            if(bit & (1 << j))continue;
            if(a[i][j] == 0)continue;
            (dp[bit + (1 << j)] += dp[bit]) %= mod;
        }
    }
    cout << dp[(1 << n) - 1] << endl;
}

Measured memory_bytes: 16768
S = [len(s) for s in input().split("T")]
X, Y = map(int, input().split())

# X方向・Y方向の移動成分
X_move = S[2::2]
Y_move = S[1::2]

# X方向・Y方法の到達可能な場所
X_reached = {S[0]}
Y_reached = {0}

# 到達可能な場所を計算
for xm in X_move:
    tmp = set()
    for xr in X_reached:
        tmp.add(xr + xm)
        tmp.add(xr - xm)
    X_reached = tmp

for ym in Y_move:
    tmp = set()
    for yr in Y_reached:
        tmp.add(yr + ym)
        tmp.add(yr - ym)
    Y_reached = tmp

print("Yes" if (X in X_reached and Y in Y_reached) else "No")


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

int main()
{
    map<int,int>mp;

    int n,val;
    cin>>n;
    for(int i=1; i<=n; i++)
    {
        cin>>val;
        mp[val]++;
    }
    int m;
    int loc =0;
    cin>>m;
    for(int i=1; i<=m; i++)
    {
        cin>>val;
        if(mp[val]>0)
        {
           loc = 1;
           --mp[val];
        }
        else{
            loc = 0;
            break;
        }
    }
    if(loc)
        cout<<"YES"<<endl;
    else
        cout<<"NO"<<endl;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll k, a, b;
    cin>>k>>a>>b;
    ll i=1;
    while(k*i<a){
        i++;
    }
    cout<<(k*i>=a&&k*i<=b?"OK":"NG");
    return 0;
}

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

int main(){
	// sengen
	int n,k;
	// nyuryoku
	cin >> n >> k;
	// keisan
	double ans = 0,tmp;
	for(int i=1;i <= n;i++){
		tmp = (double)1/n;
		int now = i;
		while(now < k){
			now *= 2;
			tmp = tmp/2;
		}
		ans += tmp;
	}
	// syutsuryoku
	printf("%.12lf\n",ans);
}

Measured memory_bytes: 3688
from collections import defaultdict

def main():
    INF = float("inf")

    N, *A = map(int, open(0).read().split())

    dp_in = defaultdict(lambda: -INF)

    dp_out = defaultdict(lambda: -INF)
    dp_out[(0, 0)] = 0

    for i, a in enumerate(A, 1):
        p = i // 2
        for j in [p - 1, p, p + 1]:
            dp_in[(i, j)] = a + dp_out[(i - 1, j - 1)]
            dp_out[(i, j)] = max(dp_in[(i - 1, j)], dp_out[(i - 1, j)])

    print(max(dp_in[(N, N // 2)], dp_out[(N, N // 2)]))

main()

Measured memory_bytes: 291132
#include<stdio.h>
#include<stdlib.h>
#include<math.h>


int main(){

  int N,M;

  scanf("%d %d",&N,&M);

  /*
  int A[N];
  int i;
  for(i=0;i<N;i++){
   scanf("%d",&A[i]);
   }
  */
  int i;
  int x;
  x = N/0.08;
  for(i=0;i<=1000;i++){
  if((int)((x+i)*0.08) == N && (int)((x+i)*0.1) == M){
   printf("%d",(int)(x+i));
   return(0);
  }

  else{}
  }

  printf("-1");





 return(0);
 }


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define ull unsigned long long int
#define ll long long int
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define MOD (ull)(double)(1e9 + 7)
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vb vector<bool>
#define vd vector<double>
#define vll vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define vvi vector<vi>
#define vvll vector<vll>
#define vs vector<string>
#define pull pair<ull, ull>
#define F first
#define S second
#define m_p make_pair
#define debug(x) cout << #x << " " << x << endl
#define printArr(a, start, end)for(int i=start ; i<end ; ++i)cout << a[i] << " ";cout << '\n';
#define readArr(a, start, end)for(int i=start ; i<end ; ++i)cin >> a[i];
#define read2D(mat, n, m)for(int i=0 ; i<n ; ++i)for(int j=0 ; j<m ; ++j)cin >> mat[i][j];

const long double PI = 3.141592653589793238462643383279502884197169399;

// Find Set LSB = (x&(-x)), isPowerOfTwo = (x & (x-1))

void solve(){
	ll x, k, d;
	cin >> x >> k >> d;
	
	x = abs(x);
	
	ll req = x / d;
	if(req >= k){
		cout << abs(x - d*k);
		return;
	}
	
	x -= d*req;
	k -= req;
	if(k&1)cout << abs(x - d);
	else cout << abs(x);
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	cout << fixed << setprecision(10);
	
	int tt=1;
	//cin >> tt;
	
	while(tt--){
		solve();
	}
}


Measured memory_bytes: 3608
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif


int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
 
    ll ans=0;

    ll n,d;

    cin >> n >> d;

    for(ll i=0; i<n; i++){
        ll x,y;
        cin >> x >> y;

        if(x*x+y*y<=d*d)
            ans++;
    }

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



Measured memory_bytes: 3648
N = int(input())
A = list(map(int, input().split()))
mod = int(1e9+7)

all = pow(sum(A), 2, mod=mod)%mod
d = 0
for a in A:
    d += pow(a,2)
    d = d%mod

print(int((all-d)*pow(2, mod-2, mod=mod))%mod)


Measured memory_bytes: 31644
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  double r, ans;

  scanf("%lf", &r);

  ans = 2 * r * M_PI;
  printf("%.2f\n", ans);

  return 0;
  }


Measured memory_bytes: 1708
def reverse(s): 
    return s[::-1] 
  
def isPalindrome(s): 
    rev = reverse(s) 
  
    if (s == rev): 
        return True
    return False

i = input()
a = (len(i)-1)//2 
b = (len(i)+3)//2
s1 = i[:a]
s2 = i[b-1:]
flag = False
if isPalindrome(i):
    if isPalindrome(s1):
        if isPalindrome(s2):
            flag = True
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 38336
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}



signed main(void) {
    int n;
    cin >> n;
    vector<vi> in(n,vi(n));
    rep(i,n)rep(j,n)cin >> in[i][j];
    vi sum(1<<n);
    rep(bit,1<<n){
        rep(i,n)loop(j,i+1,n)if((bit & 1<<i) && (bit & 1<<j)){
            sum[bit] += in[i][j];
        }
    }
    vi dp(1<<n,-1);
    dp[0] = 0;
    loop(bit,1,1<<n){
        for(int y = 0; ; y = (y - bit) & bit){
            int z = y ^ bit;
            dp[bit] = max(dp[bit], dp[y] + sum[z]);
            if(y == bit) break;
        }
    }
    cout << dp.back() << endl;
}


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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int ori_n = n;
    vector<pair<int, int>> fs;
    for(int i=2; i*i<=n; i++){
        int x = 0;
        while(n % i == 0){
            ++x;
            n /= i;
        }
        fs.push_back(make_pair(i, x));
    }
    if(n != 1) fs.push_back(make_pair(n, 1));
    printf("%d:", ori_n);
    for(auto fn: fs){
        rep(_,fn.second){
            printf(" %d", fn.first);
        }
    }
    cout << endl;
}


Measured memory_bytes: 3332
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int q, t, a, b, before, after;
long long c, ans;
multiset<pair<int, int> > mst;
map<int, int> mp;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> q;
	q--;
	cin >> t >> a >> b;
	c += b;
	mp[a]++;
	mst.insert(make_pair(a, mp[a]));
	auto p = mst.begin();
	while (q--) {
		cin >> t;
		if (t == 1) {
			cin >> a >> b;
			c += b;
			mp[a]++;
			mst.insert(make_pair(a, mp[a]));
			ans += abs((*p).fi - a);
			if (a < (*p).fi) {
				before++;
			}
			else if ((*p).fi < a){
				after++;
			}
			else {
				after++;
			}
			if (before - after > 1) {
				auto tmp = p;
				p--;
				int d = (*tmp).fi - (*p).fi;
				ans -= d*1LL*before;
				ans += d * 1LL * (1 + after);
				before--;
				after++;
			}
			else if (after - before > 1) {
				auto tmp = p;
				p++;
				int d = (*p).fi - (*tmp).fi;
				ans -= d * 1LL * after;
				ans += d * 1LL * (1 + before);
				before++;
				after--;
			}
		}
		else {
			auto tmp = p;
			if (before - after == 1) tmp--;
			cout << (*tmp).fi << " " << ans + c << "\n";
		}
	}
	//system("pause");
	return 0;
}

Measured memory_bytes: 12032
#include<stdio.h>
int main()
{
    int N,T,i,k,temp,t[100],c[100];
    scanf("%d %d",&N,&T);
    for(i=0;i<N;i++)
    {
        scanf("%d %d",&c[i],&t[i]);
        if(t[i]>T) c[i]=1500;
    }
       for(i=0; i<N; i++)
    {
        for(k=i+1; k<N; k++)
        {
            if(c[i] > c[k])
            {
                temp = c[i];
                c[i] = c[k];
                c[k] = temp;
            }
        }
    }
    if(c[0]!=1500) printf("%d",c[0]);
    else printf("TLE");
}



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

using namespace std;

typedef long long ll;

#define mod 1000000007
#define siz 100001

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll n,k;
	cin >> n >> k;
	
	vector<ll> v(n);
	for(ll i = 0; i < n; i++) cin >> v[i];
	
	sort(v.begin(), v.end());
	
	ll sums = 0;
	for(ll i = 0; i < k; i++) sums += v[i];
	
	cout << sums << "\n";
}

Measured memory_bytes: 3600
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector.Unboxed as VU

main :: IO ()
main = do
  let
    encode :: T.Text -> Int
    encode t | c == 'A'  = 0
             | c == 'W'  = 1
             | c == 'T'  = 2
             | otherwise = 3
      where
        c = T.head t
    decode :: Int -> String
    decode 0 = "AC"
    decode 1 = "WA"
    decode 2 = "TLE"
    decode _ = "RE"
    tally :: [Int] -> VU.Vector Int
    tally = VU.accum (const . succ) (VU.replicate 4 0) . map (flip (,) ())
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  ss <- sequence . replicate n $ encode <$> T.getLine :: IO [Int]
  let
    cs = map show . VU.toList . tally $ ss :: [String]
  mapM_ putStrLn $ zipWith (++) (map ((++ " x ") . decode) [0..3]) cs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


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

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

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

  int cnt = 0;
  
  for(int i = 0; i < n; i++){
    int minj = i;

    for(int j = i; j < n; j++){
      if(a[j] < a[minj]){
	minj = j;
      }
    }

    if(i != minj){
      int dummy;
      dummy = a[i];
      a[i] = a[minj];
      a[minj] = dummy;
      cnt++;
    }
  }
  
  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << a[i];
  }
  
  cout << endl;
  cout << cnt << endl;
  
  return 0;
  
}





Measured memory_bytes: 3112
#include<bits/stdc++.h>
#define yes cout<<"Yes"<<endl;
#define no cout<<"No"<<endl;
#define ll long long int
using namespace std;
int main()
{
    ll tc;
    ll a,b,c,n,x,y,z,cnt=0,sum=0;
    string str;
    cin>>str;
    if(str[0]=='9'||str[1]=='9')
    {
        yes;
        return 0;
    }
    else no

}


Measured memory_bytes: 3516
use std::io;
use std::collections::VecDeque;

fn main() {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin
        .read_line(&mut buf)
        .expect("ERROR Can't read array size");
    let v: Vec<usize> = buf.split_whitespace()
        .map(|n| n.parse().unwrap())
        .collect();
    let n = v[0];
    let m = v[1];
    let mut graph: Vec<Vec<usize>> = Vec::with_capacity(n);
    for _ in 0..n {
        graph.push(Vec::new());
    }
    for _ in 0..m {
        let mut buf = String::new();
        stdin
            .read_line(&mut buf)
            .expect("ERROR Can't read array size");
        let v: Vec<usize> = buf.split_whitespace()
            .map(|n| n.parse().unwrap())
            .collect();
        let a = v[0]-1;
        let b = v[1]-1;
        graph.get_mut(a).unwrap().push(b);
        graph.get_mut(b).unwrap().push(a);
    }

    let res = graph[0].iter().find(|&x| graph[*x].iter().find(|&y| *y==n-1).is_some()).is_some();
    if res {
        println!("POSSIBLE")
    } else {
        println!("IMPOSSIBLE")
    }

}


Measured memory_bytes: 18684
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int A = sc.nextInt();
    int B = sc.nextInt();
    int T = sc.nextInt();

    sc.close();
    
    int a = T / A;

    System.out.println(a * B);

  }

}

Measured memory_bytes: 22612