akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

signed main() {
    cin >> H >> W;
    vvi g(H, vi(W));
    vvi used(H, vi(W));
    int MX = 12801;
    vvvi res(H, vvi(W, vi(MX)));
    REP(h, H)
    REP(w, W) {
        cin >> g[h][w];
    }
    REP(h, H)
    REP(w, W) {
        cin >> B;
        g[h][w] = abs(g[h][w] - B);
    }
    queue<pair<int, int>> q;
    q.push({0, 0});
    res[0][0][g[0][0]] = 1;
    while (!q.empty()) {
        auto now = q.front();
        auto [h, w] = now;
        q.pop();
        if (used[h][w])
            continue;
        used[h][w] = 1;
        REP(i, MX) {
            if (res[h][w][i]) {
                if (h + 1 < H) {
                    if (i + g[h + 1][w] < MX)
                        res[h + 1][w][i + g[h + 1][w]] = 1;
                    if (abs(i - g[h + 1][w]) < MX)
                        res[h + 1][w][abs(i - g[h + 1][w])] = 1;
                }
                if (w + 1 < W) {
                    if (i + g[h][w + 1] < MX)
                        res[h][w + 1][i + g[h][w + 1]] = 1;
                    if (abs(i - g[h][w + 1]) < MX)
                        res[h][w + 1][abs(i - g[h][w + 1])] = 1;
                }
            }
        }
        if (h + 1 < H)
            q.push({h + 1, w});
        if (w + 1 < W)
            q.push({h, w + 1});
    }
    REP(i, MX) {
        if (res[H - 1][W - 1][i]) {
            cout << i << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 327668
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
#include<cmath>
using namespace std;
const int N=1e5+100;
const int mod=1e9+7;
int n,m;
int fac[N],inv[N];
inline int C(int n,int m){return 1ll*fac[n]*inv[m]%mod*inv[n-m]%mod;}
inline int fpow(int x,int k){
	register int ret=1;
	while(k){
		if(k&1) ret=1ll*ret*x%mod;
		x=1ll*x*x%mod;
		k>>=1;
	}
	return ret;
}
int main()
{
	cin>>n>>m;
	fac[0]=inv[0]=1;
	for(register int i=1;i<N;++i) fac[i]=1ll*fac[i-1]*i%mod;
	inv[N-1]=fpow(fac[N-1],mod-2);
	for(register int i=N-2;i;--i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	register int ed=sqrt(m)+1;
	register int ans=1;
	for(register int i=2;i<=ed;++i){
		int num=0;
		while(m%i==0) {
			++num;m/=i;
		}
		ans=1ll*ans*C(n+num-1,num)%mod;
	}
	if(m!=1) ans=1ll*ans*n%mod;
	printf("%d\n",ans);
}

Measured memory_bytes: 1024
package main

import "fmt"

func main() {

	var n, a_i int
	var buf [100]int

	fmt.Scan(&n)
	var a []int = buf[0:n]
	for i:=0; i<n; i++ {
		fmt.Scan(&a_i)
		a[i] = a_i
	}
	for i:=n-1; i>0; i-- {
		fmt.Printf("%d ", a[i])
	}
	fmt.Println(a[0])
	a = nil
}


Measured memory_bytes: 1112
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#define lli long long int
#define uli unsigned long long int
#define inf 999999999999999999
#define rep(i,n,m) for(lli i=(lli)(n);i<(lli)(m);++i)
#define reep(i,n,m) for(int i=(int)(n);i<=(int)(m);++i)
#define per(i,m,n) for(lli i=(int)(m)-1;i>=(int)(n);--i)
#define st(n) sort(n.begin(), n.end())
#define rev(n) reverse(n.begin(),n.end())
#define ou(S) cout << S << endl
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  vector<lli> l(n);
  rep(i,0,n){
    cin>>l.at(i);
    sum+=l.at(i);
  }
  //ou(sum);
  st(l);
  sum-=l.at(n-1);
  //ou(sum);
  if(l.at(n-1)<sum)
    ou("Yes");
  else ou("No");
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	answer := indexAt(n)
	fmt.Println(answer)
}

func indexAt(k int) int {
	a := []int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	return a[k-1]
}


Measured memory_bytes: 512
matrix = [[0 for _ in xrange(10)] for _ in xrange(10)]
for i in xrange(10):
    matrix[i] = map(int, raw_input().split())


def checkDigit(n):
    xor = matrix[0][int(n[0])]

    for i in xrange(1, len(n)):
        a = int(n[i])
        xor = matrix[xor][a]
    return xor


def check(n):
    for i in xrange(len(n)):
        for j in xrange(10):
            q = str(j)
            if n[i] == q:
                continue
            k = n[:i] + q + n[i + 1:]
            if 0 == checkDigit(k):
                return True

    for i in xrange(len(n) - 1):
        if n[i] != n[i + 1]:
            l = n[:i] + n[i + 1] + n[i] + n[i + 2:]
            if 0 == checkDigit(l):
                return True
    return False


ans = 0
for num in xrange(10000):
    n = "%04d" % num
    master = checkDigit(n)
    n += str(master)
    c = False
    hit = check(n)

    if hit:
        ans += 1
print ans

Measured memory_bytes: 6488
/*
 * 	The way if it's all predetermined
 * 		And the way i should go all my life
 * 			I swear to go wherever will be
 * 				'Cause there'll be something to see and to find
 */
//#pragma GCC optimize("Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#define int long long
typedef long long ll;
typedef long double f80;
#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=1e9;
//const int mod=998244353;
const int mod=1000000007;
typedef vector<int> vi;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}


int powm(int a, int b) {
	a%=mod;
	int res=1;
	while(b) {
		if(b&1)
			res=(res*a)%mod;
		b>>=1;
		a=(a*a)%mod;
	}
	return res;
}
int fact[200005],ifact[200005];
int ncr(int n, int r) {
	return (((fact[n]*ifact[r])%mod)*ifact[n-r])%mod;
}
void solve() {
	fact[0]=1;
	fr(i,1,200001)
		fact[i]=(fact[i-1]*i)%mod;
	ifact[200001]=powm(fact[200001],mod-2);
	for(int i=200000; i>=0; i--)
		ifact[i]=(ifact[i+1]*(i+1))%mod;
	int n,a,b,c;
	cin>>n>>a>>b>>c;
	a=(a*powm(100,mod-2))%mod;
	b=(b*powm(100,mod-2))%mod;
	c=(c*powm(100,mod-2))%mod;
	int con=(c*(powm(1+mod-c,mod-2)))%mod;
	int ans=0;
	trace(con);
	int temp=powm(a+b,mod-2);
	a=(a*temp)%mod;
	b=(b*temp)%mod;
	for(int i=0; i<n; i++) {
		ans=(ans+((con*(n+i)+i+n)%mod)*((((ncr(n+i-1,i)*powm(a,n))%mod)*powm(b,i))%mod))%mod;
	}
	for(int i=0; i<n; i++) {
		ans=(ans+((con*(n+i)+i+n)%mod)*((((ncr(n+i-1,i)*powm(b,n))%mod)*powm(a,i))%mod))%mod;
	}
	cout<<ans<<endl;

}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
//	cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;
const long long int INF = 1e18;

int main() {
    int n; cin >> n;
    vector<long long int> a(3*n), l(n+1), r(n+1);
    for (int i = 0; i < 3 * n; i++) cin >> a[i];

    long long int sum = 0;
    priority_queue<int, vector<int>, greater<int>> pque1;
    for (int i = 0; i < n; i++) { 
        pque1.push(a[i]);
        sum += a[i]; 
    }
    l[0] = sum;
    for (int i = n; i < 2*n; i++) {
        pque1.push(a[i]);
        sum -= pque1.top() - a[i];
        pque1.pop();
        l[i-n+1] = sum;
    }

    sum = 0;
    priority_queue<int> pque2;
    for (int i = 3*n-1; i >= 2*n; i--) {
        pque2.push(a[i]);
        sum += a[i];
    }
    r[n] = sum;
    for (int i = 2*n-1; i >= n; i--) {
        pque2.push(a[i]);
        sum -= pque2.top() - a[i];
        pque2.pop();
        r[i-n] = sum;
    }

    long long int ans = -INF; 
    for (int i = 0; i <= n; i++) {
        ans = max(ans, l[i] - r[i]);
    }
    cout << ans << endl;
}

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

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

void testCase(){
    int n; cin >> n;
    vector<int> a(n);

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

    map<int, int> mp;
    int pair = 1;
    for(int i = 0; i < n; i++){
        for(int j = 1; j * j <= a[i]; j++){
            if(a[i] % j == 0){
                if(mp[j] == 1){
                    pair = 0;
                    break;
                }
                if(j != 1 && mp[j] == 0){
                    mp[j] = 1;
                }
                if(j * j != a[i] && mp[a[i] / j] == 1){
                    pair = 0;
                    break;
                }
                if(j * j != a[i]){
                    mp[a[i] / j] = 1;
                }
            }
        }
        if(pair == 0){
            break;
        }
    }

    if(pair){
        cout << "pairwise coprime" << endl;
    } else{
        int gd = a[0];
        for(int i = 0; i < n; i++){
            gd = gcd(gd, a[i]);
        }
        if(gd == 1){
            cout << "setwise coprime" << endl;
        } else{
            cout << "not coprime" << endl;
        }
    }
}
 
signed 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

    int t = 1;
    // int t; cin >> t;
    while(t--)
        testCase();
    
    return 0;
}

Measured memory_bytes: 11040
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
set<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>o;
        v.IN(o);
    }
    cout<<v.SZ<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;
