akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))


vector<int> makePrimeLst(int N)
{
    vector<int> ans;
    vector<int> alive(N+1, 1);
    lint now = 2;
    for (; now * now <= N; now++)
    {
        if (alive[now]) ans.push_back(now);
        for (int t = now; t <= N; t += now) alive[t] = 0;
    }
    for (; now <= N; now++) if (alive[now]) ans.push_back(now);
    return ans;
}
map<lint, int> primeFactorize(lint N, const vector<int> &primeLst)
{
    map<lint, int> ans;
    for (auto v : primeLst)
    {
        while (!(N % v))
        {
            N /= v;
            ans[v]++;
        }
        if (N == 1) return ans;
    }
    ans[N]++;
    return ans;
    // exit(1);
}

int main()
{
    int N;
    cin >> N;
    vector<lint> a(N + 1);
    cin >> a;

    vector<int> primes = makePrimeLst(100000);

    set<lint> ret;
    lint gcd = abs(a[0]);
    for (auto v : a) if (v) gcd = __gcd(gcd, abs(v));
    map<lint, int> pr1 = primeFactorize(gcd, primes);
    for (auto pa : pr1) ret.insert(pa.first);

    for (auto p : primes) if (p <= N)
    {
        vector<lint> b = a;
        REP(i, N) if (i + p - 1 < N)
        {
            (b[i + p - 1] += b[i]) %= p;
            b[i] = 0;
        }
        bool flg = true;
        for (auto v : b) if (abs(v) % p) flg = false;
        if (flg) ret.insert(p);
    }
    for_each(ALL(ret), [](lint v) { cout << v << endl; });
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) throws IOException
	{
		StreamTokenizer sc=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
		PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
		ArrayList<Integer> list=new ArrayList<Integer>();
		sc.nextToken();
		int n=(int) sc.nval;
		data str[]=new data[n];
		for(int i=0;i<n;i++)
		{
			str[i]=new data();
			sc.nextToken();
			str[i].a=(int)sc.nval;
			str[i].b=i+1;
		}
		Arrays.sort(str,new Comparator<data>()
				{
				public int compare(data a,data b)
				{
					if(a.a<b.a)
						return -1;
					else
						return 1;
				}
				});
		for(int i=0;i<n;i++)
			out.print(str[i].b+" ");
		out.flush();
	}

}
class data
{
	int a,b;
}


Measured memory_bytes: 44412
#include <bits/stdc++.h>
using namespace std;
#define ll                  long long
#define ld                  long double
#define pb                  push_back
#define mkp                 make_pair
#define f(i,l,h)            for(ll i=l;i<h;i++)
#define fr(i,h,l)           for(ll i=h;i>=l;i--)
#define mem(a,val)          memset(a,val,sizeof(a))
#define all(v)              (v).begin(),(v).end()
#define ff                  first
#define ss                  second
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
const ld pi=3.14159265359;
const ll mod=998244353;
const ll INF=(ll)(1e9+7);
typedef pair<ll,ll> pll;
typedef vector<ll> vll;

ll power(ll a,ll b){
	ll res=1;
	while(b){
		if(b&1) res=(res*a);
		a=(a*a);
		b>>=1;
	}
	return res;
}

int main()
{
    //cout << "Hello world!" << endl;
    ll t;
    t=1ll;
    while(t--){
        string s;
        cin>>s;
        cout<<s.substr(0,3)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3624
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

string getAstring(string s) {
    string res = "";
    for (int i = 0; i < s.length(); i++) {
        if (s[i] == '?') res += "a";
        else res += s[i];
    }
    return res;
}

bool check(string s, string t, int k) {
    for (int i = 0; i < t.length(); i++) {
        if (s[k + i] != '?' && s[k + i] != t[i]) return false;
    }
    return true;
}

int main() {

    string S, T;
    cin >> S >> T;
    
    for (int i = S.length() - T.length(); i >= 0; i--) {
        if (check(S, T, i)) {
            string answer = "";
            answer += getAstring(S.substr(0, i));
            answer += T;
            if (i < S.length() - T.length()) answer += getAstring(S.substr(i + T.length()));
            cout << answer << endl;
            return 0;
        }
    }

    cout << "UNRESTORABLE" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n, m, x; cin >> n >> m >> x;
  int sm = 0, bg = 0;
  for(int i = 0; i < m; i++){
    int v; cin >> v;
    if(v < x) sm++;
    else bg++;
  }
  cout << min(sm, bg) << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace _1147
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0)
                {
                    break;
                }
                int[] s = new int[n];
                for (int i = 0; i < n; i++)
                {
                    s[i] = int.Parse(Console.ReadLine());
                }
                Array.Sort(s);
                int x = s.Sum() - s[0] - s[n - 1];
                x = x / (n - 2);
                Console.WriteLine(x);
            }
        }
    }
}

