akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')
import time

#A
def A():
    s = S()
    t = S()
    ans = 0
    for i in range(3):
        if s[i] == t[i]:
            ans += 1
    print(ans)
    return

#B
def B():
    a, b = LI()
    ans = 0
    b -= 1
    while b > 0:
        b -= a - 1
        ans += 1
    print(ans)

    return

#C
def C():
    n = II()
    h = LI()
    i = 0
    ans = 0
    while i < n:
        down = i+1
        while down < n:
            if h[down - 1] >= h[down]:
                down += 1
            else:
                break
        ans = max(ans, down - i - 1)
        i = down
    print(ans)
    return

#D
def D():
    n = II()
    print(n * (n - 1) // 2)
    return

#E
def E():
    start = time.time()
    n = II()
    a = LIR_(n)
    ans = 0
    tern = [0] * n
    while 1:
        ans += 1
        f = True
        c = defaultdict(int)
        for i in range(n):
            if c[i]:
                continue
            if tern[i] == n - 1:
                continue
            rival = a[i][tern[i]]
            if c[rival]:
                continue
            if tern[rival] == n - 1:
                continue
            if a[rival][tern[rival]] == i:
                c[i] += 1
                c[rival] += 1
                tern[rival] += 1
                tern[i] += 1
                f = False
        if time.time() - start >= 1:
            print(n * (n - 1) // 2)
            return
        if f:
            if tern == [n - 1] * n:
                print(ans-1)
                return
            else:
                print(-1)
                return
    return

#F
def F():
    return

#Solve
if __name__ == '__main__':
    E()


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

int main() {
	int N, K;
	cin >> N >> K;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		ans += 2 * min(tmp, (K - tmp));
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;

}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) {
    return (ll)(log(x) / log(base));
}
vec v[100005]; ll dp1[100005],dp2[100005];
void dfs(ll x, ll p)
{
	ll y,z;
	y=v[x].size();
	rep(i,0,y)
	{
		z=v[x][i];
		if(z!=p)
		{
			dfs(z,x);
			dp1[x] = (dp1[x]*dp2[z])%mod;
			dp2[x] = (dp2[x]*((dp1[z]+dp2[z])%mod))%mod;
		}
	}
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll n,k,i,j,m,h,w;
    	cin>>n;
    	repi(i,1,n-1)
    	{
    		cin>>h>>w;
    		v[h].pb(w);
    		v[w].pb(h);
		}
		repi(i,1,n){
			dp1[i]=1;
			dp2[i]=1;
		}
		dfs(1,0);
		cout<<(dp1[1]+dp2[1])%mod;
	}
	return 0;
}












Measured memory_bytes: 18868
package main

import (
	"bufio"
	"fmt"
	"os"
)

var r = bufio.NewReader(os.Stdin)
var w = bufio.NewWriter(os.Stdout)

func main() {
	defer w.Flush()

	var n int
	fmt.Fscanf(r, "%d\n", &n)

	v := make([]int, n)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(r, "%d ", &v[i])
	}
	fmt.Fscanf(r, "%d\n", &v[n-1])

	c := make([]int, n)
	for i := 0; i < n-1; i++ {
		fmt.Fscanf(r, "%d ", &c[i])
	}
	fmt.Fscanf(r, "%d\n", &c[n-1])

	ans := 0
	for i := 0; i < n; i++ {
		if v[i]-c[i] > 0 {
			ans += v[i] - c[i]
		}
	}
	fmt.Fprintln(w, ans)
}


Measured memory_bytes: 640
N = gets.to_i
d = gets.chomp.split.map(&:to_i)

con = 0
ary = []

i = 0

while i < N - 1
	if  d[i].to_i >= d[i+1].to_i
	  con += 1
	  ary << con
	else
		con = 0
	end
	i += 1
end

if ary.empty?
  puts 0
else 
	puts ary.max
end

