akhauriyash/Code-Regression huggingface dataset:
//  Created by conan1024hao on 2019/11/19.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e16
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
ll cmp(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//---------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    string s;
    cin>>s;
    int cnt1=0,cnt0=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='1')
            cnt1++;
    }
    cnt0=s.length()-cnt1;
    cout<<2*mmin(cnt0,cnt1)<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------


Measured memory_bytes: 512
#include<stdio.h>

int main()
{
	int check,n,k,s[100],b[100],i,j,x;
	while(1)
	{
		for(i=0;i<100;i++)
			b[i]=0;
		scanf("%d%d",&n,&k);
		if(n==0&&k==0)
			break;
		else
		{
			for(i=0;i<k;i++)
			{
				scanf("%d",&s[i]);
			}
			for(i=0;i<n;i++)
			{
				for(j=0;j<k;j++)
				{
					scanf("%d",&x);
					b[j]=b[j]+x;
				}
			}
			check=0;
			for(i=0;i<k;i++)
			{
				
				if(s[i]<b[i])
				{
					check=1;
					break;
				}
			}
		}
		if(check==0)
			printf("Yes\n");
		else if(check==1)
			printf("No\n");
	}
}

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

#define rep(i, N) for (int i = 0; i < (N); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back

using ll = long long;
using i_i = tuple<int, int>;

bool f(int i, bool left, string& s, vector<char>& t, vector<char>& d) {
    int N = s.length();
    int Q = t.size();
    rep(q, Q) {
        if (s[i] == t[q]) {
            if (d[q] == 'L') i--;
            if (d[q] == 'R') i++;
        }
        if (0 <= i && i < N) continue;
        if (left && i < 0) return false;
        if (!left && i >= N) return false;
        return true;
    }
    return true;
}

int main() {
    int N, Q;
    cin >> N >> Q;
    string s; cin >> s;
    vector<char> t(Q), d(Q);
    rep(q, Q) {
        string T, D;
        cin >> T >> D;
        t[q] = T[0];
        d[q] = D[0];
    }
    int l, r;
    {
        int lb = -1, ub = N;
        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            if (f(mid, true, s, t, d)) ub = mid;
            else lb = mid;
        }
        l = ub;
    }
    {
        int lb = -1, ub = N;
        while (ub - lb > 1) {
            int mid = (lb + ub) / 2;
            if (f(mid, false, s, t, d)) lb = mid;
            else ub = mid;
        }
        r = ub;
    }
    cout << r - l << endl;
}


Measured memory_bytes: 900
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(int argc,char** argv){
  char n[3];
  for(int i = 0; i < 3;i++){
    char tmp;
    cin >> tmp;
    if(tmp == '1'){
      n[i] = '9';
    }else if(tmp == '9'){
      n[i] = '1';
    }else{
      n[i] = tmp;
    }
  }
  cout << n << endl;
  
  return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

using ll = long long;
int main() {
    ll Q, H, S, D;
    ll N;
    cin >> Q >> H >> S >> D >> N;

    S = min({S, H * 2, Q * 4});
    ll ans = 0;
    ll ans1 = S * N;
    ll t;
    t = N / 2;
    ans += t * D;
    N -= t * 2;
    ans += S * N;
    cout << min(ans1, ans) << endl;

    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main()
    {
        var n=int.Parse(Console.ReadLine());
        int[,,] data = new int[4,3,10];   
        for (var i = 1; i <= n; i++)
        {
            var line = Console.ReadLine().Split(' ');
            int b = int.Parse(line[0]);
            int f = int.Parse(line[1]);
            int r = int.Parse(line[2]);
            int v = int.Parse(line[3]);

            data[b-1, f-1, r-1] += v;
        }

        for(var i=0; i<data.GetLength(0); i++)
        {
            if (i != 0)Console.WriteLine("####################");

            for (var j = 0; j < data.GetLength(1); j++)
            {
                for(var k=0; k < data.GetLength(2); k++)
                {
                    Console.Write(" " + data[i, j, k]);
                    if (k == data.GetLength(2) - 1) Console.WriteLine();
                }
            }
        }
    }

}


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

int main() {
  int N, i;
  string S;
  
  cin >> N;
  
  for (i = 0; i < N; i++) {
    cin >> S;
    if (S == "Y") {
      cout << "Four" << endl;
      break;
    }
    if (i == (N-1)) {
      cout << "Three" << endl;
    }
  }
}

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

//#define int long long

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)a, i##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(box) box.begin(), box.end()

using namespace std;

using P = pair<int,int>;
using ll = long long;

const long long INF = LLONG_MAX/3;

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; }

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[b]+=siz[a];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		fac[0] = fac[1] = 1;
    	finv[0] = finv[1] = 1;
    	inv[1] = 1;
    	for (int i = 2; i < MAX; i++){
        	fac[i] = fac[i - 1] * i % MOD;
        	inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        	finv[i] = finv[i - 1] * inv[i] % MOD;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}