Measured memory_bytes: 9604
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=sum(B[0:A[1]])
D=C
for i in range(A[1]-1,A[0]-1):
  D=D+B[i+1]-B[i-A[1]+1]
  C=max(C,D)
print((C+A[1])/2)




Measured memory_bytes: 71792
#include <iostream>
#include <vector>
using namespace std;
 
#define MAXN 100020
#define pb push_back
#define MOD 1000000007
 
int N;
vector<int> e[MAXN];
long long dp[MAXN][2];
bool vis[MAXN];
 
void dfs(int n) {
  vis[n] = true;
  if (e[n].size() == 1 && n != 0) {
    dp[n][0] = 1;
    dp[n][1] = 1;
    return;
  }
  dp[n][0] = dp[n][1] = 1;
  for (int i = 0; i < e[n].size(); i++) {
    if (!vis[e[n][i]]) {
      dfs(e[n][i]);
      dp[n][0] = (dp[n][0]*((dp[e[n][i]][0]+dp[e[n][i]][1])%MOD))%MOD;
    dp[n][1] = (dp[n][1]*dp[e[n][i]][0])%MOD;
    }
  }
}
 
int main() {
  cin >> N;
  for (int i = 0; i < N-1; i++) {
    int x,y; cin >> x >> y;
    x--; y--; 
    e[x].pb(y);
    e[y].pb(x);
  }
  dfs(0);
  cout << (dp[0][0]+dp[0][1])%MOD << endl;
}

Measured memory_bytes: 11520
#include "bits/stdc++.h"
using namespace std;

//level（入れ子レベル）、op=0...足し算、1...掛け算
string s[50];
int ind=0;
int calc(int level,int op)
{
	int ret=0;
	if(op==1)
		ret=1;
	//終了条件
	while(s[ind].size()>level)
	{
		//opだった場合
		if(s[ind][level]=='+')
		{
			ind++;
			if(op==0)
				ret+=calc(level+1,0);
			else
				ret*=calc(level+1,0);
		}else if(s[ind][level]=='*'){
			ind++;
			if(op==0)
				ret+=calc(level+1,1);
			else
				ret*=calc(level+1,1);
		}else{
			int num=s[ind][level]-'0';
			if(op==0)
				ret+=num;
			else
				ret*=num;
			ind++;
		}
	}
	return ret;
}

int main()
{
	while(1)
	{
		int n;
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<50;i++)
			s[i].clear();
		for(int i=0;i<n;i++)
			cin>>s[i];
		//最初の行を見る
		ind=1;
		if(s[0][0]=='+')
			cout<<calc(1,0)<<endl;
		else if(s[0][0]=='*')
			cout<<calc(1,1)<<endl;
		else
			cout<<(int)(s[0][0]-'0')<<endl;
	}
	return 0;
}


