akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<algorithm>
#include<functional>
using namespace std;

int a,b;
int max=0;

int main()
{
cin>>a>>b;

while(true)
{
	if(b>a)
	{
	swap(a,b);
	}
	
	a=a%b;

	if(a==0)break;
}
cout<<b<<endl;


	return 0;
}

Measured memory_bytes: 1160
X,K,D = [int(x) for x in input().split()]

if abs(X) >= K * D:
    print(abs(X) - K * D)
else:
    K = K - int(abs(X) / D)
    X = int(abs(X) % D)
    if X >= int(D / 2):
        if K % 2 == 0:
            print(X)
        else:
            print(D - X)
    else:
        if K % 2 != 0:
            print(D - X)
        else:
            print(X)

Measured memory_bytes: 9136
n = int(input())
a = [int(_) for _ in input().split()]
b = [int(_) for _ in input().split()]
res = 0
for i in range(n):
    j = n-1-i
    t = min(a[j+1],b[j])
    res += t
    b[j]-= t
    s = min(a[j],b[j])
    res += s
    a[j]-= s
print(res)

Measured memory_bytes: 18624
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int a,b;
    cin >> a >> b;
    int ans = 100000;
    for(int i = 1;i <= 1000;i++){
        if (floor(i*0.08) == a && floor(i*0.1) == b){
            ans = min(ans,i);
        }
    }
    
    if (ans == 100000) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

// Function for finding sum of larger numbers 
string findSum(string str1, string str2)
{
	// Before proceeding further, make sure length 
	// of str2 is larger. 
	if (str1.length() > str2.length())
		swap(str1, str2);

	// Take an empty string for storing result 
	string str = "";

	// Calculate length of both string 
	int n1 = str1.length(), n2 = str2.length();

	// Reverse both of strings 
	reverse(str1.begin(), str1.end());
	reverse(str2.begin(), str2.end());

	int carry = 0;
	for (int i = 0; i < n1; i++)
	{
		// Do school mathematics, compute sum of 
		// current digits and carry 
		int sum = ((str1[i] - '0') + (str2[i] - '0') + carry);
		str.push_back(sum % 10 + '0');

		// Calculate carry for next step 
		carry = sum / 10;
	}

	// Add remaining digits of larger number 
	for (int i = n1; i < n2; i++)
	{
		int sum = ((str2[i] - '0') + carry);
		str.push_back(sum % 10 + '0');
		carry = sum / 10;
	}

	// Add remaining carry 
	if (carry)
		str.push_back(carry + '0');

	// reverse resultant string 
	reverse(str.begin(), str.end());

	return str;
}

int main()
{
	int N;

	cin >> N;

	string total = "0";
	int sum = 0;
	bool useregsum = true;

	for (int i = 1; i <= N; i++)
	{
		if (i % 3 == 0 || i % 5 == 0)
			continue;

		if (useregsum)
			sum += i;

		if (sum > 2000000000 || useregsum == false)
		{
			useregsum = false;
			if (sum != 0)
			{
				total = to_string(sum);
				sum = 0;
			}
			else
				total = findSum(total, to_string(i));
		}
	}

	if (sum == 0 && useregsum == false)
		cout << total << endl;
	else
		cout << sum << endl;
}

Measured memory_bytes: 3200
N = int(input())

ans = [0]*10**4
for x in range(1,101):
    for y in range(1,int(N**0.5)+1):
        for z in range(1,int(N**0.5)+1):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n<=10**4:
                ans[n-1]+=1

for i in range(N):
    print(ans[i])

Measured memory_bytes: 69760
N, A, B, C = map(int, input().split())
l_list = [int(input()) for i in range(N)]


def dfs(a, b, c, n):
    res = float("inf")
    if n == N:
        if a > 0 and b > 0 and c > 0:
            return abs(A - a) + abs(B - b) + abs(C - c) - 30
        else:
            return float("inf")
    l = l_list[n]
    res = min(res, dfs(a, b, c, n + 1))
    res = min(res, dfs(a + l, b, c, n + 1) + 10)
    res = min(res, dfs(a, b + l, c, n + 1) + 10)
    res = min(res, dfs(a, b, c + l, n + 1) + 10)
    return res


ans = dfs(0, 0, 0, 0)
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cii(i);
    auto ans = n + 1 - i;
    co(ans);
    return 0;
}

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

public class Main{

	public static void main(String[] args) throws IOException {
		int N = readInt(), H = readInt();
		PriorityQueue<Integer> queue = new PriorityQueue<Integer>(Collections.reverseOrder());
		int maxdmg = 0;
		for(int i = 1; i<=N; i++) {
			maxdmg = Math.max(maxdmg, readInt());
			queue.add(readInt());
		}
		
		int cnt = 0;
		while(!queue.isEmpty() && maxdmg < queue.peek() && H > 0) {
			H -= queue.poll(); cnt++;
		}
		
		if(H <= 0) println(cnt);	
		else if(H%maxdmg == 0) println((H/maxdmg)+cnt);
		else println(cnt+(H/maxdmg)+1);
		exit();
	}

	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static StringTokenizer st;