template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
vector<vector<BinaryIndexedTree<int>>> b(26,vector<BinaryIndexedTree<int>>(2,500010));
signed main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	rep(i,n){
		int c=s[i]-'a';
		b[c][0].add(i,1);
		b[c][1].add(n-i-1,1);
	}
	int q;
	cin>>q;
	rep(i,q){
		int w;
		cin>>w;
		if(w==1){
			int a;
			char C;
			cin>>a>>C;
			a--;
			int c=C-'a';
			b[s[a]-'a'][0].add(a,-1);
			b[s[a]-'a'][1].add(n-a-1,-1);
			b[c][0].add(a,1);
			b[c][1].add(n-a-1,1);
			s[a]=C;
		}else{
			int l,r;
			cin>>l>>r;
			l--;
			r--;
			int re=0;
			rep(j,26){
				if(b[j][0].sum(r)+b[j][1].sum(n-l-1)-b[j][0].sum(n-1)>0)re++;
			}
			cout<<re<<endl;
		}
	}
}

Measured memory_bytes: 107776
a,b,c,x,y = list(map(int,input().split()))
ans = 0
if a + b >= c*2:
    ans += c * (min(x,y)) * 2
    if x >= y:
        if a > 2*c:
            cost = 2* c
        else:  
            cost = a
        ans += cost* (x-y)
    else:
        if b > 2*c:
            cost = 2*c
        else:
            cost = b
        ans += cost * (y-x)
    
else:
  ans = x*a + y*b
  
print(ans)

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

using namespace std;

#define rep(i, n) for(int64 i = 0; i < (int64)(n); i++)

using int64 = long long;
const int64 INF = 1LL << 60;

int main()
{
  int N, A[100000], B[100000];

  cin >> N;
  rep(i, N) cin >> A[i] >> B[i];

  cout << B[max_element(A, A + N) - A] + *max_element(A, A + N) << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <queue>
using namespace std;
int main(){
  string s;
  while(cin>>s,s[0]!='-'){
    int n,i,b;
    queue<char>a;
    for(i=0;i<s.size();i++)a.push(s[i]);
    cin>>n;
    while(n--){
      cin>>b;
      while(b--){
	a.push(a.front());
	a.pop();
      }
    }
    while(!a.empty()){
      cout<<a.front();
      a.pop();
    }
    cout<<endl;
  }
}


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

int main(){
  int ans=0;
  string s;cin>>s;
  REP(i,s.size()) if(s.at(i)=='?') s.at(i)='D';
  cout<<s<<endl;
}

Measured memory_bytes: 3752
#include<bits/stdc++.h>
using namespace std;
int gcd(int a, int b);
int main(){
    int n; cin >> n;
    int ans; cin >> ans;
    for(int i = 1; i < n; i++){
        int a; cin >> a;
        if(ans > a) ans = gcd(ans, a);
        else ans = gcd(a,ans);
    }
    cout << ans << endl;
}

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

Measured memory_bytes: 256
import java.util.*;
class Main{
 
  public static void main(String[]args){
    
       
Scanner s=new Scanner(System.in);

int n=s.nextInt();
int arr[]=new int[n+1];
for(int i=1;i<=n;i++) {
	arr[i]=s.nextInt();
}

System.out.println(frog1(n,arr));
  }
  
  public static int frog1(int n,int arr[]) {
	 
	 int dp[]=new int[n+1];
	 dp[1]=0;
	 dp[2]=Math.abs(arr[2]-arr[1]);
	 for(int i=3;i<=n;i++) {
		 int option1=Math.abs(arr[i]-arr[i-2])+dp[i-2];
		 int option2=Math.abs(arr[i]-arr[i-1])+dp[i-1];
		 dp[i]=Math.min(option1,option2);
		 }
	 return dp[n];
	 
 }
  
}
 
  
  
  
  
  
  


Measured memory_bytes: 49320
import math
import copy
import sys
import fractions
# import numpy as np
# import statistics
import decimal
import heapq
import collections
import itertools
import bisect


# from operator import mul

# sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputIntList():
    outputDataList = []
    inputData = input().split()
    outputDataList = [int(n) for n in inputData]

    return outputDataList


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) - 1 for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

n = int(input())

data = getSomeInputListInt(n)

ans = [[] for _ in range(n)]

edge = []
for d in data:
    edge.append(d[2:])


def dfs(i, cnt):
    if len(ans[i]) > 0:
        return cnt

    cnt += 1

    ans[i].append(cnt)
    for j in range(len(edge[i])):
        cnt = dfs(edge[i][j], cnt)

    cnt += 1
    ans[i].append(cnt)

    return cnt

tmp = 0
for i in range(n):
    tmp = dfs(i, tmp)

for i in range(n):
    print(i + 1, *ans[i], sep=" ")