Measured memory_bytes: 10500
#include <bits/stdc++.h>
#define all(a) a.begin(), a.end()
#define db(a) cout << fixed << #a << " = " << a << endl;

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<pii> SSP;
	vector<pii> SSN;
	for (int i = 0; i < n; i++) {
		string S;
		cin >> S;
		int L = 0;
		int R = 0;
		for (char c : S) {
			if (c == '(') {
				L++;
			} else {
				if (L == 0) {
					R++;
				} else {
					L--;
				}
			}
		}
		//cout << L << " "<< R << endl;
		if (L > R) SSP.emplace_back(L, R);
		else  SSN.emplace_back(L, R);
	}
	sort(SSP.begin(), SSP.end(), [](const pii& a, const pii& b) -> bool
	{
		return a.second < b.second;
	});
	sort(SSN.begin(), SSN.end(), [](const pii& a, const pii& b) -> bool
	{
		return a.first > b.first;
	});
	
	int L = 0;
	for (pii& s: SSP) {
		if (L >= s.second) {
			L -= s.second;
			L += s.first;
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	for (pii& s: SSN) {
		if (L >= s.second) {
			L -= s.second;
			L += s.first;
		} else {
			cout << "No" << endl;
			return 0;
		}
	}
	
	if (L == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}



Measured memory_bytes: 11228
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

int main() {
  ll n;
  cin >> n;
  vector<vector<pll>> a(n);
  for(ll i=0;i<n;i++) {
    ll k;
    cin >> k;
    while(k--) {
      ll x,y;
      cin >> x >> y;
      x--;
      a[i].push_back({x,y});
    }
  }
  ll ans=0;
  for(ll i=0;i<(1<<n);i++) {
    ll f=0;
    ll tans=0;
    for(ll j=0;j<n;j++) {
      if((i>>j)&1) {
        tans++;
        for(ll k=0;k<a[j].size();k++) {
          if(((i>>a[j][k].first)&1)!=a[j][k].second) {
            f=1;
            break;
          }
        }
      }
      if(f) break;
    }
    if(!f) ans=max(ans,tans);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

int main(void){
    int S,h,m,s = 0;

    std::cin >> S;
    
    if((0 <= S) && (S < 86400)){
    
        s = S % 60;// 秒
        m = (S / 60) % 60;// 分
        h = S / 3600;// 時
    
    }
    
    std::cout << h << ":" << m << ":" << s << std::endl;
    
    return 0;

}


Measured memory_bytes: 3100
#include <stdio.h>
int main(void)
{
        int a,i;
        char S[100],T[100];
        scanf("%d",&a);
        scanf("%s%s",S,T);
        for(i=0;i<a;i++) printf("%c%c",S[i],T[i]);
        printf("\n");
        return 0;
}


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

using namespace std;

int H,W,h,w;

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

  int P,Q;

  if(H%h!=0){
    cout<<"Yes"<<endl;
    int N=H/h; 
    int plus=100000;
    int minus=-plus/(h-1)-1;

    int c=h-1;

  for(int j=0; j<H; j++){

  if(c==h-1){
      for(int i=0; i<W; i++){
          printf("%d ", plus);
      }
        c=0; 
  }
  else{
      for(int i=0; i<W; i++){
      printf("%d ", minus);
      }
      c++;
  }
  cout<<endl;
  }

  return 0;

  }

  else if(W%w!=0){

    cout<<"Yes"<<endl;
    int N=W/w; 
    int plus=100000;
    int minus=-plus/(w-1)-1;

  for(int j=0; j<H; j++){

    int c=w-1;

    for(int i=0; i<W; i++){
          if(c==w-1){
            printf("%d ", plus);
            c=0;
          }
          else{
            printf("%d ", minus);
            c++;
          }

      }
       cout<<endl;
  }

  return 0;
  }
  else{
    cout<<"No"<<endl;
  }

}

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

int main()
{
	std::string s;
	std::cin >> s;
	int count[2]{};
	for (unsigned int i{}; i < s.size(); i++)
		if (s[i] != '0' + i % 2)
			count[0]++;
	
	for (unsigned int i{}; i < s.size(); i++)
		if (s[i] != '1' - i % 2)
			count[1]++;
	printf("%d\n", std::min(count[0], count[1]));

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
#define ll long long
int dp[100100];
int cnt = 0;
map<string,int> ma;
signed main() {
  int n;
  cin >> n;
  int ans = 0;
  rep(i,n) {
    string str;
    cin >> str;
    ma[str]++;
  }
  int mm = 0;
  for(auto m: ma) {
    mm = max(m.second,mm);
  }
  vector<string> str;
  for(auto m: ma) {
    if(mm==m.second) {
      str.push_back(m.first);
    }
  }
  sort(str.begin(),str.end());
  for(auto m: str) cout << m << endl;

  return 0;
}

Measured memory_bytes: 27300
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int w, h, x, y;
    cin >> w >> h >> x >> y;

    double ans;
    ans = (double)w*h/2.0;
    int a = 0;
    if (2*x==w && 2*y==h) {
        a = 1;
    }
    printf("%lf %d\n", ans, a);
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, a; char b; cin >> n >> b >> a;
	if (b == '+') {
		cout << n + a << endl;
	}
	else {
		cout << n - a << endl;
	}
	cin >> n;
}

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

bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}
// 入力



int main() {
    ll N;
    cin >>N;
    vector<vector<ll>> t(N);
    vector<pair<ll,ll>> ab(N-1);
    vector<ll> ans(N-1);
    map<Pi,ll> m;
    rep(i,N-1){
        ll a,b;
        cin >>a>>b;
        a--;b--;
        t[a].pb(b);
        t[b].pb(a);
        ab[i].first = a;
        ab[i].second = b;
        m[mp(a,b)]=i;
        m[mp(b,a)]=i;
    }
    ll K = 0;
    rep(i,N){
        ll s = t[i].size();
        chmax(K,s);
    }

    vector<ll> dist(N,-1);
    queue<Pi> que;

    dist[0] = 0;
    que.push(mp(0,-1));

    while(!que.empty()){
        Pi p = que.front();
        ll v=p.first;
        ll n=p.second; 
        que.pop();
        ll cnt=0;
        for(ll i : t[v]){
            if(dist[i] !=-1) continue;
            if(cnt==n){
                cnt++;
            }
            ans[m[mp(v,i)]]=cnt;
            dist[i] = dist[v] + 1;
            que.push(mp(i,cnt));
            cnt++;
        }
    }


    cout<<K<<endl;
    rep(i,N-1){
        cout<<ans[i]+1<<endl;
    }



    return 0;
    

}

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

using namespace std;

const int MAX_N = 300, MAX_M = 300;
int n, m;
int a[MAX_N][MAX_M];

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

  vector<bool> valid(m, true);
  int min_q = INT_MAX;
  for (int i = 0; i < m; i++) {
    vector<int> ctr(m, 0);
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < m; k++) {
        if (valid[a[j][k]-1]) {
          ctr[a[j][k]-1]++;
          break;
        }
      }
    }
    int mi = max_element(ctr.begin(), ctr.end()) - ctr.begin();
    min_q = min(min_q, ctr[mi]);
    valid[mi] = false;
  }

  cout << min_q << endl;

  return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