	static String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine().trim());
		return st.nextToken();
	}

	static long readLong() throws IOException {
		return Long.parseLong(next());
	}

	static float readFloat() throws IOException {
		return Float.parseFloat(next());
	}

	static boolean readBoolean() throws IOException {
		return Boolean.parseBoolean(next());
	}

	static short readShort() throws IOException {
		return Short.parseShort(next());
	}

	static byte readByte() throws IOException {
		return Byte.parseByte(next());
	}

	static int readInt() throws IOException {
		return Integer.parseInt(next());
	}

	static double readDouble() throws IOException {
		return Double.parseDouble(next());
	}

	static char readCharacter() throws IOException {
		return next().charAt(0);
	}

	static String readLine() throws IOException {
		return br.readLine().trim();
	}

	static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));

	static void print(String s) {
		pr.print(s);
	}

	static void print(int s) {
		pr.print(s);
	}

	static void print(long s) {
		pr.print(s);
	}

	static void print(boolean s) {
		pr.print(s);
	}

	static void print(short s) {
		pr.print(s);
	}

	static void print(byte s) {
		pr.print(s);
	}

	static void print(double s) {
		pr.print(s);
	}

	static void print(char s) {
		pr.print(s);
	}

	static void print(float s) {
		pr.print(s);
	}

	static void println(String s) {
		pr.println(s);
	}

	static void println(int s) {
		pr.println(s);
	}

	static void println(long s) {
		pr.println(s);
	}

	static void println(boolean s) {
		pr.println(s);
	}

	static void println(short s) {
		pr.println(s);
	}

	static void println(byte s) {
		pr.println(s);
	}

	static void println(double s) {
		pr.println(s);
	}

	static void println(char s) {
		pr.println(s);
	}

	static void println(float s) {
		pr.println(s);
	}

	static void flush() {
		pr.flush();
	}

	static void exit() throws IOException {
		br.close();
		pr.close();
		System.exit(0);
	}
}


Measured memory_bytes: 44872
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    sx,sy,tx,ty=map(int,input().split())
    x,y=tx-sx,ty-sy
    ans=''
    # 1往復目
    ans=ans+'R'*x+'U'*y+'L'*x+'D'*y
    # 2往復目
    ans=ans+'D'+'R'*(x+1)+'U'*(y+1)+'L'+'U'+'L'*(x+1)+'D'*(y+1)+'R'
    print(ans)
resolve()

Measured memory_bytes: 38256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};

int main(){
	const int MAX=100001;
	int N,C,K;
	cin>>N>>C>>K;
	int T[MAX]={};
	int S[MAX]={};
	for(int i=0;i<N;i++){
		cin>>T[i];
	}
	sort(T,T+N);
	for(int i=0;i<N;i++){
		S[i]=T[i]+K;
	}
	vector<int> bus;
	int ans=0;
	int fast=0;
	//バスにはiを入れる
	for(int i=0;i<N;i++){
		if(!bus.size()){
			fast=S[i];
			bus.push_back(i);
		}
		else{
			if(fast<T[i]){
				bus.clear();
				ans++;
				fast=S[i];
				bus.push_back(i);
			}
			else{
				bus.push_back(i);
			}
		}
		if(bus.size()==C){
			bus.clear();
			ans++;
		}
		//cout<<i<<" "<<bus.size()<<endl;
	}
	if(bus.size())
		ans++;
	cout<<ans<<endl;
	return 0;
}

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

const long INF = 1L << 60;
const int MOD = 1000000007;

int a[100010];
long dp[100010];
bool ok[100010];

int main(){
	int n, m;
	scanf("%d%d", &n, &m);
	for(int i = 0; i < m; i++) {
		scanf("%d", &a[i]);
		ok[a[i]] = true;
	}
	dp[0] = 1;
	for(int i = 0; i <= n; i++) {
		if(!ok[i+1] && i+1 <= n) dp[i+1] += dp[i];
		if(!ok[i+2] && i+2 <= n) dp[i+2] += dp[i];
		dp[i+1] %= MOD; dp[i+2] %= MOD;
	}
	printf("%ld", dp[n]);
}


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

int main() {
	int n, m;
	cin >> n >> m;
	vector<pair<ll,ll>>a(m);
	for (int i = 0; i < m; i++)cin >> a.at(i).first >> a.at(i).second;
	sort(a.begin(), a.end());
	ll l, r, p;
	ll ans = 0;
	for (int i = 0; i < m; i++) {
		if (i == 0) {
			l = a.at(i).first;
			r = a.at(i).second;
		}
		else {
			if (a.at(i).first<r) {
				l = max(a.at(i).first, l);
				r = min(a.at(i).second, r);
			}
			else {
				ans++;
				l = a.at(i).first;
				r = a.at(i).second;
			}
		}
	}
	cout << ans + 1 << endl;
}

Measured memory_bytes: 1792
///Bismillahir Rahmanir Rahim
#include "bits/stdc++.h"

#define                           ll                          long long
#define                           int                         ll
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<ll,ll>
#define                           clr(x)                      memset(x,0,sizeof(x));
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           show(x,y)                   cout<<x<<" : ";for(auto z:y)cout<<z<<" ";cout<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

using namespace std;

const ll inf=1e9;
const int mod=1e9+7;
const int M=200005;
int d[M];
int c[M];
map<pi,int>id;
vector<pi>edg;
int w[M];
bool cmp(pi a,pi b)
{
    int u1=a.fi;
    int v1=a.si;
    int u2=b.fi;
    int v2=b.si;
    if(d[u1]!=d[u2])return d[u1]<d[u2];
    if(d[v1]!=d[v2])return d[v1]<d[v2];
    return a<b;
}
 main()

