akhauriyash/Code-Regression huggingface dataset:
<?php
fscanf(STDIN,"%d",$n);
$pow=1;
for($i=1;$i<=$n;$i++){
  $pow=($pow*$i)%(10**9+7);
 // echo $pow."\n";
}

echo $pow."\n";
//echo ($pow%(10**9+7))."\n";

Measured memory_bytes: 4728
#include<iostream>
#include<map>
#include<algorithm>
#define line cout<<"here - "<<__LINE__<<"\n";
#define dbg(a) cout<<#a<<" --> "<<(a)<<"\n";
using namespace std;
main()
{
    int a,i;
    cin>>a;
    int aa[a];
    for(i=0;i<a;i++)
        cin>>aa[i];
    sort(aa,aa+a);
    int s=0;
    long long  ans=0;
    for(i=a-1;i>=0;i--)
    {
        if(i==a-1)
        {
            ans+=aa[i];
            s++;
        }
        else
        {
            if(s+2<=a-1)
            ans+=(aa[i]*2);
            else ans+=aa[i];
            s+=2;
        }
        if(s>=a-1)
            break;
    }
    cout<<ans<<endl;

}




Measured memory_bytes: 4356
#include <iostream>
#include <string>
using namespace std ; 
int main ()
{
	string s;
	cin>>s;
	if(s=="SAT")
		cout<<"1";
	else if ( s=="SUN")
		cout<<"7";
	else if ( s=="MON")
		cout<<"6";
	else if ( s=="TUE")
		cout<<"5";
	else if ( s=="WED")
		cout<<"4";
	else if ( s=="THU")
		cout<<"3";
	else if ( s=="FRI")
		cout<<"2";
	return 0;
	
}

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

int main()
{
    int N;
    cin >> N;
    int ans = 0;
    queue<int> que;
    que.push(3);
    que.push(5);
    que.push(7);
    while (que.front() <= 1000000000)
    {
        que.push(10 * que.front() + 3);
        que.push(10 * que.front() + 5);
        que.push(10 * que.front() + 7);
        if (que.front() > N)
        {
            que.pop();
            continue;
        }
        bool three = false;
        bool five = false;
        bool seven = false;
        while (que.front() > 0)
        {
            int rem = que.front() % 10;
            if (rem == 3)
            {
                three = true;
            }
            else if (rem == 5)
            {
                five = true;
            }
            else
            {
                seven = true;
            }
            que.front() /= 10;
        }
        if (three && five && seven)
        {
            ans++;
        }
        que.pop();
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
package main

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

var cnt int

// 割り当て
func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Scan()
	n, _ := strconv.Atoi(sc.Text())
	A := make([]int, n)
	for i := 0; i < n; i++ {
		sc.Scan()
		A[i], _ = strconv.Atoi(sc.Text())
	}

	sorted := mergeSort(A)
	fmt.Println(strings.Trim(fmt.Sprint(sorted), "[]"))
	fmt.Println(cnt)
}

// Runs mergeSort algorithm on a slice single
func mergeSort(slice []int) []int {
	if len(slice) <= 1 {
		return slice
	}
	mid := len(slice) / 2
	left := mergeSort(slice[:mid])
	right := mergeSort(slice[mid:])
	return merge(left, right)
}

// Merges left and right slice into newly created slice
func merge(left, right []int) []int {
	size, k, j := len(left)+len(right), 0, 0
	tmp := make([]int, size)

	for i := 0; i < size; i++ {
		if len(left) <= j {
			tmp[i] = right[k]
			k++
		} else if len(right) <= k {
			tmp[i] = left[j]
			j++
		} else if right[k] < left[j] {
			tmp[i] = right[k]
			k++
		} else {
			tmp[i] = left[j]
			j++
		}
		cnt++
	}
	return tmp
}



Measured memory_bytes: 30992
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
typedef long long  ll;
//typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set
// this for long double
#define press_F_to_pay_respect ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn for(int i=0;i<n;i++) 
#define form for(int j=0;j<n;j++) 
#define fore(i,a,b) for(int i = a; i < (b); i++)
#define pb push_back 
#define pob pop_back()
#define mp make_pair 
#define sc second 
#define f first 
#define ld long double
#define kek cout<<endl; 
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(v) ((v).begin()), ((v).end()) 
#define pob pop_back() 
#define halt {cout<<-1; return 0;}
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const int N = 1010;
const int INF = 1e8;
const ll MOD1=1073741824;
const long double pi=3.1415926535;
using namespace std;
using namespace __gnu_pbds;
typedef tree<ld,null_type,less<ld>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
string bin_rep(int n)
{
          string s="";
      for(int i=31;i>=0;i--)
   {
           if(n&(1<<i)) s+='1';
           else s+='0';
   }
   return s;
}
int main()
{
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 press_F_to_pay_respect;
 // cout << fixed << setprecision(12) << ans;
 // string al = "abcdefghijklmnopqrstuvwxyz";
 ll x;
 cin>>x;
 ll cnt=0;
 ll cur=100;
 while(cur<x)
 {
           ll add=cur/100;
           cur+=add;
           cnt++;
 }
 cout<<cnt;
 
 
 
 
 
    
 
 
 
  // cout <<"Runtime is:"<<clock() * 1.0 / CLOCKS_PER_SEC <<endl;
   return 0;
   
   
 
}

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

#define N 200123
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    if(fopen("input.in", "r")){
        freopen("input.in", "r", stdin);
        freopen("output.out", "w", stdout);
    }
    int k;
    queue<long long> qu;
    vector<long long> list;
    cin >> k;

    for(long long i = 1 ; i <= 9 ; i++)
    	qu.push(i);
    

    while(list.size() < k){
    	long long curr = qu.front();
    	qu.pop();
    	list.push_back(curr);
    	for(long long i = -1 ; i <= 1 ; i++){
    		long long b = curr%10;
    		if(b + i < 0 || b + i > 9) continue;
    		qu.push(curr*10 + b+i);
    	}
    }

    cout << list[k-1] << endl;
    return 0;
}

