akhauriyash/Code-Regression huggingface dataset:
//6:38
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <map>

using namespace std;
typedef long long ll;
ll max(ll a, ll b){return(a>b)?a:b;}
ll min(ll a, ll b){return(a<b)?a:b;}
ll abss(ll a){return(a<0)?-a:a;}

ll gcd(ll a, ll b){
        if(b > a){
                ll tmp = b;
                b = a;
                a = tmp;
        }
        if(b == 0) return a;
        else return gcd(b, a%b);
}
ll lcm(ll a, ll b){
        ll gcdi = gcd(a,b);
        return a/gcdi*(b);
}
int ketasuu(ll a){
        int i = 1;
        ll r = 10;
        while(a / r != 0){
                i++;
                r *= 10;
        }
        return i;
}



int ans = 20;
int main(){
        ll N;
        scanf("%lld",&N);
        for(ll i = 1; i * i <= N; i++){
                if( N % i == 0){
                        ans = min(ans,max(ketasuu(i), ketasuu(N/i)));
                }
        }
        printf("%d\n",ans);
}

Measured memory_bytes: 128
import collections
n = int(input())
li1 = list(input() for _ in range(n))
li1 = collections.Counter(li1)
#print(li1)
m = int(input())
li2 = list((input() for _ in range(m)))
li2 = collections.Counter(li2)
#print(li2)
li3 = li1 - li2
#print(li3)

if li3 == collections.Counter():
    print(0)
else:
    print(max(li3.values()))

Measured memory_bytes: 3316
n,l=map(int,input().split())
if l + n <= 0:
    print(sum(i for i in range(l, l + n - 1)))
elif l <= 0 and l + n > 0:
    print(sum(i for i in range(l, l + n)))
else:
    print(sum(i for i in range(l + 1, l + n)))

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;

int main()
{ 
    int n, a[100010], b[100010], c[100010];

    cin >> n;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) cin >> b[i];
    for (ll i = 0; i < n; i++) cin >> c[i];

    sort(a, a + n);
    sort(b, b + n);
    sort(c, c + n);

    ll ans = 0;
    for (ll i = 0; i < n; i++) {
        ll aa = (lower_bound(a, a + n, b[i]) - a);
        ll bb = ((c + n) - upper_bound(c, c + n, b[i]));
        // cout << aa << " " << bb << endl;
        ans += aa * bb;
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
	int N, DP[100010];
	cin >> N;
	DP[0] = 0;
	for (int i = 1; i <= N; i++) {
		DP[i] = 100000;
	}
	for (int i = 1; i <= N; i++) {
		for (int X6 = 1; X6 <= i; X6 *= 6) {
			DP[i] = min(DP[i], DP[i - X6] + 1);
		}
		for (int X9 = 1; X9 <= i; X9 *= 9) {
			DP[i] = min(DP[i], DP[i - X9] + 1);
		}
	}
	cout << DP[N];
}

Measured memory_bytes: 640
#include <iostream>
#define int long long
using namespace std;

