akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const int N = 10;

int main()
{
  int H, W;
  cin >> H >> W;
  vector<vector<int>> c(N, vector<int>(N));
  for (int i = 0; i < N; i++)
  {
    for (int j = 0; j < N; j++)
    {
      cin >> c.at(i).at(j);
    }
  }
  for (int k = 0; k < N; k++)
  {
    for (int i = 0; i < N; i++)
    {
      for (int j = 0; j < N; j++)
      {
        c.at(i).at(j) = min(c.at(i).at(j), c.at(i).at(k) + c.at(k).at(j));
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < H; i++)
  {
    for (int j = 0; j < W; j++)
    {
      int a;
      cin >> a;
      if (a == -1)
      {
        continue;
      }
      else
      {
        ans += c.at(a).at(1);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n;
  cin >> n;
  vl l(n);
  rep(i,n){
    cin >> l[i];
  }
  sort(l.begin(),l.end());
  ll sum=0;
  rep(i,n-1){
    sum +=l[i];
  }
  if(sum>l[n-1]){
    cout << "Yes" << endl;
  }
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
import math
import fractions
import sys
import itertools
import numpy as np
from collections import Counter
import datetime
#入力:N(int:整数)
def input1():
	return int(input())

#入力:N,M(int:整数)
def input2():
	return map(int,input().split())

#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))

def keta(N):
	return len(str(N))


def input_daytime(input_time):
	time,distance=input_time.split()
	t=time.split(":")
	se=str(t[-1]).split(".")
	dt1 = datetime.timedelta(hours=int(t[0]),minutes=int(t[1]),seconds=int(se[0]),milliseconds=int(se[1]))
	return dt1

n=input1()
s=str(input())

slimes=[]
first=s[0]
slimes.append(s[0])
for i in range(0,n):
	if s[i]==first:
		continue
	else:
		first=s[i]
		slimes.append(first)
print(len(slimes))











Measured memory_bytes: 14776
#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;

typedef int64_t ll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define vll vector<ll>
#define all(v) v.begin(), v.end()



int main() {
	ll H, W;
	cin >> H >> W;
	if (H % 3 == 0 || W % 3 == 0) {
		cout << 0 << endl;
		return 0;
	}

	ll val1 = INF;
	ll a1 = (H / 2) * W, a2 = (H - H / 2) * W, a3 = 0;
	rep(i, W) {
		a1 -= H / 2;
		a2 -= H - H / 2;
		a3 += H;
		val1 = min(val1, max({ a1, a2, a3 }) - min({ a1, a2, a3 }));
	}

	ll val2 = INF;
	a1 = (W / 2) * H, a2 = (W - W / 2) * H, a3 = 0;
	rep(i, H) {
		a1 -= W / 2;
		a2 -= W - W / 2;
		a3 += W;
		val2 = min(val2, max({ a1, a2, a3 }) - min({ a1, a2, a3 }));
	}

	cout << min({ val1, val2, H, W }) << endl;
}


Measured memory_bytes: 256
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val s = mutableMapOf<String, Int>()

    for (i in 1..n) {
        val letters = next().toList().sorted().joinToString("")
        s[letters] = s[letters]?.plus(1) ?: 1
    }

    println(s.map { if (it.value > 1) comb(it.value, 2) else 0 }.sum())
}

fun next() = readLine()!!
fun nextInt() = next().toInt()

fun perm(n: Int, k: Int): Long {
    require(n > 0 && k >= 0)
    return (n - k + 1 .. n).fold(1L) { acc, i -> acc * i }
}

fun comb(n: Int, k: Int): Long {
    require(n > 0 && k >= 0)
    val fact = (2..k).fold(1L) { acc, i -> acc * i }
    return perm(n, k) / fact
}

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 80152
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define re(i,a,b) for(int i=(a);i<(b);i++)
#define repd(i,a,b) for(int i=(a);i>=(b);i--)
#define run(v) for(int k=head[v];k;k=e[k].ne)
#define v e[k].t
#define clr(a) memset(a,0,sizeof(a));
#define il inline
#define sz(a) ((int)a.size())
#define all(a) a.begin(),a.end()
#define mp make_pair
#define pb push_back 
#define w1 first
#define w2 second
#define adm(a,b,c) {a=a+b;if(a>=c)a-=c;else if(a<0)a+=c;}
typedef pair<int,int> pa;
typedef long long ll;typedef long double ld;typedef unsigned long long ull;
const int N=1e5+5,M=5e7+5,INF=1e9,mod=1e9+7;
const ll linf=1e18;const double eps=1e-8,pi=acos(-1);
il int gmin(int &a,int b){if(a>b)a=b;}il ll gmin(ll &a,ll b){if(a>b)a=b;}il int gmax(int &a,int b){if(a<b)a=b;}il ll gmax(ll &a,ll b){if(a<b)a=b;}
il void read(ll&x){ll f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il ll read(ll&x,ll&y){read(x);read(y);}
il void read(int&x){int f=1,t=0;char ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9'){t=t*10+ch-'0';ch=getchar();}x=t*f;}il int read(int&x,int&y){read(x);read(y);}
il void read(int&a,int&b,int&c){read(a);read(b);read(c);}il void read(ll&a,ll&b,ll&c){read(a);read(b);read(c);}
il int read(){int x;read(x);return x;}
il ll qpow(ll a,ll b,ll p){ll ret=1;for(;b;b>>=1,a=a*a%p)if(b&1)ret=ret*a%p;return ret;}il ll qpow(ll a,ll b){ll ret=1;for(;b;b>>=1,a=a*a%mod)if(b&1)ret=ret*a%mod;return ret;}
il ll qmul(ll a,ll b,ll p){ll ret=0;for(;b;b>>=1,a=(a<<1)%p)if(b&1)adm(ret,a,p);return ret;}il ll qmul(ll a,ll b){ll ret=0;for(;b;b>>=1,a=(a<<1)%mod)if(b&1)adm(ret,a,mod);return ret;}
il void judge(){
	freopen("data.in","r",stdin);
	freopen("data.out","w",stdout);}
il void gen(){freopen("data.in","w",stdout);}
int q[N],l=500,r=l-1,dex;
void solve(ll x){
	if(x==1)return;
	if(!(x&1)){
		solve(x/2);
		q[++r]=++dex;
		return;
	}
	solve(x-1);
	q[--l]=++dex;
}
int main(){
	ll x;read(x);x++;
	solve(x);
	cout<<dex*2<<endl;
	rep(i,l,r)printf("%d ",q[i]);
	rep(i,1,dex)printf("%d ",i);
}

Measured memory_bytes: 256
#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()
{
    char a;
    cin >> a;
    if(isupper(a)){
        cout << 'A' << endl;
    }
    else{
        cout << 'a' << endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include<algorithm>
#include<string>
#include<vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
using namespace std;

int main()
{
	int k, s,cnt=0;
	cin >> k >> s;
	for (int x = 0; x <= k; x++) {
		for (int y = 0; y <= k; y++) {
			if (s - x - y <= k && s - x - y >= 0)cnt++;
		}
	}
	cout << cnt << endl;
}




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

const int N = 2e5 + 5, S = 26;

int n, dist;

int len[N], nxt[N][S];
bool f[S];

int main() {
#ifdef HOME
	freopen("arc081c.in", "r", stdin);
	freopen("arc081c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	string str, ant;

	cin >> str;
	n = str.size();

	for (int ch = 0; ch < S; ++ch)
		nxt[n][ch] = n;
	for (int i = n - 1; i >= 0; --i)
	for (int ch = 0; ch < S; ++ch)
		nxt[i][ch] = (ch + 'a' == str[i] ? i : nxt[i + 1][ch]);

	for (int i = n - 1; i >= 0; --i) {
		if (!f[str[i] - 'a']) {
			f[str[i] - 'a'] = true;
			dist+= 1; }
		len[i] = len[i + 1];
		if (dist == 26) {
			len[i]+= 1;
			memset(f, 0x00, sizeof f);
			dist = 0; } }

	len[n] = len[n + 1] = -1;
	for (int p = -1, need = len[0]; need >= 0; --need) {
		for (int ch = 0; ch < S; ++ch) {
			int tr = nxt[p + 1][ch];
			if (len[tr + 1] < need) {
				ant.push_back(ch + 'a');
				p = tr;
				break; } } }

	cout << ant << endl;

	return 0; }



Measured memory_bytes: 21652
#include <cstdio>
#include <vector>
#include <cassert>

using namespace std;

const int M = 110;

int a2[M];
vector<int>odd;
vector<int>even;
vector<int> a;
vector<int> b;

int main(){
	int n, m;
	scanf("%d %d", &n, &m);
	for(int i = 0; i < m; i++){
		scanf("%d", &a2[i]);
		if(a2[i]&1)odd.push_back(a2[i]);
		else even.push_back(a2[i]);
	}
	if(odd.size()>2){
		puts("Impossible");
	}
	else{
		if(m==1){
			a.push_back(a2[0]);
			if(a2[0]-1!=0)b.push_back(a2[0]-1);		
			b.push_back(1);		
		}
		else{
			if(odd.size()>=1)a.push_back(odd[0]);
			for(int i = 0; i < even.size(); i++){
				a.push_back(even[i]);
			}
			if(odd.size()>=2)a.push_back(odd[1]);
			if(a[0]-1!=0)b.push_back(a[0]-1);
			for(int i = 1; i < a.size()-1; i++){
				b.push_back(a[i]);
			}
			//assert(((int)a.size()-1)>=0);
			b.push_back(a[(int)a.size()-1]+1);
		}
		for(int i = 0; i < a.size(); i++){
			if(i!=0)printf(" ");
			printf("%d",a[i]);
		}
		printf("\n");
		printf("%d\n",(int)b.size());
		for(int i = 0; i < b.size(); i++){
			if(i!=0)printf(" ");
			printf("%d",b[i]);
		}
		printf("\n");
	}

}


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

int main(){
	int  n , k;
	scanf("%d%d",&n,&k);
	int Array[n];
	for(int i=0;i<n;i++){
		scanf("%d",&Array[i]);
	}
	sort(Array,Array+n);
	int sum=0;
	for(int i=0;i<k;i++){
		sum+=Array[i];
	}
	printf("%d",sum);
}



Measured memory_bytes: 3824
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#define rep(i, l, n) for(int i=(l); i<(int)(n); i++)
#define REP(i, n) for(int i=1; i<=(int)(n); i++)

using namespace std;

int main(){
    int N;
    string slime;
    vector<char> ans;
    cin >> N;
    cin >> slime;

    ans.push_back(slime[0]);
    rep(i, 1, N) {
        if (slime[i] == ans[ans.size()-1]) continue;
        else {
            ans.push_back(slime[i]);
        }
    }

    cout << ans.size() << endl;

    return 0;
}



Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
using namespace std;

#define STRMAX 1005
#define ORDREMAX 20


int main(void)
{
	char	str[STRMAX];
	int		num, i, j, k, under, over;
	char	substr[STRMAX];
	char	order[ORDREMAX];
	char	tmp;

	cin >> str;
	cin >> num;

	for (i=0; i<num; i++) {
		cin >> order >> under >> over;

		if (strcmp(order, "print") == 0) {
			for (j=under; j<=over; j++) {
				cout << str[j];
			}
			cout << endl;
		}
		else if (strcmp(order, "replace") == 0) {
			cin >> substr;
			k = 0;
			for (j=under; j<=over; j++) {
				str[j] = substr[k];
				k++;
			}
		}
		else if (strcmp(order, "reverse") == 0) {
			j = under;
			k = over;
			while (1) {
				if (under >= over) {
					break;
				}
				else {
					tmp = str[under];
					str[under] = str[over];
					str[over] = tmp;
					under++;
					over--;
				}
			}
		}
	}


	return 0;
}


Measured memory_bytes: 3112
fun main(arr:Array<String>) {
    val (a,b,c,d) = readLine()!!.split(" ").map { it.toLong() }
    val ans = (b-a+1) - getCount(a,b,c) - getCount(a,b,d) + getCount(a,b,getKoubai(c,d))
    println(ans)
}

fun getKouyaku(num1:Long, num2:Long):Long {
    if(num1 % num2 == 0L) {
        return  num2
    }
    return getKouyaku(num2, num1%num2)
}

fun getKoubai(num1:Long, num2:Long):Long {
    val kouyaku = getKouyaku(num1, num2)
    return kouyaku * (num1/kouyaku) * (num2/kouyaku)
}

fun getCount(a:Long, b:Long, num:Long):Long {
    var posMin = (a/num)*num
    if(posMin < a) {
        posMin+=num
    }
    val posMax = (b / num)*num
    if(posMin > posMax) {
        return 0
    }
    return ((posMax - posMin) / num) + 1
}


Measured memory_bytes: 37604
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])){
       // cout<<"Yes"<<endl;
        puts("Yes");
        
    }else{
       // cout<<"No"<<endl;
      puts("No");
    }
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;

int main(){
ll H,W;
  cin>>H>>W;
  char dp[H][W];
  ll ans=0;
  rep(i,H){
  rep(j,W) cin>>dp[i][j];
  }
  queue<P>op;
  rep(i,H){
  rep(j,W){
 vector<vector<ll>> num(H, vector<ll>(W));
    vector<vector<ll>> fif(H, vector<ll>(W));
if(dp[i][j]=='.'){
    op.push(P(i,j));
    fif.at(i).at(j)=1;
    while(op.size()!=0)
    {
    P p=op.front();
      op.pop();
      ll x=p.first;
      ll y=p.second;
      ll k=num.at(x).at(y);
      
      ans=max(ans,k);
      if(x>0 ){
        if(dp[x-1][y]=='.' & fif.at(x-1).at(y)==0)
        {num.at(x-1).at(y)=k+1;
        fif.at(x-1).at(y)=1;
        op.push(P(x-1,y));
      
      }  }
          if(y>0 ){
      if(dp[x][y-1]=='.' & fif.at(x).at(y-1)==0){
        num.at(x).at(y-1)=k+1;
        fif.at(x).at(y-1)=1;
        op.push(P(x,y-1));
             
      } }
            if(x<H-1) {
              if(dp[x+1][y]=='.' & fif.at(x+1).at(y)==0)
              {num.at(x+1).at(y)=k+1;
        fif.at(x+1).at(y)=1;
        op.push(P(x+1,y));
              
      } }
            if(y<W-1) {
     if(dp[x][y+1]=='.' & fif.at(x).at(1+y)==0){
              num.at(x).at(y+1)=k+1;
        fif.at(x).at(y+1)=1;
        op.push(P(x,y+1));
             
      } }
    }
    
}
  }
  
 
  
  }

  
   cout<<ans<<endl;
  }
 





Measured memory_bytes: 256
from operator import itemgetter

def solve():
    N = int(input())
    C = []
    for _ in range(N):
        a, b = list(map(int, input().split()))
        C.append((a-b, a+b))

    C.sort(key = itemgetter(1))
    
    c = 0
    cur = -float('inf')
    for i in range(N):
        if cur <= C[i][0]:
            c += 1
            cur = C[i][1]

    return c

print(solve())


Measured memory_bytes: 18300
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000ll
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  
///////

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n,m;
	cin>>n>>m;
	int mo=1000000007;
	int ans[n+1]={};
	ans[0]=1;
	for(int i=0;i<m;++i)
	{
		int d;
		cin>>d;
		ans[d]=-1;
	}
	if(ans[1]==-1)
		ans[1]=0;
	else
	{
		ans[1]=1;
	}
	for(int i=2;i<=n;++i)
	{
		if(ans[i]==-1)
			ans[i]=0;
		else
		{
			ans[i]=(ans[i-1]+ans[i-2])%mo;
		}
	}
	cout<<ans[n];
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <vector>
#define llint long long

using namespace std;
typedef pair<llint, llint> P;

llint n, k;
llint a[200005], sum[200005];
map<llint, vector<llint> > mp;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> k;
	for(int i = 1; i <= n; i++) cin >> a[i], a[i] %= k;
	
	for(int i = 1; i <= n; i++) sum[i] = sum[i-1] + a[i], sum[i] %= k;
	for(int i = 0; i <= n; i++){
		sum[i] += k-i+100000*k, sum[i] %= k;
		mp[sum[i]].push_back(i);
	}
	
	///for(int i = 0; i <= n; i++) cout << sum[i] << " "; cout << endl;
	
	llint ans = 0;
	for(int i = 1; i <= n; i++){
		vector<llint> &vec = mp[sum[i]];
		ans += lower_bound(vec.begin(), vec.end(), i) - lower_bound(vec.begin(), vec.end(), i-k+1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 25216
from collections import Counter
import sys

def input():
    return sys.stdin.readline().strip()

def dfs(v):
    start[v] = lb()
    for w in g[v]:
        if start[w] != None:
            continue
        dfs(w)
    end[v] = lb()

n = int(input())
g = [None] * (n+1)
start = [None] * (n+1)
end = [None] * (n+1)
lb = iter(range(1,2*n+1)).__next__
for _ in range(n):
    u,k,*vk = map(int,input().split())
    g[u] = vk
for v in range(1,n+1):
    if start[v] != None:
        continue
    dfs(v)

for i in range(1,n+1):
    print(i,start[i],end[i])


Measured memory_bytes: 6104
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-08-29 22:53
# @url:https://atcoder.jp/contests/abc177/tasks/abc177_d
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192
sys.setrecursionlimit(10 ** 7)
class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    n,m=map(int,input().split())
    pairs=[]
    for i in range(m):
        a,b=map(int,input().split())
        temp=[]
        temp.append(a)
        temp.append(b)
        pairs.append(temp)
    fa=[i for i in range(n+1)]
    child=[1]*(n+1)
    def find(x):
        if x!=fa[x]:
            fa[x]=find(fa[x])
        return fa[x]
    def union(x,y):
        x = find(x)
        y = find(y)
        if x == y:  
            return
        fa[x] = y
        child[y]+=child[x]
    for (i,j) in pairs:
        union(i,j)
    # for (i,j) in pairs:
    #     union(j,i)
    # d=collections.Counter(fa)
    # print (child)
    # print (fa)
    print (max(child))

if __name__ == "__main__":
    main()

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

int main() {
    int n;
    int l[110];
    int i, j, k;
    int count = 0;

    cin >> n;

    for(i=0; i<n; i++){
    	cin >> l[i];
    }

    for(i=0; i<n-2; i++){
    	for(j=i+1; j<n-1; j++){
    		for(k=j+1; k<n; k++){
    			if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] && l[k] + l[i] > l[j]){
    				
    				if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]){
    					count++;
    				}
    				//cout << i << j << k << endl;
    			}
    		}
    	}
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 3632
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<unordered_map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<queue>
#include<functional>
#include<iso646.h>
#include<bitset>

#ifndef M_PI
#define M_PI 3.14159265358979
#endif
#define deg_to_rad(deg) (((deg)/360)*2*M_PI)
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main() {
	ll i, j;
	double a, b, x;
	cin >> a >> b >> x;
	if (x >= a * a * b / 2) {
		double y = 2 / a * (a * b - x / a);
		double the = 90 - rad_to_deg(atan(a / y));
		cout << setprecision(12) << the << endl;
	}
	else {
		double y = 2 * x / a / b;
		double the = 90 - rad_to_deg(atan(y / b));
		cout << setprecision(12) << the << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(false);cin.tie(0)
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define vec std::vector<ll>
#define mp map<ll,ll>
#define fo(i,j,n) for(ll i=j;i<n;i++)
#define co cout<<
#define end <<"\n"
using namespace std;
int main (){
    boost;
    int x;
    cin>>x;
    if(x==0){
        cout<<1;
    }
    else{
        cout<<0;
    }
    return 0;
}



Measured memory_bytes: 3544
#include <bits/stdc++.h>
#define lli long long int
#define MODV 1000000007
#define INF INT_MAX // 2147483647
#define INFLL LLONG_MAX // 9223372036854775807
#define rep(i, n) for(lli i=0, i##_len=(lli)(n); i<i##_len; i++)
#define repf(i, n) for(lli i=1, i##_len=(lli)(n+1); i<i##_len; i++)
#define per(i, n) for(lli i=((lli)(n))-1; i>=0; i--)
#define perf(i, n) for(lli i=((lli)(n)); i>0; i--)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<lli>
#define vvi vector<vector<lli>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
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; }
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(10);
    lli n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    sort(all(d));
    n = n/2;
    cout << d[n]-d[n-1] << endl;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    ll N, K;
    cin >> N >> K;
    ll res = 1LL;
    rep(i, N) { res *= (i == 0 ? K : (K - 1)); }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace std;
#define fi first
#define se second
#define pb push_back
typedef pair<int, int> ii;
typedef long long ll;

const int maxn = 3e5+5;

struct node
{
	int t, L, R, det;
	node(){}
	node(int t, int L, int R): t(t), L(L), R(R)
	{
		if(t == 1) det = R-L;
		else det = L;
	}
	bool operator < (node other) const
	{
		if(det != other.det) return det> other.det;
		return t< other.t;
	}
};

int ft[maxn];
int n, m;

void update(int x, int dx)
{
	for(; x<= n; x += x&(-x)) ft[x] += dx;
}

int sum(int x)
{
	int res = 0;
	for(; x; x -= x&(-x)) res += ft[x];
	return res;
}

vector<node> vec;

int st[maxn], ed[maxn];
int ans[maxn];

int main()
{
	scanf("%d %d", &m, &n);
	for(int i = 1; i<= n; i++) vec.pb(node(2, i, i));
	for(int i = 1; i<= m; i++)
	{
		scanf("%d %d", &st[i], &ed[i]);
		update(st[i], 1);
		update(ed[i]+1, -1);
		vec.pb(node(1, st[i], ed[i]));
	}
	sort(vec.begin(), vec.end());
	int over = 0;
	for(auto kk : vec)
	{
		int t = kk.t;
		int L = kk.L;
		int R = kk.R;
		if(t == 1)
		{
			update(L, -1);
			update(R+1, 1);
			over++;
		}
		else
		{
			int x = L;
			int res = 0;
			for(int y = 0; y<= n; y += x)
			{
				res += sum(y);
			}
			ans[x] = over+res;
		}
	}
	for(int i = 1; i<= n; i++) printf("%d\n", ans[i]);
}

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

#define REP(i,n) for(int i=0;i<(n);++i)
#define ll long long
const long long INF = 1LL<<60;
const long long mod = 1e9 + 7;

int main(){
    int X;
    cin >> X;
    if (X == 7 || X == 5 || X == 3) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < int(k); i++ )
#define FOR(i, a, b) for(int i = (a); i <= int(b); i++)
#define TRAV(a, e) for(auto x : e)

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007

#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

typedef long L;
typedef unsigned long UL;
typedef long long LL;
typedef unsigned long long ULL;

string to_string(string s) {
    return '"' + s + '"';
}

string to_string(const char* s) {
    return to_string((string) s);
}

string to_string(bool b) {
    return (b ? "true" : "false");
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}

void solve(__attribute__((unused)) int tc = 0) {
    LL a, b, c, d;
    cin >> a >> b >> c >> d;
    LL div_c = b / c - (a - 1) / c;
    LL div_d = b / d - (a - 1) / d;
    LL div_c_d = b / (c / __gcd(c, d) * d) - (a - 1) / (c / __gcd(c, d)* d);
    cout << (b - a + 1) - (div_c + div_d - div_c_d) << endl;
    return;
}

int main() {
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cin.tie(0);
    ios_base::sync_with_stdio(false);

    /*int TC;
      cin >> TC;
      REP(tc, TC) {
      solve(tc);
      }*/
    solve();
#ifdef TIME
    cout << "Execution time(second) : " << int(clock() * 1000.0 / CLOCKS_PER_SEC) << " ms" << endl;
#endif
}


Measured memory_bytes: 256
import sys
from collections import deque
import copy

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    nums = string_to_int(inputs[0])
    nums.sort()
    return abs(nums[0] - nums[-1])


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    input()
    ret = solve(inputs(1))
    print(ret)


Measured memory_bytes: 3564
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int a[N];
	int b[N];
	f(i, N)a[i] = 0;
	int n,m, k;
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d %d", &n, &m, &k);
	x = 1000000100;
	y = x;
	f(i, n) {
		scanf("%d", &a[i]);
		x = min(x, a[i]);
	}
	f(i, m) {
		scanf("%d", &b[i]);
		y = min(y, b[i]);
	}
	s = x + y;
	f(i, k) {
		scanf("%d %d %d", &x, &y, &z);
		s = min(s, a[x - 1] + b[y - 1] - z);
	}

	printf("%d\n", s);


	return 0;
}

Measured memory_bytes: 1408
#include<stdio.h>
int main() {
	int arr[26] = {0};
	char(ch);
	while((ch = getchar())!='\n') {
		arr[ch-'a']++;
	}
	int flag = 1;
	int i;
	for(i=0; i<26; i++) {
		if(arr[i] == 0) continue;
		if(arr[i] % 2 == 1) {
			flag = 0;
			break;
		}
	}
	if(flag) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main(){
    int m,f,b;
    cin>>m>>f>>b;
    
    if(m>=b) cout<<0<<endl;
    
    if(m<b){
        if(m+f>=b) cout<<b-m<<endl;
        
        else cout<<"NA"<<endl;
    }
}


Measured memory_bytes: 3088
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>	
#include <cmath>
#include <string>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	vector<ll>a(3); cin >> a[0] >> a[1] >> a[2];
	if (a[0] % 2 == 0 || a[1] % 2 == 0 || a[2] % 2 == 0)cout << 0 << endl;
	else {
		cout <<min({ a[0]*a[1],a[0]*a[2],a[2]*a[1] })<< endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  string a;
  cin>>a;
  int answer=1;
  if(a=="RRR"){answer=3;}
  if(a=="SSS"){answer=0;}
  if(a=="RRS"){answer=2;}
  if(a=="SRR"){answer=2;}
  cout<<answer;
}

Measured memory_bytes: 3568
#include <iostream>
#include <string>

int main(){
    std::string s1, s2, s3;
    std::cin >> s1 >> s2 >> s3;

    std::string buf;
    std::cout << (char)(s1.at(0) - 32) << (char)(s2.at(0) - 32) << (char)(s3.at(0) - 32) << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MAXN 1000010
#define rep(i,n) for (int i = 0; i < (n); ++i)
const ll mod = 1e9+7;

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

bool pairCompare(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main() {
    ll n, a, b;

    cin >> n >> a >> b;

    ll ab = a+b;

    ll ans = a*(n / ab);

    ans += min(a, n % ab);

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <cstring>
#include <string>
#include <tuple>
#include <climits>
#include <cmath>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
const int INF = 987654321;
int dx[] = {-1,0,1,0};
int dy[] = {0,1,0,-1};
int main(){
    int n;
    string a;
    map<string,int> m;
    cin >> n;
    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;
    while(n--){
        cin >> a;
        m[a] = m[a]+1;
    }
    cout << "AC" << " x " <<  m["AC"] << endl;
    cout << "WA" << " x " <<  m["WA"] << endl;
    cout << "TLE" << " x " <<  m["TLE"] << endl;
    cout << "RE" << " x " <<  m["RE"] << endl;
}

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

using namespace std;

const int P = 1000000007;

long long power(long long x, long long t) {
	long long ret = 1;
	for(; t; t >>= 1, x = x * x % P) {
		if(t & 1) {
			ret = ret * x % P;
		}
	}
	return ret;
}

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

	int k;
	cin >> k;

	string s;
	cin >> s;

	int n = s.size();

	long long ans = 1;
	int m = 3000001;
	
	vector<long long> fac(m);
	fac[0] = 1;
	for(int i = 0; i + 1 < m; ++i) {
		fac[i + 1] = fac[i] * (i + 1) % P;
	}

	vector<long long> inv(m);
	inv[m - 1] = power(fac[m - 1], P - 2);
	for(int i = m - 1; i >= 1; --i) {
		inv[i - 1] = inv[i] * i % P;
	}

	auto C = [&] (int n, int m) {
		if(n < m) {
			return 0LL;
		}
		return fac[n] * inv[m] % P * inv[n - m] % P;
	};

	for(int i = 0; i <= k; ++i) {
		ans = (ans + C(n - 1 + i, n - 1) * power(25, i) % P * power(26, k - i)) % P;
	}

	cout << (ans - 1 + P) % P << '\n';

	return 0;
}


Measured memory_bytes: 51228
#include<bits/stdc++.h>
 
using namespace std;
#define int long long
#define MAX_V 600
#define INF (1<<28)
 
struct edge{
  int to,cap,rev;
  edge(){}
  edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};
vector<edge> G[MAX_V];
map<int,int> M[MAX_V];
int level[MAX_V];
int iter[MAX_V];
 
void add_edge(int from,int to,int cap){
  M[from][to] = G[from].size();
  M[to][from] = G[to].size();
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,G[from].size()-1));
}
 
void bfs(int s){
  memset(level,-1,sizeof(level));
  queue<int> que;
  level[s] = 0;
  que.push(s);
  while(!que.empty()){
    int v=que.front(); que.pop();
    for(int i=0;i<(int)G[v].size();i++){
      edge &e = G[v][i];
      if(e.cap > 0 && level[e.to]<0){
	level[e.to] = level[v] + 1;
	que.push(e.to);
      }
    }
  }
}
 
int dfs(int v,int t,int f){
  if(v == t) return f;
  for(int &i=iter[v];i<(int)G[v].size();i++){
    edge &e = G[v][i];
    if(e.cap > 0 && level[v]<level[e.to]){
      int d = dfs(e.to,t,min(f,e.cap));
      if(d>0){
	e.cap -= d;
	G[e.to][e.rev].cap += d;
	return d;
      }
    }
  }
  return 0;
}
 
int max_flow(int s,int t,int lim){
  int flow = 0;
  for(;;){
    bfs(s);
    if(level[t]<0||lim==0) return flow;
    memset(iter,0,sizeof(iter));
    int f;
    while((f=dfs(s,t,lim))>0){
      flow+=f;
      lim-=f;
    }
  }
}
 
int max_flow(int s,int t){
  return max_flow(s,t,INF);
}
 
signed main(){
  int N;
  cin>>N;
  for(int t=0;t<N;t++){
    for(int i=0;i<MAX_V;i++) G[i].clear(),M[i].clear();
    int W,H;
    cin>>W>>H;
    int c[H][W],d[H][W];
    int cnt[2]={},sum=0;
    int S=H*W,T=H*W+1;
    int ay[]={0,1,0,-1};
    int ax[]={1,0,-1,0};
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	cin>>c[i][j];
	d[i][j]=cnt[(i+j)%2]++;
	sum+=c[i][j];
      }
    }
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if((i+j)%2==0){
	  add_edge(S,d[i][j],c[i][j]);
	  for(int k=0;k<4;k++){
	    int ni=i+ay[k],nj=j+ax[k];
	    if(ni<0||H<=ni||nj<0||W<=nj) continue;
	    add_edge(d[i][j],cnt[0]+d[ni][nj],INF);
	  }
	}else{
	  add_edge(cnt[0]+d[i][j],T,c[i][j]);
	}
      }
    }
    if(H*W==1){
      cout<<"Case "<<t+1<<": "<<c[0][0]<<endl;
      continue;
    }
    cout<<"Case "<<t+1<<": "<<sum-max_flow(S,T)<<endl;
  }
  return 0;
}

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


Measured memory_bytes: 35652
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val SW = (0 until M).map { listOfInt().drop(1).map { 1 shl (it - 1) } }
    val P = listOfInt()
    var ans = 0
    for (n in 0 until (1 shl N)) {
//System.err.println(java.lang.Integer.toBinaryString(n))
        var d = 0
        SW.forEachIndexed { index, list ->
            var c = 0
            list.forEach {
//System.err.print("$index ${java.lang.Integer.toBinaryString(it)}")
                if (n and it != 0) c += 1
//System.err.println(" $c")
            }
            if (c % 2 == P[index]) d += 1
        }
//System.err.println(" d:$d")
        if (d == M) ans += 1
    }
    println(ans)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

Measured memory_bytes: 38244
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long ans = 0;
		long N1 = long.Parse(str[0]);
		if(N1==0){
			ans = 1;
		}
		long N2 = long.Parse(str[1]);
		if(N2==0){
			ans = 2;
		}
		long N3 = long.Parse(str[2]);
		if(N3==0){
			ans = 3;
		}
		long N4 = long.Parse(str[3]);
		if(N4==0){
			ans = 4;
		}
		long N5 = long.Parse(str[4]);
		if(N5==0){
			ans = 5;
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 17832
N, L = map(int, input().split())

pie = 0
min_abs = 10000
min_abs_apple = None
for i in range(N):
    if min_abs > abs(i + L):
        min_abs = abs(i + L)
        min_abs_apple = i + L
    pie += i + L

print(pie - min_abs_apple)

Measured memory_bytes: 2940
//-150 150暴力枚举：关键是边界值怎么试出来的？ 
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

ll quick_pow(int a, int b) {
    ll ans = 1, base = a;
    while (b) {
        if (b & 1)ans=ans*base;
   		base = base*base;
        b >>= 1;
    }
    return ans;
}



signed main()
{
	ll x;
	while(cin>>x){
		for(int i=-150;i<=150;i++)
		for(int j=-150;j<=150;j++){
			if(quick_pow(i,5)-quick_pow(j,5)==x){
				cout<<i<<" "<<j<<endl;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    if(a==b && a!=c)
        cout<<"Yes"<<endl;
    else if(b==c && a!=b)
        cout<<"Yes"<<endl;
    else if(a==c && a!=b)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A[3][3];
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
    	cin>>A[i][j];
    }
  }
  int n;
  cin>>n;
  int b[n];
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  if(n==2){
    cout<<"No"<<endl;
    return 0;
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
      	if(b[i]==A[j][k]){
        	A[j][k]=0;
      	}
      }
    }
  }
  for(int i=0;i<3;i++){
    if(A[i][0]==0 && A[i][1]==0 && A[i][2]==0){
          cout<<"Yes"<<endl;
          return 0;
        }
    for(int j=0;j<3;j++){
    	if(A[0][j]==0 && A[1][j]==0 && A[2][j]==0){
          cout<<"Yes"<<endl;
          return 0;
        }
    }
  }
  if(A[0][0]==0 && A[1][1]==0 && A[2][2]==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(A[0][2]==0 && A[1][1]==0 && A[2][0]==0){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3540
import java.util.Scanner;

public class Main{
	public static void main(String [] args){
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int  n = sc.nextInt();
			if(n == 0)break;
			int [] Point = new int [n];
			int max = -1, min = 10000000;
			int sum = 0;
			int av = 0;
			for(int i=0;i<n;i++){
				Point[i] = sc.nextInt();
				if(Point[i] >= max){
					max = Point[i];
				}
				if(Point[i] <= min){
					min = Point[i];
				}
				sum = sum + Point[i];
			}
			sum = sum -max -min;
			av =  sum/(n-2);
			System.out.println(av);
		}
	}
}

Measured memory_bytes: 20952
n,m = map(int,input().split())
A = [list(map(int,input().split())) for i in range(m)]

ma = 0
mi = float("INF")
for i in range(0,m):
    ma = max(ma,A[i][0])
    mi = min(mi,A[i][1])

ans = mi-ma+1
if ans >0:
  print(ans)
else :
  print(0)

Measured memory_bytes: 27332
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		String S = sc.next();
		StringBuilder sb = new StringBuilder(S);
		sb.replace(K-1, K, S.substring(K-1, K).toLowerCase());

		System.out.println(sb.toString());
	}

}

class FastScanner {
    private BufferedReader reader = null;
    private StringTokenizer tokenizer = null;

    public FastScanner(InputStream in) {
        reader = new BufferedReader(new InputStreamReader(in));
        tokenizer = null;
    }

    public String next() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(reader.readLine());
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
        return tokenizer.nextToken();
    }

    public String nextLine() {
        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                return reader.readLine();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }

        return tokenizer.nextToken("\n");
    }

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

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

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

    public int[] nextIntArray(int n) {
        int[] a = new int[n];
        for (int i = 0; i < n; i++)
            a[i] = nextInt();
        return a;
    }

    public long[] nextLongArray(int n) {
        long[] a = new long[n];
        for (int i = 0; i < n; i++)
            a[i] = nextLong();
        return a;
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <stack>
#include <limits>
#include <array>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <numeric>
#include <tuple>

constexpr long long mod = static_cast<long long>(1e9 + 7);


int main() {
    int V, E;
    std::cin >> V >> E;
    std::vector<std::vector<int>> edges(V);
    std::vector<int> cnts(V, 0);
    while(E--) {
        int s, t;
        std::cin >> s >> t;
        edges[s].push_back(t);
        ++cnts[t];
    }

    std::queue<int> que;
    for(int i = 0; i < V; ++i) {
        if(cnts[i] == 0) que.push(i);
    }

    std::vector<int> ans;
    ans.reserve(V);
    while(!que.empty()) {
        auto v = que.front();
        que.pop();
        ans.push_back(v);
        for(auto u: edges[v]) {
            --cnts[u];
            if(cnts[u] == 0) que.push(u);
        }
    }

    for(auto val: ans)
        std::cout << val << "\n";
    std::cout << std::flush;

    return 0;
}



Measured memory_bytes: 3684
import sys
n,y=map(int,input().split())
for i in range(y//10000+1):
  for j in range(y//5000+1):
    k=n-(i+j)
    if k<0:
      continue
    if 10000*i+5000*j+1000*k==y:
      print(' '.join([str(i),str(j),str(k)]))
      sys.exit()
print(' '.join(['-1','-1','-1']))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    
    string n;
    cin >> n;
    
    int a = int(n[int(n.size())-1]-'0');
    if(a == 3) cout << "bon" << endl;
    else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "hon" << endl;
    
    
    
    
    

    return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;
using li = __int128;
using uli = unsigned __int128;

#define fi first
#define se second

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

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

const int MAXN = 1e5 + 5;
int N, a[MAXN][3];
ll dp[MAXN][3];

int main() {
	ios_base::sync_with_stdio(0);

	cin >> N;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 3; j++) cin >> a[i][j];
	}
	dp[0][0] = a[0][0];
	dp[0][1] = a[0][1];
	dp[0][2] = a[0][2];
	for (int i = 1; i < N; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 3; k++) {
				if (j == k) continue;
				s_max(dp[i][j], dp[i - 1][k] + a[i][j]);
			}
		}
	}
	cout << *(max_element(dp[N - 1], dp[N - 1] + 3));

	return 0;
}

Measured memory_bytes: 7088
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long X = sc.nextLong();
    long ans = 0;
    for (int i = 0; i < N; i++) {
      long x = sc.nextLong();
      // 3値以上で最大公約数を求める
      ans = GCD(ans, Math.abs(x - X));
    }
    sc.close();
    System.out.println(ans);
  }

  public static long GCD(long a, long b) {
    if (b == 0) {
      return a;
    }
    return GCD(b, a % b);
  }

}


