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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9;
const LL LINF = INF * INF;

const int mod = 1e9 + 7;
 
inline int add(int x, int y)
{
	if (x + y >= mod)
		return x + y - mod;
	return x + y;
}
 
inline int mult(int x, int y)
{
	return x * (LL) y % mod;
}

inline int power(int x, int y)
{
	int r = 1;
	while(y)
	{
		if (y & 1)
			r = mult(r, x);
		x = mult(x, x);
		y >>= 1;
	}
	
	return r;
}

const int MAX = 1 << 10;
int n;
pair<int, PII> a[MAX];

int cmp(pair<int, PII> x, pair<int, PII> y)
{
	return x.X + x.Y.X < y.X + y.Y.X;
}

const int N = 20007;
LL dp[1007][N];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);
	//freopen("In.txt", "w", stdout);

	cin >> n;
	FOR(i, 0, n)
		cin >> a[i].X >> a[i].Y.X >> a[i].Y.Y;
	
	sort(a, a + n, cmp);
	
	dp[0][0] = 0;
	dp[0][a[0].X] = a[0].Y.Y;
	
	FOR(i, 1, n)
	{
		FOR(j, 0, N)
			dp[i][j] = dp[i - 1][j];
		
		FOR(j, 0, a[i].Y.X + 1)
			dp[i][j + a[i].X] = max(dp[i][j + a[i].X], dp[i - 1][j] + a[i].Y.Y);			
	}
	
	LL ans = 0;
	FOR(i, 0, N)
		ans = max(ans, dp[n - 1][i]);
	cout << ans << endl;
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}


Measured memory_bytes: 156416
# include<iostream>
# include<algorithm>
using namespace std;
int main ()
{
	 int N,K;
	 cin>>N>>K;
	 long long  H[N];
	 for(int i=0;i<N;i++)
	 {
	 	 cin>>H[i];
	 }
	 sort(H,H+N);
	 long long sum =0;
	 for(int i=0;i<N-K;i++)
	 {
	 	 sum+=H[i];
	 }
	 cout<<sum<<endl;
	 
	
}

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