Measured memory_bytes: 7104
#include <iostream>
#include <queue>
#include <vector>
#include <limits>
#define INF (1e17)
using namespace std;
template <typename T, bool directed>//directedは考えるグラフが有向グラフかどうかをもつ
class Dinic
{
public:
    Dinic(int n) : n(n), capacity(n, vector<T>(n)), edges(n), redges(n) {}
    void add_edge(int src, int dst, T cap)
    {
        capacity[src][dst] = cap;
        capacity[dst][src] = directed ? 0 : cap;
        edges[src].push_back(dst);
        redges[dst].push_back(src);
        if (!directed)
        {
            edges[dst].push_back(src);
            redges[src].push_back(dst);
        }
    }
    
    T max_flow(int s, int t)
    {
        T flow = 0;
        while (bfs(s, t))
        {
            start.assign(n, 0);
            flow += dfs(t, s, numeric_limits<T>::max());
        }
        return flow;
    }
    
private:
    int n;
    vector<int> level, start;
    vector<vector<T>> capacity, edges, redges;
    bool bfs(int s, int t)
    {
        level.assign(n, -1);
        queue<int> que;
        level[s] = 0;
        que.push(s);
        while (!que.empty())
        {
            int v = que.front();
            que.pop();
            for (int nv : edges[v])
                if (capacity[v][nv] > 0 && level[nv] < 0)
                {
                    level[nv] = level[v] + 1;
                    que.push(nv);
                }
        }
        return level[t] != -1;
    }
    
    T dfs(int v, int s, T limit)
    {
        if (v == s)
            return limit;
        
        T res = 0;
        for (int &i = start[v]; i < (int)redges[v].size(); ++i)
        {
            int nv = redges[v][i];
            if (capacity[nv][v] > 0 && level[v] == level[nv] + 1)
            {
                T d = dfs(nv, s, min(limit, capacity[nv][v]));
                if (d > 0)
                {
                    capacity[nv][v] -= d;
                    capacity[v][nv] += d;
                    res += d;
                    limit -= d;
                    if (limit == 0)
                        break;
                }
            }
        }
        return res;
    }
};

int main()
{
    int h,w;
    cin>>h>>w;
    vector<string> a(h);
    int sx,sy,tx,ty;
    for(int i = 0; i<h; i++){
      cin>>a[i];
    }
    Dinic<long long, false> dn(h + w + 2);
    for(int i = 0; i<h; i++){
      for(int j = 0; j<w; j++){
        if(a[i][j] == '.'){
          continue;
        }
        if(a[i][j] == 'o'){
          dn.add_edge(i, h+j, 1);
          continue;
        }
        if(a[i][j] == 'S'){
          sx = i;
          sy = j;
          dn.add_edge(i, h+j, 1);
          dn.add_edge(h+w, i, INF);
          dn.add_edge(h+w, h+j, INF);
          continue;
        }
        if(a[i][j] == 'T'){
          tx = i;
          ty = j;
          dn.add_edge(i, h+j, 1);
          dn.add_edge(h+w+1, i, INF);
          dn.add_edge(h+w+1, h+j, INF);
          continue;
        }
      }
    }
    if(sx == tx || sy == ty){
      cout<<-1<<endl;
      return 0;
    }
    cout << dn.max_flow(h+w, h+w+1) << endl;
    return 0;
}


Measured memory_bytes: 1024
N = int(input())

