akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int GCD(int a, int b) {
	if (b%a == 0)return a;
	return GCD(b%a, a);
}

int N, A[100002], btoi[100002], etoi[100002];

int main() {
	cin >> N >> A[0];
	btoi[0] = A[0];
	for (int i = 1; i < N; i++) {
		cin >> A[i];
		btoi[i] = GCD(btoi[i - 1], A[i]);
	}
	etoi[N - 1] = A[N - 1];
	for (int i = N - 2; i >= 0; i--) 
		etoi[i] = GCD(A[i], etoi[i + 1]);
	int ans = max(btoi[N - 2], etoi[1]);
	for (int i = 1; i < N - 1; i++) {
		ans = max(ans, GCD(btoi[i - 1], etoi[i + 1]));
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ALL(A) (A).begin(), (A).end()
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;
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; }

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int x;
    cin >> x;
    cout << 360/__gcd(x,360) << endl;
}

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

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

    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a.at(i);

    int num = 1, cnt = 0;
    for (int i = 0; i < n; i++) {
        if (a.at(i) == num) {
            num++;
        } else {
            cnt++;
        }
    }

    if (n == cnt) {
        cout << -1 << endl;
    } else {
        cout << cnt << endl;
    }

    return 0;
}


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

int main() {

    int N;

    cin >> N;
    int A[N];
    long double sum = 0;

    rep(i, N){
        cin >> A[i];
        sum += (long double)1.0/A[i];
    }
    cout << fixed << setprecision(15) << (long double)1.0/sum << endl;
}


Measured memory_bytes: 256
# AOJ 1576: Community Integration
# Python3 2018.7.13 bal4u

# UNION-FIND library
class UnionSet:
	def __init__(self, nmax):
		self.size = [1]*nmax
		self.id = [i for i in range(nmax+1)]
	def root(self, i):
		while i != self.id[i]:
			self.id[i] = self.id[self.id[i]]
			i = self.id[i]
		return i
	def connected(self, p, q): return self.root(p) == self.root(q)
	def unite(self, p, q):
		i, j = self.root(p), self.root(q)
		if i == j: return
		if self.size[i] < self.size[j]:
			self.id[i] = j
			self.size[j] += self.size[i]
		else:
			self.id[j] = i
			self.size[i] += self.size[j]
# UNION-FIND library

N, M = map(int, input().split())
u = UnionSet(N+1)
f = [0]*(N+1)
for i in range(M):
	a, b = map(int, input().split())
	u.unite(a, b)
for i in range(1, N+1): f[u.root(i)] += 1
a = b = 0
for i in range(1, N+1):
	if f[i] == 1: a += 1
	elif f[i] > 1: b += 1
print(abs(a-b))


