akhauriyash/Code-Regression huggingface dataset:
//love yjl forever
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF=0x3f3f3f3f,N=1e3+5;
int n,m;
int ga[N][N];
int sx,sy,tx,ty;
int vis[N][N];
queue<pii> q;
vector<pii> v;
int b[4][2]={{0,1},{0,-1},{1,0},{-1,0}};
int S;
void kz(int x,int y)
{
	int i,j;
	for(i=max(1,x-2);i<=min(x+2,n);i++)
		for(j=max(1,y-2);j<=min(y+2,m);j++)
		{
			if(ga[i][j]&&!vis[i][j])
			{
				v.pb(mp(i,j));
			}
		}
		
}
void bfs()
{
	S++;
	int i;
	while(!q.empty())
	{
		int x=q.front().fi,y=q.front().se;
		kz(x,y);
		q.pop();
		for(i=0;i<4;i++)
		{
			int nx=x+b[i][0],ny=y+b[i][1];
			if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&ga[nx][ny]&&!vis[nx][ny])
			{
				vis[nx][ny]=S;

				q.push(mp(nx,ny));
			}
		}
	}
}
int main()
{
	//freopen("","r",stdin);
	//freopen("","w",stdout);
	int i,j;
	cin>>n>>m;
	cin>>sx>>sy;
	cin>>tx>>ty;
	for(i=1;i<=n;i++)
	{
		string s;
		cin>>s;
		for(j=1;j<=m;j++)
		{
			if(s[j-1]=='#')
				ga[i][j]=0;
			else 	
				ga[i][j]=1;	
		}
	}
	q.push(mp(sx,sy));
	vis[sx][sy]=1;
	while(1)
	{
		bfs();
		if(vis[tx][ty])
		{
			cout<<vis[tx][ty]-1<<endl;
			return 0;
		}
		if(v.empty())
		{
			cout<<-1<<endl;
			return 0;
		}
		for(i=0;i<v.size();i++)
		{
			if(!vis[v[i].fi][v[i].se])
			{
				vis[v[i].fi][v[i].se]=S+1;
				q.push(mp(v[i].fi,v[i].se));
			}
		}
		v.clear();
	}
//	for(i=1;i<=n;i++)
//	{
//		for(j=1;j<=m;j++)
//		{
//			cout<<ga[i][j];	
//		}
//		cout<<endl;
//	}	
}


Measured memory_bytes: 11528
#include "bits/stdc++.h"

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

//#define int long long
#define ll long long

ll INF = (1LL << 60);
int mod = 1000000007;

using P = pair<int, int>;

signed main() {
	int N; cin >> N;
	vector<int>A(N), B(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];
	map<int, int>cnt;
	for (int i = 0; i < N; i++) {
		cnt[A[i]]++;
		cnt[B[i]]++;
	}
	for (int i = 1; i <= 200000; i++) {
		if (cnt[i] > N) {
			cout << "No" << endl; return 0;
		}
	}
	cout << "Yes" << endl;
	reverse(B.begin(), B.end());
	for (int i = 0; i < N; i++) {
		if (A[i] == B[i]) {
			for (int j = 0; j < N; j++) {
				if (i == j)continue;
				if (A[i] != B[j] && A[j] != B[i]) {
					swap(B[i], B[j]);
					break;
				}
			}
		}
	}
	for (int i = 0; i < N; i++) {
		cout << B[i];
		if (i == N - 1)cout << endl;
		else cout << " ";
	}
	return 0;
}


Measured memory_bytes: 14340
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;


int main(){
  int N, M;
  cin >> N >> M;
  int K[40], A[40][40];
  for(int i = 0; i < N; ++i)
  {
    cin >> K[i];
    for(int j = 0; j < K[i]; ++j)
    {
      cin >> A[i][j];
    }
  }
  int cnt = 0;
  bool like = false;
  for (int i = 1; i <= M; i++)
  {
    for(int j = 0; j < N; ++j)
    {
      like = false;
      for(int k = 0; k < K[j]; ++k)
      {
        if(A[j][k] == i)
        {
          like = true;
          break;
        }
      }
      if(like == false) break;
    }
    if (like == true) cnt++;
  }
  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <queue>

using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

void J(string& str){
  if(SZ(str)==1) return;
  rotate(str.begin(), str.end()-1, str.end());
}
void C(string& str){
  if(SZ(str)==1) return;
  rotate(str.begin(), str.begin()+1, str.end());
}
void E(string& str){
  if(SZ(str)%2 == 1){
	string s1 = str.substr(0, SZ(str)/2);
	string s2 = str.substr(SZ(str)/2+1);
	str = s2 + str[SZ(str)/2] + s1;	
  }
  else{
	string s1 = str.substr(0, SZ(str)/2);
	string s2 = str.substr(SZ(str)/2);
	str = s2 + s1;
  }
}
void A(string& str){
  reverse(ALL(str));
}
void P(string& str){
  int org = SZ(str);
  REP(i,SZ(str))
	if(isdigit(str[i]))
	  if(str[i] == '0')
		str[i] = '9';
	  else
		--str[i];
}
void M(string& str){
  REP(i,SZ(str))
	if(isdigit(str[i]))
	  if(str[i] == '9')
		str[i] = '0';
	  else
		++str[i];
}
  

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

  int N; cin >> N;
  REP(n,N){
	string p, msg; cin >> p >> msg;
	for(int i=SZ(p)-1;i>=0;--i)
	  switch(p[i]){
	  case 'J':
		J(msg); break;
	  case 'C':
		C(msg); break;
	  case 'E':
		E(msg); break;
	  case 'A':
		A(msg); break;
	  case 'P':
		P(msg); break;
	  case 'M':
		M(msg); break;
	  }
	cout << msg << endl;
  }
  
  return 0;
}

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