{
    fast
    int n,m;
    cin>>n>>m;
    f(i,0,n-1)cin>>d[i];
    memset(c,-1,sizeof c);
    f(i,0,m-1)
    {
        int u,v;
        cin>>u>>v;
        u--;v--;
        if(d[u]<d[v])swap(u,v);
        id[mp(u,v)]=i;
        edg.pb(mp(u,v));
    }
    sort(edg.begin(),edg.end(),cmp);
    f(i,0,m-1)
    {
        int u=edg[i].fi;
        int v=edg[i].si;
        int du=d[u];
        int dv=d[v];
        if(c[u]==-1 && c[v]==-1)
        {
            if(du!=dv)
            {
                cout<<"-1"<<endl;
                return 0;
            }
            c[u]=1;
            c[v]=0;
            w[id[mp(u,v)]]=du;
        }
        else if(c[u]==-1)
        {
            c[u]=c[v]^1;
            w[id[mp(u,v)]]=du;
        }
        else if(c[v]==-1)
        {
            if(du!=dv)
            {
                cout<<"-1"<<endl;
                return 0;
            }
            w[id[mp(u,v)]]=dv;
            c[v]=c[u]^1;
        }
        else
        {
            w[id[mp(u,v)]]=inf;
        }
    }
    f(i,0,n-1)
    {
        if(c[i]==1)cout<<"W";
        else cout<<"B";
    }
    cout<<"\n";
    f(i,0,m-1)
    {
      cout<<w[i]<<"\n";
    }
    return 0;

}





































Measured memory_bytes: 22816
import math
x = int(input())

def f(a, b):
    return (a ** 5) - (b ** 5)

sele = math.floor(x ** (1/4))

for j in range(-sele, sele + 1):
    for k in range(-sele, sele + 1):
        if f(j, k) == x:
            print(j, k)
            exit()

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<std::vector<char> > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<std::vector<double> > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<std::vector<std::string> > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<std::vector<bool> > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

void IsPrimeNum(ll n, v_bool &is_prime)
{
    is_prime[0] = is_prime[1] = false;
    for(ll i = 2; i <= n; i++) {
        for(ll j = i*i; j <= n; j += i) {
            is_prime[j] = false;
        }
    }
}

int main(void)
{
    int x;
    cin >> x;
    
    v_bool is_prime(200000+1, true);    
    IsPrimeNum(200000, is_prime);

    int prime = 2;

    while(1) {
        if(is_prime[prime] && prime >= x) {
            cout << prime << endl;
            return 0;
        }
        prime++;
    }
    return 0;
}
/** atcoder **/


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);
#define time_taken_start int begtime = clock();
#define time_taken_end int endtime = clock(); \
cerr << "\n\n" << "Time elapsed: " << \
(endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
return 0;
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 998244353
#define inf 1000000000000000007
#define eps 0.0000000001
#define pi acosl(-1)
#define pdd pair<ld,ld>
#define pll pair<ll,ll>
#define ff first
#define ss second
#define vpl vector<pll>
#define vll vector<ll>
#define mseti multiset <ll>
#define msetd multiset <ll,greater<ll>>
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound 
#define stp fixed<<setprecision(20)
#define endl '\n'
pair<pll,pll> p[100];
ll ans[20][20];
void solve()
{
    ll n,m;
    cin>>n>>m;
    pll p[m+2];
    for(ll i=1;i<=m;i++)
    {
        p[i].ff=m-i+1;
    }
    for(ll i=1;i<=((m+1)/2);i++)
    {
        p[i].ss=i+m;
    }
    ll q=1;
    for(ll i=m;i>((m+1)/2);i--)
    {
        p[i].ss=n-q;
        q++;
    }
    for(ll i=1;i<=m;i++)
    {
        cout<<p[i].ff<<' '<<p[i].ss<<endl;
    }
}
int main()
{
    FAST
    #ifdef ayk_16
    freopen("input.txt","rt",stdin);
    freopen("output.txt","wt",stdout);
    #endif
    ll t=1;
    //cin>>t;
    for(ll i=0;i<t;i++)
    {
        //cout<<"Case #"<<i+1<<": ";
        solve();
    }
}

Measured memory_bytes: 5020
#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string
#include <vector>			//std::vector
#include <valarray>			//std::valarray	??°????????????????¬???????
#include <algorithm>		//std::sort
#include <time.h>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs, pow, sqrt, sin, cos,
#include <fstream>			//std::ifstream
#include <iomanip>			//std::setprecision
#include <random>			//std::random(C++11)

int main(void) {

	//test??¨
	//std::ifstream in("test.txt");
	//std::cin.rdbuf(in.rdbuf());

	std::vector<int> dice1(6);//, dice2(6);
	for (int i = 0; i < 6; i++) {
		std::cin >> dice1[i];
	}

	//for (int i = 0; i < 6; i++) {
	//	std::cin >> dice2[i];
	//}
	int q, up, front;
	std::cin >> q >> up >> front;
	std::vector<int> ans(q);

	int count = 0;
	std::vector<int> temp(6);
	//while (count < 16 && ((dice1[0] != dice2[0] || dice1[1] != dice2[1]))) {
	for (int i = 0; i < q; i++) {
		count = 0;
		while (count < 16 && ((dice1[0] != up || dice1[1] != front))) {

			//??±
			temp[0] = dice1[3];
			temp[1] = dice1[1];
			temp[2] = dice1[0];
			temp[3] = dice1[5];
			temp[4] = dice1[4];
			temp[5] = dice1[2];
			dice1 = temp;

			if (count != 0 && count % 4 == 0) {
				//???
				temp[0] = dice1[1];
				temp[1] = dice1[5];
				temp[2] = dice1[2];
				temp[3] = dice1[3];
				temp[4] = dice1[0];
				temp[5] = dice1[4];
				dice1 = temp;
			}

			count++;
		}

		ans[i] = dice1[2];
		std::cin >> up >> front;
	}

	for (int i = 0; i < q; i++) {
		std::cout << ans[i] << std::endl;
	}
}

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

#define ll long long
#define pb push_back

const ll N=1e5+9,inf=1e18,mod=1e9+7;



int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    cout<<min(a,b)<<" "<<max(0,(a+b)-n)<<"\n";
    return 0;
}



