akhauriyash/Code-Regression huggingface dataset:
# coding: utf-8
# Here your code !

def parseData(line):
    dataList = line.split(" ")
    return int(dataList[0]), int(dataList[1]) * int(dataList[2])

dataCount = int(input())
while dataCount > 0:
    employeeSalesList = []
    for _ in range(dataCount):
        employeeId, price = parseData(input())
        found = False
        for data in employeeSalesList:
            if data[0] == employeeId:
                data[1] += price
                found = True
        if not found:
            employeeSalesList.append([employeeId, price])

    answerList = [data[0] for data in employeeSalesList if data[1] >= 1000000]
    if answerList:
        print("\n".join(map(str, answerList)))
    else:
        print("NA")

    dataCount = int(input())

Measured memory_bytes: 7876
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    /* f(x) = x*x */
    int d;
    int i;
    int h;
    int sum;

    void run(){
	while(sc.hasNext()){
	    sum = 0;
	    d = sc.nextInt();
	    i = d;
	    h = i*i;
	    while(i<600){
		sum += h*d;
		i = i+d;
		h = i*i;
	    }
	    System.out.println(sum);
	}
    }
}

Measured memory_bytes: 17176
use std::io;

fn read_line()-> String {
    let mut s = String::new();
    let _ = io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}


fn main () {
	let n = read_line().split_whitespace().map(|e|e.parse().unwrap())
	.collect::<Vec<i32>>();
	let r = n[0] + n[1];
	if r > 23 {
		println!("{}",r%24);
	}else{
		println!("{}",r);
	}
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  string s;
  cin >> s;
  
  ll N;
  N = s.size();
  
  vector<int> indexd;
  indexd.push_back(-1);
  
  {
    string nox;
    
    rep(i, N) {
      if(s[i] != 'x') {
        nox.push_back(s[i]);
        indexd.push_back(i);
      }
    }
    
    bool ci = true;
    rep(i, nox.size() / 2) {
      if(nox[i] != nox[nox.size() - i - 1]) {
        ci = false;
        break;
      }
    }
    
    if(!ci) {
      fin(-1);
      return 0;
    }
  }
  
  //next
  indexd.push_back(N);
  int l = indexd.size() / 2 - 1;
  int r = (indexd.size() + 1) / 2;
  
  int ct = 0;
  if(indexd.size() % 2 == 1) {
    int c = indexd[indexd.size() / 2];
    ct += abs((c - indexd.at(l)) - (indexd[r] - c));
  }
  
  while(l > 0) {
    ct += abs((indexd[l] - indexd[l-1]) - (indexd[r+1] - indexd[r]));
    l --;
    r ++;
  }
  
  fin(ct);
}

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

using namespace std;

int expressionTuples(int n) {
    int count = 0;
    for (int a = 1; a < n; a++) {
        for (int b = 1;; b++) {
            int c = n - (a * b);
            // printf("a: %d, b: %d, c: %d", a, b, c);
            if (c > 0) {
                // cout << " -----> Pass: " << endl;
                ++count;
            } else
                break;
        }
    }
    return count;
}

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

    cout << expressionTuples(n) << endl;
}


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

class Program {
    static Scanner cin = new Scanner();
    static long N = cin.Long();
    static List<long> list = new List<long>();
    static void Main() {
        foreach (var x in new long[] { 3, 5, 7 }) {
            hoge(x);
        }
        Console.WriteLine(list.Count(x => x.ToString().ToCharArray().Distinct().Count() == 3));
        Console.ReadLine();
    }

    static void hoge(long n) {
        if(n <= N) {
            list.Add(n);
            hoge(10 * n + 3);
            hoge(10 * n + 5);
            hoge(10 * n + 7);
        }
    }
}

class Scanner //標準入力
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Long() + add;
        }
        return Array;
    }

    public double Double()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = Double() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 18000
#include <bits/stdc++.h>
using namespace std;
int a[100+1]={0};
int main()
{
	int n,s=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int x;
		cin>>x;
		a[x]=1;
	}
	for(int i=1;i<=100;i++)
	{
		if(a[i]==1)
		s++;
	}
	cout<<s<<endl;
	return 0;
}

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



