akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;



namespace Acs
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var hn = new int[n];

            String[] hn_s = Console.ReadLine().Split(' ');

            for (int i = 0; i < n; ++i)
                hn[i] = int.Parse(hn_s[i]);

//          for (int i = 0; i < n; ++i) 
//             Console.Write(hn[i]+" ");

            var tab = new int[n];
            for (int i = 0; i < n; ++i)
                tab[i] = 10000+1;

            tab[0] = 0;
            tab[1] = Math.Abs(hn[1]-hn[0]);
            for (int i = 2; i < n; ++i) {

                var t1 = Math.Abs(hn[i] - hn[i - 1])+tab[i-1];
                var t2 = Math.Abs(hn[i] - hn[i - 2])+tab[i-2];
//                Console.WriteLine(t1 + " " + t2);
                tab[i] = Math.Min(t1, t2);
            }

            Console.WriteLine(
                n == 2? Math.Abs(hn.Last()-hn.First()) : tab.Last()
                );
        }
    }
}


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

int D, G;
int p[11];
int c[11];
int sum = 0, cnt = 0, dp[11][1200], ans = 1 << 30;


int main(){
    cin >> D >> G;

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

    for(int i = 1; i <= D; i++){
        for(int j = 0; j <= D * 100; j++){
            if(dp[i][j] >= G) ans = min(ans, j);
            for(int k = 0; k <= p[i]; k++){
                int pls = (100 * i * k) + (k == p[i] ? c[i] : 0);
                dp[i][j + k] = max(dp[i][j + k], dp[i - 1][j] + pls);
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

using namespace std;

int main(){
  
    int a,b;
    cin >> a >> b;

    cout << max({a + b, a- b, a * b}) << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb          emplace_back
#define ll          long long
#define x           first
#define y           second
#define mp          make_pair

using namespace std;

typedef pair<int, int> pii;
const int N = int(3e2) + 7;
const int mod = int(1e9) + 7;

void add(int& x, int y) {if((x += y) >= mod) x -= mod;}
int mul(int x, int y) {return 1ll * x * y % mod;}
int f[N][N][N], n, m, l, r, x, res;
vector<pii> q[N];

bool Check(int l, int r, int x, int xb, int xr, int xg) {
    int cnt = 0;
    if(xb >= l && xb <= r) ++cnt;
    if(xr >= l && xr <= r) ++cnt;
    if(xg >= l && xg <= r) ++cnt;
    return cnt == x;
}

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    #define Task        "test"
    if(fopen(Task".inp", "r")) {
        freopen(Task".inp", "r", stdin);
        freopen(Task".out", "w", stdout);
    }
    cin >> n >> m;
    for(int i = 1; i <= m; ++i) {
        cin >> l >> r >> x;
        q[r].pb(l, x);
    }
    f[0][0][0] = 1; /// f(blue, red, green)
    for(int i = 0; i <= n; ++i) {
        for(int j = 0; j <= n; ++j) {
            for(int k = 0; k <= n; ++k) {
                //cout << i << ' ' << j << ' ' << k << ' ' << f[i][j][k] << '\n';
                if(f[i][j][k] == 0) continue;
                if(i == j && i) continue;
                if(i == k && i) continue;
                if(j == k && j) continue;
                int pos = max({i, j, k});
                if(pos == n) add(res, f[i][j][k]);
                bool cb = 1, cr = 1, cg = 1;
                for(pii p: q[pos + 1]) {
                    l = p.x, x = p.y;
                    if(!Check(l, pos + 1, x, pos + 1, j, k)) cb = 0;
                    if(!Check(l, pos + 1, x, i, pos + 1, k)) cr = 0;
                    if(!Check(l, pos + 1, x, i, j, pos + 1)) cg = 0;
                }
                if(cb) add(f[pos + 1][j][k], f[i][j][k]);
                if(cr) add(f[i][pos + 1][k], f[i][j][k]);
                if(cg) add(f[i][j][pos + 1], f[i][j][k]);
            }
        }
    }
    cout << res;
}


Measured memory_bytes: 112896
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string n; cin>>n;
	if (n.back()=='2'||n.back()=='4'||n.back()=='5'||n.back()=='7'||n.back()=='9') cout<<"hon"<<endl;
	else if (n.back()=='0'||n.back()=='1'||n.back()=='6'||n.back()=='8') cout<<"pon"<<endl;
	else if (n.back()=='3') cout<<"bon"<<endl;
	else cout<<endl;
	return 0;
}


Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1000000000;
const int MOD = (int)1e9 + 7;

signed main()
{
    int x, a;
    cin >> x >> a;
    cout << ( x < a ? 0 : 10) << "\n";
}

Measured memory_bytes: 256
/*
sort points by x (1st time)
			by y (2nd time)
each time => push back the weight bw 2 points
=> MST (kruskal)
=> DONE!			
*/
#include<bits/stdc++.h>

using namespace std;

#define int long long

const int N=1e5+5;
struct data{
    int x,y,id;
} c[N];
int n,pset[N],ans;
vector< pair< int,pair<int,int> > > edge;

bool cmpx(data _a,data _b){
    if(_a.x!=_b.x) return _a.x<_b.x;
    else return _a.y<_b.y;
}
bool cmpy(data _a,data _b){
    if(_a.y!=_b.y) return _a.y<_b.y;
    else return _a.x<_b.x;
}

int findset(int pos){
    return ( pos==pset[pos]?pos:pset[pos]=findset(pset[pos]) );
}

bool sameset(int i,int j){
    return findset(i)==findset(j);
}

void unionset(int i,int j){
    pset[findset(i)]=findset(j);
}

signed main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    for(int i = 1; i <= n; ++i){
    cin >> c[i].x >> c[i].y;
	c[i].id = i;
	}
    sort(c + 1 , c + n + 1 ,cmpx);
    for(int i = 1; i < n; ++i) edge.push_back(make_pair(c[i+1].x-c[i].x,make_pair(c[i+1].id,c[i].id)));
    sort(c + 1, c + n + 1, cmpy);
    for(int i = 1; i < n; ++i) edge.push_back(make_pair(c[i+1].y-c[i].y,make_pair(c[i+1].id,c[i].id)));
    sort(edge.begin(),edge.end());
    for(int i = 1; i <= n; ++i) pset[i]=i;
    for(int i = 0; i < edge.size(); ++i){
        int w = edge[i].first, u = edge[i].second.first, v = edge[i].second.second;
        if(!sameset(u,v)){
            ans += w;
            unionset(u,v);
        }
    } 
    cout << ans;
    return 0;
}

Measured memory_bytes: 10864
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	int *a;
	scanf("%d", &n);
	a = (int *)malloc(sizeof(int) * n);
	for(int i=0; i<n; i++){
		a[i] = 0;
	}
	for(int j=0; j<n-1; j++){
		int _a;
		scanf("%d", &_a);
		a[_a-1]++;
	}
	for(int k=0; k<n; k++){
		printf("%d\n", a[k]);
	}
	return 0;
}

Measured memory_bytes: 2512
//no avg but median
#include <bits/stdc++.h>
using namespace std;

int main(void){
	int N,avg;
	long long total=0;
	long long total_min=-1;
	cin >> N;
	vector<int> A(N),B(N);
	for(int i=0;i<N;i++){
      cin >> A.at(i);
      A.at(i)=A.at(i)-i-1;
      B.at(i)=A.at(i);
    }

	sort(B.begin(), B.end());

	/*for(int i=0;i<N;i++){
		total+=A.at(i);
	}
	avg=total/N;
	total=0;
	*/
	
	if(N%2==1){
		int b=B.at(N/2);
		total_min=0;
		for(int i=0;i<N;i++){
			total_min+=abs(A.at(i)-b);
		}
	}
	else{
		for(int b=(B.at(N/2-1)+B.at(N/2))/2;b<=(B.at(N/2-1)+B.at(N/2))/2+1;b++){
			for(int i=0;i<N;i++){
				total+=abs(A.at(i)-b);
			}
			if(total_min==-1||total<total_min){
				total_min=total;
			}
			total=0;
		}
	}
	
	/*for(int b=avg-1;b<=avg+1;b++){
		for(int i=0;i<N;i++){
			total+=abs(A.at(i)-b);
			//if(total>=total_min)break;
			//cout << total << endl;
		}
		if(total_min==-1||total<total_min){
			total_min=total;
		}
		total=0;
	}*/

	cout << total_min << endl;

	return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<string>
#include<typeinfo>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int a,b;
	cin >> a >> b;
	
	if(a>0){
		cout << "Positive" << endl;
		return 0;
	}else if(a==0){
		cout << "Zero" << endl;
		return 0;
	}else if(b>=0){
		cout << "Zero" << endl;
		return 0;
	}else{
		if((b-a)%2==0){
			cout << "Negative" << endl;
		}else{
			cout << "Positive" << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <stack>
#include <cstdlib>
#include <vector>
using namespace std;

int a, b, c;

int main() {
	
	cin >> a >> b >> c;

	if (a == b && b == c) cout << "Yes" << endl;
	else cout << "No" << endl;

	system("pause");
	return 0;
}



Measured memory_bytes: 504
from scipy.sparse import*
def main():
  f=csgraph.floyd_warshall
  n,m,l,*t=map(int,open(0).read().split())
  m*=3
  print('\n'.join(map(str,map(int,f(f(csr_matrix((t[2:m:3],(t[:m:3],t[1:m:3])),[n+1]*2),0)<=l)[t[m+1::2],t[m+2::2]].clip(0,n)%n-1))))
main()

Measured memory_bytes: 40864
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

class UnionFind {
 private:
  vector<ll> parents;

 public:
  UnionFind(ll n) : parents(n, -1) {}

  bool issame(ll x, ll y) { return root(x) == root(y); }

  bool merge(ll x, ll y) {
    if (issame(x, y)) return false;

    ll rx = root(x);
    ll ry = root(y);
    if (parents[rx] > parents[ry]) swap(rx, ry);
    // サイズ情報を更新
    parents[rx] += parents[ry];
    // yの親を更新
    parents[ry] = rx;

    return true;
  }

  ll size(ll x) { return -parents[root(x)]; }

 private:
  ll root(ll x) {
    if (parents[x] < 0) return x;
    // 根の親の値に木の(-)サイズの情報を入れる
    return parents[x] = root(parents[x]);
  }
};

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

bool isPrime(ll n) {
  for (ll i = 2; i * i <= n; i++) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

int main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);

  ll X;
  cin >> X;

  ll ans = -1;
  ll max = 1000000;
  // エラトステネスの篩
  vector<bool> isPrime(max + 1, true);
  // 0と1は素数ではない
  isPrime[0] = false;
  isPrime[1] = false;
  // 2からスタート
  for (ll i = 2; i <= max; i++) {
    if (isPrime[i] == false) continue;

    // 2は素数
    // 4, 6, 8, 10, ... は素数ではない
    // 3は素数
    // 6, 9, 12, 15, ... は素数ではない
    for (ll j = i * 2; j <= max; j += i) {
      isPrime[j] = false;
    }

    if (isPrime[i] && i >= X) {
      ans = i;
      break;
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#define LL long long
using namespace std;
const int Maxn = 2000010;
const int Mod = 998244353;
int mp[1000];
int f[Maxn][3][3];
char s[Maxn];
int a[Maxn];
int n;
void solve1() {
	queue <int> q;
	int x = 0;
	for(int i = 1; i <= n; i++) x = x * 10 + a[i];
	int ans = 0;
	mp[x] = 1; ans++;
	q.push(x);
	while(!q.empty()){
		x = q.front(); q.pop();
		int po = 1;
		for(int i = 1; i < n; i++){
			int a1 = (x/po)%10, a2 = (x/po/10)%10;
			if(a1 != a2){
				int a3 = 3-a1-a2;
				int y = x-a1*po-a2*po*10+a3*po*11;
				if(!mp[y]){ mp[y] = 1; ans++; q.push(y); }
			}
			po *= 10;
		}
	}
	printf("%d\n", ans);
}
void up(int &x, int y) { x = (x + y) % Mod; }
bool pd1() {
	for(int i = 1; i < n; i++) if(a[i] != a[i+1]) return false;
	return true;
}
bool pd2() {
	for(int i = 1; i < n; i++) if(a[i] == a[i+1]) return false;
	return true;
}
void solve2() {
	if(pd1() == true){ printf("1\n"); return; }
	int ans = 1;
	int i, j, k;
	for(i = 1; i < n; i++) ans = (LL)ans*3%Mod;
	for(i = 0; i < 3; i++) f[1][i][i] = 1;
	for(i = 1; i < n; i++){
		for(j = 0; j < 3; j++){
			for(k = 0; k < 3; k++){
				for(int x = 0; x < 3; x++) if(x != j) up(f[i+1][x][(k+x)%3], f[i][j][k]);
			}
		}
	}
	int sum = 0;
	for(i = 1; i <= n; i++) sum = (sum+a[i])%3;
	for(i = 0; i < 3; i++) ans = (ans-f[n][i][sum]+Mod)%Mod;
	if(pd2() == true) ans++;
	printf("%d\n", ans%Mod);
}
int main() {
	int i, j, k;
	scanf("%s", s+1);
	n = strlen(s+1);
	for(i = 1; i <= n; i++) a[i] = s[i]-'a';
	if(n <= 3) solve1();
	else solve2();
	return 0;
}

Measured memory_bytes: 13312
#![allow(non_snake_case)]
#![allow(unused_imports)]

use proconio::{input, fastout};
use proconio::marker::*;
use whiteread::parse_line;
use std::collections::*;
use num::*;

use itertools::Itertools;
use itertools_num::ItertoolsNum;

#[fastout]
fn main() {
    input!{
        n: usize, a: usize, b: usize,
    }

    println!("{}", std::cmp::min(n * a, b));
}


Measured memory_bytes: 2172
def main():
    n = int(input())
    A = [int(e) for e in input().split()]
    mod = 10 ** 9 + 7

    sa = sum(A)
    ans = 0
    for i in range(n):
        sa -= A[i]
        ans += A[i] * sa % mod

    ans %= mod
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 94204
#AtcoderABC081 #2

def div(A,N):
	for n in range(N):
		A[n] = A[n]//2

N = int(input())
A = list(map(int, input().split(' ')))
f = 1
cnt = 0
ans = 0

while True:
	for a in A:
		if(a%2 == 0): cnt += 1
	if cnt == N: 
		div(A,N)
		ans += 1
		cnt = 0
	else: break

print(ans)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] S = new int[n];
        for (int i = 0; i < n; i++) {
            S[i] = sc.nextInt();
        }
        int q = sc.nextInt();
        int[] T = new int[q];
        for (int i = 0; i < q; i++) {
            T[i] = sc.nextInt();
        }
        sc.close();
        int ans = 0;
        for (int i = 0; i < q; i++) {
            if (Arrays.binarySearch(S, T[i]) >= 0) {
                ans++;
            }
        }
        System.out.println(ans);


    }
}


Measured memory_bytes: 67896
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())
sub=[]
sub.append(b-a)
sub.append(c-a)
sub.append(d-a)
sub.append(e-a)
sub.append(c-b)
sub.append(d-b)
sub.append(e-b)
sub.append(d-c)
sub.append(e-c)
sub.append(e-d)
max=max(sub)
if max<=k:
    print('Yay!')
else:
    print(':(')

Measured memory_bytes: 3064
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;

void main() {
    auto N = readln.chomp.to!int;
    auto A = readln.chomp;
    auto B = readln.chomp;

    bool[] tate;
    for (int i = 0; i < N; i++) {
        if (i == N - 1 || A[i] != A[i + 1]) tate ~= true;
        else tate ~= false, i += 1;
    }

    long ans = 1;
    long MOD = 10^^9 + 7;
    long a, b;

    for (int i = 0; i < tate.length; i++) {
        if (i == 0 && tate[i]) {
            a = 3;
            b = 1;
        } else if (i == 0 && !tate[i]) {
            a = 3;
            b = 2;
        } else if (tate[i] && tate[i-1]) {
            a = 2;
            b = 1;
        } else if (tate[i] && !tate[i-1]) {
            a = 1;
            b = 1;
        } else if (!tate[i] && tate[i-1]) {
            a = 2;
            b = 1;
        } else {
            a = 3;
            b = 1;
        }
        ans = ans * a * b % MOD;
    }

    ans.writeln;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int i,j,n,a[100],ans;
	long long dp[100][21]={0};
	scanf("%d",&n);
	for(i=0;i<n-1;i++){
		scanf("%d",&a[i]);
		if(!i){
			dp[0][a[i]]=1;
		}
	}
	scanf("%d",&ans);
	for(i=0;i<n-2;i++){
		for(j=0;j<21;j++){
			if(dp[i][j]){
				if(j-a[i+1]>=0){
					dp[i+1][j-a[i+1]]+=dp[i][j];
				}
				if(j+a[i+1]<=20){
					dp[i+1][j+a[i+1]]+=dp[i][j];
				}
			}
		}
	}
	printf("%lld\n",dp[n-2][ans]);
	return 0;
}

Measured memory_bytes: 2660
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>

using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>


ll n, m, ans, s[100];
int main() {
	cin >> n >> m;
	REP(i, n)cin >> s[i];
	REP(i, n + 1) {
		REP(j, n + 1) {
			ll now = 0;
			if (i + j > n or i + j > m)continue;
			priority_queue<ll, vector<ll>, greater<ll>> q;
			REP(k, i) {
				q.push(s[k]);
				now += s[k];
			}
			REP(k, j) {
				q.push(s[n - 1 - k]);
				now += s[n - 1 - k];
			}
			REP(k, m - i - j) {
				if (q.empty())break;
				if (q.top() >= 0)break;
				now -= q.top();
				q.pop();
			}
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const ll mod = 1e9 + 7;

int main(void){
    ll n;
    cin >> n;
    VL a(n);
    ll s = 0, ans = 0;
    REP(i,n){
        a[i] = in();
        ans = (ans + s * a[i]) % mod;
        s = (s + a[i]) % mod;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4840
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n;
    cin >> n;
    if(n < 1000) {
        cout << "ABC";
    }
    else {
        cout << "ABD";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  int mpn[n][n];
  int mpm[m][m];
  bool b=false;
  char a;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin>>a;
      if(a=='#') mpn[i][j]=1;
      if(a=='.') mpn[i][j]=0;
    }
  }
 
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      cin>>a;
      if(a=='#') mpm[i][j]=1;
      if(a=='.') mpm[i][j]=0;
    }
  }
 
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      if(mpn[i][j]==mpm[0][0]){
	b=true;
	for(int k=0;k<m;k++){
	  for(int l=0;l<m;l++){
	    if(mpn[i+k][j+l]!=mpm[k][l]){
	      b=false;
	      break;
	    }
	  }
	    if(!b) break;
	}
      }
      if(b) break;
    }
    if(b) break;
  }
  if(b) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long
#define TBMod 1000000007

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*b - *a);
}

