akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
using namespace std;

#define Y 50
#define M 5000

#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)

struct Event {int e, v;};

int main() {
	int x, y, z, r[4], n, next, money;
	double p[Y+1][M+1], ans;
	Event ev[Y+1];
	while(1) {
		cin >> x >> y >> z;
		if(!x&&!y&&!z) break;
		for(int i=0; i<x; ++i) cin >> r[i];
		for(int i=0; i<=y; ++i) {
			for(int j=0; j<=M; ++j) p[i][j] = 0.0;
			ev[i].e = ev[i].v = 0;
		}
		for(int i=0; i<z; ++i) {
			cin >> n; cin >> ev[n].e >> ev[n].v;
		}
		p[0][0] = 1.0; ans = 0.0;
		for(int i=0; i<y; ++i) {
			for(int j=0; j<=M; ++j) {
				for(int k=0; k<x; ++k) {
					next = min(i+r[k], y); money = j;
					if(ev[next].e==1) next = min(next+ev[next].v, y);
					else if(ev[next].e==2) money += ev[next].v;
					else if(ev[next].e==3) money = max(money-ev[next].v, 0);
					p[next][money] += p[i][j]/(double)x;
				}
			}
		}
		for(int i=0; i<=M; ++i) ans += p[y][i]*(double)i;
		cout << (int)ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define sz size()
#define pb push_back
#define mp make_pair
#define ALL(X) (X).begin(),(X).end()

using namespace std;

const int INF = 1000000000;
const double eps = 1e-8;

pair<int,int> val(std::string f) {
  if(f[0] == '-') {
    auto p = val(f.substr(1));
    return mp(2-p.first,p.second+1);
  }else if(f[0] == '(') {
    auto p1 = val(f.substr(1));
    auto p2 = val(f.substr(p1.second+2));
    if(f[p1.second+1] == '*') {
      return mp(min(p1.first,p2.first),p1.second+p2.second+3);
    }else{
      return mp(max(p1.first,p2.first),p1.second+p2.second+3);
    }
  }else{
    int v = f[0] - '0';
    return mp(v,1);
  }
}

int main(void) {
  while(1) {
    string str;
    cin>>str;
    if(str==".")break;
    int count =0;
    REP(i,3)REP(j,3)REP(k,3){
      string cp = str;
      for(char& c : cp){
        switch(c){
          case 'P':
          c=i+'0';
          break;
          case 'Q':
          c=j+'0';
          break;
          case 'R':
          c=k+'0';
          break;
        }
      }
      if(val(cp).first == 2)
        ++count;
    }
    cout<<count<<endl;
  }
  return 0;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<vector<int>> m;
    m.assign(h, vector<int>(w));

    int color = 0;
    rep(i, h) rep(j, w)
    {
        if (i % 2 == 0)
            m[i][j] = color + 1;
        else
            m[i][w - j - 1] = color + 1;
        --a[color];
        if (a[color] == 0)
            ++color;
    }

    rep(i, h) rep(j, w)
    {
        cout << m[i][j];
        if (j != w - 1)
            cout << " ";
        else
            cout << endl;
    }
}

Measured memory_bytes: 3600
// A - Kenken Race

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// const int INF = 2147483647;
// const ll INF = 9223372036854775807;
// const ll MOD = 1e9 + 7;

int main() {
	int N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	A--;
	B--;
	C--;
	D--;

	string S;
	cin >> S;

	bool possible = true;

	for (int i=A; i<=C-2; i++) {
		if (S[i+1] == '#' && S[i+2] == '#') possible = false;
	}

	for (int i=B; i<=D-2; i++) {
		if (S[i+1] == '#' && S[i+2] == '#') possible = false;
	}

	if (C > D) {
		bool can_overtake = false;
		for (int i=B; i<=D; i++) {
			if (S[i-1] == '.' && S[i+1] == '.') {
				can_overtake = true;
			}

			if (S[i+1] == '#') i++;
		}

		if (can_overtake == false) possible = false;
	}

	string ans;
	if (possible) ans = "Yes";
	else ans = "No";

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3720
N=int(input())
A=list(map(int,input().split()))
D={}
for i in range(N):
  if A[i] in D:
    D[A[i]]+=1
  else:
    D[A[i]]=1
s=0
for d in D:
  s+=D[d]*(D[d]-1)//2
for i in range(N):
  print(s-D[A[i]]*(D[A[i]]-1)//2+(D[A[i]]-1)*(D[A[i]]-2)//2)

Measured memory_bytes: 24872
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}
int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}



//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
 int A,B,C,D;cin>>A>>B>>C>>D;
  int t =(A+D-1)/D,a=(C+B-1)/B;
  if(a<=t)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}







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

using namespace std;

#define LOG(...) fprintf(stderr,__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int main() {
    int n;
    while (cin >> n, n) {
        bool l = false, r = false, updown = true;
        int cnt = 0;
        REP(i, n) {
            string s;
            cin >> s;
            if (s == "lu") {
                l = true;
            } else if (s == "ru") {
                r = true;
            } else if (s == "ld") {
                l = false;
            } else if (s == "rd") {
                r = false;
            }
            if (l == r && l == updown) {
                cnt++;
                updown = !updown;
            }
        }
        cout << cnt << endl;
    }
}

Measured memory_bytes: 1208
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/abc106/tasks/abc106_b>
 問題文============================================================
 =================================================================
 解説=============================================================
 愚直全探索
 ================================================================
 */