int main(){
	
	int A,B,K;
	cin>>A>>B>>K;
	for(int i=100;i>=0;i--){
		if(A%i==0&&B%i==0)K--;
		if(K==0){
			cout<<i<<endl;
			return 0;
		}
	}
	
	
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	string S;
	int w;
	cin >>S >>w;
	int i=0;
	while(i<S.size()) {
		cout <<S.at(i);
		i +=w;
	}
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
#define ll long long
const ll MOD = 1000000007;
//const ll MOD = 998244353;

int main() {
	ll N, B, A;
	cin >> N >> A >> B;
	vector<ll> H(N);
	for (int i = 0;i < N;i++) {
		cin >> H[i];
	}
	sort(all(H));
	
	ll ng = 0, ok = 1000000000, mid, cnt;
	vector<int> S(N);
	while (ng + 1 != ok) {
		mid = (ok + ng) / 2;
		cnt = 0;
		for (int i = 0;i < N;i++) {
			S[i] = max(0LL, H[i] - mid * B);
			if (S[i])cnt += (S[i] - 1) / (A - B) + 1;
		}
		if (cnt <= mid) {
			ok = mid;
		}
		else {
			ng = mid;
		}
	}
	cout << ok << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
struct R{
    string s;
    int score;
    int no;
};
bool cmp(const R &a, const R &b){
    if(a.s < b.s) return true;
    else if(a.s > b.s) return false;
    else {
        if(a.score > b.score) return true;
        else return false;
    }
}
int main(void) {
    int n; cin >> n;
    vector<R> r(n);
    rep(i, n) cin >> r[i].s >> r[i].score;
    rep(i, n) r[i].no = i + 1;
    sort(r.begin(),r.end(),cmp);
    rep(i, n) cout << r[i].no << endl;
}


Measured memory_bytes: 256
///////////////////////////////////////////////////////////
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
const int Size=1<<16;
char buffer[Size],*head,*tail;
inline char Getchar() {
    if(head==tail) {
        int l=fread(buffer,1,Size,stdin);
        tail=(head=buffer)+l;
    }
    if(head==tail) return -1;
    return *head++;
}
typedef long long ll;
inline ll read() {
    ll x=0,f=1;char c=Getchar();
    for(;!isdigit(c);c=Getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=Getchar()) x=x*10+c-'0';
    return x*f;
}
const int maxn=100010;
const ll inf=1ll<<61;
const int mod=1000000007;
int n;
ll A,B,S[maxn],tmp[maxn];
struct Segment {
	int setv[maxn<<2],sumv[maxn<<2];
	Segment() {memset(setv,0,sizeof(setv));}
	void update(int o,int l,int r,int p,int v) {
		if(l==r) setv[o]=0,(sumv[o]+=v)%=mod;
		else {
			int mid=l+r>>1,lc=o<<1,rc=lc|1;
			if(setv[o]) {
				sumv[lc]=sumv[rc]=0;
				setv[lc]=setv[rc]=1;
				setv[o]=0;
			}
			if(p<=mid) update(lc,l,mid,p,v);
			else update(rc,mid+1,r,p,v);
			sumv[o]=(sumv[lc]+sumv[rc])%mod;
		}
	}
	int query(int o,int l,int r,int ql,int qr) {
		if(setv[o]) return 0;
		if(ql<=l&&r<=qr) return sumv[o];
		int mid=l+r>>1,lc=o<<1,rc=lc|1,res=0;
		if(ql<=mid) (res+=query(lc,l,mid,ql,qr))%=mod;
		if(qr>mid) (res+=query(rc,mid+1,r,ql,qr))%=mod;
		return res;
	}
	void clear() {setv[1]=1;sumv[1]=0;}
}F,G;
int find(ll val) {return upper_bound(tmp+1,tmp+n+2,val)-tmp-2;}
int main() {
	n=read();A=read();B=read();
	S[0]=-inf;rep(i,1,n) S[i]=read();
	rep(i,0,n) tmp[i+1]=S[i];
	F.update(1,0,n,0,1);G.update(1,0,n,0,1);
	rep(i,1,n-1) {
		int v1=F.query(1,0,n,0,find(S[i+1]-B)),v2=G.query(1,0,n,0,find(S[i+1]-A));
		if(S[i+1]-S[i]<A) F.clear();
		if(S[i+1]-S[i]<B) G.clear();
		G.update(1,0,n,i,v1);F.update(1,0,n,i,v2);
	}
	int ans=F.query(1,0,n,0,n-1)+G.query(1,0,n,0,n-1);
	printf("%d\n",ans%mod);
	return 0;
}


Measured memory_bytes: 7936
def main():
    num = int(input())
    con = 10**9 + 7
    a, b, c = 1, 1, 2
    for i in range(num):
        a *= 10
        a %= con
        b *= 8
        b %= con
        c *= 9
        c %= con
    if(a+b-c < 0):
        print(a+b-c+con)
        return 0
    print(a+b-c)


if __name__ == '__main__':
    main()


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

const int N = 1e5 + 10;
const int inf = INT_MAX;

#define ll long long
#define FOR(i,a,b) for(int i = a;i <= b;i++)
#define _FOR(i,a,b) for(int i = a;i >= b;i--)

template<typename T> void read(T &x)
{
    x = 0;int f = 1;
    char c = getchar();
    for(;!isdigit(c);c = getchar()) if(c == '-') f = -1;
    for(;isdigit(c);c = getchar()) x = x * 10 + c - '0';
    x *= f;
}

int n;
string s;
int main()
{
    //freopen(".in","r",stdin);
    //freopen(".out","w",stdout);
	cin >> n;
	cin >> s;
	int ans = 0;
	FOR(i,0,s.size() - 1)
		if(i == 0 || s[i] != s[i - 1]) ans++;
	cout << ans << endl;
    return 0;
}




Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> D;
    D.push_back(a);
    D.push_back(b);
    D.push_back(c);
    sort(D.begin(), D.end());

    cout << D[0] + D[1];

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<list>
using namespace std;
static const int MAX = 100000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int s){
    queue<int> q;
    q.push(s);
    V[s] = true;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        out.push_back(u);
        for(int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            indeg[v]--;
            if(indeg[v] == 0 && !V[v]){
                V[v] = true;
                q.push(v);
            }
        }
    }
}