Measured memory_bytes: 3208
def make_divisors(n):
    divisors = set()
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.add(i)
            if i != n // i:
                divisors.add(n//i)
    return divisors

N,M = (int(x) for x in input().split())
S = list(input())
T = list(input())
if M > N:
    N,M = M,N
    S,T = T,S
dn = make_divisors(N)
dm = make_divisors(M)
dnm = dn & dm
if dnm == {1}:
    if S[0] == T[0]:
        print(N*M)
    else:
        print('-1')
else:
    gcd = max(dnm)
    n = N // gcd
    m = M // gcd
    for i in range(N//n):
        if S[n*i] != T[m*i]:
            print('-1')
            break
    else:
        print(N*M//gcd)

Measured memory_bytes: 4548
n=int(input())
arr=list(map(int,input().split()))
arr=sorted(arr)
pos=[0]*24
pos[0]=1
flag=0
for val in arr:
  if flag==0:
    pos[val]+=1
    flag=1
  else:
    pos[(24-val)%24]+=1
    flag=0
ans=10**10
for i in range(24):
  if pos[i]>=2:
    ans=0
    break
  elif pos[i]==1:
    for j in range(1,24):
      if pos[(i+j)%24]>=1:
        ans=min(ans,j)
        break
  else:
    continue    
print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"

#define ll long long
#define ull unsigned long long
#define ld long double

#define tiii tuple < int, int, int >
#define pii pair < int, int >
#define pll pair < ll, ll >
#define pci pair < char, int >
#define psi pair < string, int >
#define pis pair < int, string >

#define vi vector < int >
#define vd vector < double >
#define vld vector < ld >
#define vll vector < ll >
#define vs vector < string >
#define vc vector < char >
#define vpi vector < pii >
#define vpll vector < pll >
#define vpis vector < pis >

#define pb push_back
#define mt make_tuple
#define gt0 get < 0 >
#define gt1 get < 1 >
#define gt2 get < 2 >

#define pi acos(-1)

#define fast ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

const int maxn = 1e5 + 5;
const int mod = 1e9 + 9;

ll a[maxn], f[maxn];

int main()
{
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    fast;

    int n, k = 2;

    cin >> n;

    for(int i = 1; i <= n; i++) cin >> a[i];

    f[n] = 0;

    for(int i = n - 1; i > 0; i--){
        f[i] = 1e18;

        for(int j = 1; j <= k; j++){
            if(i + j > n) continue;

            f[i] = min(f[i], f[i + j] + abs(a[i] - a[i + j]));
        }
    }

    cout << f[1] << endl;

    return 0;
}


Measured memory_bytes: 5200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    vi G[N];
    rep(i,N-1){
        int a,b; cin >> a >> b;
        a--; b--;
        G[a].eb(b);
        G[b].eb(a);
    }
    int A[N]; 
    rep(i,N) cin >> A[i];
    int vis[N]; 
    rep(i,N) vis[i]=0;
    int sum=0;
    int pos=0;
    sort(A,A+N,greater<int>());
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int a = q.front(); q.pop();
        vis[a]=A[pos];
        if(a!=0)sum+=A[pos];
        pos++;
        for(auto t:G[a]){
            if(vis[t]>0) continue;
            q.push(t);
        }
    }
    cout << sum << endl;
    rep(i,N) {
        cout << vis[i] << " ";
    }
    cout << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

ll mod(ll x){
	return x%MOD;
}

//a,b x
int main(){
	string s; cin>>s;
	vector<vector<ll>> dp(s.sz,vector<ll>(4,0));
	if(s[0]=='A'){
		dp[0][0]=1;//カウントしない
		dp[0][1]=1;//する
	}
	else if(s[0]=='?'){
		dp[0][0]=3;
		dp[0][1]=1;
	}
	else dp[0][0]=1;

	rep1(i,s.sz-1){
		if(s[i]=='A'){
			dp[i][1]=dp[i-1][0];//する
			dp[i][3]=dp[i-1][3];
			dp[i][2]=dp[i-1][2];
			dp[i][1]+=dp[i-1][1];
			dp[i][0]=dp[i-1][0];

			dp[i][1]=mod(dp[i][1]);
		}else if(s[i]=='B'){
			dp[i][2]=dp[i-1][1];//する
			dp[i][3]=dp[i-1][3];
			dp[i][2]+=dp[i-1][2];
			dp[i][1]=dp[i-1][1];
			dp[i][0]=dp[i-1][0];

			dp[i][2]=mod(dp[i][2]);
		}else if(s[i]=='C'){
			dp[i][3]=dp[i-1][2];//する
			dp[i][3]+=dp[i-1][3];
			dp[i][2]=dp[i-1][2];
			dp[i][1]=dp[i-1][1];
			dp[i][0]=dp[i-1][0];

			dp[i][3]=mod(dp[i][3]);
		}
		else{
			dp[i][3]=dp[i-1][2];
			dp[i][2]=dp[i-1][1];
			dp[i][1]=dp[i-1][0];

			dp[i][3]+=mod(dp[i-1][3]*3);
			dp[i][2]+=mod(dp[i-1][2]*3);
			dp[i][1]+=mod(dp[i-1][1]*3);
			dp[i][0]+=mod(dp[i-1][0]*3);

			dp[i][3]=mod(dp[i][3]);
			dp[i][2]=mod(dp[i][2]);
			dp[i][1]=mod(dp[i][1]);
			dp[i][0]=mod(dp[i][0]);
		}
	}
	cout<<dp[s.sz-1][3];
}


Measured memory_bytes: 7424
# -- coding utf-8 --
import itertools
from operator import itemgetter
N=int(input())
X=[]
L=[]
MIN=[]
MAX=[]
for i in range(N):
    x,l=map(int,input().split())
    X.append(x)
    L.append(l)
    MIN.append(x-l)
    MAX.append(x+l)
    #print(x,l)

MIN_MAX_LIST = list(zip(MIN, MAX))
#print(MIN_MAX_LIST)
#MIN_MAX_LIST.sort()
#print(MIN_MAX_LIST)

MIN_MAX_LIST_SORTED  = sorted(MIN_MAX_LIST, key=itemgetter(1))
#print(MIN_MAX_LIST_SORTED)
# [(1, 3), (3, 5), (5, 7), (7, 9), (9, 11)]
count=0
previous_MAX = -1000000000
for j in range(N):
    #print(MIN_MAX_LIST_SORTED[j][1])
    if previous_MAX <= MIN_MAX_LIST_SORTED[j][0]:
        count += 1
        previous_MAX = MIN_MAX_LIST_SORTED[j][1]
print(count)

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

using namespace std;
using ld = long double;
#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

constexpr int INF = 1e9 + 9;

void run() {
    int n;
    cin >> n;
    vector<int> a(n * 2);
    for (int i = 0; i < n * 2; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    int ans = 0;
    for (int i = 0; i < n * 2; i += 2) {
        ans += a[i];
    }
    cout << ans << '\n';
}

signed main() {
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#else
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#endif
    int t = 1;
   // cin >> t;
    while (t--)
        run();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i <= 100; i += 4) {
            int ans = i;
            for (int j = 0; j <= 100; j += 7) {
                ans += j;
                if (ans == n) {
                    System.out.println("Yes");
                    return;
                }
            }
        }
        System.out.println("No");
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=1,c=9,z=0;
  cin>>a;
  for(int i=0;i<3;i++){
    if(a%10==9){
      z+=b;
      a/=10;
      b*=10;
      c*=10;
    }else{
      z+=c;
      a/=10;
      b*=10;
      c*=10;
    }
  }
  cout<<z<<"\n";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	char str[4];
	unsigned char weather = 0;
	scanf("%s", str);
	for (int i=0; i<3; i++) {
		weather |= ((str[i]=='S')?0:1)<<i;
	}
	int output;
	switch (weather)
	{
	case 0:
		output = 0;
		break;
	case 1:
		output = 1;
		break;
	case 2:
		output = 1;
		break;
	case 3:
		output = 2;
		break;
	case 4:
		output = 1;
		break;
	case 5:
		output = 1;
		break;
	case 6:
		output = 2;
		break;
	case 7:
	default:
		output = 3;
		break;
	}
	printf("%d\n", output);
	return 0;
}

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

int main () {

    int N;
    cin >> N;

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

    sort(p, p + N);

    int ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += p[i];
    }

    ans += (p[N-1] / 2);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let n = get!(usize);
    println!("{}", 180*n-360);
}


Measured memory_bytes: 8572
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N,sigma = 0;
  cin >> N;
  int A[N+2];
  A[0] = 0;
  A[N+1] = 0;
  vector<int> ans;
  for(int i = 1;i <= N;i++){
    cin >> A[i];
    sigma += abs(A[i] - A[i - 1]);
  }
  sigma += abs(A[N]);
  for(int i = 1;i <= N;i++){
    ans.push_back(abs(A[i+1]-A[i]) + abs(A[i] - A[i-1]) - abs(A[i+1] - A[i-1]));
  }
  for(int i = 0;i < ans.size();i++)cout << sigma - ans[i] << endl;
}