for i in range(1, int(N**0.5) + 1):
    x=0
    divisors = []
    if N % i == 0:
        divisors.append(i)
        if i != N // i:
            divisors.append(N // i)
        xi = max(divisors)
        if len(str(x))<=len(str(xi)):
            ans=len(str(xi))
print(ans)

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

int main(){
    LL a;
    float b;
    scanf("%lld%f",&a,&b);
    b=b*100;
    b=round(b); /* 1. b is still floating 2.Can use round(b) also*/
    // cout<<b<<"\n";
    int b_=b;
    LL ans=a*b_;
    ans/=100;
    printf("%lld",ans);
}
// 9899901000000100

Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <utility>
#include <algorithm>
#include <cmath>
#include <climits>
#include <iomanip>
#include <queue>
#include <stack>

using namespace std;

typedef long long ll;

int main() {
    ll k;
    cin >> k;
    ll a = 7;
    for (int i = 0; i <= k; i++) {
        if (a % k == 0) {
            cout << i+1 << endl;
            return 0;
        }
        a = (a*10+7)%k;
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
typedef vector<vector<P>> vvP;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 200010;

// aのn乗を求める。計算量はO(logn)
ll modpow(ll a, ll n) {
    if(n == 0) {
        return 1;
    }
    if(n%2 == 1) {
        return (a * modpow(a, n-1))%mod;
    }
    return (modpow(a, n/2) * modpow(a, n/2))%mod;
}

ll inverse(ll a) {
    return modpow(a, mod-2);
}

ll inv[MAX_N];  // inv[i] : iの逆数のmod
ll fact[MAX_N];  // fact[i] : iの階乗のmod
ll invfact[MAX_N];

void init() {
    inv[0] = fact[0] = invfact[0] = 1;
    inv[1] = 1;
    for(ll i = 1; i < MAX_N; i++) {
        if(i >= 2) {
            inv[i] = mod - inv[mod%i]*(mod/i)%mod;
        }
        fact[i] = (i*fact[i-1])%mod;
        invfact[i] = inverse(fact[i]);
    }
}
 
ll Comb(ll n, ll r) {
    if(r < 0 || n <= 0 || n < r) {
        return 0;
    }
    ll res = fact[n];
    res = (res * invfact[r])%mod;
    res = (res * invfact[n-r])%mod;
    return res;
}

//--- main関数でinit()を呼び出すのを忘れるな ---//
int main() {
    ll n;
    cin >> n;

    vl a(n+1);
    vl v(n+1);  // v[i] : aにiが現れる回数
    ll l, r;
    ll u;
    rep(i, n+1) {
        cin >> a[i];
        v[a[i]]++;
        if(v[a[i]] == 2) {
            r = i;
            u = a[i];
        }
    }

    rep(i, n) {
        if(a[i] == u) {
            l = i;
            break;
        }
    }

    init();

    exrep(k, 1, n+1) {
        if(k == 1) {
            out(n);
        }
        else if(k == n+1) {
            out(1);
        }
        else {
            ll ans = mod + Comb(n+1, k) - Comb(n-r+l, k-1);
            ans %= mod;
            out(ans);
        }
    }

    re0;
}

Measured memory_bytes: 7424
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

#define DEBUG(x) cout << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<pair<T, T> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

	std::ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	string num;
	cin >> num;

	for (int i = 0; i < num.size(); ++i) {
		if (num[i] - '0' == 7) {
			cout << "Yes\n";
			return 0;
		}
	}

	cout << "No\n";

	return 0;

}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
#define Test int t;cin>>t;while(t--)
#define PI acos(-1)
#define endl "\n"
#define fx(x) fixed<<setprecision(x)
#define sz(s) (int)s.size()
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define mem(a,n) memset((a),n,sizeof (a))
const double eps=1e-9;
const int mod=1e9+7;
int dx[]={-1,-1,-1,0,0,1,1,1};
int dy[]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll x,ll y) {return(!y)?x:gcd(y,x%y);}
ll lcm(ll x,ll y) {return((x/gcd(x,y))*y);}
using namespace std;
void fast(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
vector<vector<int> >v;
int n,m;
int dp[100001];
int solve(int x){
    if(!sz(v[x]))return 0;
    int &ret=dp[x];
    if(~ret)return ret;
    ret=0;
    for(int i=0;i<sz(v[x]);i++){
        ret=max(ret,1+solve(v[x][i]));
    }
    return ret;
}
int main()
{
    mem(dp,-1);
    cin>>n>>m;
    v.resize(n+1);
    int x,y;
    while(m--){
        cin>>x>>y;
        v[x].push_back(y);
    }
    int mx=0;
    for(int i=1;i<=n;i++){
        mx=max(mx,solve(i));
    }
    cout<<mx;
    return 0;
}


Measured memory_bytes: 11144
#include<iostream>
#include<string>
#include<algorithm>
#include<bits/stdc++.h>
#include<vector>
 
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  if(B%A==0) cout << A+B << endl;
  else cout << B-A << endl;
}

Measured memory_bytes: 256
def resolve():
    A,B,C = map(int,input().split())
    count = 0
    if A == C and A == B:
        if A % 2 == 1:
            print(0)
        else:
            print(-1)
    else:
        while (A % 2 == 0 and B % 2 == 0 and C % 2 == 0):
            tmpA = (B + C) / 2 
            tmpB = (A + C) / 2 
            tmpC = (A + B) / 2
            A = tmpA
            B = tmpB
            C = tmpC
            count = count + 1
        print(count)
resolve()

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>
int a,b;
int main(){
	scanf("%d%d",&a,&b);
	for(int i=0;i<=10000;i++){
		double x=i;
		double min=floor(x*0.08);
		double max=floor(x*0.1);
		if(min==a&&max==b){
			printf("%d",i);
			return 0;
		}
	}
	printf("-1");
}

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

int main(){
  char c[101];
  while(cin.getline(c, sizeof(c))&&c[0]!='.'){
    char a[101];
    int j=0;
    for(int i=0;i<102;i++){
      if(c[i]=='('||c[i]==')'||c[i]=='['||c[i]==']'){
        a[j]=c[i];
        if((a[j-1]=='('&&a[j]==')')||(a[j-1]=='['&&a[j]==']')){
          a[j-1] = '\0';
          a[j] = '\0';
          j--;
        }else{
          j++;
        }
      }
    }

    //  cout << a << endl;
    if(j==0) cout << "yes" << endl;
    else cout << "no" << endl;
    // initialize
    for(int i=0;i<102;i++){
      a[i] = '\0';
      c[i] = '\0';
    }
  }

  return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
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};

int main() {
  string s;
  cin >> s;
  reverse(all(s));
  s.push_back('0');
  ll n = s.size();
  vector<vl> dp(n + 1, vl(2, 1e18));
  dp[0][0] = 0;
  rep(i, n) rep(j, 2) rep(k, 10) {
    if(dp[i][j] == 1e18) continue;
    ll d = s[i] - '0';
    ll r = k - d - j;
    ll nj = r < 0;
    if(r < 0) r += 10;
    dp[i + 1][nj] = min(dp[i + 1][nj], dp[i][j] + k + r);
  }
  cout << dp[n][0] << endl;
}

Measured memory_bytes: 58876
import java.util.Scanner;

public class Main {

  /*
     input: 3 8 1
     output: 1 3 8
  */
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int[] array = new int[3];
    for (int i = 0; i < 3; i++) {
      array[i] = scan.nextInt();
    }

    for (int i = 0; i < array.length; i++) {
      for (int j = 0; j < array.length-1-i; j++) {
        if (array[j] > array[j + 1]) {
          int temp = array[j];
          array[j] = array[j + 1];
          array[j + 1] = temp;
        }
      }
    }
    System.out.printf("%d %d %d\n", array[0], array[1], array[2]);
  }
}