void tsort(){
    for(int i = 0; i < N; i++){
        indeg[i] = 0;
    }
    
    for(int u = 0; u < N; u++){
        for(int i = 0; i < G[u].size(); i++){
            int v = G[u][i];
            indeg[v]++;
        }
    }
    
    for(int u = 0; u < N; u++){
        if(indeg[u] == 0 && !V[u]) bfs(u);
    }
    
    for(list<int>::iterator it = out.begin(); it != out.end(); it++){
        cout << *it << endl;
    }
}

int main(){
    int s, t, M;
    
    cin >> N >> M;
    
    for(int i = 0; i < N; i++) V[i] = false;
    
    for(int i = 0; i < M; i++){
        cin >> s >> t;
        G[s].push_back(t);
    }
    
    tsort();
    
    return 0;
}


Measured memory_bytes: 6124
#include <stdio.h>
  
int main(void){
  
  int a,b;
  
  scanf("%d %d",&a,&b);
  if(a < b){
    printf("a < b\n");
  }else if(a > b){
    printf("a > b\n");
  }else{
    printf("a == b\n");
  }
  return 0;
}

Measured memory_bytes: 580
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
func exponentiate(_ lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
//extension Array where Element == String {
//    func joined(separator separator: String) -> String {
//        return self.joinWithSeparator(separator)
//    }
//}
extension Array where Element: Comparable {
    func max() -> Element {
        return self.maxElement()!
    }
    func min() -> Element {
        return self.minElement()!
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
func exponentiate(lhs: Int, _ rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let input = readIntSplit(by: " ")
let (N, M) = (input[0], input[1])
let A = (0..<N).map{_ in readLine()!.toArray()}
let B = (0..<M).map{_ in readLine()!.toArray()}
var ans = "No"
loop1: for i in 0...N-M {
    for j in 0...N-M {
        var flag = true
        loop2: for y in 0..<M {
            for x in 0..<M {
                if B[y][x] != A[y+i][x+j] {
                    flag = false
                    break loop2
                }
            }
        }
        if flag {
            ans = "Yes"
            break loop1
        }
    }
}
print(ans)


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

using namespace std;

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

  int x;
  cin >> x;

  int ans = 1;
  if ((x / 100) * 5 < (x % 100)) {
    ans = 0;
  }

  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i < b; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define debug(x) cerr <<__LINE__<< ": " <<#x<< " = " << x << endl
#define debug_vec(v) cerr<<__LINE__<<": "<<#v<<" = ";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

ll gcd(ll a, ll b)
{
    if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

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

void solve() {
    ll n, m;
    cin >> n >> m;
    vector<ll> A(n);
    rep(i, n) cin >> A[i], A[i] >>= 1;
    ll x = 1;
    rep(i, n) {
        x = lcm(x, A[i]);
        if (x > m) {
            cout << 0 << endl;
            return;
        }
    }
    rep(i, n) {
        if (x / A[i] % 2 == 0) {
            cout << 0 << endl;
            return;
        }
    }
    int ans = 0;
    if (m >= x) ans++, m -= x;
    ans += m / (2 * x);
    cout << ans << endl;
}

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


Measured memory_bytes: 3972
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <functional>
#include <stack>
#include <utility>
#include <map>
#include <queue>
#include <set>
#include <climits>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF = LLONG_MAX;
const ll MAX_N = 100000;
const double EPS = 10e-8;

int dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };

ll n, a, b, h[MAX_N];

bool f(int x) {
	ll y = x;
	if (b*x >= h[0])return true;
	ll i = 0;
	while (i<n && b*x < h[i]) {
		y -= (h[i] - b * x) / (a - b);
		if ((h[i] - b * x) % (a - b) != 0)y--;
		i++;
	}
	if (y >= 0)return true;
	else return false;
}

ll serch() {
	ll ok = 1000000000, ng = -1;
	while (ok - ng > 1) {
		int mid = (ok + ng) / 2;
		if (f(mid))ok = mid;
		else ng = mid;
	}
	return ok;
}


int main() {
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++)cin >> h[i];
	sort(h, h + n, greater<int>());
	cout << serch() << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

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

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

  ll S;
  cin >> S;

  ll uLimit = 1000000000;

  ll x1, y1, x2, y2, x3, y3;
  if (S >= 1000000000000000000LL) {
    x1 = 0;
    y1 = 0;
    x2 = 0;
    y2 = uLimit;
    x3 = uLimit;
    y3 = 0;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    return 0;
  }
  x1 = 0;
  y1 = 1;
  x2 = uLimit;
  y2 = 0;
  x3 = S % uLimit;
  y3 = S / uLimit + 1;
  /*
  cout << uLimit * y3 * 2 << endl;
  cout << y1 * x2 << endl;
  cout << (y3 - 1) * x3 << endl;
  cout << y3 * (uLimit - x3) << endl;
  cout << uLimit * y3 * 2 - y1 * x2 - (y3 - 1) * x3 - y3 * (uLimit - x3) << endl;
  */
  cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;


  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<vector>
#include<array>
#include<string>
#include<stack>
#include<queue>
#include<algorithm>
#include<cassert>
#include<functional>
#include<random>
#include<complex>
#include<bitset>
#include<chrono>
//#include<boost/multiprecision/cpp_int.hpp>
#define int int64_t
#define uint uint64_t
#define REP(i, a, b) for (int64_t i = (int64_t)(a); i < (int64_t)(b); i++)
#define rep(i, a) REP(i, 0, a)
#define SZ(X) ((int64_t)((X).size()))
#define ITR(x, a) for (auto x = a.begin(); x != a.end(); x++)
#define ALL(a) (a.begin()), (a.end())
#define HAS(a, x) (a.find(x) != a.end())
#define Min(x) *min_element(ALL(x))
#define Max(x) *max_element(ALL(x))
#define Unique(L) (L.erase(unique(ALL(L)), L.end()))
#define intmax (std::numeric_limits<int64_t>::max() / 4)
#define doublemax (std::numeric_limits<double>::max() / 4)
using namespace std;
//typedef boost::multiprecision::cpp_int bigint;
const double EPS = 1e-9;
const double PI = acos(-1.0);




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

	int N, W;
	cin >> N >> W;
	vector<vector<int>>mono(4);
	int w0, v0;
	cin >> w0 >> v0;
	mono[0].push_back(v0);
	REP(i, 1, N) {
		int w, v;
		cin >> w >> v;
		mono[w - w0].push_back(v);
	}
	rep(i, 4)sort(ALL(mono[i]), greater<int>());

	int ans = 0;

	for (int i = 0; i <= mono[0].size(); i++) {
		for (int j = 0; j <= mono[1].size(); j++) {
			for (int k = 0; k <= mono[2].size(); k++) {
				int weight = w0*i + (w0 + 1)*j + (w0 + 2)*k;
				if (W < weight)continue;
				int l = min((W - weight) / (w0 + 3),int(mono[3].size()));

				int total = 0;
				rep(ii, i)total += mono[0][ii];
				rep(jj, j)total += mono[1][jj];
				rep(kk, k)total += mono[2][kk];
				rep(ll, l)total += mono[3][ll];
				ans = max(ans, total);
			}
		}
	}
	cout << ans << endl;

	return 0;
}

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

const int N = 200005;
const int MOD = 1000000007;
typedef long long i64;

int a[N], b[N];

int main ()
{
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) scanf("%d", a + i), b[i] = a[i];
    sort(b + 1, b + n + 1);
    int t1 = b[n / 2], t2 = b[n / 2 + 1];
    for (int i = 1; i <= n; ++i) {
        if (a[i] > t1) printf("%d\n", t1);
        else printf("%d\n", t2);
    }
    return 0;
}


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

using namespace std;

long long calc(string s){
  string x = "";
  long long res = 0;
  for(int i = 0 ; i < s.size(); ++i){
    if(s[i] == '+'){
      res += stoll(x);
      x = "";
    }else x += s[i];
  }
  res += stoll(x);
  return res;
}

int main() {
    string s; cin>>s;
    int n = s.size();
    long long ans = 0;
    for(int i = 0 ; i < (1 << (n - 1)); ++i){
        string cur = "";
        for(int j = 0 ; j < n - 1; ++j){
          cur += s[j];
            if(i&(1 << j)){
                cur += '+';
            }
        }
         cur += s[n - 1];
         ans += calc(cur);

    }
    cout<<ans<<"\n";
}

Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main() {
	int n, k,i;
	cin >> n >> k;
	ll sum = 0;
	for (i = k + 1; i <= n; i++) {
		sum += (ll)((n / i)*(i - k));
		int l = n%i;
		if (l >= k) {
			sum += (ll)(l - k + 1);
		}
		if (k == 0)sum--;
	}
	cout << sum << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  vector<int> x(1e5 + 11, 0);
  ll sum = 0;
  for (int i = 0; i < n; i++) {
    x[a[i]]++;
    sum += a[i];
  }
  int q;
  cin >> q;
  for (int i = 0; i < q; i++) {
    int b, c;
    cin >> b >> c;
    sum += (c - b) * x[b];
    x[c] += x[b];
    x[b] = 0;
    cout << sum << endl;
  }
  return 0;
}

Measured memory_bytes: 4044
/***from dust i have come, dust i will be***/

#include<bits/stdc++.h>

typedef long long int ll;
typedef unsigned long long int ull;

#define dbg printf("in\n")
#define nl printf("\n");
#define N 310
#define inf 1e9

#define sf(n) scanf("%d", &n)
#define sff(n,m) scanf("%d%d",&n,&m)
#define sfl(n) scanf("%I64d", &n)
#define sffl(n,m) scanf("%I64d%I64d",&n,&m)

#define pf(n) printf("%d",n)
#define pff(n,m) printf("%d %d",n,m)
#define pffl(n,m) printf("%I64d %I64d",n,m)
#define pfl(n) printf("%I64d",n)
#define pfs(s) printf("%s",s)

#define pb push_back
#define pp pair<int, int>

using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);

    int i, j, k;
    int n, m, t;
    int a, b, c;

    sff(a, b), sf(c);

    if(a + b + c >= 22)
        pfs("bust\n");
    else
        pfs("win\n");



    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  while (1){
    int x, y;
    cin >> x >> y;
    if (x == 0 && y == 0) break;
    if (x < y){
      cout << x << ' ' << y << endl;
    } else {
      cout << y << ' ' << x << endl;
    }
  }
}


