akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define INF 1e7
using namespace std;

int abs(int a){
	return (a>0)?a:-1*a;
}

int main(){
	int n;
	cin>>n;
	int m[n],d[n],s[n],v[n];
	rep(i,n)cin>>m[i]>>d[i]>>v[i]>>s[i];
	int cal[360];
	rep(i,360){
		cal[i]=0;
		rep(j,n){
			int f=30*(m[j]-1)+d[j]-1,l=(30*(m[j]-1)+d[j]+v[j]-2)%360;
			if(l<f){
				if(i<=l || f<=i)cal[i]=max(cal[i],s[j]);
				else cal[i]=max(cal[i],max(0,s[j]-min(min(abs(f-i),360-abs(f-i)),min(abs(l-i),360-abs(l-i)))));
			}else{
				if(f<=i && i<=l)cal[i]=max(cal[i],s[j]);
				else cal[i]=max(cal[i],max(0,s[j]-min(min(abs(f-i),360-abs(f-i)),min(abs(l-i),360-abs(l-i)))));
			}
		}
	}
	int ans=INF;
	rep(i,360){
		ans=min(ans,cal[i]);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3112
from bisect import bisect_left

def main():
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))

    count = 0
    for t in T:
        i = bisect_left(S, t)
        if i != len(S) and S[i] == t:
            count += 1
    print(count)

if __name__ == "__main__":
    main()


Measured memory_bytes: 16744
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	int a, b;
	cin >> a >> b;
	cout << a * b << endl;

	return 0;
}



Measured memory_bytes: 3612
n = int(input())
a = sorted(map(int, input().split()))
m = a[-1]
dp = [0]*(m+1)

for i in a:
    dp[i] += 1
    if dp[i] > 1:
        continue
    else:
        for j in range(i*2, m+1, i):
            dp[j] += 1

print(sum([1 for i in a if dp[i] == 1]))


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

using ll = long long;

ll H, W;

int main() {
   cin >> H >> W;

   ll ans = 1e18;
   // 横に3分割する
   if (H % 3 == 0 || W % 3 == 0) {
      ans = 0;
   } else {
      ans = min(ans, (H/3+1)*W - H/3*W);
      swap(H, W);
      ans = min(ans, (H/3+1)*W - H/3*W);
      swap(H, W);
   }

   // 横と縦に3分割する
   for (int k = 0; k < 2; k++) {
      for (int h1 = 1; h1 < H; h1++) {
         int h2 = H - h1;
         ll a = h1 * W;
         ll b = h2 * (W/2);
         ll c = h2 * ((W+1)/2);
         ans = min(ans, max({a, b, c}) - min({a, b, c}));
      }
      swap(H, W);
   }

   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 1100000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

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

int main(){
	ll n,m; cin >> n >> m;
	vl a(n); rep(i,n) cin >> a[i];
	vd p(n);
	rep(i,n){
		cin >> p[i];
		p[i] /= 100.0;
	}
	vl gc(1<<n,0);
	vl f(1<<n,0);
	rep(bit,1<<n){
		ll cnt = 0;
		rep(i,n){
			if(bit>>i & 1){
				cnt++;
			}
			else{
				ll nxt = bit | (1<<i);
				if(gc[bit] == m+1) gc[nxt] = m+1;
				else{
					ll g = GCD(gc[bit], a[i]);
					if(gc[bit] == 0) gc[nxt] = a[i];
					else if(gc[bit] / g > m / a[i]) gc[nxt] = m+1;
					else gc[nxt] = gc[bit] / g * a[i];
				}
			}
		}
		if(cnt == 0) f[bit] = 0;
		else if(cnt & 1) f[bit] = m / gc[bit];
		else f[bit] = - m / gc[bit];
	}
	rep(i,n){
		rep(bit,1<<n){
			if(bit>>i & 1) f[bit] += f[bit ^ (1<<i)];
		}
	}
	double ans = 0.0;
	rep(bit,1<<n){
		double pp = 1.0;
		rep(i,n){
			if(bit>>i & 1) pp *= p[i];
			else pp *= (1.0 - p[i]);
		}
		ans += pp * f[bit];
	}
	printf("%.10f\n",ans);
}


Measured memory_bytes: 19252
import sys
import math
import copy
from heapq import heappush, heappop, heapify
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter
# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

class BIT():
    # A1 ... AnのBIT(1-indexed)
    def __init__(self, n):
        self.n = n
        self.BIT = [0] * (n + 2)

    # A1 ~ Aiまでの和 O(logN)
    def query(self, idx):
        res_sum = 0
        while idx > 0:
            res_sum += self.BIT[idx]
            idx -= idx & (-idx)
        return res_sum

    # Ai += x O(logN)
    def update(self, idx, x):
        # print(idx)
        while idx <= self.n:
            # print(idx)
            self.BIT[idx] += x
            idx += idx & (-idx)
        return

    def show(self):
        print(self.BIT)


def solve():
    n, k = getList()
    lis = getList()
    ans = 0
    bind = True
    dp = [-1 ,0]
    for rui in range(50, -1, -1):
        tmp = [-1 ,0]
        tgt = pow(2, rui)
        bit = tgt & k
        u, d = 0, 0
        for num in lis:
            if num & tgt == tgt:
                u += 1
            else:
                d += 1
        # print(u, d)
        if bit == 0:
            tmp[1] = dp[1] + tgt * u
            if dp[0] != -1:
                tmp[0] = dp[0] + tgt * max(u, d)
        else:
            if dp[0] != -1:
                tmp[0] = dp[0] + tgt * max(u, d)
            tmp[0] = max(dp[1] + tgt * u, tmp[0])
            tmp[1] = dp[1] + tgt * d
        dp = tmp
        # print(dp, bit, u, d)
    print(max(dp))

def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 89968
#include <stdio.h>

int tront[12][12];

void check(int x, int y);

int main(void) {
	int i, j;
	int c;
	int count = -1;
	while (1) {
		if (count != -1 && getchar() == EOF)
			break;
		count = 0;
		for (i = 0; i < 12; i++) {
			for (j = 0; j < 13; j++) {
				if ((c = getchar()) != '\n')
					tront[i][j] = c - '0';
			}
		}
		for (i = 0; i < 12; i++) {
			for (j = 0; j < 12; j++) {
				if (tront[i][j] == 1) {
					check(j, i);
					count++;
				}
			}
		}
		printf("%d\n", count);
	}
	return 0;
}

void check(int x, int y) {
	tront[y][x] = 2;
	if (x - 1 >= 0 && tront[y][x-1] == 1)
		check(x-1, y);
	if (x + 1 < 12 && tront[y][x+1] == 1)
		check(x+1, y);
	if (y - 1 >= 0 && tront[y-1][x] == 1)
		check(x, y-1);
	if (y + 1 < 12 && tront[y+1][x] == 1)
		check(x, y+1);
}

Measured memory_bytes: 524
from collections import deque

H, W = map(int, input().split())
edges = ['#']*(W+2)
field = [edges]
dyx = [(0, 1), (0, -1), (1, 0), (-1, 0)]
bk = 0
for _ in range(H):
    line = list(input())
    bk += line.count('#')
    field.append(['#'] + line + ['#'])
field.append(edges)

steps = 1
q = deque()
field[1][1] = 1
q.append((1, 1, 1))

while q:
    cy, cx, lv = q.popleft()

    for dy, dx in dyx:
        ny, nx = dy+cy, dx+cx

        if field[ny][nx] == '.':
            field[ny][nx] = lv+1
            q.append((ny, nx, lv+1))
steps = str(field[H][W])
if steps.isnumeric():
    print(W*H-bk-int(steps))
else:
    print(-1)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MAX 1000000
#define MOD 1000000007

long long modpow(long long a,long long n,long long mod){
  long long res=1;
  while(n>0){
    if(n&1){       //nのbitと...00001を比較  nが2で割り切れるならtrue
      res=(res*a)%mod;
    }
    a=(a*a)%mod;
    n>>=1;
  }
  return res;
}

long long modinv(long long a,long long mod){
  return modpow(a,mod-2,mod);
}

long long fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=(fac[i-1]*i)%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

long long 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]%MOD)%MOD;
}