bool judge(int x, int y, int z, int sum){
    if((10000 * x + 5000 * y + 1000 * z) == sum){
        return true;
    }
    return false;  
}

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

    // N枚でY円を判定する
    int ansI = -1,
        ansJ = -1,
        ansK = -1;
    for(int i=0; i<=N; i++){
        for(int j=0; j<=N; j++){
            int k = N-i-j;
            if(k < 0){
                continue;
            }
            if(judge(i, j, k, Y)){
                ansI = i;
                ansJ = j;
                ansK = k;
                break;
            }
        }
    }
    cout << ansI << " " << ansJ << " " << ansK << endl;
}



Measured memory_bytes: 256
#include<stdio.h>

int main()
{
	int N, M, C;
	int A[21][21], B[21];
	int ans = 0;
	
	scanf("%d %d %d", &N, &M, &C);
	for (int j = 0;j < M;j++)
	{
		scanf("%d", &B[j]);
	}

	for (int i = 0;i < N;i++)
	{
		int hikaku = 0;
		for (int j = 0;j < M;j++)
		{
			scanf("%d", &A[i][j]);
			hikaku += (A[i][j] * B[j]);
		}
		if ((hikaku+C) > 0)ans++;
	}
	printf("%d\n", ans);


	return 0;
}

Measured memory_bytes: 128
program counting_of_trees
  implicit none
  integer(8), parameter :: md = 998244353_8
  integer :: n, d(100000) = 0, a(0:100000) = 0, i
  integer(8) :: x = 1_8
  read(*,*) n
  read(*,*) d(1:n)
  do i = 1, n
    a(d(i)) = a(d(i))+1
  end do
  if (d(1) /= 0 .or. a(0) /= 1) then
    write(*,'(i0)') 0
    stop
  end if
  do i = 1, n
    x = mod(x*pow(int(a(i-1),8),a(i)),md)
  end do
  write(*,'(i0)') x
contains
  function pow(a,b) result(ret)
    integer(8), intent(in) :: a
    integer, intent(in) :: b
    integer :: k
    integer(8) :: ret, p
    ret = 1_8
    p = a
    k = b
    do while (k > 0)
      if (btest(k,0)) ret = mod(ret*p,md)
      p = mod(p*p,md)
      k = rshift(k,1)
    end do
  end
end program counting_of_trees

Measured memory_bytes: 1536
#include<bits/stdc++.h>
using namespace std;
int n;
int a[100000];
int main() {
	cin >> n;
	int ans1 = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		a[i] *= 2;
		ans1 = max(ans1, a[i]);
	}
	int ans2 = 10000;
	int sub = 100000000000;
	for (int i = 0; i < n; i++) {
		if (abs(ans1 / 2 - a[i]) < sub) {
			if (ans1 == a[i])continue;
			ans2 = a[i];
			sub = abs(ans1 / 2-a[i]);
		}
	}
	cout << ans1 / 2 << " " << ans2 / 2 << endl;
	return 0;
}


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

#define ll long long
#define mk make_pair

template <class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
const ll mod = 1e9 + 7;


void solve()
{
    ll n,k;
    cin>>n>>k;
    vector<ll>x(k), p; 
    for(int i=0;i<k;i++)
    {   
        cin>>x[i];
    }
    
    ll ans=0;
    for(int i=1;i<k;i++)
    {
        p.push_back(x[i]-x[i-1]);
    }
    p.push_back((n-x[k-1])+x[0]);
    sort(p.begin(), p.end());
    for(int i=0;i<k-1;i++)
    {
        ans+=p[i];
    }
    cout<<ans<<endl;
}

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

    // ll t;
    // cin >> t;

    // while (t--)
    // {
    //     solve();
    // }
    solve();
    return 0;
}

Measured memory_bytes: 3956
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n, r[200], s[200], t[200], u[200], dp[200];
long long gcd(int a, int b) { if (b == 0)return a; return gcd(b, a%b); }
long long dfs(int p) {
	if (dp[p] >= 0)return dp[p];
	if (p == 0)return 1;
	long long J1 = dfs(t[p]), J2 = dfs(u[p]);
	long long m1 = r[p] * J1, m2 = s[p] * J2;
	long long r1 = m2 / gcd(m1, m2), r2 = m1 / gcd(m1, m2);
	long long r3 = gcd(r1, r2); r1 /= r3; r2 /= r3;
	long long minx = J1*r1 + J2*r2;
	dp[p] = minx;
	return minx;
}
int main() {
	while (cin >> n, n) {
		for (int i = 0; i <= n; i++)dp[i] = -1;
		for (int i = 1; i <= n; i++) { cin >> r[i] >> s[i] >> t[i] >> u[i]; int H = gcd(r[i], s[i]); r[i] /= H; s[i] /= H; }
		long long maxn = 0; for (int i = 1; i <= n; i++)maxn = max(maxn, dfs(i));
		cout << maxn << endl;
	}
	return 0;
}

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