#define f(i,a,b) for(int i=(int)(a);i<=(int)(b);i++)
#define char_f(i,a) for(int i=(int)(a);(char)s[i]!='\0';i++)
#define rf(i,a,b) for(int i=(int)(a);i>=(int)(b);i--)
#define llf(i,a,b) for(long long int i=(long long int)(a);i<=(long long int)(b);i++)
#define llrf(i,a,b) for(long long int i=(long long int)(a);i>=(long long int)(b);i--)



#define ll long long
#define fi first
#define se second
#define pb push_back
#define pop pop_back
#define mem(ara) memset((ara),0,sizeof(ara))
#define memn(ara) memset((ara),-1,sizeof(ara))
#define b begin()
#define e end()
#define em emplace
#define eb emplace_back





#define si set<int>
#define sd set<double>
#define sll set<long long int>
#define ss set<string>
#define sc set<char>

#define pii pair<int,int>
#define pli pair<long long int,int>
#define pil pair<int,long long int>
#define pll pair<long long int,long long int>
#define pci pair<char,int>
#define pic pair<int,char>
#define pcl pair<char,long long int>
#define plc pair<long long int,char>

#define pss pair<string,string>
#define pcc pair<char,char>

#define pis pair<int,string>
#define psi pair<string,int>
#define pls pair<long long int,string>
#define psl pair<string,long long int>
#define pdd pair<double,double>
#define pcs pair<char,string>
#define psc pair<string,char>



#define vi  vector<int>
#define vll vector<long long int>
#define vd vector<double>
#define vs vector<string>
#define vc vector<char>
#define vii vector<pii>



#define mod 1000000007
#define mx (1<<30)-1
#define llmx (1ll<<62)
#define n_size 100005
#define g_size 10000005
double PI=acos(-1);



///unsigned int uMAX=4294967295;
///unsigned ll int ullMAX=18446744073709551615;





int arr[g_size];



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

	ll int n,m,T,res;

	ll int maxi=-mx,mini=mx,count=0;

	int i,j,k;

	bool flag;

	string s1,s2;

	char s[100000];

	int ara[n_size],ara2[n_size];

	cin>>n>>m;

	pll p1[n],p2[m];

	f(i,0,n-1) cin>>p1[i].fi>>p1[i].se;
	f(i,0,m-1) cin>>p2[i].fi>>p2[i].se;

	f(i,0,n-1)
	{
	    mini=mx;
	    f(j,0,m-1)
	    {
	        res=abs(p1[i].fi-p2[j].fi)+abs(p1[i].se-p2[j].se);
	        if(res<mini){
                k=j+1;
                mini=min(mini,res);
	        }
	    }
	    cout<<k<<endl;
	}



}


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

/*vector<int> p(n);
cin >> p[i]*/

int main(){

    string s;
    int count=0;
    cin >> s;

    for(int i=0; i<s.length(); i+=2){
        if(s[i] == 'h' && s[i+1] == 'i'){
            count++;
        }
    }

    if(s.length()%2 == 1) {
        cout << "No" << endl;
        return 0;
    }

    if(count >= s.length()/2 ) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String s = sc.next();
		int a[][] = new int[n][7];
		int answer = 0;
		if (s.charAt(0) == 'J') {
			a[0][0] = 0;
			a[0][1] = 0;
			a[0][2] = 0;
			a[0][3] = 1;
			a[0][4] = 1;
			a[0][5] = 1;
			a[0][6] = 1;
		} else if (s.charAt(0) == 'O') {
			a[0][0] = 0;
			a[0][1] = 0;
			a[0][2] = 0;
			a[0][3] = 0;
			a[0][4] = 0;
			a[0][5] = 1;
			a[0][6] = 1;

		} else if (s.charAt(0) == 'I') {
			a[0][0] = 0;
			a[0][1] = 0;
			a[0][2] = 0;
			a[0][3] = 0;
			a[0][4] = 1;
			a[0][5] = 0;
			a[0][6] = 1;
		}
		for (int i = 1; i < n; i++) {
			if (s.charAt(i) == 'J') {
				a[i][3] += a[i - 1][3] + a[i - 1][4] + a[i - 1][5]
						+ a[i - 1][6];
				a[i][4] += a[i - 1][0] + a[i - 1][2] + a[i - 1][3]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][5] += a[i - 1][1] + a[i - 1][2] + a[i - 1][3]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][6] += a[i - 1][0] + a[i - 1][1] + a[i - 1][2]
						+ a[i - 1][3] + a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
			} else if (s.charAt(i) == 'I') {
				a[i][0] += a[i - 1][0] + a[i - 1][2] + a[i - 1][4]
						+ a[i - 1][6];
				a[i][2] += a[i - 1][0] + a[i - 1][1] + a[i - 1][2]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][4] += a[i - 1][0] + a[i - 1][2] + a[i - 1][3]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][6] += a[i - 1][0] + a[i - 1][1] + a[i - 1][2]
						+ a[i - 1][3] + a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
			} else if (s.charAt(i) == 'O') {
				a[i][1] += a[i - 1][1] + a[i - 1][2] + a[i - 1][5]
						+ a[i - 1][6];
				a[i][2] += a[i - 1][0] + a[i - 1][1] + a[i - 1][2]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][5] += a[i - 1][1] + a[i - 1][2] + a[i - 1][3]
						+ a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
				a[i][6] += a[i - 1][0] + a[i - 1][1] + a[i - 1][2]
						+ a[i - 1][3] + a[i - 1][4] + a[i - 1][5] + a[i - 1][6];
			}
			for (int j = 0; j < 7; j++) {
				a[i][j] = a[i][j] % 10007;
			}
		}
		for (int i = 0; i < 7; i++) {
			answer += a[n - 1][i];
		} answer = answer%10007;

		System.out.println(answer);
	}
}

