akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;
	int to[100001], ne[100001], he[100001] = {};
	rep1(i, M) {
		int u, v;
		cin >> u >> v;
		to[i] = v;
		ne[i] = he[u];
		he[u] = i;
	}
	int S, T;
	cin >> S >> T;

	int D[300004];
	rep(i, 300004) D[i] = 1e9;
	D[3 * S] = 0;

	queue<ll> que;
	que.push(3 * S);
	while (que.size()) {
		ll p = que.front();
		que.pop();
		int i = p & ((1 << 20) - 1);
		int d = p >> 20;
		if (D[i] < d) continue;
		int i2 = i / 3;
		d++;
		for (int j = he[i2]; j; j = ne[j]) {
			int j2 = to[j] * 3 + (i + 1) % 3;
			if (D[j2] > d) {
				D[j2] = d;
				que.push(((ll)d << 20) + j2);
			}
		}
	}

	if (D[3 * T] == 1e9) co(-1);
	else co(D[3 * T] / 3);

	Would you please return 0;
}

Measured memory_bytes: 3072
#include <stdio.h>


int main()
{
	int x, y;
	int t;

	for (;;) {
		scanf("%d%d", &x, &y);
		if (x == 0 && y == 0) break;
		if (x > y) t = x, x = y, y = t;
		printf("%d %d\n", x, y);
	}
	return 0;
}



Measured memory_bytes: 2028
n,x = map(int,input().split())
a,p = [1],[1]
for i in range(n):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def calc(n,x):
    if n==0:
        return 1 if x>0 else 0
    else:
        if x>a[n-1]+1:
            return p[n-1]+1+calc(n-1,x-2-a[n-1])
        else:
            return calc(n-1,x-1)
print(calc(n,x))

Measured memory_bytes: 61856
def main():
    n = int(input())
    ttn = [[-1] * n for _ in range(n)]  # Testimonies.
    for i in range(n):
        a = int(input())
        for j in range(a):
            x, y = [int(z) for z in input().split()]
            x -= 1
            ttn[i][x] = y  # i says that x is honest guy or not.
    ans = set()
    for i in range(2 ** n):
        tmp = [i >> j & 1 for j in range(n)]  # Bit-shift.
        possible = True
        for k, tm in enumerate(tmp):
            if not possible:
                break
            if tm:
                for l, tt in enumerate(ttn[k]):
                    if tt == -1:
                        continue
                    if tt != tmp[l]:
                        possible = False
                        break
        if possible:
            ans.add(bin(i).count('1'))
    return max(ans)


if __name__ == '__main__':
    print(main())


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

C0,C1,C2,C3=0,0,0,0

for i in range(N):
    S = input()
    if S=="AC":
        C0 +=1
    elif S=="WA":
        C1 +=1
    elif S=="TLE":
        C2 +=1
    else:
        C3+=1

print("AC x "+ str(C0))
print("WA x "+ str(C1))
print("TLE x "+ str(C2))
print("RE x "+ str(C3))

Measured memory_bytes: 74684
import std.array;
import std.conv;
import std.string;
import std.algorithm;
import std.stdio;

void main() {
	int n = readln.chomp.to!int;
	auto a = readln.chomp.split(' ').map!(to!int).array;
	auto m = reduce!max(a);
	int count;
	bool top = false;

	while (m > 0) {
		foreach (ref e;a) {
			if (top) {
				if (e == m) {
					--e;
				} else {
					top = false;
				}
			} else {
				if (e == m) {
					top = true;
					++count;
					--e;
				}
			}
		}

		top = false;
		--m;
	}

	count.writeln;
}


Measured memory_bytes: 2716
use std::cmp::max;
use std::mem::swap;
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()));
        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)*}
    };
}

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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
    n: usize,
    a: [i64; n]
    }
    let mut dp = vec![a[0], -a[0]];
    for i in 1..n - 1 {
        let mut prev = vec![0; 2];
        swap(&mut dp, &mut prev);
        dp[0] = max(prev[0] + a[i], prev[1] - a[i]);
        dp[1] = max(prev[0] - a[i], prev[1] + a[i]);
    }
    let ans = max(dp[0] + a[n - 1], dp[1] - a[n - 1]);
    println!("{}", ans);

}



Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n;
    cin >> n;
    long long int a[n],b[n];
    for(int i=0;i<n;i++){
        cin >> a[i] >> b[i];
    }
    sort(a,a+n);
    sort(b,b+n);
    if(n%2 ==1){
        cout << b[(n-1)/2]-a[(n-1)/2] +1 << endl;
        return 0;
    }else{
        cout << (b[n/2-1]+b[n/2])-(a[n/2-1]+a[n/2])+1 << endl;
        return 0;
    }
    return 0;

}

Measured memory_bytes: 6724
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
using namespace std;

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

typedef long long ll;

const ll INF = ll(1e18) + 1;