int a[110];

int cmp(int x,int y)
{
    return x > y;
}

int main()
{
    int n;
    int i;
    int sum1,sum2;
    while(scanf("%d",&n) != EOF)
    {
        for(i = 0;i < n;i++)
        {
            scanf("%d",&a[i]);
        }
        sum1 = 0,sum2 = 0;
        sort(a,a+n,cmp);
        int flag = 0;
        for(i = 0;i < n;i++)
        {
            if(!flag)
            {
                sum1 += a[i];
                flag = 1;
            }
            else
            {
                sum2 += a[i];
                flag = 0;
            }
        }
        printf("%d\n",sum1-sum2);
    }

    return 0;
}


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

int main()
{
	std::stack<int> st;
	int n;

	while (std::cin >> n)
	{
		if (n == 0)
		{
			std::cout << st.top() << std::endl;
			st.pop();
		}
		else
		{
			st.push(n);
		}
	}

}


Measured memory_bytes: 3088
#include <iostream>

using namespace std;

int main(){
    int a,b;
    cin >> a >> b;
    if (a < b){
    cout <<  "a < b"  << endl;
}else if (a == b){
    cout <<  "a == b"  << endl;
}else {
    cout <<  "a > b"  << endl;
}
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> data(N);
  for(int i = 0; i < N; i++){
    cin >> data.at(i);
  }
  int sum = 0;
  for(int i = 0; i < N; i++){
    sum += data.at(i);
  }
  int mean = sum/N;
  if(sum % N > N/2){
    mean++;
  }
  int dis = 0;
  for(int i = 0; i< N; i++){
    dis += (data.at(i) - (mean))*(data.at(i) - (mean));
  }
  cout << dis << endl;
  
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String[] s1 = sc.nextLine().split(" ");
        int a = sc.nextInt();
        int b = sc.nextInt();
        String next = sc.next();
 
        a = s1[0].equals(next) ? a - 1 : a;
        b = s1[1].equals(next) ? b - 1 : b;
        System.out.println(a + " " + b);
    }
}

Measured memory_bytes: 22996
N, P = map(int, input().split())
A = [int(i) for i in input().split()]

e = 0
o = 0
for a in A:
    if a % 2 == 0:
        e += 1
    else:
        o += 1

