akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

constexpr int INF = std::numeric_limits<int>::max();
using namespace std;

void solve() {
  int N;
  cin >> N;

  vector<int> H(N);
  for (int &h : H) {
    cin >> h;
  }

  vector<int> dp(N + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < N - 1; i++) {
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(H[i] - H[i + 1]));
    dp[i + 2] = min(dp[i + 2], dp[i] + abs(H[i] - H[i + 2]));
  }

  cout << dp[N - 1] << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n,a,b;
        n = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
        int c,d;
        c = a*n;
        if(b<c){
            d = b;
        }else{
            d = c;
        }
        System.out.println(d);
    }
}

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

int main(){
  int n;
  cin>>n;
  int t[n+1],x[n+1],y[n+1];
  t[0]=x[0]=y[0]=0;
  for(int i=1;i<=n;i++){
    cin >> t[i]>>x[i]>>y[i];
    int passtime=t[i]-t[i-1];
    int dxdy=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
    if( passtime<dxdy||passtime%2!=dxdy%2){
      cout << "No";
      return 0;
    }
  }
  cout << "Yes";
}

Measured memory_bytes: 1408
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define INF -1e15

int main() {
	int N;
	cin>>N;
	vector<LL> A(N+4);
	for (int i = 0; i < N; i++){
		cin>>A[i];
	}
	vector<vector<LL>> dp(N+4,vector<LL>(3,INF));
	dp[0][0]=A[0];
	dp[1][1]=A[1];
	dp[2][2]=A[2];
	for (int i = 0; i < N; i++){
		if(dp[i][0]!=INF){
			dp[i+2][0]=max(dp[i+2][0],dp[i][0]+A[i+2]);
			dp[i+3][1]=max(dp[i+3][1],dp[i][0]+A[i+3]);
			dp[i+4][2]=max(dp[i+4][2],dp[i][0]+A[i+4]);
		}
		if(dp[i][1]!=INF){
			dp[i+2][1]=max(dp[i+2][1],dp[i][1]+A[i+2]);
			dp[i+3][2]=max(dp[i+3][2],dp[i][1]+A[i+3]);
		}
		if(dp[i][2]!=INF){
			dp[i+2][2]=max(dp[i+2][2],dp[i][2]+A[i+2]);
		}
	}
	if(N%2==0)cout<<max(dp[N-2][0],dp[N-1][1])<<endl;
	else cout<<max(max(dp[N-3][0],dp[N-2][1]),dp[N-1][2])<<endl;
}

Measured memory_bytes: 22004
N = int(input())
A = [list(map(int, input().split())) for _ in range(N)]

for k in range(N):
    for i in range(N):
        for j in range(N):
            #より短い経路があれば過程が崩れるのでNG
            if A[i][j] > A[i][k] + A[k][j]:
                print(-1)
                exit()


"""
存在する道路の長さの和が最小となるようなもの
→ Aについて、i<->jを結ぶ最短の辺（間に他のノードがない辺）だけ足し合わせる
"""
ans = 0
for i in range(N):
    for j in range(i+1, N):
        has_other_edges = False
        for k in range(N):
            if i == k or j == k: continue
            if A[i][j] == A[i][k] + A[k][j]:
                has_other_edges = True

        if not has_other_edges:
            ans += A[i][j]



print(ans)

            

Measured memory_bytes: 44380
#include <bits/stdc++.h>
using namespace std;
 
int main(){

    string S;
    cin >> S;

    int result = 0;

    for(int i=0; i<floor(S.size()/2); i++){
        if(S[i] != S[S.size() - 1 - i]){
            result += 1;
        }
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;

const ll MOD = 1000000007;

int main()
{
    ll n, k;
    cin >> n >> k;
    int a[2002];
    for(int i = 0; i < n; i++) cin >> a[i];
    ll s = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < i; j++) if(a[j] > a[i]) s++;
    }
    ll t = 0;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++) if(a[j] > a[i]) t++;
    }
    cout << (s % MOD * k % MOD + t % MOD * (k * (k - 1) / 2 % MOD) % MOD) % MOD << endl;
}

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

int main()
{
    int n ;
    cin >> n ;
    if(n%1000==0)
    {
        cout << 0 << endl ;
    }
    else
    {
        cout << 1000-n%1000 << endl;
    }
    
}

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

// long long 用の pow (MAX ll 9,223,372,036,854,775,807 -> 19桁)
ll myLongLongPow(ll base, ll times) {
    ll acc = 1;
    rep(i, times) acc *= base;
    return acc;
}

// MAX int 2,147,483,647 -> 10桁
// MAX ll 9,223,372,036,854,775,807 -> 19桁
// MAX O(n) 10^18 -> 18回

int main() {
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S.at(i);

    vector<int> C(4, 0);

    rep(i, N) {
        if ("AC" == S.at(i)) {
            C.at(0)++;
        } else if ("WA" == S.at(i)) {
            C.at(1)++;
        } else if ("TLE" == S.at(i)) {
            C.at(2)++;
        } else if ("RE" == S.at(i)) {
            C.at(3)++;
        }
    }

    cout << "AC x " << C.at(0) << endl;
    cout << "WA x " << C.at(1) << endl;
    cout << "TLE x " << C.at(2) << endl;
    cout << "RE x " << C.at(3) << endl;

    return 0;
}