int in(){
  int a;
  cin >> a;
  return a;
}//int型関数の受け取り

void forin(int* x,int y){
  for (int i=0;i<y;i++){
    cin >> x[i];
  }
}//(x,y) int型配列x[y]の受け取り

int intpow(int x,int y){
  double a=x,b=y;
  return pow(a,b);
}//(x,y) xをy乗

int intfabs(int x){
  double a=x;
  return fabs(a);
}//(x) xの絶対値

int fact(int x){
  if (x == 1) return 1;
  return x*fact(x-1);
}//(x) x!

main(){
 int n=in(),i2;
 string s,t;
 cin >> s >> t;
 for (int i=0;i<n;i++){
   for(i2=0;i2+i<n;i2++){
     if (s.at(i+i2)!=t.at(i2)) break;
   }
   if (i2+i==n) {
     cout << n+i << endl;
     return 0;
   }
 }
 cout << n*2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

    char pre = '*';
    bool ans = true;
    set<string> used;
    for (int i=0; i<n; i++) {
        string w;
        cin >> w;
        if (used.find(w) != used.end()) ans = false;
         used.insert(w);
        if (pre != '*' && w[0] != pre) ans = false;
        pre = w.back();
    }

    cout << (ans? "Yes" : "No") << endl;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define IOS ios_base::sync_with_stdio(false);cin.tie(0)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define int long long
const int MOD=1e9+7;
int pow(int a, int b, int m)
{
    int ans=1;
    while(b)
    {
        if(b&1)
            ans=(ans*a)%m;
        b/=2;
        a=(a*a)%m;
    }
    return ans;
}
int invmod(int x) {return pow(x,MOD-2);}
int min(int x,int y){if(x>y) return y;else return x;}
int max(int x,int y){if(x>y) return x;else return y;}

int32_t main()
{
    string s;
    cin>>s;
    int m[28]={0};
    for(int i=0;i<s.size();i++)
    {
        m[s[i]-'a']++;
    }
    for(int i=0;i<26;i++)
    {
        if(m[i]==0)
        {
            cout<<char(i+'a')<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    
  
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main{

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int sum = 0;
		int[] array = new int[5];
		int[] count = new int[5];
		int max = 0;

		for(int i=0;i<5;i++) {
			array[i] = scan.nextInt();
		}

		boolean flg = true;
		for(int i=0;i<5;i++) {
		while(true) {
			if(array[i] % 10 == 0) {
				sum += array[i];
				flg = false;
				break;
			 }else {
				array[i]++;
				count[i]++;
			 }
			}
		}

		for(int i=0;i<5;i++) {
			max = Math.max(max, count[i]);
		}

		System.out.println(sum-max);
		scan.close();
	}

}


Measured memory_bytes: 27076
/*
如果长宽高有一个是偶数，那没差，绝对是0。
如果倒霉催的全是奇数，那么输出面积最小的一面。
*/
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c;
    cin>>a>>b>>c;
    if(a%2==0 || b%2==0 || c%2==0)
    {
        cout<<0<<endl;
        return 0;
    }
    else
    {
        cout<<min(min(a*b,a*c),b*c)<<endl;
        return 0;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pint = pair<int, int>;
using ll = long long;
using ull = unsigned long long;
using vll = vector<long long>;
using pll = pair<ll, ll>;
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define VREP(s, ite) for (auto ite = s.begin(); ite != s.end(); ++ite)
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
//#define endl "\n"
#define ciosup  \
    cin.tie(0); \
    ios::sync_with_stdio(false);
#define eb emplace_back
#define vint vector<int>
constexpr ll INF = 1e15 + 7LL;
constexpr ll MOD = 998244353;

template <typename T>
istream &operator>>(istream &is, vector<T> &v)
{
    for (int i = 0; i < v.size(); ++i)
    {
        is >> v[i];
    }
    return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    for (int i = 0; i < v.size() - 1; ++i)
    {
        os << v[i] << " ";
    }
    if (v.size() > 0)
    {
        os << v[v.size() - 1] << endl;
    }
    return os;
}

ll my_pow(ll n, ll m){
    ll ans = 1;
    while (m > 0)
    {
        if (m & 1){
            ans = ans * n % MOD;
        }
        n = n * n % MOD;
        m >>= 1;
    }
    return ans;
}

int main()
{
    int n, tmp;
    cin >> n;
    vint d(n-1);
    cin >> tmp;
    if (tmp != 0){
        cout << 0 << endl;
        return 0;
    }
    cin >> d;
    vll kazu(n, 0);
    REP(i,n-1){
        kazu[d[i]]++;
    }
    if (kazu[0] != 0)
    {
        cout << 0 << endl;
        return 0;
    }
    ll totnode = 0;
    ll ans = 1, prevnodenum = 1;
    FOR(i, 1, n)
    {
        if (kazu[i] == 0){
            break;
        }
        totnode += kazu[i];
        ans = (ans *my_pow(prevnodenum,kazu[i])) % MOD;

        prevnodenum = kazu[i];
    }
    if (totnode < n - 1){
        cout << 0 << endl;
        return 0;
    }
    cout << ans << endl;
}

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

/* -128 ~ 127 */
using i8  = int8_t;
/* 0 ~ 255 */
using u8  = uint8_t;
/* -32,768 ~ 32,767 */
using i16 = int16_t;
/* 0 ~ 65,535 */
using u16 = uint16_t;
/* -2,147,483,648 ~ 2,147,483,647 */
using i32 = int32_t;
/* 0 ~ 4,294,967,295 */
using u32 = uint32_t;
/* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using i64 = int64_t;
/* 0 ~ 18,446,744,073,709,551,615 */
using u64 = uint64_t;
/* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f32 = float;
/* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f64 = double;
using f80 = __float80;

template <class T>
using Vec = vector<T>;

template <typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

/* 定数 */
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;

#define fn auto
#define ALL(v) v.begin(), v.end()

fn Main() {
    i64 N, K;
    cin >> N >> K;
    i64 m = N / K;
    if (m == N) {
        if (K == 1) {
            cout << 0 << endl;
            return;
        }
        m = (N - m < m)? K - m: m;
        cout << m << endl;
        return;
    }
    N = N - (K * m);
    N = (K - N < N)? K - N: N;
    cout << N << endl;
}

fn main() -> int {
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 256
n,m = map(int,input().split())
ans = []
for i in range(n):
    ans.append(0)
for k in range(m):
    s,c = map(int,input().split())
    if c == 0:
        c = 10    
    if ans[s-1] == 0 or ans[s-1] == c:
        ans[s-1] = c
    else:
        print('-1')
        exit()
if n != 1:
    if ans[0] == 10:
        print('-1')
        exit()
ans = [str(s) for s in ans]
if n != 1:
    if ans[0] == "0":
       ans[0] = "1"
ans = [s.replace("10","0") for s in ans]
print("".join(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    if(b%a==0){
        cout<<a+b<<endl;
    }
    else cout<<b-a<<endl;
}
//＼(^q^)／ｵﾜﾀ


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

using namespace std;

int main(int argc, char** argv){
    int N;
    string c;
    cin >> N >> c;
    int nR = 0;
    for (int i=0; i<N; i++) if (c[i] == 'R') nR++;
    int nW = 0;
    for (int i=0; i<nR; i++) if (c[i] == 'W') nW++;

    int ans = nW;
    // if (nR >= N - nR) ans = nW;
    // else ans = nR - nW;
    cout << ans << "\n";

    return 0;
}


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

int main(){
	string O,E;
	cin >> O;
	cin >> E;
	char pass[O.length()+E.length()+1];
	for(int i=0;i<O.length();i++){
		pass[2*i]=O[i];
	}
	for(int i=0;i<E.length();i++){
		pass[2*i+1]=E[i];
	}
	pass[O.length()+E.length()]=0;
	cout << pass << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = []
for _ in range(n):
    a.append(int(input()))
if a[0]>0:
    print(-1)
    exit(0)
ans = 0
for i in range(n-1):
    if a[i]+1<a[i+1]:
        print(-1)
        exit(0)
    if a[i]>=a[i+1]:
        ans += a[i]
ans += a[-1]
print(ans)

Measured memory_bytes: 11052
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;

namespace LogicSummoner
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var n = GetNumber();
                if (n == 0)
                {
                    break;
                }

                var scores = GetNumbersInt(n);
                var avg = scores.Average();
                var d = Math.Sqrt(scores.Sum(s => (s - avg) * (s - avg)) / n);
                System.Console.WriteLine(d.ToString("F8"));
            }
        }

        //static StreamReader Console = new StreamReader("input.txt");

        static int GetNumber()
        {
            return int.Parse(Console.ReadLine().Trim());
        }

        static double GetDounble()
        {
            return double.Parse(Console.ReadLine().Trim());
        }

        static int[] GetNumbersInt(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => int.Parse(x)).ToArray();
        }

        static long[] GetNumbersLong(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => long.Parse(x)).ToArray();
        }

        static double[] GetNumbersDouble(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).Select(x => double.Parse(x)).ToArray();
        }

        static string[] GetStrings(int n = 0)
        {
            return Console.ReadLine().Trim().Split(new[] { " " }, StringSplitOptions.RemoveEmptyEntries).ToArray();
        }
    }
}