if P == 1:
    print((2**e)*((2**o)//2))
else:
    print(2**N-(2**e)*((2**o)//2))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;

namespace P0021_Parallelism
{
    class Program
    {
        static void Main(string[] args)
        {
            var lines = new List<List<string>>();
            var n = int.Parse(Console.ReadLine());
            for (int i = 1; i <= n; i++) 
            {
                var sp = Console.ReadLine().Split(' ').ToList<string>();
                lines.Add(sp);
            }
            
            foreach (var line in lines)
            {
                var x1 = decimal.Parse(line[0]);
                var y1 = decimal.Parse(line[1]);
                var x2 = decimal.Parse(line[2]);
                var y2 = decimal.Parse(line[3]);
                var x3 = decimal.Parse(line[4]);
                var y3 = decimal.Parse(line[5]);
                var x4 = decimal.Parse(line[6]);
                var y4 = decimal.Parse(line[7]);
                var yy1 = y2 - y1;
                var yy2 = y4 - y3;

                if (yy1 == 0 && yy2 == 0) 
                {
                    Console.WriteLine("YES");
                }
                else if (yy1 == 0 || yy2 == 0)
                {
                    Console.WriteLine("NO");
                }
                else 
                {
                    var a1 = (x2 - x1) / (yy1);
                    var a2 = (x4 - x3) / (yy2);

                    Console.WriteLine(a1 == a2 ? "YES" : "NO");
                }

            }

        }
    }
}

Measured memory_bytes: 6132
def ans(N, M):
    if M == 0: return(N * N)
    cnt = 0
    for i in range(1,N+1):
        p, q = divmod(N,i)
        cnt += p * max(i-M,0) + max((q-M)+1,0)
    return(cnt)

N, M = list(map(int, input().split()))
print(ans(N, M))

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main() {
	string s;
	cin >> s;

	int i;
	bool res = false;

	for (i = 0; i < 3; i++) {
		if (s[i] == '7') {
			res = true;
			break;
		}

	}

	if (res) cout << "Yes";
	else cout << "No";

	return 0;
}

Measured memory_bytes: 3628
from fractions import gcd

def lcm(x, y):
    return (x * y) // gcd(x, y)

def main():
    a, b, c, d = map(int, input().split())

    ans = 0

    bc = b // c
    bd = b // d
    cd = lcm(c,d)
    bcd = b // cd

    bcount = b - bc -bd + bcd

    ac = (a-1) // c
    ad = (a-1) // d
    acd = (a-1) //cd

    acount = (a-1) - ac -ad + acd

    print(bcount-acount)

if __name__ == '__main__':
    main()

Measured memory_bytes: 65772
#include<bits/stdc++.h>
using namespace std;
using Int = long long;

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

//INSERT ABOVE HERE
signed main(){
  Int n,m,q;
  cin>>n>>m>>q;
  using P = pair<Int, Int>;
  vector<vector<P> > G(n);
  for(Int i=0;i<m;i++){
    Int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b,i);
    G[b].emplace_back(a,i);
  }
  
  vector<Int> d(m,q);
  for(Int i=0;i<q;i++){
    Int r;
    cin>>r;
    r--;
    d[r]=i;
  }

  vector<Int> dp(n,-1),ts(n,-1);
  queue<Int> x;
  dp[0]=0;
  ts[0]=q;
  x.emplace(0);
  while(!x.empty()){
    Int v=x.front();x.pop();
    //cout<<v<<":"<<dp[v]<<":"<<ts[v]<<endl;
    for(auto p:G[v]){
      Int u,c;
      tie(u,c)=p;
      Int nt=min(ts[v],d[c]);
      if(dp[u]<0){
	dp[u]=dp[v]+1;
	ts[u]=nt;
	x.emplace(u);
      }else if(dp[u]==dp[v]+1){
	chmax(ts[u],nt);
      }
    }    
  }

  vector<Int> ans(q+1,0);
  for(Int i=0;i<n;i++) ans[ts[i]]++;
  for(Int i=0;i<q;i++){
    cout<<ans[i]<<endl;
    ans[i+1]+=ans[i];
  }
  return 0;
}



Measured memory_bytes: 20336
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

template <typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

template <typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

int a[100010];
int dp[100010];

const int INF = 1e9;

int main() {
    int n;
    while (cin >> n) {
        rep(i, n) cin >> a[i];
        rep(i, n) dp[i] = INF;
        dp[0] = 0;
        rep(i, n) {
            chmin(dp[i+1],
                  dp[i] + abs(a[i] - a[i+1]));
            chmin(dp[i+2],
                  dp[i] + abs(a[i] - a[i+2]));
        }
        cout << dp[n-1] << endl;
    }
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b;

ll dfs(ll d,ll h){
  if(d==n)return b;
  ll H=(1LL<<(n-1-d));
  ll W=(1LL<<d);
  if(h<H){
    ll f=dfs(d+1,H-1-h);
    printf( f<W ? "L" : "R" );
    return W-f%W-1;
  }else{
    ll f=dfs(d+1,h-H);
    printf( f<W ? "R" : "L" );
    return f%W;
  }
}

int main(){
  while(1){
    scanf("%lld %lld %lld",&n,&a,&b);
    if(n==0&&a==0&&b==0)break;
    a--;
    b--;
    dfs(0,a);
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<utility>


#ifdef L_JUDGE
#pragma warning(disable:4996)
#endif

using namespace std;
const int MAXN=200;
const int INF=0x3f3f3f3f;
typedef pair<int,int> pii;

vector<pii> G[MAXN];
int N,M;
bool bEdge[MAXN][MAXN];



void Dijkstra(int st,int ed){
    bool vis[MAXN];
    int dist[MAXN];
    int path[MAXN];
    memset(dist,0x3f,sizeof(dist));
    memset(path,0,sizeof(path));
    memset(vis,false,sizeof(vis));
    dist[st]=0;
    path[st]=st;
    do{
        int mini=-1,minv=INF;
        for(int i=1;i<=N;i++){
            if(vis[i])continue;
            if(minv>dist[i]){
                mini=i;
                minv=dist[i];
            }
        }
        if(mini==-1)break;
        vis[mini]=true;
        bEdge[mini][path[mini]]=bEdge[path[mini]][mini]=false;
        for(int i=G[mini].size()-1;i>=0;i--){
             int v=G[mini][i].first;
             if(vis[v])continue;
             int c=G[mini][i].second;
             int tmp=dist[mini]+c;
             if(tmp<dist[v]){
                  path[v]=mini;
                  dist[v]=tmp;
             }
        }
    }while(1);
    return;
}


int main(){
	#ifdef L_JUDGE
		freopen("in.txt","r",stdin);
//		freopen("out.txt","w",stdout);
	#endif
    scanf("%d%d",&N,&M);
    memset(bEdge,false,sizeof(bEdge));
    for(int mi=0;mi<M;mi++){
         int u,v,c;
         scanf("%d%d%d",&u,&v,&c);
         G[u].push_back(make_pair(v,c));
         G[v].push_back(make_pair(u,c));
         bEdge[u][v]=bEdge[v][u]=true;
    }
    for(int ni=1;ni<=N;ni++){
         Dijkstra(ni,-1);
    }
    int ans=0;
    for(int i=1;i<=N;i++){
        for(int j=i+1;j<=N;j++){
            if(bEdge[i][j])ans++;
        }
    }
    printf("%d\n",ans);

	#ifdef L_JUDGE
		fclose(stdin);
		fclose(stdout);
//		system("out.txt");
	#endif

	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict
import sys

input = sys.stdin.buffer.readline

h, w, m = map(int, input().split())
xkouho = defaultdict(int)
ykouho = defaultdict(int)
kouho = set()
for _ in range(m):
    x, y = map(int, input().split())
    kouho.add((x, y))
    xkouho[x] += 1
    ykouho[y] += 1

max_x = []
max_xval = -1
for key, val in xkouho.items():
    if val > max_xval:
        max_x = [key]
        max_xval = val
    elif val == max_xval:
        max_x.append(key)
    else:
        continue

max_y = []
max_yval = -1
for key, val in ykouho.items():
    if val > max_yval:
        max_y = [key]
        max_yval = val
    elif val == max_yval:
        max_y.append(key)
    else:
        continue
ans = max_xval + max_yval
for x in max_x:
    for y in max_y:
        if (x, y) not in kouho:
            print(ans)
            exit()
ans -= 1
print(ans)


Measured memory_bytes: 185700
import java.util.Scanner;

public class Main{
	
	static Scanner sc;
	static int range;
	static int[] array;

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        range = sc.nextInt();
        array = new int[range + 1]; // array

        for(int i = 1; i <= range; i ++){
        	array[i] = sc.nextInt();
        }
        
        

        for(int j = 1; j <= range ; j ++){
            System.out.print("node " + j + ": key = " + array[j] + ", ");
            if(j/2 > 0){
                System.out.print("parent key = " + array[j/2] + ", ");
            }

            if(2*j <= range){
                System.out.print("left key = " + array[2*j] + ", ");
            }

            if((2*j + 1) <= range){
                System.out.print("right key = " + array[2*j + 1] + ", ");
            }
            System.out.println();
        }

    }


}



Measured memory_bytes: 27352
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define pb push_back
#define pii pair<int,int>
#define SZ(x) (int)x.size()
#ifdef __linux__
#define getchar getchar_unlocked
#endif
#define mem(a,b) memset(a,b,sizeof(a))
#define  For(i,a,b) for(int i=a,i##E=b;i<=i##E;++i)
#define rFor(i,a,b) for(int i=a,i##E=b;i>=i##E;--i)
typedef long long LL;
using namespace std;
const int N=21;
const int inf=0x3f3f3f3f;
template<typename T>inline bool chkmin(T &a,const T &b){return a>b?a=b,1:0;}
template<typename T>inline bool chkmax(T &a,const T &b){return a<b?a=b,1:0;}
template<typename T>inline void read(T &x)
{
	x=0;int _f(0);char ch=getchar();
	while(!isdigit(ch))_f|=(ch=='-'),ch=getchar();
	while( isdigit(ch))x=x*10+ch-'0',ch=getchar();
	x=_f?-x:x;
}
inline void file()
{
#ifdef ztzshiwo
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
#endif
}
int n,K;
int f[N][1<<N];
char x[1<<N];
inline void print(int n,int x)
{
	if(n==0)return;
	print(n-1,x>>1);
	printf("%d",x&1);
}
int main()
{
	file();
	read(n),read(K);
	For(i,0,n)
	{
		scanf("%s",x);
		For(j,0,(1<<i)-1)if(x[j]=='1')f[i][j]=1;
	}
	For(pos,0,n)rFor(i,n,pos+1)For(j,0,(1<<i)-1)
	{
		if(!f[i][j])continue;
		if(pos&&(j>>pos&1)==(j>>(pos-1)&1))continue;
		f[i-1][(j>>(pos+1)<<pos)|(j&((1<<pos)-1))]+=f[i][j];
	}
	rFor(i,n,0)For(j,0,(1<<i)-1)
	if(f[i][j]>=K)
	{
		print(i,j);
		exit(0);
	}
	return 0;
}


Measured memory_bytes: 50432
while True:
	try:
		n = int(input())
	except EOFError:
		break
	if n>36:
		print(0)
		continue
	ret=0
	for a in range(10):
		for b in range(10):
			for c in range(10):
				for d in range(10):
					if a+b+c+d==n:
						ret+=1
	print(ret)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
long long MAX_N = 1000000000000000000;
int main(){
  int n; cin >> n;
  vector<long long> v(n);
  for(long long &a: v){
    cin >> a;
    if(a == 0){
      cout << 0 << endl;
      return 0;
    }
  }
  long long ans = 1;
  for(int i = 0; i < n; ++i){
    if(ans > MAX_N / v[i]){
      cout << -1 << endl;
      return 0;
    } else {
      ans *= v[i];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n ;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
  }
  while(true){
    int huragu = 0;
    for(int i = 0; i + 1 < n ; i++){
      if( a.at(i) < a.at(i+1) ){
        int hako;
        hako = a.at(i);
        a.at(i) = a.at(i+1);
        a.at(i+1) = hako;
        huragu = 1;
      }
    }
    if(huragu == 0){
        break;
    }
  }
  int alice , bob;
  for(int i = 0; i < n ; i += 2){
    alice += a.at(i);
  }
  for(int i = 1; i < n ; i += 2){
    bob += a.at(i);
  }
  cout << alice - bob << endl;
}

Measured memory_bytes: 256
# 調理時間
a = [int(input()) for i in range(5)]

# 最後の料理は調理時間に左右されない = 21分みたいな最も不利な調理時間の料理を注文すべき
# それ以外の順番は問われない
# 10除算のあまりが最も少ない調理が最後

result = 0
last = 0
for i in a:
  if (i % 10) == 0:
    result += i
  elif last == 0:
    last = i
  elif (i % 10) < (last % 10):
    result += int(last / 10 + 1) * 10
    last = i
  else:
    result += int(i / 10 + 1) * 10
    
result += last
print(result)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//using ll = long long;
using P = pair<int,int>;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
T gcd(T a,T b){
	return b ? gcd(b,a % b) : a;
}

signed main(){
	int a,b,ans = 1;
	cin >> a >> b;
	int g = gcd(a,b),gg = g;
	for(int i = 2;i * i <= g;i++){
		if(gg % i == 0) ans++;
		while(gg % i == 0){
			gg /= i;
		}
	}
	if(gg != 1) ans++;
	cout << ans << endl;
}

Measured memory_bytes: 256
s = list(input())
while True:
  if "o" not in s:
    print("x")
    break
  if s[-1] == "x":
    while s[-1] == "x":s.pop()
  elif s[0] == "x":
    while s[0] == "x":s.pop(0)
  
  if "x" not in s:
    print("o")
    break
  if s[-1] == "o":
    while s[-1] == "o":s.pop()
  elif s[0] == "o":
    while s[0] == "o":s.pop(0)




Measured memory_bytes: 5560
"use strict"
// input data
function main(input) {
    const n = String(input.split('\n')[0].split(' '));
    if (n.includes('7')) {
        console.log('Yes');
    } else {
        console.log('No');
    }
}

// output
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29624
#include <algorithm> //STLͨ���㷨
#include <cmath> //������ѧ����
#include <cstdio> //��������/�������
#include <iostream> //����������/���
#include <cstring> //�ַ�������
#include <string> //�ַ�����
#include <ctime> //�������ʱ��ĺ���
#define itn int
#define fro for
#define ll long long
#define reg register
#define inf 1234567890
#define rep(i,a,b,c) for (int i=a;i<=b;i+=c)
/*#include <bitset> //STLλ������
#include <cstype> //�ַ�����
#include <cerrno> //���������
#include <complex> //������
#include <clocale> //���屾�ػ�����
#include <cstdlib> //������������ڴ���亯��
#include <deque> //STL˫�˶�������
#include <exception> //�쳣������
#include <fstream> //�ļ�����/���
#include <functional> //STL�������㺯��(���������)
#include <limits> //�����������������ֵ����
#include <list> //STL�����б�����
#include <map> //STLӳ������
#include <iomanip> //����������/���
#include <ios> //��������/���֧��
#include <iosfwd> //����/���ϵͳʹ�õ�ǰ������
#include <istream> //����������
#include <ostream> //���������
#include <queue> //STL��������
#include <set> //STL��������
#include <sstream> //�����ַ�������
#include <stack> //STL��ջ����
#include <stdexcept> //��׼�쳣��
#include <streambuf> //�ײ�����/���֧��
#include <utility> //STLͨ��ģ����
#include <vector> //STL��̬��������
#include <cwchar.h>//���ַ�����������/���
#include <cwctype.h> //���ַ�����*/

using namespace std;

int ans;

int max(int x,int y){return x>y?x:y;}

int min(int x,int y){return x<y?x:y;}

int abs(int x){return x>0?x:-x;}

int gcd(int x,int y){return (!y)?x:gcd(y,x%y);}

void exgcd(int a,int b,int &d,int &x,int &y){if (!b){d=a,x=1,y=0;}else{exgcd(b,a%b,d,y,x);y-=x*(a/b);}}

int quick_power(ll a,int b){ll r=1;for (;b;b>>=1,a=a*a)if (b&1) r=r*a;return r;}

inline char read() {
	static const int IN_LEN = 1000000;
	static char buf[IN_LEN], *s, *t;
	return (s == t ? t = (s = buf) + fread(buf, 1, IN_LEN, stdin), (s == t ? -1 : *s++) : *s++);
}
template<class T>
inline void read(T &x) {
	static bool iosig;
	static char c;
	for (iosig = false, c = read(); !isdigit(c); c = read()) {
		if (c == '-') iosig = true;
		if (c == -1) return;
	}
	for (x = 0; isdigit(c); c = read()) x = x * 10 + (c ^ '0');
	if (iosig) x = -x;
}

char sr[10000000],z[20];int C=-1,Z=0;
void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(int x){
	if (x<0) sr[++C]='-',x=-x;
    while(z[++Z]=x%10+48,x/=10);
    while(sr[++C]=z[Z],--Z);sr[++C]='\n';
}
//int find(int x){return fa[x]=fa[x]==x?x:find(fa[x]);}

//void add(int x,int y,int z){to[++cnt]=y;v[cnt]=z;Next[cnt]=head[x];head[x]=cnt;}

#define mid (l+r>>1)
int a[512][512];

void solve(int l,int r,int col)
{
	if (l==r) return ;
	for (int i=l;i<=mid;i++)
		for (int j=mid+1;j<=r;j++)
			a[i][j]=a[j][i]=col;
	solve(l,mid,col+1);solve(mid+1,r,col+1);
}

int main()
{
	int n;
	read(n);
	solve(1,n,1);
	for (int i=1;i<n;i++,puts(""))
		for (int j=i+1;j<=n;j++) printf("%d ",a[i][j]);
	return 0;
}









Measured memory_bytes: 1536
#include <stdio.h>
#include <string.h>
int main(void){
    int i,n,k[100];
    char s[101],c[52];
    
    for(i=0;i<26;i++){
        c[i]=97+i;
    }
    for(i=26;i<52;i++){
        c[i]=65+i-26;
    }
    for(;;){
        scanf("%d",&n);
        if(n==0){
            break;
        }
        for(i=0;i<n;i++){
            scanf("%d",&k[i]);
        }
        scanf("%s",s);
        
        for(i=0;i<strlen(s);i++){
            if(s[i]<=90){
                printf("%c",c[((int)s[i]-k[i%n]+13)%52]);
            }else if(s[i]>=97){
                printf("%c",c[((int)s[i]-45-k[i%n])%52]);
            }
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 576
#include <iostream>
#include <cctype>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cctype>
#include <cstring>
#include <utility>
#include <cmath>
#include <string>
#define FOR(i,a,n) for(int i=(a);i<(n);i++)
#define INF (1<<21)
using namespace std;


int main(){
    char n[4];
    FOR(i,0,4) cin>>n[i];
    if((n[0]==n[1]&&n[1]==n[2])||(n[1]==n[2]&&n[2]==n[3])) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
// Hint: Don't look, No need, Let'em Play.

#include <bits/stdc++.h>
#include "bits/stdc++.h"

using namespace std;

#define int long long
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

#ifndef bhupixb
    #define var(...)
    #define stl(...)
#endif

#define single_test

void solve() {
    int l, r, n, ans = 0;
    cin >> l >> r >> n;
    for (int i = l; i <= r; ++i) {
        ans += (i % n == 0);
    }
    cout << ans << '\n';
}

signed main() {
    fast;
    int t = 1;
    #ifndef single_test
        cin >> t;
    #endif
    while (t--) {
        solve();
    }

    return 0;
}

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

int main(){
	int N,K;
	int a[50];
	cin >> N >> K;
	rep (i, N) cin >> a[i];
	sort(a, a + N, greater<int>());
	int res;
	rep (i, K) res += a[i];
	cout << res << endl;
}

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

using namespace std;

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

int N;

int main() {
	cin >> N;
	vector<int> x(N, 0);
	vector<int> y(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> x[i] >> y[i];
	}

	int ans = 1;
	vector<vector<P> > mass(N, vector<P> (N, make_pair(0, 0)));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			mass[i][j].first = x[i] - x[j];
			mass[i][j].second = y[i] - y[j];
		}
	}
	int p, q;
	int a;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			a = 1;
			p = mass[i][j].first;
			q = mass[i][j].second;
			for (int k = 0; k < N; k++) {
				for (int l = 0; l < N; l++) {
					if (k == l) { continue; }
					if (mass[k][l].first == p && mass[k][l].second == q) {
						a--;
						break;
					}
				}
				a++;
			}
			ans = max(ans, N + 1 - a);
		}
	}

	if (N == 1) { cout << 1 << endl; }
	else {
		cout << N - ans << endl;
	}

}

Measured memory_bytes: 256
n = int(input())
h = list(map(int,input().split()))
count = 0
lis =[]
for i in range(n-1):
   if h[i] >= h[i+1]:
      count +=1
   else:
       lis.append(count)
       count = 0
lis.append(count)

print(max(lis))

Measured memory_bytes: 14252
#include <bits/stdc++.h>
#include <algorithm>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
 
 
int main() {  
 
    string s;
    cin >> s;
    int q;
    cin >> q;
    vector<int> v(q);
    vector<int> f(q);
    vector<string> c(q);
    rep(i,q) {
        cin >> v[i];
        if(v[i]!=1) {
            cin >> f[i];
            cin >> c[i];
        }
    }

    int count=0;
    rep(i,q) {
        if(v[i]==1) {
            count++;
        }
        else {
            if(count%2==0) {
                if(f[i]==1) s.insert(0,c[i]);
                else    s.append(c[i]);
            }
            else {
                if(f[i]==1) s.append(c[i]);
                else    s.insert(0,c[i]);
            }
        }

    }
    if(count%2==1) reverse(all(s));

    cout<<s<<endl;
 
 return 0;
}

Measured memory_bytes: 13440
#include<iostream>
#include<cstdio>
#include<math.h>
#include<string>
#include<algorithm>
#include<functional>
#include<vector>
#include<set>
#include<map>
#define INF 999999
#define EPS 1.0e-6

using namespace std;

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

string s;
int alp[30];

int main()
{
	cin >> s;
	int len = s.length();
	int xnum = 0;

	string r = "";
	string l = "";
	vector<int> index;
	for (int i = 0; i < len; i++) {
		if (s[i] != 'x') {
			l += s[i];
			index.push_back(i);
		}
		else xnum++;
	}

	for (int i = len - 1; i >= 0; i--) {
		if (s[i] != 'x')r += s[i];
	}
	//cout << r << endl;
	//cout << l << endl;


	int is = (int)index.size();
	int middle;


	if (is == 0) {
		cout << 0 << endl;
		return 0;
	}
	
	if (is == 1) {
		int lx = 0;
		for (int i = 0; i < len; i++) {
			if (s[i] != 'x')break;
			if (s[i] == 'x')lx++;
		}
		cout << xnum - 2 * min(lx,xnum-lx);
		return 0;
	}
	

	int k, t;
	if (is % 2 == 0) {
		middle = is / 2 - 1;
		k = index[middle] - 1;
		t = index[middle+1] + 1;
		xnum -= t - k - 3;
	}
	else {
		middle = is / 2;
		k = index[middle] - 1;
		t = index[middle] + 1;
		//xnum -= t - k - 2;
	}

	//cout << k << " " << t << endl;

	ll ans = 0;
	if (r == l) {
		while (k >= 0 && t <= len - 1) {
			if (s[k] != s[t]) {
				if (s[k] == 'x') {
					ans++;
					k--;
					xnum--;
				}
				else {
					ans++;
					t++;
					xnum--;
				}
			}
			else {
				if (s[k] == 'x')xnum -= 2;
				k--; t++;
				
			}
		}
		//cout << xnum << endl;
		cout << ans+xnum << endl;
	}
	else cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1148
#include<bits/stdc++.h>                                                                        
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<string> W(N);
  for(int i=0; i<N; i++){
    cin >> W.at(i);
  }
  int count=0;
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(i!=j){
      if(W.at(i)==W.at(j))
        count++;
      }
    }
  }
  int judge=0;
  for(int i=0; i<N; i++){
    if(i!=0){
      if(W.at(i).at(0)!=W.at(i-1).at(W.at(i-1).size()-1))
        judge++;
    }
  }
  if(count==0 && judge==0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

using namespace std;

using ll = long long;

constexpr char endl('\n');

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)

using bs = bitset<3>;

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

    vector<int> a(4);
    string s;
    cin >> s;
    REP(i, 4) {
        a.at(i) = s.at(i) - '0';
    }
    vector<int> res(4);
    res.at(0) = a.at(0);
    REP(i, 8) {
        bs b(i);
        REP(j, 3) {
            res.at(j + 1) = b.test(j) ? res.at(j) + a.at(j + 1) : res.at(j) - a.at(j + 1);
        }
        if (res.at(3) == 7) {
            REP(j, 3) {
                cout << a.at(j) << (b.test(j) ? "+" : "-");
            }
            cout << a.at(3) << "=7\n";
            break;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(auto i=0;i<n;i++)
#define s(c) static_cast<int>((c).size())

int H = 0;

//1  maxHeapify(A, i)
//2      l = left(i)
//3      r = right(i)
//4      // select the node which has the maximum value
//5      if l ≤ H and A[l] > A[i]
//6          largest = l
//7      else
//8          largest = i
//9      if r ≤ H and A[r] > A[largest]
//10         largest = r
//11
//12     if largest ≠ i　// value of children is larger than that of i
//13         swap A[i] and A[largest]
//14         maxHeapify(A, largest) // call recursively
void maxHeapify(int A[], int i){
	int l = 2*i;
	int r = l+1;

	int largest = (l <= H && A[l] > A[i]) ? l : i;
	if(r <= H && A[r] > A[largest]) largest = r;
	if(largest != i){
		swap(A[i], A[largest]);
		maxHeapify(A, largest);
	}
}

//1 buildMaxHeap(A)
//2    for i = H/2 downto 1
//3        maxHeapify(A, i)
void buildMaxHeap(int A[]){
	for(int i = H/2; i > 0; i--)
		maxHeapify(A, i);
}

int main(){
	cin >> H;
	int A[H+1];
	for(int i = 1; i <= H; i++){
		cin >> A[i];
	}

	buildMaxHeap(A);
	for(int i = 1; i <= H; i++){
		printf(" %d", A[i]);
	}
	printf("\n");
	return 0;
}



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

int main() {
    int s;

    cin >> s;

    int s1, s2, s3;

    s1 = s / 100;
    s2 = (s - s1 * 100) / 10;
    s3 = (s - s1 * 100 - s2 * 10);

    cout << s1 + s2 + s3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=1;;i++)
	{
		if(i*b>=a)
		{
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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

int main(){

    int K,S;
    cin >> K >> S;

    int c=0;

    for(int i=0;i<=K;i++){
        for(int j=0;j<=K;j++){
            if(0 <= S-i-j &&S-i-j<=K){
                c++;
            }
        }
    }
    
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict
input = sys.stdin.readline
sys.setrecursionlimit(pow(10, 6))

edges = defaultdict(lambda: [])
used = [False for _ in range(1001000)]
d = [1 for _ in range(1001000)]


def dfs(i):
    if used[i]:
        return d[i]
    else:
        used[i] = True
        ret = 0
        for v in edges[i]:
            tmp = dfs(v)
            if ret < tmp+1:
                ret = tmp+1
        d[i] = ret
        return ret


def main():
    n = int(input())
    h = [0 for _ in range(1001000)]
    for i in range(n):
        a = list(map(int, input().split()))
        for j in range(1, n-1):
            pa = a[j-1]-1
            na = a[j]-1
            pi = i
            ni = i
            if na > ni:
                na, ni = ni, na
            if pa > pi:
                pa, pi = pi, pa
            edges[1000*pi + pa].append(1000*ni + na)
            h[1000*ni + na] += 1
    
    stack = []
    for k, _ in edges.items():
        if h[k] == 0:
            stack.append(k)
    
    ans = 0
    while len(stack):
        u = stack.pop()
        for v in edges[u]:
            h[v] -= 1
            if h[v] == 0:
                stack.append(v)
        ans += 1

    if ans != n*(n-1)//2:
        print(-1)
    else:
        ret = 0
        for k, _ in edges.items():
            tmp = dfs(k)
            if tmp > ret:
                ret = tmp
        print(ret+1)


if __name__ == '__main__':
    main()


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

int main() {
/*def*/
    string s;
/*input*/
    cin >> s;

/*main*/
    if (s.back()=='s') {
        s+="es";
    }
    else{
        s+="s";
    }
/*output*/
    cout << s << endl;
}


Measured memory_bytes: 3596
#include <stdio.h>

int main(void) {

  int i,j;
  int n;

  scanf("%d",&n);

  int t[n][4];

  for(i=0;i< n;i++)
    scanf("%d %d %d",&t[i][0],&t[i][1],&t[i][2]);

  for(i=0;i< n;i++) {
    for(j=1;j< 3;j++) {
      if(t[i][0]< t[i][j]) {
	t[i][3]=t[i][0];
	t[i][0]=t[i][j];
	t[i][j]=t[i][3];
      }
    }
    if(t[i][0]*t[i][0]==t[i][1]*t[i][1]+t[i][2]*t[i][2])
      printf("YES\n");
    else
      printf("NO\n");
  }

  return 0;

}

Measured memory_bytes: 0
import java.util.Scanner

object Main extends App {

  val sc = new Scanner(System.in)

  val (a, b) = (sc.nextInt, sc.nextInt)

  if (a + b == 15) {
    println("+")
  } else if (a * b == 15) {
    println("*")
  } else {
    println("x")
  }
}


Measured memory_bytes: 27324
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define MOD 1000000007
#define ar array
#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL);

int32_t main() {
	fast_io;

	// int t; cin >> t;
	// while (t--) {

	// }
	string K; cin >> K;
	int D; cin >> D;
	int len = (int) K.size();
	vector<vector<int>> dp(D, vector<int> (2));

	for (int digit = 0; digit < K[0] - '0'; digit++) {
		dp[digit % D][true]++;
	}
	dp[(K[0] - '0') % D][false]++;

	for (int pos = 1; pos < len; pos++) {
		vector<vector<int>> new_dp(D, vector<int> (2));
		for (int sum = 0; sum < D; sum++) {
			for (bool choose_any_digit : {false, true}) {
				for (int digit = 0; digit < 10; digit++) {
					if (digit > K[pos] - '0' && !choose_any_digit) {
						break;
					}
					new_dp[(sum + digit) % D][choose_any_digit || digit < K[pos] - '0'] += dp[sum][choose_any_digit];
					new_dp[(sum + digit) % D][choose_any_digit || digit < K[pos] - '0'] %= MOD;
				}
			}	
		}
		dp = new_dp;
	}
	int res = (dp[0][true] + dp[0][false]);
	res--;
	if (res < 0) {
		cout << res + MOD << endl;
	}
	else {
		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 3600
n,m = map(int,input().split())

ls = []
for i in range(m):
    x,l = map(int,input().split())
    ls.append([x,l])
    
ls = sorted(ls, key=lambda x: x[1])
ans =m
for i in range(1,m):
    if ls[i][0] < ls[i-1][1]:
      ls[i][1] = ls[i-1][1]
      ans -=1
        
print(ans)

Measured memory_bytes: 26300
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int y=1000*(int)(s.at(0)-'0')+100*(int)(s.at(1)-'0')+10*(int)(s.at(2)-'0')+(int)(s.at(3)-'0');
  int m=10*(int)(s.at(5)-'0')+(int)(s.at(6)-'0');
  int d=10*(int)(s.at(8)-'0')+(int)(s.at(9)-'0');
  cout<<(y<=2019&&(y<2019||m<=4)&&(m<4||d<=30)?"Heisei":"TBD")<<endl;
}

Measured memory_bytes: 256
/*
ID: thanhvq1
LANG: C++14
PROB: namenum
*/

#pragma GCC optimize ("O2")
#include<bits/stdc++.h>
#include<unistd.h>
using namespace std;
#define int long long
#define double long double
#define vec vector
#define vi vector<int>
#define FZ(n) memset((n),0,sizeof(n))
#define FMO(n) memset((n),-1,sizeof(n))
#define unset unordered_set
#define ii pair<int, int>
#define vii vector<ii>
#define F first
#define S second
#define PB push_back
#define ALL(x) begin(x),end(x)
#define SZ(x) ((int)(x).size())
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORE(i, a, b) for(int i = (a); i <= (b); i++)
#define FORD(i, a, b) for(int i = (a); i >= (b); i--)
#define bitcount(n) __builtin_popcountll(n)
template <typename T,typename U>
std::pair<T,U> operator+(const std::pair<T,U> & l,const std::pair<T,U> & r) {
  return {l.first+r.first, l.second+r.second};
} 
typedef void (*callback_function)(void); // type for conciseness
const long long ZERO = 0LL;
const long long INF64 = 1e18;
const int INF32 = 1e9;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0L);
const double EPS = static_cast<double>(1e-9);
typedef long long ll;

void FILEIO() {  freopen("in.txt", "r", stdin);  freopen("out.txt", "w", stdout); }
//void FILEIO() {  freopen("namenum.in", "r", stdin);  freopen("namenum.out", "w", stdout); }
void input() {   }
const int M = 1e6;
int n, m;
vi a;
vii cb;

void showA() {
	FOR(i, 0, n) cout << a[i] << ", ";
	cout << endl;
}

void showCB() {
	FOR(i, 0, m) cout << cb[i].F << " - " << cb[i].S << "; ";
	cout << endl;
}

void solve() {
	cin >> n >> m;
	a.resize(n);
	FOR(i, 0, n) cin >> a[i];
	cb.resize(m);
	FOR(i, 0, m) cin >> cb[i].S >> cb[i].F;
	sort(a.begin(), a.end());

//	showA();

	sort(cb.begin(), cb.end()); reverse(cb.begin(), cb.end());

//	showCB();

	int replaced = 0, currentB = 0, i = 0;
	while(i<n) {

//		cout << " replaced = " << replaced <<", currentB = " << currentB
//				<< ", i = " << i << endl;

		replaced++;
		if(replaced <= cb[currentB].S) {
			if(a[i] < cb[currentB].F) {
				a[i] = cb[currentB].F;
			}
			else break;
			i++;

//	showA();

		}
		else {
			replaced = 0;
			currentB ++;
			if(currentB >= m) break;
		}
	}

//	showA();

	int sum = 0;
	FOR(i, 0, n) sum += a[i];
	cout << sum << endl;
}

//#undef int
signed main() {
//#define int long long
  ios_base::sync_with_stdio(false); cin.tie();
//  FILEIO();
//auto beginProgram = chrono::steady_clock::now();

//  while (1)
//  {
		input();
		solve();
//  }

  //auto endProgram = chrono::steady_clock::now();

  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
    
int findSumOfDigits(int n) {
int sum = 0;
while (n > 0) {
    sum += n % 10;
    n /= 10;
}
return sum;
}

int main (){
    int N,f;
    cin >> N;
    f = findSumOfDigits(N);
    if(N%f == 0){
        cout << "Yes" << endl;
    }
    else{cout << "No" << endl;
    }
}

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

using namespace std;

int main()
{
    int a,b,c,p,q,r;

    cin>>p>>q;

    a=p+q;
    b=p-q;
    c=p*q;

    r=max(a,max(b,c));


    cout<<r<<"\n";

    return 0;

}


Measured memory_bytes: 256