Measured memory_bytes: 26248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var AB = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var A = AB[0];
            var B = AB[1];

            if (A > 2* B)
            {
                Console.WriteLine(A-2*B);
            }
            else
            {
                Console.WriteLine(0);
            }

        }

    }
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod2 = 1000000007;
constexpr ll mod = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,-1};
const int dy[6] = {0, 1, 0, -1,1,-1};
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 main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> d(3);
    rep(i,3) cin >> d[i];
    vector<P> q;
    rep(i,N){
        string S;
        cin >> S;
        q.emplace_back(S[0]-'A',S[1]-'A');
    }
    q.emplace_back(0,1);
    string ans = "";
    auto add = [&](int a,int b){
        d[a]++;
        d[b]--;
        ans += a + 'A';
    };
    rep(i,N){
        int a = q[i].first;
        int b = q[i].second;
        if(!d[a] and !d[b]){
            cout << "No" << enld;
            return 0;
        }else if(!d[a]){
            add(a,b);
        }else if(!d[b]){
            add(b,a);
        }else{
            int na = q[i+1].first;
            int nb = q[i+1].second;
            if(na == a or nb == a){
                add(a,b);
            }else{
                add(b,a);
            }
        }
    }    
    cout << "Yes" << enld;
    rep(i,N){
        cout << ans[i] << enld;
    }
    return 0;
}

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

#define f(i,a,b) for( ll  i = a; i < b ; i++ ) 
#define af(i,a,b) for( ll i = a; i >= b ; i--)
#define rep(i,a,b,k) for(ll i = a; i < b ; i+= k )
#define arep(i,a,b,k) for( ll i = a; i >= b ; i-= k)
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(a) (ll) a.size()
#define all(a) a.begin(), a.end()
#define sor(a) sort( a.begin(), a.end() )
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define inter ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)

// policy-based



using namespace std;


typedef long long ll; // int or long long
typedef long double ld;
typedef pair<ll,ll> ii ;
typedef vector<ll>  vi ;
typedef vector<ii> vii ;



 
const ll MAX = 2e6+10;
const ll inf = 1e15;
const ll mod = 1e9+7;