Measured memory_bytes: 10268
#include "bits/stdc++.h"
using namespace std;

////////////// Prewritten code follows. Look down for solution. ////////////////
#define x first
#define y second
#define len(x) ((int)(x).size())
using pii = pair<int, int>;
using ll = long long;
using llu = long long unsigned;
using ld = long double;

const ld EPS = 1e-9;
inline int cmp(ld x, ld y = 0, ld tol = EPS) {
	return (x <= y + tol) ? (x + tol < y) ? -1 : 0 : 1;
}

const int MOD = 1;
inline int mod (ll x, int m = MOD) {
	return (int)(((x%m) + m)%m);
}

////////////////////////// Solution starts below. //////////////////////////////

const int INF = 1e9 + 1e3;
const int N = 1e5+10;

int n, k;
int a[N], dp[N];

int main () {
	scanf ("%d %d", &n, &k);
	for (int i = 1; i <= n; i++) {
		scanf ("%d", &a[i]);
		dp[i] = INF;
	}
	dp[1] = 0;
	for (int i = 1; i <= n; i++)
		for (int nxt = i+1; nxt-i <= k and nxt <= n; nxt++)
			dp[nxt] = min (dp[nxt], dp[i] + abs (a[i]-a[nxt]));
	
	printf ("%d\n", dp[n]);

	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.141592653589793238
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      dbl r;
      cin >> r;
      cout << fixed << setprecision(20) << (2*PI*r);
      return 0;
}