Measured memory_bytes: 6432
#include <iostream>
#include <string>
using namespace std;
int main( void )
{
  ios::sync_with_stdio(false);
  int N, A, B;
  string S;
  cin >> N >> A >> B;
  cin >> S;
  int n = 0;
  int m = 0;
  for( int i=0; i<N; i++ ){
    switch( S[i] ){
      case 'a':
        if( n < A+B ){
          cout << "Yes" << endl;
          n++;
        } else {
          cout << "No" << endl;
        }
        break;
      case 'b':
        if( n < A+B && m < B ){
          cout << "Yes" << endl;
          n++; m++;
        } else {
          cout << "No" << endl;
        }
        break;
      case 'c':
        cout << "No" << endl;
    }
  }
}

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

const int maxn = 3e5+2;

int a[maxn];
int t;

int main()
{
	string s; cin>>s;
	bool bo = 0,boo = 0;
	for(int i=0;i<s.size();++i)
	{
		if(s[2]==s[3] ) bo =1;
		if(s[4]==s[5]) boo=1;
	}
	cout<<(bo&&boo?"Yes":"No")<<"\n";
}

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

int main(){
    int n;
    string s1, s2;
    int a = 0, b = 0;
    cin >> n;
    
    for (int i =0; i < n; i++){
        cin >> s1>> s2;
        if(s1>s2) a+= 3;
        else if (s1 < s2) b += 3;
        else {
            a++; b++;
        }
    }
    cout << a << " " << b << endl;
    return 0;
}


Measured memory_bytes: 3184
import std.algorithm, std.range;
import std.string;
import std.conv;
import std.stdio;
void main()
{
    readln.chomp.split[1].to!long.solve(
            readln.chomp.split.to!(long[]),
            readln.chomp.split.to!(long[])).writeln;
}
private:
auto solve(long maxTraining, long[] currentCost, long[] difficulty)
{
    long training(long timelimit)
    {
        if (timelimit < 0)
            return long.max;
        return currentCost.minTraining(difficulty.maxCost(timelimit));
    }
    long minExcTimelimit = -1, maxIncTimelimit = 1_000000_000000;
    while (minExcTimelimit + 1 < maxIncTimelimit)
    {
        assert (maxTraining < training(minExcTimelimit));
        assert (training(maxIncTimelimit) <= maxTraining);
        immutable midTimelimit = minExcTimelimit + ((maxIncTimelimit - minExcTimelimit) >> 1);
        if (training(midTimelimit) <= maxTraining)
            maxIncTimelimit = midTimelimit;
        else
            minExcTimelimit = midTimelimit;
    }
    return maxIncTimelimit;
}
unittest
{
    assert (solve(5, [long(4), 2, 1], [long(2), 3, 1]) == 2);
    assert (solve(8, [long(4), 2, 1], [long(2), 3, 1]) == 0);
    assert (solve(14,
            [long(3), 1, 4, 1, 5, 9, 2, 6, 5, 3, 5],
            [long(8), 9, 7, 9, 3, 2, 3, 8, 4, 6, 2]) == 12);
}
long[] maxCost(long[] difficulty, long timelimit)
{
    auto ret = new long[difficulty.length];
    ret[] = timelimit / difficulty[];
    return ret;
}
unittest
{
    assert ([long(2), 3, 1].maxCost(2) == [1, 0, 2]);
}
long minTraining(long[] currentCost, long[] maxCost)
{
    return long(0).reduce!((a, b) => a + 0.max(b[0]-b[1]))
    (
        currentCost.sort!"a>b".zip
        (maxCost.sort!"a>b")
    );
}
unittest
{
    assert ([long(4), 2, 1].minTraining([1, 0, 2]) == 4);
}
unittest
{
    stderr.writeln("unittest passed!");
}


Measured memory_bytes: 50872
using System;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string sN = Console.ReadLine();
            int N = int.Parse(sN);
            string st = Console.ReadLine();
            string[] ast = st.Split();
            int[] A = new int[ast.Length];
            for (int n = 0; n < N; n++)
            {
                A[n] = int.Parse(ast[n]);

            }
            int key;
            int j;
            for (int i = 0; i < A.Length; i++)
            {
                if (i != 0)
                {
                    key = A[i];
                    /* insert A[i] into the sorted sequence A[0,...,j-1] */
                    j = i - 1;
                    while (j >= 0 && A[j] > key)
                    {
                        A[j + 1] = A[j];
                        j--;
                    }
                    A[j + 1] = key;
                }

                string output = "";

                for (int ii = 0; ii < A.Length; ii++)
                {

                    output += A[ii] + " ";
                }
                output = output.TrimEnd(' ');
                Console.WriteLine(output);

            }
            Console.ReadLine();
        }
    }
}

Measured memory_bytes: 6172
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int in() {int x; cin>>x; return x;}
ll lin() {ll x; cin>>x; return x;}
string sin() {string x;cin>>x;return x;}
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;

bool ifprime(int x){
    if(x==1)return false;
    if(x==2)return true;
    if(x%2==0)return false;
    for(int i=2;i*i<=x;i++){if(x%i==0)return false;}
    return true;
}

int main(){
    int N=in();
    int cnt=0;
    int ans=0;
    int h, f, r=0;
    int check=0;
    rep(i, N){
        cin>>h;
        if(i==0){
            cnt=h-r;
            f=h-r;
        }
        else if(f<h){
            if(check==1){
                ans+=cnt;
                cnt=h-f;
                r=f;
                f=h;
                check=0;
            }
            else{
                cnt=h-r;
                f=h;
            }
        }
        else{
            f=h;
            check=1;
        }
    }
    ans+=cnt;
    cout<<ans<<endl;
}

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

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

    int ans;
    if (K % 2 == 0) {
        ans = (K/2)*(K/2);
    } else {
        ans = (K/2)*(K/2 + 1);        
    }

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

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5+100;
const double P = acos(-1.0);
int main() {
    int n,m,sum=0;
    cin>>n>>m;
    for(int i=1,x;i<=m;i++)
        cin>>x,sum+=x;
    if(sum>n)
    cout<<-1<<endl;
    else
    cout<<n-sum<<endl;

}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
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; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }


int main() {
    int N, Q;
    while (cin >> N) {
        long long res = 0;
        map<long long, long long> ma;
        for (int i = 0; i < N; ++i) {
            long long A;
            cin >> A;
            ma[A]++;
            res += A;
        }
        cin >> Q;
        for (int i = 0; i < Q; ++i) {
            long long B, C;
            cin >> B >> C;
            long long num = ma[B];
            ma[B] = 0;
            ma[C] += num;

            res += (C - B) * num;
            cout << res << endl;
        }
    }
}

















Measured memory_bytes: 9388
using System.Linq;
using static System.Console;

namespace abc106_d
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadLine().Split().Select(int.Parse).ToArray();
            int N = input[0];
            int M = input[1];
            int Q = input[2];

            int[] l = new int[M];
            int[] r = new int[M];
            for(int i=0; i<M; i++){
                var tmp = ReadLine().Split().Select(int.Parse).ToArray();
                l[i] = tmp[0];
                r[i] = tmp[1];
            }

            int[] p = new int[Q];
            int[] q = new int[Q];
            for(int i=0; i<Q; i++){
                var tmp = ReadLine().Split().Select(int.Parse).ToArray();
                p[i] = tmp[0];
                q[i] = tmp[1];
            }

            int[,] sum = new int[N+1,N+1];
            for(int i=0; i<M; i++){
                sum[l[i], r[i]]++;
            }

            for(int i=1; i<=N; i++){
                for(int j=1; j<=N; j++){
                    sum[i,j] += sum[i-1, j];
                    sum[i,j] += sum[i, j-1];
                    sum[i,j] -= sum[i-1, j-1];
                }
            }

            for(int i=0; i<Q; i++){
                int cnt = sum[q[i],q[i]] - sum[p[i]-1, q[i]] - sum[q[i], p[i]-1] + sum[p[i]-1, p[i]-1];
                WriteLine(cnt);
            }
        }
    }
}

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

//create arrays outside of main()
int N = 10;
int a[10] = {};


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

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

    int largestNum = 0;

    for(int i=0; i<N; i++){
        if(a[i]>largestNum){
            largestNum = a[i];
        }
    }

    int priceLargest = largestNum/2;

    int total = 0;

    for(int i=0; i<N; i++){
        total = total + a[i];
    }

    total = total-priceLargest;


    cout << total;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define DEBUG
#define PI 3.141592653589793238462643383279
 
#define _GLIBCXX_DEBUG
#ifdef DEBUG
#define s(...) show(__VA_ARGS__);
#define sl(...) show(__VA_ARGS__);cout<<endl;
#else
#define s(...)
#define sl(...)
#endif
void show() {}
template <class Head,class... Args>void show(Head t,Args... args){std::cout<<t<<" ";show(args...);}
#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 REP1(i, n) for(ll i = 1; i <= n; i++)
#define REPR1(i, n) for(ll i = n; i >= 1; i--)
#define FOR1(i, m, n) for(ll i = m; i <= n; i++)
const ll INF = LLONG_MAX;
#define VEC(type,A,N) vector<type> A(N)
#define VECi(type,A,N,i) vector<type> A(N,i)
#define VEC2(type,A,N,M) vector<vector<type>> A(N,vector<type>(M))
#define VEC2i(type,A,N,M,i) vector<vector<type>> A(N,vector<type>(M,i))
#define ALL(v) v.begin(), v.end()
ll frac(ll k){
    int s = 1;
    for (ll i=1; i<=k; ++i)s *= i;
    return s;
}
ll gcd(ll a, ll b){
   if (a%b==0)return(b);
   else return(gcd(b, a%b));
}
ll lcm(ll a,ll b){
    return a*b/gcd(a,b);
}
ll antidiv(ll N,ll C,ll D){
    return N-floor(N/C)-floor(N/D)+floor(N/lcm(C,D));
}
vector<ll> yakusuu(ll N){
    vector<ll> ret;
    for (ll i = 1; i * i <= N; i++) {
        if (N % i == 0) {
            ret.push_back(i);
            if (i * i != N) ret.push_back(N / i);
        }
    }
    sort(ret.begin(), ret.end());
    return ret;
}
int main(){
    ll N,M;
    cin>>N>>M;
    
    ll sum=0;
    if(2*N>M){
        cout<<M/2;
    }else{
        cout<<N+(M-2*N)/4;
    }
    //cout<<fixed<<setprecision(32)<<m;
    //sort(ALL(C),[](auto& a, auto& b) {return a[2] < b[2];});
    //if(equal(D.begin(), D.end()-1, K.begin()))cout<<"Yes";else cout<<"No";
    cout<<endl;
    return 0;
}


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

using namespace std;

void tree_dist(const vector<vector<int> > &g, int root, vector<int> &dist)
{
	dist.assign(g.size(), 0);
	queue<pair<int, int> > q;
	for (q.push(make_pair(root, -1)); !q.empty(); q.pop())
		for (int i = 0, u = q.front().first; i < g[u].size(); i++)
			if (g[u][i] != q.front().second) {
				dist[g[u][i]] = dist[u] + 1;
				q.push(make_pair(g[u][i], u));
			}
}

