akhauriyash/Code-Regression huggingface dataset:
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  string s, t;
  cin >> s >> t;

  ll ns = s.size(), nt = t.size();

  if(ns < nt) {
    cout << "UNRESTORABLE" << endl;
    return 0;
  }

  auto f = [](string x, string y){
    rep(i, (ll)x.size()){
      if(x[i] != y[i] && x[i] != '?') {
        return false;
      }
    }
    return true;
  };

  bool ok = false;
  rrepLRE(i, ns - nt, 0) {
    if(f(s.substr(i, nt), t)){
      ok = true;
      rep(j, nt) s[i + j] = t[j];
      break;
    }
  }
  rep(i, ns) if(s[i] == '?') s[i] = 'a';
  if(!ok) s = "UNRESTORABLE";

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


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

int main() {
	vector<int> v;

	for(int i = 0; i < 10; i++)
		v.push_back(i);
	for(int i = 5; i > 0; i--)
		v.push_back(i);

	int n;
	cin >> n;
	for(int t = 0; t < n; t++) {
		int s, g;
		vector<int> ret;
		ret.resize(64);
		cin >> s >> g;
		for(int i = 0;i < v.size(); i++) {
			if(s == v[i]) {
				vector<int> tmp;
				for(int j = i;; j++) {
					tmp.push_back(v[j % v.size()]);
					if(v[j % v.size()] == g)
						break;
				}
				if(tmp.size() < ret.size())
					ret = tmp;
			}
		}

		cout << ret[0];
		for(int i = 1; i < ret.size(); i++)
			cout << " " << ret[i];
		cout << endl;
	}
}

Measured memory_bytes: 1212
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N];
long long l,r;
int main()
{
    scanf("%d",&n);
    for (int i=1;i<=n;i++) scanf("%d",&a[i]);
    l=r=2;
    for (int i=n;i;i--){
        l=(l+a[i]-1)/a[i]*a[i];
        r=r/a[i]*a[i];
        if (l>r) return puts("-1"),0;
        r+=a[i]-1;
    }
    cout<<l<<" "<<r<<endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/






int M, K;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> M >> K;

	int N = 1;
	rep(i, 0, M) N *= 2;

	if (K == 0) {
		rep(i, 0, N) printf("%d %d ", i, i);
		printf("\n");
		return;
	}

	if (M == 1 and K == 1) {
		cout << "-1" << endl;
		return;
	}

	if (N <= K) {
		cout << "-1" << endl;
		return;
	}

	rep(i, 0, N) if (i != K) printf("%d ", i);
	printf("%d ", K);
	rrep(i,N-1, 0) if (i != K) printf("%d ", i);
	printf("%d\n", K);
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define lp(x,y) for(ll i=x;i<y;i++)
#define pb push_back

int main()
{
    int t,a,b,count=1;
    cin>>t>>a>>b;
    for(int i=a;i<=b;i++)
    {
        if(i%t==0) {count=0; break;}
    }
    if(count==0) cout<<"OK";
    else cout<<"NG";
}

Measured memory_bytes: 3632
def insertionSort(arr):
    for i in range(1, len(arr)): 
        v = arr[i] 
        j = i-1
        print(*arr)                                          
        while j >= 0 and v < arr[j] : 
            arr[j+1] = arr[j] 
            j -= 1
        arr[j+1] = v
        
    print(*arr)

n = int(input())
ls = list(map(int,input().split()))
insertionSort(ls)



Measured memory_bytes: 5976
#include <iostream>

int W, H;
int sx, sy;
char map[20][20];
int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};
int cnt = 0;

void dfs(int y, int x){
  map[y][x] = '#';
  cnt++;
  for(int i=0; i < 4; i++){
    if(0 <= y + dy[i] && y + dy[i] < H && 0 <= x + dx[i] && x + dx[i]< W && map[y + dy[i]][x + dx[i]] == '.'){
      dfs(y + dy[i], x + dx[i]);
    }
  }
}



int main(void){
  while(1){
    std::cin >> W >> H;
    if(W == 0 && H == 0)  return 0;

    for(int i=0; i < H; i++){
      for(int j=0; j < W; j++){
        std::cin >> map[i][j];
        if(map[i][j] == '@'){
          sx = j; sy = i;
        }
      }
    }

    cnt = 0;
    dfs(sy, sx);

    std::cout << cnt << std::endl; 
  }
}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define dump(x) cout << (x) << endl;

int main() {
  int n, k;
  vector<int> a(n);
  cin >> n >> k;
  rep(i, n) {
    cin >> a[i];
  }
  int x;
  x = (n-1)/(k-1);
  if ((n-1)%(k-1) != 0) {
    x += 1;
  }
  dump(x);
  return 0;
}



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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr)
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))
#define trav(i,a) for(auto& (i) : (a))
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).size())
#define clr(a,x) memset((a),(x),sizeof(a)) // array (0,-1)
#define dbg(x) cerr << "STDERR => " << __LINE__ << ": " << #x << " = " << (x) << "  :(\n";
#define eb emplace_back
#define mp make_pair
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline void cpuTime() { cerr << "cpu time : " << double(clock())/CLOCKS_PER_SEC << "\n"; return; }
using ll = long long;
using ull = unsigned long long;
using F = float;
using D = double;
using vi = vector<int>;
using pii = pair<int,int>;



