akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>


#define REP(i,N) for(auto i = 0; i <N; i++)
const int MAX = INT_MAX;
using namespace std;
typedef long long ll;


int in(){
    int temp;
    scanf("%d",&temp);
    return temp;
}

ll lin(){
    ll temp;
    scanf("%lld",&temp);
    return temp;
}



int main() {

    int N = in();
    vector<int> C;
    vector<int> S;
    vector<int> F;
    
    int c,s,f;
    for(auto i = 0; i< N-1; i++){
        cin >> c >> s >> f;
        C.push_back(c);S.push_back(s);F.push_back(f);
    }
    
    int t;
    int st;
    for(auto s = 0; s<N-1; s++){
        t = S[s];
        st = s;
        while(st != N-1){
            
            t = max(S[st],t);
            
            while(t%F[st]!= 0){ ///可能な出発時刻まで進める。
                t++;
            }
            
            t += C[st];
            st++;
            
        }
        
        
        cout << t << endl;
    }
    
    
    
    
    cout << 0 << endl; ////最初から駅N
    
    return 0;
}




                          




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    for(int i=1;i<=9;i++){
        int x=n/i;
        if((n%i)==0&&x<=9){cout<<"Yes"<<endl;return 0;}
    }
    cout<<"No"<<endl;
    return 0;
}


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

int N;
int A[2][101];
int s1[101], s2[101];

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

	s1[0] = A[0][0];
	for (int i = 1; i <= N; i++) {
		s1[i] = s1[i - 1] + A[0][i];
	}
	s2[N - 1] = A[1][N - 1];
	for (int i = N - 2; i >= 0; i--) {
		s2[i] = s2[i + 1] + A[1][i];
	}

	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, s1[i] + s2[i]);
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

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

    string s, t;
    cin >> s >> t;

    for(int i = 0; i < n; i++){
        cout << s[i];
        cout << t[i];
    }

    cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
    #include<ext/pb_ds/assoc_container.hpp> 
    #include<ext/pb_ds/tree_policy.hpp>
    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>;
    #define int long long  
    typedef long double ld;
    typedef long long ll;
    #define pb push_back
    #define f(i,a,b) for(int i=a;i<b;i++)
    #define fd(i,a,b) for(int i=a-1;i>=b;i--)
    #define pf push_front
    #define fi first
    #define se second
    #define take(a,n) f(i,0,n)cin>>a[i];
    #define show(a,n) f(i,0,n){cout<<a[i]<<" ";}
    #define ashow(a)  for(auto i:a)cout<<i<<" ";
    #define khtm     cout<<endl;
    #define all(s) s.begin(),s.end()
    #define len(a) a.length()
    #define INF 1e18
    #define MAXN 2000009
    const double pi=3.14159265358979323;
    const int mod=1e9+7;
    int ng(int n){
      int i=0;
      while(n>pow(2,i))
        i++;
      i--;
      return pow(2,i)-1-n;

    }
     signed main() {
     // -------------------------------------Code starts here--------------------------------------------------------------------- 
    int t=1;
    // cin>>t;
    while(t--)
    {
        int n,k,x=0,y=0;
        int mx=-1,mi=INF,mn=INF;
        int tm=0;
        vector<int>ans;
        string s;

      // cin>>n;
      int a[100005];
            int  p[n+2]={};
      for(int i=1;i<100005;i++)
        {cin>>a[i];
          if(a[i]==0){cout<<i<<endl;break;}
        }
       
         


        }


 }

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repe(i,n) for(int i=0;i<n;i++)
#define repa(i,j,n) for(int i=j;i<n;i++)
//#define v.all() v.begin(),v.end()
#define repr(i,n) for(int i=n;i>=0;i--)
#define int long long int
#define vi vector<int>
#define vpi vector<pair<int,int>>

