akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <cmath>
#include <map>
#include <algorithm>
#include <stack>
#include <cstring>

#define ll long long
#define MP make_pair
#define PB push_back
#define P push
#define f first
#define se second
#define S size()
#define B begin()
#define E end()
#define PI acos(-1)
#define fscan1(n)  scanf("%d",&(n));
#define fscan2(n,m)  scanf("%d %d",&(n),&(m));
#define fscan3(n,m,k)  scanf("%d %d %d",&(n),&(m),&(k));

const int N = 1e5 + 100;
const int M = 2e5 + 100;
const ll oo = 1e18;

int n, m, k, t, q, h, a, b, c, x, y, z;
using namespace std;

int ar[N];
int dp[N];


int main(){
	
	cin >> n;

	for(int i = 0; i < n; i++){
		cin >> ar[i];
		if(i == 0) continue;
		if(i == 1)dp[i] = abs(ar[i] - ar[i - 1]);
		else{
			dp[i] = min(abs(ar[i] - ar[i - 1]) + dp[i - 1], abs(ar[i] - ar[i - 2]) + dp[i - 2]);
		}
	}
	

	cout << dp[n - 1] << endl;


	return 0;
 }




Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<ll> l(n);
    for(int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        for(int j = i + 1; j < n; j++) {
            for(int k = j + 1; k < n; k++) {
                if(l[i] + l[j] > l[k] && l[j] + l[k] > l[i] &&
                   l[k] + l[i] > l[j]) {
                    if(l[i] != l[j] && l[j] != l[k] && l[k] != l[i]) {
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int main() {
    int N, T;
    int c[100], t[100];
    int min_cost =-1;
    cin >> N;
    cin >> T;


    for (int i = 0; i < N; i++) {
        cin >> c[i];
        cin >> t[i];
    }
    for (int j = 0; j < N; ++j) {
        if ((t[j] <= T && min_cost == -1) || (t[j] <= T && min_cost > c[j])) {
            min_cost = c[j];
            continue;
        }
    }

    if (min_cost == -1) {
        cout << "TLE";
    } else {
        cout << min_cost;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int ans=a+b+c;
    int x = max(max(a,b),c);
    ans -= x;
    for(int i=0;i<k;i++) x *= 2;
    cout << ans + x << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cmath>

#define For(i, j, k) for(int i = j; i <= k; i++)
#define Forr(i, j, k) for(int i = j; i >= k; i--)

using namespace std;

const int Mod = 1e9 + 7;
const int N = 4010, M = 2010;

int A, B;
int C[N][N], F[M][M], G[M][M];

int main(){
	scanf("%d%d", &A, &B);
	
	For(i, 0, A + B){
		C[i][0] = 1;
		For(j, 1, i) C[i][j] = (C[i - 1][j] + C[i - 1][j - 1]) % Mod;
	}

	For(i, 0, A){
		For(j, 0, min(B - 1, A - i)) (F[i + j][B - j] += C[B - 1][j]) %= Mod;
	}	
	For(i, 0, A) For(j, 0, B){
		G[i][j] = (F[i][j] + (i ? G[i - 1][j] : 0)) % Mod;
	}
	For(i, 0, B){
		For(j, 1, A) (C[i][j] += C[i][j - 1]) %= Mod;
	}
	long long ans = G[A][B];
	For(i, 0, A){
		For(j, 0, B - 1)
			(ans += 1ll * G[i][j] * C[B - j - 1][A - i]) %= Mod;
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 94464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		String input = scanner.nextLine();
		Boolean isOK = (isOk(input)
				&& isOk(input.substring(0,input.length()/2))
				&& isOk(input.substring(input.length()/2+1)));
		String result = isOK ? "Yes" : "No";
		System.out.println(result);
//		System.out.println(isOk(input));
		scanner.close();
	}
	private static Boolean isOk(String s){
		char[] left = s.substring(0, s.length()/2).toCharArray();
		char[] right = s.substring(s.length()/2+1).toCharArray();
		if(s.length() % 2 == 0) right = s.substring(s.length()/2).toCharArray();
		for(int i = 0; i < left.length; i++){
			if(left[i] != right[right.length-1-i]){
				return false;
			}
		}
		return true;
	}
}


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

int main() {
    int s;
    int sum[2001];
    sum[0]=0;
    sum[1]=0;
    sum[2]=0;
    cin>>s;
    int mod = 1000000007;
    for(int i=3;i<=2000;i++) {
        sum[i]=1;
        for(int j=i-3;j>=0;j--) {
            sum[i] = (sum[i]+sum[j])%mod;
        }
    }
    cout<<sum[s]<<endl;
    return 0;
}

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

using namespace std;

int main() {
    int l, r;
    cin >> l >> r;

    if (r - l >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    
    l %= 2019;
    r %= 2019;
    int ans = 2019 * 2019;
    if (l > r) {
        ans = 0;
    } else if (l == r) {
        ans = (l * r) % 2019;
    } else {
        for (int i = l; i < r; ++i) {
            for (int j = i + 1; j <= r; ++j) {
                ans = min(ans, (i * j) % 2019);
            }
        }
    }

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << n * n * n << endl;
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = ['' for _ in range(W)]
white = ['.' for _ in range(W)]
white = ''.join(white)

h = 0
for i in range(H):
    inp = input()
    if inp == white:
        continue
    for j, c in enumerate(inp):
        a[j]+=c
    h+=1

b = ['' for _ in range(h)]
white = ['.' for _ in range(h)]
white = ''.join(white)

for i in range(W):
    inp = a[i]
    if inp == white:
        continue
    for j, c in enumerate(inp):
        b[j]+=c

for i in range(h):
    print(b[i])

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(ll i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-11;

int lcs(string &s, string &t) {
    vvi dp(s.size() + 1, vi(t.size() + 1));
    
    for(int i = 0; i < s.size(); i++) {//LCS
        for(int j = 0; j < t.size(); j++) {
            if(s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            }
            else{
                dp[i + 1][j + 1] = max(dp[i][j + 1], dp[i + 1][j]);
            }
        }
    }
    return dp[s.size()][t.size()];
}

int main() {
    
    int n;
    cin>>n;
    rep(i,n){
        string s,t;
        cin>>s>>t;
        fin(lcs(s,t));
    }
}


Measured memory_bytes: 6788
#include<iostream>
#include<vector>
#define ll long long
#define MOD 1000000007
using namespace std;
int dfs(int *dp,vector<vector<int>>& adj,int n,int i)
{
    if(dp[i]!=-1)
        return dp[i];
    int res=0;
    for(int g=0;g<adj[i].size();g++)
    {
        res=max(res,1+dfs(dp,adj,n,adj[i][g]));
    }
    dp[i]=res;
    return res;
}
int main()
{
    int n,m;
    cin>>n>>m;
    vector<vector<int>> adj(n+1);
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    int *dp=new int[n+1]();
    for(int i=0;i<=n;i++)
        dp[i]=-1;
    int myres=INT_MIN;
    for(int i=1;i<=n;i++)
    {
        myres=max(myres,dfs(dp,adj,n,i));
    }
    cout<<myres<<endl;
}


Measured memory_bytes: 11536
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));


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

    int n;
    cin >> n;
    vector<int> l(n);
    ll ans=0;
    rep(i,n){
        cin >> l[i];
    }
    sort(all(l));
    rep(i,n-2){
        for(int j = i+1;j < n-1;++j){
            int ab = l[i] + l[j];
            int x = lower_bound(l.begin(),l.end(),ab) - l.begin();
            ans += x - j - 1;


        }
    }
    cout << ans << endl;

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

LL k, a, b, ans;

int main() {
	cin >> k >> a >> b;
	
	if(a + 2 >= b || k < a - 1) { ans = k + 1; }
	else {
		LL x = k - (a - 1);
		ans = a + fl(x, 2) * (b - a) + mo(x, 2);
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var S = ReadLine();
        var N = S.Length + 1;
        var a = new long[N];
        for (int i = 0; i < N; i++)
        {
            a[i] = -1;
        }
        for (int i = 0; i < S.Length - 1; i++)
        {
            if (S[i] == '>' && S[i + 1] == '<') a[i + 1] = 0;
        }
        if (S[0] == '<') a[0] = 0;
        if (S[N - 2] == '>') a[N - 1] = 0;
        for (int i = 0; i < N; i++)
        {
            if (a[i] != 0) continue;
            for (int j = i + 1; j < N; j++)
            {
                if (S[j - 1] == '>') break;
                var b = a[j - 1] + 1;
               if(a[j]<b) a[j] =b;
            }
            for (int j = i - 1; j >= 0; j--)
            {
                if (S[j] == '<') break;
                var b= a[j + 1] + 1;
                if (a[j] < b) a[j] = b;
            }
        }

        WriteLine(a.Sum());

    }
}



Measured memory_bytes: 16864
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60; const ll mod=1e9+7; const int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------

int main(){
	int a,b; cin >> a >> b;
	int ans = a+b;
	chmax(ans, a-b);
	chmax(ans, a*b);
	cout << ans << endl;
	
    return 0;
}


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

int main() {
  int N,D,n=0;
  cin>>N>>D;
  for(int i=0;i<N;i++)
  {
    double X,Y;
    cin >> X>>Y;
    if(sqrt(X*X+Y*Y)<=D) n++;
  }
  cout << n << endl;
}


Measured memory_bytes: 3704
n,k=map(int,input().split())
get_score=list(map(int,input().split()))
t=list(input())
dic={'r':0,'s':1,'p':2}

ans=0
for i in range(n):
    if t[i]=='D':continue
    if i+k<n and t[i]==t[i+k]:
        t[i+k]='D'
    ans+=get_score[(dic[t[i]]+2)%3]

print(ans)

Measured memory_bytes: 4084
// template version 1.12
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings
#define infile "../test/sample-1.in"
#define int long long //{{{
const int INF=1e18;
const int MOD=1e9+7; //}}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
#define posl(A, x) (lower_bound(all(A), x)-A.begin())
#define posu(A, x) (upper_bound(all(A),x)-A.begin())
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  int n;cin>>n;
  vector<string> S(n);
  map<string, int> d;
  rep(i,n){
    dump("hello");
    cin>>S[i];
    sort(all(S[i]));
    d[S[i]]++;
  }
  dump(d);

  int ans=0;
  each(el, d){
    if (el.second>=2) ans+=el.second * (el.second-1)/2;
  }
  cout << ans << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 16640
import math

N,M = map(int, input().split())

# 両方ともNから選ぶ
a = 0
if N > 1:
    a = int(math.factorial(N) / (math.factorial(N-2)*2))

# 両方ともMから選ぶ
b = 0
if M > 1:
    b = int(math.factorial(M) / (math.factorial(M-2)*2))

print(a + b)

Measured memory_bytes: 3060
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
a, b, c = M()
l = [a, b, c]
l.sort()
if l[1] == c:
    print('Yes')
else:
    print('No')

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

int main() {
    ll n;
    cin>>n;
    ll a[n],dp[n]={0};
    for(int i=0;i<n;i++) cin>>a[i];
    dp[n-1]=0;
    dp[n-2]=abs(a[n-1]-a[n-2]);
    for(int i=n-3;i>=0;i--){
        dp[i]=min(abs(a[i]-a[i+1])+dp[i+1],abs(a[i]-a[i+2])+dp[i+2]);
    }
    cout<<dp[0]<<"\n";
}

Measured memory_bytes: 5112
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define P pair<int, int>
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const int MAX_N = 5010;
const int INF = 1e9 + 7;
#define now first
#define depth second

int N, K, cost[MAX_N][MAX_N], C[MAX_N], R[MAX_N];
vector<int> v[MAX_N];

int main() {
  cin >>N >>K;
  //REP(i, MAX_N) memset(v[i], false, sizeof(v[i]));
  REP(i, MAX_N) REP(j, MAX_N) cost[i][j] = INF;
  REP(i, N) cin >>C[i] >>R[i];
  REP(i, K){
    int A, B; cin >>A >>B;
    --A; --B;
    v[A].push_back(B);
    v[B].push_back(A);
  }
  //REP(i, N){
  //  REP(j, v[i].size()) cout <<v[i][j] <<" ";
  //  cout <<endl;
  //}
  REP(i, N){
    //cout <<"--" <<endl;
    int c = C[i], r = R[i];
    cost[i][i] = 0;
    queue<P> open;
    open.push( P(i, r) );
    bool closed[MAX_N] = {false};
    closed[i] = true;
    while(!open.empty()){
      P now = open.front(); open.pop();
      if(now.depth <= 0) continue;
      //cout <<now.now <<", " <<now.depth <<endl;
      //REP(i, N) cout <<closed[i] <<" "; cout <<endl;
      REP(k, v[now.now].size()){
        int j = v[now.now][k];
        //if(v[now.now][j] == false) continue;
        //cout <<"!" <<endl;
        //cout <<"? " <<closed[j] <<", " <<j <<endl;
        if(closed[j]) continue;
        //cout <<"!!" <<endl;
        closed[j] = true;
        cost[i][j] = c;
        open.push( P(j, now.depth - 1) );
      }
    }
  }
  //REP(i, N){
  //  cout <<i <<": ";
  //  REP(j, N) printf("%10d ", cost[i][j]);
  //  cout <<endl;
  //}

  priority_queue<P, vector<P>, greater<P> > open;
  open.push( P(0, 0) );
  int closed[MAX_N];
  fill(closed, closed + MAX_N, INF);
  int ans;
  while(!open.empty()){
    P now = open.top(); open.pop();
    if(now.now == N - 1){
      ans = now.second;
      break;
    }
    if(closed[now.now] <= now.second) continue;
    closed[now.now] = now.second;
    REP(i, N){
      if(i == now.now || cost[now.now][i] == INF) continue;
      open.push( P(i, now.second + cost[now.now][i]) );
    }
  }
  cout <<ans <<endl;
  return 0;
}

Measured memory_bytes: 166872
#include <bits/stdc++.h>
using namespace std;
int ans = 0;
void OnestrokePath(int n,vector<vector<int>> &ABC,vector<bool> &ok) {
    bool ok2 = true;
    for(int i = 0; i < ok.size(); i++) {
        if(ok[i] == false && i != n) {
            ok2 = false;
        }
    }
    if(ok2) {
        ans++;
        return;
    }
    ok[n] = true;
    for(int i = 0; i < ABC[n].size(); i++) {
        if(ok[ABC[n][i]] == true) {
            continue;
        }
        OnestrokePath(ABC[n][i],ABC,ok);
    }
    ok[n] = false;
    return;
}
int main() {
    int N,M;
    cin >> N >> M;
    vector<vector<int>>ABC(N);
    vector<bool>ok(N,false);
    for(int i = 0; i < M; i++) {
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        ABC[a].push_back(b);
        ABC[b].push_back(a);
    }
    OnestrokePath(0,ABC,ok);
    cout << ans << endl;
}


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

int main() {
 int a, b,count=0; cin >> a >> b;
 for(int i=a;i<=b;i++) {
   if(i/10000==i%10 && ((i%10000-i%1000)/1000)==((i%100-i%10)/10)) {
     count++;
   }
 }
 cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int P[100010];
int used[100010];

void init(int N){ 
	for (int i = 0; i < N; ++i) P[i] = i;
}

int root(int a){ 
	if (P[a] == a) return a; 
	return (P[a] = root(P[a])); 
}

bool is_same_set(int a, int b){ 
	return root(a) == root(b);
}

void unite(int a, int b){ 
	P[root(a)] = root(b);
}

int main(){
	int n, m;
	cin >> n >> m;
	init(n);
	for (int i = 0; i < m; i++){
		int x, y, z;
		cin >> x >> y >> z;
		unite(x-1, y-1);
	}
	int ans = 0;
	for (int i = 0; i < n; i++){
		if (!used[root(P[i])]){
			used[root(P[i])] = true;
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4928
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
int main() {
	int X, A, B;
	cin >> X >> A >> B;
	if ((B - A) <= 0) cout << "delicious" << endl;
	if (((B - A) > 0) && ((B - A) <= X)) cout << "safe" << endl;
	if (((B - A) > 0) && ((B - A) > X)) cout << "dangerous" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int n; ll d;
    cin >> n >> d;
    int cnt = 0;
    rep(i, n) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 3656
#define SUBMIT

#include <bits/stdc++.h>

using namespace std;

int main() {
#ifdef SUBMIT
    auto& in = cin;
#else
    stringstream in(R"(resident register number
)");
#endif
    string a, b, c;
    in >> a >> b >> c;
    cout << static_cast<char>(toupper(a[0])) << static_cast<char>(toupper(b[0])) << static_cast<char>(toupper(c[0]))
         << endl;
    return 0;
}

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

struct Node {
  int key;
  struct Node *right, *left, *parent;
};
typedef struct Node Node;

Node *root, *NIL;

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

Node * find(Node *u, int k) {
  while(u != NIL && k != u->key) {
    if(k < u->key) u = u->left;
    else u = u->right;
  }
  return u;
}

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 *x; // yの子

  // 削除する節点を決める
  if(z->left == NIL || z->right == NIL) y = z;
  else y = treeSuccessor(z);

  // yの子xを決める
  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 = (Node *)malloc(sizeof(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) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}

void preorder(Node *u) {
  if(u == NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}
  
int main(void) {
  int n, i, x;
  char com[16];
  scanf("%d",&n);
  
  for(i=0;i<n;i++) {
    scanf("%s",com);
    if(!strcmp(com,"find")) {
      scanf("%d",&x);
      Node *t = find(root,x);
      if(t != NIL) printf("yes\n");
      else printf("no\n");
    } else if(!strcmp(com,"insert")) {
      scanf("%d",&x);
      insert(x);
    } else if(!strcmp(com,"print")) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if(!strcmp(com,"delete")) {
      scanf("%d",&x);
      treeDelete(find(root,x));
    }
  }

  return 0;
}


Measured memory_bytes: 20496
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

ll input_a[100010];

int main(void){
    ll n;
    ll ans=1;
    bool zero_flg =false;
    bool ans_flg = false;
    cin >> n;
    REP(i,n){
        ll tmp;
        cin >> tmp;
        input_a[i] = tmp;
        if(tmp == 0){
            zero_flg = true;
        }
    }

    REP(i,n){
        if(ans > (1000000000000000000/input_a[i])){
            ans_flg = true;
            break;
        }else{
            ans *= input_a[i];
        }
    }


    if(zero_flg){
        cout << "0" << endl;
    }else if(ans_flg){
        cout << "-1" << endl;
    }else{
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3980
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
from itertools import product
from copy import deepcopy
def resolve():
    n,ma,mb=map(int,input().split())
    ABC=[tuple(map(int,input().split())) for _ in range(n)]
    M=400

    dp=[[INF]*(M+1) for _ in range(M+1)]
    dp[0][0]=0

    for a,b,c in ABC:
        for x,y in product(range(M,-1,-1),repeat=2):
            if(x+a<=M and y+b<=M):
                dp[x+a][y+b]=min(dp[x+a][y+b],dp[x][y]+c)

    ans=INF
    for x,y in product(range(1,M+1),repeat=2):
        if(x*mb==y*ma): ans=min(ans,dp[x][y])
    if(ans==INF): ans=-1
    print(ans)
resolve()

Measured memory_bytes: 54748
import math
import sys
from itertools import accumulate
from functools import reduce
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

def combination_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def permutations_count(n, r):
    return math.factorial(n) // math.factorial(n - r)

sys.setrecursionlimit(10000)

mod = 1000000007

"""
# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]

# 標準入力取得
## 文字列
    = sys.stdin.readline().rstrip()
    = list(sys.stdin.readline().rstrip())
    = [list(list(sys.stdin.readline().rstrip())) for i in range(h)] #文字列を分解して二次元配列入力

## 数値
    = int(sys.stdin.readline())
    = map(int, sys.stdin.readline().split())
    = list(map(int, sys.stdin.readline().split()))
    = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき
"""

if __name__ == "__main__":
    h,w = map(int, sys.stdin.readline().split())
    s = [list(list(sys.stdin.readline().rstrip())) for i in range(h)]
    for i in range(h):
        for j in range(w):
            c=0
            if s[i][j] == "#":
                pass
            else:
                if 0<i and 0<j and s[i-1][j-1] == "#":#左上
                    c +=1
                if 0<j and s[i][j-1] == "#":#左
                    c +=1
                if 0<i and s[i-1][j] == "#":
                    c +=1
                if i<h-1 and j<w-1 and s[i+1][j+1] == "#":
                    c +=1
                if j<w-1 and s[i][j+1] == "#":
                    c +=1
                if i<h-1 and s[i+1][j] == "#":
                    c +=1
                if 0<i and j<w-1 and s[i-1][j+1] == "#":
                    c +=1
                if 0<j and i<h-1 and s[i+1][j-1] == "#":
                    c +=1
                s[i][j] = c
    for i in range(h):
        print(*s[i], sep='')

Measured memory_bytes: 5512
#define _GLIBCXX_DEBUG//TLEの原因になるので注意！！！！！！！！！！！
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
vector<int> arr;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//#define int long long

//cerrはコメントアウトしなくても通る//ただしTLEを引き起こすことがある

//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
//const ll INF = 1LL << 60;
//typedef pair<ll,ll> P;
typedef pair<int, int> P;
bool chmx(int &a, int b) {
	if (b > a) {
		a = b;
		return true;
	}
	return false;
}

bool chmn(int &a, int b) {
	if (b < a) {
		a = b;
		return true;
	}
	return false;
}

int a[200005];
int co=0;
int ans=-1;
vector<int> Q;
set<int> S;
int num[200005];
ll st;
int fin;


void dfs(int u){
    if(S.find(u)!=S.end()){
        st=num[u];
        fin=co+1;
        return;
    }else{
        S.insert(u);
        co++;
        num[u]=co;
        Q.push_back(u);
        dfs(a[u]);
    }
    return;
}

int main(){
    int n;
    ll k;
    cin >> n>> k;
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    
    S.insert(0);
    Q.push_back(0);
    dfs(a[0]);
    int re=fin-st;
    /*
    rep(i,Q.size()){
        cerr<<Q[i]+1<<' ';
    }
    cerr<<endl;
    */
    if(k<st){
        cout<<Q[k]+1<<endl;
    }else{
        k-=st;
        k%=re;
        //cerr<<st<<' '<<k<<endl;
        cout<<Q[k+st]+1<<endl;
    }
    return 0;
}



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

using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define mp(a,b) make_pair(a,b)
const ll MOD=1000000007;

int main(){
	ll N; cin>>N;
  ll ans=0;
    rep(i,N){
      int a; cin>>a;
      ans+=a;
    }
  printf("%lld",ans-N);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#warning do not forget to change size of N and M 
#define popcnt(a) __builtin_popcount(a)
#define gcd(a,b) __gcd(a,b)
#define IO() assert(freopen("in.in", "rt", stdin)), assert(freopen("out.out", "wt", stdout))
#define FastIO() ios::sync_with_stdio(false),cin.tie(0);
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl


typedef long long ll;
typedef pair<int,int> pi;
const ll MOD = 1e9 + 7;
const int N = 1e4 + 9, M = 1e7 + 9, OO = 0x3f3f3f3f;
const double EPS = 1e-10,PI=acos(-1.0);

//Number Theory
inline bool dCMP(const long double &a, const long double &b) { return fabsl(a - b) < EPS;}

//Geometry 
inline double MintoDeg(double min){return min/60;}
inline double to_Radian(double deg){return deg*PI/180.0;}
inline double to_Degree(double radian){if(radian<0) radian+=2*PI; return radian*180/PI ;}
inline double fixAngle(double A){return A>1 ? 1 : (A<-1 ? -1 : A);}
int sx,sy,tx,ty;
int main()
{
  scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
  for(int u=sy+1;u<=ty;++u) printf("U");
  for(int r=sx+1;r<=tx;++r) printf("R");

  for(int d=ty-1;sy<=d;--d) printf("D");
  for(int l=tx-1;sx<=l;--l) printf("L");

  printf("L");
  for(int u=sy;u<=ty;++u) printf("U");
  for(int r=sx;r<=tx;++r) printf("R");
  printf("D");


  printf("R");
  for(int d=ty;sy<=d;--d) printf("D");
  for(int l=tx;sx<=l;--l) printf("L");
  printf("U");

  
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <functional>
#include <string>
#include <cstdlib>
#include <numeric>
#include <cstdbool>
#include <cstring>
#include <map> 
#include<set>
#include<queue>
#include <iomanip>

typedef long long ll;

#define rep(i,n) for(ll i=0;i<n;i++)
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; }

const long long INF = 1000000000000000;
const ll inf = -1e18;
typedef pair<ll, ll> P;
ll ma = 1000000000 + 7;
ll mx = 1000003;
ll h,n, w,m,t; string s;
ll R, C;
ll sy, sx, gy, gx;
char maze[20][20];
ll dis[20][20];
int dx[4] = { 1, 0, -1, 0 };
int dy[4] = { 0, 1, 0, -1 };
ll gcd(ll x, ll y) {
	if (x % y == 0) return y;
	return gcd(y, x % y);
}
ll lcm(ll a,ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
void comb(vector<vector <ll> >& v) {
	for (ll i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (ll k = 1; k < v.size(); k++) {
		for (int j = 1; j < k; j++) {
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j])%ma;
		}
	}
}

ll GetDigit(ll num) {
	return log10(num) + 1;
}
ll Combination(int n, int r)
{
	if (n - r < r) r = n - r;
	if (r == 0) return 1;
	if (r == 1) return n;

	vector<ll> numerator(r);
	vector<ll> denominator(r);

	for (int k = 0; k < r; k++)
	{
		numerator[k] = n - r + k + 1;
		denominator[k] = k + 1;
	}

	for (int p = 2; p <= r; p++)
	{
		int pivot = denominator[p - 1];
		if (pivot > 1)
		{
			int offset = (n - r) % p;
			for (int k = p - 1; k < r; k += p)
			{
				numerator[k - offset] /= pivot;
				denominator[k] /= pivot;
			}
		}
	}

	ll result = 1;
	for (int k = 0; k < r; k++)
	{
		if (numerator[k] > 1) result *= numerator[k];
		result %= ma;
	}

	return result;
}

ll bfs() {
	queue<P> que;
	for (int i = 0; i < R; i++) {
		for (int j = 0; j < C; j++) dis[i][j] = INF;
	}
	que.push(P(sy - 1, sx - 1));
	dis[sy - 1][sx - 1] = 0;

	while (que.size() > 0) {
		P p = que.front();
		que.pop();
		if (p.first == gy - 1 && p.second == gx - 1) break;
		for (ll i = 0; i < 4; i++) {
			ll ny = p.first + dy[i];
			ll nx = p.second + dx[i];
			if (0 <= ny && ny < R && 0 <= nx && nx < C && maze[ny][nx] == '.' && dis[ny][nx] == INF) {
				que.push(P(ny, nx));
				dis[ny][nx] = dis[p.first][p.second] + 1;
			}
		}
	}
	return dis[gy - 1][gx - 1];
}
ll dp[20500];
int main() {
	cin >> h >> w;
	ll res = 0;
	if (h % 2 == 0) {
		res += (h / 2) * w;
	}
	else {
		res += h * (w / 2) + ((h + 1) / 2) * (w % 2);
	}
	if (h == 1 || w == 1) {
		res = 1;
	}
	cout << res << endl;
}



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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    bool kanou = false;

    int CA = max(c-a,a-c);
    int BA = max(b-a,a-b);
    int CB = max(c-b,b-c);

    if(CA<=d){
        kanou = true;
    }
    if(BA<=d && CB<=d){
        kanou = true;
    }

    if(kanou){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl; 
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iomanip>
#include <math.h>
#include <vector>
#include <map>

using namespace std;

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

  map<char, int> mp;
  for (int i = 0; i < (int)S.size(); ++i)
  {
    if (mp.count(S[i]) == 0) mp.insert(make_pair(S[i], 1));
    else ++mp[S[i]];

    if (mp.size() > 2) break;
    if (mp[S[i]] > 2) break;

    if (i == (int)S.size() - 1)
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: usize,
        b: usize,
        c: usize,
    }

    if a==b+c || b==a+c || c==a+b {
        println!("Yes");
    } else {
        println!("No");
    }

}


Measured memory_bytes: 2140
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // fractions.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

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

int main() {
  // dinamic
  int N;
  int K;
  int *list;

  cin >> N >> K;
  list = new int[N];

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

  for (int j = 0; j < N - 1; j++) {
    for (int i = 0; i < N - 1; i++) {
      if (list[i] > list[i + 1]) {
        int tmp = list[i];
        list[i] = list[i + 1];
        list[i + 1] = tmp;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < K; i++) {
    ans += list[i];
  }

  cout << ans << endl;

  delete[] list;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<string.h>
#include<memory.h>

int main(){
	int n,score=0,out=0,ining=0,base=0;
	char s[8];
	scanf("%d",&n);
	while(ining!=n){
		scanf("%s",s);
		if(strcmp(s,"HIT")==0){	
			base++;
		}
		else if(strcmp(s,"HOMERUN")==0){
			score+=base+1;
			base=0;
		}
		else if(strcmp(s,"OUT")==0){
			out++;
		}
		if(base==4){
			score++;
			base=3;
		}
		if(out==3){
			ining++;
			printf("%d\n",score);
			score=0;
			out=0;
			base=0;
		}
	}
	return 0;
}

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

int main()
{
	int a,tot;
	cin>>a;
	int A[a],B[a],C[a-1];
	for(int i=0;i<a;i++)
	{
		cin>>A[i];
	}
	for(int t=0;t<a;t++)
	{
		cin>>B[t];
	}
	for(int y=1;y<a;y++)
	{
		cin>>C[y-1];
	}
	//輸入 
	for(int q=1;q<a;q++)
	{
		if(A[q]-A[q-1]==1)
		{
			tot=tot+B[A[q]-1]+C[A[q]-2];
			//printf("%d\n",tot);
		}
		else
		{
			tot=tot+B[A[q]-1];
			//printf("%d\n",tot);
		}
	}
	tot=tot+B[A[0] - 1];
	cout<<tot;
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/python3
# ABC058_B
"""
∵∴∵
"""

test = False

def restore():
    """
    奇数番目の文字の文字列 O
    偶数番目の文字の文字列 E
    からもとの文字列を復元する関数
    """
    O = input()  # 奇数番目の文字
    E = input()  # 偶数番目の文字
    password = ''  # もとのパスワード
    len_O = len(O)
    if test:
        print(len_O)

    for i in range(len_O):
        password += O[i]
        try:
            password += E[i]
        except IndexError:
            pass

    return password


def main():
    """
    main関数
    """
    print(restore())


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
let read_int_array n = Array.init n (fun _ -> Scanf.scanf " %d" (fun x -> x))

let n, a, b = Scanf.scanf "%d %d %d" (fun n a b -> n, a, b)
let x = read_int_array n

let rec ans i ret =
  if i = n - 1 then ret
  else ans (i + 1) (ret + min (a * (x.(i+1) - x.(i))) b)

let () = print_int (ans 0 0) 

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

using namespace std;
#define _for(i,j,N) for(int i = (j);i < (N);i++)
#define _rep(i,j,N) for(int i = (j);i <= (N);i++)
#define _dec(i,j,N) for(int i = (N-1);i >= (j);i--)
#define ALL(x) x.begin(),x.end()
#define PB push_back
#define LL long long

template<typename T>
ostream& operator<<(ostream& os,const vector<T>& v) {
    _for(i,0,v.size()) os << v[i] << " ";
    return os;
}

template<typename T>
ostream& operator<<(ostream& os,const set<T>& v){
    for(typename set<T>::iterator it = v.begin();it != v.end();it++)
    os << *it <<" ";
    return os;
}

using namespace std;

const int maxn = 1e5+5;

int f[maxn];
int A[maxn];
int N,M;
map<int,int> mp;
vector<int> group[maxn];

int finds(int x){return x == f[x]?x:(f[x] = finds(f[x]));}

int main()
{
    cin >> N >> M;
    _rep(i,1,N){
        f[i] = i;
        scanf("%d",&A[i]);
    }
    _for(i,0,M){
        int a,b;
        scanf("%d %d",&a,&b);
        int ra = finds(a);
        int rb = finds(b);
        if(ra != rb) f[ra] = rb;
    }

    int cnt = 0;
    _rep(i,1,N){
        int root = finds(i);
        if(!mp.count(root)){
            mp[root] = cnt++;
        }
        int id = mp[root];
        group[id].PB(i);
    }
    int ans = 0;

    _for(i,0,cnt){
        set<int> num;
        _for(j,0,group[i].size()){
            num.insert(A[group[i][j]]);
        }
        _for(j,0,group[i].size()){
            if(num.count(group[i][j])) ans++;
        }

    }

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

Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <unordered_map>
#include <utility>
#include <algorithm>
#include <set>
#include <cmath>
#include <array>
#include <bitset>
using namespace std;
typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b+1;i++)
#define Per(i,b,a) for(int i=b;i>=a;i--)
int main(){
    int H,W,K;
    cin>>H>>W>>K;
    int s[10][1000];
    string S;
    rep(i,H){
        cin>>S;
        rep(j,W){
            s[i][j] = S[j]-'0';
        }
    }
    int ind[10];
    int block = 0;
    int sum[10];
    int ans = 10000;
    int temp;
    rep(i,1<<(H-1)){
        block = 0;
        ind[0] = block;
        rep(j,H-1){
            if((i>>j)&1) block++;
            ind[j+1] = block;
        }
        temp = block;
        // cout<<i<<" "<<temp<<endl<<"   ";
        rep(j,H) sum[j] = 0;
        rep(j,W){
            rep(k,H){
                sum[ind[k]] += s[k][j];
            }
            rep(k,H){
                if(sum[ind[k]]>K) {
                    temp++;
                    // cout<<j<<" ";
                    rep(kk,H){
                        sum[kk] = 0;
                    }
                    rep(kk,H){
                        sum[ind[kk]] += s[kk][j];
                    }
                    rep(kk,H){
                        if(sum[ind[kk]]>K)temp = 100000;                
                    }
                    break;
                }
            }
        }
        // cout<<endl;
        ans = min(ans,temp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
def cost(x,y):
    return (x-y)**2
N = int(input())
A = sorted(list(map(int,input().split())))
cmin = 10**8
for a in range(A[0],A[-1]+1):
    tot = 0
    for i in range(N):
        tot += cost(a,A[i])
    cmin = min(cmin,tot)
print(cmin)

Measured memory_bytes: 38640
#include <stdio.h>

int N;
int a[271828];

int main(void) {
	int i;
	int next = 1;
	int answer = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i< N; i++) {
		if (scanf("%d", &a[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		if (a[i] != next) {
			answer++;
		} else {
			next++;
		}
	}
	printf("%d\n", next == 1 ? -1 : answer);
	return 0;
}


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

typedef long long ll;

string board[1010];

bool in_range(int n, int m, int x, int y)
{
  return 0 <= x && x < n && 0 <= y && y < m;
}

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

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

  int h, w; cin >> h >> w;
  for(int i=0; i<h; i++)
    cin >> board[i];

  queue<pair<int, int>> q, qt;

  int blacks = 0;
  for(int i=0; i<h; i++)
  {
    for(int j=0; j<w; j++)
    {
      if(board[i][j] == '#')
      {
        q.push({i, j});
        blacks++;
      }
    }
  }

  int t = 0;
  while(blacks < h*w)
  {
    while(q.size())
    {
      pair<int, int> p = q.front(); q.pop();
      for(int i=0; i<4; i++)
      {
        int nx = p.first + dx[i];
        int ny = p.second + dy[i];

        if(in_range(h, w, nx, ny) && board[nx][ny] == '.')
        {
          board[nx][ny] = '#';
          blacks++;
          qt.push({nx, ny});
        }
      }
    }

    q = qt;
    while(qt.size()) qt.pop();

    t++;
  }

  cout << t << endl;

  return 0;
}



Measured memory_bytes: 9600