Measured memory_bytes: 3096
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    public static void main(String[] args) throws Exception {

        InputStreamReader is = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(is);

        List<String> mylist = new ArrayList<>();

        // 標準入力からの値を変数strinputに代入
        String strinput = reader.readLine();

        while (strinput != null) {

            mylist.add(strinput);
            strinput = reader.readLine();

        }

        int n = Integer.valueOf(mylist.get(0).split(" ")[0]);
        int m = Integer.valueOf(mylist.get(0).split(" ")[1]);

        int mysum = n * (n - 1) / 2;
        mysum += m * (m - 1) / 2;

        System.out.println(mysum);

    }

}


Measured memory_bytes: 22996
# DP
def main():
    N, W = map(int, input().split())

    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))


main()


Measured memory_bytes: 7724
import static java.lang.Math.*;
import static java.util.Arrays.*;
import java.util.*;
import java.io.*;

public class Main {

	void tr(Object... os) {
		System.err.println(deepToString(os));
	}
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj2106/input.txt"));
			//System.setOut(new PrintStream(new FileOutputStream("src/aoj2106/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}


	Scanner sc;
	void run() {
		sc = new Scanner(System.in);
		int t = sc.nextInt();
		for (;t-->0;) {
			solve();
		}
	}

	void solve()
	{
		int n = sc.nextInt();
		int[] e = new int[n];
		for (int i = 0; i < n; i++) e[i] = sc.nextInt();

		int[][] dp = new int[n+1][401]; // dp[i][k] := i-1番目が k のとき i番目のエネルギーの最大値
		for (int i = 0; i < dp.length; i++) {
			fill(dp[i], -1);
		}
		dp[0][0] = e[0];

		for (int i = 0; i < n - 1; i++) {
			for (int k = 0; k <= 400; k++) if (dp[i][k] >= 0) {
				int cur = dp[i][k];

				// not excitation
				dp[i+1][cur] = max(dp[i+1][cur], e[i+1]);

				// excition
				if (i > 0 && cur > 0) {
					dp[i+1][cur - 1] = max(dp[i+1][cur-1], e[i+1] + k);
				}
			}
		}
		int ans = 0;
		for (int i = 0; i <= 400; i++) {
			ans = max(ans, dp[n-1][i]);
		}
		System.out.println(ans);
	}


}