signed  main(){
	int t=1;
	//cin>>t;
	while(t--) {
		int n;
		cin>>n;
		cout<<n*n*n<<endl;
	}
	return 0;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
#define VI vector<int>
#define VVI vector<vector<int>>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> A(H);
  REP(i, H) cin >> A[i];
  vector<int> w, h;
  for (int i = 0; i < H;i++){
    bool flag = true;
    for (int j = 0; j < W;j++){
      if(A[i][j]=='#')
        flag = false;
    }
    if(flag)
      h.push_back(i);
  }
  for (int i = 0; i < W;i++){
    bool flag = true;
    for (int j = 0; j < H;j++){
      if(A[j][i]=='#')
        flag = false;
    }
    if(flag)
      w.push_back(i);
  }

  int widx = 0, hidx = 0;
  for (int i = 0; i < H; i++) {
    if(hidx<h.size()&&i==h[hidx]){
      hidx++;
      continue;
    }
    widx = 0;
    for (int j = 0; j < W; j++) {
      if(widx<w.size()&&j==w[widx]){
      widx++;
      continue;
      }
      cout << A[i][j];
    }
    cout << endl;
  }

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    double r;
    double square, length;

    scanf("%lf", &r);
    square = 3.141592653589 * r * r;
    length = 2 * 3.141592653589 * r;
    printf("%lf %lf\n", square, length);

    return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
 
using namespace std;
int main() {
    long long n;
    cin >> n;
    
    long long a[200010];
    long long ans[200010]={0};
    
    for(int i=2;i<=n;i++){
        cin >> a[i];
    }
    for(int i=2;i<=n;i++){
        ans[a[i]]++;
    }
    
    for(int i=1;i<=n;i++){
        cout << ans[i] << endl;
    }
    return 0;
}



Measured memory_bytes: 6764
from itertools import product, permutations

INF=1145141919810

N,M,R=map(int,input().split())
r=map(int,input().split())

road=[[0 if x==y else INF for y in range(N+1)] for x in range(N+1)]

for _ in range(M):
	a,b,c=map(int,input().split())
	road[a][b] = road[b][a] = c

for k,i,j in product(range(N+1), repeat=3):
	road[i][j] = min(road[i][j], road[i][k] + road[k][j])

print(min(sum(road[p[i-1]][p[i]] for i in range(1, R)) for p in permutations(r)))


Measured memory_bytes: 48600
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

const lint mod = 1e9 + 7;

lint nPn(lint i) {
  lint ret = 1ll;
  for (lint j = 1ll; j <= i; j++) {
    ret = (ret * j) % mod;
  }
  return ret;
}

int main() {
  lint n, m, ans;
  cin >> n >> m;
  lint tmp = (nPn(n) * nPn(m)) % mod;

  if (n == m)
    ans = (tmp * 2ll) % mod;
  else if (n == m + 1 || n + 1 == m)
    ans = tmp;
  else
    ans = 0;
  cout << ans << endl;
  // cout << nPn(2) << " " << nPn(4) << endl;
}

Measured memory_bytes: 256
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef cc_hash_table<int,int,hash<int>> ht;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
double p[MAXN], dp[MAXN];

int main()
{
    int n;
    ni(n);
    for (int i = 0; i < n; i++)
        scanf("%lf", &p[i]);
    dp[0] = 1 - p[0];
    dp[1] = p[0];
    for (int i = 1; i < n; i++) {
        for (int j = i + 1; j > 0; j--)
            dp[j] = (1 - p[i]) * dp[j] + p[i] * dp[j - 1];
        dp[0] = (1 - p[i]) * dp[0];
    }
    double ans = 0;
    for (int i = (n + 1) / 2; i <= n; i++)
        ans += dp[i];
    printf("%.15f\n", ans);
    return 0;
}


Measured memory_bytes: 2304
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] s = scanner.nextLine().split(" ");
        int n = Integer.parseInt(s[0]);
        int k = Integer.parseInt(s[1]);
        s = scanner.nextLine().split(" ");
        int an[] = new int[s.length];
        for (int i = 0; i < s.length; i++) {
            an[i] = Integer.parseInt(s[i]);
        }

        for (int i = k + 1; i <= n; i++) {
            if (an[i - k - 1] < an[i - 1]) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
        scanner.close();
    }
}


Measured memory_bytes: 72972
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define COUT(x) cout<<(x)<<endl
#define dump(x)  cout << #x << " = " << (x) << endl;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
using M = map<int,int>;
using PQ = priority_queue<int>;
using PQG = priority_queue<int, vector<int>, greater<int>>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

string S;
int K,N;
set<string> ans;

void dfs(string s, int i) {
  if (s.size() > K || i >= N) { ans.insert(s); return; }
  dfs(s+S[i],i+1);
  if (!s.empty()) ans.insert(s);
}