Measured memory_bytes: 3804
//2018.9.12 by ljz
#include<bits/stdc++.h>
using namespace std;
#define res register LL
#define LL long long
#define inf 0x3f3f3f3f
#define eps 1e-15
inline LL read(){
    res s=0;
    bool w=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')w=1;ch=getchar();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=getchar();
    return w?-s:s;
}
inline void _swap(res &x,res &y){
    x^=y^=x^=y;
}
inline int _abs(const res &x){
    return x>0?x:-x;
}
inline int _max(const res &x,const res &y){
    return x>y?x:y;
}
inline int _min(const res &x,const res &y){
    return x<y?x:y;
}
namespace MAIN{
    LL n,x;
    LL calc(res n,res x){
        if(!x)return -n;
        res d=n%x;
        return calc(x,d)+(n/x)*2*x;
    }
    LL ans;
    inline void MAIN(){
        n=read(),x=read();
        ans=n;
        ans+=calc(n-x,x);
        printf("%lld\n",ans);
    }
}
int main(){
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

void swap(int *a, int *b){
	int t = *a;
	*a = *b;
	*b = t;
}

int main(void){
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	if (b > c) swap(&b, &c);	
	if (a > b) swap(&a, &b);
	if (b > c) swap(&b, &c);
	printf("%d %d %d\n", a, b, c);
	return 0;
}

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

using namespace std;
#define vsort(v) sort(v.begin(), v.end())
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, X;
	cin >> N >> X;
	vector<int> m;
	int total = 0;
	int ans = 0;
	for(int i = 0; i < N; i++) {
		int tmp;
		cin >> tmp;
		m.push_back(tmp);
		total += m[i];
	}
	if(X >= total) {
		X -= total;
		ans += N;
	} else {
		cout << 0 << endl;
		return 0;
	}

	vsort(m);
	ans += (X / m[0]);
	cout << ans << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int64_t const M = 1e9+7;

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int> x(N);
  for(int i = 0; i < N; ++i) std::cin >> x[i];
  std::map<int,int> m;
  int count = 0;
  for(int i = 0; i < N; ++i) {
    ++m[i-count];
    if(x[i] >= count*2+1) ++count;
  }
  count = 0;
  int64_t ans = 1;
  for(int t = 0; t < N; ++t) {
    if(m.count(t)) count += m[t];
    (ans *= count) %= M;
    --count;
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 2944
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();

		if (A + B == 3) {
			System.out.print(3);

		} else if (A + B == 4) {
			System.out.print(2);

		} else {
			System.out.print(1);

		}
sc.close();
	}
}

Measured memory_bytes: 35716
import java.util.*;

public class Main{
    
    static final int MOD = (int)1e9+7;
    static final int MAX = (int)1e5+5;
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        
        boolean[][] s = new boolean[h][w];
        for(int i=0; i<h; i++){
            String line = sc.next();
            for(int j=0; j<w; j++){
                s[i][j] = line.charAt(j)=='.';
            }
        }
        
        int max = -1;
        ArrayDeque<Integer> q = new ArrayDeque<>();
        int[][] dist = new int[h][w];
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(!s[i][j]){
                    continue;
                }
                
                q.addFirst(i*w+j);
                for(int[] d : dist){
                    Arrays.fill(d, MAX);
                }
                dist[i][j] = 0;
                while(q.size()!=0){
                    int now = q.pollLast();
                    int x = now%w;
                    int y = now/w;
                    int nowdist = dist[y][x];
                    if(y+1<h && s[y+1][x] && dist[y+1][x]>nowdist+1){
                        q.add((y+1)*w+x);
                        dist[y+1][x] = nowdist+1;
                    }
                    if(y-1>=0 && s[y-1][x] && dist[y-1][x]>nowdist+1){
                        q.add((y-1)*w+x);
                        dist[y-1][x] = nowdist+1;
                    }
                    if(x+1<w && s[y][x+1] && dist[y][x+1]>nowdist+1){
                        q.add(y*w+x+1);
                        dist[y][x+1] = nowdist+1;
                    }
                    if(x-1>=0 && s[y][x-1] && dist[y][x-1]>nowdist+1){
                        q.add(y*w+x-1);
                        dist[y][x-1] = nowdist+1;
                    }
                }
                