int main(){
    string S;
    cin >> S;
    string nickname;
    for(int i=0;i<3;i++){
        nickname+=S.at(i);
    }
    cout << nickname << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <sstream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
	int N;
	cin >> N;
	for(int i = 0; N-7*i >= 0; i++){
		if((N-7*i)%4==0){
			//cout << i << " " << (N-7*i)/4 << endl;
			cout << "Yes\n";
			return 0;
		}
	}
	cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
if __name__ == "__main__":
    weather_str = input()

    if weather_str == "SSS":
        print(0)
        exit()

    weather = list(weather_str)
    weather.append("END")

    r = range(len(weather)-1)
    c = []
    start = 1
    tmp = start

    for i in r:
        if weather[i] == "R" and weather[i] == weather[i+1]:
            tmp += 1
        else:
            c.append(tmp)
            tmp = start

    print(max(c))


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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\n";                                                          \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll n;
vector<VL> a;

signed main() {
    cin >> n;
    a.assign(n, VL(n, 0));
    REP(i, n) REP(j, n) cin >> a[i][j];
    vector<VL> sum(n, VL(n + 1, 0));
    REP(i, n) REP(j, n) sum[i][j + 1] += sum[i][j] + a[i][j];
    ll ans = -LINF;
    REP(i, n + 1) FOR(j, i + 1, n + 1) {
        ll tmp = 0;
        REP(k, n) {
            if(tmp < 0) {
                tmp = sum[k][j] - sum[k][i];
            } else {
                tmp += sum[k][j] - sum[k][i];
            }
            ans = max(ans, tmp);
        }
    }
    cout << ans << "\n";
}


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

int main() {
	ll n,cnt=0;
	cin>>n;
	string s;
	cin>>s;
	for(ll i=0;i<n-2;i++)
	{
		if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')
		++cnt;
	}
	cout<<cnt;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

void solve() {
  int n;
  cin >> n;
  using P = pair<f80, f80>;
  vi32 x(n), y(n);
  vector<P> target;
  rep(i, n) {
    cin >> x[i] >> y[i];
    target.emplace_back(-y[i], x[i]);
    target.emplace_back(-y[i], x[i] + 0.0001);
    target.emplace_back(-y[i], x[i] - 0.0001);
    target.emplace_back(y[i], -x[i]);
    target.emplace_back(y[i], -x[i] + 0.0001);
    target.emplace_back(y[i], -x[i] - 0.0001);
  }
  f80 ans = 0;
  rep(i, sz(target)) {
    f80 nx, ny;
    tie(nx, ny) = target[i];
    int fx = 0, fy = 0;
    rep(j, n) {
      if (nx * x[j] + ny * y[j] >= 0) {
        fx += x[j], fy += y[j];
      }
    }
    f80 sum = sqrt(pow((f80) fx, 2) + pow((f80) fy, 2));
    amax(ans, sum);
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define vpll vector < pair<long long,long long> >
#define fill(a,val)  memset(a,val, sizeof (a))
#define sort_unique(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define all(cont) cont.begin(), cont.end()
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MAX   1e9
#define MIN  -1e9
typedef map<int,int> mpi;
typedef set<int> seti;
typedef multiset<int> mseti;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define rep(i, n)    for(long long int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define repn(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define trav(a, x) for(auto& a : x)
struct Interval{ll start,end;};
bool compare(Interval i1, Interval i2) {return (i1.start < i2.start);}

vll divisors[10000001];
int main(){
	fio;
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
	ll n;
	cin>>n;
	if(n>=30){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 238020
#include "bits/stdc++.h" 
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
bool isPerfectSquare(long double x) 
{    
  long double sr = sqrt(x);  
  return ((sr - floor(sr)) == 0); 
} 
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    string s3=s1+s2;
    long double x=stold(s3);
  if (isPerfectSquare(x)) 
    cout << "Yes"; 
  else
    cout << "No"; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const double pi=acos(-1);
int n,L;
double po[3030];
int main()
{
    scanf("%d%d",&n,&L);
    for(int i=1;i<=n;++i)
    {
        scanf("%lf",&po[i]);
        po[i]=po[i]*pi*2/L;
    }
    double m1,m2;
    double sx=0,sy=0;
    for(int i=1;i<=n;++i)
        for(int j=i+1;j<=n;++j)
        {
            m1=(po[i]+po[j])/2;
            m2=m1+pi;
            sx+=cos(m2)*(j-i-1);
            sy+=sin(m2)*(j-i-1);
            sx+=cos(m1)*(n-j+i-1);
            sy+=sin(m1)*(n-j+i-1);
        }
    long long s=1ll*n*(n-1)*(n-2)/6;
    printf("%.15lf %.15lf\n",sx/s,sy/s);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <deque>

using namespace std;

class Dice
{
public:
	enum FACE
	{
		eTop = 0,
		eFront,
		eRight,
		eLeft,
		eBack,
		eBottom
	};

	Dice()
	{
	}

	Dice(bool isSetNumber)
	{
		if (isSetNumber)
		{
			SetDiceNumber();
		}
	}

	virtual ~Dice()
	{
	}

	void SetDiceNumber()
	{
		dqDiceNumber.resize(6);
		cin >> dqDiceNumber[eTop];
		cin >> dqDiceNumber[eFront];
		cin >> dqDiceNumber[eRight];
		cin >> dqDiceNumber[eLeft];
		cin >> dqDiceNumber[eBack];
		cin >> dqDiceNumber[eBottom];

		cin.clear();
		cin.ignore();
	}

	void OrderE()
	{
		deque<FACE>		Rotation{ eTop, eLeft, eBottom, eRight };

		OrderExecute(Rotation);
	}

	void OrderW()
	{
		deque<FACE>		Rotation{ eTop, eRight, eBottom, eLeft };

		OrderExecute(Rotation);
	}

	void OrderN()
	{
		deque<FACE>		Rotation{ eTop, eFront, eBottom, eBack };

		OrderExecute(Rotation);
	}

	void OrderS()
	{
		deque<FACE>		Rotation{ eTop, eBack, eBottom, eFront };

		OrderExecute(Rotation);
	}

	void OrderRotation()
	{
		deque<FACE>		Rotation{ eFront, eRight, eBack, eLeft };

		OrderExecute(Rotation);
	}

	int		GetDiceNumber(FACE face)
	{
		return (dqDiceNumber[face]);
	}

	void	SearchTop(int t)
	{
		for (int i = 0; i < 4; ++i)
		{
			if (t == dqDiceNumber[eTop])
			{
				return;
			}
			OrderN();
		}

		for (int i = 0; i < 4; ++i)
		{
			if (t == dqDiceNumber[eTop])
			{
				return;
			}
			OrderE();
		}
	}

	void	SearchFront(int f)
	{
		for (int i = 0; i < 4; ++i)
		{
			if (f == dqDiceNumber[eFront])
			{
				return;
			}
			OrderRotation();
		}
	}

private:
	deque<size_t>	dqDiceNumber;

	void OrderExecute(const deque<FACE> &Rotation)
	{
		auto	temp = dqDiceNumber[Rotation[0]];
		auto	LoopMax = Rotation.size() - 1;

		for (auto i = 0u; i < LoopMax; ++i)
		{
			dqDiceNumber[Rotation[i]] = dqDiceNumber[Rotation[i + 1]];
		}
		dqDiceNumber[Rotation[LoopMax]] = temp;
	}
};

void DiceI();
void DiceII();

int main()
{
	DiceII();

	return 0;
}

void DiceI()
{
	Dice	d(true);

	string	str;

	getline(cin, str);
	for (auto it : str)
	{
		switch (toupper(it))
		{
		case 'S':
			d.OrderS();
			break;
		case 'N':
			d.OrderN();
			break;
		case 'E':
			d.OrderE();
			break;
		case 'W':
			d.OrderW();
			break;
		default:
			break;
		}
	}

	cout << d.GetDiceNumber(Dice::eTop) << "\n";
}

void DiceII()
{
	Dice	d(true);

	int		q;
	cin >> q;
	cin.clear();
	cin.ignore();

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

		cin >> t >> f;
		cin.clear();
		cin.ignore();

		d.SearchTop(t);
		d.SearchFront(f);

		cout << d.GetDiceNumber(Dice::eRight) << "\n";
	}
}

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

int parent[100001];
int size[100001];
void init(int n) {
  for (int i=0; i<n; i++) {
    parent[i] = i;
    size[i] = 1;
  }
}
int find(int i) {
  if (i == parent[i]) {
    return i;
  }
  return parent[i] = find(parent[i]);
}

void unite(int i, int j) {
  i = find(i);
  j = find(j);
  if (i == j) {
    return;
  }
  if (size[i] < size[j]) {
    parent[i] = j;
    size[j] += size[i];
  } else {
    parent[j] = i;
    size[i] += size[j];
  }
}
int main() {
  long long n, m;
  cin>>n>>m;
  vector<pair<int, int> > es;
  for (int i=0; i<m; i++) {
    int a, b;
    cin>>a>>b;
    --a; --b;
    es.emplace_back(a, b);
  }
  reverse(es.begin(), es.end());

  init(n);

  long long ans = n * (n - 1) / 2;
  vector<long long> v_ans;
  v_ans.push_back(ans);
  for (auto e: es) {
    if (find(e.first) != find(e.second)) {
      ans -= size[find(e.first)] * size[find(e.second)];
    }
    unite(e.first, e.second);
    v_ans.push_back(ans);
  }
  reverse(v_ans.begin(), v_ans.end());
  for (int i=1; i<=m; i++) {
    cout<<v_ans[i]<<endl;
  }
}

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

long long mod = 1000000007;

long long mpow(long long x,long long y){
  if(y==0) return 1;
  long long ret = mpow(x,y/2);
  ret %= mod;
  ret *= ret;
  ret %= mod;
  if(y%2==1) ret *= x;
  ret %= mod;
  return ret;
}

long long com(long long n, long long r, vector<long long> &kai){
  long long ret = kai[n];
  ret *= mpow(kai[r],mod-2);
  ret %= mod;
  ret *= mpow(kai[n-r],mod-2);
  ret %= mod;
  return ret;
}

int main(){
  long long n,k;
  cin >> n >> k;
  k = min(n-1,k);
  
  vector<long long> kai(n+1,1);
  for(int i=1;i<=n;i++){
    kai[i] = kai[i-1]*i;
    kai[i] %= mod;
  }
  
  vector<long long> V(k+1);
  V[0] = 1;
  for(int i=1;i<=k;i++){
    V[i] = com(n,i,kai);
    V[i] %= mod;
    V[i] *= com(n-1,i,kai);
    V[i] %= mod;
  }
  
  long long ans=0;
  for(int i=0;i<=k;i++){
    ans += V[i];
    ans %= mod;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3328
//
//  main.cpp
//  AC
//
//  Created by makinofuya on 2019/07/08.
//  Copyright © 2019 makinofuya. All rights reserved.
//
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
typedef long long ll;
using namespace std;
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
#define out(s) cout << s << endl

ll f(ll x){
    if(x%2==0){
        if((x/2)%2==0){
            return x;
        }else{
            return x^1;
        }
    }
    else{
        if(((x+1)/2)%2==0) {
            return 0;
        }else{
            return 1;
        }
    }
}

int main(){
    ll a,b;cin >> a >> b;
    ll x1=f(a-1);
    ll x2=f(b);
    
    cout <<(x1^x2)<<endl;
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
int main(void) {
int n,l;
  cin >> n >> l;
  vector<int> ap(n);
  rep(i,n) {
     ap.at(i) = l + i;
  }
  int ans,num;
  ans =abs(ap.at(0));
  for(int  i=1; i<n; i++) {
    if( abs(ap.at(i) - 0) < ans ){
      ans = abs(ap.at(i)-0);
      //I want "i",when taking an absolute value
      num = i;
    }
  }
  int sum =0;
  rep(i,n) {
    sum += ap.at(i);
  }
  cout << sum -ap.at(num) <<endl;
  return 0;
}



Measured memory_bytes: 256
import java.util.*;
public class Main { 
	static ArrayList<Integer> list = new ArrayList<Integer>();
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		makeList();
		while(true) {
			int n = stdIn.nextInt();
			if(n == 0) break;
			int count = 0;
			for(int i = 0; i < 182; i++) {
				int a = list.get(i);
				if(a > n) break;
				for(int j = i; j < 182; j++) {
					int b = list.get(j);
					if(a + b > n) break;
					for(int k = j; k < 182; k++) {
						int c = list.get(k);
						if(a + b + c > n) break;
						for(int l = k; l < 182; l++) {
							if(a + b + c + list.get(l) == n) {
								count++;
								break;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
	public static void makeList() {
		for(int i = 0; i < 182; i++) {
			list.add(i*i);
		}
	}
		
}

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

int n, a[10];

int main() {
    cin >> n;
    int MAX = pow(3, n), cnt = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        if (a[i] % 2 == 0) cnt++;
    }
    cout << MAX - pow(2, cnt) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define INF 1000000000
using namespace std;
int cal(int d){
    int num=1;
    while(d--){
        num*=100;
    }
    return num;
}
int main(void){
    int d,n;
    cin>>d>>n;
    if(d==0){
        if(n==100){
            cout<<101<<endl;
        }else{
            cout<<n<<endl;
        }
    }else if(d==1){
        if(n==100){
            cout<<10100<<endl;
        }else{
            cout<<n*100<<endl;
        }
    }else if(d==2){
        if(n==100){
            cout<<1010000<<endl;
        }else{
            cout<<n*10000<<endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,a[101],ans1=1e9,ans2;
bool cmp(int x,int y)
{
	return x<y;
}
signed main()
{
	int l=1;
	scanf("%lld%lld",&m,&n);
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	for(int i=0;i<=101;i++)
	{
		if(a[l]!=i)
		if(abs(m-i)<ans1)
		{
			ans1=abs(m-i);
			ans2=i;
		}
		while(a[l]==i&&l<=n)
		l++;
	}
	printf("%lld",ans2);
    return 0;
}

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

public class Main {

	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String str = in.readLine();
		String s[] = str.split(" ");
		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		if (a == b) {
			System.out.println("a == b");
		} else if (a > b) {
			System.out.println("a > b");
		} else if (a < b) {
			System.out.println("a < b");
		}
	}
}


Measured memory_bytes: 24284
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXN = 3e3 + 5;
const int MAXS = 3e3 + 5;
const int mod = 998244353;

inline void add_mod(int &a,int b){ a+=b; if(a>=mod) a-=mod;}

int a[MAXN];
int f[MAXN][MAXS];

int main(void)
{
	int n,s;
	scanf("%d%d",&n,&s);
	for(int i=1; i<=n; ++i) scanf("%d",&a[i]);
	
	f[0][0]=1;
	int ans=0;
	for(int i=1; i<=n; ++i)
	{
		f[i][0]=1;
		for(int j=0; j<=s; ++j)
		{
			add_mod(f[i][j], f[i-1][j]);
			if(j>=a[i]) add_mod(f[i][j], f[i-1][j-a[i]]);
		}
		add_mod(ans, f[i][s]);
	}
	printf("%d",ans);
	return 0;
}

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

using namespace std;

using ll = long long;

int main(){
    ll n;
    cin >> n;
    set<string> s;
    for(ll i = 0; i < n; ++i){
        string tmp; cin >>tmp;
        s.insert(tmp);
    }
    cout << s.size();
}


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int BIT_MAX = 1e5+3;
const LL mod = 1e9+7;

template <class T> class BIT{
	T x[BIT_MAX + 1];
	
public:
	
	BIT(){
		fill(x,x+BIT_MAX+1,0);
	}
	
	void add(int a , T b){
		for(++a ; a <= BIT_MAX ; a += a & -a) (x[a] += b) %= mod;
	}
	
	T get(int a){
		T b = 0;
		for(++a ; a > 0 ; a -= a & -a) (b += x[a]) %= mod;
		return b;
	}
};

BIT<LL> bit;

int main(){
	int N,M; cin >> N >> M;
	vector<int> x(N),y(M);
	repp(i,0,N) cin >> x[i];
	repp(i,0,M) cin >> y[i];
	vector<pair<int,int>> p;
	{
		int k = 0;
		while(k < N && x[k] < y[0]) ++k;
		repp(j,1,M) while(k < N && x[k] < y[j]){
			p.push_back(make_pair(x[k]-y[j-1],y[j]-x[k]));
			++k;
		}
	}
	sort(p.begin(),p.end(),[](const pair<int,int> &a, const pair<int,int> &b){return a.first==b.first?a.second>b.second:a.first<b.first;});
	N = p.size();
	vector<int> s(N),r(N);
	repp(i,0,N) s[i] = i;
	sort(s.begin(),s.end(),[&](const int &a, const int &b){return p[a].second==p[b].second?a>b:p[a].second<p[b].second;});
	repp(i,0,N) r[s[i]] = i;
	repp(i,0,N) if(i == 0 || p[i-1] != p[i]){
		bit.add(r[i],bit.get(r[i])+1);
	}
	cout << (bit.get(N)+1)%mod << endl;
	return 0;
}


Measured memory_bytes: 3316
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def main2():
    n,p=map(int, input().split())
    lis = factorization(p)
    lis.sort(key=lambda x:x[1], reverse = True)
    i = 0
    res = 1
    while(i<len(lis) and lis[i][1]>=n):
        res = lis[i][0]**(lis[i][1]//n)*res
        i+=1
    print(res)

if __name__ == '__main__':
    main2()


Measured memory_bytes: 9352
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define FOR(i, o, n) for (auto i = (o); (i) < (n); ++(i))
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (auto i = (n)-1; (i) >= 0; --i)
#define REPI(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define REPIR(itr, v) for (auto itr = v.rbegin(); itr != v.rend(); ++itr)
#define fi first
#define se second
#define ll long long
#define V2(name, h, w) vector<vector<int> > name((h), vector<int>(w));
int main(){
	ll N,K,Y,X; cin >> N >> K >> X >> Y;
	cout << (N>K ? K*X+(N-K)*Y : N*X) << endl;
}


Measured memory_bytes: 256
from heapq import heappop, heappush

def dijkstra(s):
    used = [1] * N
    dp = [INF] * N
    dp[s] = 0
    hq = []
    used[s] = 0
    for i in cost[s]:
        heappush(hq, i)

    while hq:
        minv = heappop(hq)
        if used[minv[1]] == 0:
            continue
        v = minv[1]
        dp[v] = minv[0]
        used[v] = 0
        for i in cost[v]:
            if used[i[1]]:
                heappush(hq, [i[0] + dp[v], i[1]])
    return dp

INF = 10 ** 18

N, M = map(int, input().split())
cost = [[] for _ in range(N)]

for i in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    cost[a].append([1, b])
    cost[b].append([1, a])

dp1 = dijkstra(0)

for i in dp1:
    if i == INF:
        print('No')
        exit()

print('Yes')
for i in range(1, N):
    tmp = dp1[i] - 1
    for j in cost[i]:
        if dp1[j[1]] == tmp:
            print(j[1] + 1)
            break

Measured memory_bytes: 72068
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var nextReader func() string

func newScanner() func() string {
	sc := bufio.NewScanner(os.Stdin)
	sc.Buffer(make([]byte, 1024), int(1e11))
	sc.Split(bufio.ScanWords)
	return func() string {
		sc.Scan()
		return sc.Text()
	}
}

func nextString() string { return nextReader() }

func nextInt() int { n, _ := strconv.Atoi(nextReader()); return n }

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

func main() {
	nextReader = newScanner()
	H := nextInt()

	cnt := 1
	for H/2 >= 1 {
		H /= 2
		cnt++
	}
	var sum int
	for i := 0; i < cnt; i++ {
		sum += pow(2, i)
	}
	fmt.Println(sum)
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

int t[100010],a[100010];
ll MOD=1e9+7;
signed main(){
    int n;
    cin>>n;
    vector<int>l(n,0);
    vector<int>r(n,0);
    REP(i,n) cin>>t[i];
    REP(i,n) cin>>a[i];
    //右から見て更新したところに注意
    for(int i=n-2;i>=0;i--){
        if(a[i]>a[i+1]){
            if(t[i]<a[i]){
                cout<<0<<endl;
                return 0;
            }
        }
    }
    if(t[n-1]!=a[0]){
        cout<<0<<endl;
        return 0;
    }
    
    //ある位置で高さの可能性がなん通りあるか　
    l[0]=1;
    for (int i = 1; i < n; i++)
    {
        if(t[i]!=t[i-1]) {
            l[i]=1;
        }
        else{
            l[i]=t[i];
        }
    }
    r[n-1]=1;
    for(int i=n-2;i>=0;i--){
        if(a[i+1]!=a[i]) 
            r[i]=1;
        else r[i]=a[i];
    }
    ll ans=1;
   // show(l);
    //show(r);
    for (int i = 0; i < n; i++)
    {
        ans*=min(l[i],r[i]);
        ans%=MOD;
    }
    cout<<ans<<endl;
     
    return 0;
}

Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		
		int ans = (b / a < c) ? b / a : c;
        System.out.println(ans);
	}
}



Measured memory_bytes: 22612
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <string>
#include <algorithm>
using namespace std;

struct TreeNode {
    int val;
    TreeNode *left;
    TreeNode *right;
    TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
};

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<int> G[N];
    vector<P> E(N - 1);
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
        E[i] = P(a, b);
    }

    queue<int> que;
    que.push(0);
    vector<bool> visited(N, false);
    visited[0] = true;

    int res = 0;
    vector<int> color(N, 0);
    map<P, int> m;
    while (!que.empty()) {
        int u = que.front(); que.pop();
        res = max(res, (int)G[u].size());

        int curr = 1;
        for (int v : G[u]) {
            if (visited[v]) continue;
            if (color[u] == curr) curr++;
            color[v] = m[P(u, v)] = curr++;
            visited[v] = true;
            que.push(v);
        }
    }

    cout << res << endl;
    for (P p : E) {
        cout << m[p] << endl;
    }
    return 0;
}


Measured memory_bytes: 13440
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define ll              long long
#define dd              double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define vll             vector<long long>
#define vdd             vector<double>
#define vpii            vector<pair<int,int>>
#define vpll            vector<pair<long long,long long>>
#define vvi             vector<vector<int>>
#define vvl             vector<vector<long long>>
#define mii             map<int,int>
#define mll             map<long long,long long>
#define umii            unordered_map<int,int>
#define umll            unordered_map<long long,long long>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define rep(i,n)        for(int i=0;i<n;i++)
#define rep2(i,a,b)     for(int i=a;i<b;i++)
#define rev(i,n)        for(int i=n;i>=0;i--)
#define rev2(i,a,b)     for(int i=a;i>=b;i--)
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define inf             9e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define fio             ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl            '\n'
#define all(x)          x.begin(),x.end()
#define d0(x)           cout <<x<<" "
#define d1(x)           cout <<x<<endl
#define d2(x,y)         cout <<x<<" "<<y<<endl
#define d3(x,y,z)       cout <<x<<" "<<y<<" "<<z<<endl
#define d4(x,y,z,w)     cout <<x<<" "<<y<<" "<<z<<" "<<w<<endl
#define read2(x,y)      cin>>x>>y
#define read3(x,y,z)    cin>>x>>y>>z
#define read4(x,y,z,w)  cin>>x>>y>>z>>w
#define read5(x,y,z,w,a)cin>>x>>y>>z>>w>>a
#define sz(a)           (int)a.size()
const ll mod=1e9+7;
const double PI = 3.14159265359;
const ll MOD=998244353;
void i_o()
{
   #ifndef ONLINE_JUDGE
   freopen("input.txt", "r", stdin);
   freopen("output.txt", "w", stdout);
   #endif
}

int help(vi& a,vi& b,vi& c){
   int n=sz(a);
   vvi dp(n,vi(3));
   dp[0][0]=a[0],dp[0][1]=b[0],dp[0][2]=c[0];
   rep2(i,1,n){
      dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
      dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
      dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
   }
   return max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
}
int main() {
   fio
  // i_o();
   int n;
   cin>>n;
   vi a(n),b(n),c(n);
   rep(i,n) cin>> a[i]>>b[i]>>c[i];
   d1(help(a,b,c));
   return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
int main()
{
    int a,b;
    cin >> a >> b;
    string s = to_string(a);
    s += to_string(b);
    int x = stoi(s);
    int c = sqrt(x);
    if(c == sqrt(x)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    int t=1;
    //cin>>t;
    string s;
    cin>>s;
    ll N=s.size();
    ll ar[N]={};
    ar[0]=1;
    ar[1]=10;
    for(ll i=2;i<N;i++)
        ar[i]=(10*ar[i-1])%2019;
    ll rem[N]={};
    rem[0]=(s[0]-'0')*(ar[N-1]);
    rem[0]%=2019;
    for(ll i=1;i<N;i++)
        rem[i]=(((s[i]-'0')*ar[N-1-i])%2019+rem[i-1])%2019;
    map<ll,ll> ma;
    ma[0]=1;
    for(ll i=0;i<N;i++)
        ma[rem[i]]++;
    ll ans=0;
    for(auto i:ma)
        ans+=(i.ss*i.ss-i.ss)/2;
    cout<<ans<<endl;
}

//8310926

//234 330 1283 722

Measured memory_bytes: 6848
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

int main(int argc, char const *argv[])
{
	sync;
	ll N = 1000000000000001;
	ll n;
	cin >> n;
	string output = "";
    while(n > 0){
        int res = n%26;
        if(res > 0){
            char c = res-1+'a';
            string s;
            s.pb(c);
            output.insert(0,s);
            n /= 26;
        }
        else{
            output.insert(0,"z");
            n = n/26-1;
        }
    }
    cout << output << endl;
	return 0;
}


Measured memory_bytes: 3640
<?php
  list($N) = explode(" ", trim(fgets(STDIN)));
  $x=[];
  $y=[];
  $h=[];
  for ($i=0; $i<$N; $i++) {
    list($x[], $y[], $h[]) = explode(" ", trim(fgets(STDIN)));    
  }

  for($i=0;$i<=100;$i++){
    for($j=0;$j<=100;$j++){
      $isOKH1=true;
      for($k=0;$k<$N;$k++){
        if($h[$k] != 0){
          $H=$h[$k]+abs($i-$x[$k])+abs($j-$y[$k]);
          break;
        }
      }

      for($k=0;$k<$N;$k++){
        if($h[$k] == 0){
          if($H-abs($i-$x[$k])-abs($j-$y[$k]) > 0){
            $isOKH1=false;
          }
        }else{
          $H1=$h[$k]+abs($i-$x[$k])+abs($j-$y[$k]);
          if($H != $H1){
            $isOKH1=false;
          }
        }
      }
      if($isOKH1){
        echo $i." ".$j." ".$H;
        echo PHP_EOL;
        exit;
      }
    }
  }

Measured memory_bytes: 16260
import math
import copy
def prime_factorize(n):
    a = [n]
    for i in range(2, math.floor(n ** 0.5) + 1):
        if n % i == 0:
            a.append(i)
            if n // i != i:
                a.append(n // i)
    return a

N = int(input())
prime_n = prime_factorize(N)
prime_n_1 = prime_factorize(N - 1)

ans = 0
for i in prime_n:
    n = copy.deepcopy(N)
    while (n % i) == 0:
            n = n // i
    if (n % i) == 1:
        ans += 1
ans += len(prime_n_1)
if N > 2:
    print(ans)
else:
    print(1)

Measured memory_bytes: 9608
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


# 処理内容
def main():
    K = int(input())
    S = input()[:-1]

    if len(S) <= K:
        print(S)
    else:
        print(S[:K] + "...")


if __name__ == '__main__':
    main()

Measured memory_bytes: 77524
#include<bits/stdc++.h>
#define lp3(i,a,b) for(int i=a;i<b;i++)
#define lp2(i,n) for(int i=0;i<n;i++)
#define ll long long
#define W 1000000007
using namespace std;

int main(){
	string w,j="Yes";
	cin>>w;
	int n,h[26]={};
	lp2(j,w.size()){
		n=0;
		for(int i='a';i<='z';i++){
		if(w[j]==i){
			h[n]++;
			break;
		}
		n++;
			}
	}
	lp2(i,26){
		if(h[i]%2!=0){
			j="No";
			break;
		}
	}
	cout<<j<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
 
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define mod 1000000007
using ll = long long;
using namespace std;
int h,w;
int checkT(vvi &c, int x){
  rep(i, h){
    if(c[i][x]) return 0;
  }
  return 1;
}
int checkY(vvi &c, int y){
  rep(i, w){
    if(c[y][i]) return 0;
  }
  return 1;
}
int main(){
  cin >> h >> w;
  vvi a(h, vi(w));
  rep(y, h){
    rep(x, w){
      char c;
      cin >> c;
      a[y][x] = (c == '#') ? 1 : 0;
    }
  }
  rep(y, h){
    rep(x, w){
      if(checkY(a, y)) break;
      if(!checkT(a, x)){
        char ans = (a[y][x] ? '#' : '.');
        cout << ans;
      }
    }
    if(!checkY(a, y)) cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const int MAX = 100010;

int main() {
    int k; cin >> k;
    int ans;
    if (k % 2 == 1) {
        ans = (k / 2) * ((k + 1) / 2);
    } else {
        ans = pow(k / 2, 2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = list(map(int, input().split()))
xy = [map(int, input().split()) for _ in range(a[0])]
x, y = [list(i) for i in zip(*xy)]
c = 0
for i in range(a[0]):
  if a[1]**2 >= x[i]**2 +y[i]**2:
    c += 1
print(c)

Measured memory_bytes: 116556
#include<stdio.h>
int main(){
	int i,j,r,c,a[101][101],yoko=0,tate=0;
	scanf("%d %d",&r,&c);
	for(i=0;i<r;i++){
		for(j=0;j<c;j++){
			scanf("%d",&a[i][j]);
			yoko+=a[i][j];
		}
		a[i][c]=yoko;
		yoko=0;
	}
	for(i=0;i<c+1;i++){
		for(j=0;j<r;j++){
			tate+=a[j][i];
		}
		a[r][i]=tate;
		tate=0;
	}
	for(i=0;i<r+1;i++){
		for(j=0;j<c+1;j++){
			printf("%d",a[i][j]);
			if(j!=c){
				printf(" ");
			}
		}
		printf("\n");
	}
}
	
	


Measured memory_bytes: 2072
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ar[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin>>k;
    cout<<ar[k-1];

}


Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n").map(Number);
for(var i=0;i<Arr.length;i=i+2){
var x=Arr[i];
var h=Arr[i+1];
if(x==0 && h==0)break;
var S=x*Math.sqrt(4*h*h+x*x)+x*x;
console.log(S.toFixed(5));
}

Measured memory_bytes: 7640
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>


using namespace std;
#define MAX 100000

int main(){
    string  S, T;
    cin >> S;
    cin >> T;
    

    for (int i = 0; i < S.length(); i++){
        if (S == T){
            printf("Yes");
            return 0;
        }
        S.insert(S.begin(), S.back());
        S.pop_back();
    }
    printf("No");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int D, T, S;

    cin >> D >> T >> S;

    int x = T * S;
    if (x >= D) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3616
s = int(input())
kaku = set()
kaku.add(s)
def f(x):
  if x %2 == 0:
    return x//2
  else:
    return 3*x+1
for i in range(2,10**9):
  s = f(s)
  if s in kaku:
    print(i)
    exit()
  kaku.add(s)

Measured memory_bytes: 3060
def bubble(n, a)
    flag = true
    c = 0
    while flag do
        flag = false
        0.upto(n-2) do |i|
            (a[i], a[i+1], c, flag = a[i+1], a[i], c+1, true) if a[i] > a[i+1]
        end
    end
    puts a.join(" "), c
end
bubble(gets.to_i, gets.split.map(&:to_i))

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

using namespace std;

#define int long long
#define all(v) begin(v), end(v)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define min(...) min({__VA_ARGS__})
#define max(...) max({__VA_ARGS__})

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using pint = pair<int, int>;
using tint = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

struct Dinic {
  struct edge {
    int to, cap, rev;
    edge(){}
    edge(int to, int cap, int rev):to(to), cap(cap), rev(rev){}
  };
  vector< vector<edge> > graph;
  vector<int> level, iter;
  Dinic(int V):graph(V), level(V), iter(V){}
  void add_edge(int from, int to, int cap) {
    graph[from].emplace_back(to, cap, graph[to].size());
    graph[to].emplace_back(from, 0, graph[from].size()-1);
  }
  void bfs(int s) {
    fill(all(level), -1);
    queue<int> que;
    level[s] = 0;
    que.push(s);
    while(que.size()) {
      int v = que.front(); que.pop();
      for(edge& e : graph[v]) {
	if(e.cap > 0 && level[e.to] < 0) {
	  level[e.to] = level[v] + 1;
	  que.push(e.to);
	}
      }
    }
  }
  int dfs(int v, int t, int f) {
    if(v == t) return f;
    for(int &i = iter[v]; i < graph[v].size(); i++) {
      edge& e = graph[v][i];
      if(e.cap > 0 && level[v] < level[e.to]) {
	int d = dfs(e.to, t, min(e.cap, f));
	if(d > 0) {
	  e.cap -= d;
	  graph[e.to][e.rev].cap += d;
	  return d;
	}
      }
    }
    return 0;
  }
  int max_flow(int s, int t) {
    int flow = 0;
    for(;;) {
      bfs(s);
      if(level[t] < 0) return flow;
      fill(all(iter), 0);
      int f; while((f = dfs(s, t, inf)) > 0) flow += f;
    }
  }
};

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int N, M, L;
  while(cin >> N >> M >> L) {
    int wf[101][101];
    fill(wf[0], wf[101], inf);
    rep(i, N) wf[i][i] = 0;
    rep(i, M) {
      int a, b, d;
      cin >> a >> b >> d;
      --a, --b;
      wf[a][b] = wf[b][a] = d;
    }

    rep(i, N) rep(j, N) rep(k, N) {
      chmin(wf[j][k], wf[j][i] + wf[i][k]);
    }

    int P[101], K[101];
    rep(i, N) cin >> P[i];
    rep(i, N) cin >> K[i];

    int s = 2*N, t = s + 1, V = t + 1;
    Dinic graph(V);
    rep(i, N) {
      graph.add_edge(s, i, P[i]);
      rep(j, N) {
	if(wf[i][j] < L) graph.add_edge(i, N+j, inf);
      }
      graph.add_edge(N+i, t, K[i]);
    }
    cout << graph.max_flow(s, t) << endl;
  }

  return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll a[100][100001];

ll f(ll w[], ll v[], ll n, ll W)
{
    if(W<0) return -9999999999;
    if(n<0)  return 0;
    if(W==0) {a[n][W]=0; return 0;}
    if(a[n][W]!=-1) return a[n][W];
    a[n][W]=max(f(w,v,n-1,W), v[n]+f(w,v,n-1,W-w[n]));
    return a[n][W];
}
int main() {
    for(ll i=0;i<100;i++)
    {
        for(ll j=0;j<=100000;j++)
        {
            a[i][j]=-1;
        }
    }
	ll n,W;
	cin>>n>>W;
	ll w[n]; // weight
	ll v[n]; // value
	for(ll i=0;i<n;i++) cin>>w[i]>>v[i];
	cout<<f(w,v,n-1,W);
	return 0;
}


Measured memory_bytes: 78336