Measured memory_bytes: 12000
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <typeinfo>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    ll x, y, z;

    cin >> x >> y >> z;
    cout << z << " " << x << " " << y << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// 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();}

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

typedef long long ll;

const ll MOD = 1e9 + 7;

class A9x9 {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int A, B;
	    in >> A >> B;
	    if (A <= 9 && B <= 9) {
	        out << A * B << "\n";
	    } else {
	        out << -1 << "\n";
	    }
	}
};


signed main() {
	A9x9 solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int N;
		N = sc.nextInt();
		int M;
		M = sc.nextInt();
		long[] A=new long[M];
		long ans=0;

	for (int i = 0; i < N; i++) {
			int x = sc.nextInt();
			for (int j = 0; j < x; j++) {
				int X = sc.nextInt();
			A[X-1]++;
			}
	}

	for (int i = 0; i < M; i++) {
		if(A[i]==N)ans++;
	}
			

					System.out.print(ans); 	

	}
}




Measured memory_bytes: 25172
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> P;
struct edge{int to, id;};
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mod 1000000007

int main(){
    int n,w;
    cin >> n >> w;
    int v[n],weight[n];
    rep(i,n){
        int a,b;
        cin >> a >> b;
        v[i] = a;
        weight[i] = b;
    }
    int dp[n+10][w+10];
    for(int i = 0; i <= w; i++){
        dp[0][i] = 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j <=w ; j++){
            if(weight[i] <= j){
                dp[i+1][j] = max(dp[i+1][j-weight[i]] + v[i],dp[i][j]);
            }
            else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }
    cout << dp[n][w] << endl;

}