Measured memory_bytes: 2168
#include <iostream>
#include <complex>
#include <cmath>
#include <iomanip>
using namespace std;

int main(void)
{
    double a, b, c;
    double s, l, h;
    cin >> a >> b >> c;
    s = 0.5 * a * b * sin(c / 180 * M_PI);
    l = a + b + sqrt(pow(a, 2.0) + pow(b, 2.0) - 2 * a * b * cos(c/180*M_PI));
    h = b * sin(c * M_PI / 180);
    cout << fixed << setprecision(10);
    cout << s << endl;
    cout << l << endl;
    cout << h << endl;
    return 0;
}



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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int m, d;
    cin >> m >> d;
    int ans = 0;
    FOR (i, 1, m + 1) {
      FOR (j, 22, d + 1) {
        if (j % 10 <= 1) continue;
        int tmp = j;
        int d1 = tmp % 10;
        int d10 = tmp / 10;
        if (d1 * d10 == i) {
          ans++;
        }
      }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)
func scanInt() int {
	sc.Scan()
	a,_ := strconv.Atoi(sc.Text())
	return a
}

func scanText() string {
	sc.Scan()
	return sc.Text()
}

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

func main() {
	sc.Split(bufio.ScanWords)
	
	a := scanInt()
	b := scanInt()

	c := int64(abs(a+b))

	if c%2 == 1 {
		fmt.Println("IMPOSSIBLE")
	} else {
		fmt.Println(c/2)
	}
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define ll          long long int
#define pb          push_back
#define pll         pair<ll,ll>
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod         998244353
#define mode        1000000007
#define inf         1000000000000000000LL
#define vl          vector<ll>
#define F           first
#define S           second
#define db          long double
#define sz(x)       (ll)x.size()
#define fix(n)      cout<<fixed<<setprecision(n)
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define all(x)      x.begin(),x.end()
#define mset(x)     memset(x,0,sizeof x)
#define pi          3.14159265358979323

const int N = 1e5+5;
ll n,a[N];

void solve()
{
       cin>>n;
       rep(i,1,n+1) cin>>a[i];
       sort(a+1,a+1+n);
       ll ans=n;
       ll l=1;
       for(ll i=1; i<n; i++)
       {
              if(2*a[i]>=a[i+1])
              {
                     l++;
                     a[i+1]+=a[i];
              }
              else
              {
                     ans-=l;
                     l=1;
                     a[i+1]+=a[i];
              }
       }
       cout<<ans;
}


int main()
{
    speed_up
    ll T=1;
    //cin>>T;
    while(T--)
        solve();
    return 0;
}


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

int main()
{

    int n;
    cin>>n;
    int a[n+5];
    for(int i=0; i<n; i++)
        cin>>a[i];
    //sort(a,a+n);
    int cnt=0;
    for(int i=0; i<n; i++)
    {
        for(int j=i+1; j<n; j++)
        {
            for(int k=j+1; k<n; k++)
            {
                if ( a[i] + a[j] > a[k] && a[i] + a[k] > a[j] && a[k] + a[j] > a[i] && a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k])
                    cnt++;
            }

        }
    }

    cout<<cnt<<endl;

}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};
const ll dx[9]={0,-1,0,1,1,-1,1,-1,0};
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;
}
int main(){
    ll n;cin >> n;
    map<ll,ll> mp;
    vl v(n);rep(i,n)cin >> v[i],mp[v[i]]++;
    sort(all(v));
    vector<bool> dp(1000010,true);
    ll res=0;
    rep(i,n){
        if(dp[v[i]]){
            if(mp[v[i]]==1)res++;
            ll t=v[i];
            while(t<1000010){
                dp[t]=false;
                t+=v[i];
            }
        }
    }
    cout << res <<endl;
} 

