akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int n;
int t[105], v[105];
vector <int> lim;
double dp[40005][205];
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; ++ i) scanf("%d", &t[i]);
	for (int i = 0; i < n; ++ i) scanf("%d", &v[i]);
	for (int i = 0; i < n; ++ i) {
		for (int j = 0; j < 2 * t[i]; ++ j) {
			lim.push_back(2 * v[i]);
		}
	}
	for (int i = 0; i <= lim.size(); ++ i) {
		for (int j = 0; j <= 200; ++ j) {
			dp[i][j] = -1e18;
		}
	}
	dp[0][0] = 0;
	for (int i = 0; i < lim.size(); ++ i) {
		for (int j = 0; j <= lim[i]; ++ j) {
			if (j && j - 1 <= lim[i]) dp[i + 1][j - 1] = max(dp[i + 1][j - 1], dp[i][j] + j - 0.5);
			if (j <= lim[i]) dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + j);
			if (j + 1 <= lim[i]) dp[i + 1][j + 1] = max(dp[i + 1][j + 1], dp[i][j] + j + 0.5);
		}
	}
	printf("%.9f\n", dp[lim.size()][0] / 4.0);
	return 0;
}

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

int main(){
  int n;
  cin>>n;
  set<int> S;
  int tmp;
  for(int i =0;i<n;i++){
    cin>>tmp;
    S.insert(tmp);
  }
  cout<<S.size()<<endl;
  return 0;
}
    
  
  
    
         
  
  

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		sc.close();
		String[] weather = { "Sunny", "Cloudy", "Rainy" };
		for (int i = 0; i < weather.length; i++) {
			if (S.equals(weather[i])) {
				if (i == 2) {
					System.out.println(weather[0]);
				} else {
					System.out.println(weather[i + 1]);
				}
			}
		}
	}
}


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

long calc(long a, long b){
    long min_rank = min(a, b);
    long ans = 0;
    long s = floor(sqrt(a*b-1));
    if(s*s>=a*b){
        s--;
    }
    if((s+1)*(s+1)<=a*b-1){
        s++;
    }
    //cout << "s=" << s << endl;
    if(min_rank<=s){
        ans--;
    }
    /*
    for(long i=1; i<=s; i++){
        printf("%ld %ld\n", i, (a*b-1)/i);
    }
    */
    if(s*(s+1)>a*b-1){
        ans--;
    }
    ans += 2*s;
    return ans;
}

int main(void){
    long q;
    cin >> q;
    for(long i=0; i<q; i++){
        long a, b;
        cin >> a >> b;
        long r = calc(a, b);
        cout << r << endl;
    }
    return 0;
}


Measured memory_bytes: 256
/*g++ main.cpp -o main.out*/
/*./main.out*/

#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <cctype>
#include <cstdio>
#include <string>
#include <vector>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;

#define LL long long
#define LD long double
#define Mod 1000000007
#define L_Mod 17100000013

const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const double PI = 3.1415926535;

#define NO_TLE std::ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

#define ree(a,n) memset(a,n,sizeof(a));

#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define red(i,l,u) for(int (i)=(int)(l);(i)>=(int)(u);--(i))

int main()
{
    LL n;
    cin>>n;
    if(n%2==1)cout<<0<<endl;
    else
    {
        LL sum=0;
        while(n>0)
        {
            sum+=(n/5)/2;
            n/=5;
        }
        cout<<sum<<endl;
    }
    return 0;
}





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

using namespace std;

const int N = 1e3 + 7 , mod = 1e9 + 7 ;

int n , m; 

int main()
{
        ios_base::sync_with_stdio(0);
        cin.tie(0);
       // freopen("in.in" , "r" , stdin) ; 
        int a , b , c, d ,e ; 
        cin>>a>>b>>c>>d>>e ; 
        cout<< (c * 60 + d ) - (a * 60 + b) - e   ; 

        return 0;
}


Measured memory_bytes: 3640
def main():
    H, W = map(int, input().split())
    board = [[int(s == ".") for s in input()] for _ in range(H)]
    mod = 10 ** 9 + 7
    dp = [[0] * (W+1) for _ in range(H+1)]
    dp[0][0] = 1
    for i in range(H):
        for j in range(W):
            if board[i][j]:
                dp[i][j] %= mod
            else:
                dp[i][j] = 0
            dp[i+1][j] += dp[i][j]
            dp[i][j+1] += dp[i][j]
    print(dp[H-1][W-1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 58588
import java.util.Scanner;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		doIt();

	}
	public static void doIt(){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		while(n != 0){
			int[][] field = new int[n][n];
			boolean bEnd = true;
			for(int i = 0; i < n; i++){
				String s = sc.next();
				for(int j = 0; j < n; j++){
					if(s.charAt(j) == '.'){
						field[i][j] = 1;
						bEnd = false;
					}
				}
			}
			if(bEnd){
				System.out.println(0);
				n = sc.nextInt();
				continue;
			}
			int level = 1;
			while(true){
				bEnd = true;
				for(int i = 0; i < n - level; i++){
					//フィールドを見て、レベルを上げていく
					for(int j = 0; j < n - level; j++){
						if(field[i][j] == level){
							//次のレベルが作れるか？
							if(field[i][j + 1] == level 
									&& field[i + 1][j] == level 
									&& field[i + 1][j + 1] == level
							){
								field[i][j] = level + 1;
								bEnd = false;
							}
						}
					}
				}
				if(bEnd){
					break;
				}
				level++;
				//print(field);
			}
			System.out.println(level);
			n = sc.nextInt();
		}
	}
	
	public static void print(int[][] f){
		for(int[] a : f){
			for(int b : a){
				System.out.print(b + " ");
			}
			System.out.println();
		}
	}

}