Measured memory_bytes: 256
N, M = list(map(int,input().split()))
s = []
ans = 0
for _ in range(M):
    temp = list(map(int, input().split()))
    s.append(temp[1:])
p = list(map(int, input().split()))
for i in range(2 ** N):
    flag = 1
    flag_1 = 1
    sw = bin(i)[2:]
    sw = sw.zfill(N)
    for j in range(M):
        sumsw = 0
        for k in s[j]:
            sumsw += int(sw[k-1])
        if sumsw % 2 != p[j]:
            flag = 0
            flag_1 = 0
            break
        if flag_1 == 0:
            break
    if flag:
        ans += 1
print(ans)

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

int c(int n, int m, ll k, vector<ll> a, vector<ll> b) {
 
  vector<ll> a_sum(n+1, 0);
  for(int i=0;i<n;i++) {
    a_sum[i+1] = a_sum[i] + a[i];
  }
  vector<ll> b_sum(m+1, 0);
  for(int i=0;i<m;i++) {
    b_sum[i+1] = b_sum[i] + b[i];
  }
 
  ll j = m;
  ll ans = 0;
  for(int i =0;i<=n;i++) {
    if(a_sum[i] > k)
      break;

    while(b_sum[j] > k - a_sum[i]) {
      j--;
    }
    ans = max(ans, i + j);
  }
  return ans;
}

int main() {
  int n, m;
  cin >> n >> m;
  ll k;
  cin >> k;
  vector<ll> a(n);
  for(int i=0;i<n;i++) {
    cin >> a[i]; 
  }
  vector<ll> b(m);
  for(int i=0;i<m;i++) {
    cin >> b[i]; 
  }
  cout << c(n, m, k, a, b);

}

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

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
  int N;
  static ll a[3 * MAX_N];
  std::cin >> N;
  rep(i, 3 * N) std::cin >> a[i];
  std::sort(a, a + 3 * N);

  int i = 0, j = 3 * N - 2;
  ll ans = 0;
  while(i < j) {
    ans += a[j];
    ++i;
    j -= 2;
  }
  std::cout << ans << '\n';
}

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

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;
	int w = tx - sx;
	int h = ty - sy;
	for (int i=0; i<h; i++) {
		cout << "U";
	}
	for (int i=0; i<w; i++) {
		cout << "R";
	}
	for (int i=0; i<h; i++) {
		cout << "D";
	}
	for (int i=0; i<w+1; i++) {
		cout << "L";
	}
	for (int i=0; i<h+1; i++) {
		cout << "U";
	}
	for (int i=0; i<w+1; i++) {
		cout << "R";
	}
	cout << "D" << "R";
	for (int i=0; i<h+1; i++) {
		cout << "D";
	}
	for (int i=0; i<w+1; i++) {
		cout << "L";
	}
	cout << "U" << endl;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e6;
int n, a[nsz + 5], rt, lst, ans;
int ql, qr, q[nsz + 5];

struct treap {
	int sz, ls[nsz + 5], rs[nsz + 5], pri[nsz + 5];
	int key[nsz + 5], mn[nsz + 5], mx[nsz + 5];
	
	int inline node(int w) {
		int u = ++sz;
		key[u] = mn[u] = mx[u] = w, pri[u] = rand();
		return u;
	}
	
	void inline up(int u) {
		mn[u] = ls[u] ? mn[ls[u]] : key[u];
		mx[u] = rs[u] ? mx[rs[u]] : key[u];
	}
	
	int merge(int v1, int v2) {
		if (!v1 || !v2)  return v1 | v2;
		if (pri[v1] < pri[v2]) {
			rs[v1] = merge(rs[v1], v2), up(v1);
			return v1;
		} else {
			ls[v2] = merge(v1, ls[v2]), up(v2);
			return v2;
		}
	}
	
	void split(int u, int w, int &v1, int &v2) {
		if (!u) { v1 = v2 = 0; return; }
		if (key[u] <= w) {
			v1 = u, split(rs[u], w, rs[u], v2), up(u);
		} else {
			v2 = u, split(ls[u], w, v1, ls[u]), up(u);
		}
	}
	
	void inline ins(int &rt, int w) {
		rt = merge(rt, node(w));
	}
	
	void inline del(int &rt, int w) {
		int v1, v2;
		split(rt, w - 1, v1, v2);
		rt = v1;
	}
};
treap tr;