Measured memory_bytes: 26436
#include <iostream>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
using ll = long long;

using namespace std;



int main() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int ans = n;
    rep(i,n) {
        if(h[i]<k) ans--;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll dp[6570][100][100];

int main(){
    ll H,W,A[100][100],B[100][100];
    cin >> H >> W;
    Rep(i,1,H+1){
        Rep(j,1,W+1){
            cin >> A[i][j];
        }
    }
    Rep(i,1,H+1){
        Rep(j,1,W+1){
            cin >> B[i][j];
        }
    }
    dp[0][1][0]=1;
    dp[0][0][1]=1;
    Rep(i,1,H+1){
        Rep(j,1,W+1){
            ll C=abs(A[i][j]-B[i][j]);
            rep(k,6401){
                dp[k][i][j]=max(dp[abs(k-C)][i-1][j],dp[k][i][j]);
                dp[k][i][j]=max(dp[abs(k-C)][i][j-1],dp[k][i][j]);
                dp[k][i][j]=max(dp[k][i][j],dp[C+k][i-1][j]);
                dp[k][i][j]=max(dp[k][i][j],dp[C+k][i][j-1]);
            }
        }
    }
    ll T;
    rRep(i,6401,0){
        if(dp[i][H][W]){
            T = i;
        }
    }
    cout << T << endl;
}


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

int main() {
  int n;
  cin >> n;
  
  rep(i,n) {
  	string color;
  	cin >> color;
  	if (color == "Y") {
    	cout << "Four" << endl;
    	break;
    }
    if (i == n-1) {
    	cout << "Three" << endl;
    }
  }
}


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


int main() {
	long long n;
	cin >> n;
	long long max;
	long long a[10000], b[10000];
	max = sqrt(n);
	int t = 0;
	for (int i = 1; i <= max; i++) {
		if (n%i == 0) {
			a[t] = i;
			b[t] = n / i;
			t++;
		}
	}
	long long ans = 0;
	for (int i = 0; i < t; i++) {
		if (a[i] < b[i] - 1) {
			long long m;
			m = b[i] - 1;
			ans = ans + m;
		}
	}
	cout << ans << endl;

	
	return 0;
}

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

using namespace std;

#define ll long long
#define pb push_back
#define F first
#define S second
#define rf(i,a,b) for(int (i) = (a); (i) <= (b); (i)++)
#define rb(i,b,a) for(int (i) = (b); (i) >= (a); (i)--)
#define watch(x) cout << (#x) << " = " << (x) << endl
#define test(t) int(testCnt) = 0; int(t); cin >> (t); while(t -- && ++testCnt)

const int INF = 2e9 + 7;
const int MAXA = 3e3 + 10;
const ll MOD = (ll) 1e9 + 7;
const ll INFLL = 9e18 + 7;

typedef pair<int, int> ii;
typedef pair<ii, int> II;
typedef vector<int> vi;
typedef vector<ii> vii;

string s, t;
vector<char> ans;
int n,m, f[MAXA][MAXA];
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
      //freopen("in.in", "r", stdin);
    #endif
    cin >> s >> t;
    n = s.length();
    m = t.length();
    s = '%' + s;
    t = '%' + t;
    rf(i,1,n) {
        rf(j,1,m) {
            if(s[i] == t[j]) f[i][j] = f[i - 1][j - 1] + 1;
            else f[i][j] = max(f[i - 1][j], f[i][j - 1]);
        }
    }
    int i = n, j = m;
    while (i && j) {
        while(i && f[i][j] == f[i - 1][j]) i--;
        while(j && f[i][j] == f[i][j - 1]) j--;
        //cout << i << " " << j << endl;
        if(i <= 0 || j <= 0) break;
        ans.pb(s[i]);
        i --;
        j --;
    }
    if(ans.size() == 0) cout <<" ";
    else
    rb(i, ans.size() - 1, 0) cout << ans[i];
    return 0;
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define uptil(a, b, i) for(int i = (a), b_ = (b); i < b_; ++i)
#define upto(a, b, i) for(int i = (a), b_ = (b); i <= b_; ++i)
#define downtil(a, b, i) for(int i = (a), b_ = (b); i > b_; --i)
#define downto(a, b, i) for(int i = (a), b_ = (b); i >= b_; --i)
#define times(n, i) uptil(0, n, i)
#define rtimes(n, i) downto((n)-1, 0, i)

#define sp <<" "
#define ln <<"\n"
#define size(v) ((int)(v).size())
template<class T> using vec=vector<T>;
template<class T> using vvec=vec<vector<T>>;

void solve() {
  map<char, int> s;
  times(4, i) {
    char c; cin >> c; ++s[c];
  }
  for(auto i : s) {
    if(i.second != 2) {
      cout << "No" ln;
      goto next_case;
    }
  }

  cout << "Yes" ln;
  next_case:;
}

signed main() {
  // cin.tie(0);
  cout << fixed << setprecision(20);
  cerr << fixed << setprecision(10);
  solve();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define trav(a,x) for(auto &a:x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<"@"<<__LINE__<<": "<<x<<endl
using ll = long long;
using vi = vector<int>;
using pii = pair<int,int>;

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

    // vector<bool> test(2*n);
    // rep(i,0,n) test[i] = true;
    // random_shuffle(all(test));
    
    // auto querytest = [&](vi &a) {
    //     assert(sz(a)==n);
    //     vector<bool> seen(2*n);
    //     int cnt = 0;
    //     for(int x:a) {
    //         assert(!seen[x]);
    //         seen[x] = true;
    //         if(test[x]) ++cnt;
    //     }
    //     return cnt>n-cnt;
    // };
    
    auto query = [&](vi &a) {
        assert(sz(a)==n);
        cout<<"? ";
        for(int x:a) cout<<x+1<<" ";
        cout<<endl;
        string response;
        cin >> response;
        assert(response!="-1");
        if(response=="Red") return true;
        else {
            assert(response=="Blue");
            return false;
        }
    };
    
    vi common, a(n), b(n);
    rep(i,0,n) {
        a[i] = i;
        b[i] = n+i;
    }
    if(!query(a)) swap(a,b);
    while(sz(common)<n-1) {
        int k = sz(a);
        // debug(sz(common));
        // debug(k);
        assert(sz(b)==k);
        assert(k>1);
        int j = k/2;
        vi bq(j), aq(k-j);
        rep(i,0,j) bq[i]=b[i];
        rep(i,j,k) aq[i-j]=a[i];
        vi combined = common;
        for(int x:bq) combined.push_back(x);
        for(int x:aq) combined.push_back(x);
        // for(int y:combined) debug(y);
        if(query(combined)) {
            for(int x:bq) common.push_back(x);
            vi bb(k-j);
            rep(i,j,k) bb[i-j] = b[i];
            a = aq;
            b = bb;
        }
        else {
            for(int x:aq) common.push_back(x);
            vi aa(j);
            rep(i,0,j) aa[i] = a[i];
            a = aa;
            b = bq;
        }
    }
    // for(int x:common) debug(x);
    // debug(a[0]);
    // debug(b[0]);
    vector<bool> ans(2*n);
    assert(sz(a)==1 && sz(b)==1 && sz(common)==n-1);
    vector<bool> marked(2*n);
    for(int i:common) marked[i]=true;
    marked[a[0]]=true;
    marked[b[0]]=true;
    ans[a[0]]=true;
    ans[b[0]]=false;
    vi opp;
    rep(i,0,2*n) if(!marked[i]) opp.push_back(i);
    assert(sz(opp)==n-1);
    rep(i,0,2*n) if(i!=a[0] && i!=b[0]) {
        if(!marked[i]) {
            common.push_back(i);
            ans[i] = query(common);
            common.pop_back();
        }
        else {
            opp.push_back(i);
            ans[i] = query(opp);
            opp.pop_back();
        }
    }
    cout<<"! ";
    rep(i,0,2*n) {
        if(ans[i]) cout<<"R";
        else cout<<"B";
    }
    cout<<endl;
    // cout<<"! ";
    // rep(i,0,2*n) {
    //     if(test[i]) cout<<"R";
    //     else cout<<"B";
    // }
    // cout<<endl;
    // assert(ans==test);
}


Measured memory_bytes: 724
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
long long  mod = 1000000007;

int H, W;
char S[2010][2010];
int main()
{
	int U[2010][2010] = { 0 };
	int D[2010][2010] = { 0 };
	int R[2010][2010] = { 0 };
	int L[2010][2010] = { 0 };
	cin >> H >> W;
	for (int i = 0; i < H; i++) {
		cin >> S[i];
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (j == 0) {
				if (S[i][j] == '#') {
					L[i][j] = 0;
				}
				else if (S[i][j] == '.') {
					L[i][j] = 1;
				}
			}
			else {
				if (S[i][j] == '#') {
					L[i][j] = 0;
				}
				else if (S[i][j] == '.') {
					L[i][j] = L[i][j - 1] + 1;
				}
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = W - 1; j >= 0; j--) {
			if (j == W - 1) {
				if (S[i][j] == '#') {
					R[i][j] = 0;
				}
				else if (S[i][j] == '.') {
					R[i][j] = 1;
				}
			}
			else {
				if (S[i][j] == '#') {
					R[i][j] = 0;
				}
				else if (S[i][j] == '.') {
					R[i][j] = R[i][j + 1] + 1;
				}
			}
		}
	}
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			if (j == 0) {
				if (S[j][i] == '#') {
					U[j][i] = 0;
				}
				else if (S[j][i] == '.') {
					U[j][i] = 1;
				}
			}
			else {
				if (S[j][i] == '#') {
					U[j][i] = 0;
				}
				else if (S[j][i] == '.') {
					U[j][i] = U[j - 1][i] + 1;
				}
			}
		}
	}
	for (int i = 0; i < W; i++) {
		for (int j = H - 1; j >= 0; j--) {
			if (j == H - 1) {
				if (S[j][i] == '#') {
					D[j][i] = 0;
				}
				else if (S[j][i] == '.') {
					D[j][i] = 1;
				}
			}
			else {
				if (S[j][i] == '#') {
					D[j][i] = 0;
				}
				else if (S[j][i] == '.') {
					D[j][i] = D[j + 1][i] + 1;
				}
			}
		}
	}
	int max = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (U[i][j] + D[i][j] + R[i][j] + L[i][j] > max) {
				max = U[i][j] + D[i][j] + R[i][j] + L[i][j];
			}
		}
	}
	cout << max - 3 << endl;
}