Measured memory_bytes: 7044
#include <iostream>
#include <unordered_map>

using namespace std;

#define rep(i, a, n) for(int i = a; i < (n); ++i)

int main(){
  int n, x;
  cin >> n;
  unordered_map<int, int> v;
  rep(i, 0, n) {
    cin >> x;
    v[x] = i+1;
  }
  rep(i, 0, n) {
    cout << v[i+1] << endl;
  }
}

Measured memory_bytes: 4900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define EPS (1e-7)
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const double PI = acos(-1);
const ll MOD = 1000000007;
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 N,C; cin >> N >> C;
  vector<vector<int>> D(C, vector<int>(C)), c(N, vector<int>(N));
  rep(i,C) {
    rep(j,C) cin >> D[i][j];
  }
  rep(i,N) {
    rep(j,N) {
      cin >> c[i][j];
      c[i][j]--;
    }
  }

  vector<vector<int>> sum(3, vector<int>(C));

  rep(k,C) {
    rep(i,N) {
      rep(j,N) {
        int l = (i+j) % 3;
        sum[l][k] += D[c[i][j]][k];
      }
    }
  }

  int ans = INF;
  rep(i,C) {
    rep(j,C) {
      rep(k,C) {
        if (i == j || j == k || k == i) continue;
          chmin(ans,sum[0][i] + sum[1][j] + sum[2][k]);
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define rrep(i, n) for (int i = (int)n-1; i >= 0; --i)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

__attribute__ ((constructor))
void init() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(10);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

//n -> big, a -> small
mint choose(int n,int a){
  mint x = 1, y = 1;
  rep(i,a){
    x *= n-i;
    y *= i+1;
  }
  return x / y;
}

signed main(){
  ll n;
  cin >> n;
  ll ans = 0;
  FOR(i,1,2001){
    if(i*3 > n){
      break;
    }
    ll now = n - i * 3;
    // cout << int(i) << " " << now<<endl;
    ans += choose(now+i-1, i-1).x;
    ans %= MOD;
    // cout << ans << endl;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3652
A,B,C,D=map(int,list(input()))
o=["+","-"]
if A+B+C+D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[0],o[0])
elif A+B+C-D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[0],o[1])
elif A+B-C+D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[1],o[0])
elif A+B-C-D==7:
    strings="A{}B{}C{}D=7".format(o[0],o[1],o[1])
elif A-B+C+D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[0],o[0])
elif A-B+C-D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[0],o[1])
elif A-B-C+D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[1],o[0])
elif A-B-C-D==7:
    strings="A{}B{}C{}D=7".format(o[1],o[1],o[1])
strings=list(strings)
strings[0]=str(A)
strings[2]=str(B)
strings[4]=str(C)
strings[6]=str(D)
print("".join(strings))

Measured memory_bytes: 3064
n, m = map(int, input().split(" "))
ab = [list(map(int, input().split(" "))) for i in range(n)]
cd = [list(map(int, input().split(" "))) for i in range(m)]

for nx, ny in ab:
    distances = [abs(nx-mx)+abs(ny-my) for mx, my in cd]
    print(distances.index(min(distances))+1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
    while(1){
        int a,b,c;
        cin>>a>>b>>c;
        if(a==-1&&b==-1&&c==-1)break;
        else if(a==-1||b==-1)cout<<'F'<<endl;
        else if(a+b>=80)cout<<'A'<<endl;
        else if(a+b>=65)cout<<'B'<<endl;
        else if(a+b>=50)cout<<'C'<<endl;
        else if(a+b>=30&&c>=50)cout<<'C'<<endl;
        else if(a+b>=30)cout<<'D'<<endl;
        else cout<<'F'<<endl;
    }
    return 0;
}


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

typedef long long int ll;

#define endl '\n'
ll n,w;

ll dp[105][100005];
ll arr[100005][2];
ll solve(ll u,ll w)
{

    if(w<0)return -1e18;

    if(u==n ){
        return 0;
    }

    if(dp[u][w]==-1){

        dp[u][w] = max(solve(u+1,w),arr[u][1]+solve(u+1,w-arr[u][0]));

    }
    //cout<<u<<" "<<w<<" "<<mp[{u,w}]<<endl;

    return dp[u][w];

}