int main() {
  cin >> S >> K;
  N = S.size();

  REP(i,N) {
    string s;
    dfs(s, i);
  }

  auto it = ans.begin();
  REP(i,K-1) it++;
  COUT(*it);
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define ceiv(a, b) (1 + (int)((a) - 1)/(int)(b))
//#define int long long

signed main(){
    int x; cin >> x;
    int ans = 1;
    for(int i=2; i*i<=x; i++){
        int p = i * i;
        while(p * i <= x) p *= i;
        ans = max(ans, p);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define MAXN (int)1e5

#define REP(i,s,n) for (int i = (s); i < (n); ++i)
#define rep(i,n) REP(i,0,n)
int n;
long long int x[100005], a, b;
long long int ans;

int main() {

  std::cin >> n >> a >> b;
  rep(i,n) std::cin >> x[i];
  ans=0;
  for(int i = 0; i < n-1; ++i) {
    if ((x[i+1]-x[i]) * a > b) {
      ans += b;
    } else {
      ans += (x[i+1]-x[i]) * a;
    }

  }
  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i=0; i < n; i++)
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x, y, z) max((x), max((y), (z)))
#define tmin(x, y, z) min((x), min((y), (z)))
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
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;}
const ll INF = 1LL << 60;
//cout << fixed << setprecision(10);

int main(){
    string s;
    cin>>s;
    if(s == "ABC") cout<< "ARC";
    else cout<<"ABC";
}

Measured memory_bytes: 3640
# 再帰関数の最大回数を増やす
import sys
sys.setrecursionlimit(1000000)

import math

def gcd(i, j):
    """
    2値 i, j の最大公約数を求める。
    """

    if j == 0:
        return i
    else:
        return gcd(j, i % j)

def factorize(n):
    """
    素因数分解した個数を返す
    """
    count = 1
    rep = math.ceil(math.sqrt(n))
    for i in range(2, rep + 1):
        if n % i != 0:
            continue
        else:
            count += 1
            while n % i == 0:
                n /= i
        if n == 1:
            return count
    if n != 1:
        count += 1
    return count

def main():
    a, b = map(int, input().split())

    #最大公約数を求める
    x = gcd(a, b)

    #最大公約数を素因数分解する
    count = factorize(x)

    #結果を出力する
    print(count)

main()

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

int main() {
    ull n, k, ans = 0;
    cin >> n >> k;
    vector<ull> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end(), greater<ull>());
    // rep(i, n) cout << "i=" << i << ",h=" << h[i] << endl;
    if(n > k) {
        for(int i = k; i < n; i++) {
            ans += h[i];
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4752
/**
 *    author        : Sudipta Banik Trisha 
 *    created       : July 11, 2020 9:50 PM
 *    Problem Name  : A - Duplex Printing
 *    Problem Limit : 2000 ms , 1024 MB
 *    Problem Url   : https://atcoder.jp/contests/abc157/tasks/abc157_a
**/

#include<bits/stdc++.h>
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;

    if(n%2==0)
        cout << n/2 << endl;
    else cout << (n/2)+1 << endl;

    return 0 ;
}


Measured memory_bytes: 3640
//https://atcoder.jp/contests/abc143/tasks/abc143_b
#include<bits/stdc++.h>
using namespace std;
int main()
{
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        int n ;
        cin >> n ;
        int arr[n];
        for(int i = 0; i < n; i++) { cin >> arr[i]; }
        long long int ans = 0 ;
        for(int i = 0; i < n; i++)
        {
                for(int j = i+1; j < n ;j++)
                {
                        int p = arr[i] * arr[j];
                       // cout << p << endl ;
                        ans += p ;
                }
        }
        cout << ans << endl ;
}

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

int main(){
    int n;
    cin>>n;
    vector<int> vec(n);
    for(int i=0;i<n;i++){
        cin>>vec.at(i);
    }
    int Sum=0;
    for(int i=0;i<n;i++){
        Sum+=vec.at(i);
    }
    int a=Sum/2;
    int b=0;
    int c;
    for(int i=0;i<n;i++){
        b+=vec.at(i);
        if(b>=a){
            c=i;
            break;
        }
    }
    //2s1-sum
    int s=0;
    for(int i=0;i<=c;i++){
        s+=vec.at(i);
    }
    int t=0;
    for(int i=0;i<c;i++){
        t+=vec.at(i);
    }
    int ans;
    if(2*t-Sum<0){
        ans=min(2*s-Sum,Sum-2*t);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int height, width;
	char work[256] ={};

	scanf( "%d%d", &height, &width );

	for (int i=0; i < height; i++)
	{
		scanf( "%s", work );

		for (int j=0; j < 2; j++)
		{
			printf( "%s\n", work );
		}
	}

	return 0;
}

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

int main(){
    ll nll ; cin >> nll;
    bitset<32> base("10101010101010101010101010101010");
    ll basell = -1 * base.to_ullong();
    bitset<32> n(nll-basell);
    bitset<32> ans = (base ^ n);
    bool flag = false;
    for(int i=31;i>=0;i--){
        if(ans.test(i)) flag = true;
        if(flag){
            cout << (int)(ans.test(i)) ;
        }
    }
    if(!nll) cout << 0;
}


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

int main() {
    long long int X, y = 0;
    long long int yokin = 100;
    cin >> X;
    while(yokin < X){
        yokin = yokin * 1.01;
        y++;
    }
    cout << y << endl;
    return 0;
}

Measured memory_bytes: 3624
import fractions
import collections
import math
A,B = map(int,input().split())
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    
    return arr
Gcd = fractions.gcd(A,B)
ans = factorization(Gcd)
print(len(ans)+1)


Measured memory_bytes: 5048
import sys

def selection_sort(x):
    count = 0
    for i in range(0,len(l)-1):
        mini = i
        for j in range(i+1,len(l)):
            if(x[j] < x[mini]):
                mini = j
        if(mini != i):
            count += 1
            temp = x[i]
            x[i] = x[mini]
            x[mini] = temp
    for data in x:
        print data,
    print
    print count


l = []
for input in sys.stdin:
    l.append(input)
l = l[1:]
l = l[0].split()
for i in range(0,len(l)):
    l[i] = int(l[i])
selection_sort(l)


Measured memory_bytes: 4672
#include <bits/stdc++.h>
 
typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;
 
#define for01(k,n)  for (ll i=k; i<n; i++)
#define for02(k,n)  for (ll j=k; j<n; j++)
#define for03(k,n)  for (ll k=k; k<n; k++)
#define for11(k,n)  for (ll i=k; i<=n; i++)
#define for12(k,n)  for (ll j=k; j<=n; j++)
#define for13(k,n)  for (ll k=k; k<=n; k++)

#define pb push_back
#define mp make_pair
#define vll vector<ll>
#define F first
#define S second
#define pp pair <ll, ll>
#define lb lower_bound
#define ub upper_bound
#define emp empty()
#define beg begin()
#define en end()
#define si size()
#define bk back()
#define deci(n)  fixed<<setprecision(n)

#define p0(a) cout << a << " "
#define p1(a) cout << a << "\n"


#define MAX LLONG_MAX

#define MIN LLONG_MIN

using namespace std;

int main()
{
   string s;
   cin >> s;
   char alph[30];
    for(int i = 0; i < 30; i++) 
      alph[i] = 0;
    int len = s.length();
    for(int i = 0; i < len; i++)
    {
        alph[s[i]-'a']++;
    }
    for(int i = 0; i < 30; i++)
    {
        if(alph[i] % 2 != 0) 
        {
          p1("No");
          return 0;
        }
    }
    p1("Yes");
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string N;
  cin >> N;
  if (N[0] == N[1] && N[1] == N[2]){
    cout << "Yes" << endl;
  }
  else if (N[1] == N[2] && N[2] == N[3]){
    cout << "Yes"<< endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
char a[10010];
int b[10010];
int main()
{
	int n,i;
	scanf("%d%s",&n,a);
	int l=strlen(a); 
	for(i=0;i<l;i++)
	    b[i]=a[i]-64;
	for(i=0;i<l;i++)
	{
		b[i]+=n;
		if(b[i]%26==0)b[i]=26;
		else if(b[i]>26)b[i]%=26;
	}
	for(i=0;i<l;i++)
	    printf("%c",b[i]+64);
	printf("\n");		   
}

Measured memory_bytes: 256
import numpy as np

if __name__ == "__main__":
    S = input()
    N = len(S)
    ans1 = 0
    ans2 = 0
    for i in range(N):
        if((i % 2) == int(S[i])):
            ans1 += 1
        else:
            ans2 += 1
    print(min(ans1, ans2))

Measured memory_bytes: 21244
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdlib>
#include<bitset>
#include<utility>
#include<sstream>
#include<iomanip>
#include<ctime>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;

#define ll long long
#define MP make_pair

int h,w,num=0;
vector<string> s(100);
queue<pair<int,int>> q;
int vis[100][100]={};


void dfs(int ih,int iw){
    if(ih>=1){
        if(s[ih-1][iw]=='.'&&vis[ih-1][iw]==-1){
            vis[ih-1][iw]=vis[ih][iw]+1;
            q.push(MP(ih-1,iw));
        }
    }
    if(ih<h-1){
        if(s[ih+1][iw]=='.'&&vis[ih+1][iw]==-1){
            vis[ih+1][iw]=vis[ih][iw]+1;
            q.push(MP(ih+1,iw));
        }

    }
    if(iw>=1){
        if(s[ih][iw-1]=='.'&&vis[ih][iw-1]==-1){
            vis[ih][iw-1]=vis[ih][iw]+1;
            q.push(MP(ih,iw-1));
        }

    }
    if(iw<w-1){
        if(s[ih][iw+1]=='.'&&vis[ih][iw+1]==-1){
            vis[ih][iw+1]=vis[ih][iw]+1;
            q.push(MP(ih,iw+1));
        }

    }


    return;
}


int main(void) {
    for (int i = 0; i < 100; i++) {
        for (int j = 0; j < 100; j++) {
            vis[i][j]=-1;
        }
    }

    cin>>h>>w;

    for (int ih = 0; ih < h; ih++) {
        cin>>s[ih];
        for (int iw = 0; iw < w; iw++) {
            if(s[ih][iw]=='#')num++;
        }
    }

    vis[0][0]=1;
    dfs(0,0);
    while(!q.empty()){
        dfs(q.front().first,q.front().second);
        q.pop();
    }

    if(vis[h-1][w-1]==-1){
        cout<<-1<<"\n";
    }else{
        cout<<h*w-num-vis[h-1][w-1]<<"\n";
    }

    

    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD 1000000007

// #define DEBUG_F
 
typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template <class T>
void print(T& x){printf("%d\n", x);}
void printvec(vector<int> a){
    rep(i, a.size()-1){
        printf("%d ", a[i]);
    }
    printf("%d\n", a[a.size()-1]);
}

struct Node{
    int x;
    Node *prev;
    Node *next;
};

Node ed;
Node *cur, *head;

Node *newNode(){
    Node *p = (Node*)malloc(sizeof(Node));
    return p;
}

void insert(int x){
#ifdef DEBUG_F
    printf("insert(%d)\n", x);
#endif

    Node *p;
    p = newNode();
    p->x = x;
    p->next = cur;
    p->prev = cur->prev;
    if(cur->prev==NULL){
        head = p;
    }else{
        cur->prev->next = p;
    }
    cur->prev = p;
    cur = p;
}

void move_(int d){
#ifdef DEBUG_F
    printf("move(%d)\n", d);
#endif

    if(d>0){
        rep(i, d) cur = cur->next;
    }else if(d<0){
        rep(i, -d) cur = cur->prev;
    }
}

void erase(){
#ifdef DEBUG_F
    printf("erase()\n");
#endif
    if(cur->prev==NULL){ //先頭にいる
        cur->next->prev = NULL;
        cur = cur->next;
        head = cur;
    }else{
        cur->prev->next = cur->next;
        cur->next->prev = cur->prev;
        cur = cur->next;
    }
}
 
int main()
{
    ed.next = NULL;
    ed.prev = NULL;
    ed.x = INT32_MAX;
    cur = &ed;
    head = &ed;

    int q;
    cin >> q;

    int com, d;
    rep(i, q){
        cin >> com;
        if(com == 0){
            cin >> d;
            insert(d);
        }else if(com==1){
            cin >> d;
            move_(d);
        }else if(com==2){
            erase();
        }
#ifdef DEBUG_F
        Node *tmp = head;
        while(tmp->next != NULL){
            if(tmp==cur) printf(">");
            print(tmp->x);
            tmp = tmp->next;
        }
#endif
    }
#ifdef DEBUG_F
    printf("\n");
#endif
    while(head->next != NULL){
        print(head->x);
        head = head->next;
    }
    return 0;
}


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

int main() {
  int a,b,c,d,e,k,i;
  cin >> a >> b >> c >> d >> e >> k;
  i=0;
  
  if( b-a <= k){
    i += 1;
  }
  if( c-a <= k){
    i += 1;
  }
  if( d-a <= k){
    i += 1;
  }
  if (c-b <= k){
    i += 1;
  }
  if(d-b <= k){
    i += 1;
  }
  if(e-b <= k){
    i += 1;
  }  
  if(e-a <= k){
    i += 1;
  }
  if(d-c <= k){
    i += 1;
  }
  if(e-c <= k){
    i  +=1;
  }
  if(e-d <= k){
    i +=1;
  }  
  if (i == 10){
    cout << "Yay!";
  }
  else{
    cout <<":(";
  }
  
  
             
   
             
}


Measured memory_bytes: 256
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define fst first
#define snd second
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {
	
	ll N;
	cin >> N;
	vll A(N + 2, 0), B(N + 1, 0);
	fori(i, 1, N + 1) cin >> A[i];
	rep(i, N + 1) B[i] = A[i + 1] - A[i];

	ll ans = 0;
	rep(i, N + 1) ans += abs(B[i]);
	fori(i, 1, N + 1) cout << ans + abs(B[i - 1] + B[i]) - abs(B[i - 1]) - abs(B[i]) << endl;
}

Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,m;cin>>n>>m;
  vector<int >a(n,0),b(n,0),c(m,0),d(m,0);
  for(int i=0;i<n;i++)cin>>a[i]>>b[i];
  for(int i=0;i<m;i++)cin>>c[i]>>d[i];
  for(int i=0;i<n;i++){
  	int index = 0;
    int mini = abs(a[i]-c[0])+abs(b[i]-d[0]);
  		for(int j=1;j<m;j++){
        	if(abs(a[i]-c[j])+abs(b[i]-d[j])<mini){
            	mini = abs(a[i]-c[j])+abs(b[i]-d[j]);
              index = j;
            
            }
        
        }
    cout<<index+1<<'\n';
  }
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        HashMap<Integer,Integer> map = new HashMap<Integer,Integer>();
        for(int i=0;i<n;i++){
            int a = Integer.parseInt(sc.next());
            if(map.containsKey(a)){
                map.put(a, map.get(a)+1);
            }else{
                map.put(a, 1);
            }
        }
        int ans = 0;
        for(int key: map.keySet()){
            int a = map.get(key);
            ans += key>a?a:(a-key);
        }
        System.out.println(ans);
    }
}


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

using namespace std;

#define MAX 100005
#define MAX_N 105

#define int int64_t

int n, w, a[MAX], b[MAX], dp[MAX_N][MAX];

int f(int i, int r)
{
    if (r < 0)
        return LONG_LONG_MIN / 2;
    if (i == n)
        return 0;
    if (dp[i][r] != -1)
        return dp[i][r];
    dp[i][r] = max(f(i + 1, r - a[i]) + b[i], f(i + 1, r));
    return dp[i][r];
}

signed main()
{
    scanf("%lld %lld", &n, &w);
    for (int i = 0; i < n; i++)
        scanf("%lld %lld", a + i, b + i);
    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= w; j++)
            dp[i][j] = -1;
    // printf("%lld %lld\n", n, w);
    printf("%lld\n", f(0, w));
}


Measured memory_bytes: 80128
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(a); (i)<(b); ++(i))
#define rFor(i, a, b) for(int (i)=(a)-1; (i)>=(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef complex<double> xy_t;

const lint mod = 1e9 + 7;

int n;
vector<int> G[200010];
int d[200010];

void dfs(int v, int prev, int dep){
    d[v] = dep;
    for(int nv: G[v])if(nv != prev) dfs(nv, v, dep+1);
    return;
}

int main(){
    scanf("%d", &n);
    rep(i, n-1){
        int a, b;
        scanf("%d%d", &a, &b);
        G[--a].push_back(--b);
        G[b].push_back(a);
    }
    
    rep(i, n) d[i] = -1;
    dfs(0, -1, 1);
    int v, dmax;
    dmax = 0;
    rep(i, n)if(d[i] > dmax){
        dmax = d[i];
        v = i;
    }
    
    rep(i, n) d[i] = -1;
    dfs(v, -1, 1);
    rep(i, n) dmax = max(dmax, d[i]);
    
    printf(dmax % 3 == 2 ? "Second\n" : "First\n");
}

Measured memory_bytes: 21376
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int n; cin >> n; string S; cin >> S; bool one = false;
  rep(i, n){
    if(S[i]=='3') S[i]='2';
    else if(S[i]=='2') S[i]='1';
    else S[i]='0';
  }
  rep(i, n){
    if(S[i]=='1') one=true;
  }
  int ans = 0;
  if(!one){
    rep(i, n){
      if(S[i]=='2') S[i]='1';
    }
  }
  rep(i, n){
    if(n-1 == (i|(n-1-i)) && S[i]=='1') ans++;
  }
  ans%=2;
  if(!one) ans*=2;
  cout << ans << endl;
}

Measured memory_bytes: 1412
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N,H; cin >> N >> H;
  vector<pair<int,int>> X(N);
  
 for(int i = 0; i < N; i++){ cin >> X[i].first >> X[i].second;}
  
  sort(X.rbegin(),X.rend());
  
  vector<int> thrown; int shake = X[0].first;
  
  for(int i = 0; i < N; i++){
   thrown.push_back(X[i].second);}
  
  sort(thrown.begin(), thrown.end());
  int itr = upper_bound(thrown.begin(),thrown.end(),shake) - thrown.begin();
  int c = (int) thrown.size(); c--;
  int cnt = 0; 
  while( c >= itr && H > 0){ H -= thrown[c];  c--; cnt++;}
  if( H > 0){ cnt += (H+shake-1)/shake ;} 
  cout << cnt << endl; return 0;}