int main(int argc, char const *argv[])
{
	int n,*d;
	int cnt = 1;
	scanf("%d",&n);
	d = (int *)malloc(sizeof(int) * n);
	for (int i = 0; i < n; ++i)	scanf("%d",&d[i]);
	qsort(d,n,sizeof(int),comp);
	for (int i = 1; i < n; ++i)
	{
		if(d[i - 1] > d[i])	++cnt;	
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main()
{
	int n,a[60]={};
	int sum=0,ans=0;
	int i;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	for(i=0;i<n-1;i++)
	{
		sum-=a[i];
		ans+=a[i]*sum;
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
while True:
    W,H=map(int,input().split())
    if W == 0 and H == 0:
        break
    for i in range(W):
        for k in range(H):
            if (i+k)%2==0:
                print("#", end="")
            else:
                print(".", end="")
        print()
    print()


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

int main() {
    int A, B;
    cin >> A >> B;

    if(A==B) cout << A+B << endl;
    else if(A>B) cout << 2*A-1 << endl;
    else cout << 2*B-1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define endl "\n"
const int MAX= 100005 ;
const long long mod = 1.0e9+7;
int gcd(int a,int b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
ll ceil(ll a,ll b)
{
    if(a%b==0)
    {
        return a/b;
    }
    else
    {
        return a/b+1;
    }
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    int n,k,i,j,x,y;
    cin>>n>>k;
    map<int,int> mp;
    for(i=0;i<k;i++)
    {
        cin>>x;
        for(j=0;j<x;j++)
        {
            cin>>y;
            mp[y]++;
        }
    }
    cout<<n-mp.size()<<endl;
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (int i=(int)from; i<(int)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  int N; cin >> N;
  ll tb[10][10] = {};
  repr(i,1,N+1) {
    int b = i%10;
    int t = i; while(t>=10) t/=10; 
    tb[t][b]++;
  }

  ll result = 0;
  rep(i,10) rep(j,10) result += tb[i][j]*tb[j][i];
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100000
#define Q 500

int linearSearch(int);
int S[N];
int n;

int main(){
  int i, j, q, C = 0;
  int T[Q];

  scanf("%d", &n);
  for( i=0 ; i<n ; i++ ){
    scanf("%d", &S[i]);
  }

  scanf("%d", &q);
  for( j=0 ; j<q ; j++ ){
    scanf("%d", &T[j]);
  }
    for( j=0 ; j<q ; j++ ){
      if( linearSearch(T[j])==1 )
	C++;
    }
  printf("%d\n", C);
  return 0;
}

int linearSearch(int key){
  int k = 0;
  S[n] = key;
  while(S[k]!=key)
    k++;
  if( k==n ) return 0;
  else return 1;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(cin>>n){
             cin.ignore();
    int a=0,w=0,t=0,r=0;
    while(n--)
    {
        string st;
        getline(cin,st);
        if(st=="AC") a++;
        //else if(t=="AC") a++;
        else if(st=="WA") w++;
        else if(st=="TLE") t++;
        else  r++;
    }
    cout<<"AC "<<"x"<<" "<<a<<endl<<"WA"<<" "<<"x"<<" "<<w<<endl<<"TLE "<<"x"<<" "<<t<<endl<<"RE"<<" "<<"x "<<r<<endl;


    }

    return 0;
}


Measured memory_bytes: 3620
// ITP1_6_B:   Finding Missing Cards
// 2017.7.27

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

int main()
{
	int i, n, id, rank;
	short card[4][14];
	char buf[100], *p;
	char ids[4] = { 'S', 'H', 'C', 'D' };

	for (id = 0; id < 4; id++) {
		for (rank = 1; rank <= 13; rank++) card[id][rank] = 1;
	}
	gets(buf);
	n = atoi(buf);
	for (i = 0; i < n; i++) {
		gets(buf);
		p = buf;
		while (isspace(*p)) p++;
		switch (*p) {
		case 'S': id = 0; break;
		case 'H': id = 1; break;
		case 'C': id = 2; break;
		case 'D': id = 3; break;
		}
		rank = atoi(++p);
//		printf("id=%d, rank=%d\n", id, rank);
		card[id][rank] = 0;
	}
	for (id = 0; id < 4; id++) {
		for (rank = 1; rank <= 13; rank++) {
			if (card[id][rank]) printf("%c %d\n", ids[id], rank);
		}
	}
	return 0;
}

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

struct ans {
    int a;
    string s;
    bool accepted = false;
    int penality = 0;
};

void solve(){
    int n,m,correct = 0, penality = 0;
    cin >> n >> m;
    vector <ans> otv((n+1));
    for(int i=0;i<m;i++) {
        int temp; string temps;
        cin >> temp >> temps;
        if(temps == "AC") {
            if(!otv[temp].accepted) {
                otv[temp].accepted = true;
            }
        }
        else if(temps == "WA") {
            if(!otv[temp].accepted) {
                otv[temp].penality++;
            }
        }
    }
    for(int i=1;i<=n;i++) {
        if(otv[i].accepted) {
            penality+=otv[i].penality;
            correct++;
        }
    }


    cout << correct << " " << penality << endl;
}



int main() {
    ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
    cout.setf(ios::fixed), cout.precision(0);
    // freopen("a.txt","r",stdin);
    solve();
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define mset(s,_) memset(s,_,sizeof s)
using namespace std;
int a[1000],cnt;
int main(){
	int n,m;
	cin>>n>>m;
	rep(i,1,n){
		cin>>a[i];
		cnt+=a[i];
	}
	int k=cnt;
	sort(a+1,a+1+n,greater<int>());
	for(int i=1;i<=m;i++){
		if(a[i]*4*m<k) return cout<<"No"<<'\n', 0;
	}
	cout<<"Yes"<<'\n';
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%lld%lld", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define debug(x) cout<<(#x)<<"="<<x<<"\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
ll a,b;
int factor(ll x){
        int ans=0;
        for(ll i=2;i*i<=x;i++){
                if(x%i) continue;
                ans++;
                while(x%i==0) x/=i;
        }
        if(x!=1) ans++;
        return ans;
}
int main(){
        while(~getII(a,b)){
                ll g=__gcd(a,b);
                printf("%d\n",factor(g)+1);
        }
}


Measured memory_bytes: 256
def bubbleSort(a, n):   #n個の要素を持つ配列a
    flag = 1    #逆の隣接要素あり
    i = 0       #未ソートの先頭
    #count = 0
    while flag:
        flag = 0
        for j in range(n-1, i, -1): #j n-1...i+1
            if a[j][1] < a[j-1][1]:

                a[j], a[j-1] = a[j-1], a[j]
                #count += 1
                flag = 1
        i += 1
    print(' '.join(map(str, a)))
    #print(count)

def selectionSort(a, n):
    #count = 0
    for i in range(n):
        minj = i
        for j in range(i, n):
            if a[j][1] < a[minj][1]:
                minj = j
        a[i], a[minj] = a[minj], a[i]
    printArray(a)
    #print(count)

def isStable(a1, a2):
    if a1 == a2:
        print("Stable")
    else:
        print("Not stable")


#配列の出力
def printArray(a):
    print(' '.join(map(str, a)))

#配列の要素数と要素の入力
n = int(input())
a = list(input().split())
a2 = a.copy()

bubbleSort(a, n)
print("Stable")
selectionSort(a2, n)
isStable(a, a2)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

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

    vector<long long> A(N);
    for(int i=0; i<N; ++i){
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());

    // priority_queue<pair<long long, long long>, vector<pair<long long, long long>>, greater<pair<long long, long long>> > q;

    long long ans = A[0];
//    q.push({min(A[0], A[1]), max(A[0], A[1])});
    vector<int> life(N);
    for(int i=0; i<N; ++i){
        life[i] = 2;
    }

    int idx = 1;
    for(int i=2; i<N; ++i){
        if(life[idx] >0){
            ans += A[idx];
            life[idx]--;
        }else{
            idx++;
            ans += A[idx];
            life[idx]--;
        }
    }

    cout << ans << endl;
}

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

int w,h;
string room[20];

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

inline bool isRegion(int x, int y){
    return x >= 0 && y >= 0 && x < w && y < h;
}

int dfs(int x, int y){
    int cnt = 1;
    for(int i = 0; i < 4; i++){
        int nx = x + dx[i], ny = y + dy[i];
        
        if(isRegion(nx,ny) && room[ny][nx] == '.'){
            room[ny][nx] = '#';
            cnt += dfs(nx, ny);
        }
    }
    return cnt;
}

int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin >> w >> h;
        if(!w && !h) break;
        
        int sx, sy;
        for(int i = 0; i < h; i++){
            cin >> room[i];
            if(room[i].find('@') != -1){
                sx = room[i].find('@');
                sy = i;
            }
        }
        
        cout << dfs(sx, sy) << endl;
        
    }
}

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

int main(){
    string s;
    cin >> s;
    bool alp[26];
    rep(i,26){
        alp[i] = false;
    }
    rep(i,s.size()){
        alp[s[i] - 'a'] = true;
    }
    rep(i,26){
        if(!alp[i]){
            cout << char(i + 'a') << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define int long long
  #define all(v) v.begin(),v.end()
  #define f first
  #define s second
  #define PB push_back
  #define MP make_pair
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  #define MOD 1000000007
  #define N 1000001
  

int32_t main()
{


  string s;
  cin >> s;
  set<char> ss;

  for(int i = 0; i< s.length(); i++)
  {
    ss.insert(s[i]);
  }


  if(ss.size() == 2)
  {
    cout << "Yes";
  }
  else
  {
    cout << "No";
  }



    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public   class Main {
    
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner sc=new Scanner(System.in);
		Double t=sc.nextDouble();
		Double x=sc.nextDouble();
		System.out.println(t/x);
		
		
	}
}

Measured memory_bytes: 24020
#include <iostream>
using namespace std;
int main() {
  int n,m,sum=0,temp=0;
  cin>>n>>m;
  for(int i=0;i<m;i++){
    cin>>temp;
    sum+=temp;
  }
  if(n>=sum){
    cout<<n-sum<<endl;
  }else{
    cout<<-1<<endl;
  }
}

Measured memory_bytes: 3636
X, K, D = map(int, input().split())
X = abs(X)

if X-D*K>=0:
    print(X-D*K)
else:
    p = X%D
    c = (X-p)//D
    
    if (K-c)%2==0:
        print(p)
    else:
        print(-(p-D))

Measured memory_bytes: 61740
#import pysnooper
#import numpy
#import os,re,sys,operator
#from collections import Counter,deque
#from operator import itemgetter,mul
#from itertools import accumulate,combinations,groupby,combinations_with_replacement,permutations
from sys import stdin,setrecursionlimit
#from bisect import bisect_left,bisect_right
#from copy import deepcopy
#import heapq
#import math
#import string
#from time import time
#from functools import lru_cache,reduce
#from math import factorial,hypot
#import sys
#from fractions import gcd
setrecursionlimit(10**6)
input=stdin.readline

n,k=map(int,input().split())
a=[int(i) for i in input().split()]
kitai=[0]
for i in range(1,1001):
    tmp=0
    d=1/i
    for j in range(1,i+1):
        tmp+=j*d
    kitai.append(tmp)
#print(kitai[:10])
ac=[0]
for i in a:
    ac.append(ac[-1]+kitai[i])
#print(ac)
ans=0
for i in range(k-1,n+1):
    ans=max(ans,ac[i]-ac[i-k])
print(ans)

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

int main(){
  //input 入力
  int n,k;cin >> n >> k;

  //solve 処理
  int ans = k;
  for(int i=1;i<n;++i){
    ans *= k-1;
  }
  
  //output 出力
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String [] args){
    Scanner meow =new Scanner (System.in);
    int A=meow.nextInt();
    int B=meow.nextInt();
    int C=meow.nextInt();
    if(B>=A&&B>=C)
    System.out.println(A+(B*10)+C);
    else if(A>=B&&A>=C)
    System.out.println((A*10)+B+C);
    else
    System.out.println(A+(C*10)+B);
     
  }
      }
  

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

int dx[]={1,-1,0,0};
int dy[]={0,0,1,-1};

int main(){
    int h,w; cin>>h>>w;
    char b[55][55];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++) cin>>b[i][j];
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(b[i][j]=='#'){
                bool flag=false;
                for(int k=0;k<4;k++){
                    int nx=dx[k]+j;
                    int ny=dy[k]+i;
                    if(nx>=0&&nx<w&&ny>=0&&ny<h){
                        if(b[ny][nx]=='#'){
                            flag=true;
                            break;
                        }
                    }
                }
                if(!flag){
                    cout<<"No"<<endl;
                    return 0;
                }       
            }
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;


constexpr int MAX = 100010;
ll fac[MAX], inv[MAX], finv[MAX];
ll n, m, a[100010];

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> n;
  REP(i, n) cin >> a[i];

  fac[0] = inv[0] = finv[0] = 1;
  fac[1] = inv[1] = finv[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;
  }

  // 左から期待値を決めていくと漸化式で定められる。(みんな右に向かうので)
  // Ei = 1 / n * (Ei-1 + 1) + (n - 1) / n * Ei-1
  ll e = 0, ans = 0;
  for(int i = 0; i < n - 1; ++i) {
    e = (e + inv[i + 1]) % MOD;
    ans = (ans + e * (a[i + 1] - a[i]) % MOD) % MOD;
  }

  cout << ans * fac[n - 1] % MOD;
  return 0;
}



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


int main() {

    int n, T;
    cin >> n >> T;
    int ans = 10000;
    rep(i,n) {
        int c, t;
        cin >> c >> t;
        if (t <= T) {
            ans = min(c, ans);
        }
    }
    if (ans != 10000) cout << ans << endl;
    else cout << "TLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
/* Properties of modulo:
	(a/b)%m ,where m is prime  = (a%m) * (b^(m-2))%m
*/
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define IOS { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define ll long long
#define pb push_back
#define gcd __gcd
#define nl cout<<"\n"
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define trav(a,x) for(auto a = x.begin() ; a != x.end() ; a++)
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
template<typename T>
#define o_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
// o_set(ll) name ; -- defining ordered set
//member functions :
//1. order_of_key(k) : number of elements strictly lesser than k
//2. find_by_order(k) : k-th element in the set - returns iterator
bool compare(ll a, ll b){
    return a > b;
}
ll power(ll x, ll ex , ll md) {
    ll ans = 1ll;
    while (ex > 0) {
        if (ex & 1ll) ans = (ans * x) % md;
        ex >>= 1ll;
        x = (x * x) % md;
    }
    return ans;
}
void solve(){
    ll s  ,w ;
    cin >> s >> w;
    if(s > w) cout<<"safe\n";
    else cout<<"unsafe\n";
}
int main(){
    IOS;
    ll T=1;
    //cin>>T;
    ll t=0;
    while(t++<T){
        //cout<<"Case #"<<t<<":"<<' ';
        solve();
        //cout<<'\n';
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}


Measured memory_bytes: 3784
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int N;
    cin >> N ;
    vector<string> s(N+1);
    vector<int> t(N+1);
    for (int i = 0; i < N; i++) {
      cin >> s[i] >> t[i];
    }
    string lastsong;
    cin >> lastsong;
    int ctr = N;
    int alpha = 0;
    while (lastsong != s[ctr-1]) {
        ctr--;
        alpha += t[ctr];
    }
    cout << alpha;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.io.PrintWriter;

@SuppressWarnings("unchecked")
public class Main {
    public static void main(String[] args) throws IOException {
        final String s;

        try (
            BufferedReader reader = new BufferedReader(
                new InputStreamReader(System.in))) {
            s = reader.readLine();
        }

        PrintWriter out = new PrintWriter(System.out);

        final String[] sl = s.split(" ");
        int A = Integer.parseInt(sl[0]);
        int B = Integer.parseInt(sl[1]);
        int C = Integer.parseInt(sl[2]);

        int max = Math.max(A, Math.max(B, C));

        int sum = 3 * max - A - B - C;

        int ans;

        if (sum % 2 == 0) ans = sum / 2;
        else ans = (int)Math.ceil((double)sum / 2) + 1;

        out.println(ans);

        out.flush();
    }
}


Measured memory_bytes: 22356
import math
a,b,h,m=map(int,input().split(" "))
c=h*30+m/2
d=m*6

if c-d>180:
  e=d+(360-c)
  ans=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(e)))
elif c-d==180:
  ans=a+b
else:
  e=c-d
  ans=math.sqrt(a*a+b*b-2*a*b*math.cos(math.radians(e)))
print(ans)

Measured memory_bytes: 9528
//     _/    _/  _/                        _/                
//    _/    _/      _/_/_/      _/_/_/  _/_/_/_/    _/_/_/   
//   _/_/_/_/  _/  _/    _/  _/    _/    _/      _/    _/    
//  _/    _/  _/  _/    _/  _/    _/    _/      _/    _/     
// _/    _/  _/  _/    _/    _/_/_/      _/_/    _/_/_/ 
// C++ Conpetitive Programming Template 
// Ver 1.1 (codename: Hinata)
// Last Modified : 2019-05-28
// Created       : 2019-05-25
// Auther        : shirataki3
#include <bits/stdc++.h>
using namespace std;
// typename alias
template <class T> using vec = vector<T>;
template <class T, class U> using vep = vec<pair<T,U> >;
template <class T> using PQ = priority_queue<T>;
using ll = long long;
using vll = vec<ll>;
using pll = pair<ll, ll>;
using vpll = vec<pll>;
using str = string;
// あくまのちから
//#define int ll

// const
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;
static const double PI = 3.14159265358979323846;

// accelerate stdin, stdout
#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
// repeat macro
#define FOR(i, a, b) for(ll (i)=(a);(i)<=(b);i++)
#define rFOR(i, a, b) for(ll (i)=(b);(i)>=(a);i--)
#define REP(i, n) for(ll i=0;i<n;i++)
// vector macro
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort(WHOLE(v))
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse(WHOLE(v))
#define FOLDL(src, dst, lambda) partial_sum(WHOLE(src), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum(WHOLE(src), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate(WHOLE(v), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

// io helper
template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}
template <typename T>istream& operator>>(istream &is, vec<T> &v) {for(auto &a:v) is >> a; return is;}
template <typename T>ostream& operator<<(ostream &os, vec<T> &v) {os << "[";REP(i, v.size() - 1) os << v[i] <<", "; os << v[v.size()-1]<<"]";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")";return os;}
template <typename T, typename U>ostream& operator<<(ostream &os, map<T, U> &mp) {os << "{ ";for(auto &p:mp) os << p.first << ": " << p.second << ", "; os << "}";return os;}

void solve() {
    ll n, m, d;
    cin >> n >> m >> d;
    if(d == 0) {
        out((m - 1) / (double) n);
    }else {
        out(2 * (m - 1) * (n - d) / (double) (n * n));
    }
}

signed main() {
    fast_io;
    cout << setprecision(20) << fixed;
    solve();
    return 0;
}


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

using namespace std;
int main()
{
    set <string> s;
    int n;
    cin>>n;
    for(int i=0;i<n;i++){
        string t;
        cin>>t;
        s.insert(t);
    }
    cout<<s.size();
    return 0;
}


Measured memory_bytes: 19228
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math

import itertools

#import bisect

import copy
from functools import lru_cache

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default

#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]



def main():
    n=int(input())
    if n%2==0:
        print(n//2)
    else:
        print(n//2+1)






if __name__ == "__main__":
    main()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)
#define forab(i, a, b) for(int i=(int)a; i<(int)b; ++i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    string s; cin >> s;
    string r1 = "", r2 = "";
    int n = s.length();
    forn(i, n){
        r1 += (i&1) ? '0'  : '1';
    }
    forn(i, n){
        r2 += (!(i&1)) ? '0'  : '1';
    }
//    cout << r1 << "\n" << r2 << "\n";
    int re1 = 0, re2 = 0;
    forn(i, n){
        if(s[i] != r1[i])
            ++re1;
        if(s[i] != r2[i])
            ++re2;
    }
    cout << min(re1, re2) << "\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    compute();
    return 0;
}


Measured memory_bytes: 720
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;
typedef long long LL;

LL n,k;

int main(){
	ios::sync_with_stdio(false);
	cin >> n; k = 1;
	while(1){
		k <<= 1;
		if(k > n){
			cout << k - 1 << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
x=[]
y=[]
for i in range(n):
    x.append(i+a[i])
    y.append(i-a[i])
x=Counter(x)    
y=Counter(y)
s=set(x.keys()).union(set(y.keys()))

ans=0
for k in s:
    ans += x[k]*y[k]
print(ans)

Measured memory_bytes: 97992
from collections import defaultdict,Counter
import sys

n = int(input())
a = list(map(int, sys.stdin.readline().split()))

d = Counter(a)
e = defaultdict(int)

base = sum(v * (v - 1) // 2 for v in d.values())
e = {k: base - (v >= 2) * (v - 1) for k, v in d.items()}

for x in a:
  print(e[x])

Measured memory_bytes: 32488
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;

int main() {
	while (1) {
		int a, b, ans = 0;
		cin >> a >> b;
		if (a == 0) { break; }
		int k[1005];
		for (int i = 0; i < a; ++i) { cin >> k[i]; }
		for (int i = 0; i < a; ++i) {
			for (int j = i + 1; j < a; ++j) {
				if (k[i] + k[j] <= b) { ans = max(ans, k[i] + k[j]); }
			}
		}
		if (ans == 0) { cout << "NONE" << endl; }
		else { cout << ans << endl; }
	}
}


Measured memory_bytes: 3084