Measured memory_bytes: 5632
//contact me:subhajitmahata06@gmail.com 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h> 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;i<n;i++)
#define fr(i,k,n) for(ll i=k;i>n;i--)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define int ll
//===========================templates=========================
 int32_t main() {
    fast;
    ll h,n;
    cin>>h>>n;
    ll res=0;
    int a[n];
    fo(i,n) cin>>a[i];
    fo(i,n) res+=a[i];
    if(h<=res)
    cout<<"Yes";
    else
    {
        cout<<"No";
    }
    
	return 0;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
 
int swap_log[1000][2];
 
void swap(int *A, int i, int j) {
  int temp;
  temp = A[i];
  A[i] = A[j];
  A[j] = temp;
}
 
void Merge(int *A, int left, int mid, int right) {
  int n1,n2,*L,*R,i,j,k;
  n1 = mid -left;
  n2 = right - mid;
  L = (int*)malloc(sizeof(int) * (n1+1));
  R = (int*)malloc(sizeof(int) * (n2+1));
  for (i = 0; i< n1; i++) L[i] = A[left+i];
  for (i = 0; i < n2; i++) R[i] = A[mid+i];
  L[n1] = INT_MAX; R[n2] = INT_MAX;
  i = 0;j = 0;
  for(k = left; k < right; k++) {
    if (L[i] < R[j]) {
      A[k] = L[i];
      i++;
    }else {
      A[k] = R[j];
      j++;
    }
  }
  free(L);
  free(R);
}
 
void Merge_Sort(int *A, int left, int right) {
  if(left+1 < right) {
    int mid = (left + right)/2;
    Merge_Sort(A,left,mid);
    Merge_Sort(A,mid,right);
    Merge(A,left,mid,right);
  }
}
long step_sort(int *w, int *w1, int i) {
  int j,k;
  long sum = 0;
  k = 0;
  while(w[i] != w1[i]) {
    j = 0;
    while (w[j] != w1[i]) j++;
    sum += w[i]+w[j];
    swap(w,i,j);
    swap_log[k][0] = i; swap_log[k][1] = j;
    i = j;
    k++;
  }
  swap_log[k][0] = 0; swap_log[k][1] = 0;
  return sum;
}
 
int search_min(int *w, int *w1,int n) {
  int i,j;
  i = 0;
  while(1) {
    j = 0;
    while(w[j] != w1[i]) j++;
    if(i != j) break;
    i++;
    if(i >= n) return n;
  }
  return j;
}
 
long run_log(int *w) {
  int i = 0;
  long sum = 0;
  while(swap_log[i][0] != swap_log[i][1]) {
    sum += w[swap_log[i][0]]+w[swap_log[i][1]];
    swap(w,swap_log[i][0],swap_log[i][1]);
    i++;
  }
  return sum;
}
 
long sub_sort(int *w, int *w1, int i) {
  long sum;
 
  if(w[0] != w1[0]) return LONG_MAX;
  int j = 0;
  while(w[i] != w1[j]) j++;
  sum = w[i] + w[0];
  swap(w,i,0);
  sum += run_log(w);
  sum += w[0] + w[j];
  swap(w,0,j);
   
  return sum;
}
 
long repeat_sort(int *w, int *w1, int n,long now) {
  int i;
  int a1[n];
  long v1,v2;
  for (i = 0; i < n; i++) a1[i]=w[i];
  i = search_min(w,w1,n);
  if(i == n) return now;
  v1 = step_sort(w,w1,i);
  v2 = sub_sort(a1,w1,i);
  long min = (v1 < v2) ? v1:v2;
  return repeat_sort(w,w1,n,now+min);
}
 
long much_sort(int *w, int *w1, int n) {
  int i,j;
  long sum = 0;
  char *checked = (char*)calloc(n,sizeof(char));
  i = 0;
  while(i < n) {
    j = 0;
    while(w[j] != w1[i]) j++;
    if(i != j) {
      if(w1[j] ==  w[i]) {
    sum += w[i] + w[j];
    swap(w,i,j);
      }
    }
    checked[i]=1;checked[j]=1;
    while(i < n && checked[i]!=0)i++;
  }
  free(checked);
  return sum;
}
 
int main()
{
  int i,n,*w,*w2;
  long sum;
  scanf("%d",&n);
  w = (int*)malloc(sizeof(int) * n);
  w2 = (int*)malloc(sizeof(int) * n);
  for (i = 0; i < n; i++) {
    scanf("%d",w+i);
    w2[i] = w[i];
  }
  Merge_Sort(w2,0,n);
   
  sum = much_sort(w,w2,n);
  sum += repeat_sort(w,w2,n,0);
  printf("%ld\n",sum);
   
  return 0;
}

Measured memory_bytes: 1936
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

def main():
    A, B, K = map(int, input().split())

    if A >= K:
        print(A - K, B)
    elif A < K:
        if K - A >= B:
            print(0, 0)
        else:
            print(0, B - (K - A))

if __name__ == '__main__':
    main()

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

int main() {
	int n;
	while(cin >> n && n != 1){
		bool prime[300001];
		for(int i = 0; i <= n; ++i)
			prime[i] = true;
		
		cout << n << ":";
		for(int i = 2; i <= n; ++i){
			if(!prime[i])
				continue;
			
			if(n % i == 0 && (i % 7 == 1 || i % 7 == 6)){// && ((n / i) % 7 == 1 || (n / i) % 7 == 6)){
				cout << " " << i;
				for(int j = i * 2; j <= n; j += i)
					prime[j] = false;
			}
		}
		cout << endl;
	}
	return 0;
}

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

static const int N = 100;

int main()
{
  int p,ppp[N+1],m[N+1][N+1];

  cin >> p;

  for( int i = 1; i <= p; i++)
    {
      cin >> ppp[i-1] >> ppp[i];
    }

  for (int i = 1; i <= p; i++) m[i][i] = 0;
  for (int k = 2; k <= p; k++)
    {
      for(int i = 1; i <= p-k+1 ; i++)
	{
	  int j = i + k - 1;
	  m[i][j] = (1 << 21);

	  for ( int q = i; q <= j-1 ; q++)
	    {
	      m[i][j] = min(m[i][j], m[i][q] + m[q+1][j] +
			      ppp[i-1] * ppp[q] * ppp[j]);
	    }
	}
    }

  cout << m[1][p] << endl;

  return 0;
}
	



Measured memory_bytes: 3124
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int a = int.Parse(input[0]);
		int b = int.Parse(input[1]);

		int c = a * b % 2;

		string s;
		if(c == 0)
		{
			s = "Even";
		} else
		{
			s = "Odd";
		}
		//出力
		Console.WriteLine(s);
	}
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;
using ll = long long;