int inline pre(int id) { return id == 0 ? nsz : id - 1; }

int inline nxt(int id) { return id == nsz ? 0 : id + 1; }

void inline init() {
	cont (i, n - 1) {
		tr.ins(q[qr], a[i]);
		if (i != n && a[i] > a[i + 1])  qr = nxt(qr);
	}
	tr.ins(q[qr], a[n]);
	
	lst = n;
	for (; tr.mx[q[qr]] == lst && lst; --lst) {
		tr.del(q[qr], lst);
	}
	
	qr = nxt(qr);
}

void inline deal() {
	for (; !q[ql] && ql != qr; ql = nxt(ql));
	int u = q[ql], mx = tr.mx[u];
	q[ql] = 0, ql = nxt(ql);
	for (int k = ql; k != qr && mx != lst; k = nxt(k)) {
		if (!q[k])  continue;
		int v1, v2;
		tr.split(q[k], mx, v1, v2);
		q[k] = v1;
		u = tr.merge(u, v2);
		mx = max(mx, tr.mx[u]);
		
		int i = q[pre(k)], j = q[k];
		if (i && tr.mx[i] < tr.mn[j]) {
			q[k] = tr.merge(q[pre(k)], q[k]);
			q[pre(k)] = 0;
		}
	}
	q[qr] = u;
	int i = q[pre(qr)], j = q[qr];
	if (i && tr.mx[i] < tr.mn[j]) {
		q[qr] = tr.merge(q[pre(qr)], q[qr]);
		q[pre(qr)] = 0;
	}
	
	for (; tr.mx[q[qr]] == lst && lst; --lst) {
		tr.del(q[qr], lst);
	}
	
	qr = nxt(qr);
	++ans;
}

int main() {
	scanf("%d", &n);
	cont (i, n) {
		scanf("%d", &a[i]);
	}
	init();
	for (; lst; deal());
	printf("%d\n", ans);
}