int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    memset(dp,-1,sizeof(dp));
    cin>>n>>w;

    for(ll i=0;i<n;i++){
        cin>>arr[i][0]>>arr[i][1];
    }

    cout<<solve(0,w)<<endl;
}


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

using namespace std;

typedef long long ll;

int main(){
  ll n;
  ll cnt = 0;

  //vector<ll> ans;
  
  cin >> n;

  for(ll i = 1; i*i <= n; i++){
    if(n % i == 0){
      ll v = n/i-1;
      if( v > i ) cnt += v;
    }
  }
  cout << cnt << endl;
  return 0;
}


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

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

  int count=0;

  for(int i=0; i<K+1; i++) {
    for(int j=0; j<K+1; j++) {
	if(s-(i+j) <= K && s>=i+j) 
	  count++;
    }
  }

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


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	public static void main (String[] args) {
		Scanner in = new Scanner(System.in);		
		int N = in.nextInt();
        int M = in.nextInt();
      
      if((M-N)%2==0){System.out.print(M-(M-N)/2);}
      else{System.out.print("IMPOSSIBLE");}
        
        
      }
	}

Measured memory_bytes: 21716
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
using ll = long long;

int main() {
    int h,w;cin>>h>>w;
    string s;
    vector<vector<int>> m(h,vector<int>(w,-1));
    for (int i=0;i<h;i++) {
        cin>>s;
        for (int j=0;j<w;j++) if (s[j]=='.') m[i][j]=0;
    }

    vector<vector<int>> z(h,vector<int>(w,2000));
    for (int i=0;i<h;i++) {
        for (int j=0;j<w;j++) {
            if (m[i][j]==-1) z[i][j]=0;
            else {
                int u=2000,l=2000;
                if (i-1>=0) u = z[i-1][j];
                if (j-1>=0) l = z[i][j-1];
                z[i][j] = min((min(u,l) + 1),z[i][j]);
            }
        }        
    }
    int mc = 0;
    for (int s=h-1;s>=0;s--) {
        for (int t=w-1;t>=0;t--) {
            if (m[s][t]==-1) z[s][t]=0;
            else {
                int d=2000,r=2000;
                if (s+1<=h-1) d = z[s+1][t];
                if (t+1<=w-1) r = z[s][t+1];
                z[s][t] = min((min(d,r) + 1),z[s][t]);
                mc = max(mc,z[s][t]);
            }
        }        
    }
    cout <<  mc << endl;
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

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

    ll ans = n + 1;

    srep(i,1,10000000){
        ll ii = i;
        if(n % ii == 0){
            ans = min(ans, ii + n/ii);
        }
    }
    cout << ans - 2 << endl;
    return 0;
}
 
 


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;


int main(){
    int n;
    scanf("%d",&n);
    int nn=n;
    int m=0;
    for(int i=1;i<=9;i++){
        m+=n%10;
        n=n/10;
    }
    if(nn%m==0)printf("Yes");
    else printf("No");
    
}


Measured memory_bytes: 128
import java.util.*;

public class Main {

    private static final int[] ns = new int[]{2, 5, 5, 4, 5, 6, 3, 7, 6};

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[M];
        for (int m = 0; m < M; m += 1) {
            A[m] = sc.nextInt();
        }

        int[] dp = new int[N + 1];
        dp[0] = 0;
        for (int n = 1; n <= N; n += 1) {
            int next = -1;
            for (int a : A) {
                if (n - ns[a - 1] < 0 || n - ns[a - 1] > N) {
                    continue;
                }
                int curNext = dp[n - ns[a - 1]] + 1;
                if (next < curNext) {
                    next = curNext;
                }
            }
            dp[n] = next;
        }

        String integer = "";
        int curN = N;
        for (int n = 0; n < dp[N]; n += 1) {
            int curA = 0;
            for (int a : A) {
                if (curA >= a || curN - ns[a - 1] < 0) {
                    continue;
                } else {
                    if (dp[curN - ns[a - 1]] == (dp[curN] - 1)) {
                        curA = a;
                    }
                }
            }
            curN = curN - ns[curA - 1];
            integer += curA;
        }

        System.out.println(integer);

    }

}


Measured memory_bytes: 59092
while True:
    try:
        listA = map(str,raw_input().split(' '))
        listB = map(str,raw_input().split(' '))

        hit=0
        blw=0
        for tB in listB:
            if (tB in listA) and (listB.index(tB) == listA.index(tB)):
                hit += 1
            elif (tB in listA) and (listB.index(tB) != listA.index(tB)):
                blw += 1
        print hit,blw

    except EOFError:
        break

Measured memory_bytes: 4236
<?php
    fscanf(STDIN,"%d %d",$n,$k);
    while(true){
        if(strlen($n) > strlen($k)+1){
            $n = $n - $k * pow(10,strlen($n)-strlen($k)-1);
        }else{
            $ans = abs($n-$k);
            if($n > $ans){
                $n = $ans;
                continue;
            }else{
                break;
            }
        }
    }
    echo $n.PHP_EOL;