int main()
{
    int a,k,b;
    int ans = 0;
    
    cin >> k;
    cin >> a >> b;
    
    for (int i = a;i <= b;i++){
        if (i%k == 0){
            ans = 1;
            break;
        }
    }
    if (ans == 1){
        cout << "OK" << endl;
    }
    else {
        cout << "NG" << endl;
    }
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define LL long long
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n;
int h[100010];
int dp[100010];
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)cin>>h[i];
	dp[1]=0;
	dp[2]=abs(h[2]-h[1]);
	for(int i=3;i<=n;i++)dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
	cout<<dp[n]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <algorithm>
typedef long long ll;

using namespace std;
int main() {
	ll n;

	cin >> n;
	ll ans = n - 1;
	ll search_max = sqrt(n) + 1;


	for (ll i = 1; i <= search_max; i++) {
		if (n % i == 0) {
			ll j = n / i;
			ll cur = i + j - 2;
			ans = min(ans, cur);
		}
	}

	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 888
/***** TheAnshul *****/

#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define ppb         pop_back
#define	endl		'\n'
#define mii         map<ll int,ll int>
#define msi         map<string,ll int>
#define mis         map<ll int, string>
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define mpi         map<pair<ll int,ll int>,ll int>
#define pii         pair<ll int,ll int>
#define vi          vector<ll int>
#define vii         vector<pair<ll int, ll int>>
#define vs          vector<string>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll int)x.size()
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp          make_pair
#define what_is(x)  cerr << #x << " is " << x << endl;
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
#define N  100005
ll dp[25][4194314];
bool a[25][25];
ll n;
ll expo(ll base, ll exponent, ll mod) {								//return base^exponent modulo modulus
    ll ans = 1;
    while(exponent !=0 ) {
        if((exponent&1) == 1) {
            ans = ans*base ;
            ans = ans%mod;
        }
        base = base*base;
        base %= mod;
        exponent>>= 1;
    }
    return ans%mod;
}
ll fun(ll p,ll mask)
{
	if(p==n)
	{
		return 1;
	}
	if(dp[p][mask]!=-1)
		return dp[p][mask];
	ll pw=1,ans=0;
	rep(i,0,n)
	{
		if((!(pw&mask)) && (a[p][i]))
		{
			ans+=fun(p+1,(mask+pw));
			ans%=hell;
		}
		pw*=2;
	}
	dp[p][mask]=ans%hell;
	return (ans%hell);
}
void solve()
{
	cin>>n;
	rep(i,0,n)
	{
		rep(j,0,n)
		{
			cin>>a[i][j];
		}
	}
	ll vl=expo(2,n+1,hell)+5;
	rep(i,0,n+1)
	{
		rep(j,0,vl)
		{
			dp[i][j]=-1;
		}
	}
	cout<<fun(0,0);
	return;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
	while(TESTS--)
	{
		solve();
	}
	time
	return 0;
}

Measured memory_bytes: 723328
n = int(input())
a = [0 for _ in range(101**3+1)]
for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      p = i**2 + j**2 + k**2 + i*j + j*k + k*i
      if p <= 10010:
        a[p] += 1
for i in range(1,n+1):
  print(a[i])

Measured memory_bytes: 17116
#include <iostream>
#include <math.h>
#include<iomanip>
using namespace std;

long double abc(long double n,long double x1,long double x2,long double y1,long double y2)
{
	long double r;
	r = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	r /= n;
	return r;
}
int main()
{
	long double n;
	cin>>n;
	long double x[8],y[8];
	for(size_t i = 0; i<n; i++)
	{
		cin>>x[i]>>y[i];
	}
	long double ans = 0;
	for(size_t i = 0; i<n; i++)
	{
		for(size_t ii = 0; ii<n; ii++)
		{
			if(i!=ii)
			{
				ans =ans + abc(n,x[i],x[ii],y[i],y[ii]);
			}
		}
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans = 0
    if x > y:
        p = (x - y)*a
    elif y > x:
        p = (y - x)*b
    else:
        p = 0
    print(min(a*x + b*y, 2*c*max(x, y), 2*c*min(x, y) + p))


if __name__ == '__main__':
    main()


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

int main(int argc, char const *argv[])
{
	int n,m;
	cin>>n>>m;
	vector<string> A(n);
	for(int i = 0;i<n;i++)
		cin>>A[i];

	vector<vector<int>> dp(n+1, vector<int> (m+1, 0));
	int mod = 1e9+7;

	for(int i = 1;i<=n;i++)
	{
		for(int j = 1;j<=m;j++)
		{
			if(i == 1 && j==1)
			{
				if(A[i-1][j-1] == '.')
					dp[i][j] = 1;
			}
			else
			{
				if(A[i-1][j-1] == '.')
				{
					dp[i][j] = (dp[i-1][j]%mod + dp[i][j-1]%mod)%mod;
				}
			}
		}
	}

	cout<<dp[n][m]%mod<<endl;
	return 0;
}

Measured memory_bytes: 5248
#include <cstdio>

#define iter(i, n) for (int i = 1; i <= n; ++i)

const int NR = 1e5 + 100;

int n, a[NR], c[2];

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

int main() {
	//freopen("10D.in", "r", stdin);
	scanf("%d", &n);
	iter(i, n) scanf("%d", &a[i]);

	bool cur = 0;
	while (true) {
		c[0] = c[1] = 0;
		iter(i, n) ++c[a[i] % 2];
		if (c[0] % 2 != 0) { cur ^= 1; break; }
		if (c[1] > 1 || c[0] + c[1] == 1) break;
		bool fail = false;
		iter(i, n) if (a[i] % 2) {
			if (a[i] > 1) --a[i];
			else { fail = true; break; }
		}
		if (fail) break;
		int d = a[1];
		iter(i, n) d = gcd(d, a[i]);
		iter(i, n) a[i] /= d;
		cur ^= 1;
	}

	puts(cur ? "First" : "Second");
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":"\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

int N;
int lca(int u,int v) {
    if(u==v) return u;
    if(u<v) {
        return lca(u,(v-1)/N);
    } else {
        return lca((u-1)/N,v);
    }
}
signed main() {
    int Q;
    cin>>N>>Q;
    REP(i,Q) {
        int u,v;
        cin>>u>>v;
        u--,v--;
        if(N==1) {
            cout<<min(u,v)+1<<endl;
        } else{
            cout<<lca(u,v)+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 1280
I=lambda:list(map(int,input().split()))
n,W=I()
g=[0]+[I()for _ in range(n)]
dp=[[0]*-~W for _ in range(n+1)]
for i in range(1,n+1):
    t=g[i]
    for j in range(W+1):
        if j-t[0]>=0:
            dp[i][j]=max(dp[i-1][j],dp[i-1][j-t[0]]+t[1])
        else:
            dp[i][j]=dp[i-1][j]
print(max(dp[-1]))

Measured memory_bytes: 120152
/*
AUTHOR: Aman Raj
LANG: C++
*/

using namespace std;

typedef   long long  ll;
#include <bits/stdc++.h>


//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
#define fast  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
#define all(a) a.begin(),a.end()
#define mod 998244353
#define inf 1e9
//#define mod 3
#define flush fflush(stdout)

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef cc_hash_table<int, ll, hash<ll> > ht;

// find_by_order()  // order_of_key
typedef tree<
    int,
    null_type,
    less<long long int>,
    rb_tree_tag,
    tree_order_statistics_node_update>
    ordered_set;






ll power1(ll a, ll b)//a raised to power b
   {  if(b<=0) return 1; if(b==1) return a;
       ll c=power1(a,b/2);
        c*=c;c=c%mod;if(b%2==1) c*=a;c=c%mod;
        return c;
   }
   ll mi(ll a,ll m)
   { ll c= power1(a,m-2);

     return c;
   }


 ll calc(string s)
 {
     ll a=0;
      for(auto x:s)
      {
          if(x=='(')a++;
          else a--;
      }
      return a;
 }
 bool comp1(string s1,string s2)
 {
     ll a1=0,a2=0;
     ll a=0;
      for(auto x:s1)
      {
           if(x=='(')a++;
           else a--;
           a1=min(a1,a);
      }
      a=0;
       for(auto x:s2)
      {
           if(x=='(')a++;
           else a--;
           a2=min(a2,a);
      }
      return a1>a2;

 }
  int main()
{    fast;
    ll n;cin>>n;
     vector<string> v(n);
      for(auto &x:v)cin>>x;
      vector<ll> vpsahi,vn;
       priority_queue<pair<ll,ll> > pq,pqn;
       ll ans=0;
        bool ok=true;
      for(auto x:v)
      {
          ll a1=0,a=0;
           for(auto y:x)
           {
               if(y=='(')a++;else a--;
                a1=min(a1,a);
           }
           if(a>=0&&a1>=0)ans+=a;
           else if(a>=0)pq.push({a1,a});
           else  pqn.push({-1*a1+a,a});
      } 
      while(pq.size()>0)
      {
          ll a1=pq.top().first,a=pq.top().second;
          pq.pop();
          if(ans+a1<0){ ok=false;}
          ans+=a;

      }
      while(pqn.size()>0)
      {
          ll a1=pqn.top().first,a=pqn.top().second;
          pqn.pop();
          a1-=a;
          if(ans-a1<0){ ok=false;}
          ans+=a;


      }


      if(ok&&ans==0)cout<<"Yes";
      else cout<<"No";
}


Measured memory_bytes: 42812
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
using namespace std;
typedef long long LL;
const int INF = 999999999;

struct edge{
    int src, to, cost;
};
using Edges = vector<edge>;

vector<int> bellman_ford(Edges &E, int V, int st){
    vector<int> dist(V, INF);
    dist[st] = 0;
    rep(i, V-1){
        for(auto &e: E){
            if(dist[e.src] == INF) continue;
            dist[e.to] = min(dist[e.to], dist[e.src]+e.cost);
        }
    }
    for(auto &e: E){
        if(dist[e.src] == INF) continue;
        if(dist[e.to] > dist[e.src]+e.cost){
            // 負閉路が存在
            return vector<int>();
        }
    }
    return dist;
}

int main(){
    int n, m, r;
    cin >> n >> m >> r;
    Edges E;
    rep(i, m){
        int s,t,d;
        cin >> s >> t >> d;
        E.emplace_back((edge){s,t,d});
    }
    vector<int> ans = bellman_ford(E, n, r);
    if(ans.size() == 0){
        cout << "NEGATIVE CYCLE" << endl;
        return 0;
    }
    rep(i, n){
        if(ans[i] == INF) cout << "INF" << endl;
        else cout << ans[i] << endl;
    }
}





Measured memory_bytes: 3196
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;

struct data{
    int a, b, cost;
};

bool cmp(data d1, data d2){
    return d1.cost < d2.cost;
}

struct UF{
    vector<int> par;
    vector<int> sz;
    void init(int n){
        par.resize(n);
        sz.resize(n, 1);
        rep(i, 0, n) par[i] = i;
    }
    int find(int x){
        if(x == par[x]) return x;
        return par[x] = find(par[x]);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
};

signed main(){
    int n, m;
    while(1){
        cin >> n >> m;
        if(n + m == 0) break;
        vector<data> d(m);
        rep(i, 0, m){
            cin >> d[i].a >> d[i].b >> d[i].cost;
        }
        sort(all(d), cmp);
        UF uf;
        uf.init(n);
        int ans = 0;
        rep(i, 0, m){
            int u = d[i].a, v = d[i].b;
            if(!uf.same(u, v)){
                uf.unite(u, v);
                ans += d[i].cost;
            }
        }
        cout << ans << endl;
    }  
}

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

int main() {
	int n;
	cin >> n;
	double probabilities[n];
	double solve[n+1][n+1]/*={{0.0d}}*/;
	for(int i=0;i<=n;i++)
        for(int j=i;j<=n;j++)
        	solve[i][j]=0.0d;
	for(int i=0;i<n;i++)
		cin >> probabilities[i];
	solve[0][0]=1;
	for(int i=0;i<=n;i++)
        for(int j=i;j<=n;j++)
            {
                solve[i][j+1]+=solve[i][j]*(1-probabilities[j]);
                solve[i+1][j+1]=solve[i][j]*(probabilities[j]);
            }
    double totalProbability=0.0d;
    for(int i=0;i<(n+1)/2;i++)
        totalProbability+=solve[i][n];
    cout << setprecision(10) << (1-totalProbability) << "\n";
    return 0;
}

Measured memory_bytes: 70144
def bfs():
    visited = [False] * nv
    visited[0] = True
    q = [0]

    while q:
        u = q.pop(0)
        for i, w in enumerate(adj[u]):
            if not visited[i] and w > 0:
                q.append(i)
                visited[i] = True
                parents[i] = u

    return True if visited[nv - 1] else False

def maxf():
    max_flow = 0
    while bfs():
        flow = float('inf')
        c = nv - 1

        while c:
            flow = min(flow, adj[parents[c]][c])
            c = parents[c]

        max_flow += flow
        v = nv - 1

        while v:
            u = parents[v]
            adj[u][v] -= flow
            adj[v][u] += flow
            v = parents[v]

    return max_flow

nv, ne = map(int, input().split(' '))
adj = [[0] * nv for _ in range(nv)]
parents = [None] * nv

for _ in range(ne):
    s, t, w = map(int, input().split(' '))
    adj[s][t] = w

print(maxf())

Measured memory_bytes: 7816
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	void main() {
		int n = sc.nextInt();
		int s = 0; 
		int[] tt = new int[n];
		int[] vv = new int[n];
		for (int i = 0; i < n; i++)
			s += tt[i] = sc.nextInt();
		for (int i = 0; i < n; i++)
			vv[i] = sc.nextInt();
		int[] oo = new int[s];
		int[] pp = new int[s];
		int[] qq = new int[s];
		for (int h = 0; h < s; h++) {
			oo[h] = s;
			pp[h] = h;
			qq[h] = s - 1 - h;
		}
		for (int l = 0, i = 0; i < n; i++) {
			int t = tt[i], v = vv[i];
			int r = l + t;
			for (int h = l; h < r; h++)
				oo[h] = Math.min(oo[h], v);
			for (int h = r; h < s; h++)
				pp[h] = Math.min(pp[h], v + h - r);
			for (int h = 0; h < l; h++)
				qq[h] = Math.min(qq[h], v + l - 1 - h);
			l = r;
		}
		double ans = 0;
		for (int h = 0; h < s; h++) {
			int o = oo[h], p = pp[h], q = qq[h];
			if (o <= p && o <= q)
				ans += o;
			else
				ans += p == q ? p + 0.25 : Math.min(p, q) + 0.5;
		}
		println(ans);
	}
}


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

using namespace std;

bool ok(const vector<int> &v, int n) {
  while (n > 0) {
    if (v[n % 10]) return false;
    n /= 10;
  }
  return true;
}

int main() {
  int n, k;
  while (cin >> n >> k) {
    vector<int> v(10, false);
    for (int i = 0; i < k; ++i) {
      int s;
      cin >> s;
      v[s] = true;
    }

    for (int i = n; ; ++i) {
      if (ok(v, i)) {
	cout << i << endl;
	break;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < b; i++)
#define Rep(i, a, b) for(int i = a; i <= b; i++)
#define _GLIBCXX_DEBUG
#define Vl vector<ll>
#define Vs vector<string>
#define Vp vector<pair<ll, ll>>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
using namespace std;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;

// 最大公約数
ll gcd(ll a, ll b)
{
   if (a%b == 0) {
       return(b);
   } else {
       return(gcd(b, a%b));
   }
}

// 最小公倍数
ll lcm(ll a, ll b){
   return a / gcd(a, b) * b;
}

//素数判定
bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された
    if(n % 2 == 0 || n % 3 == 0) return false;
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) { 
        a = b; //a の値を b の値に置き換える 
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

/*   *   *   *   *   *   *   *   *   *   *   */

void solve() {
    ll n; cin >> n;
    ll h[100100];
    Rep(i, 1 ,n) cin >> h[i];

    ll dp[100100];
    Rep(i, 1, 100100) dp[i] = INF;
    dp[1] = 0;
    dp[2] = abs(h[2]-h[1]);
    Rep(i, 3, n){
        chmin(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        chmin(dp[i], dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n] << endl;
}

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

    solve();
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<l_l> vpl;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rrep(i,n) for(int i=1;i<=(n);i++)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=10100100100100100;
template<class T> inline bool chmin(T& a,T b){
if(a>b){
a=b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a,T b){
if(a<b){
a=b;
return true;
}
return false;
}
int main(){
    string s,t;cin>>s>>t;
    ll n=sz(s),m=sz(t);
    vector<vl> dp(n+1,vl(m+1,0));
    rep(i,n){
        rep(j,m){
            if(s[i]==t[j])chmax(dp[i+1][j+1],dp[i][j]+1);
            else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
        }
    }
    string ans="";
    while(n>0&&m>0){
        if(s[n-1]==t[m-1]){
            ans=s[n-1]+ans;
            n--;m--;
        }
        else if(dp[n][m]==dp[n-1][m])n--;
        else m--;
    }
    cout<<ans<<endl;
    return 0;
}

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

//const int mxN = 2e5+9;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int ans = 0;
    int ans2 = 0;
    string s; cin >> s;
    for(int i = 0; i < s.size(); ++i){
        if(s[i]=='R'){++ans;}
        else{
            ans = 0;
        }
        ans2 = max(ans,ans2);
    }
    cout << ans2 << endl;
    return 0;
}


Measured memory_bytes: 3584
N = int(input())
S = [input() for _ in range(N)]
mydict = {}
ans = 0
for i in range(N):
    T = [str(x) for x in S[i]]
    T.sort()
    S[i] = ''.join(T)
for j in range(N):
    if S[j] in mydict.keys():
        ans += mydict[S[j]]
        mydict[S[j]] += 1
    else:
        mydict.setdefault(S[j],1)
print(ans)

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

int main(){
  int n;
  ll d,a;
  cin>>n>>d>>a;
  vector<P> b(n);
  rep(i,0,n){
    cin>>b[i].first;
    cin>>b[i].second;
  }
  sort(b.begin(),b.end());
  
  ll total=0;
  ll ans=0;
  queue<P> q;
  rep(i,0,n){
    ll x=b[i].first;
    ll h=b[i].second;
    while(q.size() && q.front().first<x){
      total-=q.front().second;
      q.pop();
    }
    h-=total;
    if(h>0){
      ll num=(h+a-1)/a;
      ans+=num;
      ll damage=num*a;
      q.push(P(x+2*d,damage));
      total+=damage;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4992
def solve():
    N = int(input())
    T0 = []
    T1 = []
    su = 0
    for i in range(N):
        s = input()
        a = 0
        for c in s:
            if c == '(':
                a += 1
            elif a > 0:
                a -= 1
        b = 0
        for c in reversed(s):
            if c == ')':
                b += 1
            elif b > 0:
                b -= 1
        if b < a:
            T0.append((b, a))
        else:
            T1.append((a, b))
        su += a - b
    if su != 0:
        print("No")
        return

    def check(T, N):
        U = [0]*N
        cur = 0
        for i in range(N):
            k = -1; e = (-1000, -1000)
            for j in range(N):
                if U[j]:
                    continue
                b, a = T[j]
                if b <= cur:
                    ne = (a-b, b)
                    if e < ne:
                        k = j
                        e = ne
            if k == -1:
                return 0
            b, a = T[k]
            U[k] = 1
            cur += a-b
        return 1

    if check(T0, len(T0)) and check(T1, len(T1)):
        print("Yes")
    else:
        print("No")
solve()


Measured memory_bytes: 5620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    ll N, K, Q;  cin >> N >> K >> Q;
    vector<ll> A(Q);  rep(i, Q) cin >> A[i];

    vector<ll> P(N);
    rep(i, Q) {
        ++P[A[i]-1];
    }
    rep(i, N) {
        if (Q - P[i] < K) yes;
        else no;
    }

    return 0;
}

Measured memory_bytes: 2176
#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 each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

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

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; 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) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
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) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(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) { each(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; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  while (true) {
    int n; cin >> n;
    if (n == 0) return;
    int w, h; cin >> w >> h;
    vector<vi32> b(h, vi32(w));
    rep(i, n) {
      int x, y; cin >> x >> y;
      x--, y--;
      b[y][x] = 1;
    }
    int ans = 0;
    int s, t; cin >> s >> t;
    for (int i = 0; i + t <= h; i++)
    for (int j = 0; j + s <= w; j++) {
      int cnt = 0;
      for (int k = i; k < i + t; k++)
      for (int l = j; l < j + s; l++) {
        if (b[k][l] == 1) cnt++;
      }
      amax(ans, cnt);
    }
    cout << ans << '\n';
  }
}



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

#define ll long long
#define ld long long
#define pi 3.14159265359

int main() {
    int N; cin >> N;
    if ((N / 100) % 10 == 7 || (N / 10) % 10 == 7 || N % 10 == 7) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

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


using namespace std;


int main() {
    int n; cin >> n;
    vector<int> p(n); for (int i=0; i<n; i++) cin >> p[i];
    int diff = 0;

    for (int i=1; i<=n; i++) {
        if (p[i-1] != i) diff++;
    }

    if (diff <= 2) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[1001];
int main(){
    int n;cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    if(n==1)cout<<"0"<<endl;
    else cout<<a[n-1]-a[0]<<endl;
return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>
#include <queue>
#include <set>
#include <bitset>
#include <map>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<long long> vll;
typedef queue<int, int> qii;
typedef pair<int, int> pii;
typedef pair<string, int> psi;

#define PI 3.14159265359
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rept(i,n) rep(i,0,n)

//int型を受け取ってその桁数を返す
int check_digits(int n,int m) {
	int digits = 0;
	while (n != 0) {
		n /= m;
		digits++;
	}
	return digits;
}

//int型を受け取ってその各桁の和を返す
int sum_digits(int n) {
	int sum=0;
	int N = n;
	while (N) {
		sum += N % 10;
		N /= 10;
	}
	return sum;
}


//最大公約数を返す関数
int gcd(int n, int m) {
	while (n != 0) {
		if (n < m) swap(n, m);
		n = n % m;
	}
	return m;
}


//2点間の距離を返す
float dis(int x1, int y1, int x2, int y2) {
	return sqrt(pow(abs(x1 - x2), 2) + pow(abs(y1 - y2), 2));
}

void yes() {
	cout << "Yes" << endl;
}

void no() {
	cout << "No" << endl;
}

int main() {
	int n;
	ll sum = 0;
	cin >> n;
	sum += (n / 500) * 1000;
	n %= 500;
	sum += (n / 5) * 5;
	cout << sum << endl;


	system("pause");
	return 0;
}

Measured memory_bytes: 504
n = input()
taro = 0
hanako = 0

for i in xrange(n):
    t_card, h_card = raw_input().split(" ")

    if t_card < h_card:
        hanako += 3
    elif t_card > h_card:
        taro += 3
    elif t_card == h_card:
        taro += 1
        hanako += 1

print taro, hanako

Measured memory_bytes: 6440
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(a,b)<<" "<<max(a+b-n,0);
}


Measured memory_bytes: 256
N = int(input())
p = list(map(int, input().split()))
ans = 0
i = 0
while i < N:
    if p[i] == i + 1:
        ans += 1
        if i < N - 1 and p[i + 1] == i + 2:
            i += 1
    i += 1
print(ans)

Measured memory_bytes: 53036
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1e9+7
#define LINF (long long)4e18


int main(){
    string S,T;
    cin >> S >> T;
    int N = (int)S.size();
    vector<pair<char,char>> ST(N),TS(N);
    rep(i,N){
        ST[i].first = S[i];
        ST[i].second = T[i];
        TS[i].first = T[i];
        TS[i].second = S[i];
    }
    sort(ST.begin(),ST.end());
    sort(TS.begin(),TS.end());
    bool ok = true;
    rep(i,N-1){
        if(ST[i].first == ST[i+1].first){
            if(ST[i].second != ST[i+1].second)ok = false;
        }
        if(TS[i].first == TS[i+1].first){
            if(TS[i].second != TS[i+1].second)ok = false;
        }
    }
    if(ok) cout << "Yes" <<endl;
    else cout << "No" << endl;
} 

Measured memory_bytes: 1544
#include <stdio.h>

int main(void){

    int a, b;
    int sum;

    scanf("%d %d", &a, &b);
    if(a>b){
        sum = a + (a-1);
    } else if(a<b){
        sum = b + (b-1);
    } else {
        sum = a + b;
    }

    printf("%d", sum);

    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  string s;
  cin>>s;
  int n=s.size();
  if(s[n-1]=='s') cout<<s<<"es"<<endl;
  else cout<<s<<"s"<<endl;
}

Measured memory_bytes: 3604
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import Data.List (sortBy)

main :: IO ()
main = do
  (n : k : _) <- map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  as <- sortBy compare . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  fs <- sortBy (flip compare) . map unsafeSignedDecimal . T.words <$> T.getLine :: IO [Int]
  let
    afs = zip as fs
  print $ search k afs

search :: Int -> [(Int, Int)] -> Int
search k afs = search' (-1, maximum . map (uncurry (*)) $ afs)
  where
    -- search' :: (Int, Int) -> Int
    search' (i, j) | j == succ i = j
                   | check m = search' (i, m)
                   | otherwise = search' (m, j)
      where
        m = (i + j) `div` 2
    -- check :: Int -> [(Int, Int)] -> Bool
    check m = check' k afs
      where
        check' l _ | l < 0 = False
        check' _ [] = True
        check' l ((a, f) : afs') = check' (l - max 0 (a - q)) afs'
          where
            q = m `div` f

unsafeSignedDecimal :: T.Text -> Int
unsafeSignedDecimal s = case T.signed T.decimal s of
  Right (n, _) -> n


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

class Program
{
    static void Main(string[] args)
    {
        decimal n = decimal.Parse(Console.ReadLine());
        decimal a1 = Math.Truncate(Math.Ceiling(n / 1000)) * 1000;
        decimal a2 = a1 - n;
        Console.WriteLine(a2);
    }
}

Measured memory_bytes: 27536
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef pair<int, int> P;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<ll> A(N + 1, 0), B(M + 1, 0);
    rep(i, N) cin >> A[i];
    rep(i, M) cin >> B[i];

    sort(all(A));
    reverse(all(A));
    sort(all(B));
    reverse(all(B));

    ll ans = 1;
    ll a = 0, b = 0;

    for (ll num = N * M; num > 0; num--) {
        ll cal;
        /*
        if ((A[a] > num) || (B[b] > num)) {
            ans = 0;
            break;
        }
        */
        if (A[a] == num && B[b] == num) {
            cal = 1;
            a++;
            b++;
        }
        else if (A[a] == num) {
            cal = b;
            a++;
        }
        else if (B[b] == num) {
            cal = a;
            b++;
        }
        else {
            cal = a * b - (N * M - num);
            /*
            if (cal <= 0) {
                ans = 0;
                break;
            }
            */
        }
        ans *= cal;
        ans %= MOD;
        // cout << num << " " << ans << endl;
    }

    cout << ans << endl;
    return 0;
}

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

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

int main() {
    ios::sync_with_stdio (false), cin.tie (0);
    int n;
    cin >> n;
    for(int i = 1; i < 10; i++){
        int m = n / i;
        if(i * m == n && m < 10 && m > 0){
            cout << "Yes" << '\n';
            return 0;
        }
    }
    cout << "No" << '\n';

    return 0;
}













Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;
 
int main(){
    int N;
    cin >> N;

    long long sum = 0;

    for(int i = 1; i <= N; i++){
        if(i%3 != 0 && i%5 != 0){
            sum += i;
        }
    }

    cout << sum << endl;
    
    return 0;
}

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

vector<int> prime[1000001];

signed main(){
  for(int i=2;i<1000001;i++){
    if(prime[i].size())continue;
    for(int j=i;j<1000001;j+=i)prime[j].push_back(i);
  }

  int n;cin>>n;
  set<int> s;
  int tmp=0,pa=0;
  while(n--){
    int a;cin>>a;tmp=__gcd(tmp,a);
    for(int p:prime[a]){
      if(s.count(p))pa=1;
      s.insert(p);
    }
  }
  if(!pa)cout<<"pairwise coprime"<<endl;
  else if(tmp==1)cout<<"setwise coprime"<<endl;
  else cout<<"not coprime"<<endl;
}


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

using namespace std;

#define REP(var, n)  for (int var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<int>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pii;

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x << " "; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


template<class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

auto solve() {
    int A,B,C;
    cin>>A>>B>>C;

    return min(C, B/A);

}


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

//    cout << (solve() ? "Heisei" : "TBD") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}

Measured memory_bytes: 256