                for(int y=0; y<h; y++){
                    for(int x=0; x<w; x++){
                        if(max < dist[y][x] && s[y][x]){
                            max = dist[y][x];
                        }
                    }
                }
            }
        }
        
        System.out.println(max);
    }
}


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

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))

#define MOD 1000000007
#define INF 1000000000
#define MAX_N 55

ll N, P;
ll dp[MAX_N][2];
ll A[MAX_N];

// i から見始めて現在の余りが j の時のパターン数
ll search(ll i, ll j) {
    if(i >= N) {
        if(j == P) { return 1; }
        return 0;
    }
    ll ret = 0;
    if((j % 2) == (j + A[i]) % 2) {
        ret += search(i+1, (j % 2));
        ret += search(i+1, (j % 2));
    } else {
        ret += search(i+1, 1);
        ret += search(i+1, 0);
    }
    return ret;
}

int main()
{
    ZERO(dp);
    ZERO(A);

    cin >> N >> P;
    REP(i, N) { cin >> A[i]; }

    dp[N][P] = 1;
    for(ll i = N - 1; i >= 0; --i) {
        REP(j, 2) {
            if((j % 2) == (j + A[i]) % 2) {
                dp[i][j] += dp[i+1][j % 2];
                dp[i][j] += dp[i+1][j % 2];
            } else {
                dp[i][j] += dp[i+1][1];
                dp[i][j] += dp[i+1][0];
            }
        }
    }

    printf("%lld\n", dp[0][0]);

    return 0;
}


Measured memory_bytes: 256
import sys,queue,math,copy,itertools,bisect,collections,heapq

def main():
    NI = lambda : int(sys.stdin.readline())

    N = NI()

    ans = N * (N+1) - 1
    for i in range(2,int(math.sqrt(N))+1):
        ans += i*i
        j = i + 1
        while i * j <= N:
            ans += 2 * i * j
            j += 1

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 75152
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        try (Scanner sc = new Scanner(System.in);) {
            solve(sc);
        }
    }

    public static void solve(Scanner sc) {
        char[] string = sc.nextLine().toCharArray();
        int[] count = new int[26];
        for (char c : string) {
            if (count[c - 'a'] == 1) {
                System.out.println("no");
                return;
            }
            count[c - 'a']++;
        }

        System.out.println("yes");
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  int N;  cin>>N;
  string s;
  cin>>s;
  int j=N-1;
  ll cnt=0;
  rep(i,0,N){
    while(s[j]!='R' && j>=0) j--;
    if(j<=i) break;
    if(s[i]=='W' && s[j]=='R'){
      cnt++;
      swap(s[i], s[j--]);
    }
  }
  cout<<cnt<<endl;
  return 0;
}


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

