akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
int main()
{	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
		ll n; cin>>n;
		if(n&1) cout<<"0"<<endl;
		else{
			ll ans=0,c=10;
			while(c<=n)
			{
				 ans=ans+(n/c);
				 c=c*5;
			}
			cout<<ans<<endl;
		}
	return 0;
}

Measured memory_bytes: 3672
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;
typedef int keytype;

int gcd(int a, int b){ return (a % b) ? gcd(b, a % b) : b;}
int lcm(int a, int b){ return (a / gcd(a, b)) * b;}

/* a[0], ..., a[n-1] の数の最大公約数 */
int ngcd(int n, int a[])
{
    int i, d;

    d = a[0];
    for (i = 1; i < n && d != 1; i++)
        d = gcd(a[i], d);
    return d;
}

void quicksort(keytype a[], int first, int last)
{
    int i, j;
    keytype x, t;

    x = a[(first + last) / 2];
    i = first;  j = last;
    for ( ; ; ) {
        while (a[i] < x) i++;
        while (x < a[j]) j--;
        if (i >= j) break;
        t = a[i];  a[i] = a[j];  a[j] = t;
        i++;  j--;
    }
    if (first  < i - 1) quicksort(a, first , i - 1);
    if (j + 1 < last) quicksort(a, j + 1, last);
}