int main(int argc, char *argv[])
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vector<vector<int> > g(n);
	for (int i = 0; i < n - 1; i++) {
		int u, v;
		cin >> u >> v;
		u--; v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}

	vector<int> d, ans(n), p, q;
	tree_dist(g, 0, d);
	for (int i = 0; i < n; i++)
		if (d[i] % 2 == 0) p.push_back(i);
		else q.push_back(i);
	set<int> s;
	for (int i = 1; i <= n; i++) s.insert(i);
	if (p.size() <= q.size()) {
		if (p.size() <= n / 3) {
			for (int i = 0, next = 3; i < p.size(); i++, next += 3) {
				ans[p[i]] = next;
				s.erase(next);
			}
		} else {
			for (int i = 0, next = 1; i < p.size(); i++, next += 3) {
				ans[p[i]] = next;
				s.erase(next);
				if (next + 3 > n) next = 0;
			}
		}
	} else {
		if (q.size() <= n / 3) {
			for (int i = 0, next = 3; i < q.size(); i++, next += 3) {
				ans[q[i]] = next;
				s.erase(next);
			}
		} else {
			for (int i = 0, next = 1; i < q.size(); i++, next += 3) {
				ans[q[i]] = next;
				s.erase(next);
				if (next + 3 > n) next = 0;
			}
		}
	}

	set<int>::iterator it = s.begin();
	for (int i = 0; i < n; i++)
		if (ans[i] == 0) ans[i] = *it++;

	for (int i = 0; i < n; i++) cout << (i ? " " : "") << ans[i];
	cout << endl;

	return 0;
}


Measured memory_bytes: 24636
using System;
using System.IO;
 
class MainClass {
    static void Main() {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
 
        string line;
        while ((line = Console.ReadLine()) != null) {
            string[] tokens = line.Split(' ');
            int a = int.Parse(tokens[0]);
            int b = int.Parse(tokens[1]);
          if((a+b) % 2 == 0){
            Console.WriteLine((a + b)/2);
          }else{
            Console.WriteLine((a + b + 1)/2);
          }
        }
 
        Console.Out.Flush();
    }
}

Measured memory_bytes: 13140
a,b=map(int,input().split())
g1=[1,3,5,7,8,10,12]
g2=[4,6,9,11]
g3=[2]
if a in g1 and b in g1:
  print('Yes')
elif a in g2 and b in g2:
  print('Yes')
elif a in g3 and b in g3:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#define inf 1000000000

using namespace std;
struct edge{
	int to, cap, rev;
	edge(int a, int b, int c){
		to = a, cap = b, rev = c;
	}
};

int H, W;
char map[105][105];
int sx, sy, tx, ty;
vector<edge> G[205];
int S, T;
bool used[205];

void add_edge(int u, int v, int cap)
{
	G[u].push_back( edge(v, cap, G[v].size()) );
	G[v].push_back( edge(u, 0, G[u].size()-1) );
}

int dfs(int v, int f)
{
	used[v] = true;
	if(v == T) return f;
	
	int ret;
	for(int i = 0; i < G[v].size(); i++){
		if(used[G[v][i].to] || G[v][i].cap <= 0) continue;
		ret = dfs(G[v][i].to, min(f, G[v][i].cap));
		if(ret > 0){
			G[v][i].cap -= ret;
			G[G[v][i].to][G[v][i].rev].cap += ret;
			return ret;
		}
	}
	return 0;
}