int n;
int a[80];

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) { cin >> a[i]; }
	
	int ans = 1000;
	for (i = 0; i < n - 1; i++) {
		if (a[i] < a[i + 1]) {
			ans = ans % a[i] + (ans / a[i]) * a[i + 1];
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3636
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()


upper = [0]

def root(x):
    if upper[x] < 0:
        return x
    else:
        upper[x] = root(upper[x])
        return upper[x]

def equiv(x, y):
    return root(x) == root(y)

def unite(x, y):
    x, y = root(x), root(y)
    if x != y:
        if upper[y] < upper[x]:
            x, y = y, x
        upper[x] += upper[y]
        upper[y] = x
    return x == y

n, m = na()
es = []
for i in range(m):
    es.append(na())

ret = m
for i in range(m):
    upper = [-1] * n
    for j in range(m):
        if j != i:
            unite(es[j][0]-1, es[j][1]-1)
    for j in range(n):
        if upper[j] == -n:
            ret -= 1

print(ret)



Measured memory_bytes: 3064
#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 mod = 1000000007;
int main(void){
    ll a,b,c,d;cin >> a >> b >> c >> d;
    ll ans = max(a*c,max(a*d,max(b*c,b*d)));
    cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mod = 1e9+7;

int main(){
    int n;
    cin >> n;
    string s[2];
    cin >> s[0] >> s[1];
    ll ans = 1;

    for(int i = 0; i < n; i++){
        if(s[0][i] == s[1][i]){
            if(i == 0) ans *= 3;
            else if(s[0][i-1] == s[1][i-1]){
                ans *= 2;
                ans %= mod;
            }
        }
        else{
            if(i == 0) ans *= 3*2;
            else if(s[0][i-1] == s[1][i-1]){
                ans *= 2*1;
                ans %= mod;
            }
            else{
                ans *= 3;
                ans %= mod;
            }
            i++;
        }
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
import sys
import itertools
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K,*A= map(int, read().split())
l = [i for i in range(1,N)]
cost = float('inf')
for B in itertools.combinations(l,K-1):
  ans = 0
  pre = A[0]
  j = 0
  for i in range(1,N):
    if j == K-1:
      break
    if B[j]== i:
      j+=1
      if pre < A[i]:
        pre = A[i]
      else:
        ans += pre-A[i]+1
        pre +=1
    else:
      if pre < A[i]:
        pre = A[i]
  cost = min(ans,cost)
print(cost)

Measured memory_bytes: 3064
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <numeric>//iota头文件
#include <stdio.h>
#include <string.h>
#include <vector>
using namespace std;

string str;
int arr[256];
int main(){
    cin>>str;
    for(int i = 0;i<str.size();i++){
        arr[str[i]]++;
    }
    for(int i = 0;i<256;i++){
        if(arr[i] != 2 && arr[i] != 0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
int main()
{
   int n;
   cin>>n;
   vector<int>arr(n);
   for(int i=0;i<n;i++)
   cin>>arr[i];
   sort(arr.begin(),arr.end());
  
   int ans=0;
  for(int i=0;i<n;i++)
  {
      for(int j=i+1;j<n;j++)
      {
          if(arr[j]==arr[i])
          continue;
          for(int k=j+1;k<n;k++)
          {
              if(arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[k]!=arr[i]&&arr[k]<arr[i]+arr[j])
              ans++;
          }
      }
  }
  cout<<ans;
  return 0;
}

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


int main(){
	vector< pair<vector<int>,vector<int>> > table;
	table.push_back(make_pair(
	vector<int>{21,20,19,16,1,2,3,15,28,29,30},
	vector<int>{19,20,21,15,28,29,30,16,1,2,3})
	);
	/*
	table.push_back(make_pair(
	vector<int>{17,4,5,6,14,25,26,27},
	vector<int>{14,25,26,27,17,4,5,6})
	);
	*/
	table.push_back(make_pair(
	vector<int>{10,11,12,18,7,8,9,13,22,23,24},
	vector<int>{12,11,10,13,22,23,24,18,7,8,9})
	);
	table.push_back(make_pair(
	vector<int>{16,17,18,21,1,4,7,10,24,27,30},
	vector<int>{18,17,16,10,24,27,30,21,1,4,7})
	);
	table.push_back(make_pair(
	vector<int>{15,14,13,19,3,6,9,12,22,25,28},
	vector<int>{13,14,15,12,22,25,28,19,3,6,9})
	);
	/*table.push_back(make_pair(
	vector<int>{20,2,5,8,11,23,26,29},
	vector<int>{11,23,26,29,20,2,5,8})
	);
	*/
	int N;
	cin >> N;
	while(N--){
		vector<int> p(31);
		for(int i = 1 ; i <= 30 ; i++) cin >> p[i];
		queue< vector<int> > Q;
		map< vector<int> , int> memo;
		Q.push(p);
		memo[p] = 0;
		vector<int> chk = vector<int>{0,1,1,1,1,1,1,1,1,1,2,2,2,4,4,4,6,6,6,5,5,5,3,3,3,3,3,3,3,3,3};
		while(Q.size()){
			vector<int> q = Q.front(); Q.pop();
			int flag = true;
			for(int i = 1 ; i <= 6 ; i++){
				set<int> h;
				for(int j = 1 ; j <= 30 ; j++)
					if( chk[j] == i ){
						h.insert(q[j]);
					}
				if( h.size() != 1 ) flag = false;
			}
			if( flag ){
				cout << memo[q] << endl;
				break;
			}
			if( memo[q] >= 8 ) continue;
			for( auto t : table ){
				vector<int> fr = t.first;
				vector<int> to = t.second;
				vector<int> nex = q;
				for(int i = 0 ; i < fr.size() ; i++){
					nex[to[i]] = q[fr[i]];
				}
				if( !memo.count(nex) ){
					memo[nex] = memo[q] + 1;
					Q.push(nex);
				}
			}
		}
	}
}

Measured memory_bytes: 1284
/*
  Reference:-
*/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forn1(i, n) for (int i = 1; i < int(n); i++)
#define PI pair<int,int>
#define all(vec) vec.begin(),vec.end()
ll mod=1000000007;
int n;
ll ar[405];
ll dp[405][405];
ll pre[405];
int in[405][405];
ll sol(int i,int j,ll ans){
    if(i>j)return 0;
    if(dp[i][j])return dp[i][j];
    if(i==j){
        dp[i][j]=ar[i];
        //in[i][j]=i;
        return dp[i][j];
    }
    ll ans1=1e16;
    for(int i1=i;i1<j;i1++){
        //ll temp=ar[i1]+ar[i1+1];
        /*if(i1-1<i||i1+2>j){
            if(i1-1<i&&i1+2>j)ans1=min(ans1,temp);
            else if(i1-1<i)ans1=min(ans1,2*sol(i1+2,j,temp)+2*temp);
            else if(i1+2>j)ans1=min(ans1,2*sol(i,i1-1,temp)+2*temp);
        }
        else
        ll l1=sol(i,i1-1,temp),r1=sol(i1+2,j,temp);
        ll score, score1=(2*l1)+(3*temp),score2=(2*r1)+(3*temp);
        if(l1==0)score1=2*temp;
        if(r1==0)score2=2*temp;
        score=min(score1+r1,score2+l1);
        if(l1==0&&r1==0)score=temp;
        ans1=min(ans1,score);*/
        ll temp=0;
        ll l1=sol(i,i1,temp),r1=sol(i1+1,j,temp);
        ll score=l1+r1;
        if(i1==i)score=r1;
        if(i1+1==j)score=l1;
        if(i1==i&&i1+1==j)score=0;
        ll l11=pre[i1+1]-pre[i],r11=pre[j+1]-pre[i1+1];
        ans1=min(ans1,score+l11+r11);
        //if(ans1==l1+r1)in[i][j]=i1;
    }
    dp[i][j]=ans1;
    return dp[i][j];
}
int main(){
    std::ios::sync_with_stdio(false);
    //string s1,s2;
    //int n,k;
    cin>>n;
    //int ar[n+1];
    int sum=0;
    forn(i,n){cin>>ar[i];pre[i+1]=pre[i]+ar[i];}
    cout<<sol(0,n-1,0);
    /*for(int i=0;i<n;i++){
        for(int j=0;j<n;j++)cout<<"["<<i<<" "<<j<<"]"<<" - "<<dp[i][j]<<endl;
    }
    cout<<endl<<dp[0][1]<<" "<<in[0][1];
    cout<<endl<<dp[0][2]<<" "<<in[0][2];
    cout<<endl<<dp[0][4]<<" "<<in[0][4];
    int i1=0,j1=n-1;
    ll ans=0;
    while(i1<j1){
        ans+=dp[i1][j1];
        j1=in[i1][j1];
    }
    cout<<endl<<ans;*/

    return 0;
}


Measured memory_bytes: 1536
# 2019/05/23
# AtCoder Beginner Contest 079 - C

# Function
def calcChar(in_abcd, in_sum, in_idx):
    if in_idx < len(in_abcd):
        wsum = in_sum + in_abcd[in_idx]
        fnans = calcChar(in_abcd, wsum, in_idx + 1)
        
        if fnans[0] == 7:
            wans = list()
            wans.append(7)
            wans.append("+" + str(in_abcd[in_idx]) + fnans[1])
            return wans
        else:
            wsum = in_sum + in_abcd[in_idx] * (-1)
            fnans = calcChar(in_abcd, wsum, in_idx + 1)
            if fnans[0] == 7:
                wans = list()
                wans.append(7)
                wans.append("-" + str(in_abcd[in_idx]) + fnans[1])
                return wans
            else:
                return [-1, ""]
    else:
        wans = list()
        wans.append(in_sum)
        wans.append("=7")
        return wans

# Input
str_abcd = input()
abcd = list()
for i in range(4):
    abcd.append(int(str_abcd[i]))

# Call Func
ansl = calcChar(abcd, abcd[0], 1)
ans = str(abcd[0]) + ansl[1]

# Output
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
long long  n,m;
int main() {
	IO
	cin>>n;
	long long a,b,ans=n+1;
	long long s;
	for(int i=1;i<=sqrt(n);i++)
    {
        if(n%i==0)
        {
            b=n/i;
            ans=min(ans,i+b-2);
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int N;
char S[114514];

int main(void) {
	int i;
	int tangesakura = 0;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%114513s", S) != 1) return 1;
	for (i = 0; i < N; i++) {
		if ((S[i] == 'O' && S[i + 1] == 'X') || (S[i] == 'X' && S[i + 1] == 'O')) {
			tangesakura++;
			i++;
		}
	}
	printf("%d\n", tangesakura);
	return 0;
}



Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
const int nmax=5e5+3;
int n,v[nmax],m1,m2;
int main()
{
    ios::sync_with_stdio(false);
    cin>>n;
    for(int i=1;i<=n;++i)
    {
        cin>>v[i];
        if(v[i]>m1)
        {
            m2=m1;
            m1=v[i];
            continue;
        }
        if(v[i]>m2) m2=v[i];
    }
    for(int i=1;i<=n;++i)
    {
        if(v[i]!=m1) cout<<m1<<'\n';
        else cout<<m2<<'\n';
    }
    return 0;
}


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

int main(){
    int N, K;
    cin >> N >> K;
    vector<ll> A(N+1, 0);
    vector<ll> sum(N+1, 0);
    if (K > N) {
        for (int i = 1; i <= N; i++) {
            cin >> A[i];
            A[i]--;
            sum[i] = sum[i-1] + A[i];
        }
        unordered_map<ll, ll> um(0);
        for (int i = 0; i <= N; i++) {
            um[sum[i]%K]++;
        }
        ll ans = 0;
        auto it = um.begin();
        while (it != um.end()) {
            ll t = it->second;
            ans += t*(t-1)/2;
            it++;
        }
        cout << ans << endl;
    }
    else{
        for (int i = 1; i <= N; i++) {
            cin >> A[i];
            A[i]--;
            sum[i] = sum[i-1] + A[i];
        }
        vector<int> mod(K, 0);
        mod[0] = 1;
        ll ans = 0;
        for (int i = 1; i <= N; i++) {
            if (i >= K) mod[sum[i-K]%K]--;
            ans += mod[sum[i]%K];
            mod[sum[i]%K]++;
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 11592
//om nama sivaya
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define pb push_back
using namespace std;
void solve(){
    ll n,w,su=0;
    cin>>n>>w;
    ll a[n],b[n];
    for(ll i=0;i<n;i++){
        cin>>a[i]>>b[i];su+=b[i];
    }
    ll dp[su+1]={};
    dp[0]=0;
    for(int i=1;i<=su;i++)
    dp[i]=1000000005;
    for(int i=0;i<n;i++){
        for(int j=su;j>0;j--){
            if(j-b[i]>=0){
                dp[j]=min(dp[j],dp[j-b[i]]+a[i]);
            }
        }
    }
    for(int i=su;i>=0;i--)
    if(dp[i]!=1000000005 && dp[i]<=w)
    {
        cout<<i;
        return;
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int tt=1;
    //cin>>tt;
    while(tt--){
        solve();
    }
}


Measured memory_bytes: 4412
#include <bits/stdc++.h>
#define repp(i,l,r)for(long long i=(l);i<(r);i++)
#define rep(i,n) for (long long i = 0; i < (n); ++i)
#define per(i,n) for (long long i = (n); i >= 0; --i)
const int INF = 2147483647;//int max
const long long int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//ミョ(-ω- ?)
int main() {
    stack<ll> st;
    string s;
    while(cin >> s){
        if(s[0] == '+'){
            ll a = st.top();st.pop();
            ll b = st.top();st.pop();
            st.push(a+b);
        }else if(s[0] == '-'){
            ll a = st.top();st.pop();
            ll b = st.top();st.pop();
            st.push(b-a);
        }else if(s[0] == '*'){
            ll a = st.top();st.pop();
            ll b = st.top();st.pop();
            st.push(a*b);
        }else st.push(stoll(s));
    }
    cout << st.top() << endl;
    return 0;
}


Measured memory_bytes: 3184
#include<iostream>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<algorithm>
#include<set>
#include<sstream>
#include<cstdio>
#include<cmath>
#include<climits>
#include<cstdlib>
using namespace std;


#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define per(i,j,k) for(int i = (int)j;i >= (int)k;i --)
#define debug(x) cerr<<#x<<":"<<x<<endl
#define pb push_back
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0)
typedef long long ll;
const int maxn = 1 << 12;
const int maxm = 1005;
const int inf = 1e9;
int a[maxm];
int s[maxm];
template<class T>
inline bool chmax(T &a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

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

int main() {
	FAST_IO;
	int t;
	int n,m;
	cin >> n>>m;
	rep(i, 1, m) {
		int x;
		cin >> a[i]>>x;
		rep(j, 1, x) {
			int y; cin >> y;
			s[i] |= (1 << (y-1));
		}
		//cout << s[i] << endl;
	}
	vector<int> dp(1 << 12, inf);
	rep(i, 1, m) {
		dp[0] = 0;
		for (int j = 0; j < (1 << n); j++) {
			dp[j | s[i]] = min(dp[j | s[i]], dp[j] + a[i]);
		}
	}
	cout << (dp[(1 << n) - 1] == inf ? -1 : dp[(1 << n) - 1]) << endl;

	cin >> t;
	return 0;
}
/*
2 3
10 1
1
15 1
2
30 2
1 2
*/

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

int main(){
    int n;
    cin>>n;
    int p[n];
    int i;
    int taka=0;
    int m;
    int ans = 0;
    for(i =0; i<n; i++){
        cin>>p[i];
        if(p[i]>taka){
            taka = p[i];
            m = i;
        }
    }
    for(i=0; i<n; i++){
        ans+=p[i];
    }
    cout<<ans-(p[m]/2)<<endl;
    return 0;
}

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

#define int long long
#define REP(i, l, r) for (int i=(l); i<(r); ++i)
#define RREP(i, r, l) for (int i=(r); i>(l); --i)
#define vi vector<int>
#define vb vector<bool>
#define pii pair<int,int>
#define tiii tuple<int,int,int>
#define tiiii tuple<int,int,int,int>
#define popcount __builtin_popcountll

const int INF = 1LL<<60;
const int MOD = 1000000007;

template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
string to_string(string s) {return s;}
template <typename A, typename B>
string to_string(pair<A, B> p) {return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> t) {return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ")";}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> t) { return "(" + to_string(get<0>(t)) + ", " + to_string(get<1>(t)) + ", " + to_string(get<2>(t)) + ", " + to_string(get<3>(t)) + ")";}
template <typename A>
string to_string(vector<A> v) {
    bool first = true;
    string result = "[";
    for (A i : v) {
        if (!first) result += ", ";
        first = false;
        result += to_string(i); 
    }
    return result + "]";
}

string bin_string(int x) {
    const int d = 32;
    string result(d, ' ');
    RREP(i, d-1, -1) result[d-1-i] = '0'+((x&1LL<<i)!=0);
    return result;
}

int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    
    int n;
    cin >> n;
    if (n&1) cout << 0;
    else {
        int fives=0;
        int i=10;
        while (i<=n) {
            fives += n/i;
            i *= 5;
        }
        cout << fives;
    }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>>vvi;

int main(){
  int ans=INF;
  int n,T;
  cin>>n>>T;
  vector<int>c(n);
  vector<int>t(n);
  rep(i,n)cin>>c[i]>>t[i];
  rep(i,n){
    if(T>=t[i])ans=min(ans,c[i]);
  }
  if(ans==INF){
    cout<<"TLE"<<endl;
    return 0;
  }
  cout<<ans<<endl;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int ans = 0;
  REP(i,a+1)REP(j,b+1)REP(k,c+1){
    if(500*i + 100*j + 50*k == x)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
program A136
    implicit none
    integer A,B
    read *,A,B

    if(A==B) then
        print '(i0)',0
    else if(mod(A+B,2)==1) then
        print '(A)',"IMPOSSIBLE"
    else
        print '(i0)',(A+B)/2
    end if
    
end program A136

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    
    
    int n;
    cin>>n;
    double prob[n+1];
    for(int i=1;i<=n;i++)
     cin>>prob[i];
    double dp[n+1][n+1];
    for(int i=0;i<=n;i++)
     dp[0][i]=0.0;
    dp[0][0]=1.0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<=n;j++)
        {
            if(j==0)
             dp[i][j]=(1.0-prob[i])*dp[i-1][j];
            else
             dp[i][j]=prob[i]*dp[i-1][j-1]+(1.0-prob[i])*dp[i-1][j];
        }
    }
    double res=0;
    for(int i=n/2+1;i<=n;i++)
     res+=dp[n][i];

    cout<<fixed<<setprecision(10)<<res;

return 0;     
}


Measured memory_bytes: 70528
N = int(input())
S = list(input())

ans = 0

r = 0
g = 0
b = 0
for i in S:
  if i == "R":
    r += 1
  elif i == "G":
    g += 1
  else:
    b += 1

ans = r * g * b

for i in range(1, N - 1):
  for j in range(i):
    k = i + (i - j)
    if k >= N: continue
    if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
      ans -= 1

print(ans)

Measured memory_bytes: 73588
import  fractions
import math
import bisect
N,M=map(int,input().split())

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

ans=0
cnt=make_divisors(M)
tmp=bisect.bisect_right(cnt,M/N)

print(cnt[tmp-1])



Measured memory_bytes: 5088
#include <cstring>
#include <cstdio>
#include <iostream>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long LL;
typedef pair<int,int> Pair;
const int INF = 1e9+7;

LL a, b;

int main(){
	scanf("%lld%lld", &a, &b);
	if (a > b) swap(a, b);
	if (a==1){
		if (b==1) return printf("%d\n", 1)&0;
		printf("%lld\n", max(0ll, b-2));
	}else printf("%lld\n", (a-2)*(b-2));
	
	return 0;
}


Measured memory_bytes: 256
import numpy as np

n, m = map(int, input().split())

d = np.ones((n, n)) * 1001

es = []
for i in range(m):
    es.append(list(map(int, input().split())))

for (i, j, w) in es:
    d[i - 1][j - 1] = w
    d[j - 1][i - 1] = w


for k in range(n):
    for i in range(n):
        for j in range(n):
            l = d[i][k] + d[k][j]
            if d[i][j] > l:
                d[i][j] = l

c = 0
for (i, j, w) in es:
    if d[i - 1][j - 1] < w:
        c += 1

print(c)


Measured memory_bytes: 14552
N = int(input())
EDGES = [[] for _ in range(N+1)]
P = [(set(), 1) for _ in range(N+1)]

for i in range(N-1):
  a, b = map(int, input().split())
  if i == 0:
    root = a
  EDGES[a].append((b, i))
  EDGES[b].append((a, i))

ans = [None for i in range(N-1)]

def dfs(root):
  # from, parent, color
  stack = [(root, -1, -1)]
  visited = set()

  while stack:
    u, parent, color = stack.pop()
    visited.add(u)

    nextColor = 1

    for (v, index) in EDGES[u]:
      if v not in visited and v != parent:
        if nextColor == color:
          nextColor += 1
        stack.append((v, u, nextColor))
        ans[index] = nextColor
        nextColor += 1

dfs(root)

print(max(ans))
for a in ans:
  print(a)      

Measured memory_bytes: 83120
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	int x,y,z;
	cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y<<endl;

	return 0;
}


Measured memory_bytes: 256
/*
       ()       ()()()()     ()        ()       ()        ()        ()
      ()()      ()     ()    ()()      ()      ()()       ()()      ()
     ()  ()     ()      ()   ()  ()    ()     ()  ()      ()  ()    ()
    ()()()()    ()      ()   ()    ()  ()    ()()()()     ()    ()  ()
   ()      ()   ()     ()    ()      ()()   ()      ()    ()      ()()
  ()        ()  ()()()()     ()        ()  ()        ()   ()        ()

*/
#include <bits/stdc++.h>
#define MOD  (int)(1e9+7)
#define SIZE (int)(1e5+5)
#define all(x) x.begin(),x.end()
#define si(i)  scanf("%d",&i)
#define sf(f)  scanf("%f",&f)
#define pi(i)  printf("%d",i)
#define pd(d)  printf("%lf",d)
#define deb(x) cout<<#x<<" is "<<x<<"\n";
#define lb     lower_bound
#define ub     upper_bound
#define pb     push_back
#define prDouble(x) cout<<fixed<<setprecision(10)<<x;
#define IOfast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

int64_t exponentiation(int64_t base,int exp)
{
    if (exp == 0)
        return 1;

    if (exp == 1)
        return base;

    int64_t t = exponentiation(base, exp / 2);

    t = (t * t);

    if (exp % 2 == 0)
        return t;
    else
        return base * t;
}

//int in_between;
//vector <int> index[26];
int64_t dp[21][(1<<22)];

int64_t solve(vector<vector<int>>& compatible,int index_men, int women_subset,int n)
{
 if(index_men == n)
 {
   if(women_subset == 0)
    return 1;
   else
    return 0;
 }

 if(dp[index_men][women_subset] !=-1)
   return dp[index_men][women_subset];

 int64_t ans=0;
 int i=0;
 int temp = women_subset;

 while(temp)
 {
  if( (temp & 1) && compatible[index_men][i])
  ans =(ans + solve(compatible,index_men+1,women_subset^(1<<i),n))%MOD;
  temp>>=1;
  i++;
 }
 return dp[index_men][women_subset] = ans;
}

int main()
{
  IOfast;

  int q=1;
  //cin>>q;
  memset(dp,-1,sizeof(dp));
  while(q--)
  {
      int n;
      cin>>n;

      vector<vector<int>> arr(n,vector<int> (n));

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

      int64_t ans=solve(arr,0,(1<<n) - 1,n);

      cout<<ans;
      int ola =0;
  }


  return 0;
}


Measured memory_bytes: 688512
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Deque;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int h = sc.nextInt();
			int w = sc.nextInt();

			char[][] result = new char[h][];
			for (int j = 0; j < result.length; j++) {
				String line = sc.next();
				result[j] = line.toCharArray();
			}

			Map<Character, Integer[]> map = new HashMap<Character, Integer[]>();
			HashMap<Character, ArrayList<Character>> underBy = new HashMap<Character, ArrayList<Character>>();
			for (int j = 0; j < result.length; j++) {
				for (int k = 0; k < result[j].length; k++) {
					if (result[j][k] != '.') {
						if (map.get(result[j][k]) == null) {
							Integer[] put = { j, k, j, k };
							map.put(result[j][k], put);
							underBy.put(result[j][k],
									new ArrayList<Character>());
						} else {
							Integer[] get = map.get(result[j][k]);
							map.get(result[j][k])[0] = Math.min(get[0], j);
							map.get(result[j][k])[1] = Math.min(get[1], k);
							map.get(result[j][k])[2] = Math.max(get[2], j);
							map.get(result[j][k])[3] = Math.max(get[3], k);
						}
					}
				}
			}

			boolean safe = true;

			check: for (Map.Entry<Character, Integer[]> entry : map.entrySet()) {
				char key = entry.getKey();
				Integer[] get = map.get(key);

				for (int j = get[0]; j <= get[2]; j++) {
					for (int k = get[1]; k <= get[3]; k++) {
						if (result[j][k] == '.') {
							// 明らかに長方形でない時
							System.out.println("SUSPICIOUS");
							safe = false;
							break check;
						} else if (result[j][k] != key) {
							// 別の文字がかぶっている時
							// keyの上にresult[j][k]
							underBy.get(key).add(result[j][k]);
						}
					}
				}
			}

			if (!safe) {
				continue;
			}

			check: for (Map.Entry<Character, ArrayList<Character>> entry : underBy
					.entrySet()) {
				Deque<Character> deque = new ArrayDeque<Character>();
				Deque<Character> checked = new ArrayDeque<Character>();
				for (Character character : entry.getValue()) {
					deque.add(character);
				}
				while (!deque.isEmpty()) {
					char poll = deque.poll();
					checked.add(poll);
					if (poll == entry.getKey()) {
						// 明らかに長方形でない時
						System.out.println("SUSPICIOUS");
						safe = false;
						break check;
					}

					for (Character character : underBy.get(poll)) {
						if (!deque.contains(character)
								&& !checked.contains(character)) {
							deque.add(character);
						}
					}
				}

			}

			if (safe) {
				System.out.println("SAFE");
			}
		}
		sc.close();
	}
}

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

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

    int n;
    cin >> n;
    int b[n-1];
    rep (i, n-1) cin >> b[i];
    ll res = b[0];
    Rep (i, 1, n-1) {
        res += min(b[i], b[i-1]);
    }
    res += b[n-2];
    cout << res << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


bool comp(Pl x, Pl y) {
	return (x.first * (y.second+1) < y.first * (x.second+1));
}

void Main() {
	ll N, T; cin >> N >> T;
	vector<Pl> dat(N); cin >> dat;
	sort(rbegin(dat), rend(dat), comp);
	vll A, B;
	vll zs;
	
	for (int i = 0; i < N; i++) {
		if (dat[i].first > 0) {
			A.push_back(dat[i].first);
			B.push_back(dat[i].second);
		} else {
			zs.push_back(dat[i].second+1);
		}
	}
	
	sort(begin(zs), end(zs));
	for (int i = 1; i < zs.size(); i++) {
		zs[i] += zs[i-1];
	}

	int n = A.size();
	vvll dp(31, vll(n+1, LLINF));
	dp[0][0] = 0;
	int ans = 0;
	for (int c = 0; c < 31; c++) {
		ll minv = dp[c][0];
		for (int i = 1; i < n+1; i++) {
			chmin(dp[c][i], dp[c][i-1]);
			if (c > 0 && dp[c-1][i-1] <= T) {
				ll val = dp[c-1][i-1] + (dp[c-1][i-1] + 1) * A[i-1] + B[i-1] + 1;
				if (val <= T) chmin(dp[c][i], val);
			}
			chmin(minv, dp[c][i]);
		}
		if (minv > T) break;
		int num = upper_bound(begin(zs), end(zs), T - minv) - begin(zs);
		chmax(ans, c + num);
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 56804
#include<bits/stdc++.h>
        #define ll long long
        #define rep(i,a,b) for(i=a;i<b;i++)
        #define pb push_back
        #define all(v) v.begin(),v.end()
        #define F first
        #define S second
        #define hell 1000000007
        using namespace std;

        void solve()
        {
          ll n,m,i,j,k,c=0,y=0,ams=0,a,b;
          string s;
          cin>>s;
          if(s[0]>='a')
          {
              cout<<"a";
          }
          else cout<<"A";




    }

        int main()
        {
            ios::sync_with_stdio(false);
            cin.tie(0);
            cout.tie(0);
            int t=1;
            //cin>>t;
            while(t--)
            solve();
        }


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define llINF 1000000000000000000
//#define MOD 1000000007
#define MOD 998244353
#define all(v) v.begin(),v.end()
#define pb push_back
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[200010];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int inv(int x){
	x=modpow(x,MOD-2);
	return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
double dist(double ax,double ay,double bx,double by){
	return sqrt((bx-ax)*(bx-ax)+(ay-by)*(ay-by));
}
int n,a[100010],cnt[100010],maxA,ans=1;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		cnt[a[i]]++;
		maxA=max(maxA,a[i]);
	}
	if(a[0]||cnt[0]>=2){
		puts("0");
		return 0;
	}
	for(int i=1;i<=maxA;i++){
		if(cnt[i]==0){
			puts("0");
			return 0;
		}
		ans*=modpow(cnt[i-1],cnt[i]);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;
using ll = long long;

map<long long int, long long int> prime_factor(long long int n) {
    map<long long int, long long int> ret;
    for (long long int i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1) ret[n] = 1;
    return ret;
}

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

    ll output = 0;
    for (int c = 1; c <= N - 1; c++) {
        map<ll, ll> primes = prime_factor(N - c);
        int comb = 1;
        for (auto e : primes) {
            if (e.first > 1) {
                comb *= e.second + 1;
            }
        }
        output += comb;
    }

    cout << output << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((int)(x).size())
#define re(n) for (int i = 0; i < (n); ++i)
#define rej(n) for (int j = 0; j < (n); ++j)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef vector <pair <int, int>> vii;

const ld PI = acos((ld)-1);

int main() {
    #ifndef LOCALDEBUG
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    #endif  // LOCALDEBUG
    ll n;
    cin >> n;
    ll ans = LLONG_MAX;
    for (ll i = 1; i <= sqrt(n) + 1; ++i) {
        if (n % i == 0) {
            ans = min(ans, i + (n / i));
        }
    }
    cout << ans - 2;
    return 0;
}


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

public class Main {

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		int X = sc.nextInt();
		int ans = X;
		for (int i = ans;; i++)
			if (isPrime(i)) {
				System.out.println(i);
				break;
			}

	}

	//以下、自作ライブラリ

	//最大公約数
	public static long gcd(long a, long b) {
		if (a < b)
			return gcd(b, a);
		long c = 0;
		c = a % b;
		if (c == 0)
			return b;
		return gcd(b, c);
	}

	//最小公倍数
	public static long lcm(long m, long n) {
		return m * n / gcd(m, n);
	}

	//素数判定
	public static boolean isPrime(int n) {
		if (n < 2)
			return false;
		if (n == 2)
			return true;
		if (n % 2 == 0)
			return false;

		for (int i = 3; i * i <= n; i += 2) {
			if (n % i == 0)
				return false;
		}
		return true;
	}
}

//以下、高速スキャナークラス
class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

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


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

using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<int> X(n), Y(n);
    for(int i = 0; i < n; i++){
        cin >> X.at(i);
    }
    for(int i = 0; i < n; i++){
        cin >> Y.at(i);
    }

    double d_p1 = 0, d_p2 = 0, d_p3 = 0, d_pp = 0;
    for(int i = 0; i < n; i++){
        int x = X.at(i), y = Y.at(i);
        d_p1 += abs(x - y);
        d_p2 += (x-y) * (x-y);
        d_p3 += abs((x-y) * (x-y) * (x-y));
        d_pp = d_pp < abs(x-y) ? abs(x-y) : d_pp;
    }

    printf("%.6f\n", d_p1);
    printf("%.6f\n", sqrt((double)d_p2));
    printf("%.6f\n", cbrt((double)d_p3));
    printf("%.6f\n", d_pp);

}


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

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define endl '\n'
typedef long long li;
const int N = 1e5 + 10;
int n;
int a[N],b[N],c[N];
int dp[N][3];
int k;

int main(){

	cin>>n;
	for(int i = 0 ; i < n ; ++i){

		cin>>a[i]>>b[i]>>c[i];
	}
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1 ; i < n ; ++i){

		dp[i][0] = max(dp[i-1][0] , max(dp[i-1][1] + a[i] ,dp[i-1][2] + a[i]));
		dp[i][1] = max(dp[i-1][0] + b[i] , max(dp[i-1][1] ,dp[i-1][2] + b[i]));
		dp[i][2] = max(dp[i-1][0] + c[i] , max(dp[i-1][1] + c[i] ,dp[i-1][2]));
	}
	n--;
	cout<<max(dp[n][0] , max(dp[n][1],dp[n][2]))<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll n, m, t, a[100005];
vector< ll > adj[100005];
#define ari for( int i = 0 ; i < n ; i++ ) cin >> a[i];
#define ginp for( int i = 0 ; i < m ; i++ ){ int u, v; cin >> u >> v; adj[u].push_back(v); adj[v].push_back(u);}
#define pb push_back
#define ss second
#define ff first
#define fs first.second
#define fff first.first
#define sss second.second
#define sf second.first
#define mp make_pair
void printar(vector< ll > ar, ll l, ll r){
	for(int i = l ; i < r ; i++)
		cout << ar[i] << " ";
	cout << endl;
}
	
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    t = 1;
	while( t-- ){
		string s;
		cin >> s;
		if( s[0] == 'R' ){
			if( s[1] == 'S' )
				cout << "1" << endl;
			else if( s[2] == 'S' )
				cout << "2" << endl;
			else
				cout << "3" << endl;
		}
		else if( s[1] == 'R' ){
			if( s[2] == 'R' )
				cout << "2" << endl;
			else
				cout << "1" << endl;
		}
		else if( s[2] == 'R' )
			cout << "1" << endl;
		else
			cout << "0" << endl;
	}
	return(0);
}

Measured memory_bytes: 5968
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstdio>

using namespace std;

string s;

void solve() {
    int i = 0;
    for(;i < s.length();i++) {
        if(s[i] == '\n') break;
        if(islower(s[i])) printf("%c",toupper(s[i]));
        else if(isupper(s[i])) printf("%c",tolower(s[i]));
        else printf("%c", s[i]);
    }
    cout << endl;
}

int main() {
    getline(cin, s);
    solve();
}


Measured memory_bytes: 3124
/*input
7
zenkoku
touitsu
program
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}

//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const ld PI=acos(-1);
const ld eps=1e-9;
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}

int main(){
	IOS;
	string s[3];
	int n;
	cin>>n;
	REP(i,3) cin>>s[i];

	int ans=0;
	REP(i,n){
		vector<char> tmp;
		REP(j,3) tmp.pb(s[j][i]);
		sort(ALL(tmp));
		if(tmp[0]==tmp[2]);
		else if(tmp[0]==tmp[1]) ans++;
		else if(tmp[1]==tmp[2]) ans++;
		else ans+=2; 
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      if(i*j==n){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

int main() {
  
  ll X, K, D;
  cin >> X >> K >> D;

  X = abs(X);

  if ((X + D - 1) / D <= K || X <= K * D) {
    K -= X / D;
    if (K % 2 == 0) cout << X % D;
    else cout << (D - X % D) << endl;
  } else cout << (X - K * D) << endl;

  return 0;
}

Measured memory_bytes: 3620
package main

import (
	"fmt"
	"os"
)

func main() {
	var x [5]int

	for i := 0; i<5; i++{
		_, _ = fmt.Scan(&x[i])
	}

	for i:=0; i<5;i++{
		if x[i]==0{
			fmt.Println(i+1)
			os.Exit(0)
		}
	}
}

Measured memory_bytes: 1760
#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(){
    int a,b;
    cin>>a>>b;
    int abmax=max(a,b);
    int abmin=min(a,b);
    string ret;
    for(int i=0;i<abmax;i++){
        ret+=to_string(abmin);
    }
    cout<<ret<<endl;
    return 0;
}

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

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N, K;
    cin >> N >> K;
    VEC(int) V(N);
    READVEC(V);

    int ret = 0;
    FOR(l, 0, N + 1)
        FOR(r, 0, N + 1)
            if (l + r <= min(K, N)) {
                VEC(int) taken;
                FOR(i, 0, l)
                    taken.push_back(V[i]);
                FOR(i, 0, r)
                    taken.push_back(V[N - 1 - i]);

                sort(ALL(taken));
                int best = 0, ops = K - l - r;
                for(int v : taken) {
                    if (v < 0 && ops > 0) {
                        ops--;
                    }
                    else best += v;
                }

                ret = max(ret, best);
            }

    cout << ret << endl;
    return 0;
};


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <list>

using namespace std;

int main(){
	int a,max=0;
	int num[100]={0};
	while(cin>>a) num[a]++;
	for(int i=0;i<100;i++) if(num[i]>max) max=num[i];
	for(int i=0;i<100;i++) if(num[i]==max) cout<<i<<endl;
}

Measured memory_bytes: 1160
def main():
    n = int(input())
    ab = [list(map(int, input().split())) for _ in range(n)]

    ab.sort(reverse=True, key=lambda x: x[0] + x[1])

    t = sum(map(lambda x: x[0], ab[::2]))
    a = sum(map(lambda x: x[1], ab[1::2]))

    ans = t - a

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 32224
#include<iostream>
#include<cmath>
#include<vector>
#include<bitset>
#include<bitset>
#include<string>
#include<utility>
#include<queue>

using namespace std;

int main(){
    int n;
    cin >> n;
    long long int l[n];
    long long int ans=0;
    for(int i=0;i<n;i++){
        cin >> l[i];
    }
    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(l[i]==l[j] || l[j]==l[k] || l[k]==l[i]){
                    continue;
                }
                if(abs(l[i]-l[j])<l[k] && l[k]<l[i]+l[j]){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3164