Measured memory_bytes: 17320
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
const int INF=0x7fffffff;
int N,A[1005],P[1005],i,r,l,m,a,t;
char S[15000],*p;

int ch(int n)
{
	int i;
	for(i=1;i<=N;i++)if(P[i])A[i]=n;
	for(i=1;i<=N;i++)
	{
		if(i%2)
		{
			if(A[i]<A[i-1]&&A[i]<A[i+1])continue;
			else if(P[i])return 1;//too big
			return -1;//too small
		}
		else
		{
			if(A[i]>A[i-1]&&A[i]>A[i+1])continue;
			else if(P[i])return -1;//too small
			return 1;//too big
		}
	}
		return 0;//correct
}

int main()
{
	for(;scanf("%d\n",&N),N;)
	{
		gets(S);
		memset(P,0,sizeof(P));
		for(i=0;i<=N+1;i++)A[i]=i%2?-INF:INF;
		p=strtok(S," ");
		i=1;
		do
		{
			if(strcmp(p,"x")!=0)
				A[i]=atoi(p);
			else P[i]=1;
			i++;
		}while((p=strtok(NULL," "))!=NULL);
		for(l=-1000000500,r=1000000500,a=INF;l<=r;)
		{
			m=(l+r)/2;
			t=ch(m);
			if(t==0){a=m;break;}
			else if(t==-1)l=m+1;
			else if(t==1)r=m-1;
		}
		if(a==INF)puts("none");
		else
		{
			if(ch(a+1)!=0&&ch(a-1)!=0)printf("%d\n",a);
			else puts("ambiguous");
		}
	}
	return 0;
}

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif


template <typename T>
struct ReRooting {
  private:
    using F = function<T(T,int)>;
    using H = function<T(T,T)>;
    int n;
    const vector<vector<int> > G;
    vector<vector<T> > dp;
    vector<T> ans;
    //dp_v = g(combine(f(dp_u1,u1), f(dp_u2,u2), ..., f(dp_uk,uk)) , v)
    const F f;
    const H combine;
    const T NE; //neutral of combine
    const F g;