int main(){
  ll X,Y;
  cin>>X>>Y;
  if((X+Y)%3!=0||X>2*Y||Y>2*X){
    cout<<0<<endl;
  }else{
    ll x=max(X,Y)-min(X,Y);
    ll n=(X+Y)/3;
    COMinit();
    cout<<COM(n,(n+x)/2)<<endl;
  }
}


Measured memory_bytes: 23680
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n;
  cin >> n;
  int x = n;
  int m = 0;
  while(x>0){
    m += x%10;
    x /= 10;
  }
  cout << (n%m==0?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S, T, ans="No";
  cin >> S >> T;
  vector<char> s(26,'0'), t(26,'0');
  //'a'=97
  for(int i=0; i<S.size(); i++){
    int a=S[i]-97, b=T[i]-97;
//    cout<<"i:"<<i<<" s[i]:"<<S[i]<<" a:"<<a<<endl;
    if(s[a]=='0'){
      s[a]=T[i];
    }
    else if(s[a]!=T[i]) break;
    
    if(t[b]=='0'){
      t[b]=S[i];
    }
    else if(t[b]!=S[i]) break;    
    if(i==S.size()-1) ans="Yes";
  }
  cout << ans << endl;
}

Measured memory_bytes: 776
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string a;
int main()
{
    cin>>a;
    int ans=0;
    int p=0;
    for(int i=0;i<a.size();i++)
    {
        if(a[i]=='g')
        {
            if(p>0)
            {
                ans++;
                p--;
            }
            else
            {
                p++;
            }
        }
        else
        {
            if(p>0)
                p--;
            else
            {
                p++;
                ans--;
            }

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

Measured memory_bytes: 512
from math import ceil
from decimal import Decimal

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

a = 1
b = 1
for x, y in TA:
    n = max(ceil(Decimal(a) / Decimal(x)), ceil(Decimal(b) / Decimal(y)))
    a = n * x
    b = n * y
print(a + b)

Measured memory_bytes: 5076
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

ll n;
ll a[101010];
int main(){
    cin>>n;
    REP(i, 0, n) cin>>a[i];

    bool first=false;
    REP(i, 0, n) {
        if(a[i]%2!=0){
            first=true;
            break;
        }
    }
    if(first) cout<<"first"<<endl;
    else cout<<"second"<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == 1 && b == 0 && c == 0) {
		cout << "Close" << endl;
	}
	if (a == 0 && b == 1 && c == 0) {
		cout << "Close" << endl;
	}
	if (a == 1 && b == 1 && c == 0) {
		cout << "Open" << endl;
	}
	if (a == 0 && b == 0 && c == 1) {
		cout << "Open" << endl;
	}
	if (a == 0 && b == 0 && c == 0) {
		cout << "Close" << endl;
	}
}


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

using namespace std;

#define S scanf
#define P printf
#define G getline
#define Si size()
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define Em empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define Fi first
#define Se second
#define Pi acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define MP make_pair
#define LL long long int
#define ULL unsigned long long int
#define PII pair<int,int>
#define PSI pair<string,int>
#define PIS pair<int,string>
#define PLI pair<long long int,int>
#define PLL pair<long long int,long long int>
#define MII map<int,int>
#define MSI map<string,int>
#define MIS map<int,string>
#define MLI map<long long int,int>

void FAST();
LL big_mod(LL val,LL pow,LL mod);
LL mod_inverse(LL val,LL mod);









int main()
{
    FAST();

//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,l,cnt=0;
    string s;
    cin >> s;
    l=s.size();
    if(l > 1)
    {
        if(s[1] == s[0])
        {
            cnt++;
            if(s[0] == '1')
            {
                s[1]='0';
            }
            else
            {
                s[1]='1';
            }
        }
    }
    for(i=2;i<l;i++)
    {
        if(s[i] == s[i-1])
        {
            cnt++;
            s[i]=s[i-2];
        }
    }
    cout << min(cnt,l-cnt);
    return 0;
}







void FAST()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

LL big_mod(LL val,LL pow,LL mod)
{
    LL res = 1;
    val = val % mod;
    while(pow > 0)
    {
        if(pow & 1)
        {
            res = (res*val) % mod;
        }
        pow = pow >> 1;
        val = (val*val) % mod;
    }
    return res;
}

LL mod_inverse(LL val,LL mod)
{
    LL mod1 = mod;
    if(mod == 1)
    {
        return 0;
    }
    LL y = 0;
    LL x = 1;
    LL quotient,temp;
    while(val > 1)
    {
        quotient = val / mod;
        temp = mod;
        mod = val % mod;
        val = temp;
        temp = y;
        y = x - quotient * y;
        x = temp;
    }
    if(x < 0)
    {
        x += mod1;
    }
    return x;
}


Measured memory_bytes: 512
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = 5;
		int[] a = new int[n];
      	int num=0;
		for(int i=0; i<a.length; i++){
			a[i] = scn.nextInt();
          	if(a[i]==0) num=i+1;
		}
      	System.out.println(num);
	}
}