Measured memory_bytes: 23680
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef int Int;
typedef pair<Int,Int> pii;
typedef pair<Int,double> pid;
typedef pair<double,double> pdd;
typedef pair<Int,pii> pip;
typedef pair<double,Int> pdp;
#define A first
#define B second
#define pb(x) push_back(x)
#define ALL(x) x.begin(),x.end()
#define SZ(x) (x).size()
#define CLR(x) memset(x,0,sizeof x)
#define pdebug() printf("%d\n",__LINE__)
#define Itype(a) typeof(a.begin()) 
#define REP(i,a,b) for(int i = (a);i <= (b);i++)
#define FORO(i,n) REP(i,0,(int)n-1)
#define FORI(i,n) REP(i,1,(int)n)
#define FORIT(i,t) for(Itype(t) i = t.begin();i != t.end();i++)
#define eps 1e-6
#define sqr(x) ((x)*(x))
#define dist(_a,_b) sqrt(sqr(_a.A-_b.A)+sqr(_a.B-_b.B))
#define norm(_a) sqrt(sqr(_a.A)+sqr(_a.B))
template<typename T>void getMin(T &a,T b) { if(a > b) a = b; }
template<typename T>void getMax(T &a,T b) { if(a < b) a = b; }
template<typename T> vector<T> getVector(const int n) { return vector<T>(n); }
template<typename T> vector<T> getVector(const int n, const T a) { return vector<T>(n, a); }
template<typename T> vector<T> getEmptyVector() { return vector<T>(); }
// #define X first
// #define Y second
const ll MOD = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    cin >> N;
    int ans = 0;
    FORI(i, N) {
        int a;
        cin >> a;
        if(i % 2 && a % 2) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
typedef long long ll;
#define MAX_V 2000
#define INF 1000000000000000
int main(){
  ll n,m,loop,ans;
  cin >> n >> m;
  ll a[MAX_V],b[MAX_V],c[MAX_V],d[MAX_V];
  bool neg[MAX_V]={};
  for(int i=0;i<m;i++){
    cin >> a[i] >> b[i] >> c[i];
    a[i]--;
    b[i]--;
    c[i]*=-1;
  }
  for(int i=0;i<=n;i++){
    d[i]=INF;
  }
  loop = n-1;
  d[0]=0;
  while(loop!=0){
    loop--;
    for(int i=0;i<m;i++){
      if(d[a[i]]==INF)continue;
      if(d[b[i]]>d[a[i]]+c[i]){
        d[b[i]]=d[a[i]]+c[i];
      }
    }
  }
  loop = n;
  ans = d[n-1];
  while(loop!=0){
    loop--;
    for(int i=0;i<m;i++){
      if(d[a[i]]==INF)continue;
      if(d[b[i]]>d[a[i]]+c[i]){
        d[b[i]]=d[a[i]]+c[i];
        neg[b[i]]=true;
      }
      if(neg[a[i]]){
        neg[b[i]]=true;
      }
    }
  }
  if(neg[n-1]){
    cout << "inf\n";
  }else{
    cout << -ans<<endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = a;i < n;i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int n,m,a,b;
    bool cells[16][16] = {false};
    int dp[16][16] = {0};
    int q;
    
    
    while(1){
        cin >> m >> n;
        if(n+m == 0) break;
        
        rep(i,0,n){
            rep(j,0,m){
                cells[i][j] = false;
                dp[i][j] = 0;
            }
        }
        
        dp[n-1][0] = 1;
        
        cin >> q;
        
        rep(i,0,q){
            cin >> a >> b;
            a--;b--;
            cells[n-b-1][a] = true;
        }
        
        rep(i,0,n){
            rep(j,0,m){
                if(cells[n-1-i][j]) continue;
                
                if(i > 0) dp[n-i-1][j] += dp[n-i][j];
                if(j > 0) dp[n-i-1][j] += dp[n-i-1][j-1];
            }
        }
        
        /*
        rep(i,0,n){
            rep(j,0,m){
                cout << cells[i][j] << " ";
            }
            cout << endl;
        }
        cout << endl;
        
        rep(i,0,n){
            rep(j,0,m){
                cout << dp[i][j] << " ";
            }
            cout << endl;
        }
        */
        
        cout << dp[0][m-1] << endl;
    }
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 3096
<?php
  fscanf(STDIN, "%d", $n);
  $numbers = fgets(STDIN);
  $exploded_numbers = explode(' ', $numbers);

  $count = 0;
  $min = $exploded_numbers[0];
  foreach ($exploded_numbers as $key => $val) {
    if ($key-1 >= 0) {
      if ($val <= $min) {
		$min = $val;
		$count++;
	  }
    } else {
      $count++;
    }
  }
echo $count;


Measured memory_bytes: 18936
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<algorithm>
#include<list>
#include<functional>
#define _USE_MATH_DEFINES
#define X first
#define Y second
#define INF 1987654321987654321
#define PI 3.14159265358979323846264
#define MOD 1000000007
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef complex<double> base;
bool chk[100001];
int cnt[100001];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	chk[1] = 1;
	fup(i, 1, n, 1) cnt[i] = 1;
	while (m--)
	{
		int x, y;
		scanf("%d%d", &x, &y);
		if(chk[x])chk[y] = 1;
		cnt[x]--, cnt[y]++;
		if (cnt[x] == 0)chk[x] = 0;
	}
	int ans = 0;
	fup(i, 1, n, 1)if (chk[i])ans++;
	printf("%d", ans);
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
#include<vector>
#include<cstdlib>
using namespace std;
 
template <class T> using V = vector<T>;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
const long long INF = 1LL << 60;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 

vll dp(100100);

ll sum(ll n) {
ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
const int MAX = 510000;
const int MOD = 1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void Comuse() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
 
#define comuse Comuse()
 
ll combi(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
 
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}


 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
    ci(n>>k);
  st s;
    ci(s);
  vll A;
  ll count=1;
  FOR(i,1,n-1){
    if(s[i]!=s[i-1]){
      A.push_back(count);
      count=1;
    }
    else{
      count++;
    }
  }

  if(s[n-1]!=s[n-2]){
    A.push_back(count);
    A.push_back(1);
  }
  else{
    A.push_back(count+1);
  }

  ll a=A.sz;
  ll ans=0;
  FOR(i,0,a){
    ans+=A[i]-1;
  }
  ans+=2*k; 
  co(min(n-1,ans))
  }


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;




int A, B, K;
vector<int>v;

int main() {
	cin >> A >> B >> K;
	for (int i = 1; i != 1000; ++i) {
		if (A%i == 0 && B%i == 0) {
			v.push_back(i);
		}
	}
	cout << v[v.size() - K] << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

#define pai 3.14159265358979323846

void Main() {
	long double a, b, x;
	cin >> a >> b >> x;
	long double h = 2 * b - 2 * x / (a * a);
	long double rad;
	if (h > b) {
		long double a2 = 2 * x / (a * b);
		rad = atan2(b, a2);
	} else {
	    rad = atan2(h, a);
	}
	long double kakudo = 180 * rad / pai;
	cout << kakudo << endl;
}

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


Measured memory_bytes: 256
# 縦 2 マス、横 3 マスのマス目が与えられます。
# 上から i 行目、左から j 行目のマスの色は、Cij で表されます。
# このマス目を 180 度回転させたとき、元のマス目と一致するなら YES を、
# そうでないなら NO を出力するプログラムを作成してください。

c1 = gets.chomp
c2 = gets.chomp
puts c1 == c2.reverse ? "YES" : "NO"

Measured memory_bytes: 1788
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
signed main() {
    int A, B;
    cin >> A >> B;

    if (B == 1) {
        cout << 0 << endl;
        return 0;
    }

    int n = 1;
    int result = A;

    while (result < B) {
        n++;
        result += (A - 1);
    }

    cout << n << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::collections::VecDeque;
#[allow(unused_imports)]
use std::cmp;
#[allow(unused_imports)]
use std::collections::HashMap;

#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_variables)]
        #[allow(unused_mut)]
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
 
    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("parse error")
    };
}

fn main() {
    input!{
        s: i32,
        n: i32
    }
    println!("{}", if s > n {"safe"} else {"unsafe"});
}


Measured memory_bytes: 2080
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <climits>
#include <cstring>
#include <string>
#include <set>
#include <bitset>
#include <map>
#include <queue>
#include <stack>
#include <vector>
#define rep(i,m,n) for(i=m;i<=n;i++)
#define mod 1000000007
#define inf 0x3f3f3f3f
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define pi acos(-1.0)
#define pii pair<int,int>
#define sys system("pause")
const int maxn=2e5+10;
const int N=1e3+10;
using namespace std;
ll gcd(ll p,ll q){return q==0?p:gcd(q,p%q);}
ll qpow(ll p,ll q){ll f=1;while(q){if(q&1)f=f*p%mod;p=p*p%mod;q>>=1;}return f;}
int n,m,k,t,h,w,a,b;
ll fac[maxn],inv[maxn];
void init()
{
    fac[0]=1;
    for(int i=1;i<=maxn-10;i++)fac[i]=fac[i-1]*i%mod;
    inv[maxn-10]=qpow(fac[maxn-10],mod-2);
    for(int i=maxn-11;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(int x,int y)
{
    return fac[x]*inv[y]%mod*inv[x-y]%mod;
}
int main()
{
    int i,j;
    init();
    scanf("%d%d%d%d",&h,&w,&a,&b);
    ll ret=C(h+w-2,h-1);
    for(i=0;i<=b-1;i++)ret=(ret-C(i+h-a-1,h-a-1)*C(w-i+a-2,a-1)%mod+mod)%mod;
    printf("%lld\n",ret);
    return 0;
}


Measured memory_bytes: 3328
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n; char s[100001];
  scanf("%s", s);

  int cnt[2][2] = {}; int i = 0;
  while(s[i] != 0){
    cnt[s[i] - '0'][i % 2]++;
    i++;
  }

  int a = cnt[1][0] + cnt[0][1];
  int b = cnt[0][0] + cnt[1][1];
  int ans = (a < b ? a : b);
  printf("%d\n", ans);

  return 0;
}


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

typedef struct point{
    double x;
    double y;
}p;


float solve(int n, p a, p b){
    p s, u, t;
    if(n == 0) return 0;

    s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
    s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
    t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
    t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
    u.x = (t.x - s.x) * cos(M_PI * 1.0 / 3.0) - (t.y - s.y) * sin(M_PI * 1.0 / 3.0) + s.x;
    u.y = (t.x - s.x) * sin(M_PI * 1.0 / 3.0) + (t.y - s.y) * cos(M_PI * 1.0 / 3.0) + s.y;

    solve(n - 1, a, s);
    printf("%.8f %.8f\n", s.x, s.y);
    solve(n - 1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    solve(n - 1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    solve(n - 1, t, b);
}

int main(void){ 
    int n;
    p a, b;
    a.x = 0;
    a.y = 0;
    b.x = 100;
    b.y = 0;

    scanf("%d", &n);
    printf("%.8f %.8f\n", a.x, a.y);
    solve(n, a, b);
    printf("%.8f %.8f\n", b.x, b.y);
    

}


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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int n,k; cin >> n >> k;
    int h[n]; rep(i,0,n) cin >> h[i];
    int dp[n];
    rep(i,0,n) dp[i] = MOD;
    dp[0] = 0;
    rep(i,1,n){
        for(int j = 1; j <= k; j++){
            if(i-j >= 0)
                dp[i] = min(dp[i], dp[i-j] + abs(h[i]-h[i-j]));
        }
    }

    cout << dp[n-1] << "\n";
    
}

Measured memory_bytes: 4360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		long A = Integer.parseInt(tmp[0]);
		long B = Integer.parseInt(tmp[1]);
		long K = Integer.parseInt(tmp[2]);

		List<Long> ans = new ArrayList<Long>();

		for(long i = A;i<A+K;i++){
			if(i>B)break;
			ans.add(i);
		}
		for(long j = B;j>B-K;j--){
			if(j<A)break;
			ans.add(j);
		}

		List<Long> uniq = new ArrayList<Long>(new HashSet<>(ans));

		uniq.sort(null);

		for(int i = 0;i<uniq.size();i++){
			System.out.println(uniq.get(i));
		}
	}

}


Measured memory_bytes: 23124
#include<iostream>
#include<algorithm>
using namespace std;
long dp[66][3],m=1e9+7,n;
int b;
main(){
cin>>n;
dp[60][0]=1;
for(int i=59;i>=0;i--){
b=(n>>i)&1;
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
if(j*2+b>=k){
(dp[i][min(j*2+b-k,2)]+=dp[i+1][j])%=m;
}
}
}
}
cout<<(dp[0][0]+dp[0][1]+dp[0][2])%m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100001];
unordered_map<int, list<int>> l;
ll getans(int src) {
	if (dp[src] != -1) {
		return dp[src];
	}
	bool leaf = 1;
	ll m = 0;
	for (auto p : l[src]) {
		leaf = 0;
		m = max(m, getans(p));
	}
	if (leaf) {
		return dp[src] = 0;
	} else {
		return dp[src] = m + 1;
	}
}

int solve(int n) {
	ll best = 0;
	for (int i = 1; i <= n; i++) {
		best = max(best, getans(i));

	}
	return best;
}

int main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);

	freopen("output.txt", "w", stdout);