Measured memory_bytes: 46372
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main()
{
	int n,m;
	char sh[55][55];
	int d[9][2]={
		{-1,0},{-1,1},{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1}
	};
	scanf("%d %d",&n,&m);
	for(int i=0;i<n;i++)
		scanf("%s",sh[i]);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)
		{
			if(sh[i][j]=='.')
			{
				int s=0;
				for(int k=0;k<8;k++)
				{
					int x=i+d[k][0],y=j+d[k][1];
					if(x<n&&y<m)
					{
						if(sh[x][y]=='#')s++;
					}
				}
				sh[i][j]=s+48+'\0';
			}
		}
	}
	for(int i=0;i<n;i++)
	{
		printf("%s\n",sh[i]);
	}
	
	return 0;
}


Measured memory_bytes: 256
import sys
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H, W, K = IL()
a = [[i for i in S()] for i in range(H)]
#print(a)
data = [[-1]*(W) for _ in range(H)]
num = 1
for i in range(H):
  for j in range(W):
    if a[i][j] == "#":
      data[i][j] = num
      num += 1

for i in range(H):
  for j in range(1,W):
    if data[i][j] == -1:
      data[i][j] = data[i][j - 1]
for i in range(H-1,-1,-1):
  for j in range(W-2,-1,-1):
    if data[i][j] == -1:
      data[i][j] = data[i][j + 1]

for i in range(1,H):
  for j in range(W):
    if data[i][j] == -1:
      data[i][j] = data[i - 1][j]
for i in range(H-2,-1,-1):
  for j in range(W):
    if data[i][j] == -1:
      data[i][j] = data[i + 1][j]

for i in data:
  print(*i)

Measured memory_bytes: 51804