Measured memory_bytes: 35616
#include <stdio.h>
#include <stdlib.h>

int main(void){
  int h, n;
  int *a;
  int sum=0;
  scanf("%d %d", &h, &n);
  a = (int *)malloc(sizeof(int)*n);
  for(int i = 0; i < n; i++){
    scanf("%d ", &a[i]);
    sum = sum + a[i];
  }
  if(sum>=h){
    printf("Yes");
  }else{
    printf("No");
  }
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	long long n, ans = 1;
	cin >> n;

	vector<long long> p(n);
	cin >> p.at(0);
	long long mi = p.at(0);
	for(long long i=1;i<n;i++){
		cin >> p.at(i);
		if(p.at(i-1)>=p.at(i) && mi>=p.at(i)){
			ans++;
			mi = p.at(i);
		}
	}
	cout << ans << endl;
}

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

const double pi = 3.141592653589793;
#define YESNO(x) x ? printf("YES") : printf("NO")
#define YesNo(x) x ? printf("Yes") : printf("No")
#define rep(i,a,b) for (int (i) = (a); (i) < (b); ++(i))
#define scani(x) scanf("%d", &x)
#define scanll(x) scanf("%lld", &x)
#define printi(x) printf("%d", x)
#define printll(x) printf("%lld", x)
typedef long long ll;
using namespace std;

long long GCD(long long x, long long y) {
	return y ? GCD(y, x % y) : x;
}

long long LCM(long long x, long long y) {
	return x * y / GCD(x, y);
}