#endif
	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int u, v;

		cin >> u >> v;
		l[u].push_back(v);
	}

	memset(dp, -1, sizeof dp);

	cout << solve(n);
	return 0;
}

Measured memory_bytes: 15436
/*"Everything in the universe is balanced. Every disappointment
   you face in life will be balanced by something good for you!
                Keep going, never give up."            */

#include "bits/stdc++.h"
using namespace std;

#define ll long long
const ll N=1e6+9;
const ll mod=1e9+7;

ll a[N];

void solve()
{    
    ll n, m ,W;
    string s,t;
    cin >> s >> t;
    n = s.size() ;
    m = t.size() ;

    vector<vector<int>> dp(n+1, vector<int>(m+1,0)) ;
    for(int i = 1; i<=n; i++){
    	for(int j=1; j<=m; j++){
    			if(s[i-1]==t[j-1]) {
    				dp[i][j] = dp[i-1][j-1]+1;
    			}
    			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]) ;
    			//cout<<dp[i][j]<<" ";
    	}
    	//cout<<"\n";
    }

    string ans = "" ;
/*ll r=n,c=m;
	while(1)
	{
		if(s[r-1]==t[c-1])
		{
			ss+=s[r-1];
			r--;
			c--;
		}
		else
		{
			if(a[r-1][c]>a[r][c-1])
			{
				r--;
			}
			else c--;
		}
		//cout<<r<<" "<<c<<" "<<ss<<nl;
		if(r<1 || c<1)break;
	}*/

    int total = dp[n][m] ,i=n ,j=m;

    while(i&&j) {
    	if(s[i-1]==t[j-1]){
    		ans += s[i-1] ;
    		i--;j--;total--;
    	}
    	else {
    		if(dp[i-1][j]>dp[i][j-1])i--;
    		else j--;
    	}
    }
    reverse(ans.begin(),ans.end());
    cout<< ans; 

}

