akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

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

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

ll N, X, Y;

// i,j の最短経路
ll f(ll i, ll j)
{
  // i <= X
  if (i <= X)
  {
    // j >= Y
    if (j >= Y)
    {
      return X - i + j - Y + 1;
    }
    // j <= X
    if (j <= X)
    {
      return j - i;
    }
    // X < j < Y
    ll res = X - i;
    return res + min(j - X, (Y - X + 1) - (j - X));
  }
  // i >= Y
  if (i >= Y)
  {
    return j - i;
  }
  // X < i < Y
  if (X < i && i < Y)
  {
    // j >= Y
    if (j >= Y)
    {
      ll res = j - Y;
      return res + min(Y - i, (Y - X + 1) - (Y - i));
    }

    // X < j < Y
    return min(j - i, Y - j + i - X + 1);
  }
  return -1;
}

signed main()
{

  cin >> N >> X >> Y;
  map< ll, ll > K;
  FOR(i, 1, N - 1)
  {
    FOR(j, i + 1, N)
    {
      ll k = f(i, j);
      K[k] += 1;
    }
  }

  FOR(i, 1, N - 1)
  {
    cout << K[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n,N) for(int i=n;i<N;i++)
#define p(S) cout<<S<<endl
using namespace std;


int main(){
	int h,w;
	while(cin>>h>>w&&h&&w){
		int r=h*h+w*w;
		int minr=100000;
		int tmp;
		pair<int,int> ans;
		for(int i=1;i<150;i++){
			for(int j=i+1;j<150;j++){
				if(i==h&&j==w) continue;
				tmp=i*i+j*j;
				if(tmp>r){
					if(minr>tmp){
						minr=tmp;
						ans={i,j};
					}
				}else if(tmp==r){
					if(i>h&&minr>tmp){
						minr=tmp;
						ans={i,j};
					}
				}
			}
		}
		cout<<ans.first<<" "<<ans.second<<endl;
	}

	return 0;
}

Measured memory_bytes: 3096
import sys
import fractions
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

n = ni()
t = ni()
if n == 1:
    print(t)
else:
    for i in range(n - 1):
        tmp = ni()
        t = lcm(t, tmp)
    print(t)


Measured memory_bytes: 5968
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define modulo 1000000007
#define fast_io ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
using namespace std;
int main(){
	fast_io;
	ll n,k;
	cin>>n>>k;
	ll a[n];
	ll dp[n];
	for (int i = 0; i < n; ++i){
		cin>>a[i];
		dp[i]=LLONG_MAX;
	}
	dp[0]=0;
	for (int i = 0; i < n-1; ++i){
		for (int j = i+1; j < min(i+k+1,n); ++j){
			dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
		}
	}
	cout<<dp[n-1]<<"\n";
	return 0;
}

Measured memory_bytes: 5160
#include <algorithm>
#include <stdio.h>
#include <math.h>
using namespace std;

const int NMAX = 100110;

int dp[2][3];

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

    for (int i = 1; i <= n; i++) {
        int * act = dp[i & 1];
        int * prv = dp[(i & 1) ^ 1];
        int v1, v2, v3;
        scanf("%d%d%d", &v1, &v2, &v3);
        act[0] = v1 + max(prv[1], prv[2]);
        act[1] = v2 + max(prv[0], prv[2]);
        act[2] = v3 + max(prv[0], prv[1]);
    }

    printf("%d\n", max(max(dp[n & 1][0], dp[n & 1][1]), dp[n & 1][2]));
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+5;

int main()
{
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int n, m;
	cin >> n >> m;
	ll a[n], ans = 0, acc = 0;
	map<ll, int> mop;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		acc = (acc + a[i]) % m;
		mop[acc]++;
	}
	acc = 0;
	for (int i = 0; i < n; i++)
	{
		ans += mop[acc];
		acc = (acc + a[i]) % m;
		mop[acc]--;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h> 
#include <cstring>
using namespace std;
//typedef
typedef long long ll;
typedef vector<int> vi;
typedef vector<string> vs;
//define
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)

int main(){
   string s;
   int n;
   cin >> n >> s;
   int count;
   count = n;
    rep(i, n - 1){
        if(s.at(i) == s.at(i+1)){
            count--;
        }
    }
    cout << count << endl;
 return 0;
}

Measured memory_bytes: 512
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations
import sys
import bisect
import string
import math
import time
ts=time.time()
sys.setrecursionlimit(10**6)
def SI():
    return input().split()
def MI():
    return map(int,input().split())
def I():
    return int(input())
def LI():
    return [int(i) for i in input().split()]
YN=['Yes','No']
mo=10**9+7

n,k=LI()
s=list(input())

ans=0
dif=0
for i in range(n-1):
    if s[i]!=s[i+1]:
        dif+=1
        
    if s[i]=='R' and s[i+1]=='R':
        ans+=1
    if s[i+1]=='L' and s[i]=='L':
        ans+=1
'''
#ans-=dif-2*k
print(dif)
print(dif-2*k)
print(ans)
'''
print(min(ans+2*k,n-1))

Measured memory_bytes: 49900
#include<stdio.h>

int IsPrime(int);

main(){

  int n,count=0,i,x;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){

    scanf("%d",&x);

    if(IsPrime(x)==1) count++;

  }

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

  return 0;
}

int IsPrime(int n){
    int i;
 
    if(n < 2)
        return 0;
    else if(n == 2)
        return 1;
 
    if(n % 2 == 0)
        return 0;
 
    for(i = 3; i <= n / i; i += 2)
         if(n % i == 0)
            return 0;
    return 1;
}

Measured memory_bytes: 596
#include <iostream>
#include <algorithm>

using namespace std;

int A, B, C, X;

int main() {
	int x = 0;
	cin >> A;
	cin >> B;
	cin >> C;
	cin >> X;

	for (int a = 0; a <= A; a++) {
		if (500*a > X) break;
		for (int b = 0; b <= B; b++) {
			if (500*a + 100*b > X) break;
			for (int c = 0; c <= C; c++) {
				if (500*a + 100*b + 50*c > X) break;
				if (500*a + 100*b + 50* c == X) x++;
			}
		}
	}

	cout << x << endl;
	return 0;
	
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from collections import deque
from itertools import combinations
import bisect

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    N, MA, MB = NMI()
    D = []
    for _ in range(N):
        a, b, c = NMI()
        t = a*MB - b*MA
        D.append((t, c))
    D.sort()

    D1 = D[:N//2]
    D2 = D[N//2:]
    ld1 = len(D1)
    ld2 = len(D2)

    S1 = defaultdict(lambda: 10**5)
    for case in range(2**ld1):
        if case == 0: continue
        s, c = 0, 0
        for i in range(ld1):
            if (case>>i)&1:
                s += D1[i][0]
                c += D1[i][1]
        S1[s] = min(S1[s], c)

    S2 = defaultdict(lambda: 10**5)
    for case in range(2 ** ld2):
        if case == 0: continue
        s, c = 0, 0
        for i in range(ld2):
            if (case >> i) & 1:
                s += D2[i][0]
                c += D2[i][1]
        S2[s] = min(S2[s], c)

    ans = 10**5
    for s, c in list(S1.items()):
        ans = min(ans, c + S2[-s])
    ans = min(ans, S1[0], S2[0])
    if ans >= 10**5:
        print(-1)
    else:
        print(ans)



if __name__ == "__main__":
    main()

Measured memory_bytes: 74940
#include<iostream>
#include<algorithm>
#include<cstdlib>
 
using namespace std;
 
int n;
 
void countingSort(int *A, int *B, int k){
  int C[10010] = {}; //counter
 
  for(int i = 1;i <= n;i++) C[A[i]]++; //counting
  for(int i = 1;i <= k;i++) C[i] += C[i - 1]; //counting the number of element less than i
  for(int i = n;i >= 1;i--){ //sorting
    B[C[A[i]]] = A[i];
    C[A[i]]--;
  }
}
 
int main(){
 
  int k = 0;
  int *a, *b;

  //input
  cin >> n;
  
  //create two arrays
  //memory allocate
  a = (int *)malloc(sizeof(int) * n + 1);
  b = (int *)malloc(sizeof(int) * n + 1);
  for(int i = 1;i <= n;i++){
    cin >> a[i];
    k = max(k, a[i]); //k is maximun value
  }
 
  countingSort(a, b, k);

  //output
  for(int i = 0;i < n;i++){
    cout << (i?" ":"");
    cout << b[i + 1];
  }
  cout << endl;
 
  return 0;
}



Measured memory_bytes: 18724
import java.util.Scanner;
class Main{
	public static void  main(String[] args){
      Scanner sc = new Scanner(System.in);
      int k = sc.nextInt();
      sc.nextLine();
      String s = sc.nextLine();
      if(s.length() <= k)
        System.out.print(s);
      else
        System.out.print(s.substring(0, k) + "...");

    }
}


Measured memory_bytes: 38772
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define All(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
    int N;
    cin >> N;
    bool ok = false;
    int k=0;
    for(k=0;k<=N;++k){
        if(k*(k+1)==2*N){
            ok = true;
            break;
        }
    }
    if(!ok)cout << "No" << endl;
    else{
        vector<vector<int> > S(k+1,vector<int>());
        int sum = 1;
        int base = 0;
        for(int i=k;i>=1;i--){
            for(int j=1;j<=i;j++){
                S[base].push_back(sum);
                S[base+j].push_back(sum);
                sum++;
            }
            base++;
        }
        cout << "Yes" << endl;
        cout << S.size() << endl;
        rep(i,k+1){
        cout << S[i].size() << " ";
        rep(j,S[i].size())cout << S[i][j] << " ";
        cout << endl;
        }
    }    
    return 0;
}

Measured memory_bytes: 2304
#include "bits/stdc++.h"
#define double long double
#define int long long
#define low lower_bound
#define upp upper_bound
#define mod 1e9+7
#define inf 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec));
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define cend cout<<endl;
#define P pair<int,int>
#define prique priority_queue<P,vector<P>,greater<P>>
using namespace std;

signed main() {
	int a,b,c,d,e,k;
	cin>>a>>b>>c>>d>>e>>k;
	if(e-a<=k) cout<<"Yay!"<<endl;
	else cout<<":("<<endl;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  char a, b;
  ci(a, b);
  if(a == b){
    co('H');
  }
  else{
    co('D');
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  int a, b;
  cin >> n >> a >> b;
  int ans = 0;

  REP(i, n + 1)
  {
    int tmp = i;
    int val = 0;
    while (tmp != 0)
    {
      val += tmp % 10;
      tmp /= 10;
    }
    if (a <= val && val <= b)
    {
      ans += i;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}


int main()
{
  string s ;
  cin >> s ;
  int cnt = 0 ;

  REP(i,4){
    if(s.at(i)=='2'){
      cnt++ ;
    }
  }
  
  cout << cnt <<endl ;
  
    


  return 0 ;
}




Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;

int a,b;
int kq;

int main(){
  cin>>a>>b;
  if (b==1) kq=0;
  else{
    kq=1;int tmp=a;
    while(tmp<b){
      kq++;tmp=tmp+a-1;
    }
    //cout<<"Tmp= "<<tmp<<endl;
  }
  cout<<kq;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std; 
  
typedef long long LL; 
typedef pair<int, int> pii; 
typedef pair<LL, LL> pll; 
typedef pair<string, string> pss; 
typedef vector<int> vi; 
typedef vector<string> vs;
typedef vector<vi> vvi; 
typedef vector<pii> vii; 
typedef vector<LL> vl; 
typedef vector<vl> vvl; 
  
double EPS = 1e-9; 
int INF = 100005; 
long long int mod=1000000007;
long long TES=1000007;
long long INFF = 1000000000000000005LL; 
double PI = acos(-1); 
int dirx[8] = { -1, 0, 0, 1, -1, -1, 1, 1 }; 
int diry[8] = { 0, 1, -1, 0, -1, 1, -1, 1 }; 
  
#ifdef TESTING 
#define DEBUG fprintf(stderr, "====TESTING====\n") 
#define VALUE(x) cerr << "The value of " << #x << " is " << x << endl 
#define debug(...) fprintf(stderr, __VA_ARGS__) 
#else 
#define DEBUG 
#define VALUE(x) 
#define debug(...) 
#endif 
  
#define FOR(a, b, c) for (int(a) = (b); (a) < (c); ++(a)) 
#define FORN(a, b, c) for (int(a) = (b); (a) <= (c); ++(a)) 
#define FORD(a, b, c) for (int(a) = (b); (a) >= (c); --(a)) 
#define FORSQ(a, b, c) for (int(a) = (b); (a) * (a) <= (c); ++(a)) 
#define FORC(a, b, c) for (char(a) = (b); (a) <= (c); ++(a)) 
#define FOREACH(a, b) for (auto&(a) : (b)) 
#define rep(i, n) FOR(i, 0, n) 
#define repn(i, n) FORN(i, 1, n) 
#define MAX(a, b) a = max(a, b) 
#define MIN(a, b) a = min(a, b) 
#define SQR(x) ((LL)(x) * (x)) 
#define RESET(a, b) memset(a, b, sizeof(a)) 
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back 
#define ALL(v) v.begin(), v.end() 
#define ALLA(arr, sz) arr, arr + sz 
#define SIZE(v) (int)v.size() 
#define SORT(v) sort(ALL(v)) 
#define REVERSE(v) reverse(ALL(v)) 
#define SORTA(arr, sz) sort(ALLA(arr, sz)) 
#define REVERSEA(arr, sz) reverse(ALLA(arr, sz)) 
#define PERMUTE next_permutation 
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define TC(t) while (t--)

void solve()
{
   
    LL res=0;
    repn(i,5)
    {
        LL temp;
        cin>>temp;
        if(temp==0)
        res=i;
    }
    cout<<res<<endl;
}
int main()
{
    IOS();
   /* int test;
    cin>>test;
    TC(test)*/
    solve();
    return 0;
}





Measured memory_bytes: 3592
#include <stdio.h>
int main(void){
int H ,W;int i, j;
while(1){scanf("%d %d" ,&H ,&W);
if(H == 0 && W == 0) break;
for ( i = 0; i < H; i++ ){
for ( j = 0; j < W; j++ ){
if(j==0||j==W-1||i==0||i==H-1){
printf("#");}else{printf(".");
}
}
printf("\n");
}
puts("");
}
return 0;
}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    vl A(N);
    in(N,A);
    map<ll,ll> M;
    rep(i,N) M[A[i]]++;
    ll ans = 0;
    rep(i,N) ans += A[i];
    vl res;
    
    int Q;
    cin >> Q;
    rep(i,Q){
        ll B,C;
        cin >> B >> C;
        if(M.count(B)){
            ll aa = M[B];
            ans -= B*aa;
            M.erase(B);
            ans += C*aa;
            M[C] += aa;
        }
        res.pb(ans);
    }
    rep(i,Q) cout << res[i] << endl;
    
    
    

    return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var A = ReadSplitInt().OrderBy(x => x).ToArray();
            var sum = 0;
            for (int i = 1; i < A.Length; i++)
            {
                sum += Abs(A[i - 1] - A[i]);
            }
            Println(sum);
        }


        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <utility>
#include <map>
using namespace std;
#define mp make_pair
typedef long long LL;

const int MAX_N = 1e5;
map<pair<int,int>, int> m;
LL cnt[10];

int main()
{
	int h,w,n;
	scanf("%d %d %d", &h, &w, &n);
	for (int i = 0; i < n; i++)
	{
		int a,b;
		scanf("%d %d", &a, &b);
		a -= 3; b -= 3;
		for (int x = a; x < a+3; x++)
			for (int y = b; y < b+3; y++)
				if (x >= 0 && x < h-2 && y >= 0 && y < w-2)
					m[mp(x,y)]++;
	}
	for (map<pair<int,int>, int>::iterator it = m.begin(); it != m.end(); it++)
		cnt[it->second]++;
	cnt[0] = 1LL * (h-2) * (w-2) - m.size();
	for (int i = 0; i < 10; i++)
		printf("%lld\n", cnt[i]);
}

Measured memory_bytes: 56448
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <climits>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef pair<int,int> pii;
const int INF = 1<<29;
const double PI = acos(-1);
const double EPS = 1e-8;

int M[1000],L[1000],K[1000];
bool flag[1000];
int N, T;
int owaru[1001];

bool check(int num) {
  int aki = num;
  memset(flag,0,sizeof(flag));
  memset(owaru,0,sizeof(owaru));
  int cnt = 0;
  REP(i,T) {
    aki += owaru[i];
    REP(j,N) {
      if (aki == 0) break;
      if (flag[j]) continue;
      if (i%(L[j]+K[j]) <= L[j]) {
        if (i+M[j]>T) return 0;
        aki--;
        owaru[i+M[j]]++;
        cnt++;
        flag[j] = 1;
        if (cnt == N) return 1;
      }
    }
  }
  return 0;
}

int main() {
  while(cin>>N>>T,N||T) {
    REP(i,N) {
      cin >> M[i] >> L[i] >> K[i];
    }
    int ans = -1;
    for (int i=1; i<=N; ++i) {
      if (check(i)) {
        ans = i;
        break;
      }
    }
    cout << ans << endl;
  }
}

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

#define fi first
#define se second
#define fin(s) freopen( s, "r", stdin );
#define fout(s) freopen( s, "w", stdout );

const long long N = 303;
const long long Q = 101;
const long long mod = 1e9 + 7;
const long long block = 250;

using namespace std;

int n;
bool used[N][N];
char c[N][N];
bitset < N > va[N], vb[N];

void solve()
{
        cin >> n;
        for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                        cin >> c[i][j];
                        used[i][j] = 1;
                }
        }
        int ans = 0;
        for(char c = 'a'; c <= 'z'; c++){
                for(int a = 0; a < n; a++){
                        for(int i = 0; i < n; i++){
                                for(int j = 0; j < n; j++){
                                        bool g = 0;
                                        if(::c[(i + a) % n][j] == c){
                                                g = 1;
                                        }
                                        va[i][j] = g;
                                        vb[j][i] = g;
                                }
                        }
                        bool cor = 1;
                        for(int i = 0; i < n; i++){
                                if(va[i] != vb[i]){
                                        cor = 0;
                                        break;
                                }
                        }
                        for(int b = 0; b < n; b++){
                                used[a][b] &= cor;
                        }
                }
        }
        for(int i = 0; i < n; i++){
                for(int j = 0; j < n; j++){
                        ans += used[i][j];
                }
        }
        cout << ans << "\n";
}

bool mtest = false; int main()
{
        //fin("input.txt");
        //fout("output.txt");
        //fin("maze.in");
        //fout("maze.out");
        ios_base::sync_with_stdio(0);
        int TE = 1;
        if(mtest)
                cin >> TE;
        while(TE--)
                solve();
        return 0;
}


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

int main(){
    int n,m;
    cin>>n>>m;
    vector<int>to[100010];
    vector<int>h(n+1,0);
    for(int i=1; i<=n; ++i){
        cin>>h[i];
        to[i].push_back(h[i]);
    }
    rep(i,m){
        int a,b; cin>>a>>b;
        to[a].push_back(h[b]);
        to[b].push_back(h[a]);
    }
    int ans=0;
    for(int i=1; i<=n; ++i){
        sort(to[i].rbegin(),to[i].rend());
        if(to[i].size()==1){
            ans++;
        }
        else{
            if(to[i][0]==h[i]&&to[i][1]<to[i][0])ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
using namespace std;
  
int main(void){
  int n,m,max;
  int i,j,k;
  int car[20000];
  
  while(1){
    max=0;
  
    cin >> n >> m;
    if( n == 0 && m == 0 ) break;
  
    for( i = 0 ; i < n ; i++ ){
      cin >> car[i];
    }
  
    for( j = n ; j < n + m ; j++ ){
      cin >> car[j];
    }
  
    sort( car , car + n+m );
  
    for( k = 0 ; k < n + m ; k++ ){
  
      if( max < car[k] - car[k-1] ) max = car[k] - car[k-1];
  
    }
  
    cout << max << endl;
  
  }
  
  return 0;
  
}

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

int main(){
    string s;
    cin >> s;
    int top = stoi(s.substr(0,2));
    int bottom = stoi(s.substr(2,2));
    if(top>=1 && top <=12 && bottom >= 1&& bottom <=12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }
    if( (top > 12 || top < 1) && (bottom > 12 || bottom < 1) ){
        cout << "NA" << endl;
        return 0;
    }
    if( top>=1 && top <=12){
        cout << "MMYY" << endl;
        return 0;
    }
    if(bottom>=1 && bottom <=12){
        cout << "YYMM" << endl;
        return 0;
    }
}


Measured memory_bytes: 256
# B - ∵∴∵
O = str(input())
E = str(input())
ans =""

if len(O) == len(E):
    for i in range(len(O)):
        ans += O[i]+E[i]
elif len(O) >= len(E):
    for i in range(len(E)):
        ans += O[i]+E[i]
    ans += O[len(O)-1]
elif len(O) >= len(E):
    for i in range(len(O)):
        ans += O[i]+E[i]
    ans += E[len(E)-1]

print(ans)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define OO 1e9
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
typedef long long ll;
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const  int MOD=1e10;
const int N=1e5+9;
const int inf = 1<<30;


template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }


int32_t main() {
    IOS;
string s;
cin>>s;
int ans1=0,ans2=0;
char one='0',two='1';
    for (int i = 0; i < s.size(); ++i) {
        if(s[i]!=one)ans1++;
        if(s[i]!=two)ans2++;
        swap(one,two);
    }
    cout<<min(ans2,ans1);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;
bool f(const vector<int>& v) {
    for (auto num : v) {
        if (num > 1) return false;
    }
    return true;
}

int main() {
    int n;
    cin >> n;
    vector<int> v(n, 0);
    for (int i = 0; i < n; i++) {
        cin >> v[i];
    }
    long long int res = 0;
    vector<int> state(20, 0);
    int b = 0, e = 0;
    for (int i = 0; i < 20; i++) {
        state[i] += (v[0] >> i) % 2;
    }
    while (b < n) {
        while (e < n && f(state)) {
            e++;
            for (int i = 0; i < 20; i++) {
                state[i] += (v[e] >> i) % 2;
            }
        }
        res += e - 1 - b + 1;
        // if (f(state)) res++;
        for (int i = 0; i < 20; i++) {
            state[i] -= (v[b] >> i) % 2;
        }
        b++;
    }
    cout << res << endl;
}


Measured memory_bytes: 4048
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+': 
        print(a + b)
    elif op == '-': 
        print(a - b)
    elif op == '*': 
        print(a * b)
    elif op == '/': 
        print(a // b)
    else: 
        break



Measured memory_bytes: 5596
#include <iostream>
using namespace std;
int main(){
  double t1,t2;
  string ch;
  while( cin >> t1 >> t2){

    if(t1 < 35.5 && t2 < 71){
      ch = "AAA";
    }else if(t1 < 37.5 && t2 < 77){
      ch = "AA";
    } else if(t1 < 40 && t2 < 83){
      ch = "A";
    }else if(t1 < 43 && t2 < 89){
      ch = "B";
    }else if(t1 < 50 && t2 < 105){
      ch = "C";
    }else if(t1 < 55 && t2 < 116){
      ch = "D";
    }else if(t1 < 70 && t2 < 148){
      ch = "E";
    }else ch = "NA";
    cout << ch << endl;
  }
  return 0;
}

Measured memory_bytes: 1216
#include <stdio.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <queue>
#include <cstring>

using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define FIND(x, target) find(x.begin(),x.end(),target)
#define pb(x) push_back(x)
#define output(x) cout<<x<<endl
// #define int long long
#define P pair<int, int>
typedef long long ll;

vector<bool> seen;

const long long int MOD = 1e9+7;
const int INF = -1;

struct _chunk {
	int connect;
	int dist;
	int color;
};

signed main(void) {
  	int N;
  	vector<int> a;
  	vector<int> b;
  	int num[3];
  	int flag = false;
  	rep(i, 3) {
  		num[i] = 0;
  	}
  	cin >> N;
  	rep(i, N) {
  		if (flag == true) break;
  		int tmp;
  		cin >> tmp;
  		a.pb(tmp);
  		if (i == 0) {
  			b.pb(tmp);
  			num[0]++;
  		} else {
  			bool find = false;
  			rep(j, b.size()) {
  				if (tmp == b[j]) {
  					num[j]++;
  					find = true;
  					break;
  				}
  			}
  			if (!find) {
  				b.pb(tmp);
				if (b.size() > 3) {
					flag = true;
				} else {
					num[b.size()-1]++;
				}
  			}
  		}
  	}

  	if (flag == false && num[0] == num[1] && num[1] == num[2] && b.size() == 3) {
  		if (int(b[0]^b[1]) == b[2]) {
  			cout << "Yes" << endl;
  		} else {
  			cout << "No" << endl;
  		}
  	} else if (flag == false && b.size() == 2 && (num[0] == 2 * num[1] || 2 * num[0] == num[1])) {
  		if (num[0] == 2 * num[1]) {
  			if (int(b[0]^b[0]) == b[1]) {
	  			cout << "Yes" << endl;
	  		} else {
	  			cout << "No" << endl;
	  		}
	  	} else if (2 * num[0] == num[1]) {
			if (int(b[1]^b[1]) == b[0]) {

  				cout << "Yes" << endl;
  			} else {
  				cout << "No" << endl;
  			}
  		}
  	} else if (flag == false && b.size() == 1) {
  		if (int(b[0]^b[0]) == b[0]) {
  			cout << "Yes" << endl;
  		} else {
  			cout << "No" << endl;
  		}
  	} else {
  		cout << "No" << endl;
  	}

 
	return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m;
	cin>>n>>m;
	if(m%n==0)
	{
		cout<<m/n;
		return 0;
	}
	int ma=1;
	for(int i=1;i<=m/n+1;i++){
		if(m%i==0&&m/i>=n&&i>ma)
		   ma=i;
	}
	cout<<ma<<endl;
	return 0;
}


Measured memory_bytes: 256
cards = readlines.map(&:split)
  cards.shift

  picture = ["S","H","C","D"]
  number = [*1..13]

  4.times do |timesloop|
    newarray = []
    temparray = cards.select{|sel| sel[0] == picture[(timesloop)]}
    temparray = temparray.map{|a,b| b.to_i}
    newarray = number - temparray
    if newarray.count > 0
      for put in newarray
        puts("#{picture[(timesloop)]} #{put}")
      end
    end
  end


Measured memory_bytes: 6884
// D - Coloring Edges on Tree
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int x){
	char c[10];
	int d; for(d=0; x; d++, x/=10) c[d] = x%10 + '0';
	for(int i=d-1; i>=0; --i) *di++ = c[i];
	*di++ = '\n';
}

int main(){
	int N; cin>>N;
	int G[N], C[N-1];
	rp(i, 0, N-1){
		int p; scanf("%d%d", &p, C+i);
		G[--C[i]] = p-1;
	}

	int K = 1;
	int pre_colors[N]; rp(i, 0, N) pre_colors[i] = 0;

	rp(c, 1, N){
		int p = G[c];
		int color = pre_colors[p] + 1;
		pre_colors[p] = G[c] = color==G[p]? ++color: color;
		K = max(K, color);
	}

	putint(K);
	for(int c:C) putint(G[c]);
	fwrite(dn, 1, di - dn, stdout);
}

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

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

  int res = 0;
  int edA = 0;
  int stB = 0;
  int BandA = 0;
  int inAB = 0;
  for (int i = 0; i < n; i++) {
	string tmp;
	cin >> tmp;

	/*文字列中にABがあるもの */
	string::size_type pos = tmp.find("AB");
	while (pos != string::npos) {
	  inAB++;
	  pos = tmp.find("AB", pos + 2);
	}
	/*文字列の両端がBとAであるもの*/
	if (tmp[0] == 'B' && tmp[tmp.size() - 1] == 'A') {
	  BandA++;
	  continue;
	}
	/*文字列のはじめがBなもの*/
	if (tmp[0] == 'B')
	  stB++;
	/*文字列の終端がAなもの*/
	if (tmp[tmp.size() - 1] == 'A')
	  edA++;
  }
  if (BandA > 0) {
	res += BandA - 1;
	if (stB > 0) {
	  res++;
	  stB--;
	}
	if (edA > 0) {
	  res++;
	  edA--;
	}
  }
  res += min(edA, stB);
  res += inAB;
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

std::vector<std::vector<int>> g;
std::vector<std::string> s, t;
int h, w; 

std::vector<int> vec;
std::vector<bool> used;
bool dfs(int n = 0) {
	if(n == (h + 1) / 2) {
		std::map<std::string, int> mp, uku;
		for(int i = 0; i < w; i++) {
			std::string latte = "";
			for(int j = 0; j < h; j++) {
				latte += s[vec[j]][i];
			}
			
			std::string malta = latte;
			reverse(begin(malta), end(malta));
			if(malta == latte) {
				uku[latte]++;
			} else {
				mp[latte]++;
				mp[malta]--;
			}
		}
		
		for(auto p : mp) if(p.second < 0) return false;
		
		int c = 0;
		for(auto p : uku) c += p.second % 2;
		if(!(w % 2) and c) return false;
		if(w % 2 and c != 1) return false;
		
		return true;
	}
	
	for(int i = 0; i < h; i++) {
		if(used[i]) continue;
		for(auto e : g[i]) {
			if(used[e]) continue;
			if(n != h - n - 1 and i == e) continue;
			vec[n] = i;
			vec[h - n - 1] = e;
			used[i] = true;
			used[e] = true;
			if(dfs(n + 1)) return true;
			used[i] = false;
			used[e] = false;
		}
	}
	
	return false;
}

int main(){
	cin >> h >> w; s.resize(h); t.resize(h); g.resize(h);
	for(int i = 0; i < h; i++) {
		cin >> s[i];
		
		t[i] = s[i];
		sort(begin(t[i]), end(t[i]));
	}
	
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < h; j++) {
			if(t[i] == t[j]) g[i].push_back(j);
		}
	}
	
	if(h == 1) {
		std::vector<int> li(26, 0); int c = 0;
		for(int i = 0; i < w; i++) li[s[0][i] - 'a']++;
		for(int i = 0; i < 26; i++) c += li[i] % 2;
		if(c > 1) cout << "NO" << endl;
		else cout << "YES" << endl;
		return 0;
	} else if(w == 1) {
		std::vector<int> li(26, 0); int c = 0;
		for(int i = 0; i < h; i++) li[s[i][0] - 'a']++;
		for(int i = 0; i < 26; i++) c += li[i] % 2;
		if(c > 1) cout << "NO" << endl;
		else cout << "YES" << endl;
		return 0;
		
	}
		
	
	vec.resize(h, 0);
	used.resize(h, false);
	cout << (dfs() ? "YES" : "NO") << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<string>
#include<cmath>
#include<iostream>
#include<set>
#include<map>
#include<queue>
#include<stack>

using namespace std;

map<char,char> m={{'A','T'},{'C','G'},{'T','A'},{'G','C'}};

int main()
{
    int c;
    c=getchar();

    putchar(m[c]);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int num[]={0,2,5,5,4,5,6,3,7,6};
int a[10];
vector<int> v;
int n,m;
int ma;
vector<string> res;

void dfs(int rest,string s){
    //cout<<rest<<" "<<s<<endl;
    for(int i=0;i<m;i++){
        if(num[a[i]]==num[ma]) continue;
        if(rest-(num[a[i]]-num[ma])<0) continue;
        if(a[i]>ma){
            for(int j=0;j<s.size();j++){
                if(s[j]-'0'==ma){
                    if(rest-(num[a[i]]-num[ma])==0){
                        string t=s;
                        t[j]=char(a[i]+'0');
                        res.push_back(t);
                        break;
                    }else{
                        string t=s;
                        t[j]=char(a[i]+'0');
                        dfs(rest-(num[a[i]]-num[ma]),t);
                        break;
                    }
                }
            }
        }else{
            for(int j=s.size()-1;j>=0;j--){
                if(s[j]-'0'==ma){
                    if(rest-(num[a[i]]-num[ma])==0){
                        string t=s;
                        t[j]=char(a[i]+'0');
                        res.push_back(t);
                        break;
                    }else{
                        string t=s;
                        t[j]=char(a[i]+'0');
                        dfs(rest-(num[a[i]]-num[ma]),t);
                        break;
                    }
                }
            }
        }
    }
    return;
}

int main(){
  cin>>n>>m;
  int mit=10;
  for(int i=0;i<m;i++){
      cin>>a[i];
      v.push_back(a[i]);
      if(num[a[i]]<mit){
          mit=num[a[i]];
          ma=a[i];
      }else if(num[a[i]]==mit){
          ma=max(ma,a[i]);
      }
  }
  sort(v.begin(),v.end());

  string ans;
  int x=n;
  for(;;){
      if(x-mit>=0){
          ans+=char(ma+'0');
          x-=mit;
      }else break;
  }
  //cout<<x<<endl;
  //cout<<ans<<endl;
  if(x==0) cout<<ans<<endl;
  else{
      /*int tmp=0;
      for(int k=0;k<=ans.size();k++){
          bool flag=false;
          for(int j=0;j<m;j++){
              if(num[a[j]]==num[ma]) continue;
              if(x%(num[a[j]]-num[ma])==0&&x/(num[a[j]]-num[ma])<=ans.size()) flag=true;
          }
          if(flag) break;
          else{
              ans.pop_back();
              x+=num[ma];
          }
      }*/
      //cout<<ans<<" "<<tmp<<endl;
      /*if(ans.size()==0){
          char sa='0';
          for(int i=0;i<m;i++){
              if(num[a[i]]==n){
                  sa=max(sa,char(a[i]+'0'));
              }
          }
          cout<<sa<<endl;
          return 0;
      }*/
      dfs(x,ans);
      while(res.size()==0){
          ans.pop_back();
          x+=num[ma];
          dfs(x,ans);
      }
      string so=res[0];
      for(int i=0;i<res.size();i++){
          so=max(so,res[i]);
          //cout<<res[i]<<endl;
      }
      //sort(res.begin(),res.end());
      //reverse(res.begin(),res.end());
      cout<<so<<endl;
  }
  

  return 0;
}


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

using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os; }

void solve() {
  int N;
  cin >> N;
  vector<int> A(N), B(N);
  
  ll sumA = 0, sumB = 0;
  for (int i = 0; i < N; i++) {
    cin >> A[i];
    sumA += A[i];
  }
  for (int i = 0; i < N; i++) {
    cin >> B[i];
    sumB += B[i];
  }

  if (sumA > sumB) {
    cout << "No" << endl;
    return;
  }

  ll need = 0;
  for (int i = 0; i < N; i++) {
    if (A[i] > B[i]) continue;
    need += (B[i] - A[i] + 1) / 2;
  }

  if (sumB - sumA < need) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }

}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  cout.setf(ios::fixed);
  cout.precision(16);
  solve();
  return 0;
}

Measured memory_bytes: 384
n = int(input())
a =  list(map(int, input().split()))

b = []
count = 0
for v in a:
    if v < 0:
        count += 1
        b.append(-v)
    else:
        b.append(v)
if count % 2 == 1:
    b = sorted(b)
    print(sum(b) - 2 * b[0])
else:
    print(sum(b))

Measured memory_bytes: 14332
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
int main(){
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin >> n;
	ll ret = 0;
	vector<int>prime(1e6 + 5, true);
	prime[1] = false;
	for(int p=2; p*p<=1e6; p++){
		if(prime[p]){
			for(int i=p*p; i<=1e6; i += p)
				prime[i] = false;
		}
	}
	for(ll i=1; i<=n; i++){
		for(ll j=1; j<=n; j++){
			if(i*j > n){
				break;
			}
			if(n - (i*j) > 0) {
				ret++;
			}
		}
	}
	cout << ret << endl;
	return 0;
}


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



int main() {

//変数の宣言

	int i,j;


/////メイン処理/////

	for(i=0;i<9;i++){
		for(j=0;j<9;j++){
			cout << i+1 << "x" << j+1 << "=" << (i+1) * (j+1) << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* main */

signed main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> a(N);
    FOR(i,0,N)cin >> a[i];
    vector<ll> b(N,0),c(N,0);
    FOR(i,1,N)b[i] = max(0,a[i-1])+b[i-1];
    REP(i,0,N-1)c[i] = max(0,a[i+1])+c[i+1];
    FOR(i,1,N)a[i] += a[i-1];
    ll ans = 0;
    FOR(i,0,N-K+1){
        chmax(ans,b[i] + max(0,a[i+K-1]-(i ? a[i-1] : 0)) + c[i+K-1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2560
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def gcd_list(numbers):
    return reduce(math.gcd, numbers)

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n,x = map(int,input().split())
x = [abs(int(i) - x) for i in input().split()]

print(gcd(*x))

Measured memory_bytes: 20864
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, r;
    cin >> n >> r;
    if(n >= 10) cout << r << endl;
    else cout << r + (100) * (10 - n) << endl;

    return 0;
}


Measured memory_bytes: 256
//２つの整数 a, b と１つの演算子 op を読み込んで、a op b を計算するプログラム   
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main()
{
	int a, b;//整数
	char op = 'x';//文字
	while (1)//∞ループ
	{
		scanf("%d %c %d", &a, &op, &b);
	if (op == '+') {
		printf("%d\n", a + b);
	}
	else  if (op == '-') {
		printf("%d\n", a - b);
	}
	else if (op == '*') {
		printf("%d\n", a * b);
	}
	else if (op == '/') {
		printf("%d\n", a / b);
	}
	else 
		break;//終了
		

			}
	
	return 0;
 }


Measured memory_bytes: 2064
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

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

func min(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v < ret {
			ret = v
		}
	}
	return ret
}

func main() {
	sc.Split(bufio.ScanWords)
	a := []int{nextInt(), nextInt(), nextInt()}
	sort.Sort(sort.IntSlice(a))
	up := abs(a[1]-a[0]) + abs(a[2]-a[1])
	down := abs(a[1]-a[2]) + abs(a[0]-a[1])
	fmt.Println(min(up, down))
}


Measured memory_bytes: 640