Measured memory_bytes: 67328
import java.util.*;
import java.lang.Math;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
  		
      	int n = sc.nextInt();
      	int m = sc.nextInt();
      	List acList = new ArrayList<String>();
      	boolean  acs[] = new boolean[n];
      	int was[] = new int[n];
      	int istack;
      	String sstack;
      	String sstack2;
      	int ac = 0;
      	int wa = 0;
      
      	Arrays.fill(acs,false);
      	Arrays.fill(was,0);
      	
      	for(int i = 0;i < m;i++){
        	istack = sc.nextInt() - 1;
          	sstack = sc.next();
          	if(sstack.equals("AC") && !acs[istack]){
              ac++;
              acs[istack] = true;
              wa += was[istack];
            } else was[istack]++;
        }
      
        System.out.print(ac + " ");
      	System.out.println(wa);
             	
        
	}
}


Measured memory_bytes: 60012
#include<bits/stdc++.h>
using namespace std;
#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, a, b) for(int i=a; i<b; i++)
#define ALL(v) v.begin(),v.end()
#define pb push_back
#define eb emplace_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

int n;
ll dp[11][11];

int digit(int x) {
    int ans = 0;
    while (x != 0) {
        x /= 10;
        ans++;
    }
    return ans;
}

int head(int x) {
    int p = pow(10, digit(x)-1);
    return x / p;
}