//give up(TLE)
int ABC168D() {
	int n, m;
	scani(n);
	scani(m);

	vector<int> graph[101010];
	int ans[101010];
	rep(i, 0, m) {
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	vector<bool> visit(n, false);
	visit[0] = true;
	queue<int> q;
	q.push(0);
	while (!q.empty()) {
		int cur = q.front();
		q.pop();

		for (auto& itr : graph[cur]) {
			if (!visit[itr]) {
				ans[itr] = cur;
				visit[itr] = true;
				q.push(itr);
			}
		}
	}

	bool isOk = true;
	for (auto itr : visit) {
		if (!itr) {
			YesNo(0);
			return 0;
		}
	}

	YesNo(1);
	printf("\n");
	rep (i, 1, n) {
		printf("%d\n", ans[i] + 1);
	}


	return 0;
}

int main()
{
	ABC168D();
	return 0;
}

Measured memory_bytes: 10640
import sys
def input(): return sys.stdin.readline().rstrip()


def per(n, r, mod=10**9+7):  # 順列数
    per = 1
    for i in range(r):
        per = per*(n-i) % mod
    return per


def com(n, r, mod=10**9+7):  # 組み合わせ数
    bunshi = per(n, r, mod)
    bunbo = 1
    for i in range(1, r+1):
        bunbo = bunbo*i % mod
    return bunshi*pow(bunbo, -1, mod) % mod


def main():
    s = int(input())
    ans = 0
    for i in range(1, (s//3)+1):
        k = s-3*i
        ans += com(k+i-1, i-1)
        #print(com(k+i,k),k+i,i)
    print(ans % (10**9+7))


if __name__ == '__main__':
    main()


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

using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;
 
#define SORT_ASC(c) sort((c).begin(), (c).end())
#define SORT_DESC(c) sort((c).begin(), (c).end(), greater<typeof((c).begin())>())
 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
 
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_LARGE = 1000000100;

template<typename T>
void vecprint(vector<T> v) {
    for(auto x : v) {
        cout << x << " ";
    }
    cout << endl;
}

template<typename T>
void pqprint(priority_queue<T> q) {
    while(!q.empty()) {
        cout << q.top() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void qprint(queue<T> q) {
    while(!q.empty()) {
        cout << q.front() << " ";
        q.pop();
    }
    cout << endl;
}

template<typename T>
void vecqprint(vector<queue<T>> v) {
    for(int i = 0; i < v.size(); i++) {
        qprint(v[i]);
    }
}

int main(void) {
    int n;
    cin >> n;
    
    priority_queue<double, vector<double>, greater<double>> q;
    REP(i, n) {
        double tmp;
        cin >> tmp;
        q.push(tmp);
    }
    
    double ans = q.top();
    q.pop();
    FOR(i, 1, n) {
        ans = (ans + q.top()) / 2.0;
        q.pop();
    }
    
    cout << ans << endl;
    
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    s = input()
    t = [0]*(n + 1)

    for i in range(n):
        if s[i: i + 2] == "AC":
            t[i + 1] = t[i] + 1
        else:
            t[i + 1] = t[i]
    
    for i in range(q):
        l, r = map(int, input().split())
        print(t[r - 1] - t[l - 1])

main()

Measured memory_bytes: 6356
N, D = map(int, input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    tmp = 0
    for k in range(D):
      tmp += abs(X[i][k]-X[j][k])**2
    tmp = tmp**0.5
    if tmp == int(tmp):
      ans += 1
print(ans)
   

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl

using namespace std;

const int mod=1e9+7;

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int n;
    cin>>n;
    vi a(n),b(n);
    int sa=0,sb=0;
    rep(i,n){
        cin>>a[i];
        sa+=a[i];
    }
    rep(i,n){
        cin>>b[i];
        sb+=b[i];
    }
    int k=sb-sa;
    int ta=0,tb=0;
    rep(i,n){
        if(a[i]>b[i])tb+=a[i]-b[i];
        else ta+=(b[i]-a[i]+1)/2;
    }
    cout<<(ta<=k&&tb<=k?"Yes":"No")<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>
#include <stdlib.h>
int main(void){
    int n,i,a[200000];
    long int sumx=0,sumtotal=0,dif,ans;
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&a[i]);
    };
    for(i=0;i<n;i++){
        sumtotal+=a[i];
    };
    //printf("sumtotal=%d\n",sumtotal);
    sumx=a[0];
    ans=dif=labs(sumtotal-sumx-sumx);
    //printf("dif=%d\n",dif);
    for(i=1;i<n-1;i++){
        sumx+=a[i];
        dif=labs(sumtotal-sumx-sumx);    
        //printf("dif=%d\n",dif);
        if(dif<ans){
            ans=dif;
        };
    };
    printf("%ld",ans);
    return 0;
};


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
int main()
{
    ll n;
    cin >> n;
    vector <ll> arr(n);
    ll sum=0;
    for(ll i=0;i<n;i+=1)
    {
        cin >> arr[i];
        sum+=arr[i];
    }
    sort(arr.begin(),arr.end());
    map <ll,ll> mp;
    for(ll i=0;i<n;i+=1)
    {
        mp[arr[i]]++;
    }
    ll q;

    cin >> q;
    for(ll i=0;i<q;i+=1)
    {
        ll b,c;
        cin >> b >> c;
        sum+=(c-b)*mp[b];
        mp[c]+=mp[b];
        mp[b]=0;
        cout << sum <<"\n";
    }

    

}


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

P operator+(P a, P b) {
	return P(a.first + b.first, a.second + b.second);
}
#ifndef MAX
#define MAX 400000
#endif
template<class T>
class RAQ_RMQ {
public:
	int n;
	T dat[MAX], lazy[MAX], ZERO, DEFAULT;
	bool(*cmp)(T, T);
	void init(int n_,
		bool(*c)(T, T) = [](int a, int b) {return a < b; }, T d = INT_MAX) {
		cmp = c;
		DEFAULT = d;
		ZERO = T();
		n = 1; while (n < n_)n <<= 1;
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = lazy[i] = ZERO;
			//if (i >= n - 1 + n_)dat[i] = DEFAULT;
		}
	}
	inline void push(int k) {
		if (lazy[k] == ZERO)return;
		dat[k] = dat[k] + lazy[k];
		if (k < n - 1) {
			lazy[k * 2 + 1] = lazy[k * 2 + 1] + lazy[k];
			lazy[k * 2 + 2] = lazy[k * 2 + 2] + lazy[k];
		}
		lazy[k] = ZERO;
	}
	inline void update_node(int k) {
		if (cmp(dat[k * 2 + 1], dat[k * 2 + 2]))dat[k] = dat[k * 2 + 1];
		else dat[k] = dat[k * 2 + 2];
	}
	inline void update(int a, int b, T x, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return;
		if (a <= l&&r <= b) {
			lazy[k] = lazy[k] + x; push(k); return;
		}
		update(a, b, x, k * 2 + 1, l, (l + r) / 2);
		update(a, b, x, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
	}
	inline T query(int a, int b, int k, int l, int r) {
		push(k);
		if (r <= a || b <= l)return DEFAULT;
		if (a <= l&&r <= b)return dat[k];
		T lb = query(a, b, k * 2 + 1, l, (l + r) / 2);
		T rb = query(a, b, k * 2 + 2, (l + r) / 2, r);
		update_node(k);
		if (cmp(lb, rb))return lb;
		return rb;
	}
	inline void update(int a, int b, T x) {
		update(a, b, x, 0, 0, n);
	}
	inline void update(int a, T x) {
		update(a, a + 1, x);
	}
	inline T query(int a, int b) {
		return query(a, b, 0, 0, n);
	}
	inline T query(int a) {
		return query(a, a + 1);
	}
};
RAQ_RMQ<P>seg;
int main() {
	int n, q; scanf("%d%d", &n, &q);
	seg.init(n, [](P a, P b) {return a.second < b.second; }, P(0, INT_MAX));
	rep(i, q) {
		int a; scanf("%d", &a);
		if (a == 0) {
			int s, t, x; scanf("%d%d%d", &s, &t, &x); s--;
			seg.update(s, t, P(0, x));
		}
		else {
			int s; scanf("%d", &s); s--;
			printf("%d\n", seg.query(s).second);
		}
	}
}

Measured memory_bytes: 9492
def main():
    n, *b = map(int, open(0).read().split())

    m = []
    for k in range(1, n + 1):
        for i in range(n - k, -1, -1):
            if b[i] == i + 1:
                b.pop(i)
                m.append(i + 1)
                break
        else:
            print(-1)
            exit()

    print('\n'.join(map(str, m[::-1])))


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char s[100010];
int n;
int main() {
	scanf("%s%n",s+1,&n);
	if(s[1]=='0'||s[n]=='1')
		return printf("-1"),0;
	for(int i=1; i<(n>>1); i++)
		if(s[i]!=s[n-i]) {
			printf("-1");
			return 0;
		}
	int x=1;
	for(int i=2;i<=n;i++){
		printf("%d %d\n",x,i);
		if(s[i-1]=='1')
			x=i;
	}
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define REP1(i,n) for(int i=1;i<=(int)(n);i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;

int main(){
  int x;
  int a;
  
  cin >> x;
  if(x>=400&&x<600)a=8;
  else if(x>=600&&x<800)a=7;
  else if(x>=800&&x<1000)a=6;
  else if(x>=1000&&x<1200)a=5;
  else if(x>=1200&&x<1400)a=4;
  else if(x>=1400&&x<1600)a=3;
  else if(x>=1600&&x<1800)a=2;
  else if(x>=1800&&x<2000)a=1;

  cout << a << endl;
}


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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
typedef priority_queue <ll> pq;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
const ll INF = (ll)1e18;
const ll MAXN = 1000006;

ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
   
    int T=1;
    //cin >> T;
    while(T--){
        int n;
        cin>>n;
        string s;
        cin>>s;
        int r=0, w=0;
        rep(i,n){
            (s[i]=='R')?r++:w++;
        }
        int z=0, j=n-1;
        while(w>0){
            if(s[j]=='R') z++;
            j--;
            w--;
        }

        cout<<z<<el;



    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}

Measured memory_bytes: 3960
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<vector<int>> adj;
vector<bool> visi;
int n, m;

int dfs(int node)
{
    int val = 0;
    for (int x : adj[node])
    {
        if (!visi[x])
        {
            visi[x] = true;
            val += dfs(x);
        }
    }
    return val + 1;
}

int main()
{
    cin >> n >> m;
    adj.resize(n);
    while (m--)
    {
        int x, y;
        cin >> x >> y;
        x--, y--;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }

    visi.resize(n, false);
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if (!visi[i])
        {
            visi[i] = true;
            ans = max(ans, dfs(i));
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 23488
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

set<string> s;
int n;
string str;

int main() {
	scanf( "%d", &n );
	for ( int i = 0; i < n; i++ ) {
		cin >> str;
		for ( int j = 0; j < str.size(); j++ ) {
			string s1 = str.substr( 0, j );
			string s2 = str.substr( j, str.size() - j );
			s.insert( s1 + s2 );
			s.insert( s2 + s1 );
			reverse( s1.begin(), s1.end() );
			s.insert( s1 + s2 );
			s.insert( s2 + s1 );
			reverse( s1.begin(), s1.end() );
			reverse( s2.begin(), s2.end() );
			s.insert( s1 + s2 );
			s.insert( s2 + s1 );
			reverse( s1.begin(), s1.end() );
			s.insert( s1 + s2 );
			s.insert( s2 + s1 );
		}
		printf( "%d\n", s.size() );
		s.clear();
	}
	return 0;
}

Measured memory_bytes: 1324
#include<stdio.h>
#include<cstdlib>

#define MAX 100

int main(){
  int i, j, n, m, a, b[MAX+1][MAX+1];

  
  scanf("%d", &n);

  for(i = 1; i < n+1; i++){
    for(j = 1; j < n+1; j++){
      b[i][j] = 0;
    }
  }
  for(i = 1; i <= n; i++){
    scanf("%d %d", &m, &m);
    for(j = 1; j <= m; j++){
      scanf("%d", &a);
      //printf("b[%d][%d]:1\n", i, a);
      b[i][a] = 1;
    }
  }

  
  for(i = 1; i < n+1; i++){
    for(j = 1; j < n; j++){
      printf("%d ", b[i][j]);
    }
    printf("%d\n", b[i][n]);
    }

  
  return 0;
}



Measured memory_bytes: 2728
import math
import itertools
import statistics
#import collections

#n =  list(map(int, input().split()))
s = int(input())

def calc_f(n):
    if n%2==0:
        return n/2
    else:
        return 3*n+1

count1 = 0

a = [s]
while count1<2:
    s = calc_f(s)
    a.append(s)
    if s==1:
        count1+=1
 
for i in range(len(a)):
    for j in range(i+1, len(a)):
        if a[i]==a[j]:
            print(j+1)
            exit()


Measured memory_bytes: 5656
#include <bits/stdc++.h> //全てのヘッダファイルをインクルード

//ループ
#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++) //最初の数値を指定したループ

//型名省略
typedef long long ll;
//配列要素数
static const int MAX = 200000;
//値
static const ll MX = 1e18;

using namespace std;

//#include "./lib/generic/sort.h"

/*std::tuple<int, int> swap(int num1, int num2){
     return std::forward_as_tuple(num1, num2);
}
void traceArray(int A[], int N){
    for(int i=0; i<N; i++){
        cout << A[i];
        if(i!=N-1){
            cout  << " ";
        }
    }
    cout << endl;
}*/

int main(){
    /*int  N;
    cin >> N;
    int  A[N];
    REP(i, N) cin >> A[i];*/
    //sort::Sort test;
    //test.sortByIntention(A, N);
    //test.sortByBubble(A, N);
    //test.sortBySelection(A, N);
    //traceArray(A, N);

    stack<int> S;
    string s;
    int a, b;

    while(cin >> s){ 
        if(s[0] == '+'){
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a+b);
        }
        else if(s[0] == '-'){
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(b-a);
        }
        else if(s[0] == '*'){
            a = S.top();
            S.pop();
            b = S.top();
            S.pop();
            S.push(a*b);
        }
        else if(cin.eof()){
            break;
        }
        else{
            S.push(atoi(s.c_str()));
        }
    }

    cout << S.top() << endl;
    return 0;
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long int;
using ull = unsigned long long int;
using P = pair<int, int>;
using P3 = pair<int,P>;
using PP = pair<P ,P>;
constexpr ll MOD = ll(1e9+7);
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e6) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll power(ll x, ll n){
    x %= MOD;
    ll res = 1;
    while(n > 0){
        if(n&1){
            res = res*x % MOD;
        }
        x = x*x %MOD;
        n >>= 1;
    }
    return res;
}

ll mod_inv(ll x){
    return power(x, MOD-2);
}

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    map<int,int> lcm;
    for(int i=0;i<n;i++){
        int t = a[i];
        for(int x=2;x*x<=t;x++){
            if(t%x == 0){
                int cnt = 0;
                while(t%x == 0){
                    cnt++;
                    t /= x;
                }
                lcm[x] = max(lcm[x], cnt);
            }
        }
        if(t != 1){
            lcm[t] = max(lcm[t], 1);
        }
    }
    ll L = 1;
    for(auto p : lcm){
        L = L*power(ll(p.first),ll(p.second))%MOD;
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        ll b = L;
        int t = a[i];
        for(int x=2;x*x<=t;x++){
            if(t%x == 0){
                int cnt = 0;
                while(t%x == 0){
                    cnt++;
                    t /= x;
                }
                b *= power(mod_inv(x),cnt);
                b %= MOD;
            }
        }
        if(t != 1){
            b *= mod_inv(t);
            b %= MOD;
        }
        ans += b;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N = 1e6 + 10;
const int INF = 0x3f3f3f3f;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const ll mod = 998244353;
int n, ck;
char s[N];
typedef pair<int, int>pii;
vector<pii>vc;
void cal() {
	int a = 0, b = INF;
	for (int i = 0; s[i]; i++) {
		if (s[i] == '(')a++;
		else a--;
		b = min(b, a);
	}
	if (b >= 0)ck += a;
	else vc.push_back(pii(a, b));
}
bool cmp(const pii& a, const pii& b) {
	if (a.first >= 0 || b.first >= 0) {
		if (a.first >= 0 && b.first >= 0)return a.second > b.second;
		else return a.first >= 0;
	}
	return a.first + b.second > b.first + a.second;
}
int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%s", s);
		cal();
	}
	sort(vc.begin(), vc.end(), cmp);
	for (pii p : vc) {
		if (ck + p.second < 0) { puts("No"); return 0; }
		ck += p.first;
	}
	puts(ck ? "No" : "Yes");
	return 0;
}

Measured memory_bytes: 7396
program test
implicit none

integer(8) :: n,a(200000),dummy(200000)=0,i,j,ans,k,ans1,ans2,ans3

read(*,*) n
do i=1,n
	read(*,*) a(i)
enddo

call heapsort_down(n,a(1:n),dummy(1:n))

if(n==2)then
	ans = abs(a(2)-a(1))
else if(n==3) then
	ans1 = abs(a(1)-a(2))+abs(a(2)-a(3))
	ans2 = abs(a(1)-a(3))+abs(a(3)-a(2))
	ans3 = abs(a(3)-a(1))+abs(a(1)-a(2))
	ans = max(ans1,ans2,ans3)
else if(mod(n,2)==0) then !偶数
	k = n/2
	ans = 2*sum(a(1:k-1)) + a(k) - a(k+1) -2*sum(a(k+2:n))
else !奇数
	k = (n-1)/2
	ans1 = 2*sum(a(1:k)) - a(k+1) - a(k+2) -2*sum(a(k+3:n))
	ans2 = 2*sum(a(1:k-1)) + a(k) + a(k+1) -2*sum(a(k+2:n))
	ans  = max(ans1,ans2)
endif

write(*,*) ans

contains
subroutine heapsort_down(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) > y1(j+1)) j = j+1
				endif
				
				if (t1 > y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_down
 
subroutine heapsort_up(n,y1,y2)
 
	implicit none
	integer(8),intent(in) :: n
	integer(8),intent(inout) :: y1(1:n)
	integer(8),intent(inout) :: y2(1:n)
	integer(8) :: i,k,j,l
	integer(8) :: t1,t2
	
	l = n/2+1
	k = n
 
	do while (k /= 1)
		 if(l > 1) then
				l = l-1
				t1 = y1(l)
				t2 = y2(l)
				
		 else
				t1 = y1(k)
				t2 = y2(k)
				y1(k) = y1(1)
				y2(k) = y2(1)
				k = k-1
				if(k == 1) then
					 y1(1) = t1
					 y2(1) = t2
					 exit
				endif
		 endif
 
		 i = l
		 j = l+l
 
		 do while(j <= k)
				if(j < k) then
					 if(y1(j) < y1(j+1)) j = j+1
				endif
				
				if (t1 < y1(j)) then
					 y1(i) = y1(j)
					 y2(i) = y2(j)
					 i = j
					 j = j+j
				else
					 j = k+1
				endif
		 
		 enddo
		 
		 y1(i) = t1
		 y2(i) = t2
	
	enddo
	return
 
end subroutine heapsort_up

end program

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

#define MaxN 100005
#define MOD 1000000007
#define INF 2140000000

using namespace std;

string S;
bool check(int len)
{
    int L=0,type=-1;
    for(int i=0;i<S.size();i++)
    {
        if(type!=S[i])
            L=1,type=S[i];
        else L++;
        if(i+1>=len&&len-L<=S.size()-i-1)
            return true;
    }
    L=0,type=-1;

    for(int i=S.size()-1;i>=0;i--)
    {
        if(type!=S[i])
            L=1,type=S[i];
        else L++;
        if(S.size()-i>=len&&len-L<=i)
            return true;
    }
    return false;
}
int main()
{
    cin>>S;
    int lw=1,hi=S.size(),last=1,mid;
    while(lw<=hi)
    {
        mid=(lw+hi)>>1;
        if(check(mid))
        {
            last=mid,lw=mid+1;
        }
        else hi=mid-1;
    }
    cout<<last;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define chmax(a,b) (a<b?(a=b,1):0)
#define chmin(a,b) (a>b?(a=b,1):0)
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
const int INF = 1<<29;
const double EPS= 1e-3;
typedef long long ll;
typedef pair<int,int> pii;

typedef vector<double> vec;
typedef vector<vec> mat;

ostream &operator<<(ostream &os, const vec &a) {
  FOR(it, a) os << setw(6) << *it << " ";
  return os;
}
ostream &operator<<(ostream &os, const mat &a) {
  FOR(it, a) os << *it << endl;
  return os;
}

bool GaussElimination(const mat &A, const vec &b, vec &res) {
  int n = A.size();
  mat B(n, vec(n+1));
  REP(i,n) REP(j,n)
    B[i][j] = A[i][j];
  REP(i, n) B[i][n] = b[i];
  
  int nowy = 0;
  REP(x, n) {
    int pivot = -1;
    for (int j=nowy; j<n; ++j)
      if (B[j][x]) {
        pivot = j;break;
      }
    if (pivot == -1) continue;
    swap(B[nowy], B[pivot]);

    for (int j=nowy+1; j<n; ++j) {
      double t = B[j][x] / B[nowy][x];
      for (int k=x; k<=n; ++k)
        B[j][k] = B[j][k] - B[nowy][k] * t;
    }
    nowy++;
  }
  res.clear();
  for (int y=nowy; y<n; ++y)
    if (B[y][n])                // rank(A) != rank(A|b)
      return 0;
  if (nowy != n) {              // rank(A) == rank(A|b) != n
    return 0;
  }
  // ティツァツ」テ」ツ?古、ツクツ?ヲツ?湘」ツ?ォテヲツアツコテ」ツ?セテ」ツつ凝」ツ?づヲツ卍ョテゥツ?堙」ツ?ォテ・ツセツ古ゥツ??、ツサツ」テ・ツ?・
  res.resize(n);
  for (int x=n-1; x>=0; --x) {
    double sum = B[x][n];
    for (int i=n-1; i>x; --i) {
      sum -= res[i] * B[x][i]; 
    }
    res[x] = sum / B[x][x];
  }
  return 1;
}

double v[10];
int d;

bool ok(const vec &a, int x) {
  double res = 0;
  REP(i,d+1) {
    res += a[i] * pow(x,d-i);
  }
  return abs(res-v[x]) < EPS;
}

bool check2(vector<int> &vs, int id, int ex) {
  mat A(d+1,vec(d+1));
  vec b(d+1);
  int ct = 0;
  REP(i,vs.size()) {
    if (i == id) continue;
    for (int j=0; j<=d; ++j) {
      A[ct][j] = pow(vs[i],d-j);
    }
    b[ct] = v[vs[i]];
    ct++;
  }
  vec res;
  if (GaussElimination(A,b,res)) {
    return ok(res,vs[id]) && !ok(res,ex);
  } else return 0;
}

bool check(int id) {
  vector<int> vs;
  REP(i,d+3) {
    if (id == i) continue;
    vs.push_back(i);
  }
  REP(j,vs.size()) {
    if (!check2(vs,j,id)) return 0;
  }
  return 1;
}

int main() {
  while(cin >> d, d) {
    REP(i,d+3) cin >> v[i];
    // REP(i,d+3) cout << v[i] << " "; cout << endl;
    int id = -1;
    REP(i,d+3) {
      if (check(i)) id = i;
    }
    cout << id << endl;
  }
}

Measured memory_bytes: 1320
import std.stdio, std.string, std.conv;

void main() {
	auto input = getStdin!(int[])()[0];
	int hours = input / 3600;
	int mod = input % 3600;
	int minutes = mod / 60;
	int seconds = mod % 60;
	writefln("%d:%d:%d", hours, minutes, seconds);
}

T getStdin(T)() {
    string[] cmd;
    string line;
    while ((line = chomp(stdin.readln())) != "") cmd ~= line;
    return to!(T)(cmd);
}

Measured memory_bytes: 2488
#include <stdio.h>

int main(void)
{
	int n[5];
	int t;
	int i, j;
	
	for (i = 0; i < 5; i++){
		scanf("%d", &n[i]);
	}
	for (i = 0; i < 5; i++){
		for (j = 0; j < 5; j++){
			if (n[i] > n[j]){
				t = n[i];
				n[i] = n[j];
				n[j] = t;
			}
		}
	}
	
	for (i = 0; i < 5; i++){
		printf("%d", n[i]);
		if (i != 4){
			printf(" ");
		}
	}
	printf("\n");
	
	return (0);
}

Measured memory_bytes: 600
def main():
    _ = int(input())
    A = list(map(int, input().split()))
    A.insert(0, 1e10)
    ans = []
    B = [0] * len(A)
    for i in range(len(A)-1, 0, -1):
        idx = i
        s = 0
        while idx <= len(A) - 1:
            s += B[idx]
            idx += i

        if s % 2 != A[i]:
            ans.append(i)
            B[i] = 1

    if len(ans) > 0:
        print(len(ans))
        print(*ans)
    else:
        print(0)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14096
//
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PI 3.14159265
#define EPS 1e-9
#define Pi acos(-1.0)
typedef pair<int, int> ii;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
#define forr(i,a,b) for(int i=(a); i<(b); i++)
#define clean(arr,val) memset(arr,val,sizeof(arr))
#define forn(i,n) forr(i,0,n)
#define PB push_back
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<pll> vpll;

/*CODE START HERE*/

string s;
int appear[30];
bool sol;

int main(){
    ios::sync_with_stdio(0);
    cin >> s;
    clean(appear,0);
    sol = true;
    forn(i,(int)s.size()){
        if(appear[s[i]-'a'] != 0){
            sol = false;
            break;
        }
        appear[s[i]-'a']++;
    }

    if(sol){
        cout << "yes\n";
    }else{
        cout << "no\n";
    }
    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        PrintWriter out = new PrintWriter(System.out);
        InputStreamScanner in = new InputStreamScanner(System.in);
        new Main().solve(in, out);
        out.flush();
    }

    private void solve(InputStreamScanner in, PrintWriter out) {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();

        out.println(Math.min(b/a, c));
    }

    static class InputStreamScanner {

        private InputStream in;

        private byte[] buf = new byte[1024];
        private int len = 0;
        private int off = 0;

        InputStreamScanner(InputStream in)	{
            this.in = in;
        }

        String next() {
            StringBuilder sb = new StringBuilder();
            for (int b = skip(); !isSpace(b);){
                sb.appendCodePoint(b);
                b = read();
            }
            return sb.toString();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        char nextChar() {
            return (char)skip();
        }

        int skip() {
            for (int b; (b = read()) != -1;) {
                if (!isSpace(b)) {
                    return b;
                }
            }
            return -1;
        }

        private boolean isSpace(int c) {
            return c < 33 || c > 126;
        }

        private int read() {
            if (len == -1) {
                throw new InputMismatchException("End of Input");
            }
            if (off >= len){
                off = 0;
                try {
                    len = in.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException(e.getMessage());
                }
                if (len <= 0) {
                    return -1;
                }
            }
            return buf[off++];
        }
    }
}

Measured memory_bytes: 22484
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

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

    std::vector<int> counter(n + 1, 0);

    int ac_count = 0;
    int wa_count = 0;

    for (int i = 0; i < m; i++)
    {
        int p;
        string state;
        cin >> p >> state;

        if (state == "AC")
        {
            if (counter[p] != -1)
            {
                wa_count += counter[p];
                ac_count++;
                counter[p] = -1;
            }
        }
        else
        {
            if (counter[p] != -1)
            {
                counter[p]++;
            }
        }
    }
    cout << ac_count << " " << wa_count << endl;
}

Measured memory_bytes: 640