Measured memory_bytes: 15000
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <iterator>  // std::back_inserter()
#include <algorithm>  // std::copy()
#include <functional>  // std::greater<T>()
#include <utility>  // std::swap()
#include <numeric>  // accumulate(ALL(vec), 0)  0 は初期値
#include <cmath>
#include <climits>  // INT_MIN
#include <cctype>  // std::isdigit()
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;

// typedef
typedef long long ll;
typedef unsigned long ul;
// #define int long long

// macro
#define ALL(obj) (obj).begin(), (obj).end()
#define REP(i, n) for (int i=0; i < (int)(n); i++)  // 0 ~ n-1
#define REPN(i, n) for (int i=1; i <= (int)(n); i++)  // 1 ~ n
#define DESCEND greater<int>()  // sort 降順 大きい順
#define UNIQUE(vec) (vec).erase(unique(ALL((vec))), (vec).end());  // 必ずsortを行なってから
#define MIN(vec) min_element(ALL((vec)))  // 値を取り出すときは * を先頭につける
#define MAX(vec) max_element(ALL((vec)))
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define SUM(vec) accumulate(ALL((vec)), 0)  // 0 は初期値
#define COPY(vec1, vec2) copy(ALL(vec1), back_inserter(vec2))  // vec1をvec2にコピーする vec2は空にしておく必要あり
#define zero_pad(num) setfill('0') << std::right << setw(num)  // 直後の要素をパディング
#define space_pad(num) setfill(' ') << std::right << setw(num)  // 直後の要素をパディング

// func declaration
template <class T> void print2DVec(vector< vector<T> >&);
template <class T> void calcVec(vector<T>&, int, char);
int char_to_int(const char);

// const
const int INF = 10000000;

/*MEMO
・辞書順
abc < abcd, atcoder < atlas
・イテレータ
std::vector<int>::iterator とタイプするのは面倒なので、
 通常は型推論の auto を使用する。
 auto iter = max_element(ALL(vec));
・2次元配列
vector<vector<int>> vec = {{1, 2, 3}, {4, 5, 6}}
・20×10の配列
vector<vector<int>> vec(20, vector<int>(10, 0));
・(n, m)の多次元配列
vector< vector<int> > vec(n, vector<int>(m, 0))  // 0で初期化
*/

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

    // input
    int r, g, b;
    cin >> r >> g >> b;
    int num = 100*r + 10*g + b;
    
    // calculation
    if (num%4 == 0) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
    
    return 0;
}


// function
template <class T> void print2DVec(vector< vector<T> >& vec) {
    REP(i, vec.size()) {
        REP(j, vec.front().size()) {
            cout << vec.at(i).at(j);
        }
        cout << endl;
    }
}

template <class T> void calcVec(vector<T> &vec, int num, char ch) {
    // vec全体への演算
    switch (ch) {
        case '+':
            REP(i, vec.size()) vec.at(i) += num; break;
        case '-':
            REP(i, vec.size()) vec.at(i) -= num; break;
        case '*':
            REP(i, vec.size()) vec.at(i) *= num; break;
        case '/':
            REP(i, vec.size()) vec.at(i) /= num; break;
        case '%':
            REP(i, vec.size()) vec.at(i) %= num; break;
        default:
            cout << "Incorrect Operator" << endl;
    }
}

int char_to_int(const char c) {
    if('0' <= c && c <= '9') return (c - '0');
    return -1;
}


Measured memory_bytes: 256
using System;

class Program
{
	static void Main(string[] args)
	{
        var line = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
        int a = line[0], b = line[1];
		if ((a * b) % 2 == 0) Console.WriteLine("Even");
      	else Console.WriteLine("Odd");
	}
}


Measured memory_bytes: 11092
#ifdef LOCAL
#include <cstdio>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cstring>
#else
#include <bits/stdc++.h>
#endif
using namespace std ;

typedef long long ll ;
#define rep(i , n ) for ( int i =0; i < n ; i++)
#define _sort(arg) sort(begin(arg), end(arg))
#define MOD 1000000007
#define pb push_back
#define DEBUG(x) cout << #x << ": " << x << endl;

/*
__attribute__((constructor))
void initial()
{
	cin.tie(NULL);
	ios::sync_with_stdio(false);
}
*/

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

	int H, W, D;
	
	cin >> H >> W >> D;

	int a[H][W];
	
	int px[90001], py[90001];
	int d[90001];

	memset(px, 0, sizeof(px));
	memset(py, 0, sizeof(py));
	memset(d, 0, sizeof(d));

	rep(i, H)
	{
		rep(j, W)
		{
			cin >> a[i][j];
			px [ a[i][j] ]= i , py [ a[i][j] ]= j ;
		}
	}

	int Q;
	cin >> Q;
	int l[Q], r[Q];

	

	for(int i=D+1; i <= H*W; i++)
	{
		d[i] = d[i-D] + abs(px[i]-px[i-D]) + abs(py[i]-py[i-D]);
	}

	rep(i, Q)
	{
		cin >> l[i] >> r[i];
		cout << d[r[i]] - d[l[i]] << endl;
	}



	
	return 0;
}


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

