akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <map>
using namespace std;

int N,M;
//memo
int memo[60];
int graph[60][60];

int dfs(int x){
    if(memo[x] == 1) return 0;
    memo[x] = 1;
    for(int i=1;i<=N;i++){
//        cout << " " << x << ":" << i << ":" << graph[x][i] << endl;
        if(graph[x][i] == 1){
            dfs(i);
        }
    }
}

int main() {

    cin >> N >> M;

    int a[M+1],b[M+1];
    for(int i=1;i<=N;i++){
        for(int k=1;k<=M;k++){
            graph[i][k] = 0;
        }
    }

    for(int i=1;i<=M;i++){
        cin >> a[i] >> b[i];
        graph[a[i]][b[i]] = 1;
        graph[b[i]][a[i]] = 1;
    }

    int res = 0;
    for(int i=1;i<=M;i++){
        for(int k=1;k<=N;k++) memo[k] = 0;
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = 0;
        dfs(1);
        for(int k=1;k<=N;k++){
            if(memo[k] != 1){
                res++;
                break;
            }
        }
        graph[a[i]][b[i]] = graph[b[i]][a[i]] = 1;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ii pair<int,int>
#define ll long long
#define pll pair<ll,ll>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define iiordered_set tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
#define MOD (1000*1000*1000+7)
ll power(ll a,ll b, ll m=MOD)
{
    ll res=1;
    while(b>0)
    {
        if(b&1)
            res=(res*a)%MOD;
        a=(a*a)%MOD;
        b>>=1;
    }
    return res;
}
ll inverse(ll a,ll m=MOD)
{
    return power(a,m-2,m);
}
int ceil(int a,int b)
{
    return (a+b-1)/b;
}
#define INFl (1e18+5)
#define vi vector<int>
#define vvi vector<vi>
#define vl vector<long long>
#define vvl vector<vl>
#define vll vector<pll>
#define vii vector<ii>
#define vvii vector<vii>
#define tri pair<int,ii>
#define F first
#define S second
#define forl(i,n) for(int i=0;i<n;i++)
#define fore(i,n) for(int i=1;i<=n;i++)
#define rforl(i,n)  for(int i=n-1;i>=0;i--)
#define rfore(i,n)  for(int i=n;i>=1;i--)
#define CASE(t) cout<<"Case #"<<(t)<<": ";
#define INF 1020000000
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define mp make_pair
#define pb push_back
#define print(x)    for(auto it=x.begin();it!=x.end();it++) cout<<*it<<' '; cout<<endl;
#define printii(x)  for(auto it=x.begin();it!=x.end();it++) cout<<it->F<<' '<<it->S<<endl;  
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
	int n,m;
	cin>>n>>m;
	cout<<n*(n-1)/2+m*(m-1)/2<<endl;;
}

Measured memory_bytes: 256
from sys import *

def get(n):
	return n * n * n * n * n

X = int(stdin.readline())
for a in range(0, 10001):
	A = get(a)
	B = abs(A - X)
	lo = 0
	hi = 10000
	b = -1
	ok = False
	while lo <= hi:
		mid = (lo + hi) // 2
		sum = get(mid)
		if sum is B:
			b = mid
			ok = True
			break
		if sum < B:
			lo = mid + 1
		else:
			hi = mid - 1
	if ok is True:
		if A < X:
			b = -b
		print("{} {}".format(a, b))
		exit()
			

Measured memory_bytes: 64352
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_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(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    ll X, K, D;
    cin >> X >> K >> D;
    X = abs(X);
    ll pos_cnt = X / D;
    ll neg_cnt = X / D + 1;
    ll ans_cnt;
    if(K % 2 == pos_cnt % 2) ans_cnt = min(K, pos_cnt);
    else ans_cnt = min(K, neg_cnt);
    output(abs(X - ans_cnt * D));
    
    
    return 0;
}


Measured memory_bytes: 3636
#include <stdio.h>

int main(void) {
   
   int R,G,B,N;
   
   scanf("%d%d%d%d",&R,&G,&B,&N);
   
   int i,j;
   int ans = 0;
   
   for (i = 0; i <= N; i++) {
      for (j = 0; j <= N; j++) {
         if ((i*R + j*G) <= N && (N - (i*R + j*G))%B == 0) {
            //printf("%d %d %d\n",i,j,(N - (i*R + j*G))/B);
            ans++;
         }
         if (j*G > N) {
            break;
         }
      }
   }
   
   printf("%d\n",ans);
   
   return 0;
   
}


Measured memory_bytes: 128
require 'prime'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times {|i|yield(i)}                    end
def repl(st,en,n=1);       n*= -1 if st>en;st.step(en,n){|i|yield(i)} end

ch = gsf
key = nil
case ch
when 'a'
key = true
when 'i'
	key = true
when 'u'
	key = true
when 'e'
	key = true
when 'o'
	key = true
else
	key = false
end

puts key ? 'vowel' : 'consonant'

Measured memory_bytes: 2044
object Main extends App {
  val inputs: Seq[String] = scala.io.Source.stdin.getLines().toList
  val s = inputs(0)
  val t = inputs(1)

  println(solve(s, t))

  def solve(s: String, t: String): String = {
    val size = s.size
    var ans = "No"
    (0 until size).foreach { i =>
      val splited = s.splitAt(size - i)
      if ( (splited._2 + splited._1) == t) {
        ans = "Yes"
      }
    }

    ans
  }
}

Measured memory_bytes: 54920
/*** akshaykumar99 ***/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
  
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 1e5+1;
 
typedef long long ll;
typedef long double ld;

void test_case()
{
    ll n,i,j;
    cin >> n;
    vector<ll> v(n);
    for(i = 0; i < n; i++)
    {
        cin >> v[i];
    }
    sort(v.rbegin(), v.rend());
    ll ans = v[0];
    ll tot = 2;
    for(i = 1; i < n; i++)
    {
        ans += v[i] * min(n-tot, 2ll);
        tot+=2;
        if(tot >= n)
            tot = n;
    }
    cout << ans << '\n';
}

 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL); 
    int tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Measured memory_bytes: 4780
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n;
    cin >> n;
    vi d(n);
    rep(i, n) cin >> d[i];
    int ans = 0;
    rep(i, n){
        for(int j=i+1;j<n;j++){
            ans += d[i]*d[j];
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N, X, Y= map(int, input().split(' '))
 
array=[None]*N
for i in range(N):
    array[i]=0
    
for k in range(1, N+1):
    for v in range(k, N+1):
       array[min([abs(k-v), abs(X-k)+abs(v-Y)+1, abs(Y-k)+abs(X-v)+1])] += 1 

for i in range(1, N):
    print(array[i])
   

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define int long long 
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back
#define pii pair<int,int>
using namespace std;
signed main()
{
    fast;
   	int n;
   	cin>>n;
   	int a[n+1];
   	bool flag = 1;
   	for(int i=1;i<=n;i++){
   		cin>>a[i];
   		if(a[i]%2 == 0){
   			if(!(a[i]%3 == 0 || a[i]%5 == 0)){
   				flag = 0;
   			}
   		}
   	}
   	if(flag)
   		cout<<"APPROVED";
   	else cout<<"DENIED";
    
}   

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
 
 
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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 print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
//template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
//template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll INF=1e9+7;

int main()
{
    string s;
    cin >> s;
    ll n=s.length();
    bool a=true;
    bool b=true;
    bool c=true;
    ll p=(n-1)/2;
    ll q=p+1;
    for(ll i=0;i<n;i++){
        if(s[i]!=s[n-1-i]){
            a=false;
            break;
        }
    }
    for(ll i=0;i<p;i++){
        if(s[i]!=s[p-1-i]){
            b=false;
            break;
        }
    }
    for(ll i=q;i<n;i++){
        if(s[i]!=s[n-1-i+q]){
            c=false;
            break;
        }
    }
    //cout << q << endl;
    if(a && b && c){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        //cout << a << b << c << endl;
        cout << "No" << endl;
    }
    return 0;
} 

Measured memory_bytes: 256
#!/usr/bin/env python

S = raw_input().split()

lst = []

for s in S:
	if s == '+':
		num1 = lst.pop()
		num2 = lst.pop()
		lst.append(num1 + num2)
	elif s == '-':
		num1 = lst.pop()
		num2 = lst.pop()
		lst.append(num2 - num1)
	elif s == '*':
		num1 = lst.pop()
		num2 = lst.pop()
		lst.append(num2 * num1)
	else:
		lst.append(int(s))

print lst[0]


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

using namespace std;

int main()
{
    unsigned long long x,y;
    cin >> x >> y;
    unsigned long long i;
    int j = 0;
    for (i = x;i <= y;j++) {
        i *= 2;
    }
    cout << j << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int solve(int a,int b){
    int sum=a+b,ans=0;
    while(sum>0){
        ans++;
        sum/=10;
    }
    return ans;
}
int main(void){
    int a[300]={},b[300]={},i=0;
    while(cin>>a[i]>>b[i]){
        cout<<solve(a[i],b[i])<<endl;
        i++;
    }
    return 0;
}

Measured memory_bytes: 3040
#include<cstdio>
#include<queue>
#include<algorithm>
using namespace std;

#define ran 5055

int n;
pair<int, int> p[ran];
priority_queue<int> q;

int main() {
	scanf("%d", &n);
	for(int i=0;i<n;i++) {
		int x, y; scanf("%d%d", &x, &y);
		p[i] = make_pair(x+y, y);
	}
	sort(p, p+n);
	
	while(!q.empty()) q.pop();
	long long tot = 0LL;
	for(int i=0;i<n;i++) {
		// printf("%d %d %lld\n", p[i].first, p[i].second, tot);
		if (tot + p[i].second <= p[i].first) {
			tot += p[i].second;
			q.push(p[i].second);
		} else {
			q.push(p[i].second);
			tot -= q.top() - p[i].second;
			q.pop();
		}
	}
	
	int ans = 0;
	while(!q.empty()) {
		q.pop(); ans++;
	}
	printf("%d\n", ans);
	
	return 0;
}


Measured memory_bytes: 384
N = int(input())
A = list(map(int, input().split()))
y = sum(A)
x = y * 1.0 / 2
s = 0
for i in range(N):
  s += A[i]
  if s >= x:
    break
print(min(abs(s - (y - s)), abs((s-A[i]) - (y - (s - A[i])))))

Measured memory_bytes: 94092
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;

mat t;
vll v;
lli c;
string s;
lli x;
lli r = 0;

void insert(lli x,lli i){
    if(x < v[i]){
        if(t[i][0] >= 0) insert(x,t[i][0]);
        else t[i][0] = c;
    }else{
        if(t[i][1] >= 0) insert(x,t[i][1]);
        else t[i][1] = c;
    }
}
bool find(lli x,lli i){
    if(x == v[i]) return true;
    if(x < v[i]){
        if(t[i][0] >= 0) return find(x,t[i][0]);
        else return false;
    }else{
        if(t[i][1] >= 0) return find(x,t[i][1]);
        else return false;
    }
}

void del(lli x,lli& i){
    //cout << x << " " << i << endl;
    if(x == v[i]){
        if(t[i][0] < 0 && t[i][1] < 0) i = -1;
        else if(t[i][0] < 0) i = t[i][1];
        else if(t[i][1] < 0) i = t[i][0];
        else{
            lli j = t[i][1];lli k = i;lli l = 1;
            while(t[j][0] >= 0)l = 0,k = j,j = t[j][0];
            v[i] = v[j];
            del(v[j],t[k][l]);
        }
        return;
    }
    if(x < v[i]){
        if(t[i][0] >= 0) return del(x,t[i][0]);
        else return;
    }else{
        if(t[i][1] >= 0) return del(x,t[i][1]);
        else return;
    }    

}

void inorder(lli i){
    if(t[i][0] >= 0) inorder(t[i][0]);
    cout << " " << v[i];
    if(t[i][1] >= 0) inorder(t[i][1]);
}

void preorder(lli i){
    cout << " " << v[i];
    if(t[i][0] >= 0) preorder(t[i][0]);
    if(t[i][1] >= 0) preorder(t[i][1]);
}

int main(){
    cin >> n;
    t = mat(n,vll(2,-1));
    v = vll(n);
    for(lli i = 0;i < n;i++){
        cin >> s;
        if(s == "insert"){
            cin >> x;
            v[c] = x;
            if(i) insert(x,r);
            c++;
        }else if(s == "print"){
            inorder(r);cout << endl;
            preorder(r);cout << endl;
        }else if(s == "find"){
            cin >> x;
            cout << (find(x,r) ? "yes" : "no") << endl;
        }else if(s == "delete"){
            cin >> x;
            del(x,r);
        }
    }

    return 0;
}

Measured memory_bytes: 33952
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int dx = tx - sx, dy = ty - sy;
    string ans = "";
    ans += string(dx, 'R');
    ans += string(dy, 'U');
    ans += string(dx, 'L');
    ans += string(dy, 'D');
    ans += "D";
    ans += string(dx + 1, 'R');
    ans += string(dy + 1, 'U');
    ans += "L";
    ans += "U";
    ans += string(dx + 1, 'L');
    ans += string(dy + 1, 'D');
    ans += "R";
    cout << ans << '\n';

}


Measured memory_bytes: 256
def readInt():
    return list(map(int,input().split()))
    
n,m = readInt()
h_j = [1 for i in range(n)]
h = readInt()
ans = 0
for i in range(m):
    a,b = readInt()
    a -= 1
    b -= 1
    if h[a]>h[b]:
        h_j[b]=0
    elif h[a]<h[b]:
        h_j[a]=0
    else:
        h_j[a]=0
        h_j[b]=0
# print(h_j)
for j in h_j:
    if j==1:
        ans += 1
print(ans)


Measured memory_bytes: 20832
def abc073_d():
    from scipy.sparse import lil_matrix
    from scipy.sparse.csgraph import floyd_warshall
    from itertools import permutations

    n, m, r = map(int, input().split())
    R = list(map(lambda x: int(x)-1, input().split()))
    graph = lil_matrix((n, n), dtype=int)
    for _ in range(m):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        graph[a, b] = c
        graph[b, a] = c

    dist = floyd_warshall(csgraph=graph)
    #print(dist)

    ans = 10**18
    for route in permutations(R, r):
        tmp = 0
        for i in range(r-1):
            s = route[i]
            t = route[i+1]
            tmp += dist[s][t]
            if tmp > ans: break
        ans = min(ans, tmp)
        #print(route, tmp)

    print(int(ans))

if __name__ == '__main__':
    abc073_d()

Measured memory_bytes: 40772
from sys import stdin
input = stdin.readline


def main():
  N, M = list(map(int, input().split()))
  H = list(map(int, input().split()))

  G = [[] for _ in range(N)]
  for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

  cnt = 0
  for i in range(N):
    for j in G[i]:
      if H[i] <= H[j]:
        break
    else:
      cnt += 1

  print(cnt)


if(__name__ == '__main__'):
  main()


Measured memory_bytes: 95160
'use strict';

const input = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');
const hands = input[0].split(' ').map(Number)

const A = hands[0] == 1 ? 14 : hands[0];
const B = hands[1] == 1 ? 14 : hands[1];

console.log(A == B ? 'Draw' : A > B ? 'Alice' : 'Bob');

Measured memory_bytes: 21064
#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define UNIQUE(v) { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); }
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) (q ? "Yes" : "No")
#define YES(q) (q ? "YES" : "NO")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) { cerr << "[DEBUG] " #q ": ["; REP(dumpall_i, (q).size()) { cerr << q[dumpall_i] << (dumpall_i == (q).size() - 1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; }
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
using  ll = long long;
using ull = unsigned long long;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ll n, m; cin >> n >> m;
    vector<ll> u(m), v(m);
    vector<vector<ll>> g(n);
    REP(i, m) {
        cin >> u[i] >> v[i];
        u[i]--; v[i]--;
        g[u[i]].emplace_back(v[i]);
    }
    ll s, t; cin >> s >> t;
    s--; t--;

    vector<vector<ll>> ds(n, vector<ll>(3, INF)); {
        deque<pair<ll,ll>> q = {{s, 0}}; ds[s][0] = 0;
        while (!q.empty()) {
            pair<ll,ll> pr = q.front(); q.pop_front();
            ll v = pr.first;
            ll modo = pr.second;
            ll next_modo = (modo + 1) % 3;
            for (ll ngb : g[v]) {
                if (chmin(ds[ngb][next_modo], ds[v][modo])) {
                    ds[ngb][next_modo] = ds[v][modo] + !next_modo;
                    q.emplace_back(ngb, next_modo);
                }
            }
        }
    }

    ll ans = ds[t][0];
    cout << (ans == INF ? -1 : ans) << endl;
    
}

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