// nの約数を列挙する
vector<ll> getdivisor(ll n){
    vector<ll> res;
    for(ll i = 1; i*i <= n;i++){
        if(n%i == 0) {
            res.push_back(i);
            if(n/i != i) res.push_back(n/i);
        }
    }
    sort(res.begin(),res.end());
    return res;
}
ll solveB(){
    ll res = 0;
    ll N; cin >> N;
    for(int i = 1; i <= N;i++){
        if(i%2 == 0) continue;
        if(getdivisor(i).size() == 8) res++;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solveB() << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cctype>
#define R register
#define IN inline
#define W while
#define gc getchar()
#define MX 610
bool vis[MX][MX];
int siz, d1, d2, bd;
void deal(R int dis)
{
	int tim = 0;
	W (!(dis % 4)) dis /= 4, ++tim;
	if(dis & 1)
	{
		for (R int i = 0; i < bd; ++i)
		for (R int j = 0; j < bd; ++j)
		if((i >> tim) + (j >> tim) & 1) vis[i][j] = true;
	}
	else
	{
		for (R int i = 0; i < bd; ++i)
		for (R int j = 0; j < bd; ++j)
		if((i >> tim) & 1) vis[i][j] = true;
	}
}
int main(void)
{
	scanf("%d%d%d", &siz, &d1, &d2);
	bd = siz << 1; deal(d1), deal(d2);
	int tar = siz * siz, cnt = 0;
	for (R int i = 0; i < bd; ++i)
	for (R int j = 0; j < bd; ++j)
	{
		if(!vis[i][j]) printf("%d %d\n", i, j), cnt++;
		if(cnt == tar) return 0;
	}
}

Measured memory_bytes: 1152
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N, M, X, Y = map(int, input().split())
XS = list(map(int, input().split())) + [X]
YS = list(map(int, input().split())) + [Y]

print("No War" if max(XS) < min(YS) else "War")

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1)
int main(){

ll x ,y,sum=0;
cin>>x>>y;
//x-=1;y-=1;
while(x--)sum+=x;
while(y--)sum+=y;
cout<<sum<<endl;

return 0;
}



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

int main(){
	const int nmax = 1000;
	char c;
	int count = 1;
	int dp[nmax+1];
	int n, w;
	int val[nmax+1], weight[nmax+1];
	while(cin >> w){
		if(w == 0) break;
		cin >> n;
		for(int i = 1; i <= n; i++){
			cin >> val[i] >> c >> weight[i];
		}
		for(int i = 0;i <= w; i++) dp[i] = 0;
		for(int i = 1; i <= n; i++){
			for(int j = w; j >= weight[i]; j--){
				dp[j] = max(dp[j],dp[j - weight[i]] + val[i]);
			}
		}
		cout << "Case " << count++ << ":" << endl;
		cout << dp[w] << endl;
		while(w > 0 && dp[w] == dp[w-1]) w--;
		cout << w << endl;
	}
	return 0;
}

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

using namespace std;

using ll = long long;

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

    int n; cin >> n;
    vector<int> a(n); for (int& x : a) cin >> x;
    vector<int> b = a;
    sort(a.begin(), a.end());

    for (int i = 0; i < n; i++) {
        if (b[i] == a[n - 1]) cout << a[n - 2] << endl;
        else cout << a[n - 1] << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  int a[n];
  int c = 0;
  for(int i = 0;i < n;i++){
    cin >> a[i];
  }
  for(int i = 0;i < n;i++){
    c += a[i];
  }
  
  int b = a[0];
  for(int i = 1;i < n;i++){
    if(b < a[i]){
      b = a[i];
    }
  }
  int d = b/2;
  int e = c-d;
  cout << e << endl;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <ostream& out = cout, class... T> void prints(T&&...){ }
template <ostream& out = cout, class... T> void printd(T&&...){ }
template <ostream& out = cout, class... T> void printb(T&&...){ }
template <ostream& out = cout, class... T> void printArr(T&&...){ }
#endif

bool solve(vector<int>& as, vector<int>& cs, int idx){
    int n = as.size();
    if(n == idx){
        vector<int> nums(n);
        set<int> s(cs.begin(), cs.end());
        int total = s.size();
        for(int i = 0; i < n; i++){
            nums[cs[i]]++;
        }
        bool ok = true;
        for(int i = 0; i < n; i++){
            ok &= as[i] == total - (nums[cs[i]] == 1);
        }
        // prints(ok, cs);
        return ok;
    }
    for(int i = 0; i < n; i++){
        cs[idx] = i;
        if(solve(as, cs, idx + 1)){
            return true;
        }
    }
    return false;
}

int main(){
    int n; cin >> n;
    vector<int> as(n);
    int mini = M, maxi = -1;
    int mins = 0, maxs = 0;
    for(int i = 0; i < n; i++){
        cin >> as[i];
        mini = min(mini, as[i]);
        maxi = max(maxi, as[i]);
    }
    if(mini + 1 < maxi){
        cout << "No" << '\n';
        return 0;
    }
    // if(mini == maxi && (mini == n - 1 || mini == 1)){
    //     cout << "Yes" << '\n';
    //     return 0;
    // }
    for(int i = 0; i < n; i++){
        if(as[i] == mini){
            mins++;
        }else{
            maxs++;
        }
    }
    if(mini != maxi){
        int l = mins + 1, r = mins + maxs / 2;
        // cout << (real + l <= n/* && _ <= real + r*/ ? "Yes" : "No") << '\n';
        cout << (l - 1 <= mini && maxi <= r ? "Yes" : "No") << '\n';
        printd(l, r, mini, maxi);
    }else{
        int l = 1, r = mins / 2;
        cout << ((l - 1 <= mini && maxi <= r) || maxi == n - 1 ? "Yes" : "No") << '\n';
        printd(l, r, mini, maxi);
    }
    return 0;
    // int real = mini + 1;
    vector<int> cs(n);
    prints(solve(as, cs, 0));
    return 0;
}


Measured memory_bytes: 640
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_MOD			1000000007								// 除数(10の9乗+7)
#define D_ARRAY_MAX		105										// 最大配列数
#define D_VAL_MAX		256										// 最大値
#define D_FACT_MAX		D_ARRAY_MAX								// 最大階乗数

// 内部変数
static FILE *szpFpI;											// 入力
static int si3PCnt[D_ARRAY_MAX][D_VAL_MAX][D_ARRAY_MAX];		// パターン数[桁数][値][長さ]
static int si1ModFact[D_FACT_MAX];								// 階乗リスト

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 和 - 取得
int
fGetModSum(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	return (piVal1 + piVal2) % D_MOD;
}

// 積 - 取得
int
fGetModMulti(
	int piVal1					// <I> 値１
	, int piVal2				// <I> 値２
)
{
	return (int)((long long)piVal1 * (long long)piVal2 % D_MOD);
}

// 階乗リスト - 作成
int
fMakeModFact(
	int piMax					// <I> 最大値
)
{
	int i;

	si1ModFact[0] = 1;
	si1ModFact[1] = 1;
	for (i = 2; i <= piMax; i++) {
		si1ModFact[i] = fGetModMulti(si1ModFact[i - 1], i);
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i, j, k;
	char lc1Buf[1024];

	// データ - 初期化
	memset(si3PCnt, 0, sizeof(si3PCnt));
	si3PCnt[0][0][0] = 1;

	// 配列数・k - 取得
	int liACnt, liK;
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &liACnt, &liK);

	// 配列 - 取得
	for (i = 0; i < liACnt; i++) {
		int liVal;
		fscanf(szpFpI, "%d", &liVal);

		// 現在値でループ
		for (j = 0; j < D_VAL_MAX; j++) {
			int liXor = j ^ liVal;
			for (k = 0; k <= i; k++) {

				// 値 - 追加
				si3PCnt[i + 1][liXor][k + 1] = fGetModSum(si3PCnt[i + 1][liXor][k + 1], si3PCnt[i][j][k]);

				// 値 - 追加しない
				si3PCnt[i + 1][j][k] = fGetModSum(si3PCnt[i + 1][j][k], si3PCnt[i][j][k]);
			}
		}
	}
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);

	// 階乗リスト - 作成
	fMakeModFact(liACnt);

	// 合計 - 取得
	int liSum = 0;
	for (i = 0; i <= liACnt; i++) {
		int liCnt = fGetModMulti(si3PCnt[liACnt][liK][i], si1ModFact[i]);
		liSum = fGetModSum(liSum, liCnt);
	}

	return liSum;
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



Measured memory_bytes: 11264
def main():
    n = int(input())
    s = list(map(int,input().split()))
    ans=0
    point=-1
    for i in range(n-1):
        mark=0
        if i > point and i + ans < n:
            for j in range(n-i-1):
                if s[i+j]>=s[i+j+1]:
                    mark+=1
                    if mark>=ans:
                        ans=mark
                else:
                    if mark>=ans:
                        ans=mark
                        point=i+j
                    break
    print(ans)
main()

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

using namespace std;

int main(){
int N,X; cin >> N >> X;
  vector<int> L(N);
  for(int i = 0; i < N; i++){ cin >> L[i];}
  
  int hight = 0; int cnt = 1;
  
  for(int i = 0; i < N; i++){
    hight += L[i]; cnt++;
    if( hight > X){ cnt--;break;}}
 
  cout << cnt << endl; return 0;}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main() {
    int H, W, M;
    cin >> H >> W >> M;
    int h[M], w[M];
    int ch[H]{}, cw[W]{};
    int hmax = 0;
    int wmax = 0;
    for (int i = 0; i < M; i++) {
        cin >> h[i] >> w[i];
        h[i]--;
        w[i]--;
        ch[h[i]]++;
        cw[w[i]]++;
        hmax = max(hmax, ch[h[i]]);
        wmax = max(wmax, cw[w[i]]);
    }
    int hh = 0;
    int ww = 0;
    for (int i = 0; i < H; i++) {
        if (hmax == ch[i]) hh++;
    }
    for (int i = 0; i < W; i++) {
        if (wmax == cw[i]) ww++;
    }
    int cnt = 0;
    for (int i = 0; i < M; i++) {
        if (ch[h[i]] == hmax && cw[w[i]] == wmax) cnt++;
    }
    if (cnt==hh*ww) {
        cout << hmax + wmax - 1<< endl;
    } else {
        cout << hmax + wmax << endl;
    }
    return 0;
}

Measured memory_bytes: 8252
#include "bits/stdc++.h"
#define REP(i, n) for(int i = 0; i < int(n); i++)
#define FOR(i,n,m) for(int i = int(n); i < int(m); i++)
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 6;
const ll LLINF = 1e18 + 1;

// ワーシャルフロイド法 O(V^3)
template<typename T>
struct Warshall_floyd {
private:
    int V; // 頂点数
    vector<vector<T>> d; // i から j の最短距離
public:
    T inf = numeric_limits<T>::max();

    Warshall_floyd(int V) : V(V) {
        d.resize(V, vector<T>(V, inf));
        for (int i = 0; i < V; i++) {
            d[i][i] = 0;
        }
    }
    void add_edge(int from, int to, int cost, bool directed = false) {
        d[from][to] = cost;
        if (!directed) d[to][from] = cost;
    }

    void warshall_floyd() {
        for (int k = 0; k < V; k++) {
            for (int i = 0; i < V; i++) {
                for (int j = 0; j < V; j++) {
                    if (d[i][k] != inf && d[k][j] != inf) {
                        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                    }
                }
            }
        }
    }

    // from から to の距離
    // d[i][i] < 0 の時は負閉路
    T dist(int from, int to) {
        return d[from][to];
    }
};

int main() {
    int v, e; cin >> v >> e;
    Warshall_floyd<ll> G(v);
    REP(i, e) {
        int a, b, c; scanf("%d %d %d", &a, &b, &c);
        G.add_edge(a, b, c, true);
    }
    G.warshall_floyd();
    REP(i, v) if (G.dist(i, i) < 0) {
        puts("NEGATIVE CYCLE");
        return 0;
    }
    REP(i, v) {
        REP(j, v) {
            if (G.dist(i, j) == G.inf) cout << "INF";
            else cout << G.dist(i, j);
            if (j == v - 1) cout << endl;
            else cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 3300
#include <iostream>
using namespace std;
bool a[10001];
int main()
{
  int i,j;
  for(i=2;i<10001;i++){
    if(!a[i]){
      for(j=2;i*j<10001;j++){
	a[i*j] = true;
      }
    }
  }
  for(;;){
    cin >> i;
    if(i==0) break;
    if(i%2 == 0) i--;
    while(i > 4){
      if(a[i] == false && a[i-2] == false) break;
      i -= 2;
    }
    cout << (i-2) << " " << i << endl;
  }
  return 0;
}

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

int main(){
  int a,b,c,x,ans=0;
  cin >>a>>b>>c>>x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(500*i+100*j+50*k==x)
          ans++;
      }
    }
  }
  cout << ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

void solve(){
        long long x,k,d;
        cin>>x>>k>>d;
        x=abs(x);
        if(x>0 && (x/d)>=k){
            long long qq=x/d;
            x=x-(k)*d;
            cout<<x;
            return;
        }
        long long y=x/d;
        x-=y*d;
        k-=y;
        if(k%2==0)
            cout<<abs(x);
        else
            cout<<min(abs(x-d),abs(x+d));
        return;
    }

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	solve();
}	






Measured memory_bytes: 3664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,D;
    cin >> N >> D;
    ll X[15][15];
    rep(i,0,N){
        rep(j,0,D){
            cin >> X[i][j];
        }
    }
    ll ans = 0;
    rep(i,0,N){
        rep(j,0,N){
            if(i >= j) continue;
            ll dist = 0;
            rep(k,0,D){
                dist += (X[i][k] - X[j][k]) * (X[i][k] - X[j][k]);
            }
            bool ok = false;
            rep(v,1,500){
                if(v * v == dist){
                    ok = true;
                }
            }
            if(ok) ans++;
        }
    }
    print(ans);

    
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <string.h>
#include <stack>
#define Endl endl
#define mp make_pair
#define ll long long 
#define pii pair<int,int>
#define pll pair<ll,ll>
#define over(A) {cout<<A<<endl;exit(0);}
#define all(A) A.begin(),A.end()
#define ceil(a,b) ((a-1)/b+1)
#define srand() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define rand(l,r) uniform_int_distribution<int>(l,r)(rng)
typedef unsigned long long ull;
const int inf=1039074182;
using namespace std;
int n,m,p;
vector <pair<int,int> >vec[2505];
ll dist[2505];
int reachable[2505];
bool visit[2505];
vector <int> ivec[2505];

void dfs(int x)
{
	reachable[x]=true;
	visit[x]=true;
	for(auto u:ivec[x])
	{
		if(!visit[u]) dfs(u);
	}
}

int main()
{
//	freopen("input.txt","r",stdin);
	cin>>n>>m>>p;
	int x,y,z;
	for(int i=0;i<m;i++)
	{
		scanf("%d%d%d",&x,&y,&z);
		x--;
		y--;
		z-=p;
		vec[x].push_back(mp(y,z));
		ivec[y].push_back(x);
	}
	reachable[n-1]=true;
	dfs(n-1);
	for(int i=0;i<n;i++)
	{
		dist[i]=-inf;
	}
	bool ok;
	dist[0]=0;
	for(int k=0;k<=5*n;k++)
	{
		ok=false;
		for(int i=0;i<n;i++)
		{
			if(dist[i]==-inf) continue;
			if(!reachable[i]) continue;
			for(auto x:vec[i])
			{
				if(dist[x.first]<dist[i]+x.second)
				{
					ok=true;
					dist[x.first]=dist[i]+x.second;
				}
			}
		}
		if(ok==false) break;
	}
	if(ok)
	{
		cout<<-1<<endl;
	}
	else
	{
		cout<<max(0LL,dist[n-1])<<endl;
	}
	return 0;
}

Measured memory_bytes: 768
function main()
	N,C,K=map(x->parse(Int,x),split(readline()))
	T=sort([parse(Int,readline()) for _=1:N])
	ans=0
	pre=-K
	id=-C
	i=0
	for t=T
		i+=1
		if pre+K<t||i-id>=C
			ans+=1
			pre=t
			id=i
		end
	end
	println(ans)
end
main()


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

int main()
{
    ll n;
    cin >> n;
    
    vector<pair<ll, int>> a;
    for(ll i = 2; i*i <= n; i++){
        int x = 0;
        while(n%i == 0){
            n /= i;
            x++;
        }
        a.emplace_back(i, x);
    }
    if(n != 1) a.emplace_back(n, 1);
    int ans = 0;
    for(auto i : a){
        int x = 1;
        while(i.second - x >= 0){
            i.second -= x;
            x++;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 19768
"use strict";
const main = arg => {
    var lines = arg.split('\n');

    var k = +lines.shift();

    var array = lines[0].split(" ").map(Number);
    
    var isDistance = false;

    for(var i = array[0]; i <= array[1]; i++){
        if((i % Number(k)) === 0){
            isDistance = true;
        }
    }

    if(isDistance){
        console.log("OK");
    }else{
        console.log("NG")
    }
}
 
main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
    long long N, x;
    cin >> N >> x;
    long long count = 0;
    vector<long long> a(N);

    rep(i,N)cin>>a[i];
    rep(i,N-1){
        if(a[i]+a[i+1]>x&&x>=a[i]){
            count+=a[i+1]+a[i]-x;
            a[i+1]-=a[i+1]+a[i]-x;
        }else if(a[i]+a[i+1]>x && x<a[i]){
            count+=a[i+1]+a[i]-x;
            a[i+1]=0;
        }
    }
    cout<<count<<endl;
}

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

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)

int main() {
	while (true) {
		int N, M, K; cin >> N >> K >> M;
		if (N == 0) break;
		vector<int> v(N);
		REP(i, N) v[i] = i + 1;
		int x = M - 1;
		v.erase(v.begin() + x);
		while (v.size() > 1) {
			x = (x + K - 1) % v.size();
			v.erase(v.begin() + x);
		}
		cout << *v.begin() << endl;
	}
}

Measured memory_bytes: 1252
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int main()
{
	ll n,m;
	cin>>n>>m;
	ll d=m,x=0,y=0;
	cin>>x>>y;
	ll a,b;
	while(--d)
	{
		cin>>a>>b;
		if(a>x)
		{
			//cout<<"this 1"<<endl;
			x=a;
			//cout<<x<<" ";
		}
		if(b<y)
		{
			//cout<<"this 2"<<endl;
			y=b;
			//cout<<y<<" ";
		}
	}
	if(y-x+1<=0)
	cout<<"0";
	else
	cout<<y-x+1;
	return 0;
}

Measured memory_bytes: 256
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

const ll DIV = (ll)1e9+7;
// const ll MAXN = (ll)1e5+10;

int main(void) {
   int N;
   cin>>N;
   map<ll,ll> A;
   rep(i,0,N) {
      ll a;
      cin>>a;
      A.insert(make_pair(a,i));
   }
   ll ans = 0;
   ll cnt = 0;
   for (auto el:A) {
      // cout<<el.second<<" "<<el.first<<" "<<cnt<<endl;
      if ((el.second-cnt)%2 != 0) ans++;
      cnt++;
   }
   cout<<ans/2<<endl;

   return 0;
}



Measured memory_bytes: 6528
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
#include <cstdint>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long int ll;
typedef pair<ll, ll> P;
const vector<int> di = { -1, 0, 1, 0 };
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a.at(i);
	sort(a.begin(), a.end());

	int ans = a.at(a.size() - 1) - a.at(0);
	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
/* ex7_3
   Acro    */

#include <stdio.h> 
#include <stdlib.h>

int main(void){
    int row,column,TF,i,j,k;
    scanf("%d %d",&row,&column);
    /* メモリの動的確保 */
    char **squares;
    /* 各行の配列へのポインタ分のメモリ領域を確保 */
    squares = (char**)calloc(row, sizeof(char*));
    if (squares == NULL)
    {
        exit(1);
    }
    /* 各行の要素分のメモリ領域を確保 */
    for ( i = 0; i < row; i++)
    {
        squares[i] = (char*)calloc(column, sizeof(char));
        if (squares[i] == NULL)
        {
            exit(1);
        }
        
    }
    /* 入力 */
    for ( i = 0; i < row; i++)
    {
        for ( j = 0; j < column; j++)
        {
            scanf(" %c",&squares[i][j]);
        }
    }
    /* 列の探索 */
    for ( i = 0; i < row; i++)
    {
        TF = 1;
        for ( j = 0; j < column; j++)
        {
            if (squares[i][j] == '#')
            {
                TF = 0;
            }
        }
        /* 列が全て白だった場合 */
        if (TF)
        {
            for (j = i;j < row-1;j++)
            {
                for ( k = 0; k < column; k++)
                {
                    /* 列を上に寄せていく */
                    squares[j][k] = squares[j+1][k];
                }
                
            }
            row -= 1;
            i -= 1;
        }
        
        
    }
    /* 行の探索 */
    for ( i = 0; i < column; i++)
    {
        TF = 1;
        for ( j = 0; j < row; j++)
        {
            if (squares[j][i] == '#')
            {
                TF = 0;
            }
            
        }
        /* 行が全て白だった場合 */
        if (TF)
        {
            for ( j = i; j < column-1; j++)
            {
                for ( k = 0; k < row; k++)
                {
                    squares[k][j] = squares[k][j+1];
                }
                
            }
            column -= 1;
            i -= 1;
        }
        
        
    }
    /* 出力 */
    for ( i = 0; i < row; i++)
    {
        for ( j = 0; j < column; j++)
        {
            printf("%c",squares[i][j]);
        }
        printf("\n");
        
    }
    /* メモリ領域の解法 */
    for ( i = 0; i < row; i++)
    {
        free(squares[i]);
    }
    free(squares);
    return 0;
}


Measured memory_bytes: 1620
#include<bits/stdc++.h>
#define R register int
#define ll long long 
using namespace std;
const int mod=1000000007;
const int N=100001;
int n,w[N],res[N];
int le,ri,z,y;ll ans;
int gi(){
    R x=0,k=1;char c=getchar();
    while(c!='-'&&(c<'0'||c>'9'))c=getchar();
    if(c=='-')k=-1,c=getchar();
    while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+c-'0',c=getchar();	
    return x*k;
}
int main(){
	n=gi();
	for(R i=1;i<=n;++i)w[i]=gi();
	sort(w+1,w+n+1);
	le=2,ri=n,z=w[1],y=w[1];
	while(le<=ri){
		R p=abs(w[le]-z),q=abs(w[le]-y),a=abs(w[ri]-z),b=abs(w[ri]-y),Mx=max(max(p,q),max(a,b));
		if(Mx==p)z=w[le],le++;
		else if(Mx==q)y=w[le],le++;
		else if(Mx==a)z=w[ri],ri--;
		else y=w[ri],ri--;
		ans+=Mx;
	}
	cout<<ans<<endl;
    return 0;
}


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

int main() {
	static long K, N, a[2000000], max = 0,total=0;
	cin >> K;
	cin >> N;
	for (int x = 0; x < N; x++)cin >> a[x];
	max = K - a[N - 1]+a[0];
	for (int x = 0; x < N-1; x++) {
		total += a[x + 1] - a[x];
		if (a[x + 1] - a[x] > max)max = a[x + 1] - a[x];
	}
	total += a[0] + (K - a[N - 1]);
	cout << total - max << endl;
}


Measured memory_bytes: 1792
import sys


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    s = str(readline().rstrip().decode('utf-8'))
    cur = n
    ans = []
    while True:
        b = False
        for i in range(cur - m, cur):
            if 0 <= i < n + 1:
                if s[i] == "0":
                    b = True
                    ans.append(cur - i)
                    cur = i
                    break
        if not b:
            print(-1)
            exit()
        if cur == 0:
            ans.reverse()
            print(*ans)
            exit()


if __name__ == '__main__':
    solve()


Measured memory_bytes: 49648
import itertools
h, w = map(int,input().split())
masu = []
for _ in range(h):
    masu.append(list(input()))

for i in range(h):
    for j in range(w):
        if masu[i][j] == '.':
            continue

        directions = [[1,0],[0,1],[-1,0],[0,-1]]
        for d in directions:
            if 0 <= i + d[0] <= h-1 and 0 <= j + d[1] <= w-1:
                if masu[i+d[0]][j+d[1]] != '.':
                    masu[i][j] = '黒'
                    masu[i + d[0]][j + d[1]] = '黒'

if '#' in list(itertools.chain.from_iterable(masu)):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9192
#include<stdio.h>

int main(void){

    int a[3];
    int i,j;
    int tmp;
    for(i = 0; i < 3; i++){
        scanf("%d",&a[i]);
    }

    for(i = 0; i < 3; i++){
        for(j = 2 ;j > i; j--){
            if(a[j] < a[j-1]){
                tmp = a[j];
                a[j]= a[j-1];
                a[j-1]= tmp;
            }
        }
    }

    printf("%d %d %d\n",a[0], a[1], a[2]);


    return 0;
}

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

int main()
{
	int m;
	cin >> m;
	for(int i=0;i<m;i++){
		int money,year,n;
		int max = 0;
		cin >> money >> year >> n;
		for(int j=0;j<n;j++){
			bool flag;
			double nennri;
			int risi;
			cin >> flag >> nennri >> risi;
			int mon = money;
			if(flag)
				for(int k=0;k<year;k++)
					mon = mon+static_cast<int>(static_cast<double>(mon)*nennri)-risi;
			else{
				int B=0;
				for(int k=0;k<year;k++){
					B +=  static_cast<int>(static_cast<double>(mon)*nennri);
					mon -= risi;
				}
				mon += B;
			}
			if(max < mon)
				max = mon;
		}
		cout << max << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
int main() {
	int num;
	cin >>num;
	VE val(num),cost(num);
	REP(i, num) {
		cin >> val[i];
	}
	REP(i, num) {
		cin >> cost[i];
	}
	VE bal(num);
	int ans = 0;
	REP(i, num) {
		bal[i] = val[i] - cost[i];
		if (bal[i] > 0) {
			ans += bal[i];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
const int INF = 1e9;

string s;
int K;

int main(){
    cin >> s >> K;

    vector<string> v;
    REP(i,s.size()){
        for(int j = 1; j <= K; ++j)
        v.push_back(s.substr(i,j));
    }
    sort(v.begin(),v.end());
    unique(v.begin(),v.end());
    cout << v[K-1] << endl;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,i;
  cin >> N;
 
  for (i = 0; i < N; i++) {
    string S;
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    else if (i == N - 1) {
      cout << "Three" << endl;
    }
  }
  }

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

int n, m, ans = 0;
int memo[105] = {0};

int main() {
  while(1) {
    cin >> n >> m;
    if(n + m == 0) break;
    ans = 0;
    for(int i = 0; i < n; ++i) {
      int d, v;
      cin >> d >> v;
      memo[d] = max(memo[d], v);
    }
    for(int i = 1; i <= m; ++i) ans += memo[i];
    cout << ans << endl;
    for(int i = 0; i <= m; ++i) memo[i] = 0;
  }
  return 0;
}


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

int main()
{
    std::string s,t;
    std::cin >> s >> t;
    int a,b;
    std::string f;
    std::cin >> a >> b >> f;
    if(f == s)a--;
    else b--;
    std::cout << a << " " << b << std::endl;
}

Measured memory_bytes: 256
from collections import defaultdict
import sys
import math
from datetime import datetime

def sol(m1, d1, m2, d2):
    return 0 if m1 == m2 else 1


do_submit = True
#do_submit = False

def input_parse(input_str):
    lines = [x.strip() for x in input_str.split("\n") if x.strip()]
    parsed_lines = [list(map(str, line.split())) for line in lines]
    print(parsed_lines)
    m1 = int(parsed_lines[0][0])
    d1 = int(parsed_lines[0][1])
    m2 = int(parsed_lines[1][0])
    d2 = int(parsed_lines[1][1])
    #S = parsed_lines[1][0]
    return m1, d1, m2, d2


if not do_submit:
    m1, d1, m2, d2 = input_parse("""
    11 16
    11 17
    """)
    print(sol(m1, d1, m2, d2))

    m1, d1, m2, d2 = input_parse("""
    11 30
    12 1
    """)
    print(sol(m1, d1, m2, d2))

else:
    m1, d1 = list(map(int, input().split()))
    m2, d2 = list(map(int, input().split()))
    # S = input().split()
    # S = input()
    # T = input()
    print(sol(m1, d1, m2, d2))
    # S = input().strip()
    # print(sol(S))


Measured memory_bytes: 3696
n = int(input())
listN = list(str(n))

if listN[0]==listN[1] and listN[1] ==listN[2]:
    print(n)
else:
    if listN[0] > listN[1]:
        print(listN[0]+listN[0]+listN[0])
    elif listN[0] == listN[1] and listN[1] > listN[2]:
        print(listN[0]+listN[0]+listN[0])
    else:
        number = str(int(listN[0])+1)
        print(number+number+number)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000;

int main(){
    int n; cin >> n;
    n *= 100;
    for (int i = 0; i < 100; i++) {
        if ((n+i) % 108 == 0) {
            cout << (n+i) / 108 << endl;
            return 0;
        }
    }

    cout << ":(" << endl;

    return 0;
} 

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
int main()
{
    string s;
    cin>>s;
    for(ll i=0;i<s.size();i++)
    {
         if(i%2==0){
         if(s[i]=='L')  
         {
              return cout<<"No",0;
         }}
         else
         {
              if(s[i]=='R')
              {
                   return cout<<"No",0;
              }
         }
         
    }
    cout<<"Yes";
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
#define MOD @
#define ADD(X,Y) ((X) = ((X) + (Y)%MOD) % MOD)
typedef long long i64; typedef vector<int> ivec; typedef vector<string> svec;

int N, M;
int A[101010], B[101010];
vector<int> graph[101010]; int indeg[101010];

int dmax[101010];

int visit(int p)
{
	if (dmax[p] != -1) return dmax[p];
	
	dmax[p] = 0;
	for (int q : graph[p]) {
		dmax[p] = max(dmax[p], visit(q) + 1);
	}

	return dmax[p];
}

int ans[101010];

void visit2(int p, int rt)
{
	if (ans[p] != -1) return;
	ans[p] = rt + 1;

	vector<pair<int, int>> ch;
	for (int q : graph[p]) ch.push_back({dmax[q], q});
	sort(ch.begin(), ch.end());
	reverse(ch.begin(), ch.end());

	for (auto a : ch) visit2(a.second, p);
}

int main()
{
	scanf("%d%d", &N, &M);
	for (int i = 0; i < N + M - 1; ++i) {
		scanf("%d%d", A + i, B + i);
		--A[i]; --B[i];
	}
	for (int i = 0; i < N + M - 1; ++i) {
		graph[A[i]].push_back(B[i]);
		++indeg[B[i]];
	}
	int ori = -1;
	for (int i = 0; i < N; ++i) {
		if (indeg[i] == 0) ori = i;
	}

	for (int i = 0; i < N; ++i) dmax[i] = ans[i] = -1;
	visit(ori);
	visit2(ori, -1);

	for (int i = 0; i < N; ++i) printf("%d\n", ans[i]);

	return 0;
}


Measured memory_bytes: 20736
use std::io;
use std::collections::VecDeque;

fn main() {
    let mut input = Input::new();
    let h: usize = input.next();
    let w: usize = input.next();
    let a: Vec<Vec<bool>> = (0..h)
        .map(|_| input.next::<String>().chars().map(|c| c == '#').collect())
        .collect();
    let mut b: Vec<Vec<bool>> = vec![vec![false;w];h];
    let mut y = 0;
    let mut x = 0;
    loop {
        b[y][x] = true;
        if y + 1 < h && a[y + 1][x] {
            y += 1;
        } else if x + 1 < w && a[y][x + 1] {
            x += 1;
        } else {
            break;
        }
    }
    println!("{}",
             if y + 1 == h && x + 1 == w && (0..h).all(|i| (0..w).all(|j| a[i][j] == b[i][j])) {
                 "Possible"
             } else {
                 "Impossible"
             });
}

struct Input {
    queue: VecDeque<String>,
}

impl Input {
    fn new() -> Input {
        Input { queue: VecDeque::new() }
    }

    fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        if self.queue.is_empty() {
            let mut line = String::new();
            let _ = io::stdin().read_line(&mut line);
            for x in line.split_whitespace() {
                self.queue.push_back(String::from(x));
            }
        }
        return self.queue.pop_front().unwrap().parse::<T>().unwrap();
    }
}



Measured memory_bytes: 4352
import java.util.Scanner;

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

Measured memory_bytes: 26376
using System;

namespace エクサウィーズ2019_C___Snuke_the_Wizard
{
    class Program
    {
        static void Main(string[] args)
        {
            var NQ = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NQ[0]; var Q = NQ[1];
            var s = Console.ReadLine();
            var t = new char[Q]; var d = new char[Q];
            for (int i = 0; i < Q; i++)
            {
                var td = Console.ReadLine();
                t[i] = td[0];
                d[i] = td[2];
            }

            var deadL = -1; var deadR = N;
            for (int i = Q - 1; i >= 0; i--)
            {
                if (d[i] == 'L')
                {
                    if (deadL < N - 1 && s[deadL + 1] == t[i]) deadL++;
                    if (deadR < N && s[deadR] == t[i]) deadR++;
                }
                else
                {
                    if (deadL > -1 && s[deadL] == t[i]) deadL--;
                    if (deadR > 0 && s[deadR - 1] == t[i]) deadR--;
                }
            }

            Console.WriteLine(Math.Max(deadR - deadL - 1, 0));
        }
    }
}

Measured memory_bytes: 16604
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    h,w = LI()
    a = LIR(h)
    b = LIR(h)
    for i in range(h):
        for j in range(w):
            a[i][j] -= b[i][j]
            if a[i][j] < 0:
                a[i][j] *= -1
    d = [(0,1),(1,0)]
    f = [0 for x in range(w)]
    M = (1<<25600)-1
    b = 12800
    f[0] = (1<<(b+a[0][0]))|(1<<(b-a[0][0]))
    for y in range(h):
        ny = y+1
        nf = [0 for x in range(w)]
        for x in range(w):
            nx = x+1
            if nx < w:
                f[nx] |= ((f[x]<<a[y][nx])|(f[x]>>a[y][nx]))
                f[nx] &= M
            if ny < h:
                nf[x] |= ((f[x]<<a[ny][x])|(f[x]>>a[ny][x]))
                nf[x] &= M
        if ny < h:
            f = [i for i in nf]
    ans = bin(f[w-1])[2:]
    ans = [abs(i-b) for i in range(len(ans)) if ans[len(ans)-i-1] == "1"]
    print(min(ans))
    return

#Solve
if __name__ == "__main__":
    solve()


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;

long long H;
long long now;
long long ans;

void attack(){
    ans+=now;
    H=floor((double)H/2);
    now*=2;
    
}
int main(){
    
    cin>>H;
    now=1;
    ans=0;

    while(H!=0){
        attack();
        //cout<<ans<<" ";
    }

    cout<<ans<<endl;
    
    return 0;

}
/*


*/


Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int n_val=0,m_val=0,l_val=0;
	scanf("%d %d %d",&n_val ,&m_val ,&l_val);
	int A[100][100],B[100][100];
	long long int C[100][100];

	for(int i=0; i<100; i++){
		for(int t=0; t<100; t++){
			C[i][t]=0;
		}
	}

	for(int i=0; i<n_val; i++){
		for(int t=0; t<m_val; t++){
			scanf("%d",&A[i][t]);
		}
	}
	for(int i=0; i<m_val; i++){
		for(int t=0; t<l_val; t++){
			scanf("%d",&B[i][t]);
		}
	}
	for(int i=0; i<n_val; i++){
		for(int t=0; t<l_val; t++){
			for(int f=0;f<m_val;f++){
				C[i][t]+=A[i][f]*B[f][t];
			}
		}
	}
	for(int i=0; i<n_val; i++){
		for(int t=0; t<l_val; t++){
			if(t<l_val-1){
			printf("%lld ",C[i][t]);
			}else{
				printf("%lld\n",C[i][t]);
			}
		}
	}
	return 0;
}



Measured memory_bytes: 2856
import sys
import math
n = int(sys.stdin.readline().rstrip("\n"))
n_2 = math.ceil(math.sqrt(n))
ans = 0
for a in range(1,n_2):
    q, mod = divmod(n, a)
    if mod == 0:
        bmax = q
    else:
        bmax = q + 1
    for b in range(a,bmax):
        if a == b:
            ans += 1
        else:
            ans += 2
print(ans)

Measured memory_bytes: 66420