#define FOR(i, a, b)   for(int i = (a); i < (b); ++i)
#define RFOR(i, a, b)  for(int i = (a); i > (b); --i)
#define rep(i, n)      for(int i = 0; i < (n); ++i)
#define all(c)         begin(c), end(c)
#define rall(c)        rbegin(c), rend(c)
#define SZ(a)          ((ll) a.size())

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int main() {
  int N;
  cin >> N;
  vi H(N);
  rep(i,N) cin >> H[i];
  int ma=0;
  int ans=0;
  rep(i,N){
    if(H[i]>=ma){
      ans++;
      ma=H[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//By Tushar Gautam
#pragma GCC optimize ("-O2")
#include <bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define memreset(a) memset(a,0,sizeof(a))
#define testcase(t) int t;cin>>t;while(t--)
#define forstl(i,v) for(auto &i: v)
#define forn(i,e) for(int i = 0; i < e;++i)
#define forsn(i,s,e) for(int i = s; i < e;++i)
#define rforn(i,s) for(int i = s; i >= 0;--i)
#define rforsn(i,s,e) for(int i = s; i >= e;--i)
#define bitcount(a) __builtin_popcount(a) // set bits (add ll)
#define ln '\n'
#define getcurrtime ((double)clock()/CLOCKS_PER_SEC)
#define dbgarr(v,s,e) cerr<<#v<<" = "; forsn(i,s,e) cerr<<v[i]<<", "; cerr<<endl
#define inputfile freopen("input.txt", "r", stdin)
#define outputfile freopen("output.txt", "w", stdout)
#define dbg(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) { cerr<<endl; }
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << "\t"; err(++it, args...);
}
template<typename T1,typename T2>
ostream& operator <<(ostream& c,pair<T1,T2> &v){
	c<<"("<<v.fi<<","<<v.se<<")"; return c;
}
template <template <class...> class TT, class ...T>
ostream& operator<<(ostream& out,TT<T...>& c){
    out<<"{ ";
    forstl(x,c) out<<x<<" ";
    out<<"}"; return out;
}
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> p64;
typedef pair<int,int> p32;
typedef pair<int,p32> p96;
typedef vector<ll> v64;
typedef vector<int> v32; 
typedef vector<v32> vv32;
typedef vector<v64> vv64;
typedef vector<p32> vp32;
typedef vector<p64> vp64;
typedef vector<vp32> vvp32;
typedef map<int,int> m32;
const int LIM=1e5+5,MOD=1e9+7;
int t,n,m,k,x,y,w;
struct event{
	double tm;
	int type,ind;
	event(double tm,int type,int ind): tm(tm),type(type),ind(ind){}
	bool operator < (const event &o) const{
		return tm<o.tm;
	}
};
signed main(){
	fastio;
	cin>>n>>k;
	vector<event> v;
	forn(i,n){
		cin>>x>>y>>w;
		x-=w;
		y-=w;
		v.pb(event(x-0.5,1,w));
		v.pb(event(y-0.5,0,w));
	}
	int ans[k];
	forn(i,k) ans[i]=-1;
	forn(i,k){
		cin>>x;
		v.pb(event(x,2,i));
	}
	sort(all(v));
	multiset<int> st;
	forstl(it,v){
		// dbg(st);
		// dbg(it.type,it.ind,it.tm);
		if(it.type==2){
			if(!st.empty()) ans[it.ind]=*st.begin();
		}else if(it.type==1) st.insert(it.ind);
		else{
			auto it1=st.find(it.ind);
			st.erase(it1);
		}
	}
	forn(i,k) cout<<ans[i]<<ln;
	return 0;
}

Measured memory_bytes: 22244
#include<cstdio>
#include <iostream>
#include <string>
#include<algorithm>
#include <map>
#pragma warning(disable:4786)  // VisualC++6.0の警告対策



using namespace std;

#define ll long long
#define SINT(n) scanf("%d",&n);
#define SLL(n) scanf("%lld",&n);
#define SST(s) scanf("%s",&s);

#define PINT(n) printf("%d",(int)(n));
#define PLL(n) printf("%lld",(long long)(n));
#define PST(s) printf("%s",(s));
#define PCH(s) printf("%c",(s));

#define PINTN(n) printf("%d\n",(int)(n));
#define PLLN(n) printf("%lld\n",(long long)(n));
#define PSTN(s) printf("%s\n",(s));
#define PCHN(s) printf("%c\n",(s));

#define PSP() printf(" ");
#define PN() printf("\n");



#define dlp(i) while(i-->0)
#define ulp(i) for(ll _hoge_counter_hoge_=i,i=0;i<_hoge_counter_hoge_;i++)

#define lp(i) for(ll _hoge_counter_hoge_=i;_hoge_counter_hoge_--;)
#define lpp(i,to) for(i=0;i<to;i++)
#define lpft(i,from,to) for(i=from;i<to;i++)


map<ll, map<ll, short> > memo[50][50][4];

char Map[60][60];

int main(){
	int N,M;
	int i,j,k;
	int len;
	bool f;
	int r;
	char a[11];
	char b[11];
	
	SST(a);
	lpp(i,10){
		if(a[i]==0) break;
	}
	len=i;

	SINT(N);

	r=0;
	dlp(N){
		SST(b);
		lpp(i,10){
			f=true;
			lpp(j,len){
				if(a[j]!=b[(i+j)%10]) f=false;
			}
			if(f){
				r++;
				break;
			}
		}
	}
	PINTN(r);

	return 0;
}

Measured memory_bytes: 1660
#include <algorithm>
#include <cmath>
#include<stdio.h>
#include <functional>
#include <fstream>
#include <limits>
#include <sstream>
#include <iostream>
#include <set>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include<map>
using namespace std;
using ll = long long;
const int N = 100005;
long long a[N],b[N],dp[N],n,k;
long long solve(int i){
     if(dp[i]!=1e18)return dp[i];
     if(i==n-1)return 0;
     long long h=1e18;
    for (int j = 1; j <= k; ++j)
    {   
        if(i+j<n)
        h=solve(i+j)+abs(a[i]-a[i+j]);
        dp[i]=min(dp[i],h);
    }
    return dp[i];

       
}
int main(){
        #ifdef MANSOUR
        freopen("input.txt", "r", stdin);
        #endif
       cin>>n>>k;
        for(int i=0;i<N;i++)dp[i]=1e18;
       for(int i=0;i<n;i++)cin>>a[i];
        cout<<solve(0);




}

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

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

int main()
{
	int X;
	cin >> X;
	while(true)
	{
		if (prime(X))
		{
			cout << X << endl;
			return 0;
		}
		X++;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <bitset>
#include <algorithm>
#include <functional>
#include <utility>
#include <iomanip>

#define int long long int
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1000003;

template <typename T>
using vector2 = vector<vector<T>>;
template <typename T>
vector2<T> initVec2(size_t n0, size_t n1, T e = T()){
    return vector2<T>(n0, vector<T>(n1, e));
}

template <typename T>
using vector3 = vector<vector<vector<T>>>;
template <typename T>
vector3<T> initVec3(size_t n0, size_t n1, size_t n2, T e = T()){
    return vector3<T>(n0, vector2<T>(n1, vector<T>(n2, e)));
}

int powM(int x, int n){
    if(n == 0){
        return 1;
    }
    if(n % 2 == 0){
        return powM(x * x % MOD, n / 2);
    }
    return powM(x, n-1) * x % MOD;
}

int factM(int n){
    static vector<int> t = {1};

    if((int)t.size() > n){
        return t[n];
    }

    for(int i = t.size(); i <= n; i++){
        t.push_back(t[i-1] * i % MOD);
    }
    return t[n];
}

class Combination{
    private:
        vector<int> t;

    public:
        Combination(int n): t(n+1){
            t[n] = powM(factM(n), MOD-2);

            for(int i = n-1; i >= 0; i--){
                t[i] = t[i+1] * (i+1) % MOD;
            }
        }

        int comb(int n, int k){
            if(n < k || n < 0 || k < 0){
                return 0;
            }
            return factM(n) * t[k] % MOD * t[n-k] % MOD;
        }

        int getInv(int n){
            return t[n];
        }
};

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

    Combination c(MOD-1);

    int q;
    cin >> q;
    while(q--){
        int x, d, n;
        cin >> x >> d >> n;

        int l = x * powM(d, MOD - 2) % MOD;
        int r = l + n - 1;

        if(d == 0){
            cout << powM(x, n) << endl;
            continue;
        }

        if(l <= MOD && MOD <= r){
            cout << 0 << endl;
            continue;
        }
        l = (l + MOD) % MOD;

        cout << factM(r) * c.getInv(l - 1) % MOD * powM(d, n) % MOD << endl;
    }

    return 0;
}


Measured memory_bytes: 18284
A,B,C,D = map(int, input().split())
Ans = 0

AC = A * C
AD = A * D
BC = B * C
BD = B * D

Ans = AC

if AD > Ans:
  Ans = AD
if BC > Ans:
  Ans = BC
if BD > Ans:
  Ans = BD

print(Ans)

Measured memory_bytes: 9204
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
count = 0
for n in range(N):
  if B[n]>=A[n]:
    count+=A[n]
    if B[n]-A[n]>A[n+1]:
      count+=A[n+1]
      A[n+1]=0
    else:
      count+=B[n]-A[n]
      A[n+1]-=(B[n]-A[n])
  else:
    count+=B[n]
print(count)

Measured memory_bytes: 19648
#include <vector>
#include <algorithm>
#include <iostream>

using namespace std;

void print_vector(vector<int> v, int n) {
  for(int i = 0; i < n - 1; i++) {
    cout << v[i] << " ";  
  }
  cout << v[n - 1] << endl;
}

int main(void) {
  int n;
  vector<int> v;

  cin >> n;

  for(int i = 1; i <= n; i++) {
    v.push_back(i);
  }

  do {
    print_vector(v, n);
  } while(next_permutation(v.begin(), v.end()));
}


Measured memory_bytes: 3176
import java.util.Scanner;


public class Main{

	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n=sc.nextInt();
		int sum=0;
		int t[]=new int[n];

		for(int i=0;i<n;++i){
			sum=sum+sc.nextInt();
			t[i]=sum;
		}
		int ans=sum;
		for(int i=0;i<n;++i){
			int a=Math.abs(sum-2*t[i]);
			if(ans>a) ans=a;
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 23252
N, C, *rest = $stdin.read.split.map(&:to_f)
EVENTS = rest.each_slice(3).sort_by{|start, till, ch| [ch, start]}
  
EVENTS_ = []
prev = nil
EVENTS.each do |start, till, ch|
  if prev.nil?
    prev = [start, till, ch]
  else
    start_, till_, ch_ = *prev
    if ch == ch_ && till_ == start
      prev = [start_, till, ch]
    else
      EVENTS_.push(prev)
      prev = [start, till, ch]
    end
  end
end
EVENTS_.push(prev)
  
ans = 0
n = 0
EVENTS_.flat_map{|start, till, ch|
  [
    [start-0.5, +1],
    [till, -1],
  ]
}.sort_by(&:first).chunk(&:first).each do |(_, events)|
  n += events.map(&:last).inject(:+)
  ans = n if n > ans
end

p ans


Measured memory_bytes: 52128
#include <bits/stdc++.h>
#define rep(i,n); for(long long i = 0;i < (n);i++)
using namespace std;
typedef long long ll;
int main(){
  int a,b; cin >> a >> b;
  if(a < b*2){
    cout << 0 << endl;}
  else cout << a - b*2 << endl;
}

Measured memory_bytes: 256
a, b = map(int, input().split())

if a == b:
    print(a)
elif b - a < 5:
    ans = a
    for i in range(b - a):
        ans = ans ^ (a + 1 + i)
    print(ans)
else:
    c = b - a + 1
    if a % 2 == 1:
        ans = a
        c -= 1
    else:
        ans = 0
    if b % 2 == 0:
        ans = ans ^ b
        c -= 1
    c //= 2
    ans = ans ^ (c % 2)
    print(ans)




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

int main(){
   int64_t x; cin >> x;
   int64_t ans = 0;
   ans += x/500 * 1000;
   x = x%500;
   ans += x/5 * 5;
   cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D) {
    cout << "Left" << endl;
  }
  else if (A + B == C + D) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int H,W;
int d[100][100];
char s[100][100];
void dfs(int h,int w,int black){
    d[h][w]=black;
    if(h==H-1&&w==W-1)return;
    if(h+1<H&&black+(s[h][w]=='.'&&s[h][w]!=s[h+1][w])<d[h+1][w])dfs(h+1,w,black+(s[h][w]=='.'&&s[h][w]!=s[h+1][w]));
    if(w+1<W&&black+(s[h][w]=='.'&&s[h][w]!=s[h][w+1])<d[h][w+1])dfs(h,w+1,black+(s[h][w]=='.'&&s[h][w]!=s[h][w+1]));
}
int main(){
    cin>>H>>W;
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>s[i][j];
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)d[i][j]=1000;
    dfs(0,0,s[0][0]=='#');
    cout<<d[H-1][W-1]<<endl;
    return 0;
}

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

#define MAX_W 100
#define MAX_H 100

char room[MAX_H][MAX_W];
int h, w;

void solve() {
    int x=0, y=0;
    bool loop=false;
    while (room[x][y] != '.' && !loop) {
        if (room[x][y] == 'x') {
            loop = true;
        } else if (room[x][y] == '>') {
            room[x][y] = 'x';
            y = y+1;
        } else if (room[x][y] == '<') {
            room[x][y] = 'x';
            y = y-1;
        } else if (room[x][y] == '^') {
            room[x][y] = 'x';
            x = x-1;
        } else { // room[x][y] == 'v'
            room[x][y] = 'x';
            x = x+1;
        }
    }
    if (loop) {
        std::cout << "LOOP" << std::endl;
    } else {
        std::cout << y << ' ' << x << std::endl;
    }
}

void split(const std::string &str) {
    std::string buf;
    std::stringstream ss(str);
    std::vector<std::string> v;
    while (std::getline(ss, buf, ' ')) {
        v.push_back(buf);
    }
    /*
    h = std::stoi(v[0]);
    w = std::stoi(v[1]);
    */
    std::istringstream(v[0]) >> h;
    std::istringstream(v[1]) >> w;
}

int main() {
    std::string line;
    while (std::getline(std::cin, line)) {
        split(line);
        if (h==0 && w==0) break;

        for (int i=0; i<h; i++) {
            for (int j=0; j<w; j++) {
                // scanf("%c", &room[i][j]);
                std::cin >> room[i][j];
            }
        }
        solve();
        std::cin.ignore();
    }
}



Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define rep(i, start, end) for (long long i = start; i < end; ++i)
#define repreverse(i, start, end) for (long long i = start; i >= end; --i)
#define all(x) (x).begin(), (x).end()
#define len(x) ((long long)(x).size())
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vllvll = vector<vll>;
using pll = pair<ll, ll>;
template<class T>void print1d(T x,ll n=-1){if(n==-1)n=x.size();rep(i,0,n){cout<<x[i]<<' ';}cout<<'\n';}
template<class T>void print2d(T x,ll r=-1,ll c=-1){if(r==-1)r=x.size();if(c==-1)c=x[0].size();rep(i,0,r)print1d(x[i],c);}
template<class T, class U>bool haskey(T mp, U key) { return mp.find(key) != mp.end(); }
template<class T, class U>bool isin(T el, U container) { return find(all(container), el) != container.end(); }
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; }
template<class T>bool even(T n) { return ! (n & 1); }
template<class T>bool odd(T n) { return n & 1; }
template<class T>ld deg2rad(T deg) { return M_PI * deg / 180.0; }
template<class T>ld rad2deg(T rad) { return 180.0 * rad / M_PI; }
ll intpow(ll a,ll n){ll p=1;while(n){if(n&1)p*=a;a*=a;n>>=1;}return p;}
const long double pi = M_PI;
const long long big = 1LL << 50;
const long long inf = 1LL << 60;
const long long mod = 1e9 + 7;



int main()
{
        ll N;
        cin >> N;
        vll A(N), B(N);
        rep(i, 0, N) cin >> A[i] >> B[i];
        ll ans = 0;
        repreverse(i, N-1, 0) {
                ll tmp = A[i] + ans;
                if (tmp % B[i] == 0) continue;
                ll rem = B[i] - tmp % B[i];
                ans += rem;
        }
        cout << ans << endl;
}

Measured memory_bytes: 4840
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<bitset>
#include<deque>
#define N 200003
#define mod 1000000007
#include<cstdlib>
#include<set>
#include<ctime>
#define ll long long
#define mp make_pair
using namespace std;
ll read()
{
	ll x=0,f=1;
	char c=getchar();
	while(c>'9'||c<'0')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return f*x;
}
int n,pre[N],c[N]; 
ll dp[N];
int main()
{
	n=read();
	dp[0]=1;
	for(int i=1;i<=n;++i)
	{
		int x=read();
		dp[i]=dp[i-1];
		if(pre[x]&&pre[x]!=i-1) dp[i]=(dp[i]+dp[pre[x]])%mod;
		pre[x]=i;
	//	cout<<i<<":00"<<" "<<dp[i]<<'\n';
	}
	cout<<dp[n];
	return 0;
 }


Measured memory_bytes: 2560
import java.util.*;

class Main{
     public static void main(String[] args){
         Scanner sc = new Scanner(System.in);
         int N = sc.nextInt();
         int[] d;
         d = new int[N];
         for(int i = 0; i < N; i++) d[i] = sc.nextInt();
         Arrays.sort(d);
         System.out.println(d[N/2] - d[N/2-1]);
     }
 }

Measured memory_bytes: 51064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll>>;
template <class _t> inline bool chmax (_t& a,_t b){if(a<b){a=b;return true;}return false;}
template <class _t> inline bool chmin (_t& a,_t b){if(a>b){a=b;return true;}return false;}

const long long inf = 1ll << 60;
const long long mod = 1000000007;

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

int main() {
    string s;cin >> s;
    if(s=="ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
	int n;
	cin >> n;
	int m = 0;
	vector<int> a(n), b(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		b[i] = a[i];
		m=max(m,a[i]);
	}
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (m == a[i])count++;
	}
	
	if (count == n) {
		for (int i = 0; i < n; i++) {
			cout << m << endl;
		}
	}
	else {
		sort(b.begin(), b.end());
		reverse(b.begin(), b.end());
		decltype(b)::iterator re = unique(b.begin(), b.end());
		b.erase(re, b.end());
		int max2 = b[1];
		bool flag = false;

		for (int i = 0; i < n; i++) {
			if (a[i] == m&&count == 1) {
				cout << max2 << endl;
			}
			else {
				cout << m << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <numeric>
using namespace std;

int main()
{
    int K;
    string S;
    cin >> K >> S;

    if(S.size() <= K){
        cout << S << endl;
    }else{
        for (int i = 0; i < K; ++i){
            cout << S[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define ld long double
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(var) (var).begin(), (var).end()
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >

int n,k,a[200005];

int check(int m)
{
	int ans = 0;

	for(int i=0;i<n;i++)
	{
		ans += (a[i] - 1) / m;
	}

	return ans;
}

int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	int i,j,x,y,l,r,m;
	cin >> n >> k;
	for(i=0;i<n;i++)
	{
		cin >> a[i];
	}

	l = 1;
	r = 1000000000;
	while(l <= r)
	{
		m = (l + r) / 2;
		x = check(m);
		if(x <= k)
		{
			r = m - 1;
		}
		else
		{
			l = m + 1;
		}
	}

	// cout << check(5) << endl;;

	cout << l;
	
	return 0;
}

Measured memory_bytes: 5136
# Heaps - Complete Binary Tree
from math import floor

def parent(i):
    p_id = floor(i/2)
    if p_id > 0: return p_id
    else: return 0

def left(H,i):
    l_id = 2 * i
    if 0 < l_id < H: return l_id
    else: return 0

def right(H,i):
    r_id = 2 * i + 1
    if 0 < r_id < H: return r_id
    else: return 0

def build_max_heap(A):
    H = len(A)
    for i in range(H//2,0,-1):
        max_heapify(A,i)

def max_heapify(A,i):
    H = len(A)
    l = left(H,i)
    r = right(H,i)
    largest = 0
    if 1 <= H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r <= H and A[r] > A[largest]:
        largest = r
    if not largest == i:
        A[i], A[largest] = A[largest], A[i]
        max_heapify(A, largest)

H = int(input())
heap = [-2000000001]*(H+1)
for i,k in enumerate(input().split()):
    heap[i+1] = int(k)

build_max_heap(heap)

for i,h in enumerate(heap):
    if i == 0: continue
    print(' {0}'.format(h), end='')
print()


Measured memory_bytes: 62324
/*
    In the name of
        "ALLAH"
    And say "AL-HAMD-U-LILLAH"
*/

#include<bits/stdc++.h>
#define   ll   long long
#define   llu  unsigned long long
#define   _    printf("\n")
int      take() {
    int n;
    scanf("%d",&n);
    return n;

}
double  ttake() {
    double n;
    scanf("%lf",&n);
    return n;
}
ll     takes() {
    ll n;
    scanf("%lld",&n);
    return n;

}

#define  Int            take()
#define  Dnt            ttake()
#define  LL             takes()
#define  done           {return 0;}
#define  fr(i,x,n,a)    for(int i=x;i<=n;i+=a)
#define  FR(a,b,x)      for(int i=(a);i<=(b);i+=(x))
#define  rfr(i,x,n,a)   for(int i=x;i>=n;i--)
int      cas;
#define  print          printf("Case %d:",++cas)
#define  vi             vector<int>
#define  vl              vector<ll>
#define  pb              push_back
#define  pii             pair<int,int>
#define  vii             vector<pii>
#define  pll             pair<ll,ll>
#define  pil             pair<int,ll>
#define  pli             pair<ll,int>
#define  mk              make_pair
#define  fill(x,v)       memset(x,v,sizeof x)

using    namespace      std;

bool     approximatelyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     essentiallyEqual(float a, float b, float epsilon) {
    return fabs(a - b) <= ( (fabs(a) > fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyGreaterThan(float a, float b, float epsilon) {
    return (a - b) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}

bool     definitelyLessThan(float a, float b, float epsilon) {
    return (b - a) > ( (fabs(a) < fabs(b) ? fabs(b) : fabs(a)) * epsilon);
}
#define  STR            {struct info}
#define  dbg(x)         {cout<<"ekhane"<<x<<endl;}
#define  SS             second
#define  FF             first
#define  PQ             priority_queue
#define  great          greatest
#define  less           lesser
#define  mii            map<int,int>
#define  mil            map<int,ll>
#define  mll            map<ll,ll>
#define  msb            map<string,bool>
#define  V              vector
#define  M              100005
#define  pf             printf
//////////////////////////////////////////


int main(){

    int x = Int ;ll ans = 1 ;

    fr( i ,2  , x , 1 ){
        ll u = i ;
        for( ll k = 2 ; ; k++ ){
            u *= i ;
            if( u > x ) break ;
            ans = max( ans , u ) ;
        }
    }
cout<<ans<<endl;
    done;
}




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

using namespace std;

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

    int res;
    cin >> res;
    for (int i = 1; i < n; ++i) {
        int a;
        cin >> a;
        res = __gcd(res, a);
    }

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<vector>
#include<cstring>
#include<sstream>
#include<algorithm>
//#include<bits/stdc++.h>
#include<cstdio>
using namespace std;

#define MOD 1000000007

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

    int n;
    cin >> n;

    for (int N = 1; N <= n; N++) {
        set<pair<int,pair<int,int>>> st;

        for (int i = 1; i*i <= N; i++) {
            for (int j = 1; (i*i+j*j+j*i) <= N; j++) {
                for (int s = 1; (i*i+j*j+s*s+s*i+s*j+i*j) <= N; s++) {
                    int tot = i*i + j*j + s*s + i*j + i*s + j*s;

                    if (tot == N) {
                        st.insert(make_pair(i, make_pair(j, s)));
                    }
                }
            }
        }

        cout << st.size() << endl;
    }

    return 0;
}


Measured memory_bytes: 3116
import math

#mの約数のうち、n以上の最小の約数でmを割った商が答え
inn,inm = list(map(int,input().split()))
root = math.floor(math.sqrt(inm))

a = []
for i in range(1,root+1):
  if inm%i == 0:
    a.append(i)
    a.append(inm/i)
    
a.sort()
for i in a:
  if i >= inn:
    print(int(inm/i))
    break

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T>
using vec = std::vector<T>;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n = 1) : n(n), f(n + 1) {
        f[0] = f[1] = -1;
        for (ll i = 2; i <= n; ++i) {
            if (f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for (ll j = i * i; j <= n; j += i) {
                if (!f[j]) f[j] = i;
            }
        }
    }
    bool isPrime(int x) {
        return f[x] == x;
    }
    vector<int> factorList(int x) {
        vector<int> res;
        while (x != 1) {
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<pair<int, int>> factor(int x) {
        vector<int> fl = factorList(x);
        if (fl.size() == 0) return {};
        vector<pair<int, int>> res(1, pair<int, int>(fl[0], 0));
        for (int p : fl) {
            if (res.back().first == p) {
                res.back().second++;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};


int main() {
    int Q;
    cin >> Q;
    Sieve sieve(1e6);
    vec<int> S((int)1e5+1,0);
    for(int i=3;i<=100000;i+=2){
        bool c1 = (sieve.isPrime(i));
        bool c2 = (sieve.isPrime((i+1)/2)) ;
        if(c1&&c2) S[i]=1;
        S[i-1] += S[i-2];
        S[i] += S[i-1];
    }
    rep(i,Q){
        int l,r;
        cin >> l >> r;
        cout << S[r]-S[l-1] << endl;
    }
}

Measured memory_bytes: 5368
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********

int main()
{
    IOS;
    string s,t;
    cin>>s>>t;

   int len = t.length();
   int mn = len;

   fn(i,s.length()-len+1)
   {
     int  cnt = 0;
       fn(j,len)
          if(t[j] != s[i+j])
           cnt++;

    mn = min(mn,cnt);

   }

   cout<<mn<<endl;

return 0;
}


Measured memory_bytes: 3656
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>


int main(){
#ifdef DEBUG
	
#endif
	int A, B, C;
	int ans;
	scanf("%d %d %d", &A, &B, &C);

	if (A == B) {
		ans = C;
	}
	else if (A == C) {
		ans = B;
	}
	else {
		ans = A;
	}

	printf("%d\n", ans);
}

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

int main() {
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a < b && b < c) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(long long)>
using namespace std;
#define All(v) (v).begin(),(v).end()
const long long mod = 1000000007;
const long long inf = mod*mod;
const long long MAXS = 114514;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
signed main(){
    long long n;
    cin>>n;
    vector<long long> a(n);
    for(long long i=0;i<n;i++)cin>>a[i];
    long long res = inf;
    for(long long ave=-100;ave<=100;ave++){
        long long t = 0;
        for(long long i=0;i<n;i++){
            t+=(a[i]-ave)*(a[i]-ave);
        }
        res=min(res,t);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
def main():
    import sys
    #input = sys.stdin.readline
    H,W = map(int, input().split())
    S = [(input()) for i in range(H)]
    wall = "#"*W
    for i in range(H):
        S[i] += "#"
    S.append(wall)
    A = [([0]*W) for _ in range(H)]
    B = [([0]*W) for _ in range(H)]
    
    for i in range(H+1):
        for j in range(W):
            if i == 0:
                if S[i][j]  == ".":
                    A[i][j] = 1
            else:
                if S[i][j]  == ".":
                    A[i][j] = A[i-1][j] + 1
                else:
                    k = i-1
                    while k>=0 and A[k][j]>0:
                        A[k][j] = A[i-1][j]
                        k -= 1
    for j in range(W+1):
        for i in range(H):
            if j == 0:
                if S[i][j]  == ".":
                    B[i][j] = 1
            else:
                if S[i][j]  == ".":
                    B[i][j] = B[i][j-1] + 1
                else:
                    k = j-1
                    while k >=0 and B[i][k]>0:
                        B[i][k] = B[i][j-1]
                        k -= 1
    answer = 0
    for i in range(H):
        for j in range(W):
            tmp = A[i][j] + B[i][j] - 1
            if tmp >= answer:
                answer = tmp
    print(answer)
    
    
    
main()

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

using namespace std;

typedef long long ll;

ll arr[100005];

int main()
{

    int flag=0;
    string arr;
    cin >> arr;
    if(arr[0]=='7'||arr[1]=='7'||arr[2]=='7')
        cout << "Yes" ;
    else cout << "No";



    return 0;
}


Measured memory_bytes: 3628
#include <iostream>

bool is_right_triangle(const int a, const int b, const int c)
{
    bool ret;
    int aa;
    int bb;
    int cc;
    
    aa = a * a;
    bb = b * b;
    cc = c * c;
    
    if (aa + bb == cc || bb + cc == aa || cc + aa == bb){
        ret = true;
    }
    else {
        ret = false;
    }
    
    return ret;
}

int main()
{
    int n;
    int a;
    int b;
    int c;
    
    std::cin >> n;
    
    for (int i = 0; i < n; i++){
        std::cin >> a >> b >> c;
        if (is_right_triangle(a, b, c)){
            std::cout << "YES" << std::endl;
        }
        else {
            std::cout << "NO" << std::endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1148
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner( System.in );
            int n, x, count, tmp3, tmp2;
            String[] tmpArray;  
            while( true ) {
                String str = scan.nextLine();
                tmpArray = str.split( " " );
                n = Integer.parseInt( tmpArray[0] );
                x = Integer.parseInt( tmpArray[1] );

                if( 0 == n && 0 == x ) {  break; }

                count = 0;
                tmp3 = x / 3;
                int i, j, k;
                for( i=1; i<tmp3; i++ ) {
                    tmp2 = ( x-i ) / 2;
                    for( j=i+1; j<=tmp2; j++ ) {
                        k = x - i - j;
                        if( j < k && k <= n ) {
                            count++;
                        }
                    }
                }
                System.out.println( count );    
            }
        } 
}


Measured memory_bytes: 26144
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<string>
#include<iostream>
#include<cctype>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include <algorithm>
#include<math.h>
#include<set>
#include<map>
#include <sstream>
#include<iomanip>
#include <ctype.h>

//#include<bits/stdc++.h>





using namespace std;
int main() {


	int x, k;
	cin >> k >> x;
	for (int i = x - k + 1; i <= x + k - 1; i++) {
		if (i != x - k + 1)cout << " ";
		cout << i;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <limits.h>
#include <stdbool.h>

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

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    char c[2][3];
    
    rep(i, 2){
        scanf("%s", c[i]);
    }
    
    if (c[0][0]==c[1][2]&&c[0][2]==c[1][0]&&c[0][1]==c[1][1]) {
        printf("YES");
    } else {
        printf("NO");
    }
    
    return 0;
}



Measured memory_bytes: 1700
#include <bits/stdc++.h> 
#define F(i,a,b) for(int i=a;i<=(b);++i)
#define dF(i,a,b) for(int i=a;i>=(b);--i)
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-6
using namespace std;
typedef long long ll;
const int mods = 998244353;
const int maxn = 2e3+10;

ll a,b;
string s[2];

inline long long read() {
    long long tmp=0, fh=1; char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
    while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
    return tmp*fh;
}

int main() {
	cin>>a>>b;
	F(i,1,b){
		s[0]+=char(a+'0');
	}
	F(i,1,a){
		s[1]+=char(b+'0');
	}
	sort(s,s+2);
	cout<<s[0]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
  int K,A,B;
  cin >> K >> A >> B;
  if((B-A) <= 2 || K-B >= A){
    cout << K+1 << endl;
    return 0;
  }
  else{
    int ans = 1;
    K -= A-1;
    ans = A;
    ans += (K/2)*(B-A);
    if(K%2 == 1){
      ans++;
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3632
import sys
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def II(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def SI(): return input()
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')

A, B = LI()

if A>=13:
    print(B)
elif 6<=A<=12:
    print(B//2)
else:
    print(0)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
#define endl	"\n"
#define pb 		push_back
#define mp 		make_pair
#define MOD 	1000000007
#define INF 	(long long int)1e9
#define EPS 	1e-9
#define PI 		3.1415926535897932384626433832795 
#define ll      long long int
#define ret     return
#define NUM 	100020
void fastio(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

void input(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

int main(){
	fastio();
	//input();

	int n;
	cin>>n;
	vector<int> v(n);
	for(int i=0;i<n;i++){
		cin>>v[i];
	}
	int dp[n];
	dp[0] = 0;
	dp[1] = abs(v[1]-v[0]);
	for(int i=2;i<n;i++){
		int x1 = dp[i-1]+abs(v[i]-v[i-1]);
		int x2 = dp[i-2]+abs(v[i]-v[i-2]);
		dp[i] = min(x1,x2);
	}
	cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 1024
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
#include<string>
#include<cstdio>
#include<cctype>
#include<cassert>
#include<cstdlib>
#include<cstring>
#include<sstream>
#include<iostream>
#include<algorithm>

#define For(i,x,y) for (int i=x;i<y;i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second

#define dprintf(...) fprintf(stderr,__VA_ARGS__)
using namespace std;

typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> Vi;

int IN(){
	int c,f,x;
	while (!isdigit(c=getchar())&&c!='-');c=='-'?(f=1,x=0):(f=0,x=c-'0');
	while (isdigit(c=getchar())) x=(x<<1)+(x<<3)+c-'0';return !f?x:-x;
}

const int N=200000+19;

char s[N];
int n,S,T;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	For(i,1,n+1){
		if (s[i]=='T'){
			if (S) S--;else T++;
		} else{
			S++;
		}
	}
	printf("%d\n",S+T);
}


Measured memory_bytes: 384
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

int N,M,X;

int main(void){
    int X;
    cin >> X;
    if(X<600){
        cout <<"8"<<endl;
    }else if(X<800){
        cout <<"7"<<endl;
    }else if(X<1000){
        cout <<"6"<<endl;
    }else if(X<1200){
        cout <<"5"<<endl;
    }else if(X<1400){
        cout <<"4"<<endl;
    }else if(X<1600){
        cout <<"3"<<endl;
    }else if(X<1800){
        cout <<"2"<<endl;
    }else{
        cout <<"1"<<endl;
    }
}

Measured memory_bytes: 3628