Measured memory_bytes: 1660
//C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

//Hang in there!

using namespace std;


int main() {
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	cout << min(A, B) + min(C, D) << endl;
}



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

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

	cin >> N;
	for (int i = 0; i < N; i++) cin >> C[i];

	sort(C, C + N, greater<int>());
	A = 0;
	B = 0;
	for (int i = 0; i < N; ++i) {
		if (i % 2 == 0) {
			A += C[i];
		}else{
			B += C[i];
		}
	}
	cout << A - B << endl;
}




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

namespace arc069_a
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = GetDecimalList();
            var N = NM[0];
            var M = NM[1];
            decimal r = 0;

            r += Math.Min(N, Math.Floor(M / 2));
            M -= r * 2;
            r += Math.Floor(M / 4);

            Console.WriteLine(r);
        }

        public static string GetStr() => Console.ReadLine();
        public static int GetInt() => int.Parse(Console.ReadLine());
        public static long GetLong() => long.Parse(Console.ReadLine());
        public static double GetDouble() => double.Parse(Console.ReadLine());
        public static decimal GetDecimal() => decimal.Parse(Console.ReadLine());

        public static List<string> GetStrList() => Console.ReadLine().Split(' ').ToList();
        public static List<int> GetIntList() => Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToList();
        public static List<long> GetLongList() => Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
        public static List<double> GetDoubleList() => Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToList();
        public static List<decimal> GetDecimalList() => Console.ReadLine().Split(' ').Select(x => decimal.Parse(x)).ToList();

    }
}


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