int main(void)
{
	cin >> H >> W;
	for(int y = 1; y <= H; y++){
		for(int x = 1; x <= W; x++){
			cin >> map[x][y];
			if(map[x][y] == 'S'){
				sx = x, sy = y;
				map[x][y] = 'o';
			}
			if(map[x][y] == 'T'){
				tx = x, ty = y;
				map[x][y] = 'o';
			}
		}
	}
	if(sx == tx || sy == ty){
		cout << -1 << endl;
		return 0;
	}
	
	for(int y = 1; y <= H; y++){
		for(int x = 1; x <= W; x++){
			if(map[x][y] == '.') continue;
			add_edge(x, W+y, 1);
			add_edge(W+y, x, 1);
		}
	}
	S = H+W+1, T = H+W+2;
	add_edge(S, sx, inf), add_edge(S, W+sy, inf), add_edge(tx, T, inf), add_edge(W+ty, T, inf);
	
	int ans = 0, flow;
	while(1){
		for(int i = 1; i <= T; i++) used[i] = false;
		flow = dfs(S, inf);
		if(flow <= 0) break;
		ans += flow;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 896
Uses math;
var h, w, i, j, k, cnt, start, ans : int64;
    s : array[1..2001] of array[1..2001] of char;
    tate, yoko : array[1..2001] of array[1..2001] of int64;
    temp : char;
begin
  readln(h, w);
  for i := 1 to h do begin
    for j := 1 to w do read(s[i][j]);
    read(temp);
    s[i][w+1] := '#';
  end;
  for i := 1 to w+1 do s[h+1][i] := '#';
  
  for i := 1 to h do begin
    for j := 1 to w do begin
      tate[i][j] := 0; yoko[i][j] := 0;
    end;
  end;
  
  for i := 1 to h do begin
    cnt := 0;
    start := 1;
  
    for j := 1 to w+1 do begin
      if s[i][j] = '.' then inc(cnt) else begin
        for k := start to j-1 do yoko[i][k] := cnt;
        start := j+1;
        cnt := 0;
      end;
    end;
  end;
  
  for j := 1 to w do begin
    cnt := 0;
    start := 1;
  
    for i := 1 to h+1 do begin
      if s[i][j] = '.' then inc(cnt) else begin
        for k := start to i-1 do tate[k][j] := cnt;
        start := i+1;
        cnt := 0;
      end;
    end;
  end;
  
  ans := 0;
  for i := 1 to h do begin
    for j := 1 to w do begin
      if s[i][j] = '#' then Continue;
      ans := Max(ans, tate[i][j] + yoko[i][j] - 1);
    end;
  end;
  writeln(ans);
end.


Measured memory_bytes: 66688
#include <stdio.h>         //█████████████████████████████
#include <stdlib.h>        //█                           █
#include <math.h>          //█        ▄▀▄     ▄▀▄        █
#include <string.h>        //█       ▄█░░▀▀▀▀▀░░█▄       █
#include <ctype.h>         //█   ▄▄  █░░░░░░░░░░░█  ▄▄   █
#include <iostream>        //█  █▄▄█ █░░▀░░┬░░▀░░█ █▄▄█  █
#include <algorithm>       //█████████████████████████████
#include <string>
#include <vector>

using namespace std;

#define U unsigned
#define S short
#define L long
#define LL long long 
#define LLU long long unsigned

#define rd(arr, n) for(int aab = 0; aab < n; aab++){scanf("%d", &arr[aab]);}
#define pd(arr, n) for(int aab = 0; aab < n; aab++){printf("%d ", arr[aab]);}
#define rlld(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lld", &arr[aab]);}
#define plld(arr, n) for(int aab = 0; aab < n; aab++){printf("%lld ", arr[aab]);}
#define rllu(arr, n) for(int aab = 0; aab < n; aab++){scanf("%llu", &arr[aab]);}
#define pllu(arr, n) for(int aab = 0; aab < n; aab++){printf("%llu ", arr[aab]);}
#define rlf(arr, n) for(int aab = 0; aab < n; aab++){scanf("%lf", &arr[aab]);}
#define plf(arr, n) for(int aab = 0; aab < n; aab++){printf("%lf ", arr[aab]);}
#define rc(arr, n) for(int aab = 0; aab < n; aab++){scanf("%c", &arr[aab]);}
#define pc(arr, n) for(int aab = 0; aab < n; aab++){printf("%c", arr[aab]);}
#define rs(arr) scanf("%s", arr);
#define ps(arr) puts(arr);

#define swap(a, b) {int temp = a;a = b;b = temp;}
#define freopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stdout);

int min(int a, int b){	return a <= b ? a : b;}
int max(int a, int b){	return a >= b ? a : b;}
int findmin(int arr[], int n){int min = 0;for(int i = 1; i < n;min = arr[i] < arr[min] ? i : min, i++);return min;}
int findmax(int arr[], int n){int max = 0;for(int i = 1; i < n;max = arr[i] > arr[max] ? i : max, i++);return max;}
int arrsum(int arr[], int n){int sum = 0;for(int i = 0; i < n; sum += arr[i], i++);return sum;}
	
int main(){
	long long n, k, min, oncekimin;

	scanf("%lld %lld", &n, &k);

	oncekimin = n;

	while(true){
		oncekimin = n;
		if(n > k){
			min = n % k;
		}

		if(n == k){
			min = 0;
		}

		if(n < k){
			if(k - n <= n){
				min = k - n;
			}
			else{
				min = n;
			}
		}
		n = min;
		if(n >= oncekimin){
			break;
		}
	}

	printf("%lld", oncekimin);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=0;i<=(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
using namespace std;
typedef long long ll;

int main(void) {
	int n;
	int i = 0, j = 0;
	cin >> n;
	REPS(i, n/4) {
		REPS(j, n/7) {
			if (n == 4 * i + 7 * j) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;

	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
    REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

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

vector< vector<int> > Graph;
vector< int > value;









int main(int argc, const char * argv[]) {
    
   
    
    
    int n; cin >> n;
    vector<int> A(n);
    vector<int> B(n);
    rep(i,n) cin >> B[i];
    
    ll ans = 0;
    
    A[0] = B[0];
    A[1] = B[0];
    for (int i = 1; i < n; i++) {
        A[i] = max(A[i-1],B[i-1]);
        if(A[i]>B[i] && i < n-1) A[i] = B[i];
    }
    
    rep(i,n) ans += A[i];
    
    cout << ans << endl;
    


    
    

    
}


Measured memory_bytes: 256
/* AOJ0002 Digit Number */
 
#include <stdio.h>
 
int sum_digits(int n, int base)
{
    int count = 0;
 
    while(n) {
        count++;
        n /= base;
    }
 
    return count;
}
 
int main(void)
{
    int a, b;
 
    while(~scanf("%d%d", &a, &b))
        printf("%d\n", sum_digits(a + b, 10));
 
    return 0;
}



Measured memory_bytes: 2580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main(){
	int N,L;
	cin >> N >> L;
	vector<string> strlist;
	for(int i=0;i<N;i++){
		string S;
		cin >> S;
		strlist.push_back(S);
	}
	sort(strlist.begin(),strlist.end());
	for(const string& s : strlist){
		cout << s;
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
void main() {
	auto N = ri;
	int[] C, S, F;
	foreach(i; 0..N-1) {
		auto ip = readAs!(int[]), c = ip[0], s = ip[1], f = ip[2];
		C ~= c; S ~= s; F ~= f;
	}
	
	foreach(i; 0..N-1) {
		long tmp;
		foreach(j; i..N-1) {
			if(tmp < S[j]) tmp = S[j];
			else if(tmp % F[j] != 0) tmp += F[j] - tmp % F[j];
			tmp += C[j];
			debug writefln("tmp: %d, i: %d, j: %d", tmp, i, j);
		}
		tmp.writeln;
	}
	0.writeln;
}

// ===================================

import std.stdio;
import std.string;
import std.functional;
import std.algorithm;
import std.range;
import std.traits;
import std.math;
import std.container;
import std.bigint;
import std.numeric;
import std.conv;
import std.typecons;
import std.uni;
import std.ascii;
import std.bitmanip;
import core.bitop;

T readAs(T)() if (isBasicType!T) {
	return readln.chomp.to!T;
}
T readAs(T)() if (isArray!T) {
	return readln.split.to!T;
}

T[][] readMatrix(T)(uint height, uint width) if (!isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		res[i] = readAs!(T[]);
	}
	return res;
}

T[][] readMatrix(T)(uint height, uint width) if (isSomeChar!T) {
	auto res = new T[][](height, width);
	foreach(i; 0..height) {
		auto s = rs;
		foreach(j; 0..width) res[i][j] = s[j].to!T;
	}
	return res;
}

int ri() {
	return readAs!int;
}

double rd() {
	return readAs!double;
}

string rs() {
	return readln.chomp;
}


Measured memory_bytes: 380
#include<iostream>
using namespace std;
int main(){
    int a, b, c, conta = 0, contb = 0, contc = 0;
    cin >> a >> b >> c;
    if(a == 5) conta++;
    else contb++;
    if(b == 5) conta++;
    else contb++;
    if(c == 5) conta++;
    else contb++;
    if(conta == 2 && contb == 1) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    ll n, l;
    cin >> n >> l;
    vl a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int idx = -1;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] + a[i + 1] >= l) {
            idx = i;
            break;
        }
    }
    if (idx == -1) {
        cout << "Impossible"
             << "\n";
        return 0;
    }
    idx++;
    vl ret;
    for (int i = 1; i < idx; ++i) {
        ret.push_back(i);
    }
    for (int i = n - 1; i >= idx + 1; --i) {
        ret.push_back(i);
    }
    ret.push_back(idx);
    cout << "Possible"
         << "\n";
    for (auto &r : ret) {
        cout << r << "\n";
    }

    return 0;
}

Measured memory_bytes: 2548
def factorize(n):
    if n < 4:
        return [n]
    res = []
    i = 2
    while i*i <= n:
        while n%i == 0:
            res.append(i)
            n //= i
        i += 1
    if n != 1:
        res.append(n)
    res.sort()
    return res

N = int(input())
f = factorize(N)
print(str(N)+": ", end="")
print(*f)


Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <cstdint>
#include <unordered_set>
typedef long long int llint;

bool same_lst(std::vector<int> a, std::vector<int> b){
  if(a.size() != b.size()) return false;
  
  for(int i=0; i<a.size(); i++){
    if(a[i] != b[i]) return false;
  }
  return true;
}

int main(void){
  int n;
  std::cin >> n;
  std::vector<int> p(n), q(n), ref(n);
  for(int i=0; i<n; i++){
    std::cin >> p[i];
  }
  for(int i=0; i<n; i++){
    std::cin >> q[i];
  }

  for(int i=0; i<n; i++){
    ref[i] = i+1;
  }

  int num_p = -1;
  int num_q = -1;

  int num_ref = 1;
  while(true){
    if(same_lst(p, ref)) num_p = num_ref;
    if(same_lst(q, ref)) num_q = num_ref;

    num_ref++;
    if(!std::next_permutation(ref.begin(), ref.end())) break;
  }

  std::cout << std::abs(num_p-num_q) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int limit = 50;
int n, m;
int a[limit], b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v) {
    visited[v] = true;
    for (int v2 = 0; v2 < n; ++v2) {
        if (graph[v][v2] == false) continue;
        if (visited[v2] == true) continue;
        dfs(v2);
	}
}

int main(void) {
  cin>>n>>m;
  for(int i = 0; i < m; ++i) {
	cin >> a[i] >> b[i];
	a[i]--, b[i]--;
	graph[a[i]][b[i]] = graph[b[i]][a[i]] = true;
  }
  int ans=0;
  for(int i=0;i<m;i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0;j<n;j++) visited[j]=false;
    dfs(0);
    bool bridge=false;
    for(int j=0;j<n;j++) if(visited[j]==false) bridge=true;
    if(bridge) ans+=1;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
    
  }
  cout<<ans<<endl;
  return 0;
}




Measured memory_bytes: 256
def solve(A, B, C, X, Y):
    ans = X * A + B * Y
    ans = min(ans, 2 * C * X + B * max(Y - X, 0))
    ans = min(ans, A * max(X - Y, 0) + 2 * C * Y)
    return ans

if __name__ == "__main__":
    A, B, C, X, Y = tuple(map(int, input().split(" ")))
    print(solve(A, B, C, X, Y))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

const int mod = 1000000007;
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; }
mint fact(int n) {
  if(n == 1 || n == 0) return 1;
  mint res = n;
  return res * fact(n - 1);
}

vl factor(ll n) {
  vl res;
  for(ll i = 2; i * i <= n; i++) {
    if(n % i == 0) {
      res.push_back(i);
      if(i * i != n) res.push_back(n / i);
    }
  }
  return res;
}

int main() {
  ll n, k;
  cin >> n >> k;
  mint ans = k;
  ans = ans.pow(n);
  vector<mint> num(k + 1, mint(0));
  for(int i = k; i >= 2; i--) {
    mint now = k / i;
    num[i] += now.pow(n);
    ans += num[i] * (i - 1);
    vl l = factor(i);
    for(auto v : l) num[v] -= num[i];
  }
  cout << ans << endl;
}

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

int main(){
  long long h; cin >> h;
  int cnt = 0;
  while(h>1){
  	h /= 2;
  	cnt++;
  }
  
  long long ans = 2;
  for(int i = 0; i < cnt; i++) ans *= 2;
  cout << ans-1 << endl;
}

Measured memory_bytes: 256
import sys

a = []
for l in sys.stdin:
    a.append(l)
    
N,D = a[0].split(' ')
N = int(N)
D = int(D)
D = D*D

count = 0
for i in range(1,N+1):
	
	x, y = a[i].split(' ')
	x = int(x)
	y = int(y)
	dist = x*x+y*y
	if dist <= D:
		count = count + 1

print(count)

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

int main() {
  int N, s1, s2, s3, s4;
  cin >> N;
  s1 = N/1000;
  s2 = (N%1000)/100;
  s3 = (N%100)/10;
  s4 = N%10;
  if ((s1 == s2 && s2 == s3)
      || (s2 == s3 && s3 == s4)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}

	for i := 0; i < n-1; i++ {
		if h[i] < h[i+1] {
			h[i+1]--
		}
		if h[i] > h[i+1] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5504
//
// Created by 李青坪 on 2018/11/25.
//

#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>

#define MAXN 10000
#define NIL -1
using namespace std;

int n, e;

class Edge {
public:
    int s;
    int t;
    int w;

    Edge() {}

    Edge(int s, int t, int w) : s(s), t(t), w(w) {}
};

class Compare {
public:
    bool operator()(Edge a, Edge b) {
        return a.w > b.w;
    }
};


class Graph {
public:
    vector<Edge> G[MAXN];
    priority_queue<Edge, vector<Edge>, Compare> q;
    set<int > uSet[MAXN];
    vector<Edge> tree;
    int parent[MAXN];
    int rank[MAXN];

    Graph() {}

    void addEdge(int cur, Edge node) {
        G[cur].push_back(node);
    }

    void makeQueue() {
        vector<Edge>::iterator it;
        for (int i = 0; i < n; ++i) {
            for (it = G[i].begin(); it != G[i].end(); ++it) {
                q.push(*it);
            }
        }
    }

    void makeSet(){
        for (int i = 0; i < n; ++i) {
            uSet[i].insert(i);
            parent[i] = i;
            rank[i] = 0;
        }
    }

    int findSet(int a){
        if (parent[a] != a){
            return findSet(parent[a]);
        }
        return a;
    }

    void unite(int a, int b){
        int r_a = findSet(a);
        int r_b = findSet(b);
        if (r_a == r_b) return;
        if (rank[r_a] > rank[r_b]){
            parent[r_b] = r_a;
        } else{
            parent[r_a] = r_b;
            if (rank[r_a] == r_b){
                rank[r_b]++;
            }
        }
    }

    bool same(int a, int b){
        return findSet(a) == findSet(b);
    }

    void kruskal(){
        while (!q.empty()){
            Edge edge = q.top();
            q.pop();
            if (!same(edge.s, edge.t)){
                unite(edge.s, edge.t);
                tree.push_back(edge);
            }
        }
    }
};


int main() {
    Graph g = Graph();
    scanf("%d %d", &n, &e);
    int s, t, w;
    Edge edge;
    for (int i = 0; i < e; ++i) {
        scanf("%d %d %d", &s, &t, &w);
        edge = Edge(s, t, w);
        g.addEdge(s, edge);
    }
    g.makeQueue();
    g.makeSet();
    g.kruskal();
//    while (!g.q.empty()){
//        Edge edge1 = g.q.top();
//        g.q.pop();
//        printf("%d %d %d\n", edge1.s, edge1.t, edge1.w);
//    }
    int sum = 0;
    vector<Edge>::iterator it;
    for (it = g.tree.begin(); it != g.tree.end(); ++it){
        sum += (*it).w;
//        printf("%d %d %d\n", (*it).s, (*it).t, (*it).w);
    }
    printf("%d\n", sum);
}
/*
4 6
0 1 2
1 2 1
2 3 1
3 0 1
0 2 3
1 3 5
 */


Measured memory_bytes: 6944
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  char grid[51][51];
  memset(grid, '.', sizeof(char) * 51 * 51);

  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      cin >> grid[i][j];
    }
  }

  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (grid[i][j] == '#') continue;

      int n = 0;
      if (grid[i - 1][j - 1] == '#') ++n;
      if (grid[i - 1][j] == '#') ++n;
      if (grid[i - 1][j + 1] == '#') ++n;
      if (grid[i][j + 1] == '#') ++n;
      if (grid[i + 1][j + 1] == '#') ++n;
      if (grid[i + 1][j] == '#') ++n;
      if (grid[i + 1][j - 1] == '#') ++n;
      if (grid[i][j - 1] == '#') ++n;
      grid[i][j] = n;
    }
  }

  for (int i = 1; i <= H; ++i) {
    for (int j = 1; j <= W; ++j) {
      if (grid[i][j] == '#')
        printf("#");
      else
        printf("%d", grid[i][j]);
    }
    printf("\n");
  }

  return 0;
}

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