    T dfs1(int v, int p = -1) {
      T res = NE;
      dp[v].assign(G[v].size(), NE);
      for (int i = 0; i < (int)G[v].size(); ++i) {
        int to = G[v][i];
        if (to == p) continue;
        dp[v][i] = dfs1(to, v);
        res = combine(res, f(dp[v][i], to));
      }
      return g(res,v);
    }
    void dfs2(int v, const T& add, int p = -1) {
      int m = G[v].size();
      for (int i = 0; i < m; ++i){
        if (G[v][i] == p) dp[v][i] = add;
      }
      vector<T> dp_l(G[v].size()+1,NE), dp_r(G[v].size()+1,NE); //累積combine
      for (int i = 0; i < m; ++i) {
        dp_l[i+1] = combine(dp_l[i], f(dp[v][i], G[v][i]));
      }
      for (int i = G[v].size(); i > 0; --i) {
        dp_r[i-1] = combine(dp_r[i], f(dp[v][i-1], G[v][i-1]));
      }
      ans[v] = g(dp_l[m], v); //頂点vの答え
      for (int i = 0; i < m; ++i) {
        int to = G[v][i];
        if (to == p) continue;
        dfs2(to, g(combine(dp_l[i], dp_r[i+1]), v), v);
      }
    }
  public:
    ReRooting(const vector<vector<int> >& G, const F &f, const H &combine, T ne, F g=[](T a, int b){ return a;}):
    G(G),f(f),combine(combine),NE(ne),g(g) {
      n = G.size();
      dp.resize(n);
      ans.assign(n,NE);
    }
    void build(int root = 0) {
      dfs1(root);
      dfs2(root, NE);
    }
    T operator[](const int &v) const{
      assert(v < n);
      return ans[v];
    }
};

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n,m;
  cin >> n >> m;
  auto f = [&](ll a, int v){ return (a+1) % m;};
  auto combine = [&](ll a, ll b){ return (a*b) % m;};
  vector<vector<int> > G(n);
  rep(i,n-1) {
    int x,y;
    cin >> x >> y;
    x--; y--;
    G[x].emplace_back(y);
    G[y].emplace_back(x);
  }
  ReRooting<ll> dp(G, f, combine, 1);
  dp.build();
  rep(i,n) cout << dp[i] % m << "\n";
  return 0;
}

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

#define ll long long
const int mod = 1e9 + 7;


int n;
int dp[1<<22];
int mat[25][25];


ll int kil(int idx, int mask)
{
  if(idx == n)
  {
    if( __builtin_popcount(mask) == n)
      return 1;
    return 0;
  }

  if(dp[mask] != -1)
    return dp[mask];

  dp[mask] = 0;
  for(int j=0;j<n;j++)
  {
    if(mat[idx][j] &&  (mask & (1<<j)) == 0)
      dp[mask] = (dp[mask] + kil(idx+1, mask | (1<<j))) % mod;
  }

  return dp[mask];
}

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

  memset(dp, -1, sizeof dp);
  cin>>n;
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      cin>>mat[i][j];

  cout<<kil(0, 0)<<endl;

  return 0;
}


Measured memory_bytes: 20004
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;





int main()
{
    int n, m;
    cin >> n >> m;
    vector<int>a(n), b(n);
    for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
    
    ll t = 999999999999;

    vector<ll>dp(m + 1005, -t);
    dp[0] = 0;

    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= m; j++) {
            dp[j + b[i]] = max(dp[j + b[i]], dp[j] + a[i]);
        }
    }
    ll an = 0;
    for (int i = 0; i <= m; i++)an = max(an, dp[i]);
    cout << an << endl;
   

    return 0;

}


Measured memory_bytes: 3180
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <utility>
#include <limits>
#include <list>
#include <type_traits>

/* template start */
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()

#ifdef LOCAL
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  if(sizeof...(t)>0)std::cout<<" :";
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}

template<typename Num>
constexpr Num mypow(Num a, long long b) {
  if(b==0)return 1;
  if (a==0)return 0;
  Num x = 1;
  while (b > 0) {
    if(b & 1)x*=a;
    a*=a;
    b >>= 1;
  }
  return x;
}

/* template end */

using ll = long long;

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

  ll a;
  std::cin>>a;

  std::cout<<a+a*a+a*a*a<<"\n";

  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
    string s;
    cin >> s;
    if (s.length() == 3) {
        string s2 = "";
        for (int i = 2; i >= 0; i--) {
            s2 += s[i];
        }
        cout << s2 << endl;
    } else {
        cout << s << endl;
    }
    
    return 0;
}

Measured memory_bytes: 384
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
typedef pair<LL, LL> P;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
constexpr long long MMOD = 500000004;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)      (x).begin(),(x).end()
# define UNIQ(c)     (c).erase(unique(ALL((c))), end((c)))
# define mp          make_pair
# define eb          emplace_back
# define FOR(i,a,b)  for(int i=(a);i<(b);i++)
# define RFOR(i,a,b) for(int i=(a);i>=(b);i--)
# define REP(i,n)    FOR(i,0,n)
# define INIT        std::ios::sync_with_stdio(false);std::cin.tie(0)