typedef long long ll;
const int MOD = 1e9 + 7;
const int maxn = 1.5 * 1e5;

ll f[maxn + 5], inv[maxn + 5];
ll ans = 1;

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

void init() {
    f[0] = 1;
    for(int i = 1; i <= maxn; i++)
        f[i] = f[i-1] * i % MOD;
    inv[0] = 1;
    inv[maxn] = powab(f[maxn], MOD-2);
    for(int i = maxn-1; i > 0; i--)
        inv[i] = inv[i+1] * (i + 1) % MOD;
}

int main() {
    int n, m;
    cin >> n >> m;
    init();
    for (int i = 2; i * i <= m; i++) {
        if (m % i == 0) {
            int cnt = 0;
            while (m % i == 0) {
                m /= i;
                cnt++;
            }
            ans = (ans % MOD) * f[n + cnt - 1] % MOD * inv[n - 1] % MOD * inv[cnt] % MOD;
        }
    }
    if (m != 1) ans = ans % MOD * n % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,c=0,a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    while(a%2==0){
      a/=2;
      c++;
    }
  }
  cout<<c;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    REP(i, n)
    {
        cin >> a[i];
        mp[a[i]]++;
    }
    sort(ALL(a));
    reverse(ALL(a));
    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        int x = a[i];
        if(mp[a[i]]==0){
            continue;
        }
        mp[a[i]]--;
        int idx = 0;
        for (int j = 0; j < 40; j++)
        {
            if( (1LL<<j) > x ){
                idx = j;
                break;
            }
        }
        int y = (1LL << idx) - x;
        //cerr << y << endl;
        if (mp[y] > 0)
        {
            ans++;
            mp[y]--;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 26752
n,m,x = map(int,input().split())
a = [int(_) for _ in input().split()]

cnt = 0
while a[cnt] < x and cnt != m-1:
    cnt += 1
cnt2 = 0
while a[m - 1 - cnt2] > x and m - 1 - cnt2 != 0:
    cnt2 += 1
print(min(cnt,cnt2))

Measured memory_bytes: 3060
import sys
import numpy as np
from numba import njit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit
def slove(A):
  count = np.zeros(10**6 + 10, np.int32)
  for x in A:
    if count[x] > 1:
      continue
    count[::x] += 1
  ret = 0
  for x in A:
    ret += count[x] == 1
  return ret

A = np.array(read().split(), np.int32)[1:]

print(slove(A))

Measured memory_bytes: 123016
#include <iostream>

using namespace std;

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

    cin >> a >> b >> c;

    if(a >= b && a >= c) {
        max = a;
    } else if(b >= a && b >= c) {
        max = b;
    } else {
        max = c;
    }

    cout << (max*9)+a+b+c << endl;

    return 0;
}

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