Measured memory_bytes: 2676
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
using namespace std;
int mod = 1e9+7;

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


int main() {

  int a, b, x;
  cin >> a >> b >> x;

  if( a <= x && x <= a+b ) cout << "YES" << endl;
  else cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 256
H, W, D = map(int, input().split())
As = [list(map(int, input().split())) for i in range(H)]
Q = int(input())
LRs = [list(map(int, input().split())) for i in range(Q)]

poss = [(0, 0)] * (H * W)
for i in range(H):
    for j in range(W):
        poss[As[i][j] - 1] = (i, j)

MPs = [[] for i in range(D)]
for st in range(1, D + 1):
    MPs[st - 1] += [0]
    pi, pj = poss[st - 1]
    for i, j in poss[st - 1 + D::D]:
        MPs[st - 1] += [MPs[st - 1][-1] + abs(i - pi) + abs(j - pj)]
        pi, pj = i, j

for L, R in LRs:
    st = (L - 1) % D + 1
    print(MPs[st - 1][(R - st) // D] - MPs[st - 1][(L - st) // D])


Measured memory_bytes: 45156
#include "bits/stdc++.h"
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using V = vector<int>;
using S = string;
using C = char;

const double pi = 3.1415926535;

void Main()
{
	int a, b, c;
	cin >> a >> b >> c;
	if (a + b < c) {
		cout << a + 2*b + 1 << endl;
	} else {
		cout << b + c << endl;
	}
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 3648
import heapq
n,m = map(int,input().split())
a = list(map(lambda x:int(x)*(-1),input().split()))

heapq.heapify(a)
for _ in range(m):
    tmp_min = heapq.heappop(a)
    heapq.heappush(a,(-1)*(-tmp_min//2))
print(-sum(a))


Measured memory_bytes: 14180
#pragma GCC optimize("Ofast")
/*#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <cstdio>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <random>
#include <iomanip>
#include <bitset>
                        
using namespace std;
                        
template<typename T> void uin(T &a, T b) {
    if (b < a) {
        a = b;
    }
}
                        
template<typename T> void uax(T &a, T b) {
    if (b > a) {
        a = b;
    }
}
  
#define int long long
#define ghost signed
#define left left228
#define right right228
#define prev prev228
#define list list228

const int N = 5005;
const int MOD = 1e9 + 7;

int mod(int x) {
	x %= MOD;
	if (x < 0) x += MOD;
	return x;
}

void add(int &x, int y) {
	x += y;
	if (x >= MOD) x -= MOD;
}

int fp(int a, int b) {
	int res = 1;
	while (b) {
		if (b & 1) res = mod(res * a);
		a = mod(a * a);
		b >>= 1;
	}
	return res;
}

int n;
int dp[N][N][2], pd[N][N][2], gg[N], sz[N];
int f[N], rf[N];
vector<int> g[N];

void pre() {
	f[0] = 1;
	for (int i = 1; i <= n; ++i) f[i] = mod(f[i - 1] * i);
	for (int i = 0; i <= n; ++i) rf[i] = fp(f[i], MOD - 2);
}

int C(int n, int k) {
	if (k > n) return 0;
	return mod(f[n] * mod(rf[k] * rf[n - k]));
}


void dfs(int v, int par = -1) {
	vector<int> sons;
	sz[v] = 1;
	for (int to : g[v]) {
		if (to == par) continue;
		dfs(to, v);
		sons.push_back(to);
		sz[v] += sz[to];
	}
	dp[0][0][0] = 1;
	for (int i = 0; i <= (int)sons.size(); ++i) {
		for (int j = 0; j <= sz[v]; ++j) {
			pd[i][j][0] = pd[i][j][1] = 0;
		}
	}
	pd[0][1][0] = 1;
	int preff = 0;
	for (int i = 0; i < (int)sons.size(); ++i) {
		int son = sons[i];
		for (int j = 1; j <= preff + 1; ++j) {
			for (int par1 = 0; par1 < 2; ++par1) {
				if (pd[i][j][par1] == 0) continue;
				for (int take = 1; take <= sz[son]; ++take) {
					for (int par2 = 0; par2 < 2; ++par2) {
						add(pd[i + 1][j][par1 ^ par2 ^ 1], mod(pd[i][j][par1] * mod(dp[son][take][par2] * gg[take])));
						add(pd[i + 1][j + take][par1 ^ par2], mod(pd[i][j][par1] * dp[son][take][par2]));
					}
				}
			}
		}
		preff += sz[son];
	}
	for (int kek = 0; kek <= preff + 1; ++kek) {
		for (int parity = 0; parity < 2; ++parity) {
			dp[v][kek][parity] = pd[(int)sons.size()][kek][parity];
		}
	}
}

ghost main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
	cin >> n;
	pre();
	for (int it = 0; it < n - 1; ++it) {
		int u, v;
		cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for (int i = 2; i <= n; i += 2) {
		gg[i] = C(i, i / 2);
		gg[i] = mod(gg[i] * f[i / 2]);
		gg[i] = mod(gg[i] * mod(fp(fp(2, i / 2), MOD - 2)));
	}
	dfs(1);
	int res = 0;
	for (int i = 1; i <= n; ++i) {
		res = mod(res - mod(dp[1][i][1] * gg[i]));
		res = mod(res + mod(dp[1][i][0] * gg[i]));
	}
	cout << res << '\n';
    return 0;
} // kek ;












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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    ll X;
    ll ans = 100;
    ll count = 0;
    cin >> X;
    while(ans < X) {
        ans += ans / 100;
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 3612
import Control.Monad (replicateM)
import Data.List (sort, sortBy)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B

main = do
  [n, m] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine 
  ns <- replicateM m ((\[a,b] -> (a,b)) . 
          map (fst . fromJust . B.readInt) . B.words <$> B.getLine)
  print $ solve 0 . sortBy (\(_,a) (_,b) -> compare a b) $ ns

solve :: Int -> [(Int, Int)] -> Int 
solve count [] = count 
solve count (t:ts) = solve (count + 1) (filter (\(a,_) -> a > (snd t - 1)) ts)

Measured memory_bytes: 49532
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main() {
	double w, h, x, y,k;
	cin >> w >> h >> x >> y;
	if (w/2==x&&h/2==y) {
		k = 1;
	}
	else {
		k = 0;
	}
	printf("%.9f %.0f", (h*w)/2, k);
}

Measured memory_bytes: 256
//#define MYDEBUG
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <stack>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl 
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
  out << "[";
  size_t last = v.size() - 1;
  for (size_t i = 0; i < v.size(); ++i) {
    out << v[i];
    if (i != last)
      out << ",";
  }
  out << "]";
  return out;
}

void solve(){
	string s;
	cin >> s;
	string key="";
	for(int i=0; i<s.size(); ++i){
		char c=s[i];
		if(c!='B') key+=c;
		else if(0<key.size()) key = key.substr(0,key.size()-1);
		debug(key);
	}
	cout << key << endl;
}

int main() {
	solve();
}


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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

	int n;
	cin >> n;

	vector<int> c(n - 1);
	vector<int> s(n - 1);
	vector<int> f(n - 1);
	rep (i, 0, n - 1)
		cin >> c[i] >> s[i] >> f[i];

	vector<int> res(n, 0);
	rep (i, 0, n - 1) {
		int now = 0;
		rep (j, i, n - 1) {
			if (now <= s[j]) {
				now = s[j] + c[j];
			} else {
				int k = ceil((float)(now - s[j]) / f[j]);
				now = s[j] + k * f[j] + c[j];
			}
		}
		res[i] = now;
	}

	for (int tmp : res)
		cout << tmp << endl;

	return 0;
}


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

int A[20];
int x[20][20];
int y[20][20];

int main() {
  int N;
  scanf("%d", &N);

  for (int i = 0; i < N; ++i) {
    scanf("%d", &A[i]);
    for (int j = 0; j < A[i]; ++j) {
      scanf("%d%d", &x[i][j], &y[i][j]);
    }
  }

  int ans = 0;
  // bit全探索
  for (int bits = 0; bits < (1 << N); ++bits) {
    bool is_consistent = true;

    for (int i = 0; i < N; i++)
      if ((bits >> i) & 1) {
        // シミュレートしている状態と各正直者の証言が整合しているか確認
        for (int j = 0; j < A[i]; j++) {
          if ((bits >> (x[i][j] - 1)) & 1 ^ y[i][j]) is_consistent = false;
        }
      }

    if (is_consistent) ans = max(ans, (int)bitset<15>(bits).count());
  }

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<char,char> win;
map<char,int> val;
void fl()
{
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
}
int main()
{
	ios::sync_with_stdio(0);
//    fl();
	int n,k;
	cin>>n>>k;
	int r,s,p;
	cin>>r>>s>>p;
	string ss;
	cin>>ss;
	ss='_'+ss+'_';
	win['r']='p';
	win['s']='r';
	win['p']='s';
	val['r']=r;
	val['s']=s;
	val['p']=p;
	int ans=0;
	for(int i=1;i<=k;i++)
	{
		string tmp="";
		for(int j=i;j<=n;j+=k)
			tmp+=win[ss[j]];
		tmp='_'+tmp+'_';
		string tmp2="";
		tmp2+=tmp[1];
		for(int j=2;j<=tmp.length()-1;j++)
		{
			if(tmp[j]!=tmp[j-1])
			{
				ans+=val[tmp2[0]]*((tmp2.length()+1)/2);
				tmp2="";
			}
			tmp2+=tmp[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

/* aとbの最大公約数を求める */
int div(int a,int b)
{
  int m,n;

  m = a;
  n = b;

  for(;;)
    {
      while(m > n)
        {
          if(m - n != 0)
            m = m - n;
        }
      while(n > m)
        {
          if(n - m != 0)
            n = n -m;
        }
      if(m == n)

      return m;
    }
}


int main()
{
  int a,b,c;
  int A,B,C,K,ans=0;

  scanf("%d", &K);
  for(A=1; A<=K; A++){
      for(B=1; B<=K; B++){
        for(C=1; C<=K; C++) {
          ans += div((div(A,B)),C);
        }
      }
    }

  printf("%d",ans );
  return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	long double a,b,c;cin>>a>>b>>c;
	long double sa,sb;
	sa = sqrt(a);
	sb = sqrt(b);
	if (a + b + (long double)2.0 * sa * sb < c){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	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 a[] = new int[3];
		a[0] = sc.nextInt();
		a[1] = sc.nextInt();
		a[2] = sc.nextInt();
		int K = sc.nextInt();
		sc.close();
		long sum = 0;
		while (K != 0 && a[0] > 0) {
			sum += 1;
			--K;
			a[0]--;
		}
		while (K != 0 && a[1] > 0) {
			a[1]--;
			--K;
		}
		while (K != 0 && a[2] > 0) {
			sum -= 1;
			a[2]--;
			--K;
		}
		System.out.println(sum);
	}
}


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

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

    int x,y,z;
    cin >> x >> y >> z;

    cout << z << " " << x << " " << y << " " << endl;

    return 0;
}

Measured memory_bytes: 256
/* ****mittal21**** */
#include<bits/stdc++.h>
#define ll          long long int 
#define ld          long double
#define pb          push_back
#define endl        '\n'
#define pii         pair<long long int,long long int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll )x.size()
#define hell        1000000007
#define jell        998244353
#define rep(i,a,b)    for(ll int i=a;i<b;i++)
#define repr(i,a,b)   for(ll int i=a;i>=b;i--)
#define lbnd    lower_bound
#define ubnd        upper_bound
#define mp          make_pair
#define DEC(N)  cout << std::fixed; cout << setprecision(N);
using namespace std;
#define N  100005
ll dp[3005][3005];
ll a[3005];
ll fun(ll l,ll r)
{
    if(l>r)
      return 0;
    if(dp[l][r]!=-1)
      return dp[l][r];
    dp[l][r]=max(a[l]+min(fun(l+1,r-1),fun(l+2,r)),a[r]+min(fun(l+1,r-1),fun(l,r-2)));
  return dp[l][r];
}
void solve()
{
   ll n;
   cin>>n;
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
    cin>>a[i];
    sum+=a[i];
   }
   memset(dp,-1,sizeof(dp));
   ll o=fun(1,n);
   cout<<2*o-sum;
   return;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll testcase=1;
    //cin>>testcase;
    while(testcase--)
    {
        solve();
    }
    return 0;
}

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

int main(){
    string S, T, U = "";
    int A, B = 0;
    cin >> S >> T >> A >> B >> U;
    if (U == S)
    {
        cout << A - 1 << " " << B << endl;
    }
    else{
        cout << A << " " << B - 1 << endl;
    }
}

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


int main(){
	int n;
	int *data;
	int i, j, k;
	int v;

	scanf("%d", &n);
	data = (int *)malloc(sizeof(int) * n);

	for(i=0; i<n; i++){
		scanf("%d", &data[i]);
	}

	for(k=0; k< n; k++){
		if(k>0){
			printf(" ");
		}
		printf("%d", data[k]);
	}
	printf("\n");
	
	for(i=1; i< n; i++){
		v = data[i];
		j = i - 1;
		while((j>=0) && data[j]>v){
			data[j+1] = data[j];
			j = j - 1;
		}
		data[j+1] = v;

		for(k=0; k< n; k++){
			if(k>0){
				printf(" ");
			}
			printf("%d", data[k]);
		}
		printf("\n");
	}


	free(data);
	return 0;
}


Measured memory_bytes: 2044
// abc166_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string S;
    cin >> S;

    if (S == "ARC"){
        print("ABC");
    } else {
        print("ARC");
    }

    return 0;
}


Measured memory_bytes: 3668
package main

import (
	"fmt"
	"math"
)

var count = 0

func main() {
	var x, a, b int
	fmt.Scan(&x, &a, &b)
	if abs(x - a) < abs(x - b) {
		fmt.Println("A")
	} else {
		fmt.Println("B")
	}
}

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

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

int main(void){
    ll H[2], M[2], K;
    cin >> H[0] >> M[0] >> H[1] >> M[1] >> K;
    ll l = H[0] * 60 + M[0];
    ll r = H[1] * 60 + M[1];
    cout << r - l - K << endl;
    return 0;
}


Measured memory_bytes: 3636
while 1:
    n, x = map(int,input().split())
    if n==0 and x==0:break
    count=0
    for a in range(1, n+1):
        for b in range(a+1, n+1):
            for c in range(b+1, n+1):
                if a+b+c ==x: count+=1
    print(count)



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
#define VI vector<int>
#define PII pair<int,int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ll long long
#define db double
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)x.size())
#define out(x) cout<<(#x)<<" = "<<x<<endl
mt19937 mrand(random_device{}());
const ll mod = 1000000007;
int rnd(int x){return mrand()%x;}
clock_t ac; double TLE(){return (double)(clock()-ac)/CLOCKS_PER_SEC;}

int main(){
 ios::sync_with_stdio(0);
 cin.tie(0);
 map<string,int>m;
 int n;
 cin>>n;
 for(int i=0;i<n;i++){
   string s;
   cin>>s;
   m[s]++;
 }
 cout<<"AC "<<"x"<<" "<<m["AC"]<<"\n";
 cout<<"WA "<<"x"<<" "<<m["WA"]<<"\n";
 cout<<"TLE "<<"x"<<" "<<m["TLE"]<<"\n";
 cout<<"RE "<<"x"<<" "<<m["RE"]<<"\n";
}




Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define mod 100000007
using namespace std;

int main()
{
int N,K,Q;scanf("%d %d %d",&N,&K,&Q);
int A[Q];for(int i=0;i<Q;i++)scanf("%d\n",&A[i]);
int scores[N];for(int i=0;i<N;i++)scores[i]=0;
for(int i=0;i<Q;i++)scores[A[i]-1]++;
for(int i=0;i<N;i++)if(scores[i]>Q-K)printf("Yes\n");else printf("No\n");
}

Measured memory_bytes: 4448
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, k, a, b;
bool nuri[100008];
vector<vector<ll>> t(100008);
ll MOD = 1e9+7;

ll dfs(ll at, ll ans){
	nuri[at] = true;
	
	ll eda = t[at].size();
	ll edanuru = 0;
	for(ll i = 0; i < eda; i++){
		ll next = t[at][i];
		if(!nuri[next]){
			ans = dfs(next, ans);
			edanuru++;
		}
	}
	
	ll kf = k-(eda-edanuru+1);
	for(ll i = 1; i <= edanuru; i++){
		ans *= kf;
		ans %= MOD;
		kf--;
	}
	
	return ans;
}

int main(){
	cin >> n >> k;
	for(ll j = 1; j <= n-1; j++){
		cin >> a >> b;
		t[a].push_back(b);
		t[b].push_back(a);
	}
	
	for(ll i = 1; i <= n; i++){
		if(t[i].size()+1 > k){
			cout << 0 << endl;
			return 0;
		}
	}
	
	memset(nuri, 0, sizeof(nuri));
	ll ans = k;
	ans = dfs(1, ans);

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

Measured memory_bytes: 9344
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 0
info = [[] for _ in range(n)]
for i in range(n):
    a = I()
    for _ in range(a):
        x, y = LI()
        info[i].append((x-1, y))

for i in range(1, 1 << n):
    ret = 0
    for j in range(n):
        if i >> j & 1:
            ret += 1
            for x, y in info[j]:
                if y == 0 and i >> x & 1:
                    break
                elif y == 1 and not i >> x & 1: 
                    break
            else:
                continue
            break
    else:
        ans = max(ans, ret)
print(ans)


Measured memory_bytes: 74532
from sys import stdin

a = []
a1 = [int(x) for x in stdin.readline().rstrip().split()]
a2 = [int(x) for x in stdin.readline().rstrip().split()]
a3 = [int(x) for x in stdin.readline().rstrip().split()]
a4 = [a1[0], a2[0], a3[0]]
a5 = [a1[1], a2[1], a3[1]]
a6 = [a1[2], a2[2], a3[2]]
a7 = [a1[0], a2[1], a3[2]]
a8 = [a1[2], a2[1], a3[0]]
a.append(a1)
a.append(a2)
a.append(a3)
a.append(a4)
a.append(a5)
a.append(a6)
a.append(a7)
a.append(a8)

n = int(stdin.readline().rstrip())
b = []
for i in range(n):
    b.append(int(stdin.readline().rstrip()))

result = "No"
for aa in a:
    if (aa[0] in b and aa[1] in b and aa[2] in b):
        result = "Yes"

print(result)

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;
const double PI=3.1415926535897932;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

ll r;

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

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

using namespace std;
#define INF (1LL<<60)
#define int long long
#define FOR(i, a, b) for(int i=(int)(a);i<(int)(b);++i)


class B754 {
public:
    void solve(std::istream &in, std::ostream &out) {
      string s;
      in >> s;
      int min = INF;
      FOR(i, 2, s.length()) {
        int tmp = abs(stoll(s.substr(i - 2, 3)) - 753);
        if (tmp < min) {
          min = tmp;
        }
      }
      out << min << endl;
    }
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
  B754 solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  solver.solve(in, out);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
#include <queue>
#define MOD 1000000007
#define REP(i,st,num)for(int i=(st);i<(num);++i)
#define ll long long
using namespace std;

bool cmp(pair<int,int> &a, pair<int,int> &b) {
    return a.second>b.second;
}

int main() {
    ios::sync_with_stdio(false);
    vector<pair<int,int> > jobs;
    int N,M,A,B;
    cin>>N>>M;
    REP(i,0,N){
        cin>>A>>B;
        jobs.push_back(make_pair(A,B));
    }
    sort(jobs.begin(),jobs.end());
    ll ans=0;
    int idx=0;
    priority_queue<int> pq;
    REP(day,1,M+1){
        while (idx<N&&jobs[idx].first<=day){
            pq.push(jobs[idx].second);
            ++idx;
        }
        if(pq.empty())continue;
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 1908
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define _CRT_SECURE_NO_WARNINGS
#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back

typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	string s;
	getline(cin, s);
	stack<int> st;
	int i = 0;
	while (i < SZ(s)) {
		if (isdigit(s[i])) {
			int num = 0;
			while (i < SZ(s) && isdigit(s[i])) {
				num = num * 10 + (s[i] - '0');
				i++;
			}
			st.push(num);
		}
		else if (s[i] == '+' || s[i] == '-' || s[i] == '*') {
			int n1, n2, result;
			n2 = st.top();
			st.pop();
			n1 = st.top();
			st.pop();

			if (s[i] == '+')result = n1 + n2;
			else if (s[i] == '-')result = n1 - n2;
			else if (s[i] == '*')result = n1 * n2;

			//printf("%d %c %d = %d\n", n2, s[i], n1, result);
			st.push(result);
			i++;
		}
		else {
			i++;
		}
	}
	cout << st.top() << endl;
}


Measured memory_bytes: 3168
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)

int a,b;

int main() {

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

	if (a + b == 15) printf("+\n");
	else if (a*b == 15) printf("*\n");
	else printf("x\n");

	return 0;
}


Measured memory_bytes: 764
import * as fs from "fs";


class DisjointSet {
    parents: number[];

    constructor(readonly size: number) {
        this.parents = new Array(size);
        for(let i=0; i<size; i++)
            this.parents[i] = i;
    }

    find(node: number): number {
        if (this.parents[node] != node)
            this.parents[node] = this.find(this.parents[node]);
        return this.parents[node];
    }

    union(node1: number, node2: number): void {
        let parent1 = this.find(node1),
            parent2 = this.find(node2);
        if (parent1 != parent2)
            this.parents[parent2] = parent1;
    }
}

let [line1, line2, ...lines] = fs.readFileSync("/dev/stdin", "utf8").trim().split("\n");

let [N, M] = line1.split(" ").map(Number);
let P = line2.split(" ").map((n) => {return Number(n)-1;});
let X:number[] = [],
    Y:number[] = [];

let disjointSet: DisjointSet = new DisjointSet(N);

for(let i=0; i<M; i++) {
    let [x, y] = lines[i].split(" ").map(Number);
    disjointSet.union(x-1, y-1);
}

let answer = 0;
for(let i=0; i<N; i++) {
    if (disjointSet.find(i) == disjointSet.find(P[i])) {
        answer += 1;
    }
}

console.log(answer);


Measured memory_bytes: 61440
#include <iostream>

using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;
    string arr[N];
    for (int i = 0 ; i<N ; i++){
        cin >>arr[i];
    }
    for (int i = 0 ; i< N ; i++){
        cout<< arr[i]<<endl;
        cout<< arr[i]<< endl;
    }
    return 0;
}


Measured memory_bytes: 256
def check_month(n):
  return 1 <= n <= 12
def check_year(n):
  return 0 <= n <= 99

S = input()
Y = int(S[:2])
M = int(S[2:])
if check_month(Y) and check_month(M):
  print('AMBIGUOUS')
elif check_month(Y) and check_year(M):
  print('MMYY')
elif check_year(Y) and check_month(M):
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false); cin.tie(0);
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
int main() {
    IO;
   
    ll n, m;
    cin >> n >> m;
    if (n == 1 && m == 1) {
        cout << 1;
        return 0;
    }
    if (n == 1) {
        cout << m - 2;
        return 0;
    }
    if (m == 1) {
        cout << n - 2;
        return 0;
    }
    cout << (n - 2) * (m - 2);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC omodtimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
using namespace __gnu_pbds;
using namespace std;
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll n,k;
	cin >> n >> k;
	if (n >= k) cout << min(n,ll(k*ceil(ld(n)/ld(k))-n)) << endl;
	else cout << min(n,k-n) << endl;
}

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

int cmpnum(const void * n1, const void * n2)
{
	if(*(long int *)n1 >*(long int *)n2)
	{
		return -1;
	}
	else if(*(long int *)n1 < *(long int *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
}
}

int main(void)
{
	int n,k,i;
	long int a[200000]={0};

	long int score=0;
	long int h;
	
	scanf("%d%d",&n,&k);
	
	for(i=0;i<n;i++){
		scanf("%ld",&h);
		a[i]=h;
	}
	
	qsort(a, sizeof(a)/ sizeof(a[0]),sizeof(long int),cmpnum);
	
	for(i=k;i<n;i++){
			score+=a[i];
	}
	
	printf("%ld",score);
	
	return 0;
}


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

int main() {
    int a, b;
    cin >> a >> b;
    // i円のときの消費税i*x/100
    for (int i = 1; i <= 10000; i++){
        if ((i*8)/100 == a && (i*10)/100 == b){
            cout << i << endl;
            break;
        }
        else if(i == 10000){
            cout << -1 << endl;
            break;
        }

    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define optimizar_io ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
int main(){
    int a,b,c,d; cin>> a >> b >> c >> d;
    if(a+b>c+d)cout<<"Left"<<endl;
    else if(c+d>a+b)cout<<"Right"<<endl;
    else cout<<"Balanced"<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

int main() {
  ll S, W;
  cin >> S >> W;
  string ans = "safe";
  if (S <= W) {
    ans = "unsafe";
  }

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

Measured memory_bytes: 3620
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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() {
    string S;
    cin >> S;
    //vector<vector<int>> data(3, vector<int>(4));
    //初期値0
    //vector<int> data(i, 0);
    int count = 0;
    int mx = -1;
    rep(i, 0, S.length()) {
        if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T') {
            ++count;
        } else {
            mx = max(mx, count);
            count = 0;
        }
        mx = max(mx, count);
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
a, b, c = map(int, input().split())

if a < b:
    if b < c:
        print("{} {} {}".format(a, b, c))
    else:
        print("{} {} {}".format(a, c, b))
else:
    if b < c:
        print("{} {} {}".format(b, c, a))
    else:
        print("{} {} {}".format(c, b, a))


Measured memory_bytes: 5592
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int main() {
    int n, a[108],i,j,ttl=0,min2=9987600;
    cin >> n;
    for (i=0; i<n; i++) {
        cin >> a[i];
    }
    int min=a[0],max=a[0];
    for (i=1; i<n; i++) {
        if (a[i]<min) {
            min=a[i];
        }
        else if(a[i]>max){
            max=a[i];
        }
    }
    for (i=min; i<=max; i++) {
        ttl=0;
        for (j=0; j<n; j++) {
            ttl=ttl+((a[j]-i)*(a[j]-i));
        }
        if (ttl<min2) {
            min2=ttl;
        }
    }
    cout << min2;
    return 0;
}


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

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N, a;
  cin >> N;
  vector<int> c(9, 0);

  rep(i, N){
    cin >> a;
    if(a < 400) c[0]++;
    else if(a < 800) c[1]++;
    else if(a < 1200) c[2]++;
    else if(a < 1600) c[3]++;
    else if(a < 2000) c[4]++;
    else if(a < 2400) c[5]++;
    else if(a < 2800) c[6]++;
    else if(a < 3200) c[7]++;
    else  c[8]++;
  }

  int min_ans=0, max_ans;
  rep(i, 8){
    if(c[i] != 0) min_ans++;
  }
  max_ans=min_ans+c[8];
  if(min_ans == 0) min_ans++;
  
  cout << min_ans << " " << max_ans << endl;

}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var num, blue, red int
	fmt.Scan(&num, &blue, &red)

	var perfCycleNum int = num / (blue + red)
	var rem int = num % (blue + red)
	var blueTotal int = perfCycleNum * blue

	blueTotal += min(rem, blue)

	fmt.Println(blueTotal)
}

// min は2つのint型の値を比べて小さいほうを返す関数 (float型を扱う場合は math.Min())
func min(x int, y int) int {
	if x > y {
		return y
	}
	return x
}


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

int main(){
    ll n;
    cin>>n;
    ll a[n];
    for(ll i=0;i<n;++i){
        cin>>a[i];
    }
    sort(a, a+n);
    ll ans=a[n-1]-a[0];
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N, M; std::cin >> N >> M;
  std::vector<std::vector<int>>G(N);
  for(int i = 0; i < M; ++i) {
    int a, b; std::cin >> a >> b; --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  int mask = (1<<N)-1;
  auto dfs = [&](auto&& f, int v, int s) {
    if(s == mask) return 1;
    int res = 0;
    for(int c: G[v]) if(((1<<c)&s)==0) {
      res += f(f, c, s+(1<<c));
    }
    return res;
  };
  fin(dfs(dfs, 0, 1));
  return 0;
}


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

typedef long long int ll;

ll n;
ll arr[100005];
int main()
{
    cin>>n;

    for(ll i=0;i<n;i++)cin>>arr[i];

    ll ne = 0;
    ll po = 0;
    ll s = 0;
    ll mi = INT_MAX;
    for(ll i=0;i<n;i++){
        if(arr[i]<0){
            ne+=1;
        }
        else{
            po+=1;
        }
        s+=abs(arr[i]);
        mi = min(mi,abs(arr[i]));
    }

    if(ne%2==0){
        cout<<s<<endl;
    }
    else{
            //cout<<mi<<endl;
        cout<<(s-2*mi)<<endl;
    }




}


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

using namespace std;

int main(){
    int n,m;

    cin >> n >> m;

    int a,k;

    vector<int> aa(m,0);
    for(int i = 0;i < n;i++){
        cin >> k;
        for(int j = 0;j < k;j++){
            cin  >> a;
            aa[a-1]++;
        }
    }
    int ans = 0;
    for(int i = 0;i < m;i++){
        // cout << aa[i] << endl;
        if(aa[i] == n){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

//template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;                         

const int N = (int)5e5 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;

void solve () {
	string a;
	cin >> a;
	int ans = 0;
	int yes = 0;
	for (int i = 0; i < sz (a); i ++) {
		if (a[i] == 'T') {
			if (yes) yes --;
			else ans ++;
		}
		else {
			yes ++;
		}
	}		
	ans += yes;
	cout << ans;
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define pb push_back
#define int long long
#define mp make_pair
#define inf 1000000007
#define LINF 10000000000000007LL
#define ll long long
using namespace std;
vector<int> nex[114514];
int used[114514];
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int p2[55],res=1;
	p2[0]=1;p2[1]=x%inf;
	for(int i=2;i<=50;i++){
		p2[i]=p2[i-1]*p2[i-1];
		p2[i] %= inf;
	}
	for(int i=1;i<=50;i++){
		if(k%2==1){
			res *= p2[i];
			res %= inf;
		}
		k /= 2;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
signed main(){
	int n,k;
	cin>>n>>k;
	setkaijo(110000);
	setinv(110000);
	for(int i=0;i<n-1;i++){
		int x,y;
		cin>>x>>y;
		nex[x].pb(y);
		nex[y].pb(x);
	}
	int ans = k;
	queue<int> que;
	que.push(1);
	used[1] = 1;
	while(!que.empty()){
		int cur = que.front();que.pop();
		int cnt = 0;
		for(int i=0;i<nex[cur].size();i++){
			int nx = nex[cur][i];
			if(used[nx] == 0){
				cnt++;
				used[nx]=1;
				que.push(nx);
			}
		}
		int col;
		if( cur == 1 ) col = k-1; else col = k-2;
		int cb = comb(col, cnt);
		ans *= cb; ans %= inf;
		ans *= ka[cnt]; ans %=inf;
	}
	cout<<ans<<endl;
	return 0;
}

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

typedef long long LL;

const int MAXN = 200005;
const int MAXM = 400005;

int tot;
int head[MAXN];
struct node
{
    int u, v, w, next;
} edge[MAXM];

void add(int u, int v, int w)
{
    edge[tot] = {u, v, w, head[u]};
    head[u] = tot++;
}

int n, m;
bool ff = false;

void gg(int u, int fa,int ca)
{
    if(ff) return;
    for(int i = head[u]; i != -1; i = edge[i].next)
    {
        int v = edge[i].v;
        if(v == fa) continue;
        if(ca == 2)
        {
            if(v == n)
            {
                ff = true;
                return;
            }
        }
        if(ca + 1 < 3)
        gg(v, u, ca + 1);
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    int u, v;
    memset(head, -1, sizeof(head));
    for(int i = 0; i < m; ++i)
    {
        cin >> u >> v;
        add(u, v, 1);
        add(v, u, 1);
    }
    
    gg(1, 0, 1);
    if(ff) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
    
    return 0;
}

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


int main()
{
	int n, max=-1000000, min=1000000;
	long long sum=0;
	cin >> n;

	for (int i = 0;i < n;i++) {
		int a;
		cin >> a;

		sum += a;
		if (a > max) {
			max = a;
		}
		if (a < min) {
			min = a;
		}
	}

	cout << min << " " << max << " " << sum << endl;

    return 0;
}



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

int main(void){
    
    //入力
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    
    //aとeの距離を計算し、kより大きいかどうかを調べる
    int longeset_distance = e - a;
    if (longeset_distance > k) cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

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

using namespace std;
const int maxnode=100+20;
int sigma_size;//后面读入

typedef long long ll;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;

struct AC_Automata
{
    int ch[maxnode][100+20];
    int match[maxnode];
    int f[maxnode];
    map<char ,int> mp;
    int sz;
    void init()
    {
        sz=1;
        memset(ch[0],0,sizeof(ch[0]));
        match[0]=f[0]=0;
        mp.clear();
    }
    void insert(char *s)
    {
        int n=strlen(s),u=0;
        for(int i=0;i<n;i++)
        {
            int id=mp[s[i]];
            if(ch[u][id]==0)
            {
                ch[u][id]=sz;
                memset(ch[sz],0,sizeof(ch[sz]));
                match[sz++]=0;
            }
            u=ch[u][id];
        }
        match[u]=1;
    }
    void getFail()
    {
        f[0]=0;
        queue<int> q;
        for(int i=0;i<sigma_size;i++)
        {
            int u=ch[0][i];
            if(u)
            {
                f[u]=0;
                q.push(u);
            }
        }
        while(!q.empty())
        {
            int r=q.front();q.pop();
            for(int i=0;i<sigma_size;i++)
            {
                int u=ch[r][i];
                if(!u){ ch[r][i]=ch[f[r]][i]; continue; }
                q.push(u);
                int v=f[r];
                while(v && ch[v][i]==0) v=f[v];
                f[u]=ch[v][i];
                match[u] |= match[f[u]];
            }
        }
    }
};
AC_Automata ac;
vector<vector<ll>> dp(110, vector<ll>(100 + 10, 0));//dp[i][j]是一个最大长度为100的大数
ll add(ll a, ll b)//大数相加,a[0]表示的是个位,a[1]是十位
{
    return (a % MOD + b % MOD) % MOD;
}
int main()
{
    int n = 4;
    int m;
    int p = 9;
    string str;
    cin >> m;
    {
        sigma_size=n;
        ac.init();
        str = "AGCT";
        for(int i=0;i<n;i++)
            ac.mp[str[i]]=i;
        ac.insert("AGC");
        ac.insert("ACG");
        ac.insert("GAC");
        ac.insert("AGGC");
        ac.insert("ACGC");
        ac.insert("ATGC");
        ac.insert("AGAC");
        ac.insert("AGGC");
        ac.insert("AGTC");
        ac.getFail();
 
        dp[0][0] = 1;
        for(int k=0;k<m;k++)
        {
            for(int i=0;i<ac.sz;i++)
                if(ac.match[i]==0)
                for(int j=0;j<sigma_size;j++)
                    if(ac.match[ac.ch[i][j]]==0)
                        dp[ac.ch[i][j]][k+1] = add(dp[ac.ch[i][j]][k+1],dp[i][k]);
        }
        ll ans = 0;
        for(int i=0;i<ac.sz;i++)if(ac.match[i]==0)
            ans = add(ans,dp[i][m]);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool compPair(pair<int, int> a, pair<int, int> b){
  return a.second < b.second;
}

int main(){
  int n;
  cin >> n;
  vector<pair<int, int> > Ai;
  for(int i=0; i<n; i++){
    int manNum;
    cin >> manNum;
    Ai.push_back( make_pair(i, manNum) );
  }

  sort(Ai.begin(), Ai.end(), compPair);

  for(int i=0; i<n; i++) cout << Ai[i].first + 1 << ' ';

  return 0;
}


Measured memory_bytes: 1780