void Main()
{
	ll n, k, sum = 0; cin >> n >> k;
	priority_queue<ll> h;
	rep(i, n) {
		ll temp;
		cin >> temp;
		h.push(temp);
		sum += temp;
	}
	if (n >= k) {
		rep(i, k) {
			ll temp = h.top();
			sum -= temp;
			h.pop();
		}
	}
	else {
		sum = 0;
	}
	
	cout << sum << endl;

}

int main() {
	Main();
	return 0;
}

Measured memory_bytes: 2420
/*input
100000 99999
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout << (#x) << " is " << (x) << endl
#define debug cout << "hi" << endl

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;

const int MOD = 1e9 + 7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b; cin >> a >> b;
    cout << (a * b)/__gcd(a, b);

    return 0;
}

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

int main() {
    int n, k, cnt = 0;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
        int h;
        cin >> h;
        if (h >= k) cnt++;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld a, v, b, w, t;
  cin >> a >> v >> b >> w >> t;
  cout << ((v - w) * t >= abs(a - b) ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 3644
void main() {
    int n = readln.chomp.to!int;
    int[] a1 = readln.split.to!(int[]);
    int[] a2 = readln.split.to!(int[]);

    int candy;
    foreach (i; 0 .. n) {
        candy = max(candy, a1[0..i+1].sum+a2[i..$].sum);
    }

    candy.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
import sys
N=int(input())
a=N//1.08
c=a+1
d=a-1
b=a*1.08
b=int(b)
if b==N:
  print(int(a))
  sys.exit()
elif int(c*1.08)==N:
  print(int(c))
elif int(d*1.08)==N:
  print(int(d))
else:
  print(":(")

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1e9+1)
//#define INF (1LL<<59)


//verified AOJ GRL_1
#define MAX_V 10000
struct edge{int to,cost,p;};
vector<edge> G[MAX_V];

void dijkstra(int s, vector<int> &d){
	priority_queue< pii,vector<pii>,greater<pii> > que;
	rep( i,d.size() )d[i]=INF;
	d[s] = 0;
	que.push( pii(0,s) );
	
	while( que.size() ){
		pii p=que.top();
		que.pop();
		
		int v=p.second;
		if(d[v]<p.first)continue;
		
		rep(i,G[v].size()){
			edge e=G[v][i];
			if(d[e.to]>d[v]+e.cost){
				d[e.to]=d[v]+e.cost;
				que.push(pii(d[e.to],e.to));
			}
		}
	}
}

int main(){
	int v,e;
	while(cin>>v>>e&&(v||e)){
		rep(i,MAX_V)G[i].clear();
		rep(i,e){
			int u,v,d,c;
			cin>>u>>v>>d>>c;
			u--,v--;
			G[u].pb(edge{v,d,c});
			G[v].pb(edge{u,d,c});
		}
		
		vector<int> d(v);
		dijkstra(0,d);
		
		vector<pii> vec(v);
		rep(i,d.size()){
			vec[i] = pii(d[i],i);
		}
		sort(all(vec));

		
		
		vector<pii> dir(v,pii(INF,INF));
		dir[0] = pii(0,0);
		
		int sum=0;
		rep(i,vec.size()){
			int to = vec[i].second;
			sum+=dir[to].second;
			for(auto &e:G[to]){
				dir[e.to] = min(dir[e.to],pii(d[to]+e.cost,e.p));
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 4976
#include <iostream>
#include <string>
using namespace std;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    if(n / 100 == 9) {
        ans += 100;
        n -= 900;
    } else {
        ans += 900;
        n -= 100;
    } 

    if(n / 10 == 9) {
        ans += 10;
        n -= 90;
    } else {
        ans += 90;
        n -= 10;
    }

    if(n == 9){
        ans++;
    } else {
        ans += 9;
    }
    cout << ans << endl;
    return 0;
}

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

Measured memory_bytes: 256
let ic c = int_of_char c - int_of_char '0'

let () =
  let n = Scanf.sscanf (input_line stdin) "%d" (fun a -> a) in
  let s = Scanf.sscanf (input_line stdin) "%s" (fun a -> a) in
  let ans = String.map (fun c ->
                let c' = ((int_of_char c - int_of_char 'A' + n) mod 26) + int_of_char 'A'
                in char_of_int c'
              ) s in
  print_string ans;
  print_newline ()


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define show(x) for(auto i: x){cout << i << " ";}
typedef long long ll;

int n;
vector<string> dic;
void fds(int bitinfo, string s){
    if (s.size() == n){
        dic.push_back(s);
        return;
    }
    for (int i = 1; i <= n; i++)
    {
        if (!((bitinfo >> (i-1)) & 1)){
          string t = s + to_string(i);
          int nextbit = bitinfo + (1 << (i-1));
          fds(nextbit, t);
        } 
    }
}

void perm(){
    vector<int> v(n);
    iota(v.begin(), v.end(), 1);
    do {
        string s;
        for (auto x : v) s += to_string(x);
        dic.push_back(s);
    } while (next_permutation(v.begin(), v.end()) );
}


int main()
{
    cin >> n;
    //fds(0, "");
    perm();
    sort(dic.begin(), dic.end());
    //show(dic);
    string s,t;
    rep(i, n) {int tmp; cin >> tmp; s += to_string(tmp);}
    rep(i, n) {int tmp; cin >> tmp; t += to_string(tmp);}

    int s_itr, t_itr;
    for (int i = 0; i < dic.size(); i++)
    {
        if (s == dic[i]) s_itr = i;
        if (t == dic[i]) t_itr = i;
    }
    
    cout << abs(s_itr - t_itr) << endl;

}


Measured memory_bytes: 2424
import java.util.Scanner;;
public class Main {
	public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int a[];
	a=new int [5];
	int s=0;
	for(int i=0;i<5;i++){
		 a[i]= sc.nextInt();
	}
	for(int i=0;i<5;i++){
		if(a[i]<40){
			s+=40;
		}
		else{s+=a[i];}
	}
	System.out.println(s/5);
}
	}

Measured memory_bytes: 26244
import java.util.*;
import java.lang.*;
import java.io.*;

class Main
{
	static int maxW;

	static int KS(int score[], int weight[], int i, int W)
	{
		if(i==0)
			return 0;

		int temp = KS(score, weight, i-1, W);

		if((W+weight[i-1])<=maxW)
		{
			temp = Math.max(temp, score[i-1]+KS(score, weight, i-1, W+weight[i-1]));
		}
		return temp;
	}


	public static void main(String args[])
	{
		Scanner scan=new Scanner(System.in);
		int n=scan.nextInt();
		int w=scan.nextInt();

		int score[]=new int[n];
		int weight[]=new int[n];
		for(int i=0;i<n;i++)
		{
			weight[i]=scan.nextInt();
			score[i]=scan.nextInt();
		}
		maxW=w;
		//int ans = KS(score, weight, n, 0);
		long dp[][]=new long[n+1][maxW+1];

		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=maxW;j++)
			{
				dp[i][j]=dp[i-1][j];
				if((j-weight[i-1])>=0)
				{
					dp[i][j] = Math.max(dp[i][j], score[i-1]+dp[i-1][j-weight[i-1]]);
				}
			}
		}
		
		System.out.println(dp[n][maxW]);

	}
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

int main(void) {
    string s, t;
    int a, b;
    cin >> s >> t;
    cin >> a >> b;
    string u;
    cin >> u;
    if(u == s) {
        cout << a - 1 << " " << b << endl;
    }else {
        cout << a  << " " << b - 1<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define pob pop_back
#define ff first
#define ss second
#define endl "\n"
#define all(a) a.begin(),a.end()
#define int long long
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
/* 	1) order_of_key (k) : Number of items strictly smaller than k .
	2) find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace __gnu_pbds;
using namespace std;
using LD = long double;

const int maxs = 1e6+1;
const int mod = 1e9+7;
const int INF = 1e18;
int row[8] = {1,1,0,-1,-1,-1,0,1};
int col[8] = {0,-1,-1,-1,0,1,1,1};

using pii = pair<int, int>;

void solve() {
	int S;
	cin >> S;
	if(S <= 2) {
		cout << 0 << endl;
		return;
	}
	vector<int> DP(S + 1);
	DP[0] = 1;
	for(int i = 3; i <= S; i++) {
		for(int j = i; j >= 3; j--) {
			DP[i] += DP[i - j];
			DP[i] %= mod;
		}
	}
	cout << DP[S] << endl;
}
 
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int t = 1,i = 1;
    //cin >> t;
    while(t--) {
        //cout << "Case #" << i << ": ";
        solve();
        //i++;
    }
    return 0;
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static string InputPattern = "InputX";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 4");
            WillReturn.Add("4 10");
            WillReturn.Add("3 4");
            //11
            //1,3個目の物を選ぶと良いです
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("4 6");
            WillReturn.Add("2 1");
            WillReturn.Add("3 7");
            WillReturn.Add("4 10");
            WillReturn.Add("3 6");
            //13
            //2,4個目の物を選ぶと良いです
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("4 10");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            WillReturn.Add("1 100");
            //400
            //すべての物が選べます
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("4 1");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            WillReturn.Add("10 100");
            //0
            //1個も物が選べません
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    struct NimotuDef
    {
        internal int W;
        internal int V;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();

        int[] wkArr = { };
        Action<string> SplitAct = pStr =>
            wkArr = pStr.Split(' ').Select(X => int.Parse(X)).ToArray();

        SplitAct(InputList[0]);
        int W = wkArr[1];

        var NimotuList = new List<NimotuDef>();
        foreach (string EachStr in InputList.Skip(1)) {
            SplitAct(EachStr);
            NimotuList.Add(new NimotuDef() { W = wkArr[0], V = wkArr[1] });
        }

        //最大の価値[重さ合計]なDP表
        var DPDict = new Dictionary<long, int>();
        DPDict[0] = 0;

        foreach (NimotuDef EachNimotu in NimotuList) {
            foreach (int EachKey in DPDict.Keys.OrderByDescending(A => A).ToArray()) {
                long NewKey = EachKey + EachNimotu.W;
                if (NewKey > W) continue;

                int NewVal = DPDict[EachKey] + EachNimotu.V;

                if (DPDict.ContainsKey(NewKey)) {
                    if (DPDict[NewKey] < NewVal) {
                        DPDict[NewKey] = NewVal;
                    }
                }
                else DPDict[NewKey] = NewVal;
            }
        }
        Console.WriteLine(DPDict.Values.Max());
    }
}


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

int main(){
    double w,h,x,y; cin>>w>>h>>x>>y;
  double ans = w*h/2.0;
    if(w==2*x&&h==2*y){
        cout << ans <<" "<< 1<< endl;
    }
    else{
        cout << ans <<" "<< 0<< endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

LL k;

const int MAXN = 55;
LL a[MAXN];

int main() {
    GLL(k);

    LL q = k / 50;
    LL r = k % 50;

    FORN(i, 50) {
        a[i] = q + 49;
    }

    FORN(i, r) {
        a[i] += 50 - r + 1;
    }

    for (int i = r; i < 50; i++) {
        a[i] -= r;
    }

    cout << 50 << endl;

    FORN(i, 50) {
        cout << a[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace AtCoder.ABC10
{
    static class Program
    {
        static void Main(string[] args)
        {
            var q = new Quest(Console.In, Console.Out);

            new C086().Solve(q);
        }
    }
  
      public class C086 : ISolver
    {
        public void Solve(Quest q)
        {
            int n = int.Parse(q.ParseLine());

            var points = Enumerable.Range(1, n)
                .Select(_ => q.ParseLine(' '))
                .Select(x => x.Select(s => int.Parse(s)).ToArray())
                .Select(p => new Point(p[1], p[2], p[0]))
                .ToArray();

            string got = Solve(points)
                ? "Yes"
                : "No";

            q.Answer(got);
        }


        public bool Solve(Point[] plans)
        {
            var from = new Point(0, 0, 0);

            foreach (var to in plans)
            {
                if (!CanReach(from, to))
                {
                    return false;
                }

                from = to;
            }

            return true;
        }

        private bool CanReach(Point from, Point to)
        {
            int dt = to.T - from.T;
            int dx = Math.Abs(to.X - from.X);
            int dy = Math.Abs(to.Y - from.Y);

            int dp = dx + dy;

            if (dt < dp)
            {
                return false;
            }

            return dp % 2 == dt % 2;
        }

        public struct Point
        {
            public int X;
            public int Y;
            public int T;
            public Point(int x, int y, int t)
            {
                X = x;
                Y = y;
                T = t;
            }
            public override string ToString(){
                return $"{T},{X},{Y}";
            }
        }
    }

  
    #region
    public class Quest
    {
        private readonly System.IO.TextReader _reader;
        private readonly System.IO.TextWriter _writer;

        public Quest(System.IO.TextReader reader, System.IO.TextWriter writer)
        {
            _reader = reader;
            _writer = writer;
        }

        public void Answer(object answer)
        {
            _writer.WriteLine(answer);
        }

        public string ParseLine()
        {
            return _reader.ReadLine();
        }

        public string[] ParseLine(char sep)
        {
            return _reader.ReadLine().Split(new char[] { sep });
        }
    }


    public interface ISolver
    {
        void Solve(Quest q);
    }

    #endregion
  
}


Measured memory_bytes: 21304
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define end "\n"
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define pii pair < int, int >
typedef vector<int> vi;
typedef  long long ll;
const int inf = int(1e9);
const int mod =1e9+7;
const int N = (int)2e5 + 5;


void solve(){
	char c;
	cin>>c;
	if(c=='T')cout<<'A';
	if(c=='A')cout<<'T';
	if(c=='G')cout<<'C';
	if(c=='C')cout<<'G';


}
int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

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

def main():
    M = int(10**9)

    S = int(input())

    if S == M**2:
        print(0, 0, M, 0, 0, M)
    else:
        m = S%M

        x2 = 1
        y1 = M - m
        x1 = M
        y2 = (S + (M - m))//M

        print(0, 0, x1, y1, x2, y2)
 


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include<stdio.h>
int main(){
int N,i,m=0;
int A[100000];
scanf("%d",&N);
for(i=0;i<N;i++){
    scanf("%d",&A[i]);
    if(A[i]%2!=0)m++;}
if(m%2==0)printf("YES");
else printf("NO");
return 0;}



Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <climits>

using namespace std;

int main() {
    int n, k;  cin >> n >> k;
    long long *h = new long long[n];
    for (int i = 0; i < n; i++)
        cin >> h[i];
    sort(h, h+n);

    long long ans = LLONG_MAX;
    for (int i = 0; i+k-1< n; i++) {
        ans = min(ans, h[i+k-1]-h[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#define MOD_TYPE 1

#pragma region Macros
#include <bits/stdc++.h>
using namespace std;

#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
using Int = boost::multiprecision::cpp_int;
using lld = boost::multiprecision::cpp_dec_float_100;

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pld = pair<ld, ld>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
//constexpr ll MOD = 1;
constexpr int INF = (int)1e9 + 10;
constexpr ll LINF = (ll)4e18;
constexpr double PI = acos(-1.0);
constexpr double EPS = 1e-11;
constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0};
constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0};

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define REPI(i, m, n) for (int i = m; i < (int)(n); ++i)
#define repi(i, n) REPI(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << "\n"
#define Yes(n) cout << ((n) ? "Yes" : "No") << "\n"
#define possible(n) cout << ((n) ? "possible" : "impossible") << "\n"
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n"
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << "\n"
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << "\n";

inline void init_main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(30) << setiosflags(ios::fixed);
}
template <typename T>
inline bool chmin(T &a, T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
inline bool chmax(T &a, T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
inline ll CEIL(ll a, ll b)
{
  return (a + b - 1) / b;
}
template <typename A, size_t N, typename T>
inline void Fill(A (&array)[N], const T &val)
{
  fill((T *)array, (T *)(array + N), val);
}
template <typename T, typename U>
constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept
{
  is >> p.first >> p.second;
  return is;
}
template <typename T, typename U>
constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept
{
  os << p.first << " " << p.second;
  return os;
}
#pragma endregion

void solve()
{
  int n;
  cin >> n;
  vector<ll> l(n);
  rep(i, n) cin >> l[i];
  int cnt = 0;
  rep(i, n) REP(j, i + 1, n) REP(k, j + 1, n)
  {
    vector<ll> v = {l[i], l[j], l[k]};
    sort(all(v));
    if (v[0] != v[1] and v[1] != v[2] and v[0] + v[1] > v[2])
      cnt++;
  }
  cout << cnt << "\n";
}

int main()
{
  init_main();
  solve();
}


Measured memory_bytes: 3600
/*
* Author : MaxSally
*/
/********   All Required Header Files ********/
#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and typedef Constants *******/
#define SCD(t) scanf("%d",&t)
#define SCLD(t) scanf("%ld",&t)
#define SCLLD(t) scanf("%lld",&t)
#define SCC(t) scanf("%c",&t)
#define SCS(t) scanf("%s",t)
#define SCF(t) scanf("%f",&t)
#define SCLF(t) scanf("%lf",&t)
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i <= k ; ++i)
#define rrep(i, j, k) for (int i = j; i >= k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define mp make_pair
#define pb push_back
#define inf (int) (1e9 + 7)
#define epsi 1e-9
#define PI 3.1415926535897932384626433832795
#define mod 1000000007
#define read(type) readInt<type>()
#define io ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define left tuyiuoi
#define right fgjhk
#define ss second
#define ff first
#define debug(a) cout << #a << ": " << a << endl
#define debuga1(a, l, r) rep(i, l, r) cout << a[i] << " "; cout << endl
#define Flag(n) cout << "here " << n << endl
const double pi=acos(-1.0);
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<ll, ll> pll;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<pll> vpll;
typedef vector<vi> vvi;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