int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll t=1;
    //pre();
    //cin>>t;
    while(t--)
    {
      solve();
    }  
}


// Xorawar

Measured memory_bytes: 38508
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

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

	ll n, m;
	cin >> n >> m;

	vll y; //約数列挙
	for(ll i = 1; i * i <= m; i++){
		if(m % i == 0) y.push_back(i);
	}
	ll len = y.size();
	REP(i, len) y.push_back(m / y[i]);
	ll res = 0;
	for(auto v : y){
		if(m / v >= n) res = max(res, v);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
def longest():
    alps1 = raw_input()
    alps2 = raw_input()
    
    x, y = len(alps1), len(alps2)
    k = [0 for i in range(y+1)]
    for i in range(x):
        e1 = alps1[i]
        l = k+[]
        for j in range(y):
            if e1 == alps2[j]:
                k[j+1] = l[j] + 1
            elif k[j+1] < k[j]:
                k[j+1] = k[j]
 
    return k[-1]
    
n = input()
for i in range(n):
    print longest()

Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define  lalalala    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define  endl        "\n";
#define  pi          2*acos(0.0)
#define  inf         LONG_MAX
#define  size        1e5

int main(){
    lalalala;
    //testCase
    int t;
    cin>>t;
    if(t<30){
      cout<<"No"<<endl;
      }
    else{
      cout<<"Yes"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3648
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 200007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   int n, a[N] = {}, mx1 = 0, mx2 = 0, ctr1 = 0, ctr2 = 0;
   cin >> n;
   for (int i = 0; i < n; i++)
      cin >> a[i];

   for (int i = 0; i < n; i++)
   {
      if (a[i] >= mx1)
      {
         mx2 = mx1;
         mx1 = a[i];
      }
      else if (a[i] >= mx2)
         mx2 = a[i];
   }
   for (int i = 0; i < n; i++)
   {
      if (a[i] != mx1)
         cout << mx1 << endl;
      else
         cout << mx2 << endl;
   }
   return 0;
}


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

int main(){
	int a, b;
  	cin >> a >> b;
  
  	int ans = (a-1 + b-1 - 1) / (a-1);
    cout << ans << endl;
}

Measured memory_bytes: 3672
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner scan=new Scanner(System.in);
        int n=scan.nextInt();
        int b, f, r, v;
        int[][][] rooms=new int[4][3][10];
        
        for(int i=0; i<n; i++){
            b=scan.nextInt();
            f=scan.nextInt();
            r=scan.nextInt();
            v=scan.nextInt();
            rooms[b-1][f-1][r-1]+=v;
        }
        for(int i=0; i<4; i++){
            for(int j=0; j<3; j++){
                for(int k=0; k<10; k++)
                    System.out.print(" "+rooms[i][j][k]);
                System.out.println();
            }
            if(i!=3)System.out.println("####################");
        }
    }
}


Measured memory_bytes: 29136
#include <iostream>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr ll MOD = 1e9 + 7;

ll dp[100010][2]; // dp[i][j] := check first i digits, (j==0) ai+bi=L, (j==1) ai+bi<L

int main() {
    string L;
    cin >> L;
    int N = L.size();
    dp[0][0] = 1;
    REP(i,N){
        if(L[i]=='1'){
            dp[i+1][0] = (dp[i+1][0] + dp[i][0] * 2)%MOD; // (ai,bi) = (1,0) or (0,1)
            dp[i+1][1] = (dp[i+1][1] + dp[i][0] + dp[i][1] * 3)%MOD; // (ai,bi) = (0,0) or (1,0) or (0,1)
        } else {
            dp[i+1][0] = (dp[i+1][0] + dp[i][0])%MOD; // (ai,bi) = (0,0)
            dp[i+1][1] = (dp[i+1][1] + dp[i][1] * 3)%MOD; // (ai,bi) = (0,0) or (1,0) or (0,1)
        }
    }
    cout << (dp[N][0] + dp[N][1]) % MOD << endl;
    return 0;
}

Measured memory_bytes: 2048