typedef long long ll;

#define int ll
#define all(v) v.begin(), v.end()
#define reps(__i, a, b) for (int __i = a; i < b; i++)
#define rep(__i, n) reps(__i, 0, n)

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    cin >> n;
    cout << (180 * (n - 2)) << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		long ans = 0;
		for(int i=1;i<=N-1;i++) {
			ans += i;
		}
		System.out.println(ans);
	}
}

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

int main() {
  int n, k;
  cin >> n >> k;
  long long h[n];
  for ( int i = 0; i < n; i++ ) {
    cin >> h[i];
  }
  sort(h, h+n);

  long long ans = 0;
  for ( int i = 0; i < n-k; i++ ) {
    ans += h[i];
  }

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


Measured memory_bytes: 5132
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    ll n = 0;
    cin >> n;
    for (int i=(int)sqrt(n); i>0; i--) {
        if (n%i == 0) {
            ll buf = n/i;
            int digit = 0;
            while (buf > 0) {
                buf /= 10;
                digit++;
            }
            cout << digit << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<string>
#include<iomanip>
#include<bits/stdc++.h>
using namespace std;

/*define*/
#define rep(i, n) for(int i=0; i<n; ++i)
#define endl "\n"
typedef long long ll;

const long long mod = 1e18;
const long long INF=1e9;
int ci;

int main(){
    int n;
    double d;
    cin >> n >> d;
    vector<pair<ll, ll>> P(n);
    ll x, y;
    rep(i, n){
        cin >> x >> y;
        P[i] = {x, y};
    }
    int ans=0;
    rep(i, n){
        double D;
        x = P[i].first; y= P[i].second;
        D = sqrt(x*x + y*y);
        if(D<=d) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6524
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            long ans = long.MinValue;
            string[] s = Console.ReadLine().Split(' ');

            int N = int.Parse(s[0]);
            int M = int.Parse(s[1]);

            long[][] value = new long[4][];

            for(int i=0;i<4;i++)
            {
                value[i] = new long[N];
            }


            for(int i=0;i<N;i++)
            {
                s = Console.ReadLine().Split(' ');

                long x = long.Parse(s[0]);
                long y = long.Parse(s[1]);
                long z = long.Parse(s[2]);

                value[0][i] += x;
                value[1][i] += x;
                value[2][i] += x;
                value[3][i] += x;

                value[0][i] += y;
                value[1][i] -= y;
                value[2][i] += y;
                value[3][i] -= y;

                value[0][i] += z;
                value[1][i] -= z;
                value[2][i] -= z;
                value[3][i] += z;
            }

            for(int i=0;i<4;i++)
                Array.Sort(value[i]);
    
            for(int i=0;i < 4;i++)
            {
                long min = 0;
                long max = 0;

                for(int j=0;j<M;j++)
                {
                    min += value[i][j];
                    max += value[i][N - j - 1];
                }

                min = Math.Abs(min);
                max = Math.Abs(max);

                if(min > max)
                {
                    if (min > ans)
                        ans = min;
                }
                else
                {
                    if (max > ans)
                        ans = max;
                }
            }

            Console.WriteLine(ans.ToString());
        }
    }
}


Measured memory_bytes: 13356
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  string S;
  cin >> S;

  if(S[1] == 'B') cout << "ARC" << endl;
  else cout << "ABC" << endl;
  
  return 0;
}


Measured memory_bytes: 3624
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 200010;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int fac[IMAX + 1], ifac[IMAX + 1], inv[IMAX + 1];
	constexpr unko() : fac(), ifac(), inv() {
		fac[0] = 1;
		rep1(i, IMAX) fac[i] = ll(fac[i - 1]) * i % mod;
		ifac[IMAX] = modpow(fac[IMAX], mod - 2);
		for (int i = IMAX; i > 0; i--) ifac[i - 1] = ll(ifac[i]) * i % mod;
		inv[0] = 1;
		rep1(i, IMAX) inv[i] = ll(ifac[i]) * fac[i - 1] % mod;
	}
	int comb(int A, int B) {
		return ll(fac[A]) * ifac[B] % mod * ifac[A - B] % mod;
	}
} f;