int main(){
    int n,m;
    cin >> n >> m;
    char A[50][50],B[50][50];
    rep(i,n)rep(j,n) cin >> A[i][j];
    rep(i,m)rep(j,m) cin >> B[i][j];

    bool flag = false;
    rep(y,n)rep(x,n){
        if(y - 1 + m >= n || x - 1 + m >= n) continue;

        flag = true;
        rep(nx,m)rep(ny,m){
            if(A[y+ny][x+nx] != B[ny][nx]) flag = false;
        }

        if(flag) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;
}

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

namespace CSharpSample01
{


    class Program
    {

        const int MOD = 1000000007;

        static long Solve(string S)
        {
            int n = S.Length;

            S = string.Join("", S.Reverse());
            
            long[,] dp = new long[n + 1, 13];

            dp[0, 0] = 1;

            for(int j = 1; j < 13; j++)
            {
                dp[0, j] = 0;
            }
            
            int ten = 0;

            for(int i = 0; i < n; i++)
            {
                if (i == 0) ten = 1;
                else ten = (ten * 10) % 13;
                

                int c;
                if (S[i] == '?') c = -1;
                else c = S[i] - '0';

                for (int j = 0; j < 13; j++)
                {
                    for(int k = 0; k <= 9; k++)
                    {
                        if(c != -1)
                        {
                            dp[i + 1, (c * ten + j) % 13] += dp[i, j];
                            break;
                        }
                        dp[i + 1, (k * ten + j) % 13] += dp[i, j];
                    }       
                    
                }  
                
                for(int j = 0; j < 13; j++)
                {
                    dp[i + 1, j] %= MOD;
                }

            }

            
            return dp[n, 5];
        }

        
        static void Main(string[] args)
        {
            string S = Console.ReadLine();

            
            Console.WriteLine(Solve(S));
        }
    }
}

Measured memory_bytes: 24544
# -*- coding: utf-8 -*-

from collections import deque

X,Y,A,B,C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

def sort(L):
  if len(L)==1:
    return L
  left = sort(L[:len(L)//2])
  right = sort(L[len(L)//2:])
  result = []
  left.append(-1)
  right.append(-1)
  left_index = 0
  right_index = 0
  while len(result)<len(L):
    if left[left_index]>=right[right_index]:
      result.append(left[left_index])
      left_index += 1
    else:
      result.append(right[right_index])
      right_index += 1
  return result

P = sort(P)[:X]
Q = sort(Q)[:Y]
R = sort(R)

P_index = X-1
Q_index = Y-1
R_index = 0

while True:
  if P[P_index] <= Q[Q_index] and R[R_index]>P[P_index]:
    P[P_index] = R[R_index]
    P_index = max(0, P_index-1)
    R_index += 1
  elif P[P_index] > Q[Q_index] and R[R_index]>Q[Q_index]:
    Q[Q_index] = R[R_index]
    Q_index = max(0, Q_index-1)
    R_index += 1
  else:
    break
  if R_index>=len(R):
    break

print(sum(P)+sum(Q))
      

Measured memory_bytes: 23608
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int a,b;
  cin >> a >> b;
  int ans = 0;
  rep(i,b+1)if(i/10>=2 && i%10>=2){
   if((i/10)*(i%10)<=a) ans++; 
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
int N;
int a[1001];
int main(){
    std::cin>>N;
    for(int i=1;i<=N;i++){
        std::cin>>a[i];
    }
    int sum=1;
    int ans=0;
    for(int i=2;i<=N;i++){
        if(a[i]==a[i-1]){
            sum++;
        }else{
            ans+=sum/2;
            sum=1;
        }
    }
    ans+=sum/2;
    std::cout<<ans<<std::endl;
    return 0;
}

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

int f(int x,int y,int z){
  return x*x+y*y+z*z+x*y+y*z+z*x;
}

int main() {
  int nmax;
  cin >> nmax;
  for(int n=1;n<=nmax;n++){
    int cnt=0;
    for(int x=1;x<=100;x++){
      for(int y=1;y<=100;y++){
        int z = round(1/2.0*sqrt(4*n-(3*x*x+2*x*y+3*y*y)) - (x+y)/2.0);
        if(z >= 1 && f(x,y,z) == n){
          //cout << x << " " << y << " " << z << endl;
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
		  
  return(0);
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {

    ll N; cin >> N;
    vector<string> S(N);
    map<string,ll> m;
    for(ll i=0;i<N;i++){
        cin >> S[i];
        m[S[i]]++;
    }
    
    cout << "AC x "<<m["AC"] << endl;
    cout << "WA x "<<m["WA"] << endl;
    cout << "TLE x "<<m["TLE"] << endl;
    cout << "RE x "<<m["RE"] << endl;

    
    
    return 0;
}


Measured memory_bytes: 9568
"""
    選ぶ整数の数: 1~
    選ぶ整数: A*nで表現できる
    sum % B = CであればYes

    sum = A*(n1+n2+...)
    sum % B = A%B * (n1+n2+...)%B = C
    A%BがCの約数であればYes
    (A%B*n)%BがCの約数であってもYes
"""
a, b, c = map(int, input().split())
flag = False
a_mod = a % b
if a_mod == 0 and c == 0:
    flag = True
elif a_mod == 0:
    pass
# 以降 0< a_mod <b
elif c % a_mod == 0:
    flag = True
else:
    # 簡単に終わらなかったパターン
    # c % ((a%b*n)%b) == 0
    for i in range(1, b-1):
        ia_mod = (i*a_mod) % b
        if ia_mod == 0:
            continue
        elif c % ia_mod == 0:
            flag = True
            break

if flag:
    print('YES')
else:
    print('NO')


Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <string>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <utility>

using namespace std;
using ll = long long int;
int main(){
int A,B;
cin >> A >> B;

if((A*B)%2==1){
    cout <<"Yes";
}else{
    cout << "No";
}


return 0;
}

Measured memory_bytes: 256
import scala.io.StdIn.{readLine,readInt}

object Main extends App {
    val n = readInt
    for(i <- 1 to n) {
      val Array(a,b,c) = readLine.split(" ").map(_.toInt).sorted
      if(a*a+b*b==c*c)
        println("YES")
      else
        println("NO")
    }
}

Measured memory_bytes: 45776
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>


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

  int n;
  std::cin >> n;
  std::vector<int> ss(n);
  for (auto&& s : ss) {
    std::cin >> s;
  }
  std::sort(std::begin(ss), std::end(ss));

  auto sum = std::accumulate(std::cbegin(ss), std::cend(ss), 0);
  if (sum % 10 == 0) {
    for (const auto& s : ss) {
      if (s % 10 != 0) {
        sum -= s;
        break;
      }
    }
  }
  std::cout << (sum % 10 == 0 ? 0 : sum) << std::endl;

  return EXIT_SUCCESS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60; //intじゃ扱えないことに注意！
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //範囲外参照とループの初期化に注意！

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

  int sum = 0;
  for(int a = 1; a <= K; a++){
      for(int b=1; b<=K; b++){
          for(int c=1; c<=K; c++){
              sum += __gcd(a,__gcd(b,c));
          }
      }
  }
  cout << sum << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000000000000



int main(){
	
	int A,B,C,D;
	cin>>A>>B>>C>>D;
	
	cout<<min(A,B)+min(C,D)<<endl;
		
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

static const int N = 1000;

void trace(int A[], int n){
  int i;
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n");
}

int main(){
  int n, i, j,v;
  int A[N+1];
  scanf("%d", &n);

  for ( i = 1; i <= n; i++ ) scanf("%d", &A[i]);
  
  trace(A, n);
  
  for(i=2;i<=n;i++){
    v=A[i];
    j=i-1;    
    
  
  while(j>=0&&A[j]>v){
    A[j+1]=A[j];
    j--;
  }
  A[j+1]=v;
  
  trace(A, n);
  }
  return 0;
}

Measured memory_bytes: 608
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1, y1, x2, y2;
	double ans;

	//座標を入力
	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	//距離 = sqrt((y2 - y1)^2 + (x2 - x1)^2)
	ans = sqrt(pow(y2 - y1, 2.0) + pow(x2 - x1, 2.0));

	//結果を出力
	printf("%lf\n", ans);

	return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read() {
	int x = 0, fh = 1;
	char c = getchar();
	while (c < '0' || c > '9') {
		if (c == '-') fh = -1;
		c = getchar();
	}
	while (c >= '0' && c <= '9') {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * fh;
}
string s;
int n, k;
int main() {
	n = read(); k = read();
	cin >> s;
	s[k - 1] += 32;
	cout << s << '\n';
	return 0;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 5050;
Int solve(Int ga,Int sa,Int ba,Int gb,Int sb,Int bb,Int n){
  using P = pair<Int, Int>;
  vector<P> vt;
  vt.emplace_back(ga,gb);
  vt.emplace_back(sa,sb);
  vt.emplace_back(ba,bb);
  auto comp=[](P a,P b){return a.first*b.second>b.first*a.second;};
  sort(vt.begin(),vt.end(),comp);

  Int res=n;
  tie(ga,gb)=vt[0];
  tie(sa,sb)=vt[1];
  tie(ba,bb)=vt[2];

  for(Int i=0;i<MAX;i++){
    if(i*ga>n) break;
    for(Int j=0;j<MAX;j++){
      Int sum=i*ga+j*sa;
      if(sum>n) break;
      Int k=(n-sum)/ba;
      assert(n-(i*ga+j*sa+k*ba)>=0);
      chmax(res,n-(i*ga+j*sa+k*ba)+(i*gb+j*sb+k*bb));
    }
  }
  return res;
}

signed main(){
  Int n;
  cin>>n;

  Int ga,sa,ba;
  Int gb,sb,bb;
  cin>>ga>>sa>>ba;
  cin>>gb>>sb>>bb;

  Int p=solve(ga,sa,ba,gb,sb,bb,n);
  Int q=solve(gb,sb,bb,ga,sa,ba,p);
  cout<<q<<endl;
  return 0;
}


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

#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define rep(i,a,b) for(int i=a; i<b; i++)
#define ll long long
#define pb push_back
#define inf 1e+18L
#define MOD 1000000007

bool isPalin(const string &s, int i, int j){
    for(int x=i, y=j; x < y; x++, y--){
        if(s[x] != s[y]){ 
            return false;
        }
    }
    return true;
}

int main(){
    FastIO
    string s;
    cin >> s;
    int n = s.size();
    int x=(n-1)/2;
    if(isPalin(s,0,n-1) && isPalin(s,0,x - 1) && isPalin(s,x+1, n-1)){
        cout<<"Yes\n";
    }
    else{ 
        cout <<"No\n";
    }
    return 0;
}

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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

string base(int N, string S){
    if(N == 0){
        if(S == "") return "0";
        else return S;
    }

    if(abs(N) % 2 == 1){
        N--;
        return base(N / (-2), "1" + S);
    } else {
        return base(N / (-2), "0" + S);
    }
}

int main(){
    int N;
    cin >> N;
    cout << base(N, "") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch OrdinaryBeauty | diff OrdinaryBeauty.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address OrdinaryBeauty.cpp && ./a.out

/*
 
 3/29/2020
 
 15:14-15:47 give up
 
 https://qiita.com/drken/items/3fe1613c44de1f3bfbe1
 https://docs.google.com/document/d/1Yq384PEooRVsmlzB103YMLWwE_JhPN8AbxZagNrF_vY/edit#bookmark=id.rxwwyq1g7loy
 
 */

int N,M,D;

void solve() {
  double res;
  if(D==0) {
    res=1.0*(M-1)/N;
  } else {
    res=2.0*(N-D)*(M-1)/N/N;
  }
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N>>M>>D;
  solve();
  
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#include <vector>
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define LONG_LONG_MAX 9223372036854775807LL
#define pblank putchar(' ')
#define ll LL
#define fastIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> P;
int n, m, k;
const int maxn = 1e5 + 10;
template <class T>
inline T read()
{
    int f = 1;
    T ret = 0;
    char ch = getchar();
    while (!isdigit(ch))
    {
        if (ch == '-')
            f = -1;
        ch = getchar();
    }
    while (isdigit(ch))
    {
        ret = (ret << 1) + (ret << 3) + ch - '0';
        ch = getchar();
    }
    ret *= f;
    return ret;
}
template <class T>
inline void write(T n)
{
    if (n < 0)
    {
        putchar('-');
        n = -n;
    }
    if (n >= 10)
    {
        write(n / 10);
    }
    putchar(n % 10 + '0');
}
template <class T>
inline void writeln(const T &n)
{
    write(n);
    puts("");
}
const ld PI = acos(-1);
ld f(int a, int b, int x)
{
    if (2.0 * x >= a * a * b)
        return (ld)atan((2 * a * a * b * 1.0 - 2 * x) / (a * a * a * 1.0));
    return PI / 2 - atan(2 * x * 1.0 / (a * b * b));
}
int main(int argc, char const *argv[])
{
#ifndef ONLINE_JUDGE
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
#endif

    int a, b, x;
    cin >> a >> b >> x;
    cout << fixed << setprecision(10) << f(a, b, x) * 180.0 / PI;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define REP(i,n) for(int i=0; i<n; i++)
#define REP_R(i,n,m) for(int i=m; i<n; i++)
#define MAX 100

int main() {
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  int ans = 0, ans1 = 0;

  ans1 = abs(a-b) + abs(b-c);
  ans = abs(a-c) + abs(c-b);
  ans1 = min(ans,ans1);
  ans = abs(b-a) + abs(a-c);
  ans1 = min(ans,ans1);
  ans = abs(b-c) + abs(c-a);
  ans1 = min(ans,ans1);
  ans = abs(c-a) + abs(a-b);
  ans1 = min(ans,ans1);
  ans = abs(c-b) + abs(b-a);

  cout << ans1 << endl;
}


Measured memory_bytes: 256
def f(a,b,c):
	return (a==5 and b==7 and c==5)
# your code goes here
a,b,c = map(int,input().split())
if f(a,b,c) or f(a,c,b) or f(b,a,c) or f(b,c,a) or f(c,a,b) or f(c,b,a):
	print("YES")
else:
	print("NO")

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
//#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl


signed main(void){
    int A,B;
    cin >> A >> B;
    REP(i,100000){
        int a=(i*8)/100;
        int b=(i)/10;
        if(A==a && B==b){
            cout << i << endl;
            return 0;
        }
    }
    cout << -1 << endl;
    return 0;
}



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

#define rep(i, a, b) for ( int i = (a); i < (b); i++ )
#define per(i, a, b) for ( int i = (b)-1; i >= (a); i--)
#define pb push_back
#define mp make_pair
#define bg begin()
#define en end()


using namespace std;

typedef long long ll;

static const long long MOD = 1000000007;
static const int INF = 1000000000;


int ans, H, W;
char maze[25][25];
map<pair<int, int>, int> m;
int d[405][405];

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

int main(void) {
    scanf("%d %d", &H, &W);
    rep(i, 0, H) {
        scanf("%s", maze[i]);
    }

    rep(i, 0, H*W) {
        rep(j, 0, H*W) {
            if (i==j) d[i][j] = 0;
            else d[i][j] = INF;
        }
    }


    rep(y, 0, H) {
        rep(x, 0, W) {

            if (maze[y][x] == '#') continue;

            rep(r, 0, 4) {
                int sx = x + dx[r];
                int sy = y + dy[r];
                if (x<0 || x>=W || y<0 || y>=H) continue;

                int src = y*W + x;
                int dst = sy*W + sx;

                if (maze[sy][sx] == '.') {
                    d[src][dst] = d[dst][src] = 1;
                }
                
            }
        }
    }

    rep(k, 0, H*W) {
        rep(i, 0, H*W) {
            rep(j, 0, H*W) {
                //if (d[i][j] != INF || d[i][k] != INF || d[k][j] != INF) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
                d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    rep(i, 0, H*W) {
        rep(j, 0, H*W) {
            if (d[i][j] != INF) ans = max(ans, d[i][j]);
        }
    }


   

  
    printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 896
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>

using namespace std;



int main(){

    long long a, b, t;
    cin >> a >> b >> t;

    long long ans = 0;
    for(int i = a;i<=t;i+=a){
        ans +=b;
    }

    cout << ans << endl;
}


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

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

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

    int max = 0;
    int poj = 0;
    for(int i = 0; i < n; i++){
        if(i != n - 1){
            dis[i] = a[i + 1] - a[i];
            if(max < dis[i]){
                max = dis[i];
                poj = i;
            }
        }else{
            dis[i] = a[0] + (k - a[i]);
            if(max < dis[i]){
                max = dis[i];
                poj = i;
            }
        }
    }

    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(i != poj){
            ans += dis[i];
        }
    }

    cout << ans << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int ans = 0, cnt = 0;
    REP(i, n-1){
        if(v[i] >= v[i+1]){
            cnt++;
        }else{
            chmax(ans, cnt);
            cnt = 0;
        }
    }
    chmax(ans, cnt);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int mp[3][3];
	bool f[3][3] = {};
	
	for (int i = 0; i < 3; ++i){
		for (int j = 0; j < 3; ++j){
			cin >> mp[i][j];
		}
	}
	int n;
	cin >> n;
	
	while(n--){
		int in;
		cin >> in;
		for (int i = 0; i < 3; ++i){
			for (int j = 0; j < 3; ++j){
				if (mp[i][j] == in) f[i][j] = true;
			}
		}
	}
	
	bool ans = false;
	
	for (int i = 0; i < 3; ++i){
		bool ans2 = true;
		for (int j = 0; j < 3; ++j){
			if (!f[i][j]) ans2 = false;
		}
		if (ans2) ans = true;
	}
	for (int i = 0; i < 3; ++i){
		bool ans2 = true;
		for (int j = 0; j < 3; ++j){
			if (!f[j][i]) ans2 = false;
		}
		if (ans2) ans = true;
	}
	if (f[0][0] && f[1][1] && f[2][2] || f[0][2] && f[1][1] && f[2][0]) ans = true;
	
	cout << (ans ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
#define SORT(i) sort((i).begin(),(i).end())
#define INF 2000000000
constexpr ll mod = 1000000007;

int main() {
	int N;
	cin >> N;
	vector<int>p(N);
	for (int i = 0;i < N;++i) {
		cin >> p[i];
	}
	int cnt = 0;
	for (int i = 0;i < N;++i) {
		if (p[i] == i + 1) {
			++cnt;
			if (i == N - 1)break;
			else ++i;
		}
	}
	cout << cnt << "\n";

	return 0;
}

Measured memory_bytes: 640
/*ITP1_2_C.c*/
#include<stdio.h>
int main(void){
   int a,b,c;
   scanf("%d %d %d",&a,&b,&c);
   if(a<=b && b<=c){
      printf("%d %d %d\n",a,b,c);
      return 0;
   }
   if(a<=c && c<=b){
      printf("%d %d %d\n",a,c,b);
      return 0;
   }
   if(b<=a && a<=c){
      printf("%d %d %d\n",b,a,c);
      return 0;
   }
   if(b<=c && c<=a){
      printf("%d %d %d\n",b,c,a);
      return 0;
   }
   if(c<=a && a<=b){
      printf("%d %d %d\n",c,a,b);
      return 0;
   }
   if(c<=b && b<=a){
      printf("%d %d %d\n",c,b,a);
      return 0;
   }
   return 0;
}

Measured memory_bytes: 1860