int tail(int x) {
    return x % 10;
}

int main() {
    cin >> n;
    for (int i = 1; i <= n; i++) {
        dp[head(i)][tail(i)]++;
    }

    ll ans = 0;
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            if (i == j) {
                ans += dp[i][j] * dp[i][j];
            } else {
                ans += dp[i][j] * dp[j][i];
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
pub fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

pub fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

pub fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

pub fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let x: u32 = read();

    let gohyaku = x / 500;
    let go = (x % 500) / 5;
    println!("{}", gohyaku * 1000 + go * 5);
}


Measured memory_bytes: 4352
#include <iostream>
#include <cmath>
#include <cstdio>
#include <string>
#include <numeric>
using namespace std;
#define INF 1 << 29

#define elif else if
#define read cin >>
#define echo cout <<
#define fin << '\n'
#define endl '\n'

int sum;

int main(){
	int n;
	read n;
	for ( int i = 0; i < n; i++ ) {
		int a; read a;
		sum += a;
	}
	echo sum - n fin;
	
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T> &p){ cout << "[" << p.first << ", " << p.second << "]"; return os; }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) { for(const auto &e : xs) cout << e << " "; cout << "\n"; }
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")
#define Return(expr) { Cout(expr); return 0; }
#define vc vector
#define Mini(a, x) a = min(a, x)
#define Maxi(a, x) a = max(a, x)

// constexpr int MOD = 1e9+7;
#include <unordered_set>