int N;
const int VN = 200000;
int to[VN * 2 + 2], ne[VN * 2 + 2], he[VN + 1];
int n[VN + 1];
void dfs(int v, int prev) {
	int kazu = 1;
	for (int i = he[v]; i; i = ne[i]) {
		int t = to[i];
		if (t != prev) {
			dfs(t, v);
			kazu += n[t];
		}
	}
	n[v] = kazu;
}
void dfs2(int v, int prev) {
	for (int i = he[v]; i; i = ne[i]) {
		int t = to[i];
		if (t != prev) {
			n[t] = ll(n[v]) * n[t] % mod * f.inv[N - n[t]] % mod;
			dfs2(t, v);
		}
	}
}

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

	
	cin >> N;
	int k = 2;
	rep1(i, N - 1) {
		int a, b;
		cin >> a >> b;

		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}
	dfs(1, -1);
	ll tmp = 1;
	rep1(i, N) tmp = (tmp * n[i]) % mod;
	n[1] = modpow(tmp, mod - 2) * f.fac[N] % mod;
	for (int i = he[1]; i; i = ne[i]) {
		int t = to[i];
		n[t] = ll(n[1]) * n[t] % mod * f.inv[N - n[t]] % mod;
		dfs2(t, 1);
	}
	rep1(i, N) co(n[i]);

	Would you please return 0;
}