?>

Measured memory_bytes: 4728
#include<bits/stdc++.h>
#define mod 998244353
using namespace std;
int C[4005][4005],Pow[4005],k,n;
int solve(int x,int y,int z){
    int res=0;
    for(int i=0;i<=z&&i<=x;++i)
        if(y+i-1>=0)res=(res+1ll*Pow[i]*C[x][i]%mod*C[z+y-1][y+i-1]%mod)%mod;
    return res;
}
int main(){
	C[0][0]=1,Pow[0]=1;
	for(int i=1;i<=4000;++i){
		C[i][0]=1; 
		for(int j=1;j<=i;++j)C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
		Pow[i]=Pow[i-1]*2%mod;
	}
	scanf("%d%d",&k,&n);
	for(int i=2;i<=2*k;++i){
		int cnt=min(i-1,k)-max(0,i-k-1);
		if(i&1)printf("%d\n",solve(cnt/2,k-cnt,n));
        else printf("%d\n",(solve(cnt/2,k-cnt,n)+solve(cnt/2,k-cnt,n-1))%mod);
	}
}

Measured memory_bytes: 61440
#pragma GCC target("avx2,avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//using i128 = __int128_t;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln = '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) {if (a < b) {a = b; return true;} return false;}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) {if (a > b) {a = b; return true;} return false;}
inline int topbit(int x) {return x == 0 ? -1 : 31-__builtin_clz(x);}
inline int topbit(long long x) {return x == 0 ? -1 : 63-__builtin_clzll(x);}
inline int botbit(int x) {return x == 0 ? 32 : __builtin_ctz(x);}
inline int botbit(long long x) {return x == 0 ? 64 : __builtin_ctzll(x);}
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
inline void print() {cout << "\n";}
template<class T>
inline void print(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cout << *itr << " ";
    print();
}
template<class T, class... Args>
inline void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
#ifdef MINATO_LOCAL
#define dump(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;
inline void debug() {cerr << endl;}
template<class T>
inline void debug(const vector<T> &v) {
    for (auto itr = v.begin(); itr != v.end(); ++itr) cerr << *itr << " ";
    debug();
}
template<class T, class... Args>
inline void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
#else
#define dump(x) void(0)
inline void debug() {}
template<class T> inline void debug(const vector<T> &v) {}
template<class T, class... Args> inline void debug(const T &x, const Args &... args) {}
#endif
struct Fast_ios {Fast_ios() {cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20);};} fast_ios;
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int MAX = 1e6;
int main() {
    int N; cin >> N;
    vector<int> A(N),cnt(MAX+1);
    rep(i,N) {
        cin >> A[i];
        cnt[A[i]]++;
    }

    bool pc = true;
    for (int i = 2; i <= MAX; i++) {
        int tmp = 0;
        for (int j = 1; j*i <= MAX; j++) {
            tmp += cnt[j*i];
        }
        if (tmp >= 2) pc = false;
    }

    if (pc) {
        cout << "pairwise coprime" << ln;
        return 0;
    }

    int g = 0;
    rep(i,N) g = gcd(g,A[i]);
    cout << (g==1 ? "setwise coprime" : "not coprime") << ln;
}

Measured memory_bytes: 11052
#include <cstdio>

//biginner49

int main(){
	char c;
	scanf("%c", &c);
	char k[5] = { 'a', 'i', 'o', 'u', 'e' };
	for (int i = 0; i < 5; i++){
		if (c == k[i]){
			printf("vowel\n");
			return 0;
		}
	}
	printf("consonant\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned ll
#define jmp cout<<"\n"
#define vl vector<ull>
#define vi vector<int>
#define vvl vector<vl>
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define printv(v) for(auto x:v) cout<<x<<" "; jmp;
#define endll "\n"
#define SORT(v) sort(v.begin(),v.end())
#define REV(x)  reverse(x.begin(),x.end())
#define UNI(a) a.erase( unique( a.begin(), a.end() ), a.end() )
#define all(a) a.begin(), a.end()
#define si(x) x.size()
#define ff first
#define ss second
#define iin insert
using namespace std;

ll dp[3005][3005];

void solve()
{

	ll n, k;
	cin >> n ;
	ll a[n];
	for (ull i = 0; i < n; i++) cin >> a[i];
	//memset(dp, -1, sizeof(dp));
	for (ll i = n - 1; i >= 0; i--)
	{
		for (ll j = i; j < n; j++)
		{
			if (i == j)
				dp[i][j] = a[i];
			else
				dp[i][j] = max((a[i] - dp[i + 1][j]), ( a[j] - dp[i][j - 1]));
		}
	}

	cout << dp[0][n - 1] << endll;
}
signed main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast;
	solve();
	return 0;
}


Measured memory_bytes: 70016