int al, bo, a[101010], n;

int main() {
	cin >> n;
	REP(i, n)cin >> a[i];
	sort(a, a + n);
	reverse(a, a + n);
	REP(i, n) {
		if (i % 2 == 0)al += a[i];
		else bo += a[i];
	}
	cout << al - bo << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair< ll , string > P;

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

	cin>>a>>b>>c;

	if(a==b==c){
		cout<<"No";
	}
	else if(((a==b)&&(b!=c))||((b==c)&&(c!=a))||((c==a)&&(a!=b))){
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}

}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
const double PI = 3.1415926535897932;   // acos(-1)
const double EPS = 1e-15;
const int INF = 1001001001;
const ll mod = 1e+9 + 7;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

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

    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; ++i)  cin >> a[i];
    ll res = 0;
    for(int i = 0; i < n; ++i){
        while(a[i] % 2 == 0){
            ++res;
            a[i] /= 2;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
r, g, b = gets().chomp.split(' ').map(&:to_i)
k = gets().chomp.to_i

count = 0
while count < k do
    if b <= r || b <= g
        b *= 2
    elsif g <= r
        g *= 2
    end
    count += 1
end

if b > g && g > r
    puts 'Yes'
else
    puts 'No'
end

Measured memory_bytes: 14328
#include <iostream>
#include <fstream>
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <numeric>
#include <functional>
#include <string> 
#include <vector>
#include <bitset>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>

using namespace std;
using ll = long long;

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;

#define REP(i,n) for(int i = 0; i < int(n); i++)
#define FOR(i, m, n) for(int i = int(m);i < int(n);i++)
#define ALL(obj) (obj).begin(),(obj).end()

const ll MOD = (ll)1e9 + 7;
const ll HINF = (ll)1e18;
const ll LINF = (ll)1e9;
const long double PI = 3.1415926535897932384626433;

template<class T> void corner(bool flg, T hoge) {
	if (flg) {
		cout << hoge << endl;
		exit(0);
	}
	else return;
}

template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {
	o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;
}

template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {
	o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;
}

template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {
	o << "{" << obj.first << ", " << obj.second << "}"; return o;
}

template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {
	o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;
}

void print(void) {
	cout << endl;
}

template <class Head> void print(Head&& head) {
	cout << head;
	print();
}

template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {
	cout << head << " ";
	print(forward<Tail>(tail)...);
}

void YN(bool flg) {
	cout << ((flg) ? "YES" : "NO") << endl;
}

void Yn(bool flg) {
	cout << ((flg) ? "Yes" : "No") << endl;
}

void yn(bool flg) {
	cout << ((flg) ? "yes" : "no") << endl;
}

//Greatest Common Divisor
long long GCD(long long a, long long b) {
	return ((b == 0) ? a : GCD(b, a % b));
}

int main() {
	int N; cin >> N;
	ll X; cin >> X;
	V<ll> x(N);
	REP(i, N) cin >> x[i];
	REP(i, N) x[i] = abs(x[i] - X);
	ll ans = x[0];
	REP(i, N) ans = GCD(ans, x[i]);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <stdio.h>
#include <limits.h>
#define MAX 100

int matrix[MAX][MAX];
int A[MAX];
int len;

void MatrixOrder(void){
  int a,b,i,j,k,n;
  n=len;

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

  for(k=2;k<=n;k++){
    for(i=1;i<=n-k+1;i++){
      a=i+k-1;
      //matrix[i][a]=INT_MAX
      matrix[i][a]=2147483647;
      for(j=i;j<=a-1;j++){
	b=matrix[i][j]+matrix[j+1][a]+A[i-1]*A[j]*A[a];
	if(matrix[i][a]>b) matrix[i][a]=b;
	   }
      }
    }
  }


int main(){
  int a,i;
  scanf("%d",&len);

  for(i=1;i<=len;i++){
    scanf("%d%d",&a,&A[i]);
    if(i==1){
      A[0]=a;
    }
  }


  MatrixOrder();

  printf("%d\n",matrix[1][len]);
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main()
{
	int a,b,c,d,e,f;
    scanf("%d %d %d",&a,&b,&c);
    d=a+b;
    e=a+c;
    f=b+c;
    if(d<e&&d<f)
    {
    	printf("%d",d);
    }
    else if(e<d&&e<f)
    {
    	printf("%d",e);
    }
    else if(d==e&&d==f)
    {
    	printf("%d",d);
    }
    else
    {
    	printf("%d",f);
    }
    return 0;
    
}

Measured memory_bytes: 128
"use strict"
let fs = require('fs');
let input = fs.readFileSync("/dev/stdin", "utf8").split(/\s/);

const myMin = (a: number, b: number) => a < b ? a : b;
let blocks = input[0];
let red = 0, blue = 0;

for(let i=0; i<blocks.length; i++) {
  blocks[i] === '0' ? red++ : blue++;
}

console.log( 2 * myMin(red, blue) );


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

typedef long long int ll;

int main () {
    int n;
    string s;
    cin >> n >> s;
    ll ans = 0;
    for (int i = 0; i + 2 < (int)s.size(); i++) {
        if (s.substr(i, 3) == "ABC") {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
// C.

#include <iostream>
#include <algorithm>
#include <vector>
#include <sstream>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char *argv[])
{
	int N, L, prev;
	cin >> N >> L >> prev;
	for (int i = 1; i < N; ++i) {
		int a;
		cin >> a;
		if (prev + a >= L) {
			cout << "Possible" << endl;
			for (int j = 0; j < i - 1; ++j) {
				cout << (j + 1) << endl;
			}
			for (int j = N - 2; j >= i; --j) {
				cout << (j + 1) << endl;
			}
			cout << i << endl;
			return 0;
		}
		prev = a;
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 896
def main():
    # a = [int(a) for a in input().split()]
    # print(234)
    a = int(input())

    ki = 0
    for i in range(1, a + 1):
        if i % 2 == 1:
            ki += 1
    print(ki / a)


if __name__ == "__main__":
    main()


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

const int MAXN = 100000;
int n, sum;
int a[MAXN+2];

signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  for (int i = 0; i <= n; i++)
    sum += abs(a[i+1] - a[i]);
  for (int i = 1; i <= n; i++)
    cout << sum - abs(a[i] - a[i-1]) - abs(a[i+1] - a[i]) + abs(a[i+1] - a[i-1]) << "\n";
}


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

typedef long long int ll;

int main()
{
    ll x, ans = 0;
    cin >> x;
    ll money = 100;
    while(x > money){
        money = money * 1.01;
        ans++;
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <utility>
#include <map>

#include <stdio.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
#define irep(i, k, n) for (int i = (k); i < (n); i++)
#define rrep(i, k, n) for (int i = (k); i >= (n); i--)
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define vec vector

typedef long long ll;

const ll inf = 1LL << 60;
const int mod = 1e9 + 7;

using namespace std;

/* Input variables. */
int n;
vec<ll> a;

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

/* Solve! */
void solve() {
  ll res = 0;
  vec<ll> l(n + 1, 0), r(n + 1, 0);
  rep(i, n) l[i + 1] = gcd(l[i], a[i]);
  rrep(i, n - 1, 0) r[i] = gcd(r[i + 1], a[i]);
  rep(i, n) {
    res = max(res, gcd(l[i], r[i + 1]));
  }
  cout << res << endl;
}

int main() {
  /* Input handling. */
  cin >> n;
  a = vec<ll>(n);
  rep(i, n) cin >> a[i];

  solve();
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ULL;
typedef long long LL;
#define FOR(i, a, b) for(LL i=(LL)(a);i<(LL)(b);i++)
#define REP(i,x) for(LL i=0;i<(LL)(x);i++)

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(10);
    int n;
    cin >> n;
    vector<int> v_a;
    bool app_flag = true;
    for(int i=0; i<n; i++)
    {
        int temp;
        cin >> temp;
        if(temp % 2 == 0)
        {
            if(temp % 3 != 0 && temp % 5 != 0)
            {
                app_flag = false;
            }
        }
    }
    if(app_flag == true)
    {
        cout << "APPROVED" << endl;
    }
    else
    {
        cout << "DENIED" << endl;
    }
    return 0;
}

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


int calc(vector<int> c){
  int counter = 0;
  
  while(prev_permutation(c.begin(), c.end())){
    counter++;
  }
  
  return counter;
}

int main(){
  int n;
  int i;

  cin >> n;
  
  vector<int> a(n), b(n);
  for(i = 0; i < n; i++){
    cin >> a.at(i);
  }
  for(i = 0; i < n; i++){
    cin >> b.at(i);
  }

  
  int n1 = calc(a);
  int n2 = calc(b);
  
  cout << abs(n1-n2) << endl;

}



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

class MainClass : Scanner
{
    static void Main()
    {
        var (N, M, X) = ReadTuple<int,int,int>();
        var A = RInts();

        int suml = 0;
        int sumr = 0;
        for (int i = 0; i < M; i++)
        {
            if (A[i] < X) suml++;
            else sumr++;
        }
        WriteLine(Min(suml,sumr));
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 27512