void solve(){

    char s[3],t[3];
    cin >> s >> t;

    int ans = 0;
    rep(i,0,3) if(s[i] == t[i]) ++ans;

    cout << ans << "\n";

    return;
}

/*
 read the question carefully ( what're the exact constraints? )
 look out for SPECIAL CASES (n=1?) and OVERFLOW (ll vs int?) ARRAY OUT OF BOUNDS
 Check datatypes
*/
int main(){

    fast_io;
    int t=1;
    // cin >> t;

    while(t--){
        solve();
    }

    cpuTime();
return 0;
}




Measured memory_bytes: 256
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
int solve()
{

	int n,x;
	cin>>n>>x;
	vi g;
	g.pb(x);
	for(int i=1;i<n;i++)
	{
		int init=g[g.size()-1];
		cin>>x;
		if(x<init)
			g.pb(x);
	}
	cout<<g.size()<<endl;


}
signed main()
{
	fastio;
	clock_t start, end;
//	test
	{
		start=clock();
		solve();
		end=clock();
		double time_taken=double(end-start)/double(CLOCKS_PER_SEC);
//		cout<<time_taken<<endl;
	}
}


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

int main() {
    double N, K;
    cin >> N >> K;

    double res = 0;
    for (int i = 0; i < N; i++) {
        double prob = 1 / N;
        int score = i + 1;
        while (score < K) {
            score *= 2;
            prob *= (double)1 / 2;
        }
        res += prob;
    }
    printf("%.9f", res);
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long a,b,i,flag=0,temp,temp1;
	cin>>a>>b;
	temp=max(a,b);
	temp1=min(a,b);
	for(i=temp1;i<=temp;i++)
	{
		if(abs(temp1-i)==(temp-i))
		{
			cout<<i<<endl;
			flag=1;
		}	
	}
	if(flag!=1)
	cout<<"IMPOSSIBLE"<<endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=[[] for _ in range(n+1)]
ans=[-1]*m
for i in range(m):
    p,y=map(int,input().split())
    x[p].append([y,i])

for p in range(1,n+1):
    x[p].sort()
    for j in range(len(x[p])):
        ans[x[p][j][1]]=str(p).zfill(6)+str(j+1).zfill(6)

for i in range(m):
    print(ans[i])

Measured memory_bytes: 81056
#include <limits.h>
#include <stdio.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>

#include <bits/stdc++.h>

namespace test {
std::string to_string(char val) {
    return std::string(1, val);
    // return std::string{val};
}
}  // namespace test

using namespace std;

int main(void) {
    int *a,k; a = new int[5]; 
    for(int i = 0; i < 5; i++){
        cin >> a[i];
    }
    cin >> k;

    cout << (a[4] - a[0] <= k ? "Yay!" : ":(") << endl; 
    return 0;
}

Measured memory_bytes: 384
namespace atcoder
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Runtime.CompilerServices;
    using static System.Math;
    using static Ex;
    class Program
    {
        static void Main(string[] args) => new Program().Solve();

        void Solve()
        {
            var t1 = GetInputs.AsInt().ToArray();
            var X = t1[0];
            var N = t1[1];
            if (N == 0) {
                Console.WriteLine(X);
            }
            else
            {
                var p = new HashSet<int>(GetInputs.AsInt());

                Console.WriteLine(
                    Enumerable.Range(-1, 200)
                        .Select(x => (x, Abs(X - x)))
                        .OrderBy(x => x.Item2)
                        .Where(x => !p.Contains(x.x))
                        .First().x
                );
            }
        }

    }

    static class Ex
    {
        public static IEnumerable<string> GetInputs => Console.ReadLine().Split();
        public static IEnumerable<int> AsInt(this IEnumerable<string> xs) => xs.Select(int.Parse);
    }

}

Measured memory_bytes: 28232
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstring>
#include <string>
#include <cmath>
#include <iomanip>
#include <cstdio>
using namespace std;

typedef long long ll;

const int maxn = 1e5+5;
int N,M;
int fa[maxn];
int size[maxn];
ll ans[maxn];
int l[maxn];
int r[maxn];

int find(int x)
{
    return fa[x] == x ? x : fa[x] = find(fa[x]); //这里一开始写错了，写成了x = find。。
}

void join(int a, int b)
{
    a = find(a), b = find(b);
    if(a != b)
    {
        size[a] += size[b];
        size[b] = 0;
       fa[b] = a;
    }
}
int main(){
	cin>>N>>M;

	for(int i=0;i<maxn;i++)
		fa[i] = i,size[i]=1;
	 memset(ans, 0, sizeof(ans));
		
	for(int i=1;i<=M;i++)
		scanf("%d%d", &l[i], &r[i]);
	ll cnt = N;
	ans[M+1] = cnt*(cnt-1)/2;
	for(int i = M;i>=2;i--){
		int x = find(l[i]);
		int y = find(r[i]);
		if(x!=y){
			ans[i] = ans[i+1]-size[x]*size[y];
			join(l[i],r[i]);
		}
		else 
			ans[i] = ans[i+1];
	}
	
	for(int i=2;i<=M+1;i++)
		  printf("%lld\n", ans[i]);
	
	return 0;
}