unordered_map<int, int> factors(ll n){
    unordered_map<int, int> d;
    for(int i = 2; (ll)i*i <= n; i ++) while(n % i == 0) d[i] ++, n /= i;
    if(n > 1) d[n] ++;
    return d;
}

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    
    auto pc = [&](){
        unordered_set<int> ps;
        For(i, n){
            auto ds = factors(a[i]);
            for(auto [d, _] : ds){
                if(ps.count(d) > 0) return false;
                ps.insert(d);
            }
        }
        return true;
    };
    auto sc = [&](){
        ll d = a[0];
        For(i, n) d = gcd(d, a[i]);
        return d == 1;
    };
    
    Cout(pc() ? "pairwise coprime" : sc() ? "setwise coprime" : "not coprime");
}


Measured memory_bytes: 7152
#include<stdio.h>
int main(void){
    int n;

    for(scanf("%d",&n);n>0;n--){
        char a[8],w;
        int b[8],s[8],i,j,f;
        scanf("%s",a);

        for(i=0;i<7;i++){
            for(j=i+1;j<8;j++){
                if(a[i]<a[j]){
                    w=a[i];
                    a[i]=a[j];
                    a[j]=w;
                }
            }
        }
        for(i=0;i<8;i++){
            b[i]=a[i]-'0';
        }
        for(i=0;i<8;i++){
            s[i]=b[7-i];
        }

        for(i=7;i>=0;i--){
            b[i]-=s[i];
            if(b[i]<0){
                b[i]+=10;
                b[i-1]--;
            }
        }
        f=0;
        for(i=0;i<8;i++){
            if(b[i]==0){
                if(f==0)continue;
                else printf("%d",b[i]);
            }
            else {
                f=1;
                printf("%d",b[i]);
            }
        }
        if(f==0)printf("%d",0);
        puts("");
    }
    return 0;
}

Measured memory_bytes: 608
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int K = sc.nextInt();
	int S = sc.nextInt();
	int cnt = 0;
	for(int i = 0; i<=K; i++) {
	    for(int j = 0; j<=K; j++) {
		if((S - i - j >= 0) && (S - i - j <= K )) cnt++;
	    }
	}
	System.out.println(cnt);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod

int solve(int l, int r, int al, int ar, vec &A){
    if(r == l + 1) return al * A[l] + ar * A[r];
    int m = INF;
    FOR(k, l + 1, r) Min(m, solve(l, k, al, al + ar, A) + solve(k, r, al + ar, ar, A) - (al + ar) * A[k]);
    return m;
}


vec A;
signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;
    int ans = solve(0, N - 1, 1, 1, A);
    Out(ans);

    return 0;
}


Measured memory_bytes: 384
def main():
  n = int(input())
  lst = list(map(int, input().split()))
  
  a = lst.copy()
  a.sort()
  t = 0
  for i in range(n):
    if (lst[i] != a[i]) == True:
      t += 1
  
  if t ==2 or t == 0:
    print("YES")
  else:
    print("NO")
main()

Measured memory_bytes: 3060
import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	private static final int BIG_NUM  = 2000000000;
	private static final int MOD  = 1000000007;

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		PriorityQueue<Integer> Q = new PriorityQueue<Integer>(1,Collections.reverseOrder());

		String order;
		StringBuilder ans = new StringBuilder();
		int value;

		while(true){

			order = scanner.next();

			if(order.equals("end")){
				break;
			}else if(order.equals("insert")){
				value = scanner.nextInt();
				Q.add(value);
			}else{ //extract
				ans.append(Integer.toString(Q.peek())).append("\n");
				Q.remove();
			}
		}
		System.out.printf(ans.toString());
	}
}





Measured memory_bytes: 481904
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include<math.h>
#include<map>
#include<set>
using namespace std;
#define INF 11000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;

int num[110000];

int main(){
  string a,b;
  cin>>a>>b;

  if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}


Measured memory_bytes: 888
package main

import (
	"bufio"
	"fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func ri() (n int) {
	sc.Scan()
	b := sc.Bytes()
	if b[0] == 45 {
		return -b2i(b[1:])
	} else {
		return b2i(b)
	}
}

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func b2i(a []byte) (n int) {
	for _, v := range a {
		n = n*10 + int(v-48)
	}
	return
}

func sum(a []int) (x int) {
	for _, i := range a {
		x += i
	}
	return
}

func main() {
	sc.Split(bufio.ScanWords)
	n := ri()

	a := make([]int, n)
	minAbs := int(1e10)
	for i := 0; i < n; i++ {
		a[i] = ri()

		if x := abs(a[i]); x < minAbs {
			minAbs = x
		}
	}

	for i := 0; i <= n-2; i++ {
		if a[i] < 0 {
			a[i] *= -1
			a[i+1] *= -1
		}
	}

	if a[n-1] < 0 {
		fmt.Println(sum(a) + abs(a[n-1])*2 - minAbs*2)
	} else {
		fmt.Println(sum(a))
	}
}


Measured memory_bytes: 1408