int is_prime(int x){
    if(x <= 1) return 0;
    for(int i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}

int is_substr(char s[], char t[], int i){
    int flag = 1;

    if(s[i] == '\0') flag = 0;

    for(int j = 0; j < strlen(t); ++j, ++i){
        if(s[i] != t[j]){
            flag = 0;
            break;
        }
    }
    return flag;
}

// factor list, number of factors, natural number
void factorize(int ftr[], int *num, int n){
    int a = 2, cnt = 0;

    while(n >= a){
        if(n % a == 0){
            n = n / a;
            ftr[cnt++] = a;
        }else{
            a++;
        }
    }
    *num = cnt;
}

//#define N 5
//int p[N + 1];
int nextperm(int p[], int N)  /* 辞書式順序で次の順列 */
{
    int i, j, t;

    i = N - 1;
    p[0] = 0;  /* 番人 */
    while (p[i] >= p[i + 1]) i--;
    if (i == 0) return 0;  /* 完了 */
    j = N;
    while (p[i] >= p[j]) j--;
    t = p[i];  p[i] = p[j];  p[j] = t;
    i++;  j = N;
    while (i < j) {
        t = p[i];  p[i] = p[j];  p[j] = t;  i++;  j--;
    }
    return 1;  /* 未了 */
}

void comb(int size1, int size2, int v[size1][size2]){
  for(int i = 0; i < size1; i++){
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for(int k = 1; k < size1; k++){
    for(int j = 1; j < k; j++){
      v[k][j] = (v[k-1][j-1] + v[k-1][j]);
    }
  }
}

int abs_val(int a, int b){
    if(a > b) return a - b;
    else return b - a;
}

const int inf = 1012345678;
int main(){
    int p[5];
    int index[6] = {0, 1, 2, 3, 4, 5};
    int k;

    scanf("%d %d %d %d %d %d", &p[0], &p[1], &p[2], &p[3], &p[4], &k);

    for(int i = 0; i < 5; ++i){
        for(int j = i + 1; j < 5; ++j){
            if((p[j] - p[i]) > k){
                puts(":(");
                return 0;
            }
        }
    }

    puts("Yay!");

    return 0;
}


Measured memory_bytes: 1632
#include <bits/stdc++.h>
using namespace std;
long long n , c , k , t[200000] , pos , ans , isi;
int main(){
	cin >> n >> c >> k;
	for(int i = 1 ; i <= n ; i++){
		cin >> t[i];
	}
	sort(t + 1 , t + n + 1);
	pos = 0;
	isi = c;
	for(int i = 1 ; i <= n ; i++){
		if(isi == 0 || t[i] > pos){
			ans++;
			isi = c - 1;
			pos = t[i] + k;
		}
		else {
			isi--;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4308
import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
       PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
        // int n = Integer.parseInt(bf.readLine());
        StringTokenizer st = new StringTokenizer(bf.readLine());
        int a =  Integer.parseInt(st.nextToken());
        int b =  Integer.parseInt(st.nextToken());
        int c =  Integer.parseInt(st.nextToken());
        int min = Integer.MAX_VALUE;
        for(int i=-2; i<=52; i++) {
          int ans = 0;
          if(a >= i) ans += (a-i);
          else {
            if((i-a) % 2 == 0) ans += (i-a)/2;
            else ans += (i-a)/2 + 2;
          }

          if(b >= i) ans += (b-i);
          else {
            if((i-b) % 2 == 0) ans += (i-b)/2;
            else ans += (i-b)/2 + 2;
          }

          if(c >= i) ans += (c-i);
          else {
            if((i-c) % 2 == 0) ans += (i-c)/2;
            else ans += (i-c)/2 + 2;
          }
          if(ans < min) min = ans;
        }
        out.println(min);
        // int[] a = new int[n];
        // for(int i=0; i<n; i++) a[i] =  Integer.parseInt(st.nextToken());

        out.close(); System.exit(0);
    }


}


Measured memory_bytes: 21332
import java.util.*;

public class Main {
	private int[] mt = new int[10];

	public static void main(String[] args) {
		new Main().run();
	}
	
	private void run() {
		Scanner scan = new Scanner(System.in);
		for (int i = 0; i < 10; i++) {
			mt[i] = scan.nextInt();
		}
		Arrays.sort(mt);
		for (int i = 9; i > 6; i--) {
			System.out.println(mt[i]);
		}
	}
}

Measured memory_bytes: 17332
<?php
class Scanner {
    private $arr = [];
    private $count = 0;
    private $pointer = 0;
    public function next() {
        if($this->pointer >= $this->count) {
            $str = trim(fgets(STDIN));
            $this->arr = explode(' ', $str);
            $this->count = count($this->arr);
            $this->pointer = 0;
        }
        $result = $this->arr[$this->pointer];
        $this->pointer++;
        return $result;
    }
    public function hasNext() {
        return $this->pointer < $this->count;
    }
    public function nextInt() {
        return (int)$this->next();
    }
    public function nextDouble() {
        return (double)$this->next();
    }
}

$sc = new Scanner();

$s = $sc->next();
$count = 0;

for ($i=0; $i < strlen($s) / 2; $i++) { 
    if($s[$i] != $s[strlen($s) - ($i + 1)])
    {
        $count++;
    }
}

echo $count . "\n";


Measured memory_bytes: 4604
#include <iostream>
#include <algorithm>

using namespace std;

int a[2005];
int n;

#define TRI_VALID(a,b,c) ((a) < (b) + (c) && (b) < (c) + (a) && (c) < (a) + (b))

//constexpr bool triangle_valid(int a, int b, int c)
//{
//	return a < b + c && b < c + a && c < a + b;
//}

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	sort(a, a + n);
	int count = 0;
	for (int i = 0; i < n - 2; i++)
	{
		for (int j = i + 1; j < n - 1; j++)
		{
			for (int k = j + 1; k < n && a[k] < a[i] + a[j]; k++)
			{
				TRI_VALID(a[i],a[j],a[k]) && count++;
			}
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#define int long long
#define ll getchar();getchar();return 0;
	using namespace std;
	int a[114];
	signed main() {
		int n,cnt=0;
		cin >> n;
		for (int i = 0; i < n; i++)cin >> a[i];
		sort(a, a + n);
		for (int i = 0; i < n; i++) {
			cnt++;
			if (i<n-1&&a[i] == a[i + 1])cnt--;
		}
		cout << cnt << endl;
		ll
	}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
int main(){
    ll x,d,k;cin >> x >> k >>d;
    x=abs(x);
    ll t=x/d;
    if(x/k>=d)cout << x-d*k <<endl;
    else{
        ll t=x/d;ll f=x-t*d;
        ll r=x-(t+1)*d;
        //cout << f <<" " << r <<endl;
        if((k-t)%2==0)cout << f <<endl;
        else cout << -r <<endl;
    }
}

Measured memory_bytes: 3640
#include <stdio.h>
#include <iostream>
using namespace std ; 
int main ( ) 
{ 
	long long  a,b,x;
	cin>>a>>b>>x;
	if(a%x==0){
		cout<<((b/x)-((a)/x))+1 ;
	}
	else

cout<<(b/x)- ((a)/x) ;
	 
	return 0 ; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n, l, sum =0;
    cin >> n >> l;
    for(int i = l; i <= l+n-1; ++i ){
        sum += i;
    }
    if(l<=0 && sum >=0){
        cout << sum;
    }
    else if(l <= 0 && sum< 0){
        cout << sum - (l+n-1);
    }
    else{
        cout << sum-l;
    }
    return 0 ;
}

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end



int main(){
   int n; cin>>n;
   ll res=0;
   rep(i,0,n)res+=1LL*(i+1)*(n-i);
   rep(_,0,n-1){
      int lb,rb; cin>>lb>>rb; lb--; rb--;
      if(lb>rb)swap(lb,rb);
      res-=1LL*(lb+1)*(n-rb);
   }
   cout<<res<<endl;
   return 0;
}

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

int main(){
	int x, y;
	cin>>x>>y;
	if(x==y){
		cout<<"Yes";
	}else if(((x==1)or(x==3)or(x==5)or(x==7)or(x==8)or(x==10)or(x==12))and((y==1)or(y==3)or(y==5)or(y==7)or(y==8)or(y==10)or(y==12))){
		cout<<"Yes";
	}else if(((x==4)or(x==6)or(x==9)or(x==11))and((y==4)or(y==6)or(y==9)or(y==11))){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

long long gcd(long long a, long long b){ // Ååöñ
    if(a == 0 || b == 0)
        return 0;
    if(b > a)
        swap(a, b);
    long long tmp;
    while((tmp = a % b) != 0){
        a = b;
        b = tmp;
    }
    return b;
}

int main()
{
    for(;;){
        int p, n;
        cin >> p >> n;
        if(p == 0)
            return 0;

        int u = 0;
        int v = 1;
        int x = INT_MAX/2;
        int y = 1;

        for(int i=1; i<=n; ++i){ // ªê
            int j = i * sqrt(double(p)); // ªq
            if(j > n)
                break;
            if(gcd(i,j) == 1 && i*u < j*v){
                u = j;
                v = i;
            }

            ++ j;
            if(j > n)
                break;
            if(gcd(i, j) == 1 && i*x > j*y){
                x = j;
                y = i;
            }
        }
        cout << x << '/' << y << ' ' << u << '/' << v << endl;
    }
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	char str[105];
	scanf("%s",str);
	int l=strlen(str);
	for(int i=0;i<l;i++)
	if(str[i]!=',')
	printf("%c",str[i]);
	else printf(" ");
}

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

//#define int long long
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define rept(i,n) rep(i,(n)+1)
#define repst(i,s,n) reps(i,s,(n)+1)
#define reprt(i,n,t) for(int (i)=(n);(i)>=(t);--(i))
#define repr(i,n) reprt(i,n,0)
#define each(itr,v) for(auto &(itr):(v))
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define tmax(x,y,z) max(x,max(y,z))
#define tmin(x,y,z) min(x,min(y,z))
#define chmin(x,y) if(x>y)x=y
#define chmax(x,y) if(x<y)x=y
#define log2(x) (log(x)/log(2))
#define ln '\n'
#define bln(i,n) ((i==n-1)?'\n':' ')
#define dbg(x) cout<<#x" = "<<(x)<<ln
#define dbga(x,n) {cout<<#x" : ";for(int (i)=0;i<(n);++i){cout<<((x)[i])<<(i==((n)-1)?'\n':' ');}}

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vst;
typedef vector<bool> vb;
typedef vector<ld> vld;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vector<int> > mat;

const ll inf = (ll)1e9+10;
const ll linf = (ll)1e18+10;
const ll mod = (ll)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

ll mop(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b) {return a*b/gcd(a,b);}

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

string s;

signed main() {
	cin >> s;
	sort(all(s));
	cout << (s=="abc" ? "Yes" : "No") << ln;
}

Measured memory_bytes: 256
n, m, x = map(int, input().split())
c = [0] * n
a = [[] for _ in range(n)]
for i in range(n):
    c[i], *a[i] = map(int, input().split())

ans = float(('inf'))
for s in range(1 << n):
    money = 0
    understand = [0] * m
    for i in range(n):
        if (1 << i) & s != 0:
            money += c[i]
            for j in range(m):
                understand[j] += a[i][j]
    if min(understand) >= x:
        ans = min(ans, money)

if ans == float('inf'):
    print(-1)
else:
    print(ans)

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

#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(void)
{
    int n,x,t,ans;

    cin >> n >> x >> t;

    if(n%x == 0){
        ans = n/x*t;
    }else{
        ans = (n/x+1)*t;
    }

    

    cout << ans << endl;

}

Measured memory_bytes: 3632
from collections import defaultdict as dd
from collections import Counter
from pprint import pprint as pp

YN = {True: 'Yes', False: 'No'}
ri = lambda: int(input())
ria = lambda: list(map(int, input().split()))
rian = lambda n: [ria() for _ in range(n)]
rs = lambda: input()
rsa = lambda: input().split()
rsn = lambda n: [rs() for _ in range(n)]

A, B, C = ria()

umai = 0
if C <= B:
  umai = C+B
else:
  umai = B*2
  C -= B
  if C <= A:
    umai += C
  else:
    umai += A+1

print(umai)

Measured memory_bytes: 3572
import sys
input = sys.stdin.readline
n, t = map(int, input().split())
shop = []
shop_0 = []
for i in range(n):
    a, b = map(int, input().split())
    if a == 0:
        shop_0.append((a, b))
        n -= 1
    else:
        shop.append((a, b))
shop.sort(key = lambda x: (x[0])/(1+x[1]), reverse = True)
shop_0.sort()

inf = 10**18
dp = [[inf for i in range(30)] for j in range(n+1)]
dp[0][0] = 0
for i in range(n):
    for j in range(29):
        dp[i+1][j] = min(dp[i][j], dp[i+1][j])
        dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (dp[i][j]+1)*(shop[i][0])+shop[i][1]+1)



ans = 0
for i in range(30):
    tmp = i
    T = dp[n][i]
    if T > t:
        continue
    else:
        for j in range(len(shop_0)):
            if T+shop_0[j][1]+1 <= t:
                T += shop_0[j][1]+1
                tmp += 1
            else:
                break
    ans = max(tmp, ans)

print(ans)


Measured memory_bytes: 132316
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+10;
ll a[maxn],b[maxn];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	ll sum=0;
	for(int i=1;i<n;i++){
		if(i&1)sum-=a[i];
		else sum+=a[i];
	}
	sum=a[n]-sum;
	b[1]=sum;
	for(int i=2;i<=n;i++){
		b[i]=a[i-1]-b[i-1]/2;
		b[i]*=2;
	}
	for(int i=1;i<=n;i++)printf("%lld ",b[i]);
}

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

using namespace std;

#define MAX_SIZE 1000

// true:1 false:0
static bool s[MAX_SIZE][MAX_SIZE];

int main(){

  // 初期化
  for (int i = 0; i < MAX_SIZE; i++){
    for (int j = 0; j < MAX_SIZE; j++){
      s[i][j] = false;
    }
  }
  
  int h, w, a, b;
  cin >> h >> w >> a >> b;
  cin.ignore();

  for (int i = 0; i < b; i++){
    for(int j = 0; j < a; j++){
      cout << "1" << flush;
    }
    for(int j = a; j < w; j++){
      cout << "0" << flush;
    }
    cout << endl;
  }
  for (int i = b; i < h; i++){
    for(int j = 0; j < a; j++){
      cout << "0" << flush;
    }
    for(int j = a; j < w; j++){
      cout << "1" << flush;
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using Point = pair<int,int>;

int main()
{
    int N,K;
    cin >> N >> K;
    
    vector<long long> h(N);
    for(int i=0;i<N;i++)
    {
        cin >> h[i];
    }
    
    long long ans = LONG_LONG_MAX;
    for(int bit = 0;bit < (1<<N);bit++)
    {
        vector<int> used;
        for(int i=0;i<N;i++)
        {
            if(bit & (1 << i))
            {
                used.push_back(i);
            }
        }
        if(used.size() < K)
        {
            continue;
        }
        
        long long temp = 0;
        vector<long long> a(N);
        a=h;
        for(int i = 0;i<used.size();i++)
        {
            for(int j = 0;j<used[i];j++)
            {
                long long k =a[j]-a[used[i]] + 1;
                if(k>0)
                {
                    a[used[i]] += k;
                    temp += k;
                }
            }
        }
        ans = min(temp,ans);
    }
    
    cout << ans << endl;
    
    return 0;
}

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

int main(){
    int n, r;
    cin >> n >> r;
    if(n < 10){
        r += 1000 - 100 * n;
    }
    cout << r << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cstdio>

using namespace std;

int main(void){

  int n;
  cin >> n;

  while(n--){

    double x1,x2,x3;
    double y1,y2,y3;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

    double A1 = 2*(x2 - x1);
    double B1 = 2*(y2 - y1);
    double C1 = pow( x1 , 2 ) - pow( x2 , 2 ) + pow( y1 , 2 ) - pow( y2 , 2);
    double A2 = 2*(x3 - x1);
    double B2 = 2*(y3 - y1);
    double C2 = pow( x1 , 2 ) - pow( x3 , 2 ) + pow( y1 , 2 ) - pow( y3 , 2);
    double x = ( B1*C2 - B2*C1 ) / ( A1*B2 - A2*B1 );
    double y = ( C1*A2 - C2*A1 ) / ( A1*B2 - A2*B1 );
  
  double R = pow( (x - x1) , 2 ) + pow( (y - y1 ) , 2 );
  printf("%.3f %.3f %.3f", x, y, sqrt(R));
  cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,a[102][102],ans=-1e9;
int main(){
    cin>>n;
    r(i,n)r(j,n)cin>>a[i+1][j+1];n++;
    r(i,n)r(j,n-1)a[i][j+1]+=a[i][j];
    r(j,n)r(i,n-1)a[i+1][j]+=a[i][j];
    r(i,n)r(j,n){
        for(int k=i+1;k<n;k++){
            for(int l=j+1;l<n;l++){
                ans=max(ans,a[k][l]-a[i][l]-a[k][j]+a[i][j]);
            }
        }
    }
    cout<<ans<<endl;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set
#define pll pair<ll, ll>
#define vll vector<ll>
#define mll map<ll, ll>

using namespace std;

const ll MOD = 1000000007LL;
const ll INF = (1LL << 60LL);

class Permutation {
  ll *_array;
  ll _length;
  bool _finished;

 public:
  Permutation(ll *array, ll length) {
    _array = array;
    _length = length;
    _finished = false;
  }

  void next() {
    if (_finished) {
      return;
    }
    if (!next_permutation(_array, _array + _length)) {
      _finished = true;
    }
  }

  ll data(ll index) { return _array[index]; }

  void print() {
    for (ll i = 0; i < _length; i++) {
      cout << _array[i];
    }
    cout << endl;
  }

  bool finished() { return _finished; }
};

int main() {
  std::cout << std::fixed << std::setprecision(10);

  ll N;
  scanf("%lld", &N);

  vector<pair<ll, ll>> list;
  for (ll i = 0; i < N; i++) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    list.emplace_back(make_pair(a, b));
  }

  vector<ll> v;
  for (ll i = 0; i < N; i++) {
    v.emplace_back(i);
  }

  ll count = 0;
  double sum = 0;

  auto perm = Permutation(v.data(), v.size());
  while (!perm.finished()) {
    // perm.print();
    double this_sum = 0;
    pll current;
    current.first = list[perm.data(0)].first;
    current.second = list[perm.data(0)].second;
    for (ll i = 1; i < N; i++) {
      ll next_index = perm.data(i);
      pll next = list[next_index];

      ll dx = (next.first - current.first);
      ll dy = (next.second - current.second);

      double plus = pow(dx * dx + dy * dy, 0.5);

      this_sum += plus;

      current = next;
    }
    // cout << "this_sum:" << this_sum << endl;
    sum += this_sum;

    count++;
    perm.next();
  }

  double ans = sum / count;
  cout << ans << endl;
}


Measured memory_bytes: 4228
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <iomanip>

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)
#define SHOWP(x) cerr<<"("<<(x).FI<<", "<<(x).SE<<")"<<endl;
#define SHOWX(x) cerr<<#x<<": "<<x<<endl;
#define SHOWVEC(v, e) REP(i, e) cerr << (v[i]) << ' '; cerr << endl;
#define SHOW2D(a, h, w) REP(i, h){REP(j, w)cerr<<setw(3)<<(a[i][j])<<' ';cerr<<endl;}

typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
  ll N; cin >> N;

  ll bsum = 0;
  vector<ll> v;
  REP(i, N) {
    ll A, B;
    cin >> A >> B;
    bsum += B;
    v.PB(A + B);
  }
  sort(ALL(v), greater<ll>());

  ll sum = 0;
  REP(i, N) {
    if (i % 2 == 0) sum += v[i];
  }
  cout << (sum - bsum) << endl;

  return 0;
}

Measured memory_bytes: 1400
#include <stdio.h>

int main(void) {
	int N;
	int X;
	int i;
	int k = 100000;
	
	scanf("%d %d",&N,&X);
	
	int m[N];
	
	for(i = 0; i < N; i++) {
		
		scanf("%d",&m[i]);
		
		X = X - m[i];
		
		
		if(m[i] < k) {
			
			k = m[i];
			
		}
	}
	
	printf("%d",X / k + N);
	
	return 0;
}

Measured memory_bytes: 128
a1,a2,a3,b = Array.new
a1 = gets.chomp.split(' ').map(&:to_i)
a2 = gets.chomp.split(' ').map(&:to_i)
a3 = gets.chomp.split(' ').map(&:to_i)
n =  gets.chomp.to_i

n.times do
 num = gets.chomp.to_i
 if a1.index(num) != nil
   a1[a1.index(num)] = -1
 end
 if a2.index(num) != nil
   a2[a2.index(num)] = -1
 end
 if a3.index(num) != nil
 a3[a3.index(num)] = -1
 end
end
if a1 == [-1,-1,-1] || a2 == [-1,-1,-1] || a3 == [-1,-1,-1] || (a1[0] == a2[0] && a2[0] == a3[0]) || (a1[1] == a2[1] && a2[1] == a3[1]) || (a1[2] == a2[2] && a2[2] == a3[2]) ||( a1[0] == a2[1] && a2[1] == a3[2] )||(a1[2] == a2[1] && a2[1]== a3[0])
  puts "Yes"
else
  puts "No"
end

Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll N,K;
    cin >>N>>K;
    vector<ll>D(10);
    rep(i,K){
        ll d;
        cin>>d;
        D[d]=1;
    }
    rep3(i,N,234567){
        ll num=i;
        while(1){
            ll n=num%10;
            if(D[n])break;
            num/=10;
            if(num==0){
                cout<<i<<endl;
                return 0;
            }
        }
    }
    
   


    return 0;
    

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int c[30005][10];
int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=0;
    map<int,int> san;
    map<int,int> ni;
    map<char,int> ichi;
    for(int i=0;i<n-2;i++){
        if(ichi[s[i]]==0){
            ichi[s[i]]++;
            for(int j=i+1;j<n-1;j++){
                if(ni[(s[i]-'0')*10+(s[j]-'0')]==0){
                    ni[(s[i]-'0')*10+(s[j]-'0')]++;
                    for(int k=j+1;k<n;k++){
                        if(san[(s[i]-'0')*100+(s[j]-'0')*10+(s[k]-'0')]==0){
                            ans++;
                            san[(s[i]-'0')*100+(s[j]-'0')*10+(s[k]-'0')]++;
                        }
                    }
                }
            }
        }
    }
    cout << ans;
}

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

using namespace std;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVS vector<vector<string>>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)
typedef long long ll;
const int  INF = 2147483647;
const ll INFL = 9223372036854775807;
const ll mod = 1000000007;




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



	if (n==3||n==5||n==7)cout << "YES" << endl;
	else cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++){
    cin>>h[i];
  }
  int ans=0;
  int active=0;
  for(int i=0;i<n;i++){
    if(h[i]>active){
      ans+=h[i]-active;
      active=h[i];
    }
    else {
      active=h[i];
    }
  }
  cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,ans;
  ans =0;
  string s;
  cin >> n >> s;
  for (int i = 0;i<=n-3;i++) {
    if ((s.at(i)=='A'&&s.at(i+1)=='B')&&s.at(i+2)=='C') ans++;
  };
  cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)

{

   int a,b;

   scanf("%d %d",&a,&b);

   if(a==b){

      printf("a == b\n");

   }

     else{

      if(a<b){

         printf("a < b\n");

      }

      else{

         printf("a > b\n");

      }


     }

   return 0;

}

Measured memory_bytes: 580
#include<stdio.h>
int main()
{
	int n,a,b,c,d;
	scanf("%d",&n);
	a=n/1000;
	b=n/100%10;
	c=n/10%10;
	d=n%10;
	if(a==b&&c==b||b==c&&c==d||a==b&&b==c&&c==d)
		printf("Yes\n");
	else
		printf("No\n");
}

Measured memory_bytes: 128
def abc138d_ki():
    import heapq
    n, q = map(int, input().split())
    cnt = [0] * n
    graph = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(int, input().split())
        graph[a - 1].append(b - 1)
        graph[b - 1].append(a - 1)
    for _ in range(q):
        p, x = map(int, input().split())
        cnt[p - 1] += x
    qu = [(0, 0)]
    heapq.heapify(qu)
    check = [False] * n
    while len(qu) != 0:
        h, no = heapq.heappop(qu)
        check[no] = True
        for nxt in graph[no]:
            if not check[nxt]:
                cnt[nxt] += cnt[no]
                heapq.heappush(qu, (h + 1, nxt))
    for c in cnt:
        print(c, end=' ')


abc138d_ki()

Measured memory_bytes: 62656
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor
int main(){
    llong N,X,T;
    cin >> N >> X >> T;
    cout << int(ceil((double)N/(double)X)*T) <<endl;
    return 0;
}

//数値から文字列に変換
string num2string(llong num){
    ostringstream oss;
    oss << num;

    return oss.str();
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;

int main(void){
  ll n;
  string s;
  cin >> n >> s;
  
  ll ans = 0;
  ll x = 0;
  for (int i = 0; i < n; i++){
    if (s[i] == 'I')
      x++;
    else
      x--;

    ans = max(ans, x);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3516
# solution
import io
import math
import heapq
import bisect

MOD = 10**9+7

N = int(input())
array = list(map(int, input().split()))
array.sort()

result = 0
for a in range(N-2):
    for b in range(a+1,N-1):
        c = bisect.bisect_left(array,array[a]+array[b])
        result += c-b-1
            
print(result)

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

using namespace std;

const int MAXK = 1e5 + 10;
const int MOD = 1e9 + 7;

int pref[MAXK],dp[MAXK],N,K;

int main(){
	cin >> N >> K;
	dp[0] = 1;
	for(int kid = 1;kid<=N;kid++){
		int c;
		cin >> c;
		pref[0] = dp[0];
		dp[0] = 0;
		for(int i = 1;i<=K;i++){
			pref[i] = (pref[i-1] + dp[i]) % MOD;
		}
		for(int i = 0;i<=K;i++){
			dp[i] = (pref[i] - (i-c>=0 ? pref[i-c-1] : 0)) % MOD;
		}
	}

	int ans = dp[K];
	if(ans < 0) ans += MOD; 
	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
	int N, X;
	cin >> N >> X;
	int L[100];
	int sum = 0;
	int ans = 1;
	for (int i = 0; i < N; i++) {
		cin >> L[i];
	}
	for (int i = 0; i < N; i++) {
		sum += L[i];
		if (sum > X) break;
		else ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int prime[1300001];

void isprime(void){
	int i,j,n,c;
	
	for(i = 4;i<1300001;i += 2)prime[i] = 1;
	
	for (i = 3;i * i <= 1300001;i += 2){
		if (prime[i] == 0){
			for (j = i + i; j <= 1300001; j += i){
				prime[j] = 1;
			}
		}
	}
}

int main(void){
	int n,i,a=0;
	int flag,p,j,k;
	isprime();
	while (scanf("%d%d",&n,&p),n!=-1&&p!=-1){
		a=0;
		flag=0;
		for(i = (n+1)*2;;i++){
			for(j = n+1;j < i;j++){
				for(k = j;j+k <= i;k++){
					if(j+k == i){
						if(prime[j]==0&&prime[k]==0){
							a++;
							if(a==p){
								printf("%d\n",i);
								flag=1;
								break;
							}
						}
					}
					if(flag)break;
				}
				if(flag)break;
			}
			if(flag)break;
		}
	}
	return 0;
}

Measured memory_bytes: 6100
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
b_dic = {}
for i in range(1, N + 1):
  b_dic[i] = B[i - 1]
c_dic = {}
for i in range(1, N):
  c_dic[i] = C[i - 1]
count=0
br = -1
for a in A:
  count += b_dic[a]
  if br == a - 1:
    count += c_dic[br]
  br = a
print(count)


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	for (int i = s.size()-2; i >= 2; i -= 2)
	{
		string a = s.substr(0, i/2);
		string b = s.substr(i/2, i/2);
		if (a == b)
		{
			cout << i << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long LL; 

const LL mod=(LL)1e9+7,N=(LL)1e5;

LL fac[2*N+5]={1};

LL exgcd(LL a,LL b,LL &x,LL &y)
{
	if(!b)
	{
		x=1; y=0;
		return a;
	}
	LL gcd=exgcd(b,a%b,x,y);
	LL tmp=x;
	x=y;
	y=tmp-(a/b)*y;
	return gcd;
}

LL C(LL n,LL m)
{
	LL x,y;
	exgcd( fac[m]*fac[n-m]%mod ,mod,x,y);
	return fac[n]*(x+mod)%mod;
}

int main()
{
	for(int i=1;i<=2*N;i++)
		fac[i]=(fac[i-1]*i)%mod;
	
	LL w,h,a,b;
	scanf("%lld %lld %lld %lld",&h,&w,&a,&b);
	
	LL ans=0;
	for(LL i=b+1;i<=w;i++)
		ans=(ans+(C(h-a+i-2,h-a-1)%mod)*(C(w-i+a-1,w-i)%mod))%mod;
	
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1664
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>
#include <numeric>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)

typedef long long ll;

int main() {
    
    int N, sum;
    vector<int> s;
    
    cin >> N;
    
    for (int i = 0; i < N; i++) {
        int num;
        cin >> num;
        s.push_back(num);
    }
    sort(s.begin(), s.end());
    sum = accumulate(&s[0], &s[N], 0);

    if (sum % 10 == 0) {
        for (int i = 0; i < s.size(); i++) {
            if (s.at(i) % 10 != 0) {
                sum -= s.at(i);
            }
            if (sum % 10 != 0) break;
        }
        if (sum % 10 == 0) sum = 0;
    }

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

Measured memory_bytes: 256
def convert_adjacency_list_to_matrices():
    n = int(input())
    for _ in range(n):
        _, _, *v = map(int, input().split())
        s = set(v)
        ans = list(map(str, [int(i in s) for i in range(1, n+1)]))
        print(" ".join(ans))

if __name__ == "__main__":
    convert_adjacency_list_to_matrices()


Measured memory_bytes: 5608
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int R, G, B, N;

void MAIN() {
    scanf("%d%d%d%d", &R, &G, &B, &N);

    int ans = 0;
    REP (r, N+1) REP (g, N+1) {
	LL cur = R * r + G * g;
	if (cur <= N && (N - cur) % B == 0) ans++;
    }
    printf("%d\n", ans);

}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(void) {
	int n,q,b,e,com;
	vector<int> newB = {};
	int a[1000]; 
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
	}
	cin >> q;
	
	for(int j = 0 ; j < q;j++)
	{   
	    newB = {};
	    //b == c, e == d
		cin >> com >> b >> e;
		for(int k = b;k < e;k++)
		{
		    newB.push_back(a[k]);
		}
		
		switch(com)
		{   
		    case 0:
			    cout<< *min_element(a + b,a + e) <<endl;
			    break;
			
			case 1:
			    cout << *max_element(a + b,a + e) <<endl;
			    break;
		}
	}

}


Measured memory_bytes: 3160
#include <stdio.h>

int main( void )
{
	int i, m, f, r, cnt = 0;
	char result[200];
	
	do{
		scanf("%d %d %d", &m, &f, &r);
		if( (m == -1) && (f == -1) && (r == -1) ){
			break;
		}
		else{
			if( (m == -1) || (f == -1) ){
				result[cnt] = 'F';
			}
			else if( (m+f) >= 80 ){
				result[cnt] = 'A';
			}
			else if( ((m+f) >= 65) && ((m+f) < 80) ){
				result[cnt] = 'B';
			}
			else if( ((m+f) >= 50) && ((m+f) < 65) ){
				result[cnt] = 'C';
			}
			else if( ((m+f) >= 30) && ((m+f) < 50) ){
				if( r >= 50 ){
					result[cnt] = 'C';
				}
				else{
					result[cnt] = 'D';
				}
			}
			else if( (m+f) < 30 ){
				result[cnt] = 'F';
			}
			else{
				// DO NOTHING
			}
			cnt++;
		}
	}while( 1 );
	
	for(i = 0; i < cnt; i++){
		printf("%c\n", result[i]);
	}

	return 0;
}

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

int main(){
    // 制約見て！！！デカかったらlong longにすること！
    int n,m;
    cin >> n>>m;
    int foods[m]={0};
    rep(i,n){
        int k;
        cin >>k;
        rep(j,k){
            int like;
            cin >> like;
            foods[like-1]++;
        }
    }
    int ans{0};
    rep(i,m){
        if(foods[i]==n)
            ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3644
e1,e2,e3,e4=map(int,input().split())
if e1==e3 and e2==e4:
    print('yes')
elif e1==e2 and e3==e4:
    print('yes')
elif e4==e1 and e2==e3:
    print('yes')
elif e1==e2==e3==e4:
    print('yes')
else:
    print('no')



Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll, ll> Pll;
#define rep(i,n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define debug(var)  do{std::cout << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void err() {cout << -1 << endl;}
#define all(x) (x.begin(), x.end())

const int MOD = 1000000007;
const int INF = 1e9;

#define PI acos(-1);
int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
int ddx[8] = {1,1,1,-1,-1,-1,0,0};
int ddy[8] = {0,1,-1,0,1,-1,1,-1};


int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << max({a, b, c}) - min({a, b, c}) << endl;
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using WGraph = vector<vector<pair<int, ll>>>;

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

constexpr int INF = 1e9;
constexpr int MOD = 1e9 + 7;
constexpr long long LINF = 1e18;
constexpr double EPS = 1e-10;
constexpr double PI = M_PI;

int cost(int i, int j, const vector<int> &A) {
    if (j == 0 || j == 4) return A[i];
    if (j == 1 || j == 3) {
        if (A[i] == 0) return 2;
        if (A[i] % 2 == 0) return 0;
        else return 1;
    }
    if (j == 2) {
        if (A[i] % 2 == 0) return 1;
        else return 0;
    }
    return INF;
}

void solve() {
    int L;
    cin >> L;
    vector<int> A(L);
    for (int i=0; i<L; ++i) cin >> A[i];

    vector<vector<ll>> dp(L+1, vector<ll>(5, LINF));
    dp[0][0] = 0;
    for (int i=1; i<L+1; ++i) {
        ll mini = LINF;
        for (int j=0; j<5; ++j) {
            chmin(mini, dp[i-1][j]);
            chmin(dp[i][j], mini + cost(i-1, j, A));
        }
    }
    ll ans = LINF;
    for (ll x : dp[L]) chmin(ans, x);
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    solve();

    return 0;
}


Measured memory_bytes: 17928
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,a[200000],i,x=0,f=0;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	sort(a,a+n);
	for(i=0;i<n;i++){
		if(a[i]==a[i+1]) f=1;
	}
	if(f==0) printf("YES\n");
	else printf("NO\n");
	return 0;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e10;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define mins(x, y) x = min(x, y)
#define maxs(x, y) x = max(x, y)
typedef priority_queue<P, vector<P>, greater<P> > PQ_ASK;
const int mod = 1000000007;


int main() {

    string s;
    cin >> s;
    int ans = INF;
    for (int i = 0; i < s.size() - 2; i++) {
        string sub = s.substr(i, 3);
        int d = atoi(sub.c_str());
        int diff = abs(753 - d);
        ans = min(ans, diff);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
// Welcome to my source code!

#define MAX 100000
#define NIL -1

struct Node { int p, l, r; };
Node T[MAX];
int D[MAX];

void print(int u) {
    cout << "node " << u << ": ";
    cout << "parent = " << T[u].p << ", ";
    cout << "depth = " << D[u] << ", ";

    if (T[u].p == NIL) cout << "root, ";
    else if (T[u].l == NIL) cout << "leaf, ";
    else cout << "internal node, ";

    cout << "[";
    for (int i = 0, c = T[u].l; c != NIL;  i++, c = T[c].r) {
        if (i) cout << ", ";
        cout << c;
    }
    cout << "]" << endl;
}

int rec(int u, int p) {
    D[u] = p;
    if (T[u].r != NIL) rec(T[u].r, p);
    if (T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
    int n, id, k, c, l, r;
    cin >> n;
    rep(i,n) T[i].p = T[i].l = T[i].r = NIL;

    rep(i,n) {
        cin >> id >> k;
        rep(j,k) {
            cin >> c;
            if (j == 0) T[id].l = c;
            else T[l].r = c;
            l = c;
            T[c].p = id;
        }
    }

    rep(i,n) {
        if (T[i].p == NIL) {
            r = i;
            break;
        }
    }

    rec(r,0);

    rep(i,n) print(i);
}


Measured memory_bytes: 7716
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  int L,R;
  
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;
  
  if(L > R)			cout << "Left" << endl;
  if(L == R)		cout << "Balanced" << endl;
  if(L < R)			cout << "Right" << endl;
  
}

Measured memory_bytes: 256
require 'set'
n, m = gets.split.map(&:to_i)
rel = Array.new(n).map{Array.new}
m.times do
    a, b = gets.split.map(&:to_i)
    rel[a-1].push(b-1)
    rel[b-1].push(a-1)
end
q = [0]
visited = Set.new
visited.add(0)
ans = Array.new
while q.size > 0
    c = q.shift
    rel[c].each do |d|
        next if visited.include?(d)
        ans[d] = c + 1
        visited.add(d)
        q.push(d)
    end
end
puts "Yes"
1.upto(ans.size - 1) do |c|
    puts ans[c]
end

Measured memory_bytes: 38332
#include<cstdio>
int main(){
    int n;
    char a[101],b[101],c[101];
    scanf("%d%s%s%s",&n,a,b,c);
    int ans=0;
    for(int i=0;i<n;i++){
        if(a[i]!=b[i]||b[i]!=c[i]||a[i]!=c[i]){
            if(a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i])ans+=2;
            else ans+=1;
        }
    }
    printf("%d",ans);
    return 0;
}

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

using namespace std;

const int N = 100 * 1000 + 17;
const int MOD = 1000 * 1000 * 1000 + 7;

int n, m;
int a[N];

bool read() {
    if (!(cin >> n >> m))
        return false;

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

    return true;
}

void solve() {
    auto ans = 0;
    map<int, int> f, g, h;

    for (int i = 0; i < n; ++i)
        ++(a[i] % m == 0 ? ans : f[a[i]]);

    ans /= 2;

    for (auto p : f) {
        ans += p.second / 2;

        if (p.second >= 2)
            h[p.first % m] += p.second / 2;

        if (p.second & 1)
            ++g[p.first % m];
    }

    for (int k = 1; k + k <= m; ++k)
        if (k + k < m) {
            auto res = 0;

            for (int t = 0; t <= min(g[k], g[m - k]); ++t)
                res = max(res, t + min(h[m - k], (g[k] - t) / 2) + min(h[k], (g[m - k] - t) / 2));

            ans += res;
        } else {
            ans += g[k] / 2;
        }

    cout << ans << endl;
}

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

    while (read())
        solve();

    return 0;
}



Measured memory_bytes: 14720
import java.util.*;
//System.out.println("")

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a>b){
            a--;
            if(a>b){
                System.out.println(a+1+a);
            }else{
                System.out.println(a+1+b);
            }
        }else{
            b--;
            if(a>b){
                System.out.println(b+1+a);
            }else{
                System.out.println(b+1+b);
            }
        }
    }
}

Measured memory_bytes: 23636
ans = [False] * 200000

def collatz(n, i):
    ans[n] = True
    next_val = n//2 if n % 2 == 0 else 3*n+1
    if ans[next_val]: return i+1
    return collatz(next_val, i+1)

def solve():
    s = int(input())
    print(collatz(s, 1))
    
solve()

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

int main()
{
    string a,b;
    cin>>a>>b;
    if(a.length()<b.length()){
        cout << "LESS"<<endl;
        return 0;
    }
    if(a.length()>b.length()){
        cout<<"GREATER"<<endl;
        return 0;
    }
    for (size_t i = 0; i < a.length(); i++)
    {
        if(a[i]<b[i]){
            cout << "LESS" << endl;
            return 0;
        }
        if(a[i]>b[i]){
            cout << "GREATER" << endl;
            return 0;
        }
    }
    cout << "EQUAL" << endl;

    return 0;
}

Measured memory_bytes: 256
def solve(N, K):
    b = 1 / N
    poss = [b for _ in range(N + 1)]
    for n in range(30):
        for i in range(N + 1):
            if i == 0:
                continue
            if (i << n) < K <= (i << n + 1):
                poss[i] = b * (0.5 ** (n + 1))
    return "{:1.12f}".format(sum(poss[1:]))

if __name__ == "__main__":
    N, K = tuple(map(int, input().split(" ")))
    print(solve(N, K))


Measured memory_bytes: 4632