Measured memory_bytes: 3712
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var abc = ReadIntArray();
            if (abc[0] == abc[1] + abc[2] ||
                abc[1] == abc[0] + abc[2] ||
                abc[2] == abc[0] + abc[1]  )
            {
                Console.WriteLine("Yes");      
            }
            else
            {
                Console.WriteLine("No");
            }
        }


        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#include <math.h>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 61;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;
const int NN = 5e3 + 6;

void solve()
{
    string s;
    cin>>s;
    if(s == "SUN")
        cout<<7;
    else if(s == "MON")
        cout<<6;
    else if(s == "TUE")
        cout<<5;
    else if(s == "WED")
        cout<<4;
    else if(s == "THU")
        cout<<3;
    else if(s == "FRI")
        cout<<2;
    else if(s == "SAT")
        cout<<1;

    cout<<'\n';
    return ;
}

/*
*/
;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

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


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String S = sc.next();
    
    int countC = 0;
    for (int i = 0; i < S.length(); i++) {
      char c = S.charAt(i);
      if (i == 0) {
        if (c != 'A') {
          System.out.println("WA");
          return;
        }
      } else if (2 <= i && i <= S.length() - 2 && c == 'C') {
        countC++;
      } else {
        if (!('a' <= c && c <= 'z')) {
          System.out.println("WA");
          return;
        }
      }
    }
    if (countC != 1) {
      System.out.println("WA");
      return;
    }

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

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

#define REP(i ,n) for(int i=0 ;i < n; i++)
#define REPB(i ,n) for(int i=n; i >= 0; i--)
#define FOR(i ,m ,n) for(int i=m; i < n; i++)
#define FORB(i, m, n) for(int i=m; i>= n; i--)
#define ll long long
#define pb push_back
#define popb pop_back
#define debug(i) cout << i << endl
using namespace std;
int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<ll,ll>> dr;

  REP(i, n){
      ll a, b;
      cin >> a >> b;
      dr.pb(make_pair(a, b));
    }
    ll count = 0;
    ll ans = 0;
    sort(dr.begin(),dr.end());

    for(ll i = 0;count < m; i++){
      int r = m - count;
      if(r < dr[i].second){
          ans+= (r * dr[i].first);
          count+= r;
        }else{
            ans+= (dr[i].first * dr[i].second);
            count += dr[i].second;
          }
      }
      cout << ans << endl;
      return 0;
}

Measured memory_bytes: 2420
# ナップザック問題
N, W = map(int, input().split())
wv = [list(map(int, input().split())) for _ in range(N)]

inf = float("inf")
dp = [[-inf for _ in range(W+1)] for _ in range(N+1)]
for i in range(W+1):
    dp[0][i] = 0

for i in range(N):
    weight = wv[i][0]
    value = wv[i][1]
    for w in range(W+1):
        # 重量に収まる場合のみ価値を加える
        if weight <= w:
            dp[i+1][w] = max(dp[i][w-weight] + value, dp[i][w])
        else:
            dp[i+1][w] = dp[i][w]
print(max(dp[-1]))


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

using namespace std ;

const int MAX = 1e5 + 10 ;

int arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	n %= 10 ;
	if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
		return cout<<"hon\n" , 0 ;
	if(n == 3)
		return cout<<"bon\n" , 0 ;
	return cout<<"pon\n" , 0 ;
}		

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