const int N = 100005;
int n;
int a[N];
pii b[N];

int main(){
    io;
    //freopen("input.txt", "r", stdin);
    cin >> n;
    rep(i, 0, n - 1){
        cin >> a[i];
        b[i].ff = a[i];
        b[i].ss = i;
    }
    sort(b, b + n);
    int cnt = 0;
    rep(i, 0, n - 1){
        if((i + b[i].ss) & 1){
            cnt++;
        }
    }
    cout << cnt/2;
    return 0;
}


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

int main() {
  string s;
  int a = 0;
  cin >> s;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == '+'){
      a++;
    }
    else{
      a--;
    }
  }
  cout << a <<endl;
}


Measured memory_bytes: 256
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << 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; }

void solve() {
	int n, k; cin >> n >> k;
    int ans = 0;
    if(k == 0) {
        cout << n * n << endl;
        return;
    }
    for(int b = k + 1; b <= n; ++ b) {
        ans += (b - k) * (n / b) + (n % b < k ? 0 : n % b - k + 1);
        //cerr << (b - k) * (n / b) + (n % b < k ? 0 : n % b - k + 1) << endl;
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
n = int(input())

r = [[0, 0]] * n
for i in range(n):
   x, l = map(int, input().split())
   r[i] = [x+l, x-l]
r.sort()

cur = -1000000000
ans = 0
for i in range(n):
   if (cur <= r[i][1]):
      ans += 1
      cur = r[i][0]

print(ans)


Measured memory_bytes: 20068
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int INF = 1001001001;

int main(){
  int n,m; cin >> n >> m;
  vector<vector<int>> to(n,vector<int>(0));
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to.at(a).push_back(b);
    to.at(b).push_back(a);
  }
  queue<vector<int>> q;
  int ans = 0;
  q.push({0});
  while(q.size()){
    auto v = q.front(); q.pop();
    for(auto x:to.at(v.at(v.size()-1))){
      bool flag = 0;
      for(auto i:v){
        if(i==x) flag = 1;
      }
      if(flag) continue;
      auto w = v;
      w.push_back(x);
      q.push(w);
    }
    if(v.size() == n) ans++;
  }
  cout << ans << endl;

}

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



int main(void) {
    ll A;
    string B;
    cin >> A >> B;

    ll i,d,dd;

    i = B[0] - '0';
    d = B[2] - '0';
    dd = B[3] - '0';
    int AA,AAA;
    ll ans;
    if(A==0 || (i==0 && d==0 && dd==0))
      cout << 0 << endl;
    else{
      ans = (A*(i*100+d*10+dd))/100;


      cout <<ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    set<int> st;
    rep(i, M) {
        int A;
        cin >> A;
        st.insert(A);
    }

    vector<ll> dp(N + 2);
    dp[0] = 1;
    rep(i, N) {
        if (st.count(i + 1) == 0) {
            dp[i + 1] += dp[i];
            dp[i + 1] %= MOD;
        }
        if (st.count(i + 2) == 0) {
            dp[i + 2] += dp[i];
            dp[i + 2] %= MOD;
        }
    }

    cout << dp[N] % MOD << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

#define x first
#define y second

const int N = 1e5 + 10;

int n;
char s[N];
int p[N];

void impossible() {
	cout << -1 << endl;
	exit(EXIT_SUCCESS);
}

int main() {
	scanf("%s", s + 1);
	n = strlen(s + 1);
	s[0] = '0';

	if (s[1] == '0') impossible();
	if (s[n] == '1') impossible();

	for (int i = 0; i <= n; i++) {
		if (s[i] != s[n - i]) impossible();
	}

	int at = 1;
	for (int i = 2; i <= n; i++) {
		if (s[i - 1] == '0') p[i] = at;
		else {
			p[at] = i;
			at = i;
		}
	}

	for (int i = 1; i <= n; i++) {
		if (p[i]) printf("%d %d\n", i, p[i]);
	}

	return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

lli a[510][510];

signed main(){

	lli h,w,d;
	cin>>h>>w>>d;
	map<lli,pair<lli,lli>> dd;

	REP(i,0,h)REP(j,0,w){
		cin>>a[i][j];
		a[i][j]--;
		dd[a[i][j]] = make_pair(i,j);
	}
	lli sum[200100];
	REP(i,0,200100)sum[i]=0;
	REP(i,0,d){
		for(lli j=0;j<h*w;j+=d){
			if(j==0)sum[j] = 0;
			else{
				if(i+j-d<0)continue;
				pair<lli,lli> x,y;
				x = dd[i+j];
				y = dd[i+j-d];
				if(DEBUG)cout<<"x="<<x.first<<","<<x.second<<"y="<<y.first<<","<<y.second<<endl;
				sum[i+j] += sum[i+j-d] + abs(x.first-y.first)+abs(x.second-y.second);
			}
		}
	}
	lli q;
	cin>>q;
	REP(i,0,q){
		lli a,b;
		cin>>a>>b;
		a--,b--;
		cout<<sum[b]-sum[a]<<endl;
	}

	return 0;
 
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main(){
    int N;
    int A,B;
  	cin>>N>>A>>B;
    string S;
    cin>>S;
    int sum = A+B; 
    int cnt =0;
    int cntf =0;
    for (int i = 0; i < N; i++)//A
    {
       if (S[i] == 'a' && cnt < sum)
       {
          cout<<"Yes"<<endl;
          cnt++; 
       }else if (S[i] == 'b' && cntf < B && cnt < sum)//B
       {
         cout<<"Yes"<<endl;
          cnt++;cntf++;
       }else{
         cout<<"No"<<endl;
       }
       
       
    }
    
    
}

Measured memory_bytes: 896
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector
;
#define vvec(s) vector<vector
> ;
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(bool x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    char a;
    cin>>a;
    if(a-'A'<32){
        out("A");
    }
    else out("a");
}

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

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(lol i=0;i<lol(n);i++)
#define REPD(i,n) for(lol i=n-1;i>=0;i--)
#define FOR(i,a,b) for(lol i=a;i<=lol(b);i++)
#define FORD(i,a,b) for(lol i=a;i>=lol(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) lol(x.size()) //sizeをsize_tからllに直しておく
//定数
#define PI 3.1415926535897932385 //pi
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//最大値最小値
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int gcd3(int a, int b, int c)
{
    return gcd(gcd(a, b), c);
}

int main()
{
    lol result{0};
    lol k; cin >> k;
    FOR(i, 1, k)
    {
        FOR(j, i, k)
        {
            FOR(h, j, k)
            {
                //cout << "i" << i << " j" << j << " h" << h << endl;
                //cout << gcd3(i, j, h) << endl;
                if(i == j && j == h)
                {
                    result += gcd3(i, j, h);
                    //cout << result << endl;
                }
                else if(i == j || j == h)
                    result += 3*gcd3(i, j, h);
                else
                    result += 6*gcd3(i, j, h);
            }
        }
    }

    cout << result << endl;
    return 0;
}

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

#define int long long

typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int N,M;
int G[10][10];

int ans;
bool used[10];
void dfs(int v,int cnt){
    if(cnt==N){
        ans++;
        return;
    }
    used[v]=1;
    rep(i,N)if(!used[i]&&G[v][i])dfs(i,cnt+1);
    used[v]=0;
}

signed main(){
    cin>>N>>M;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a][b]=G[b][a]=1;
    }

    dfs(0,1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<iomanip>
using namespace std;

#define ll long long
#define dd double

ll  mod =100000009;

ll arr[10000001];



int main(){
    
    ll x;
    cin>>x;
    ll res=1;
    
    for(int i=2;i<=x;i++){
        ll j=i;
        while(j<=x){
            j=j*i;
            if(x >= j && res<j){
                res=j;
            }
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 256
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

K=gets.to_i
if K.even?
    puts (K/2)**2
else
    puts (K/2)*(K/2+1)
end

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

using namespace std;

const int maxn = 1e5 + 10;
int a[maxn];

int main()
{
    int n, e = 0, o = 0;
    cin >> n;

    for (int i = 0; i < n; i ++)
    {
        cin >> a[i];
        if (a[i] % 2 == 0)
        {
            e ++;
        }
        else
        {
            o ++;
        }
    }
    if (o % 2 == 0)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    return 0;
}


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

int main()
{
  
  int coins[17];

  for(int i = 0; i < 17; ++i){
    coins[i] = (i+1)*(i+1);
  }

  long long dp[300][17] = {{0,}};

  for(int i = 0; i < 17; ++i){
    dp[coins[i]][i] = 1;
  }
  for(int i = 0; i < 300; ++i){
    for(int j = 0; j < 17; ++j){
      for(int k = j; k < 17; ++k){
        if(i+coins[k]<300){
          dp[i+coins[k]][k] += dp[i][j];
        }
      }
    }
  }

  int p;
  while(cin>>p){
    if(p==0)break;
    long long ret = 0;
    for(int i = 0; i < 17; ++i){
      ret += dp[p][i];
    }
    cout << ret << endl;
  }
  return 0;
}

Measured memory_bytes: 1204
while True:
    R, N = map(int, input().split())
    if not (R | N):
        break
    geta = 20
    buildings = [0] * (geta * 2)
    for _ in range(N):
        xl, xr, h = map(int, input().split())
        for i in range(xl + geta, xr + geta):
            buildings[i] = max(buildings[i], h)

    left, right = 0, 20
    while right - left > 1e-4:
        mid = (left + right) / 2
        flag = True
        for i in range(-R + geta, R + geta):
            if i < geta:
                y = pow(R * R - (i - geta + 1) * (i - geta + 1), 0.5)
                flag &= buildings[i] >= y - R + mid
            else:
                y = pow(R * R - (i - geta) * (i - geta), 0.5)
                flag &= buildings[i] >= y - R + mid
        if flag:
            left = mid
        else:
            right = mid
    print("{:.20f}".format(left))

Measured memory_bytes: 7652
//OM
#include <cmath>
#include <cstdio>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <utility>
#include <sstream>
#include <algorithm>
using  namespace  std;

#define  x first
#define  y second
#define  pb push_back
#define  mp make_pair
#define  PI (acos(-1.0))
#define  mem(a,b) memset(a,b,sizeof(a))
#define  Sort(x) sort(x.begin(),x.end())
#define  FOR(i, b, e) for(int i = b; i <= (int)(e); i++)
#define  FORR(i, b, e) for(int i = b; i >=(int)(e); i--)
#define  FORI(i, s) for (__typeof ((s).end ()) i = (s).begin (); i != (s).end (); ++i)
#define  pr(x) cout<<x<<"\n"
#define  prs(x) cout<<x<<" "
#define  pr2(x,y) cout<<x<<" "<<y<<"\n"
#define  pr3(x,y,z) cout<<x<<" "<<y<<" "<<z<<"\n"
#define  ppr(a) cout<<a.x<<" "<<a.y<<"\n"

typedef  long long ll;
typedef  pair <int, int> pii;
typedef  pair <double , double> pdd;
typedef  vector <int> vi;
typedef  vector <pii> vpii;

//int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};
//int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction

#define  EPS 1e-9
#define  MAX 100007
char s[MAX];
int main()
{
    int T,n;
    scanf("%s",&s);
    int len=strlen(s);
    string a;
    int j=-1;
    int ans=1;
    int an=0,as=0,ae=0,aw=0;
    FOR(i,0,len-1)
    {
        if(j>=0&&a[j]==s[i])
        {
            continue;
        }
        a=a+s[i];
        j++;
        if(s[i]=='N')an++;
        if(s[i]=='S')as++;
        if(s[i]=='E')ae++;
        if(s[i]=='W')aw++;
    }

    if(an>=1&&as==0)ans=0;
    if(an==0&&as>=1)ans=0;
    if(ae>=1&&aw==0)ans=0;
    if(ae==0&&aw>=1)ans=0;

    if(ans)printf("Yes");
    else printf("No");

    return 0;
}



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

class Shop implements Comparable<Shop>{
    long price;
    int stock;
    public Shop(long price, int stock){
        this.price = price;
        this.stock = stock;
    }

    public int compareTo(Shop o) {
        return Long.compare(this.price, o.price);
    }

    public String toString(){
        return "["+price+","+stock+"]";
    }
}

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        LinkedList<Shop> shops = new LinkedList<>();
        for(int n=0; n<N; n++) shops.add(new Shop(sc.nextLong(), sc.nextInt()));
        Collections.sort(shops);

        long totalCost = 0;
        while(M>0){
            Shop bestShop = shops.poll();
            if(M <= bestShop.stock){
                totalCost += M * bestShop.price;
                M = 0;
            }else{
                totalCost += bestShop.stock * bestShop.price;
                M -= bestShop.stock;
            }
        }
        System.out.println(totalCost);





    }
}

Measured memory_bytes: 90312
#include "bits/stdc++.h"
#define _CRT_SECURE_NO_WARNINGS
#define rep(i,n) for(int i = 0;i < n;i++)
#define REP(i,n,k) for(int i = n;i < k;i++)
#define P(p) cout << (p) << endl;
#define sP(p) cout << setprecision(15) << fixed << p << endl;
#define Pi pair<int,int>
#define IINF 1e9
#define LINF 1e18
#define vi vector<int>
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 0, 1,0,-1 };
int dy[] = { 1, 0,-1,0 };
int dx8[] = { -1,-1,-1,0,0,1,1,1 };
int dy8[] = { -1,0,1,-1,1,-1,0,1 };

unsigned long long sttoi(std::string str) {
	unsigned long long ret;
	std::stringstream ss; ss << str;
	ss >> ret;
	return ret;
}

ull gcd(ull a, ull b) {
	if (b > a)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a%b);
}

int comb(int n, int k) {
	int ans = 1;
	for (int i = 0; i < min(k, n - k); i++) {
		ans *= n - i;
		ans /= i + 1;
	}
	return ans;
}

ll mod_pow(ll n, ll p, ll mod) {
	if (p == 0) return 1 % mod;
	if (p < 2) {
		return n % mod;
	}
	else {
		ll d = 2, value = (n%mod)*(n%mod) % mod;
		while (d * 2 < p) { d *= 2;	value *= value;	value %= mod; }
		value %= mod;
		return ((value%mod) * (mod_pow(n, p - d, mod) % mod)) % mod;
	}
}

bool isPrime(int n) {
	if (n <= 1)return false;
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i*i <= n; i += 2) {
		if (n%i == 0)return false;
	}
	return true;
}

void solve() {
	int a, b, h;
	cin >> a >> b >> h;
	P((a+b)*h/2)
}

int main() {
	solve();
	return 0;
}

Measured memory_bytes: 764
S = int(input())
mod = 10**9 + 7

fac = [0] * 3000
facinv = [0] * 3000
fac[0] = 1
facinv[0] = 1

for i in range(1,3000):
    fac[i] = (fac[i-1] * i) % mod
    facinv[i] = (facinv[i-1] * pow(i, -1, mod)) % mod

def nCk(n, k):
    return (fac[n] * facinv[k] * facinv[n-k]) % mod

a = S // 3
ans = 0
for i in range(1, a+1):
    ball = S - (i * 3)
    bar = i - 1
    ans = (ans + nCk(ball + bar, bar)) % mod
    #print()

print(ans)

Measured memory_bytes: 9352
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int D = scan.nextInt();
        int[][] x = new int[N][D];
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < D; j++) {
                x[i][j] = scan.nextInt();
            }
        }
        int answer = 0;
        for (int i = 0; i < N; i++) {
            for (int j = i+1; j < N; j++) {
                int d = 0;
                for (int k = 0; k < D; k++) {
                    d += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
                }
                for (int l = 1; l * l <= d; l++) {
                    if (l * l == d) {
                        answer += 1;
                    }
                }
            }
        }
        System.out.println(answer);
    }
}


Measured memory_bytes: 21716