//ll a[MAX];
int main(){
	fastio;
	ll n;
	string s;
	cin >> s;
	if(s == "RRR") cout << "3\n";
	else if( s == "SSS") cout << "0\n";
	else if(s == "RSR") cout << "1\n";
	else{
		ll x = 0;
		f(i,0,3) if(s[i] == 'R') x++;
		cout << x << endl;
	}
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 10, inf = 0x3f3f3f3f;
struct e{
    int pos, num;
    bool operator < (const e &b) const {return pos < b.pos;}
}a[maxn];
ll acc[maxn];
int main()
{
    int n, d, A;
    cin >> n >> d >> A;
    for (int i = 0; i < n; ++i) cin >> a[i].pos >> a[i].num;
    sort(a, a + n);
    int l = -1, r = 1;
    ll cur = 0, ans = 0;
    //two point
    while (++l < n){
        cur += acc[l];//更新对当前位置的影响
        if (cur * A >= a[l].num) continue;//直接走
        while (r < n && a[r].pos - a[l].pos <= 2 * d) ++r;//r走
        int ci = (a[l].num - cur * A + A - 1) / A;//当前需要用多少
        acc[r] += -ci;//差分
        cur += ci;//更新和
        ans += ci;//更新答案
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
// Problem : A - Number of Multiples
// Contest : AtCoder - AIsing Programming Contest 2020
// URL : https://atcoder.jp/contests/aising2020/tasks/aising2020_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

//Macros

#define ll long long
#define db long double
#define pb push_back
#define eb emplace_back
#define pii pair<int,int>
#define vi vector<int>
#define vii vector<pii>
#define mi map<int,int>
#define mii map<pii,int>
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define sz(x) (int)x.size()
#define mod 1000000007
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define inf 1e10
#define PI acos(-1.0)
#define int long long
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
#define N 100005

//Solution

void solve(){
    int l,r,d;
    cin>>l>>r>>d;
    int ans = 0;
    for(int i=0;i<=100;i+=d){
        if(i >= l && i <= r) ans++;
    }
    cout<<ans;
}

signed main(){
    io;
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
    int tests;
    //cin>>tests;
    tests = 1;
    while(tests--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3608
#include <stdio.h>


int main()
{
	int n, x, i, j, k, count;
	scanf("%d%d", &n, &x);
	while (1) {
		if (n == 0 && x == 0) break;
		count = 0;
		for (i = 1; i <= n; i++) {
			for (j = 1; j <= n; j++) {
				if (j <= i) continue;
				for (k = 1; k <= n; k++) {
					if (k <= j) continue;
					if (i + j + k == x) count++;
				}
			}
		}
		printf("%d\n", count);
		scanf("%d%d", &n, &x);
	}

    return 0;
}

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

int main()
{
	double a,b,C,d;
	double S,L,h;
	
	scanf("%lf%lf%lf",&a,&b,&C);
	
	h = b*sin(C*M_PI/180);
	S = a*h/2;
	d = (a*a+b*b) - 2*a*b*cos(C*M_PI/180);
	d = sqrt(d);
	L = a+b+d;
	
	printf("%f\n%f\n%f\n",S,L,h);
	
	return 0;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pd;
typedef complex<ld> cd;
typedef vector<int> vi;
typedef vector<ll> vll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n;
	cin >> n;
	vi arr(n);
	M00(i, n) cin >> arr[i];
	int sum = 0;
	M00(i, n) sum ^= arr[i];
	M00(i, n) {
		cout << (arr[i] ^ sum) << " ";
	}
	cout << endl;
}


Measured memory_bytes: 3956
N = int(input())
x_list = []
u_list = []
ans = 0

for _ in range(N):
    x, u = input().split()
    x_list.append(float(x))
    u_list.append((u))

for i in range(N):
    if u_list[i] == "JPY":
        ans += x_list[i]
    else:
        ans += x_list[i]*380000

print(ans)

Measured memory_bytes: 3060
#include <iostream> // cout, endl, cin
#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
#include <iomanip> // setprecision
#include <complex> // complex
#include <math.h> 
#include <climits> 
#include <assert.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[8] = {1, 0, -1, 0,1,1,-1,-1};
const int dy[8] = {0, 1, 0, -1,1,-1,1,-1};
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 main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    ll sum = 0;
    int now = 2;
    sum += A[0]-1;
    for(int i=1; i<N; i++){
        if(A[i] == now){
            now++;
            continue;
        }
        if(A[i]%now == 0){
            sum += A[i]/now - 1;
        }else{
            sum += A[i]/now;
        }
    }
    cout << sum << "\n";
    return 0;
}

Measured memory_bytes: 640
/***************************************************************************
                                AUTHOR: SPARSH SINHA
            **************************************************************************/


#include <bits/stdc++.h>
using namespace std;
#define si(N) scanf("%d",&N);
#define sll(N) scanf("%lld",&N);
#define ss(s) scanf("%s",s);
#define ll long long
#define pi pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(int i = a; i<=b;i++)
#define fori(i,n) for(int i = 0 ; i < n; i++)
#define umapii unordered_map<int,int>
#define umapll unordered_map<ll,ll>
#define mapll map<ll,ll>
#define mapii map<int,int>
#define debug(x)       cerr<< #x <<" : "<<x<<endl;
#define debuga(A,N)    cerr<< #A <<" : [";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
#define debuga2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}
#define debugp(p)      cerr<< #p <<" : "<<"("<<(p).first<<","<<(p).second<<")\n";
#define debugv(v)      cerr<< #v <<" : "<<"[";for(int i = 0; i< (v).size(); i++) cerr<<v[i]<<" "; cerr<<"]\n";
#define debugv2(v)     cerr<< #v << " : \n"; for(int i=0;i<v.size();i++){cerr<<"[";for(int j=0;j<(v[0].size());++j) cerr<<v[i][j]<<" ";cerr<<"]\n";}
#define debugs(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin(); itr!=m.end();itr++) cerr<<*itr<<" "; cerr<<"]\n";
#define debugm(m)      cerr<< #m <<" : [ "; for(auto itr = m.begin();itr!=m.end(); itr++) cerr<<"("<<itr->first<<","<<itr->second<<") ";cerr<<"]\n";
const int INF = 1e9 + 7;

int main()
{
                  int A , B;
                  cin >> A >> B;
                  int ans = max({A + B , A - B , A*B});
                  cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define endl "\n"
#define all(v) v.begin(),v.end()
#define mp make_pair
#define mm(a) memset(a,0,sizeof(a))
#define rep(i,a,b) for(ll i = a; i < b; i++)
#define repn(i,a,b) for(ll i = a; i >= b; i--)
#define pb push_back
#define ff first
#define ss second
#define fto(k,m) for(auto k:m)
#define in_edges(m) repp(i, 1, m){ ll a, b; cin >> a >> b; adj[a].pb(b), adj[b].pb(a);}
#define debug(this) cerr<<"> "<<#this<<" : "<<this<<"\n"
#define MOD 1000000007
#define sz(a) ll((a).size())
#define pii 3.1415926535897
#define quick ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
// stoll(s);
int main()
{
    quick
	ll t;t=1;
    // cin >> t;
	while(t--){
        char a; cin >>a;
        if(isupper(a))cout<<"A";
        else if(islower(a))cout<<"a";
    }
}

Measured memory_bytes: 3580
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder07
{
    class Program
    {
        static void Main(string[] args)
        {
            int a = int.Parse(Console.ReadLine());
            if (a == 25)
            {
                Console.WriteLine("Christmas");
            }
            else if (a == 24)
            {
                Console.WriteLine("Christmas Eve");
            }
            else if (a == 23)
            {
                Console.WriteLine("Christmas Eve Eve");
            }
            else if (a == 22)
            {
                Console.WriteLine("Christmas Eve Eve Eve");
            }
        }
    }
}


Measured memory_bytes: 11092
#include <iostream>
using namespace std;
 
int main(void){
    int n;
    while(cin>>n,n){
        int a = 0;
        int b = 0;    
        for(int i=0; i<n; i++){
            int ta,tb;
            cin >> ta >> tb;
            int sum = ta + tb;
            if(ta > tb) a += sum;
            if(ta < tb) b += sum;
            if(ta == tb){
                a += ta; b += tb;
            }
        }
        cout << a << " " << b << endl;
    }
} 

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s[1000], x;
  int t[1000];
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
    if (i > 0) {
      t[i] += t[i - 1];
    }
  }
  cin >> x;
  for (int i = 0; i < n; i++) {
    if (s[i] == x) {
      cout << t[n - 1] - t[i];
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<string>
#include<queue>
#include<vector>
#include<algorithm>
#include<tuple>
#include<numeric>
#include<map>
#include<cmath>
#define ll long long
#define rep(i,n) for(int i=0;i<(int) (n);i++)
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
using namespace std;
int main(){
  int s,w;
  cin>>s>>w;
  if(s>w)cout<<"safe";
  else cout<<"unsafe";

  return 0;
}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main
{

	public static void main(String[] args)
	{
		Scanner in=new Scanner(System.in);
		int a,b,c,count=0;
		a=in.nextInt();
		b=in.nextInt();
		c=in.nextInt();
		for (int i = a; i <= b; i++)
		{
			if((c%i)==0)
			{
				count++;
			}			
		}
		System.out.println(count);
		

	}

}

Measured memory_bytes: 26392
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    S = [list(input().strip("\n")) for _ in range(N)]
    for i in range(N): S[i].sort()
    S.sort()
    S.append(["E", "N", "D"])

    ans = 0
    current = "".join(S[0])
    same = 0
    for i in range(1, N+1):
        tempS = "".join(S[i])
        if tempS == current:
            same += 1
        else:
            ans += (1 + same) * same // 2
            same = 0
            current = tempS
    print(ans)

    return  0

if __name__ == "__main__":
    solve()

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

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

    int r, s, p;
    cin >> r >> s >> p;

    string t;
    cin >> t;

    int flag[n];
    for(int i = 0; i < n; i++){
        flag[i] = 0;
    }

    ll ans = 0;

    for(int i = 0; i < n; i++){
        if(i < k){
            if(t[i] == 'r'){
                ans += p;
            }else if(t[i] == 's'){
                ans += r;
            }else{
                ans += s;
            }
            flag[i] = 1;
        }else{
            if(t[i] == 'r'){
                if(t[i - k] != 'r'){
                    ans += p;
                    flag[i] = 1;
                }else{
                    if(flag[i - k] == 0){
                        ans += p;
                        flag[i] = 1;
                    }
                }
            }else if(t[i] == 's'){
                if(t[i - k] != 's'){
                    ans += r;
                    flag[i] = 1;
                }else{
                    if(flag[i - k] == 0){
                        ans += r;
                        flag[i] = 1;
                    }
                }
            }else{
                if(t[i - k] != 'p'){
                    ans += s;
                    flag[i] = 1;
                }else{
                    if(flag[i - k] == 0){
                        ans += s;
                        flag[i] = 1;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long int ll;
#define fi first
#define se second
ll p=pow(10,9)+7;
ll phi(ll n) {
    ll result = n;
    for (ll i = 2; i * i <= n; i++) {
        if(n % i == 0) {
            while(n % i == 0)
                n /= i;
            result -= result / i;
        }
    }
    if(n > 1)
        result -= result / n;
    return result;
}
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      
    x = x % p;  
   while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p; 
    } 
    return res; 
} 

ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,j,i,k,x,y,z,m;
    string s;
    
    cin>>n>>k;
    ll temp=n%k;
    cout<<std::min(temp,k-temp);
    return 0;
    
}
    


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

const int N = 100000;
const int Q = 50000;

int main() {
  std::ios_base::sync_with_stdio(false);
  
  int n = 0;
  std::vector<int> S;

  S.reserve(N);

  std::cin >> n;

  for (int i = 0; i < n; i++) {
    int x = 0;

    std::cin >> x;

    if (i == 0) {
      S.push_back(x);

      continue;
    }

    if ((i > 0) && (x != S[S.size() - 1])) {
      S.push_back(x);
    }
  }

  int q = 0;
  std::vector<int> T;

  T.reserve(Q);

  std::cin >> q;

  for (int i = 0; i < q; i++) {
    int x = 0;

    std::cin >> x;

    T.push_back(x);
  }

  int count = 0;
  
  std::vector<int>::iterator j = T.begin();
    
  while (j != T.end()) {
    int left = 0;
    int right = S.size() - 1;

    bool found = false;
    
    while (left <= right) {
      int middle = (left + right) / 2;
	
      if (S[middle] == *j) {
	count++;

	found = true;

	break;
      } else if (S[middle] < *j) {
	left = middle + 1;
      } else {
	right = middle - 1;
      }
    }

    if (found) {
      j = T.erase(j);
    } else {
      ++j;
    }
  }
    
  std::cout << count << std::endl;
  
  return 0;
}

Measured memory_bytes: 1532
#include <iostream>
#include <string>
#include <math.h>
using namespace std;

int main(){
	string kaibun;
	cin >> kaibun;
	int n = kaibun.length();
	int k = (n+1)/2;
	int t;
	int judge=1;
	//first check
	for( int i=0; i<k-1; i++ ){
		if( kaibun[i]!=kaibun[n-i-1]){
			judge *= 0;
		}
	}
	if( fmod( (n-1)/2 , 2 )==1 ) t=((n-1)/2-1)/2;
	else t=(n-1)/4;
	for( int i=0; i<t; i++ ){	
		if( kaibun[i]!=kaibun[(n-3)/2-i]){
			judge*=0;
		}
	}
	if( fmod( (n-3)/2, 2 )==1 ) t=((n-3)/2-1)/2;
	else t=(n-3)/4;
	for( int i=0; i<t; i++ ){
		if( kaibun[(n+3)/2+i-1]!=kaibun[n-i-1] ){
			judge*=0;
		}
	}
	if( judge == 1 ) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e2 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	auto check = [=](int x) -> bool
	{
		return m % x == 0 && m / x >= n;
	};
	int ans = 0;
	for (int i = 1; i * i <= m; i++)
	{
		if (m % i) continue;
		if (check(i)) ans = max(ans, i);
		if (check(m / i)) ans = max(ans, m / i);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
#include <random>
#include <climits>  // A/Bを計算するときA==LLONG_MIN && B==-1のみ(1ull<<63)で代用
using namespace std;

typedef long long LL;
typedef pair<LL, LL> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<VL> VVL;				// VVL v(100,VL(100,0));
typedef vector<pair<LL, LL> > VP;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<LL, pair<P, P> > PP;

#define INF 999999999999999997		// 少し加算したらオーバーフローする
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) if(dbgF){FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a % b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定
string Replace(string S, string from, string to) { auto p = S.find(from); while (p != string::npos) { S.replace(p, from.size(), to); p = S.find(from, p + to.size()); }return S; }
// 桁和
LL Ketawa_s(string s) { LL a = 0; FOR(i, 0, s.length())a += s[i] - '0'; return a; }

//二項係数 nCk mod pを求める
const LL MAX = 510000, p = 998244353; LL fac[MAX], finv[MAX], inv[MAX];
/* 前処理 */void COM_init() { fac[0] = fac[1] = 1; finv[0] = finv[1] = 1; inv[1] = 1; FOR(i, 2, MAX) { fac[i] = fac[i - 1] * i % p; inv[i] = p - inv[p % i] * (p / i) % p; finv[i] = finv[i - 1] * inv[i] % p; } }
/* 主処理 */LL COM(int n, int k) { if (n < k) return 0; if (n < 0 || k < 0) return 0; return fac[n] * (finv[k] * finv[n - k] % p) % p; }

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

// -------------------------------------------------------------------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	LL AB, BC, CA;
	cin >> AB >> BC >> CA;

	O((AB * BC) / 2);

	return 0;
}

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

int main(){
  int h,a,num=0;
  cin>>h>>a;
  while(0<h){
    h-=a;
    num++;
  }
    cout<<num<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
       Scanner scanner = new Scanner(System.in);
       String input = scanner.next();
       if (input.length()==12){
        String output = input.substring(0, 4) + " " + input.substring(4);       
        System.out.println(output.toUpperCase());
       }
       else{
        System.out.println("");
       }
    }
}

Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll mod = 998244353;
double pi = 3.14159265358979;

ll r(ll x, ll y) {
  if (y == 0) return 1;
  else if (y % 2 == 0) return r(x, y/2) * r(x, y/2) % mod;
  else return x * r(x, (y-1)/2) % mod * r(x, (y-1)/2) % mod;
}

int main() {
  double a, b, h, m;
  cin >> a >> b >> h >> m;
  double ty = pi * m / 30.0;
  double ta = 2 * pi * h / 12 + pi * m / 360.0;
  double sa = max(ty-ta, ta-ty);
  double c2 = a* a + b * b - 2*a*b*cos(sa);
  double c = sqrt(c2);
  printf("%.12lf\n", c);
}

Measured memory_bytes: 4228
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, A);
    IN(ll, B);
    IN(ll, M);
    AIN(ll, a, A);
    AIN(ll, b, B);
    vi x(M), y(M), c(M);
    REP(i, M)
    {
        cin >> x[i] >> y[i] >> c[i];
    }
    ll ans = *min_element(ALL(a)) + *min_element(ALL(b));
    REP(i, M)
    {
        CH(min, ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    OUT(ans);
}

Measured memory_bytes: 4224
/**
 *    author:  Mohamad Milhem
 *    created: 2020-02-19-12.06.24
**/

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define MOD ll(1000000007)
#define debug(x) cout << '[' << #x << " is: " << x << "] " <<endl;
#define decimalpoint cout << std::fixed << setprecision(5)


int main(){

    FAST;

    int n;
    cin >> n;

    int arr[n];

    for (int i = 0 ; i < n ; i++)cin >> arr[i];

    for (int i = 0 ; i < n ; i++){
        if (arr[i] % 2 == 0){
            if ((arr[i] % 3 == 0 )||(arr[i] % 5 == 0))continue;
            else {cout << "DENIED" << endl; return 0;}
        }
    }

    cout << "APPROVED" << endl;



    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int[] hills = new int[n];
        for(int i = 0;i<n;i++) {
            hills[i] = in.nextInt();
        }
        int counter = 1;
        int cur = hills[0];
        for(int i = 1;i<n;i++) {
            if(hills[i]>=cur) {
                counter++;
                cur = hills[i];
            }
        }
        System.out.println(counter);
    }
}


Measured memory_bytes: 21844
N  = int(input())
a = []
l = 0
for i in range(N):
    x,y,H = map(int,input().split())
    a.append([x,y,H])
for t in range(N):
    if a[t][2] != 0:
        break
for i in range(101):
    for j in range(101):
        l = a[t][2] + abs(a[t][0]-i)+abs(a[t][1]-j)
        for k in range(N):
            if a[k][2]!=max(0,l-abs(i-a[k][0])-abs(j-a[k][1])):
                break
            elif k == N-1:
                print(str(i)+' '+str(j)+ ' '+str(l))
                exit()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
vector<int> likes(10, 1);
bool isok(int i, vector<int> &likes) {
  while (i) {
    int a = i % 10;
    if (!likes[a]) return false;
    i /= 10;
  }
  return true;
}

int main() {
  int k;
  int n;
  cin >> n >> k;
  vector<int> likes(10, 1);
  for (int i = 0; i < k; i++) {
    int t;
    cin >> t;

    likes[t] = 0;
  }
  // cout << likes[9] << endl;
  // sort(likes.begin(), likes.end());
  int answer = n;
  while (true) {
    if (isok(answer, likes)) {
      cout << answer << endl;
      break;
    }

    else
      answer++;
  }
}


Measured memory_bytes: 3564
H, W = map(int, input().split())

ans = 10 ** 18

# 平行に三分割出来れば答えは0
Hsplit = W * ((H + 2) // 3 - H // 3)
Wsplit = H * ((W + 2) // 3 - W // 3)
ans = min(ans, Hsplit, Wsplit)

# 縦横に分割


def calc(X, Y):
    res = 10 ** 18

    Ymax = (Y + 1) // 2
    Ymin = Y // 2
    for i in range(1, X):
        s1 = Ymax * i
        s2 = Ymin * i
        s3 = Y * (X - i)
        res = min(res, max(s1, s2, s3) - min(s1, s2, s3))
    return res


ans = min(ans, calc(H, W))
ans = min(ans, calc(W, H))

print(ans)


Measured memory_bytes: 3064
require 'mathn'

n, k, t, u, v, l = gets.split.map &:to_i
carrots = (1..n.to_i).map{gets.to_i}
carrots << l

x = 0
c = 0
accel = 0
time = 0

carrots.each{|d|
	if x + accel * v >= d
		dt = (d - x) / v
		time += dt
		accel -= dt
		x = d
		if c == k
			accel = t
		else
			c += 1
		end
	else
		x += accel * v
		time += accel 
		accel = 0

		if c == 0
			time += (d - x) / u
			x = d
			c = 1
		else
			if x + c * t * v >= d
				used = ((d - x) / (t * v)).ceil
				c -= used - 1
				dt = (d - x) / v
				time += dt
				x = d
				accel = used * t - dt
			else
				x += c * t * v
				time += c * t
				time += (d - x) / u
				x = d
				c = 1
			end
		end
	end
}

p time.to_f

Measured memory_bytes: 7256
#include<iostream>
#include<vector>
int main(){
    int vec[4];
    int result = 0;
    for(int i=0; i<4; i++){
        std::cin >> vec[i];
    }
    for(int i=0; i<3; i++){
            if(i==0){
                result += std::min(vec[i], vec[3]);
            }
            else if(i==2){
                result -= std::min(vec[i], vec[3]);
            }
            vec[3]-=std::min(vec[i], vec[3]);
            if(vec[3] <= 0) break;
    }
    std::cout << result << "\n";
    return 0;
}

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

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// chmax, chmin
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 log2ceil(int n) {
  --n;
  n |= n >> 16;
  n |= n >> 8;
  n |= n >> 4;
  n |= n >> 2;
  n |= n >> 1;
  return n + 1;
}

template <class Monoid> class SegmentTree {
public:
    using value_type = typename Monoid::value_type;
    using update_type = typename Monoid::value_type;

private:
    const int size_, n;
    std::vector<value_type> data;

public:
    SegmentTree(const std::vector<value_type> &vec) :
            size_(vec.size()), n(log2ceil(size_)), data(n * 2, Monoid::id()) {
        std::copy(begin(vec), end(vec), begin(data) + n);
        for (int i = n - 1; i >= 0; --i) {
            data[i] = Monoid::op(data[i * 2 + 0], data[i * 2 + 1]);
        }
    }

    SegmentTree(const int count, const value_type &value = Monoid::id()) :
            SegmentTree(std::vector<value_type>(count, value)) {}

    int size() const { return size_; }

    void update(int pos, const value_type &value) {
        assert(0 <= pos && pos < size_);  // assertion
        data[pos += n] = value;
        while (pos /= 2) {
            data[pos] = Monoid::op(data[pos * 2], data[pos * 2 + 1]);
        }
    }

    // セグメント木の区間 [l, r) を演算 Monoid::op (⋅⋅) で畳み込んだ値を返す． すなわち，al⋅al+1⋅…⋅ar−1al⋅al+1⋅…⋅ar−1 を返す． l=rl=r の場合は Monoid::id() を返す．
    value_type query(int l, int r) const {
        assert(0 <= l && l <= r && r <= size_);  // assertion
        l += n;
        r += n;
        value_type res1 = Monoid::id(), res2 = Monoid::id();
        while (l < r) {
            if (l & 1) res1 = Monoid::op(res1, data[l++]);
            if (r & 1) res2 = Monoid::op(data[--r], res2);
            l >>= 1;
            r >>= 1;
        }
        return Monoid::op(res1, res2);
    }
};

// GCD
struct GCD {
    using value_type = int;

    static value_type id() { return -1; }

    static value_type op(const value_type &l, const value_type &r) {
        if (l == -1) return r;
        if (r == -1) return l;
        return __gcd(l, r);
    }
};

void solve(long long N, std::vector<long long> A) {
    SegmentTree<GCD> rmq(N);
    for(int i = 0 ; i < N ; i++){
        rmq.update(i, A[i]);
    }
    long long ans = 0;
    for(int i = 0 ; i < N ; i++){
        long long sub;
        if( i == 0 ){
            sub = rmq.query(1, N);
        }else if( i == N - 1 ){
            sub = rmq.query(0, N-1);
        }else{
            sub = __gcd(rmq.query(0, i), rmq.query(i+1, N));
        }
        ans = max(sub, ans);
    }
    cout << ans << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	Scanner sc = new Scanner(System.in);
	int INF = Integer.MAX_VALUE / 2;

	void run() {
		int n = sc.nextInt();
		int[][] f = new int[n][n];
		for (int i = 0; i < n; i++) for (int j = 0; j < n; j++) f[i][j] = sc.nextInt();
		int[][] sum = new int[n][n];
		for (int i = 0; i < n; i++) sum[0][i] = f[0][i];
		for (int i = 0; i < n; i++) for (int j = 1; j < n; j++) sum[j][i] = sum[j - 1][i] + f[j][i];
		int ans = -INF;
		for (int i = 0; i < n; i++) {
			for (int j = i; j < n; j++) {
				int first = (i == 0) ? sum[j][0] : sum[j][0] - sum[i - 1][0];
				int[] dp = new int[n];
				Arrays.fill(dp, -INF);
				dp[0] = first;
				ans = Math.max(ans, dp[0]);
				for (int k = 1; k < n; k++) {
					int s = (i == 0) ? sum[j][k] : sum[j][k] - sum[i - 1][k];
					dp[k] = Math.max(dp[k - 1] + s, s);
					ans = Math.max(ans, dp[k]);
				}
			}
		}
		System.out.println(ans);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 39388
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,T,H,L;
int t[101],h[101];

int solve(){

  int money = 0;
  while(1){
    for(int i=0;i<n;i++){
      if(t[i]) money += 10,t[i]--,T++;
      else if(h[i]) money +=100,h[i]--,H++;
      else return i;
      if(T>L) return i;
      if(money >=90) {
	money -= 90;
	if(money/10 > T)return i;
	t[i] += money / 10;
	T-=money/10;
	money = 0;
      }
    }
  }
}

signed main(){
  
  cin>>n>>T>>H>>L;
  
  for(int i=0;i<n;i++)cin>>t[i]>>h[i];

  cout<<solve()+1<<endl;  

   
  
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n;
    cin>>n;
    set<string> st;
    rep(i,n){
        string s;
        cin>>s;
        st.insert(s);
    }
    cout<<st.size()<<endl;
}

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

int a, b, c, prevA, prevB, prevC, ans=0;

int main(){
    cin >> a >> b >> c;
    prevA = a;
    prevB = b;
    prevC = c;
    while(a%2==0 && b%2==0 && c%2==0){
        ans++;
        a = (prevB+prevC)/2;
        b = (prevC+prevA)/2;
        c = (prevA+prevB)/2;
        
        if(prevA==a && prevB==b && prevC==c){
            ans = -1;
            break;
        }
        
        prevA=a;
        prevB=b;
        prevC=c;
    }
    cout << ans << endl;
}
 


Measured memory_bytes: 256