int main(){
    long long n, k, r, s, p;

    cin >> n >> k >> r >> s >> p;

    string machine;

    cin >> machine;
    string hand;
    int point;
    int ans = 0;

    for(int i = 0; i < n; i++){
        if(machine[i] == 'r'){
            hand.push_back('p');
            point = p;
        }
        else if(machine[i] == 's'){
            hand.push_back('r');
            point = r;
        }
        else if(machine[i] == 'p'){
            hand.push_back('s');
            point = s;
        }

        if(i-k >= 0 and hand[i-k] == hand[i]){
            hand[i] = ' ';
            point = 0;
        }
        ans += point;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+10;


ll a[maxn];
int main()
{
	ll n;
	cin >> n;
	for(int i=0;i<n;i++)
		cin >> a[i];
	sort(a,a+n);
	ll sum1=0,sum2=0;
	for(int i=0;i<n;i++)
	{
		if(i%2)
			sum1+=a[i];
		else
			sum2+=a[i];
	}
	cout << abs(sum1-sum2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m,k,a[100010],b[100010],x,y,z,mn1=1e9,mn2=1e9,ans;
int main(){
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        mn1=min(mn1,a[i]);
    }
    for(int i=1;i<=m;i++){
        cin>>b[i];
        mn2=min(mn2,b[i]);
    }
    ans=mn1+mn2;
    while(k--){
        cin>>x>>y>>z;
        ans=min(ans,a[x]+b[y]-z);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
	int a,b,c,d,p;
	cin>>a>>b>>c>>d>>p;
	if(p<=c){
		if(p*a<b) cout<<p*a<<endl;
		else cout<<b<<endl;
	}
	else{
		if(p*a<b+(p-c)*d) cout<<p*a<<endl;
		else cout<<b+(p-c)*d<<endl;
	}
	return 0;
}


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

vector<int> doubling(vector<int> v, long long k){
  int n = v.size(), t = 1; long long l = k;
  while(l > 0){
    ++t;
    l /= 2;
  }
  vector<int> ans(n); vector<vector<int>> tmp(t, vector<int>(n));
  for(int i = 0; i < n; ++i) tmp[0][i] = v[i];
  for(int i = 1; i < t; ++i) for(int j = 0; j < n; ++j) tmp[i][j] = tmp[i-1][tmp[i-1][j]];
  for(int i = 0; i < n; ++i){
    int u = i; long long m = k;
    for(int j = 0; j < t; ++j){
      if(m & 1) u = tmp[j][u];
      m /= 2;
    }
    ans[i] = u;
  }
  return ans;
}

int main(){
  int n; long long k; cin >> n >> k;
  vector<int> v(n), ans; rep(i, n){cin >> v[i]; --v[i];}
  ans = doubling(v, k);
  cout << ans[0] + 1 << "\n";
  return 0;
}

Measured memory_bytes: 54208
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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



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

	ll N;
	cin >> N;

	ll keta = (ll)ceil(log10((double)N));

	ll ans = 0;
	for (ll i = 3; i <= keta - 1; ++i)
	{
		ans += (ll)pow(3, i) - (ll)pow(2, i) * 3 + 3;
	}

	if (keta >= 3)
	{
		vector<string> kouho = { { "3", "5", "7" } };

		for (ll i = 0; i < keta-1; ++i)
		{
			vector<string> tmp;
			for (const auto& k : kouho)
			{
				tmp.emplace_back(k + "3");
				tmp.emplace_back(k + "5");
				tmp.emplace_back(k + "7");
			}

			kouho = tmp;
		}

		for (const auto& k : kouho)
		{
			if (N < stoll(k)) continue;

			bool check3 = false;
			bool check5 = false;
			bool check7 = false;
			for (const auto& e : k)
			{
				if (e == '3') check3 = true;
				if (e == '5') check5 = true;
				if (e == '7') check7 = true;
			}

			if (check3 && check5 && check7)
			{
				ans++;
			}
		}
	}

	cout << ans << endl;

	//system("pause");
}


Measured memory_bytes: 2172
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
//10^12<2^41

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll a,b,c;cin>>a>>b>>c;
    ll ans;
    if(max(a,max(b,c))==a){
        ans=a*10+b+c;
    }elif(max(a,max(b,c))==b){
        ans=b*10+a+c;
    }else{
        ans=c*10+a+b;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <math.h>
#include <string>
#include <ios>
#include <iomanip>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	vector< vector< int > > path(5);
	for (int i = 0; i < 3; i++) {
		int a, b;
		cin >> a >> b;
		path[a].push_back(b);
		path[b].push_back(a);
	}

	for (int i = 1; i < 5; i++) {
		if (path[i].size() >= 3) {
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";


	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <bits/stdc++.h>
#define MOD 1000000007
using namespace std;
int main()
{
    int n,h;
    cin >> n >> h;
    int a[n],b[n];
    for(int i = 0;i < n;i++)
    {
        cin >> a[i] >> b[i];
    }
    sort(a,a + n,greater<int>());
    sort(b,b + n,greater<int>());
    int count = 0;
    for(int i = 0;i < n && b[i] >= a[0];i++)
    {
        h -= b[i];
        count++;
        if(h <= 0)
        {
            break;
        }
    }
    if(h <= 0)
    {
        cout << count << "\n";
    }
    else
    {
        cout << count + (int)ceil((double)h / a[0]) << "\n";
    }

    return 0;
}

Measured memory_bytes: 1024
#output <= 1000

nums = [int(e) for e in input().split()]
flag = 0
for i in range(1,1001):
  if ((((i * 8) // 100) == nums[0]) & (((i * 10) // 100) == nums[1])):
    flag = 1
    print(i)
    break

if flag == 0:
    print(-1)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int, input().split()))

class Inversion():
    def __init__(self):
        self.cnt = 0
    def merge(self, A, left, mid, right):
        n1 = mid - left 
        n2 = right - mid
        L = [0] * (n1 + 1)
        R = [0] * (n2 + 1)
        for i in range(n1):
            L[i] = A[left + i]
        for i in range(n2):
            R[i] = A[mid + i]
        L[n1] = 10000000000
        R[n2] = 10000000000
        i = 0
        j = 0
        for k in range(left, right):
            if L[i] <= R[j]:
                A[k] = L[i]
                i += 1
            else:
                self.cnt += n1 - i
                A[k] = R[j]
                j += 1
        return self
    
    def mergesort(self, A, left, right):
        if left + 1 < right:
            mid = (left + right) // 2
            self.mergesort(A, left, mid)
            self.mergesort(A, mid, right)
            self.merge(A, left, mid, right)
        return self

a = Inversion().mergesort(A, 0, n)
print(a.cnt)


Measured memory_bytes: 27488
#queueを使った方法
from collections import deque

pnum,mtime = map(int,input().split(" "))

q = deque([])
[q.append(input().split(" ")) for u in range(pnum)]

tcnt=0
while len(q) > 0:
	qq = q.popleft()
	ztime = int(qq[1]) - mtime
	if ztime <= 0:
		tcnt += int(qq[1])
		print(qq[0],int(tcnt))
	else:
		q.append([qq[0],ztime])
		tcnt += mtime



Measured memory_bytes: 17352
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int count = 0;

        if(str.charAt(0) == 'R' && str.charAt(1) == 'R' && str.charAt(2) == 'R') count = 3;
        else if(str.charAt(0) == 'R' && str.charAt(1) == 'R') count = 2;
        else if(str.charAt(1) == 'R' && str.charAt(2) == 'R') count = 2;
        else if(str.charAt(0) == 'R' || str.charAt(1) == 'R' || str.charAt(2) == 'R') count = 1;

        System.out.println(count);
    }
}


Measured memory_bytes: 35532
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF=1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);

const int N=1000005;


void solve()
{
    int a[32]={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};
    int k;
    cin>>k;
    cout<<a[k-1]<<endl;
}

int32_t main()
{
    
    IOS;
    //FILE *fin = freopen("in","r",stdin);
    //FILE *fout = freopen("out","w",stdout);
    
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}


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

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
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; }
typedef long long ll;

const long long INF = 1LL << 60;

int main()
{
    int N, K;
    string S;
    string T;
    cin >> N >> K >> S;

    vector<int> R, L;

    T = S;
    char before = S[0];
    int cnt = 0;
    repd(i, 1, N) {
        if (before != S[i]) T[i] = before;
        else {
            if (S[i - 1] != S[i]) cnt++;
        }
        if (cnt == K) break;
    }

    int ans = 0;
    //cout << T << endl;
    rep(i, N) {
        if (T[i] == 'L') ans++;
        else {
            if (T[i - 1] != T[i]) ans--;
        }
    }
    rep(i, N) {
        if (T[i] == 'R') ans++;
        else {
            if (T[i - 1] != T[i]) ans--;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>

using namespace std;

//?????????????´???°?????????
vector<int> a;

//m????????????????´???°??????????????????
//m??\????????????????????°??§???????????????????????????????????????
vector<int> f(int m) {
	vector<int> ret; //??????????????????
	for (int i = 0; i < a.size();i++) {
		if (m % a[i] == 0) {
			//?????£???????????°
			int t = m / a[i];
			//?????£???????????????????????°??§????????????continue
			if (t % 7 != 1 && t % 7 != 6)continue;
			//i???m????????????????´???°
			ret.push_back(a[i]);
		}
		if (a[i] >= m) {//m????????§???????????????????´???°??????????????§??????
			return ret;
		}
	}
}

int main() {

	for (int i = 1; i <= 300000; i++) {
		if (i % 7 == 1 || i % 7 == 6) {
			a.push_back(i);
		}
	}
	int n;
	while (cin >> n && n != 1) {
		//n????????????????´???°?????????????±???????
		vector<int> b = f(n);
		cout << n << ":";
		for (int i = 0; i < b.size();i++) {
			//1????????§???????´???°?????°???2?????????
			//n????????????????´??????°????????§??????
			if (b[i] > 1 && f(b[i]).size() == 2) {
				cout << " " << b[i];
			}
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

int main()
 {
    long long int n,m,i,p,c=0;
   long double b;
     cin>>n>>m;
    long long int a[n];
     for(i=0;i<n;i++){
        cin>>a[i];
     }
   long long int sum=0;
    for(i=0;i<n;i++){

        sum=sum+a[i];
   }
 b=((double)sum / (m*4));
 b=ceil(b);
for(i=0;i<n;i++){
    if(a[i]>=b)c++;
}
if(c>=m)cout<<"Yes"<<endl;
else cout<<"No"<<endl;

 }



Measured memory_bytes: 256
def main():
    import collections

    N = int(input())
    A = list(map(int, input().split()))

    allc = collections.Counter(A)
    # all_list = [0]*N
    allsu = 0
    for pairs in sorted(allc.values(), reverse=True):
        allsu += pairs*(pairs-1)//2

    for a in A:
        num = allc[a]
        print(allsu - (num-1))

    # for i in range(N):
    #     x = A[i]
    #     A[i] = 0
    #     tmp_A = cc(A)
    #     su = 0
    #     for pairs in sorted(tmp_A.values(), reverse=True):
    #         if pairs >= 2:
    #             su += pairs*(pairs-1)//2
    #         else:
    #             break
    #     A[i] = x
    #     print(su)


if __name__ == '__main__':
    main()


Measured memory_bytes: 26780
//投影
#include<bits/stdc++.h>
using namespace std;
const double PI=acos(-1);
const double EPS=1e-6;
#define equals(a,b) (fabs(a)-fabs(b)<EPS)
enum{
	online_Front=-2,
	clock_Wise=-1,
	on_Segment=0,
	counter_clock_Wise=1,
	online_Back=2
};
const int INFTY=1<<29;
struct Point{
	double x,y;
	Point(double x,double y):x(x),y(y){}
	Point(){}
	Point(const Point&a){x=a.x;y=a.y;}
	Point operator+(const Point&a){
		return Point(x+a.x,y+a.y);
	}
	Point operator-(const Point&a){
		return Point(x-a.x,y-a.y);
	}
	Point operator*(double k){
		return Point(k*x,k*y);
	}
	Point operator/(double k){
		return Point(x/k,y/k);
	}
	bool operator==(const Point&a){
		return equals(x,a.x)&&equals(y,a.y);
	} 
};
typedef Point Vector;
Point operator*(double k,const Point&a){
	return Point(k*a.x,k*a.y);
}
double norm(const Point&a){
	return a.x*a.x+a.y*a.y;
}
double abs(const Point&a){
	return sqrt(norm(a));
}
double dot_product(const Point&a,const Point&b){
	return a.x*b.x+a.y*b.y;
}
double cross_product(const Point&a,const Point&b){
	return a.x*b.y-a.y*b.x;
}
bool is_Vertical(Vector&a,Vector&b){
	return equals(dot_product(a,b),0.0);
}
bool is_Parallel(Vector&a,Vector&b){
	return equals(cross_product(a,b),0.0);
}
Point projection_Point(Point&p1,Point&p2,Point&p){
	Vector base=p2-p1;
	double r=dot_product(base,p-p1)/norm(base);
	return p1+base*r;
}
Point reflection_Point(Point&p1,Point&p2,Point&p){
	Point temp=projection_Point(p1,p2,p);
	return 2*temp-p;
}
int Counter_Clockwise(Point&p0,Point&p1,Point&p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross_product(a,b)>EPS)return counter_clock_Wise;
	if(cross_product(a,b)<-EPS)return clock_Wise;
	if(dot_product(a,b)<-EPS)return online_Back;
	if(norm(a)<norm(b))return online_Front;
	return on_Segment;
}
void print(int flag){
	switch(flag){
		case -2:cout<<"ONLINE_FRONT"<<endl;break;
		case -1:cout<<"CLOCKWISE"<<endl;break;
		case 0:cout<<"ON_SEGMENT"<<endl;break;
		case 1:cout<<"COUNTER_CLOCKWISE"<<endl;break;
		case 2:cout<<"ONLINE_BACK"<<endl;break;
	}
}
int main(){
	Point p1,p2;
	Point temp;
	scanf("%lf%lf%lf%lf",&p1.x,&p1.y,&p2.x,&p2.y);
	int q;
	scanf("%d",&q);
	while(q--){
		scanf("%lf%lf",&temp.x,&temp.y);
		print(Counter_Clockwise(p1,p2,temp));
	}
	return 0;
}


Measured memory_bytes: 3320
#include<stdio.h>
#include<algorithm>
using std::sort;

int a[4];

int main(void){
	register int i;
	for(i=1;i<=3;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+4);
	if(a[2]-a[1]==a[3]-a[2])
		puts("YES");
	else
		puts("NO");
	return 0;
}

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

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

  int N;
  cin>>N;
  map<pii,ll>M;
  ll c=0;
  for(int i=1;i<=N;i++){
    int a=i;
    int b=i;
    int U=(a/(int)pow(10,(int)log10(a)))%10;
    int D=b%10;
    M[{U,D}]++;
  }
  ll ans=0;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      ans+=(M[{i,j}]*M[{j,i}]);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 640
MODULO = 1000000007


def solve(n, xs):
    dp = [0] * (n + 1)
    dp[0] = 1
    dp[1] = 1 if 1 not in xs else 0
    for i in range(2, n + 1):
        if i in xs:
            dp[i] = 0
        else:
            if i - 1 not in xs:
                dp[i] += dp[i - 1]
            if i - 2 not in xs:
                dp[i] += dp[i - 2]
        dp[i] %= MODULO
    return dp[n]
         


def main():
    n, m = (int(z) for z in input().split())
    xs = {int(input()) for _ in range(m)}
    res = solve(n, xs)
    print(res)


if __name__ == "__main__":
    main()

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

using namespace std;

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

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

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

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

const int MOD=1000000007;
#define FIX(a) ((a)%MOD+MOD)%MOD

const double EPS=1e-11;
#define EQ0(x) (abs((x))<EPS)
#define EQ(a, b) (abs((a)-(b))<EPS)

int n, m, a[60], b[60];
bool visited[60];
bool g[60][60];

void dfs(int i){
	visited[i]=true;
	REP(j, n){
		if(visited[j] || !g[i][j]) continue;
		dfs(j);
	}
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>m;
	REP(i, m){
		cin>>a[i]>>b[i];
		--a[i];
		--b[i];
		g[a[i]][b[i]]=g[b[i]][a[i]]=true;
	}
	int ans=0;
	REP(i, m){
		g[a[i]][b[i]]=g[b[i]][a[i]]=false;
		REP(j, n) visited[j]=false;
		dfs(0);
		bool ok=false;
		REP(j, n){
			if(!visited[j]) ok=true;
		}
		if(ok) ++ans;
		g[a[i]][b[i]]=g[b[i]][a[i]]=true;
	}
	cout<<ans<<'\n';
	return 0;
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x)
{
    while (x->left != NIL) x = x->left;
    return x;
}

Node treeMaximum(Node x)
{
    while (x->right != NIL) x = x->right;
    return x;
}

Node treeSearch(Node x, int k)
{
    if (x == NIL || k == x->key) return x;
    if (k < x->key) return treeSearch(x->left, k);
    else return treeSearch(x->right, k);
}

Node treeSuccessor(Node x)
{
    if (x->right != NIL) return treeMinimum(x->right);
    Node y = x->parent;
    while (y != NIL && x == y->right)
    {
        x = y;
        y = y->parent;
    }
    return y;
}

void treeDelete(Node z)
{
    Node y; // node to be deleted
    Node x; // child of y
    
    if (z->left == NIL || z->right == NIL) y = z;
    else y = treeSuccessor(z);

    if (y->left != NIL) x = y->left;
    else x = y->right;
    
    if (x != NIL) x->parent = y->parent;
    if (y->parent == NIL) root = x;
    else if (y == y->parent->left) y->parent->left = x;
    else y->parent->right = x;
    
    if (y != z) z->key = y->key;
}

void insert(int k){
    Node y = NIL;
    Node x = root;
    Node z;

    z = malloc(sizeof(struct node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
  
    while (x != NIL)
    {
        y = x;
        if (z->key < x->key) x = x->left;
        else x = x->right;
    }
    
    z->parent = y;
    
    if (y == NIL) root = z;
    else if (z->key < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u)
{
    if (u != NIL)
    {
        inorder(u->left);
        printf(" %d", u->key);
        inorder(u->right);
    }
}
void preorder(Node u)
{
    if (u != NIL) 
    {
        printf(" %d", u->key);
        preorder(u->left);
        preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return EXIT_SUCCESS;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    ll ans = K;
    rep(i, N - 1) ans *= K - 1;
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, ans=2e9;
	cin >> n;
	string str;
	cin >> str;
	vector<int> pre(n), pos;
	for(int i=0; i<n; i++){
        if(str[i]=='W')
            pre[i]=1;
        else
            pos.push_back(i);
        if(i>0)
            pre[i]+=pre[i-1];
	}
	if(pos.size()==0 || pre[n-1]==0){
        cout << 0 << endl;
        return 0;
	}
	for(int i=0; i<pos.size(); i++)
        ans=min(ans, (int)pos.size()-i-1+pre[i]);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 5204
sx, sy, tx, ty = map(int, input().split())
dx = tx - sx
dy = ty - sy
print("U" * dy + "R" * dx + "D" * dy + "L" * dx + "L" + "U" * (dy + 1) + "R" * (dx + 1) + "DR" + "D" * (dy + 1) + "L" * (dx + 1) + "U")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long l, r; cin >> l >> r;
	r = min(r, l + 4038);
	long long ans = 1e18;
	for (long long i = l; i <= r; ++i) 
		for (long long j = i + 1; j <= r; ++j)
			ans = min(ans, (i * j) % 2019);
	cout << ans << '\n';	
	return 0;
}	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define ull unsigned long long
#define ld long double

#define mod 1000000007
#define EULER 2.7182818284
#define INF 1000000000

#define pb push_back
#define ins insert
#define IT iterator
#define PQ priority_queue

#define fi first
#define se second
#define maxe max_element
#define mine min_element
#define er erase
#define lb lower_bound
#define ub upper_bound

#define vi vector<int>
#define vll vector<ll>
#define vb vector<bool>
#define pi pair<int,int>
#define pll pair<ll,ll>


#define mem(v,i) memset(v,i,sizeof(v)) // v is array. To set all elements to 0 or -1 only. mem(arr,0);


#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORd(i,a,b) for(int i=(a);i>=(b);i--)
#define FORl(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORN(i,n) for(int i=(0);i<(n);i++)
#define FORR(i,n) for(int i=(n);i>=0;i--)
#define bs bitset
#define bpc(a) __builtin_popcount(a)

ll max(ll a,ll b)
{
    if(a>b)return a;return b;
}
ll min(ll a,ll b)
{
    if(a<b)return a;return b;
}

ll mypow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll gcd(ll a,ll b)
{
    if(b==0)
    return a;
    return gcd(b,a%b);
}
//..............................!!!!!!Get ready to fight!!!!!!............................



int main()
{
    fast
    
    ll n,m,i;
    cin>>n>>m;
    ll a[m],sum=0;
    for(i=0;i<m;i++)
    cin>>a[i],sum+=a[i];
    if(sum>n)
    cout<<"-1\n";
    else
    cout<<n-sum<<"\n";
    return 0;
}

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

public class Test
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Split(' ');
		int n = int.Parse(line[0]);
		int a = int.Parse(line[1]);
		int b = int.Parse(line[2]);

		int ans = 0;
		int res;
		int target;

		for(int i = 0 ; i <= n ; i++){
			target = 0;
			res = i;
			while(res > 0){
				target += res % 10;
				res = res / 10;
			}
			if(target >= a && target <= b){
				ans += i;
			}
		}
		Console.WriteLine(ans);
	}                                                                                                                                                                       
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int i = (int)(n); i >= 0; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;

int main(){
    string S;
    cin >> S;
    if (S == "SAT") cout << 1 << endl;
    if (S == "FRI") cout << 2 << endl;
    if (S == "THU") cout << 3 << endl;
    if (S == "WED") cout << 4 << endl;
    if (S == "TUE") cout << 5 << endl;
    if (S == "MON") cout << 6 << endl;
    if (S == "SUN") cout << 7 << endl;
}



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

#define pi 3.14159265358979323846264

#define ll long long
#define fori(n) for(long long i=0;i<n;i++)
#define forj(n) for(long long j=0;j<n;j++)

#define sp(n) setprecision(n)
#define d7 1000000007
#define mkp make_pair
#define mkt make_tuple

using namespace std;

bool isPrime(long long k){
    if(k<=1){return false;}
    if(k==2){return true;}
    if(k%2==0){return false;}
    long long i = 3;
   while (i*i <= k) {if (k % i == 0) {return false;}i += 2;}
return true;
}

ll binomialCoeff(ll n, ll k){
    ll C[n + 1][k + 1];ll i, j;
    for (i = 0; i <= n; i++){
        for (j = 0; j <= min(i, k); j++)
        {if (j == 0 || j == i) C[i][j] = 1;
            else C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]);}}
    return C[n][k];
 }

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

ll srihrg(ll n,ll k,ll m){
    ll ans;
    ans=1;
    fori(k){
        ans=(ans*n)%m;
    }
    return ans;
}

ll kk=1;
void dfsi(vector<bool> &vis, vector<ll> adj1[], ll n, ll start, vector<ll> &pre, vector<ll> &pos){
    vis[start]=true;
    pre[start]=kk;kk++;
    for(ll i: adj1[start]){
        if(!vis[i]){
            vis[i]=true;
            dfsi(vis,adj1,n,i,pre,pos);
        }
    }
    pos[start]=kk;kk++;
}

void bfsi(vector<ll> &dis, vector<ll> adj[], ll s, vector<ll> &parent){
    dis[s]=-1;
    queue<ll> q;
    q.push(s);
    while(!q.empty()){
        ll z=q.front();
        q.pop();
        for(ll v:adj[z]){
            if(dis[v]==0){
            q.push(v);
            dis[v]=-dis[z];
                parent[v]=z;}
        }
    }
}

void make_set(ll v, vector<ll> &parent, vector<ll> &krank) {
    parent[v] = v;
    krank[v] = 0;
}

ll find_set(ll v,vector<ll> &parent, vector<ll> &krank) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v], parent, krank);
}

void union_sets(ll a, ll b,vector<ll> &parent, vector<ll> &krank) {
    a = find_set(a,parent,krank);
    b = find_set(b,parent,krank);
    if (a != b) {
        if (krank[a] < krank[b])
            swap(a, b);
        parent[b] = a;
        if (krank[a] == krank[b])
            krank[a]++;
    }
}

void dijkstra(ll s, vector<ll> &dist, vector<ll> &parent, ll n, vector<pair<ll,ll>> adj[]){
    dist[s]=0;
    vector<bool> u(n,false);
    fori(n){
        ll v=-1;
        forj(n){
            if(!u[j] &&(v==-1||(dist[j]<dist[v]))) v=j;
        }
        if(dist[v]==d7) break;
        u[v]=true;
        for(auto j:adj[v]){
            ll a,b;
            a=j.first;
            b=j.second;
            if(dist[v]+b<dist[a]){
                dist[a]=dist[v]+b;
                parent[a]=v;
            }
        }
    }
}


int main(int argc, const char * argv[]) {
 //cout<<"Om\n";
 //Praise to Lord
 //make cin/cout faster
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
// code now
   
    ll n,m;
    cin>>n>>m;
    string s,t;
    fori(n){
        s.push_back(m+'0');
    }
    fori(m){
        t.push_back(n+'0');
    }
    cout<<((s.compare(t)<0)?s:t);
    
//code ends
    return 0;
}


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

int main(){

    ll n; cin >> n;
    ll cum = 0;
    ll ids = 0;
    if(n==1){
        cout << 1 << endl;
        return 0;
    }
    for(ll i=1; i<=n; i++){
        cum += i;
        if(cum >= n){
            ids = i;
            break;
        }
    }
    ll dis = cum - n;
    vector<ll> ans;
    for(ll i=ids; i>=1; i--){
        if(i != dis){
            ans.push_back(i);
        }
    }
    for(ll i = ans.size()-1; i>=0; i--){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
import math

N, D = [int(i) for i in input().split()]
Points = [[int(i) for i in input().split()] for j in range(N)]

#print(N,D,Points)

counter = 0

for i in range(N):
    for j in range(N-i-1):
        sum = 0
        for k in range(D):
            sum += (Points[i][k] - Points[j+i+1][k]) ** 2
        dist = math.sqrt(sum)
        if dist.is_integer():
            counter += 1

print(counter)


Measured memory_bytes: 3060