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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(24);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;


// <------------- Declare Variables Here ------------> //

ll T = 1;

ll n, m, x, k, a , b;
string s, t;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	ld a,b;
	cin>>a>>b;
	cout<<(ll)(a*b);
}

int main() {
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3728
#include <stdlib.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>


using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

char change[100];
int main(){
	vector<string> ans;
	while(1){
		REP(i,100)change[i]='?';
		int n;
		cin>>n;
		if(n==0)break;
		REP(i,n){
			char t1,t2;
			cin>>t1>>t2;
			change[(unsigned int)(t1-'0')]=t2;
		}
		int m;
		cin>>m;
		string temp;
		REP(i,m){
			char tt,ss;
			cin>>tt;
			ss=(change[(unsigned int)(tt-'0')]!='?')?change[(unsigned int)(tt-'0')]:tt;
			temp+=ss;
		}
		ans.push_back(temp);
	}
	REP(i,ans.size())cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 1336
#include<cstdio>
#include<cstring>
//#include<iostream>
using namespace std;

int main(){
	char in[21], out[21] ;
	int n, i;

	scanf("%s", in);
	n= strlen(in);
	for(i=0; i<n; i++)	out[i]=in[n-i-1];
	out[n]='\0';
	printf("%s\n", out);

 return 0;
}

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

int		main(void)
{
	string s;

	cin >> s;
	int ops = 0;
	for (int i = 0; i < 3; i++)
		s[i] == 'o' ? ops++ : 0;
	cout << (700 + 100 * ops) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define F(i,a,b) for(int i=a;i<b;i++)
#define f(i,n) for(int i=0;i<n;i++)
typedef unsigned long long ull;
typedef long long ll;
#define pb(a) push_back(a);

int main(){
	int n;
	cin>>n;
	// int dp[]
	int choice[n];
	int a[n][3];
	int maxA,maxB,maxC,total=0,na,nb,nc;
	f(i,n){
		cin>>a[i][0]>>a[i][1]>>a[i][2];
		if(i==0) {
			maxA=a[i][0];
			maxB=a[i][1];
			maxC=a[i][2];
			total = max(maxA,max(maxB,maxC));
		}
		else{
			na = a[i][0] + max(maxC,maxB);
			nb = a[i][1] + max(maxA,maxC);
			nc = a[i][2] + max(maxB,maxA);
			total = max(na,max(nc,nb));
			maxA=na;
			maxB=nb;
			maxC=nc;
		}
		
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <memory.h>
#include <math.h>

#define MAX(a, b) (((a) > (b)) ? (a) : (b))
#define MIN(a, b) (((a) > (b)) ? (b) : (a))
#define SWAP(t, a, b) do{t c = a; a = b; b = c;}while(0)

int main (int argc, char **argv)
{
  int64_t a = 0;
  int64_t b = 0;
  int64_t c = 0;

  scanf("%lld %lld %lld", &a, &b ,&c);

  printf("%lld\n", (((a - b) > c) ? (0) : (c -(a - b))));

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep for(int i = 0;i<n;i++)
#define ll long long
 
//const int INF = 1e8;
typedef pair<int,int>P;
int dx[4] = {1,0,-1,0};int dy[4] = {0,1,0,-1};
queue<P> que;
bool compare(pair<pair<int,int>,int> a,pair<pair<int,int>,int> b){
    return a.second < b.second;
}
int main(){
    string s;cin >> s;
    int f = 1e9;int c = 1e9;
    for(int i = 0;i<s.size();i++){
        if(s.at(i) == 'F') f = i;
    }
    for(int i = s.size()-1;i>=0;i--){
        if(s.at(i) == 'C') c = i;
    }
    if(c<f and c<s.size() and f<s.size()){
        cout <<"Yes"<<endl;
    }else{
        cout << "No" << endl;
    }

}

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

using namespace std;

int main()
{ char a[10000] ;
   int n ;
 cin >> n;
 cin>>a;
 for ( int i =0 ; i < strlen(a) ;i++ )
 { int ans  =(int) a[i]+n ;
  if ( ans > 90) ans -=26 ;
 a[i] = (char) ans ;
 }
   cout<<a;
      return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;
    char s[16];
    char new_num[8] = { 0, 1, 2, 3, 5, 7, 8, 9 };
    int i;

    while (1){
        scanf("%d", &n);
        if (n == 0){
            break;
        }

        sprintf(s, "%o", n);
        for (i = 0; s[i] != '\0'; i++){
            if (s[i] >= '5'){
                s[i] += 2;
            }
            else if (s[i] >= '4'){
                s[i]++;
            }
        }
        printf("%s\n", s);
    }

    return (0);
}

Measured memory_bytes: 620
from heapq import heappop,heappush
from operator import or_
from functools import reduce

N,M = map(int,input().split())
def it():
    for _ in range(M):
        a,b = map(int,input().split())
        c = sum(2**(x-1) for x in map(int,input().split()))
        yield (a,c)
boxes = list(it())

end = 2**N-1
check = reduce(or_, (c for a,c in boxes))
if check != end:
    print(-1)
    exit()

cost = [float('inf')]*(2**N)
cost[0] = 0
q = [(0,0)]

while q:
    c,v = heappop(q)
    if cost[v] < c:
        continue
    if v == end:
        break
    for nc,u in boxes:
        nc += c
        u |= v
        if nc < cost[u]:
            heappush(q,(nc,u))
            cost[u] = nc

print(cost[end])


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

using namespace std;

void input();
string s;

void solve(){
    for(int i=0;i<3;i++)cout<<s[i];
    cout<<endl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    input();
    solve();
}

void input(){
    cin>>s;
}


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

#define ull unsigned long long
#define ll long long


int main(){
    int a, b, c;
    cin >> a  >> b >> c;
    int ans=0;

    while(!(a&1) && !(b&1) && !(c&1)){
        if(a==b && b==c){
            cout << -1;
            return 0;
        }


        int sa = a/2;
        int sb = b/2;
        int sc = c/2;

        a = sb + sc;
        b = sa + sc;
        c = sb + sa;
        ans++;
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 3612
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <map>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

template<class T> inline bool chMax(T& a, T b){if(a < b) {a = b; return true;} return false;}
template<class T> inline bool chMin(T& a, T b){if(a > b) {a = b; return true;} return false;}

int main(){
	int A, B;
	cin >> A >> B;
	cout << (A - 1)*(B - 1) << endl;

    return 0;
}

Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import           Data.Maybe

readInt = fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

isInt :: Real a => a -> Bool
isInt x = x == fromInteger (round (realToFrac x))

times :: Real a => a -> Int
times x = (+1) . length $ takeWhile (not . isInt) $ map (\y -> 360*y / realToFrac x) [1..]

solve :: Int -> Integer -> Int
solve n x = 360 * n `div` fromIntegral x

main = do
  x <- getInt
  print $ solve (times x) x


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    size_t N;
    string s;
    cin >> N >> s;

    char c[]="SW";
    for (int q=0; q<4; ++q) {
        string res;
        res.push_back(c[q%2]);
        res.push_back(c[q/2]);
        for (size_t i=1; i<=N; ++i) {
            if (res.back() == 'S') {
                res.push_back((s[i%N]=='o'? 0:'S'^'W')^res[(i+N-1)%N]);
            } else {
                res.push_back((s[i%N]=='o'? 'S'^'W':0)^res[(i+N-1)%N]);
            }
        }
        if (!(res[0] == res[N] && res[1] == res[N+1]))
            continue;

        for (size_t i=1; i<=N; ++i) {
            if (res[i-1] == res[i+1]) {
                if (s[i] == 'o' && res[i] == 'W') {
                    goto fail;
                } else if (s[i] == 'x' && res[i] == 'S') {
                    goto fail;
                }
            } else {
                if (s[i] == 'o' && res[i] == 'S') {
                    goto fail;
                } else if (s[i] == 'x' && res[i] == 'W') {
                    goto fail;
                }
            }
        }

        return !(cout << res.substr(0, N) << endl);

    fail:
        cerr << res.substr(0, N) << endl;
        continue;
    }

    cout << "-1\n";
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
const int MAX_NUM = 999999999;
void solve() {
	int A, B; cin >> A >> B;
	cout << (A - 1) * (B - 1) << endl;
	return;
}
int main() {
	solve();
	return 0;
}

Measured memory_bytes: 3596
main :: IO()
main = do
  _ <- fmap read getLine :: IO Int
  ss <- fmap (map read . words) getLine :: IO [Int]
  _ <- fmap read getLine :: IO Int
  ts <- fmap (map read . words) getLine :: IO [Int]
  print $ solve ss ts 0

solve :: [Int] -> [Int] -> Int -> Int
solve _ [] i = i
solve ss (t:ts) i = solve ss ts $ if t `elem` ss then i + 1 else i



Measured memory_bytes: 5612
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,
    mut h: [usize;n]
  }
  
  if n <= k {
    println!("0");
    return
  }
  
  h.sort();
  println!("{}", h.iter().by_ref().take(n-k).sum::<usize>());
}

Measured memory_bytes: 6184
N, M = map(int, input().split())
ps = [tuple(input().split()) for _ in range(M)]

idx = list(range(N+1))
wa = [0] * (N + 1)
AC = 0
WA = 0
for i in range(len(ps)):
    if idx[int(ps[i][0])] != "AC":
        if ps[i][1] == "AC":
            AC += 1
            idx[int(ps[i][0])] = "AC"
        else:
            wa[int(ps[i][0])] += 1

for i in range(N+1):
    if idx[i] == "AC":
        WA += wa[i] 

print(str(AC) + " " + str(WA))

Measured memory_bytes: 26104
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<sstream>
#include<utility>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<stack>
#include<functional>
#include<ios>
#include<iomanip>

using namespace std;
typedef unsigned long long ll;
typedef pair<int,int>P;

int main()
{
	int n,mx=0,my=0;
	cin>>n;
	vector<int>p;
	for(int i=0;i<n;i++)
	{
		int a;
		cin>>a;
		p.push_back(a);
		mx=max(mx,a);
	}
	for(int i=0;i<p.size();i++)
	{
		int t=p[i]>mx/2?mx-p[i]:p[i];
		int t2=my>mx/2?mx-my:my;

		if(abs(mx/2-t)<abs(mx/2-t2))
		{
			my=p[i];
		}
	}
	cout<<mx<<" "<<my<<endl;

}

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

class DisjointSet {
public:
    std::vector<int> rank, p; //p: parent
    DisjointSet() {}
    DisjointSet(int size) {
        rank.resize(size, 0);
        p.resize(size, 0);
        for (int i = 0; i < size; i++) makeSet(i);
    }

    void makeSet(int x) {
        p[x] = x;
        rank[x] = 0;
    }

    bool same (int x, int y) {
        return findSet(x) == findSet(y);
    }

    void unite(int x, int y) {
        link(findSet(x), findSet(y));
    }

    void link(int x, int y) {
        if (rank[x] > rank[y]) {
            p[y] = x;
        } else {
            p[x] = y;
            if (rank[x] == rank[y]) rank[y]++;
        }
    }

    //find parent (represtator) of x set
    int findSet(int x) {
        if (x != p[x]) {
            p[x] = findSet(p[x]);
        }
        return p[x];
    }
};



int main()
{
/* input
5 12
0 1 4
0 2 3
1 1 2
1 3 4
1 1 4
1 3 2
0 1 3
1 2 4
1 3 0
0 0 4
1 0 0
1 3 0
* n: 5 q(query): 12
* com: first element 0 or 1 0 is unite, 1 is same
* second and third element two nodes
*/
    int n, a, b, q;
    int qtype;
    std::scanf("%d %d", &n, &q);

    DisjointSet ds = DisjointSet(n);

    for (int i = 0; i < q; i++) {
        std::scanf("%d %d %d", &qtype, &a, &b);
        if (qtype == 0) ds.unite(a, b);
        else if (qtype == 1) {
            if (ds.same(a, b)) std::cout << 1 << std::endl;
            else std::cout << 0 << std::endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3252
import collections
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  a[i]-=i
c=collections.Counter(a)
l=list(c.items())
d={}
for i in range(len(l)):
  d[l[i][0]]=l[i][1]
ct=0
for i in range(n):
  if -a[i]-i*2 in d:
    ct+=d[-a[i]-i*2]
print(ct)

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

namespace otameshi
{
    class Program
    {
        static void Main(string[] args)
        {
            int a,b,c;
            var word = Console.ReadLine().Split(' ');
            a = int.Parse(word[0]);
            b = int.Parse(word[1]);
            c = int.Parse(word[2]);
            if (a + b + c >= 22)
                Console.WriteLine("bust");
            else
                Console.WriteLine("win");
            Console.ReadKey();
            
        }
    }
}


Measured memory_bytes: 11092
import std.stdio,std.string,std.conv;

int main()
{
	string s;
	while((s = readln.chomp).length != 0)
	{
		for(int i=0;i<s.length;i++)
		{
			if(s[i] == '@')
			{
				int count = s[i+1] - '0';
				foreach(j;0..count)
				{
					write(s[i+2]);
				}
				i += 2;
			}
			else
			{
				write(s[i]);
			}
		}
		writeln;

	}
	return 0;
}

Measured memory_bytes: 1028
/*
asnasncsja
asncansca
ascnasncaks
sacnjsc
*/
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <cstring>
#include <string>
#include <bitset>
#include <stack>
#include <set>
#include <map>
#include <list>
using namespace std;
#define e exp(1.0)
typedef long long ll;
#define MAXN 100005
#define mod 998244353
#define INF 0x3f3f3f3f
#define fe(i,st,en) for(i = (st);i <= (en);++i)
#define fne(i,st,en) for(i = (st);i < (en);++i)
#define ri register int
#define db double
int fa[MAXN], ans;
bool vis[MAXN];
int getfa(int x) {
	if (fa[x] == x) return x;
	return fa[x] = getfa(fa[x]);
}
void merge(int x, int y) {
	int fx = getfa(x), fy = getfa(y);
	if (fx != fy) {
		fa[fx] = fy;
	}
}
int main() {
	int n, m, x, y, z;
	cin >> n >> m;
	for (int i = 1; i <= n; ++i) fa[i] = i;
	for (int i = 0; i < m; ++i) {
		scanf("%d%d%d", &x, &y,&z);
		merge(x, y);
	}
	for (int i = 1; i <= n; ++i) {
		int f = getfa(i);
		if (!vis[f]) vis[f] = true, ++ans;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1152
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.readInt();
            int ans = Integer.MAX_VALUE;
            for (int i = 1; i < n; i++) {
                int sum = calc(i) + calc(n - i);
                ans = Math.min(ans, sum);

            }
            out.println(ans);
        }

        int calc(int n) {
            int ans = 0;
            while (n > 0) {
                ans += n % 10;
                n /= 10;
            }
            return ans;
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int readInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return isWhitespace(c);
        }

        public static boolean isWhitespace(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22612
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	long long sum[20];
	int j=0;
	while(true){
		int n;
		cin >> n;
		if(n==0)break;
		int s[n];
		sum[j] = 0;
		for (int i = 0; i < n; ++i)
		{
			cin>>s[i];
			sum[j]+=s[i];
		}
		sort(s,s+n);
		sum[j] -= s[0]+s[n-1];
		sum[j] = sum[j]/(n-2);
		j++;
	}
	for (int i = 0; i < j; ++i)
	{
		cout << sum[i] <<endl;
	}
	return 0;
}

Measured memory_bytes: 3148
import sys

def main():
    N = int(input())
    t, x, y = 0, 0, 0

    for _ in range(N):
        next_t, next_x, next_y = [int(__) for __ in input().split()]

        delta_t = next_t - t
        distance = abs(next_x - x) + abs(next_y - y)

        if distance > delta_t:
            print("No")
            sys.exit()

        if (delta_t - distance) % 2 != 0:
            print("No")
            sys.exit()

        t, x, y = next_t, next_x, next_y

    print("Yes")

main()


Measured memory_bytes: 3064
#include<iostream>

#define rep(i, n) for(int i = 0; i < n; i++)
using ll = long long;

using namespace std;

int main()
{
    ll n, a;   cin >> n;

    int m = 0;
    for(ll i = 1; i * i <= n; i++){
        if(n % i == 0){
            a = i;
        }
    }

    cout << a + (n / a) - 2 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
string S;long long cnt=0;
int main(){
	cin>>S;
	for(int i=0;i<S.size();i++){
		for(int j=i;j<S.size();j++){
			long long num=stoll(S.substr(i,j-i+1));
			long long K=1;
			if(i==0)K*=1;else K*=(1<<(i-1));
			long long L=S.size()-j-1;
			if(L==0)K*=1;else K*=(1<<(L-1));
			cnt+=num*K;
		}
	}
	cout<<cnt<<endl;
	return 0;
}

Measured memory_bytes: 256
'''
研究室PCでの解答
'''
import math
#import numpy as np
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7

def main():
    n,m = map(int,ipt().split())
    pts = [[] for i in range(8)]
    for i in range(n):
        ni = [int(i) for i in ipt().split()]
        for j in range(8):
            nm = 0
            for k in range(3):
                if (j>>k)&1:
                    nm += ni[k]
                else:
                    nm -= ni[k]
            pts[j].append(nm)

    ma = 0
    for i in range(8):
        pts[i].sort(reverse=True)
        sm = sum(pts[i][:m:])
        if ma < sm:
            ma = sm
    print(ma)
    return None

if __name__ == '__main__':
    main()


Measured memory_bytes: 10096
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayDeque;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] inputs = br.readLine().split(" ");
		int N = Integer.parseInt(inputs[0]);

		int rival[][] = new int[N + 1][N]; // pのn番目の対戦相手 r = tb[p][n]  (1-origin 
		int mday[][] = new int[N + 1][N];  // pのn番目の試合日   d = tb[p][n]  (1-origin 

		// p:player  r:rival
		for ( int p = 1; p <= N; p++ ) {
			inputs = br.readLine().split(" ");
			for ( int n = 1; n <= N - 1; n++ ) {
				int r = Integer.parseInt(inputs[n - 1]);
				rival[p][n] = r;
			}
		}

		int match = N * (N - 1) / 2;
		int days = 0;
		ArrayDeque<Integer> q = new ArrayDeque<Integer>();
		int[] prog = new int[N + 1];				   // p が何試合目まで進んだか =  prog[p]
		// キューの初期化
		for ( int p = 1; p <= N; p++ ) {
			int r = rival[p][1];
			if ( p == rival[r][1] && mday[p][1] * mday[r][1] == 0 ) {

				mday[p][1] = mday[r][1] = 1;
				prog[p] = prog[r] = 1;

				q.addLast(p);
				q.addLast(r);
			}
		}

//		for ( Integer is : q ) {
//			System.out.println(is);
//		}

		while ( 0 < q.size() ) {
			int p = q.pollFirst();
			int pn = prog[p] + 1;
			if ( pn >= N ) continue;
			int r = rival[p][pn];
			int rn = prog[r] + 1;
			if ( rn >= N ) continue;
			// System.out.println("check p:" + p + " pn:" + pn + " r:" + r + " rn:" + rn);

			// 試合が成立したら試合日テーブルに記入
			if ( p == rival[r][rn] ) {
				// System.out.println(p + " vs " + r);

				mday[p][pn] = mday[r][rn] = Math.max(mday[p][pn - 1] + 1, mday[r][rn - 1] + 1);

				prog[p]++;
				q.addLast(p);

				prog[r]++;
				q.addLast(r);

			}
		}

//		for ( int[] is : mday ) {
//			for ( int i : is ) {
//				System.out.print(i + " ");
//			}
//			System.out.println();
//		}

		int lastMatchDay = 0;
		for ( int p = 1; p <= N; p++ ) {
			int d = mday[p][N - 1];
			if ( d == 0 ) {
				lastMatchDay = -1;
				break;
			} else {
				lastMatchDay = Math.max(lastMatchDay, d);
			}
		}

		System.out.println(lastMatchDay);
		br.close();
	}
}


Measured memory_bytes: 66972
#include<iostream>
#include<algorithm>
using namespace std;
#define MAX 2000000
#define INFTY (1<<30)

int H, A[MAX+1];

void maxHeapify(int i){
	int l, r, largest;
	l=2*i;
	r=2*i+1;

	if(l<=H && A[l]>A[i])
		largest=l;
	else
		largest=i;
	if(r<=H && A[r]>A[largest])
		largest=r;
	if(largest!=i){
		swap(A[i], A[largest]);
		maxHeapify(largest);
	}
}

int extract(){
	int maxv;
	if(H<1)	return -INFTY;
	maxv=A[1];
	A[1]=A[H--];
	maxHeapify(1);
	return maxv;
}


void incresingKey(int i, int key){
	if(key<A[i])	return ;
	A[i]=key;
	while(i>1 && A[i/2]<A[i]){
		swap(A[i], A[i/2]);
		i=i/2;
	}
}


void insert(int key){
	H++;
	A[H]=-INFTY;
	incresingKey(H, key);
}

int main(){
	int key;
	char com[10];
	while(1){
		cin>>com;
		if(com[0]=='e' && com[1]=='n')
			break;
		if(com[0]=='i'){
			cin>>key;
			insert(key);
		}
		else{
			cout<<extract()<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 6920
#include "bits/stdc++.h"
using namespace std;
using     ll=long long;
using    vll=vector<   ll>;
using   vvll=vector<  vll>;
using  vvvll=vector< vvll>;
using vvvvll=vector<vvvll>;
constexpr ll INF = 1LL << 60;
struct Fast{ //cin,cout高速化のおまじない＋桁数指定
	Fast(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(std::numeric_limits<double>::max_digits10); }
} fast;
#define rep(i, S, E)  for (ll i = (S); i <= (E); i++)
#define dep(i, E, S)  for (ll i = (E); i >= (S); i--)
#define each(e, v) for (auto&& e : v)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; }return false; }
template<class T> inline T MaxE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmax(m,v[i]); return m; }
template<class T> inline T MinE(vector<T>&v,ll S,ll E){ T m=v[S]; rep(i,S,E)chmin(m,v[i]); return m; }
template<class T> inline T MaxE(vector<T> &v) { return MaxE(v,0,(ll)v.size()-1); }
template<class T> inline T MinE(vector<T> &v) { return MinE(v,0,(ll)v.size()-1); }
template<class T> inline T Sum(vector<T> &v,ll S,ll E){ T s=T(); rep(i,S,E)s+=v[i]; return s; }
template<class T> inline T Sum(vector<T> &v) { return Sum(v,0,v.size()-1); }
template<class T> inline ll sz(T &v){ return (ll)v.size(); }
template<class T> inline T POW(T a, ll n){ T r=1; for (; n>0; n>>=1, a*=a){ if (n&1)r*=a; } return r; }
inline ll POW(int a, ll n){ return POW((ll)a, n); }
inline ll CEIL(ll a, ll b){ return (a+b-1)/b; }



void solve()
{
	ll n,A,B;  cin >> n >> A >> B;
	string s;  cin >> s;

	ll a=0;
	ll b=0;
	rep(i,0,n-1){
		if (s[i]=='a' and a+b<A+B){
			a++;
			cout << "Yes" << '\n';
		}
		else if (s[i]=='b' and a+b<A+B and b<B){
			b++;
			cout << "Yes" << '\n';
		}
		else{
			cout << "No" << '\n';
		}
	}
}


int main(){
#if 1
	solve();
#else
	ll t;  cin >> t;
	rep(i, 0, t-1){
		solve();
	}
#endif
	return 0;
}


Measured memory_bytes: 3688
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int n, c[10][1000], f[10][1000];
int main() {
    cin >> n;
    for(int i = 1; i <= 2; ++i) {
        for(int j = 1; j <= n; ++j) {
            cin >> c[i][j];
        }
    }
    for(int i = 1; i <= 2; ++i) {
        for(int j = 1; j <= n; ++j) {
            f[i][j] = max(f[i - 1][j], f[i][j - 1]) + c[i][j];
        }
    }
    cout << f[2][n] << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import deque
N = int(input())
A = deque(sorted([int(input()) for _ in range(N)]))
B = deque([])
B.append(A.popleft())
cnt = 0
while A:
    a0 = A[0]
    a1 = A[-1]
    b0 = B[0]
    b1 = B[-1]
    c00 = abs(a0-b0)
    c01 = abs(a0-b1)
    c10 = abs(a1-b0)
    c11 = abs(a1-b1)
    cmax = max(c00,c01,c10,c11)
    if cmax == c00:
        B.appendleft(A.popleft())
    elif cmax == c01:
        B.append(A.popleft())
    elif cmax == c10:
        B.appendleft(A.pop())
    else:
        B.append(A.pop())
    cnt += cmax
print(cnt)

Measured memory_bytes: 60248
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) (x=min(x,y))
#define chmax(x,y) (x=max(x,y))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}

int main(){
	string s;
  cin>>s;
  int cnt[26] = {};
  rep(i, s.size()) cnt[s[i]-'a']++;
  rep(i, 26) if(cnt[i]%2){ cout<<"No"<<endl; return 0;}
  cout<<"Yes"<<endl;
	return 0;
}


Measured memory_bytes: 256
using System;using System.Linq;
class A{
    static void Main(){
        while(true){
            int n=int.Parse(Console.ReadLine());
            if(n==0){break;}
        int []a=new int[n];
        for(int i=0;i<n;i++){
            a[i]=Console.ReadLine().Split().Select(int.Parse).ToArray().Sum();
            
        }
        Array.Sort(a);
        Console.WriteLine(a[a.Length-1]+" "+a[0]);
            
        }
        
    }
    
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0;i < N;i++) {
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int Max = A.at(0);
  reverse(A.begin(),A.end());
  int Min = A.at(0);
  cout << Min - Max << endl;
}
  

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define MT make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define RT return
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vll = vector<ll>;

template<class T>
vector<int> kmp(const T &sentence, const T &word) {
    int lenS = (int)sentence.size(), lenW = (int)word.size(), idx = -1, head = 0;
    vector<int> table(lenW + 1, -1), res;
    for (int i = 0; i < lenW; ++i) {
        while (idx >= 0 && word[i] != word[idx])idx = table[idx];
        table[i + 1] = ++idx;
    }

    idx = 0;
    while (head + idx < lenS) {
        if (word[idx] == sentence[head + idx]) {
            ++idx;
            if (idx == lenW) {
                res.push_back(head);
                head = head + idx - table[idx];
                idx = table[idx];
            }
        } else {
            head = head + idx - table[idx];
            if (idx > 0)idx = table[idx];
        }
    }
    return res;
}

void solve() {
    int N;
    cin >> N;
    vi A(N), B(N), AA(N), BB(2 * N);
    rep(i, N) {
        cin >> A[i];
    }
    rep(i, N) {
        cin >> B[i];
    }
    rep(i, N) {
        AA[i] = A[i] ^ A[(i + 1) % N];
        BB[i] = B[i] ^ B[(i + 1) % N];
        BB[i + N] = BB[i];
    }
    BB.pop_back();

    vi found = kmp(BB, AA);
    each(i, found) {
        i = (i == 0 ? i : N - i);
    }
    sort(all(found));

    each(i, found) {
        cout << i << ' ' << (A[i] ^ B[0]) << endl;
    }
}

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

Measured memory_bytes: 8292
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(){
  string s;
  long int k;
  cin >> s >> k;

  int length = s.size();


    bool flag=false;
  for (int i = 0; i < length; ++i) {
    if(k==1){
      cout << s[i]<<endl;
      flag = true;
      break;
    }
    k--;
    if(s[i]!='1'){
      cout << s[i]<<endl;
      break;
    }
  }



  
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <string>
#include <stdexcept>

struct ParseError: public std::logic_error {
  ParseError(const std::string &what_arg): std::logic_error(what_arg) {}
};

void apply(int &lhs, char op, int rhs) {
  switch (op) {
  case '+':
    lhs += rhs;
    break;
  case '-':
    lhs -= rhs;
    break;
  case '*':
    lhs *= rhs;
    break;
  }
  if (!(0 <= lhs && lhs < 1024))
    throw std::out_of_range("value must be in [0, 1023]");
}

int parse_bin(const std::string &s, size_t &i) {
  int res=0;
  while (i < s.length() && isdigit(s[i])) {
    res = res*2+s[i]-'0';
    ++i;
    if (res >= 1024)
      throw std::out_of_range("value must be in [0, 1023]");
  }
  assert(res < 1024);
  return res;
}

std::pair<int, int> parse(
    const std::string &s, size_t &i, int &balance,
    const std::vector<std::string> &ops={"+-", "*", ""}, size_t prec=0) {

  // <calculates, num of operators>
  if (prec == ops.size()) {
    if (s.at(i) == '(') {
      ++i;
      ++balance;
      if (s.at(i) == ')')
        throw ParseError("empty parentheses");

      std::pair<int, int> res=parse(s, i, balance, ops, 0);
      if (s.at(i) != ')')
        throw ParseError("mismatch parentheses");

      ++i;
      --balance;
      if (balance < 0)
        throw ParseError("mismatch parentheses");
      if (res.second < 1)
        throw ParseError("singleton parentheses");
      return {res.first, 0};
    }
    if (isdigit(s.at(i))) {
      return {parse_bin(s, i), 0};
    }
    throw ParseError("unexpected token");
  }

  std::pair<int, int> lhs=parse(s, i, balance, ops, prec+1);
  while (i < s.length()) {
    char op=s.at(i);
    if (op == ')')
      break;
    if (!(op == '+' || op == '-' || op == '*'))
      throw ParseError("unexpected token");
    if (!std::count(ops[prec].begin(), ops[prec].end(), op))
      break;

    std::pair<int, int> rhs=parse(s, ++i, balance, ops, prec+1);
    apply(lhs.first, op, rhs.first);
    lhs.second += rhs.second+1;
  }
  return lhs;
}

int rec(std::string &s, std::vector<size_t> &dot) {
  if (dot.empty()) {
    try {
      size_t i=0;
      int b=0;
      int res=parse(s, i, b).first;
      if (i != s.length()) throw ParseError("garbage found");
      if (b < 0) throw ParseError("mismatch parentheses");

      return res;
    } catch (const std::logic_error &x) {
      // fprintf(stderr, "Parse failed: %s\n", x.what());
      return -1;
    }
  }

  size_t x=dot.back();
  dot.pop_back();
  int res=-1;
  for (char ch: {'0', '1', '+', '-', '*', '(', ')'}) {
    s[x] = ch;
    res = std::max(res, rec(s, dot));
  }
  s[x] = '.';
  dot.push_back(x);
  return res;
}

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s=buf;
  std::vector<size_t> dot;
  for (size_t i=0; i<s.length(); ++i) {
    if (s[i] == '.')
      dot.push_back(i);
  }

  printf("%d\n", rec(s, dot));
}



Measured memory_bytes: 3148
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;
import static java.lang.Long.parseLong;

/**
 * Carpenters' Language
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		String[] words;

		int q = parseInt(br.readLine());

		long lp = 0, rp = 0;

		for (int i = 0; i < q; i++) {

			words = br.readLine().split(" ");

			long n;
			char c;
			c = words[1].charAt(0);
			n = parseLong(words[2]);

			if (c == '(') lp += n;
			else rp += n;

			if (lp == rp) System.out.println("Yes");
			else System.out.println("No");

		}
	}
}

Measured memory_bytes: 36984
#include <bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i=0;i<n;i++)
#define ALL(x) (x).begin(),(x).end()
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

void trace(int A[],int N){
    REP(i,N){
        if(i>0)printf(" ");
        printf("%d",A[i]);
    }
    printf("\n");
}


int main(){
    int A,B;
    string op;
    cin >> A >> op >> B;
    if(op == "+")cout << A+B << endl;
    else cout << A-B <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define sz(x) (int)(x).size()
using namespace std;

ll binpow(ll a, ll b) {
    if (b == 0)
    {
        return 1;
    }
    ll res = binpow(a, b / 2);
    res*=res;
    if (b % 2)
    {
        return res * a;
    }
    return res;
}

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

string to_upper(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A';
    return a;
}
 
string to_lower(string a)
{
    for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A';
    return a;
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll a;
    string b;
    cin>>a>>b;
    a*=((b[0]-'0')*100+(b[2]-'0')*10+(b[3]-'0'));
    a/=100;
    cout<<a;
    return 0;
}

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

int func(int x){
    if(x<10) return x;
    return x%10+func(x/10);
  }

int main() {
  int N; cin>>N;
  int S = func(N);
  if(N%S==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

int main() {
  int W,H,x,y;
  cin>>W>>H>>x>>y;
  
  int ans=0;
  
  double b=(double)W*(double)H/2;
  if((double)W/2==x&&(double)H/2==y){
    ans++;  
  }
  cout<< fixed<< setprecision(10);
  cout <<b<<" "<<ans<<endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
const int INF = (int)1e9;

using ll = long long;

int a[MAXN];
bool b[MAXN];


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

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

    sort(a, a + n);
    int ans1 = 0, ans2 = 0;

    for (int i = 0; i < n; ++i) {
        if (a[i] < 400) {
            if (!b[0]) {
                ++ans1;
                ++ans2;
                b[0] = true;
            }
        } else if (a[i] < 800) {
            if (!b[1]) {
                ++ans1;
                ++ans2;
                b[1] = true;
            }
        } else if (a[i] < 1200) {
            if (!b[2]) {
                ++ans1;
                ++ans2;
                b[2] = true;
            }
        } else if (a[i] < 1600) {
            if (!b[3]) {
                ++ans1;
                ++ans2;
                b[3] = true;
            }
        } else if (a[i] < 2000) {
            if (!b[4]) {
                ++ans1;
                ++ans2;
                b[4] = true;
            }
        } else if (a[i] < 2400) {
            if (!b[5]) {
                ++ans1;
                ++ans2;
                b[5] = true;
            }
        } else if (a[i] < 2800) {
            if (!b[6]) {
                ++ans1;
                ++ans2;
                b[6] = true;
            }
        } else if (a[i] < 3200) {
            if (!b[7]) {
                ++ans1;
                ++ans2;
                b[7] = true;
            }
        } else if (a[i] >= 3200) {
            ++ans2;
        }
    }
    if (ans1 == 0 && n > 0) {
        ++ans1;
    }
    cout << ans1 << " " << ans2;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
using namespace std;


int main() {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    int distAC = std::abs(a - c);
    if(distAC <= d) {
        printf("Yes\n");
        return 0;
    }

    int distAB = std::abs(a - b);
    int distBC = std::abs(b - c);
    if(distAB <= d && distBC <= d) {
        printf("Yes\n");
        return 0;
    }

    printf("No\n");
    return 0;
}


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

using namespace std;
typedef long long ll;
const int N = 105;

ll n, w, Ws[N], Vs[N];
ll dp[N][100005];

ll solve(ll i, ll cw) {
    if(i == n) return 0;
    ll& res = dp[i][cw];
    if(~res) return res;
    res = solve(i+1, cw);
    if(cw + Ws[i] <= w)
        res = max(res, solve(i+1, cw + Ws[i]) + Vs[i]);
    return res;
}

int main() {
    memset(dp, -1, sizeof(dp));
    cin >> n >> w;
    for(int i=0; i<n; i++)
        cin >> Ws[i] >> Vs[i];
    cout << solve(0, 0) << "\n";
    return 0;
}


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

class Main{
    public static void main(String[] args){
	BufferedReader sc=new BufferedReader(new InputStreamReader(System.in));
	try {
	    String st;
	    LinkedList<String> lot = new LinkedList<String>();
	    while((st=sc.readLine())!=null){
		if(st.equals("0"))
		    System.out.println(lot.pop());
		else
		    lot.push(st);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 16852
#include <iostream> 
#include <stack>
using namespace std;
 
int main(){
    stack<int> train;
    int n;
    while(cin>>n){
        if(n==0){
            cout<<train.top()<<endl;
            train.pop();
        }else{
            train.push(n);
        }
         
    }
    return 0;
}


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

using namespace std;
int main(){
    int n;
    cin>>n;
    double a[n],b[n];
    double t,c,x,m=1000;
    cin>>t>>c;
    for(int i=0;i<n;i++)
        {cin>>a[i];
        b[i]=t-(0.006*a[i]);
        if(c>b[i]) b[i]=c-b[i];
        else b[i]=b[i]-c;
        if(b[i]<m){
            m=b[i];
            x=i;
        }
        }
    cout<<x+1<<endl;
return 0;
}



Measured memory_bytes: 256
#include<stdio.h>

int main(void){
  int N,Q;
  long long int K,tmp;
  scanf("%d %lld %d",&N,&K,&Q);
  long long int A[N];
  for(int i=0;i<N;i++) A[i] = K-Q;
  for(int i=0;i<Q;i++){
    scanf("%lld",&tmp);
    A[tmp-1]++;
  }
  for(int i=0;i<N;i++){
    if(A[i]>0) printf("Yes\n");
    else printf("No\n");
  }
  
  return 0;
}

Measured memory_bytes: 1280
// AtCoder template
// sabaより胡蝶しのぶさんの方が可愛いのではないか？
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)

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

    ll x,y; cin >> x >> y;
    ll ans = 1LL;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans-1 << endl;
}

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

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

    long long a;
    unordered_map<long long, int> ump;
    for (int i=0; i<n; i++){
        cin >> a;
        ump[a]++;
    }

    int count = 0;
    for(auto p: ump){
//        cout << p.second << ' ';
        count += p.second % 2;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 4388
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>


#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16

// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>


// using namespace __gnu_pbds;
using namespace std;

using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;

int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}

vi a(200005);

void solve()
{
    int t,n,m,i,k,r,l,u,v,w,j,s,sum=0,pos,flag=0,count=0;
    string S,T,U; 
    // int a,b;
    char c;
    cin>>n>>k;
    vi a(n);
    rep(i,0,n) cin>>a[i];
    sortA(a);
    rep(i,0,k) sum+=a[i];
    cout<<sum;
}


signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}


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

int N;
int e[101][101][101];

void dpf(int a, int b, int c, int d[]) {
  if (e[a][b][c] == 1) {
    return;
  }
  int tmp = a*a + b*b + c*c + a*b + b*c + c*a;
  if (tmp <= N) {
    ++d[tmp];
    e[a][b][c] = 1;
    // printf("%d %d %d\n", a, b, c);
    dpf(a+1, b, c, d);
    dpf(a, b+1, c, d);
    dpf(a, b, c+1, d);
  }
  return;
}

int main () {
  for (int i = 0; i < 101; ++i) {
    for (int j = 0; j < 101; ++j) {
      for (int k = 0; k < 101; ++k) {
        e[i][j][k] = 0;
      }
    }
  }
  cin >> N;
  int ans[2*N] = {0};
  dpf(1, 1, 1, ans);
  for (int i = 1; i <= N; ++i) {
    printf("%d\n", ans[i]);
  }
  return 0;
}

Measured memory_bytes: 7872
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
int main(){
  map<string,int> x;
  map<int,string> y;
  vector<int> pa(10000001,0);

  int n,f,fl;
  string a;
  cin >> n >> f;
  //in

  for(int i=0;i<n;i++){
    int m;
    cin >> m;
    vector<string>st(m);
    for(int j=0;j<m;j++){
      cin >>a;
      st[j].clear();
      st[j]=a;
      fl=0;
      if(x[a]==0){
	//if(x.size()+1==1000)x[a]=0;
	x[a]=x.size()+1;
	y.insert(map<int,string>::value_type(x[a],a));
      }
    }
    for(int l=0;l<m;l++){
      for(int k=l+1;k<m;k++){
	if(st[l]==" "||st[k]==" ")continue;
	//	cout<< st[l]<<" "<<st[k]<<endl;
	if(st[l]>st[k])pa[x[st[k]]*2000+x[st[l]]]++;
	else pa[x[st[l]]*2000+x[st[k]]]++;
      }
    }
  }    
  
  //out
  vector<string>ans;
  int c=0;
  for(int i=2000;i<pa.size();i++){
    if(pa[i]>=f){
      c++;
      ans.push_back( y[i/2000]+" "+y[i%2000]);
    }
    
    //cout <<y[i]<<endl;
    /* if(pa[i]!=0)
       cout << pa[i]<< " "<<endl;*/
  }
  cout << c<<endl;
  sort(ans.begin(),ans.end());
  for(int i=0;i<c;i++){
    cout << ans[i]<< endl;
  }
  return 0;
}
  

Measured memory_bytes: 42444
S = input()
N = len(S) + 1


lst = [0] * N

for i in range(N-1):
    if S[i] == "<":
        lst[i+1] = max(lst[i+1], lst[i] + 1)

for i in range(N-2,-1,-1):
    if S[i] == ">":
        lst[i] = max(lst[i], lst[i+1] + 1)


print(sum(lst))

Measured memory_bytes: 23336
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = Long.parseLong(sc.next());
        String s = sc.next();
        long b = Long.parseLong(sc.next());
        if (s.equals("+")) {
            System.out.println(a + b);
        } else {
            System.out.println(a - b);
        }
    }
}

Measured memory_bytes: 23124