Measured memory_bytes: 6912
s = gets.chomp.to_s.split(//)
s.delete_at(-1)

while s.size > 1
  if s.size.odd?
    s.delete_at(-1)
  else
    if s[0..(s.size / 2 - 1)] == s[(s.size / 2)..-1]
      puts s.size
      exit
    else
      s.delete_at(-1)
    end
  end
end


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e5 + 10;
int ok[MAXN];
int main()
{
	int X;
	cin >> X;
	for (int i = 100; i <= 105; i++)
	{
		ok[i] = 1;
	}
	for (int i = 106; i <= 100000; i++)
	{
		int res = 0;
		for (int j = 100; j <= 105; j++)
		{
			res = res | ok[i - j];
		}
		ok[i] = res;
	} 
	cout << ok[X] << endl;
	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int sum = 0;
		int t[] = new int[n];
		for(int i = 0;i < n;i++){
			t[i] = sc.nextInt();
			sum += t[i];
		}
		int m = sc.nextInt();
		for(int i = 0;i < m;i++){
			System.out.println(sum-t[sc.nextInt()-1]+sc.nextInt());
		}
	}
}


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

int DPFibonacci(int x, vector<bool> v){
  ll dp[1000010] = {0};
  dp[0] = 1;
  for(int i = 1; i < x+1; i++){
    if(v[i] == false){
      dp[i] = 0; continue;
    }
    if(i==1 && v[1] == true){ dp[1] = 1; continue; }
	dp[i] = dp[i-1] + dp[i-2];  //cout << dp[i] << endl;
    dp[i] %= 1000000007;
  }
  return dp[x];
}

int main() {
  int n,m; cin >> n >> m;
  vector<bool> v(1000010,true);
  rep(i, m){
    int c; cin >>c;
    v[c] = false;
  }
  
  cout << DPFibonacci(n, v) << endl;
  
}

Measured memory_bytes: 11688
#include <iostream>
#include <algorithm>
#include <map>
#include <regex>
#include <string>
#include <cstdlib>
#include <math.h>
using namespace std;
int main() {
  int N;
  cin >> N;

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

  string X;
  cin >> X;

  int cnt = 0;
  bool f = false;
  for (int i = 0; i < N; i++) {
    if (f) cnt += t[i];
    if (s[i] == X) f = true;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  n <- readInt
  arr <- readIntList
  let s = sum arr
      l = s `div` n
      u = (s + n - 1) `div` n
      scoreL = foldl' (\acc val -> acc + (val - l)^2) 0 arr
      scoreU = foldl' (\acc val -> acc + (val - u)^2) 0 arr
  print $ min scoreL scoreU


Measured memory_bytes: 508