int main(){
    int N,K; cin  >> N >> K;
    string s; cin >> s;
    vector<int> num;
    if(s[0]=='0') num.push_back(0);

    for(int left=0;left<N;){
        int right=left;
        while(right<N&&s[right]==s[left]){
            right++;
        }
        num.push_back(right-left);
        left=right;
    }//連続した数を尺取りで記録
    if(s.back()=='1') s.push_back('0');

    vector<int> sum(num.size()+1,0);
    for(int i=0;i<num.size();i++){
        sum[i+1]=sum[i]+num[i];
    }//累積和

    /*
    for(int i=0;i<sum.size();i++){
        cout << sum[i] << endl;
    }
    */

    int ans=0;
    for(int left=0;left<sum.size();left+=2){
        int right=left+2*K+1;
        //cout << right << endl;
        if(right>=sum.size()) right=sum.size()-1;
        ans=max(ans,sum[right]-sum[left]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int combi(int n, int r){
    int num = 1;
    for(int i=1; i<=r; i++){
        num = num*(n-i+1)/i;
    }
    return num;
}
int main(){
    int n,m;cin>>n>>m;
    int cnt=0; 
    n = combi(n,2);
    m = combi(m,2);
    cout<<n+m<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll


int f(int a,int b){
    stringstream x,y;
    x<<a;
    y<<b;
    return max(x.str().size(),y.str().size());
}


signed main(){
    int n;
    cin>>n;
    
    int ans = INF;
    for(int i=1;i<=sqrt(n)+1;i++){
        if(n%i!=0)continue;
        ans = min(ans,f(i,n/i));
    }
    cout<<ans<<endl;
}


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

	int coins[6] = { 500,100,50,10,5,1 };
int main() {
	while (1)
	{
	int n, ans = 0;
	cin >> n;
	if (n == 0)break;
	n = 1000 - n;
	for (int i = 0; i < 6; i++)
	{
		ans += n / coins[i];
		n %= coins[i];
	}
	cout << ans << endl;
	}
	return 0;
}

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

int main() {
  vector<int> card(9);
  for(int i=0; i<9; i++){
    cin >> card.at(i);
  }
  vector<int> line1(3);
  vector<int> line2(3);
  vector<int> line3(3);
  vector<int> line4(3);
  vector<int> line5(3);
  vector<int> line6(3);
  vector<int> line7(3);
  vector<int> line8(3);
  for(int i=0; i<3; i++){
    line1.at(i) = card.at(i);
    line2.at(i) = card.at(i+3);
    line3.at(i) = card.at(i+6);
    line4.at(i) = card.at(3*i);
    line5.at(i) = card.at(3*i+1);
    line6.at(i) = card.at(3*i+2);
    line7.at(i) = card.at(4*i);
    line8.at(i) = card.at(2*i+2);
  }
  
  int N;
  cin >> N;
  vector<int> number(N);
  for(int i=0; i<N; i++){
    cin >> number.at(i);
  }
  bool check = false;
  int count1 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line1.at(j) == number.at(i)){
        count1 ++;
      }
    }
  }
  if(count1 == 3){
    check = true;
  }
  int count2 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line2.at(j) == number.at(i)){
        count2 ++;
      }
    }
  }
  if(count2 == 3){
    check = true;
  }
  int count3 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line3.at(j) == number.at(i)){
        count3 ++;
      }
    }
  }
  if(count3 == 3){
    check = true;
  }
  int count4 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line4.at(j) == number.at(i)){
        count4 ++;
      }
    }
  }
  if(count4 == 3){
    check = true;
  }
  int count5 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line5.at(j) == number.at(i)){
        count5 ++;
      }
    }
  }
  if(count5 == 3){
    check = true;
  }
  int count6 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line6.at(j) == number.at(i)){
        count6 ++;
      }
    }
  }
  if(count6 == 3){
    check = true;
  }
  int count7 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line7.at(j) == number.at(i)){
        count7 ++;
      }
    }
  }
  if(count7 == 3){
    check = true;
  }
  int count8 = 0;
  for(int i=0; i<N; i++){
    for(int j=0; j<3; j++){
      if(line8.at(j) == number.at(i)){
        count8 ++;
      }
    }
  }
  if(count8 == 3){
    check = true;
  }
  
  if(check){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; typedef long long int ll;
#define all(a) a.begin() , a.end()
#define print(x)   cout<<x<<"\n";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; if (i != v.size() - 1) os << ", "; } os << "]\n"; return os;}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& v)
{os << "["; for (auto it : v) {os << it; if (it != *v.rbegin())os << ", ";} os << "]\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v)
{for (auto it : v)os << it.first << " : " << it.second << "\n"; return os;}
template <typename T, typename S>
ostream& operator<<(ostream& os, const pair<T, S>& v)
{os << "("; os << v.first << ", " << v.second << ")"; return os;}
/*******************************************************************************/
#define pi 3.14159265358979323846264338327950L
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);    freopen("output.txt", "w", stdout);
#endif

    long long a, b, h, m;
    cin >> a >> b >> h >> m;
    long double angle = abs((30.0 * h + m * 0.5) - (6.0 * m));
    if (angle > 180.0)
        angle = 360.0 - angle;
    double long cs = (a * a) + (b * b) - 2 * a * b * cos(angle * pi / 180);
    cs = sqrt(cs);
    cout << fixed << setprecision(20) << cs << '\n';
}

Measured memory_bytes: 4120
void main(){
	string[] val = inln!string();
	bool a = (val[0]=="H")?true:false;
	bool b = (val[1]=="H")?true:false;
	bool ans = a^b;
	writeln(( (a^b)==false)?'H':'D');

}
     
import std.stdio, std.conv, std.algorithm, std.numeric, std.string, std.math, std.range;
const long mod = 10^^9+7;      
// 1要素のみの入力
T inelm(T= int)(){
	return to!(T)( readln().chomp() );
}
     
// 1行に同一型の複数入力
T[] inln(T = int)(){
	T[] ln;
	foreach(string elm; readln().chomp().split())ln ~= elm.to!T();
	return ln;
}


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

int main()
{
    char ch[10];
    int n,m;
    int i,s;
    char c;
    int flag=0;
    
    for(i=0;i<10;i++)
    {
        ch[i]='*';
    }
    
    scanf("%d %d",&n,&m);
    for(i=0;i<m;i++)
    {
        scanf("%d %c",&s,&c);
        if(ch[n-s]=='*'||ch[n-s]==c)
        {
            ch[n-s]=c;
        }
        else
        {
            flag=1;
        }
    }
    
    if(flag==0)
    {
        if(ch[n-1]=='0'&&n!=1)
        {
            flag=1;
        }
        if(ch[n-1]=='*'&&n!=1)
        {
            ch[n-1]='1';
        }
        if(n==1&&m==0)
        {
            ch[0]='0';
        }
        for(i=0;i<n-1;i++)
        {
            if(ch[i]=='*')
            {
                ch[i]='0';
            }
        }
    }
    
    
    if(flag==1)
    {
        printf("-1\n");
    }
    else
    {
        for(i=n-1;i>=0;--i)
        {
            printf("%c",ch[i]);
        }
        printf("\n");
    }
    
    return 0;
}


Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=1e5+4;

int main()                  
{
    string s;
    
    cin>>s;
    
    string ch[5];
    
    ch[0]="hi"; ch[1]="hihi"; ch[2]="hihihi"; ch[3]="hihihihi"; ch[4]="hihihihihi";
    
    rep(i,0,5)
    if(s==ch[i])
    {
        cout<<"Yes";
        
        return 0;
    }
    
    cout<<"No";
} 

Measured memory_bytes: 256