using namespace std;

int main(){
	//~ freopen("input.txt", "r", stdin);
	//~ freopen("output.txt", "w", stdout);
	int a, b;
	scanf("%d %d", &a, &b);
	for (int i = 0; i <= a; i++){
		int j = a - i;
		if (2 * i + 4 * j == b){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


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

def main():
    int(input())
    l = [int(e) for e in input().split(" ")]
    max_l = max(l)
    s = 0
    once = True
    for e in l:
        if e == max_l and once:
            once = False
            continue
        s += e

    if max_l < s:
        print("Yes")
    else:
        print("No")

main()


Measured memory_bytes: 3060
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
 int r;
 cin >> r;
 if(r < 1200){
     cout << "ABC" << endl;
 }else if(r < 2800){
     cout << "ARC" << endl;
 }else{
     cout << "AGC" << endl;
 }
  return 0;
  }

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

int main() {
  int N,M,s=0;
  cin >>N>>M;
  int a[N];
  for(int i=0;i<M;i++) {
    cin>>a[i];
    s+=a[i];
  }
  if(N>=s)
    cout<<N-s<<endl;
  else
    cout<<-1<<endl;
}
    
  
  
 

Measured memory_bytes: 3676
# D
import math
S = input()
SS = list(S)
index_num_kugiri = [-1]
index_num_soko = []
for i in range(len(SS) - 1):
    if SS[i] == 'L' and SS[i+1] == 'R':
        index_num_kugiri.append(i)
    if SS[i] == 'R' and SS[i+1] == 'L':
        index_num_soko.append(i)
index_num_kugiri.append(len(S)- 1)
ans = []
for k in range(0, len(index_num_soko)):
    if index_num_soko[k] % 2 == index_num_kugiri[k]  % 2:
        tmp1 = math.floor((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    else:
        tmp1 = math.ceil((index_num_kugiri[k+1] - index_num_kugiri[k] ) / 2)
        tmp2 = index_num_kugiri[k+1] - index_num_kugiri[k]  - tmp1
    ans.append([index_num_soko[k], tmp1])
    ans.append([index_num_soko[k], tmp2])
tugi = False
tmp = 0
final_ans = []
for i in range(len(S)):
    if tugi:
        tugi = False
        final_ans.append(ans[tmp][1])
        tmp += 1
        continue
    if i in index_num_soko:
        final_ans.append(ans[tmp][1])
        tmp += 1
        tugi = True
        continue
    else:
        final_ans.append(0)
        
print(' '.join(map(str, final_ans)))

Measured memory_bytes: 68088
#include<map>
#include<iostream>
#include<vector>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};
int main(){
  mint ans=1;
  int i,j,n,res=0;
  map<int,int> s;
  scanf("%d\n",&n);
  for(i=2;i<=n;i++){
    int a=i;
    for(j=2;j*j<=i;j++){
      while(a%j==0){
        res++;
        a=a/j;
      }
      s[j]+=res;
      res=0;
    }
    if(a!=1){
      s[a]+=1;
    }
  }
  for(i=2;i<=n;i++){
    if(s[i]==0){
      continue;
    }
    ans=ans*(s[i]+1);
  }
  printf("%lld\n",ans);
  return 0;
}

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

#define debug(x) cout << #x << " = " << x << endl

const int INF = 1<<29;
typedef long long ll;
typedef pair<int,int> P;


int main(){
   int N;
   cin >> N;
   int A[N];

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

   ll ans = A[0] - 1;
   ll maxValue = 2;

   for(int i=1; i<N; i++){
	  if(A[i] == maxValue){
		 maxValue++;
	  } else if(A[i] < maxValue){
		 continue;
	  } else if(A[i] % maxValue == 0){
		 ans += (A[i] / maxValue) - 1;
	  } else {
		 ans += (A[i] / maxValue);
		 maxValue = max(maxValue,A[i] % maxValue);
	  }
   }
   
   cout << ans << endl;
   
   return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	int N;
	cin >> N;
	cout << "ABC" << N;
}

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

class UnionFindTree
{
    vector<int> parent;
    vector<int> depth;
    vector<int> cnt;

public:
    UnionFindTree(int n) : parent(n), depth(n), cnt(n)
    {
        for (int i = 0; i < n; i++)
        {
            parent[i] = i;
            depth[i] = 0;
            cnt[i] = 1;
        }
    }

    //木の根を求める
    int find(int x)
    {
        if (parent[x] == x)
        {
            return x;
        }
        else
        {
            return parent[x] = find(parent[x]);
        }
    }

    //xとyの属する集合を併合
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (depth[x] < depth[y])
        {
            parent[x] = y;
            cnt[y] += cnt[x];
        }
        else
        {
            parent[y] = x;
            cnt[x] += cnt[y];
            if (depth[x] == depth[y])
                depth[x]++;
        }
    }
    // 同じ集合に属しているか判定
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    // 集合のサイズを取得
    int size(int x)
    {
        return cnt[find(x)];
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    UnionFindTree utree(n + 10);
    for (int i = 0; i < m; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        utree.unite(x, y);
    }
    set<int> s;
    for (int i = 1; i <= n; i++)
    {
        s.insert(utree.find(i));
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 6144
#include <stdio.h>

int main(){
  int r, g, b;
  scanf("%d%d%d", &r, &g, &b);
  if((r*100 + g*10 + b)%4 == 0){
    printf("YES\n");
  }else{
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 128