akhauriyash/Code-Regression huggingface dataset:
/* Simplicity and Goodness */

#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;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//             tree_order_statistics_node_update> indexed_set;

void my_dbg() { cout << endl; }
template<typename Arg, typename... Args> void my_dbg(Arg A, Args... B)
{ cout << ' ' << A; my_dbg(B...); }
#define dbg(...)  cout << "(" << #__VA_ARGS__ << "):", my_dbg(__VA_ARGS__)

#define scn(n) scanf("%d", &n)
#define lscn(n) scanf("%lld", &n)
#define pri(n) printf("%d ", (int)(n))
#define prin(n) printf("%d\n", (int)(n))
#define lpri(n) printf("%lld ", n)
#define lprin(n) printf("%lld\n", n)
#define rep(i,a,b) for(int i=(int)(a); i<(int)(b); i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;

const int inf = INT_MAX;
const int ninf = INT_MIN;
const int mod = 1e9+7;
const int maxN = 5e5+2;

vi vals(4 * maxN), a(maxN);
int n;

void update(int i, int x, int lx, int rx)
{
    if(rx == lx) {
        vals[x] ^= 1;
        return;
    }
    int m = (lx + rx) / 2;
    if(i <= m) {
        update(i, 2 * x, lx, m);
    } else {
        update(i, 2 * x + 1, m + 1, rx);
    }
    vals[x] = vals[2 * x] + vals[2 * x + 1];
}

void update(int i)
{
    update(i, 1, 1, n);
}

int query(int l, int r, int x, int lx, int rx)
{
    if(l > rx or lx > r) return 0;
    if(lx >= l and rx <= r) return vals[x];
    int m = (lx + rx) / 2;
    int s1 = query(l, r, 2 * x, lx, m);
    int s2 = query(l, r, 2 * x + 1, m + 1, rx);
    return s1 + s2;
}

int query(int l, int r)
{
    return query(l, r, 1, 1, n);
}

int main()
{
    int q;
    scn(n); scn(q);

    rep(i, 1, n+1)
    scn(a[i]);

    vector<pair<int, int>> ask[n+1];
    vector<int> ans(q);

    rep(i, 0, q) {
        int l, r;
        scn(l); scn(r);
        ask[r].emplace_back(l, i);
    }    

    map<int, int> fnd;

    rep(i, 1, n+1) {
        if(!fnd.count(a[i])) {
            fnd[a[i]] = i;
            update(i); 
        } else {
            update(fnd[a[i]]);
            fnd[a[i]] = i;
            update(i);
        }

        sort(ask[i].begin(), ask[i].end());

        for(auto it : ask[i]) {
            int l = it.F, id = it.S;
            int res = query(l, i);
            ans[id] = res;
        }
    }

    for(auto i : ans)
        prin(i);

    return 0;
}

Measured memory_bytes: 60576
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
//FILE *fi = freopen("1.txt", "r", stdin);
//FILE *fo = freopen("1", "w", stdout);
//FILE *fi = freopen("P.inp", "r", stdin);
//FILE *fo = freopen("P.out", "w", stdout);
bool used[1000001];
void bfs(int x)
{
    queue<int> q;
    if (used[x])
        return;
    q.push(x);
    used[x] = true;
    while (q.size())
    {
        int u = q.front();
        q.pop();
        used[u] = true;
        u += x;
        if (u <= 1e6 && !used[u])
            q.push(u);
    }
    return;
}
int a[1000001];
int Min[1000001];
int main()
{
    //------------------------------
    // Faster
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //------------------------------
    int N = 1e6;
    for (int i = 1; i <= N; i++)
        Min[i] = i;
    for (int i = 2; i <= sqrt(N); i++)
    {
        for (int j = i; j <= N; j += i)
        {
            Min[j] = min(Min[j], i);
        }
    }
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
    }
    bool ok = false;
    int G = 0;
    for (int i = n; i >= 1; i--)
    {
        G = __gcd(G, a[i]);
        if (a[i] == 1)
            continue;
        vector<int> U;
        while (a[i] > 1)
        {
            int x = Min[a[i]];
            if (used[x])
            {
                ok = true;
            }
            U.push_back(x);
            a[i] /= x;
        }
        for (auto x : U)
            bfs(x);
    }
    if (ok == false)
    {
        cout << "pairwise coprime";
    }
    else if (ok == true && G == 1)
    {
        cout << "setwise coprime";
    }
    else
    {
        cout << "not coprime";
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define pb              push_back
#define PII             pair <int,int>
#define PLL             pair <ll,ll>
#define mp              make_pair
#define xx              first
#define yy              second
#define all(v)          v.begin(),v.end()

#define lt              2*n
#define rt              2*n+1
#define clft            2*n,st,mid
#define crgt            2*n+1,mid+1,ed

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define eps             1e-9
#define PI              acos(-1.0)
#define MAX             100010
#define INF             2000000000

/******************************************************************************************/

#define mod1            1000000007
#define mod2            1000000123
#define base            100001

vector <ll> ed[MAX];
ll has1[MAX],has2[MAX];
map <PLL,ll> M;

void dfs(ll u,ll p)
{
    ll i,v,h1 = 0,h2 = 0;
    for(i=0;i<ed[u].size();i++){
        v = ed[u][i];
        if(v==p) continue;
        dfs(v,u);
        h1 += has1[v];
        h2 += has2[v];
        h1 %= mod1;
        h2 %= mod2;
    }
    has1[u] = (h1*base + 1)%mod1;
    has2[u] = (h2*base + 1)%mod2;
    M[mp(h1,h2)]++;
}

int main()
{
    //ios_base::sync_with_stdio(false);
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    ll n,i,u,v;
    cin >> n;
    for(i=1;i<n;i++){
        cin >> u >> v;
        ed[u].pb(v);
        ed[v].pb(u);
    }
    dfs(1,0);

    ll ans = 0;
    map <PLL,ll> :: iterator it = M.begin();
    while(it!=M.end()){
        ans += (it->second*(it->second-1))/2;
        it++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24220
fn main() {
    // 問題文中で使われる変数の型宣言をしておく。
    let k: i64;
    // 【入力段ここから】
    // 定型句 bufにstdinから1行読み込む。読み込んだ後、CRLFが入りっぱなしになっている点に注意。
    let mut buf: String;
    buf = String::new();
    let stdin_obj = std::io::stdin();
    stdin_obj.read_line(&mut buf).ok();
    // 定型句 buf（Str）に読み込んだ文字列をi64にパースしてnに代入。
    k = buf.trim().parse().ok().unwrap();
    // 【入力段ここまで】
    // NOTE: 下記は解説見たあとで実装だけ書いた
    // 【計算段】
    let mut a: i64 = 7 % k;
    for i in 1..k + 1 {
        if a == 0 {
            println!("{}", i);
            return;
        } else {
            a *= 10;
            a += 7;
            a %= k;
        }
    }
    println!("{}", -1);
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	map<char,int> mp;
	rep(i,4){
		char c; cin>>c;
		mp[c]++;
	}
	int cnt=0;
	for(auto i:mp){
		cnt++;
		if(i.second!=2) {
			cout<<"No"<<endl;
			return 0;
		}
	}
	if(cnt!=2) {
		cout<<"No"<<endl;
		return 0;
	}
	cout<<"Yes"<<endl;
	return 0;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,N) for(int i=0; i<N; i++)
#define cinv(v,N) vector<int> v(N); for(int i=0; i<N; i++){ cin >> v[i]; }
#define mt make_tuple
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main()
{
  //input
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  string S; cin >> S;
  int ans = 0;
  
  //main
  if(S == "MON"){ ans = 6;
  }else if(S == "TUE"){ ans = 5;
  }else if(S == "WED"){ ans = 4;
  }else if(S == "THU"){ ans = 3;
  }else if(S == "FRI"){ ans = 2;
  }else if(S == "SAT"){ ans = 1;
  }else if(S == "SUN"){ ans = 7;
  }
  
  // output
  cout << ans << endl;
                       
  return 0;
}

Measured memory_bytes: 256
#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++)
#define mod 1000000007
#define pi 3.141592653589793
typedef vector<ll> vcl;

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a, ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t =rep_jijo(n,x/2);
        return t*t%mod;
  }
  return n*rep_jijo(n,x-1)%mod;
}
ll c2(ll n){
    return n*(n-1)/2;
}

int main() {
    ll a,b,h,m;
    double hs,ms,s,c,ans;
    cin >>a>>b>>h>>m;
    hs=2*pi*h/12+2*pi*m/12/60;
    ms=2*pi*m/60;
    s=hs-ms;
    if(s<0)s=-s;
    if(s>pi)s=2*pi-s;
c=a*a+b*b-2*a*b*cos(s);
ans=sqrt(c);
printf("%.10lf",ans);
}


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

int f(int size){
	if( size <= 60 )
		return 600;
	else if( size <= 80 )
		return 800;
	else if( size <= 100 )
		return 1000;
	else if( size <= 120 )
		return 1200;
	else if( size <= 140 )
		return 1400;
	else if( size <= 160 )
		return 1600;
	
	return 0;
}

int g(int w){
	if( w <= 2 )
		return 600;
	else if( w <= 5 )
		return 800;
	else if( w <= 10 )
		return 1000;
	else if( w <= 15 )
		return 1200;
	else if( w <= 20 )
		return 1400;
	else if( w <= 25 )
		return 1600;

	return 0;
}

int main(){
	int n;
	while( cin >> n , n ){
		int x,y,h,w,sum=0;

		for(int i=0 ; i < n ; i++ ){
			cin >> x >> y >> h >> w;
			int size = x+y+h;
			if( f(size) && g(w) ){
				sum += max( f(size) , g(w) );
			}
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
using namespace std ;
int main(){
    int x , y , number[101] , i , j , k , cn= 0 ;
    while ( 1 ){
        cn = 0 ;
    cin >> x >> y ;
    if ( x + y == 0 ) break ;
    for ( i = 1 ; i<=x ; i ++ ){
        number[i] = i ;
    }
    for ( i = 1 ; i <= x ; i ++ ){
        for ( j = i + 1 ; j <= x ; j ++ ){
            for ( k = j + 1 ; k <= x ; k ++ ){
                if ( number[i] + number[j] + number[k] == y ){
                    cn ++ ;
                }
            }
        }
    }
    cout << cn << endl ;
}
	return 0;
}

Measured memory_bytes: 3124
#include<stdio.h>

#define MAX_ARRAY 100001

void MergeSort(int array1[],int array2[],int Left,int Right){

    int i,j,k,center;
    int work_A[MAX_ARRAY],work_CO[MAX_ARRAY];

    if(Left<Right){
        center = (Left + Right)/2;
        MergeSort(array1,array2,Left,center);
        MergeSort(array1,array2,center+1,Right);

        for(i = center;i >= Left;i--){
            work_A[i] = array1[i];
            work_CO[i] = array2[i];
        }
        for(j = center + 1;j <= Right;j++){
            work_A[Right-(j-(center+1))] = array1[j];
            work_CO[Right-(j-(center+1))] = array2[j];
        }

        i = Left;
        j = Right;

        for(k = Left;k <= Right;k++){
            if(work_A[i] < work_A[j]){
                array1[k] = work_A[i];
                array2[k] = work_CO[i];
                i++;
            }else{
                array1[k] = work_A[j];
                array2[k] = work_CO[j];
                j--;
            }
        }
    }
}

int main(void){

    int A[MAX_ARRAY],ComeOrder[MAX_ARRAY];
    int N,i;

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

    MergeSort(A,ComeOrder,0,N-1);

    for(i = 0;i < N;i++){
        printf("%d ",ComeOrder[i]);
    }

    printf("\n");

    return 0;
}

Measured memory_bytes: 14848
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <vector>
#include <stack>
using namespace std;
typedef long long ll;
int n,k,ans,y;
int a[200005];
int main(void){
    cin>>n>>k;
    for(int i=0;i<n;i++){
        int x;
        cin>>x;
        if(a[x]==0)y++;
        a[x]++;
    }
    sort(a,a+200002);
    int i=0;
    for(;a[i]==0;i++);
    for(int j=0;j<y-k;j++)ans+=a[i+j];
    cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,x;
    cin>>a>>b;
    c=((a-1)+a);
    d=((b-1)+b);
    e=(a+b);
    x=max(c,d);
    cout<<max(x,e);

    return 0;
}




Measured memory_bytes: 256
def main():
    a_count = 0
    b_count = 0
    ab_count = 0
    o_count = 0
    while True:
        try:
            x,y = map(str,input().split(','))
            if y == 'A':
                a_count += 1
            elif y == 'B':
                b_count += 1
            elif y == 'AB':
                ab_count += 1
            else:
                o_count += 1
        except EOFError:
            break
    print('{}\n{}\n{}\n{}'.format(a_count,b_count,ab_count,o_count))

if __name__ == '__main__':
    main()


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

int main(){long N;
cin >> N;
vector<long> a(N);
rep(i, N) cin >> a.at(i);
sort(a.begin(), a.end());

long num = 0; long ans = 0;
while(num < N){
    long numlow = lower_bound(a.begin(), a.end(), a.at(num)) - a.begin();
    long numupp = upper_bound(a.begin(), a.end(), a.at(num)) - a.begin();
    long check = (numupp - numlow) % 2;
    if(check == 1) ans++;
    num = numupp;
}

// cout << numlow << endl;
// cout << numupp << endl;
// cout << check << endl;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(int i=m;i<n;i++)
#define OKawaiiKoto ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const ll INF=2*1e18;
const ld PI=3.14159265358979323846;
ll ans[60005];
int main()
{
    OKawaiiKoto
    rep1(i,100) rep1(j,100) rep1(k,100) ans[i*i+j*j+k*k+i*j+j*k+k*i]++;
    ll n;
    cin>>n;
    rep1(i,n) cout<<ans[i]<<"\n";
}


Measured memory_bytes: 3956
<?php
while (true) {
    list($height, $width) = getSpacesByExplodeTrimInput();

    if ($height == 0 && $width == 0) {
        break;
    }

    $edge = setRectangleEdgePart($width);
    $middle = setRectangleMiddlePart($height, $width);
    echo $edge.$middle.$edge, PHP_EOL;
}

function setRectangleEdgePart($width)
{
    return sprintf('%s%s', str_repeat('#', $width), PHP_EOL);
}

function setRectangleMiddlePart($height, $width)
{
    $middle  = sprintf('%s%s', '#'.str_repeat('.', $width - 2).'#', PHP_EOL);
    return str_repeat($middle, $height - 2);
}

function getSpacesByExplodeTrimInput()
{
    return explode(' ', trim(fgets(STDIN)));
}

Measured memory_bytes: 15320
#include<bits/stdc++.h>
#define F first
#define S second
#define endl '\n'
#define lcm( a, b ) ((a)/__gcd(a,b)*(b))
#define MP make_pair
#define pb push_back
#define all(x) (x).begin(),(x).end()

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<int, P> i_P;
typedef pair< LL, LL > L_P;

const int INF = INT_MAX;
const int MIN = INT_MIN;
const LL LINF = LLONG_MAX;
const int MOD = 1000000000 + 7;
const int SIZE = 100005;

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

    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    vector< int > v;
    for( int i = 0; i < n; ++i ) {
        if( s[i] != t[i] ) {
            ++i;
            v.pb( 2 );

        } else {
            v.pb( 1 );

        }
    }

    LL res;
    if( v[0] == 1 ) {
        res = 3;

    } else {
        res = 6;

    }

    for( int i = 1; i < v.size(); ++i ) {
        if( v[i - 1] == 1 ) {
            res = ( res * 2 ) % MOD;

        } else {
            if( v[i] == 2 ) {
                res = ( res * 3 ) % MOD;

            }
        }
    }
    cout << res << endl;
    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1012345678;
int main() {
	vector<int> A(5);
	cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
	vector<int> P = { 4, 3, 2, 1, 0 };
	int final_answer = inf;
	do {
		int ans = 0;
		for (int i = 0; i < 5; ++i) {
			while (ans % 10 != 0) ans += 1;
			ans += A[P[i]];
		}
		final_answer = min(final_answer, ans);
	} while (prev_permutation(P.begin(), P.end()));
	cout << final_answer << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ar array
#define endl '\n'
#define ll long long
#define in insert
#define pb push_back
#define vt vector
#define P_Q(x) priority_queue<x>
#define p_q(x) priority_queue<x, vector<x>, greater<x>>
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Rev(i,a,b) for(ll i=a;i>=b;i--)
#define FOR(m) Rep(i,1,m)
#define For(m) Rep(i,0,m-1)
#define Rbl(x,a) for(auto &x : a)
#define FIO ios::sync_with_stdio(0);   cin.tie(0);
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mp make_pair
#define vpii vector<pii>
#define vpll vector<pll>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
const ll INF = 0x3f3f3f3f3f3f3f3fll;
#define mod 1000000007
 
const int mxN = 1e5 + 1;
int a[mxN];
vt<int> dp(mxN, 2e9);
ll n, k;
 
 
int main()
{
FIO
 
    cin >> n >> k;
    FOR(n) cin >> a[i];
    dp[1] = 0; 
    Rep(i,1,n)
    {
        for(int j = i+1; j <= min(i+k, n); j++)
        {
            dp[j] = min( dp[j], dp[i] + abs(a[j] - a[i]) );
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 4048
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
typedef unsigned long long ll;

// 最大公約数求める関数
int my_gcd(int n , int m){
  if(n < m){
    int tmp = n;
    n = m;
    m = tmp;
  }
  int l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return m;
}

//char⇒int関数
 int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}



int main(){
int N; cin >> N;
string S; cin >> S;
int cnt = 0;
rep(i,N-2){

  if(S.substr(i, 3) == "ABC"){
  
    cnt++;
  }
}
  cout << cnt << endl;
  }


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

int N;
vector<long long> x, y;

int solve() {
    if (N == 1) return 1;

    int res = N;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            if (i == j) continue;
            long long dx = x[j] - x[i], dy = y[j] - y[i];

            int sub = 0;
            for (int i2 = 0; i2 < N; ++i2) {
                for (int j2 = 0; j2 < N; ++j2) {
                    if (j2 == i2) continue;
                    if (dx == x[j2] - x[i2] && dy == y[j2] - y[i2]) ++sub;
                }
            }
            res = min(res, N - sub);
        }
    }
    return res;
}

int main() {
    cin >> N;
    x.resize(N); y.resize(N);
    for (int i = 0; i < N; ++i) cin >> x[i] >> y[i];
    cout << solve() << endl;
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, m;
char buf[10];

int main() {
    scanf("%d%d", &n, &m);
    int ii = -1;
    int jj = -1;
    forn(i, n) forn(j, m) {
        scanf("%s", buf);
        if (string(buf) == "snuke") {
            ii = i;
            jj = j;
        }
    }
    printf("%c%d\n", char('A' + jj), ii + 1);
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <vector>
#include <complex>
#include <utility>
#define X real()
#define Y imag()
#define EPS 1e-10
using namespace std;
typedef complex<double> P;
typedef vector<P> Poly;
typedef pair<P,P> L;

namespace std{
  bool operator<(const P& a, const P& b){
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }

  bool cmp_y(const P &a, const P &b){
    return a.Y != b.Y ? a.Y < b.Y : a.X < b.X;
  }
}

double cross(P a, P b){
  return a.X*b.Y - a.Y*b.X;
}

Poly convex_hull(Poly v){
  int n = v.size(), k = 0;
  sort(v.begin(), v.end(), cmp_y);
  Poly r(2*n);
  for(int i = 0; i < n; i++){
    while(k>1 && cross(r[k-1]-r[k-2],v[i]-r[k-2]) < -EPS)k--;
    r[k++] = v[i];
  }
  for(int i = n-2, t = k; i >= 0; i--){
    while(k>t && cross(r[k-1]-r[k-2],v[i]-r[k-2]) < -EPS)k--;
    r[k++] = v[i];
  }
  r.resize(k-1);
  return r;
}

int main(){
  int n;
  cin >> n;
  double x, y;
  Poly p;
  for(int i = 0; i < n; ++i){
    cin >> x >> y;
    p.push_back(P(x,y));
  }
  Poly ans = convex_hull(p);
  cout << ans.size() << endl;
  for(int i = 0; i < ans.size(); ++i){
    printf("%d %d\n", (int)ans[i].X, (int)ans[i].Y);
  }
  return 0;
}

Measured memory_bytes: 9232
#include <iostream>
#include <algorithm>
#include <string>
#include <stack>
#include <cstdlib>
#include <queue>
#include <vector>
#include <set>
#include <stdio.h>
#include <cstdio>
#include <cmath>
#include <complex> 
using namespace std;
typedef complex<double> xy_t;
xy_t P[4];
double x,y;
double a,b,c;
int main() {
	int i=0;
while (cin >> x >> y) {
	P[i] = xy_t(x,y);
	i += 1;
	if (i == 4) {
	a =  ((P[0]-P[3]).real()*(P[1]-P[3]).imag()-(P[0]-P[3]).imag()*(P[1]-P[3]).real())/2;
	b =  ((P[1]-P[3]).real()*(P[2]-P[3]).imag()-(P[1]-P[3]).imag()*(P[2]-P[3]).real())/2;
	c =  ((P[2]-P[3]).real()*(P[0]-P[3]).imag()-(P[2]-P[3]).imag()*(P[0]-P[3]).real())/2;
	bool p = a*b > 0 && b*c > 0;
cout << (p ? "YES" : "NO") << endl;
i = 0;
}
}
}

Measured memory_bytes: 1216
h,w=map(int,input().split())
s=[[i for i in input().split()] for i in range(h)]

for i in range(h):
    for j in range(w):
        if s[i][j]=='snuke':
            r=i+1
            s=chr(j+97).upper()
            print(s+str(r))
            exit()
        
        

Measured memory_bytes: 3060
import java.util.*;
public class Main{
  public static void main(String []args){
    Scanner sc=new Scanner(System.in);
    long N = sc.nextLong();
    
    long x=0;
    long y=0;
    long min=N;
    for(int i=1;i<=Math.sqrt(N);i++){
      if(N%i==0){
        x=i-1;
        y=N/i-1;
     }
     min=Math.min(min,x+y);
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 23764
s=input()

ans=int(len(s)/2)
for i in range(26):
	temp=0
	tempAns=0
	if s.count(chr(i+97))!=0:
		for j in s:
			if j==chr(i+97):
				tempAns=max(temp,tempAns)
				temp=0
			else:
				temp+=1
		tempAns=max(temp,tempAns)
		ans=min(ans,tempAns)
		#print(tempAns)
print(ans)

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

if len(str(N)) == 1:
    ans = N
else:
    s = list(str(N))
    S = s[1:]
    #print(S)
    #print(['9']*((len(str(N)))-1))
    if S == ['9']*((len(str(N)))-1):
        ans = int(str(N)[0]) + 9 * (len(str(N))-1)
        #print('YYY')
    else:
        ans = int(str(N)[0]) + 9 * (len(str(N))-1) - 1

print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
int main() {
	int n, m, k, sum = 1;
	cin >> n >> m;
	REP(i, n) { cin >> k; }
	n -= m;
	m--;
	sum += n / m + (n % m == 0 ? 0 : 1);
	cout << sum;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char s[4];
  scanf("%s",&s);
  int count=0;
  
  for(int i=0;i<3;i++){
   
      if(s[i]==s[i+1]){
        count++;
      
    }
  }
  if(count==0){
    printf("Good");
  }else{
    printf("Bad");
  }
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long int ll;

const ll mod=1e9+7;

ll N,K;
ll A[100005];

ll fact[200005];
ll fact_inv[200005];

class Comb{
public:
    Comb(ll N){
        fact[0]=1;
        fact_inv[0]=1;
        for(int i=1;i<=N;++i){
            fact[i]=fact[i-1]*i%mod;
            fact_inv[i]=modPow(fact[i],mod-2);
        }
    }

    ll modPow(ll a, ll n) {
        if(n==1)return a%mod;
        if (n%2==1)return(a*modPow(a,n-1))%mod;
        ll t=modPow(a,n/2);
        return (t*t)%mod;
    }

    ll comb(ll n,ll r){
        return (((fact[n]*fact_inv[r])%mod)*fact_inv[n-r])%mod;
    }
};

int main(){
    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>A[i];
    sort(A,A+N);
    ll ans=0;
    Comb C(N);
    for(int i=0;i<N;++i){
        ll max=0,min=0;
        if(i>=K-1)max=A[i]*C.comb(i,K-1)%mod;
        if(N-i-1>=K-1)min=A[i]*C.comb(N-i-1,K-1)%mod;
        ans+=(max-min+mod)%mod;
        ans%=mod;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
n,m,k = list(map(int,input().split(" ")))
a = list(map(int,input().split(" ")))
b = list(map(int,input().split(" ")))
cnt = 0
ans = 0
j = m
t = sum(b)

for i in range(n+1):
    while j>0:
        if t>k: #aのみの場合の処理が足りない（常にjでスキップされてしまう）
            j -= 1
            t -= b[j]
        else:break
    if t<=k:ans = max(ans,i+j)
    if i==n:break
    t += a[i]
print(ans)

Measured memory_bytes: 40392
use io::*;
use std::cmp::max;

fn main() {
    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let es: Vec<(usize, usize)> = (0..n - 1)
        .map(|_| {
            let f: usize = sc.next();
            let t: usize = sc.next();
            (f - 1, t - 1)
        })
        .collect();

    let mut g: Vec<Vec<usize>> = vec![vec![]; n];

    for &(f, t) in es.iter() {
        g[f].push(t);
        g[t].push(f);
    }

    let mut ans = (n + 1, 0);

    for root in 0..n {
        let t = bfs(&g, &[root]);
        if t < ans {
            ans = t;
        }
    }

    for &(f, t) in es.iter() {
        let t = bfs(&g, &[f, t]);
        if t < ans {
            ans = t;
        }
    }

    println!("{} {}", ans.0, ans.1);
}

fn bfs(g: &Vec<Vec<usize>>, start: &[usize]) -> (usize, usize) {
    let mut cur: Vec<usize> = start.iter().cloned().collect();

    let mut dep = 0;
    let mut leafs = start.len();
    let mut used = vec![false; g.len()];

    for &c in start.iter() {
        used[c] = true;
    }

    while cur.len() > 0 {
        let mut next = vec![];
        let mut maxl = 0;

        for &c in cur.iter() {
            if dep == 0 && start.len() == 1 {
                maxl = max(maxl, g[c].len());
            } else {
                maxl = max(maxl, g[c].len() - 1);
            }

            for &d in g[c].iter() {
                if used[d] {
                    continue;
                }
                used[d] = true;
                next.push(d);
            }
        }

        if maxl != 0 {
            leafs *= maxl;
        }

        dep += 1;

        cur = next;
    }

    (dep, leafs)
}

//-----

pub mod io {
    use std;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T>(&mut self) -> T
        where
            T: std::str::FromStr,
            <T as std::str::FromStr>::Err: std::fmt::Debug,
        {
            let s = self.iter.next().unwrap();
            s.parse::<T>().unwrap()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
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)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
 
int main(){
  int n,k;
  cin >> n >> k;
  cout << n-k+1 << endl;
return 0;}

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

int main(){
    string s,t;
    cin >> s >> t;
    int len = s.size();
  vector<int>alfa1(26, 0);
  vector<int>alfa2(26, 0);
    bool ans = true;
    for (int i = 0; i < len; i++){
      int a1 = s[i] - 'a';
      int a2 = t[i] - 'a';
      alfa1[a1]++; 
      alfa2[a2]++;
      if(alfa1[a1] != alfa2[a2]){
            ans = false;
            break;
        }
    }
    if(!ans)cout << "No" << endl;
    else cout << "Yes" << endl;
}

Measured memory_bytes: 776
import sys
import collections

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

k = ni()
runrun = k
ans = 0


class Node(object):
    def __init__(self, nam ):
        self.nam = nam
        if nam == -1:
            ne = [1, 2, 3, 4, 5, 6, 7, 8, 9]
        else:
            nam_digit= nam%10
            nam=nam*10+nam_digit
            ne = [nam - 1, nam, nam + 1]
            if nam_digit == 0:
                ne = [nam, nam+1]
            elif nam_digit == 9:
                ne = [nam-1, nam]
        self.nextlist = ne
        self.nextc = -1
        self.j = False


node = Node(-1)
queue = collections.deque()
j=False
while runrun is not 0:
    queue.extend(node.nextlist)
    nx_nam = queue.popleft()
    node = Node(nx_nam)
    runrun -= 1
ans = node.nam

print("{}".format(ans))



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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  int S1 = A + B, S2 = C + D, x = S1 - S2;
   if (x < 0) 
     cout << "Right" << endl;
  else if (x == 0)
    cout << "Balanced" << endl;
  else if (x > 0)
    cout << "Left" << endl;
}
  

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

int main() {
  string S;
  cin>>S;
  set<char>A;
  for(int i=0;i<S.size();i++){
    A.insert(S.at(i));
  }
  if(A.size()==S.size()){
    cout<<"yes"<< endl;
  }
  else{
    cout<<"no"<< endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		//sort(all(vi S)) sort(all(string S))
#define push_back pb
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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

int main() {
	int a,b,T;
	cin>>a>>b>>T;
  int c = T/a;
	int ans = b * c;
	
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>

using namespace std;

int main()
{
	int table[6]={1,5,10,50,100,500};
	int ans=0;
	for(int i=0;i<6;i++)
	{
		int data;
		cin>>data;
		ans+=data*table[i];
	}
	cout<<(ans/1000>=1?1:0)<<endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
    return scanf("%lld", &x);
}

int GI(int& x) {
    return scanf("%d", &x);
}

int n;

const int MAXN = 200005;
int x[MAXN], y[MAXN], visited[MAXN];

set<PII> a, b;

LL getres() {
    LL adiff = a.rbegin()->FF - a.begin()->FF;
    LL bdiff = b.rbegin()->FF - b.begin()->FF;
    return adiff * bdiff;
}

int main() {
    GI(n);

    FOR1(i, n) {
        GI(x[i]);
        GI(y[i]);
        a.insert(MP(max(x[i], y[i]), i));
        b.insert(MP(min(x[i], y[i]), i));
    }

    memset(visited, 0, sizeof visited);

    LL res = getres();

    auto t = *a.rbegin();
    auto i = t.SS;

    while (!visited[i]) {
        a.erase(MP(max(x[i], y[i]), i));
        b.erase(MP(min(x[i], y[i]), i));

        a.insert(MP(min(x[i], y[i]), i));
        b.insert(MP(max(x[i], y[i]), i));

        res = min(res, getres());
        visited[i] = 1;

        t = *a.rbegin();
        i = t.SS;
    }

    cout << res << "\n";

    return 0;
}

Measured memory_bytes: 23424
S = input()
T = input()
match = 0
ans = 0
 
for n in range(len(S)-len(T)+1):
  match2 = 0
  U = S[n:n+len(T)]
  for m in range(len(T)):
    if U[m]==T[m]:
      match2+=1
  match = max(match,match2)
      
print(len(T)-match)

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

// input
int N, A, B;


void input() {
    cin >> N >> A >> B;
}


int main() {
    input();
    int ans = min(A * N, B);
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=200020;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define ROF(i,a,b) for(int i=(a);i>=(b);i--)
#define MEM(x,v) memset(x,v,sizeof(x))
inline int read(){
	int x=0,f=0;char ch=getchar();
	while(ch<'0' || ch>'9') f|=ch=='-',ch=getchar();
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return f?-x:x;
}
int n,m,l,x,y;
char A[maxn],B[maxn];
inline int dx(char c){
	if(c=='U') return -1;
	if(c=='D') return 1;
	return 0;
}
inline int dy(char c){
	if(c=='L') return -1;
	if(c=='R') return 1;
	return 0;
}
bool check(char a,char b){
	int cx=x,cy=y;
	FOR(i,1,l){
		if(A[i]==a) cx+=dx(a),cy+=dy(a);
		if(cx<1 || cx>n || cy<1 || cy>m) return true;
		if(B[i]==b){
			cx+=dx(b),cy+=dy(b);
			if(cx<1 || cx>n || cy<1 || cy>m) cx-=dx(b),cy-=dy(b);
		}
	}
	return false;
}
int main(){
	n=read();m=read();l=read();x=read();y=read();
	scanf("%s%s",A+1,B+1);
	if(check('L','R')) return puts("NO"),0;
	if(check('R','L')) return puts("NO"),0;
	if(check('U','D')) return puts("NO"),0;
	if(check('D','U')) return puts("NO"),0;
	puts("YES");
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
const int mod = 1e9+7;
int n,a[200100],sum[200100],dp[200100],b[200100],cnt;
int main(){
    int i,j,k;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
      scanf("%d",&a[i]);
      if(a[i]!=a[i-1])b[++cnt]=a[i];
    }
    dp[0]=1;
    for(i=1;i<=cnt;i++){
      dp[i]=(dp[i-1]+sum[b[i]])%mod;
      sum[b[i]]=dp[i];
    }
    cout<<dp[cnt];
	return 0;
}


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

using namespace std;

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n, ans = 0;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        int x = i, y = 0;
        while (x > 0) {
            y++;
            x /= 10;
        }
        if (y % 2 == 1) ans++;
    }
    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 256
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val s = readLine()!!

    val charMap = (0..25).map { ('A' + it) to ('A' + ((it + n) % 26)) }
        .toMap()
    s.forEach {
        print(charMap[it])
    }
}

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

int main()
{
    int x, n;
    cin >> x >> n;
    set<int> s;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        s.insert(a);
    }
    int ans = 1000;
    int diff = 1000;
    for (int i = 0; i <= 101; i++)
    {
        if (s.count(i))
        {
            continue;
        }
        int tmp = abs(x - i);
        if (diff > tmp) {
            diff = tmp;
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
def main():
    N, M, Q = [int(x) for x in input().split()]
    queries = [[int(x) for x in input().split()] for _ in range(Q)]

    ans = float("-inf")
    import itertools
    for A in itertools.combinations_with_replacement(range(1, M+1), N):
        # print(A)
        s = 0
        for a, b, c, d in queries:
            if A[b-1] - A[a-1] == c:
                s += d
        ans = max(ans, s)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9200
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<int> a(13);
	a[1] = a[3] = a[5] = a[7] = a[8] = a[10] = a[12] = 1;
	a[4] = a[6] = a[9] = a[11] = 2;
	a[2] = 3;
	int x, y; cin >> x >> y;
	if (a[x] == a[y]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 892
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    int i, j;
    
    while (1) {
        scanf("%d %d", &H, &W);
        
        if(H==0 && W==0){
            break;
        }
        else{
            for(i=0;i<H;i++){
                for(j=0; j<W; j++){
                    if((i + j)%2){
                        printf(".");
                    }else{
                        printf("#");
                    }
                }
                printf("\n");
            }
            printf("\n");
        }
    }
    return 0;
}


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

int main()
{
    string str1, str2, str3;
    cin >> str1 >> str2 >> str3;
    str1[0] -= 32;
    str2[0] -= 32;
    str3[0] -= 32;
    cout << str1[0] << str2[0] << str3[0] << endl;
    return 0;
}


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

using namespace std;

typedef long long	ll;

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

	int n;

	cin >> n;

	ll sum = 0LL;
	ll mn = ll(1e18);
	int cnt = 0;

	for(int i = 1 ; i <= n ; i++){
		ll ai;

		cin >> ai;

		mn = min(mn, abs(ai));

		sum += abs(ai);

		if(ai < 0LL){
			cnt++;
		}
	}

	if(cnt & 1){
		sum -= 2LL * mn;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <clocale>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

const int MOD = 1'000'000'007; 
const int INF = 1'000'000'000; //1e9
const int NIL = -1;
const long long LINF = 1'000'000'000'000'000'000; // 1e18
const long double EPS = 1E-10;

template<class T, class S> inline bool chmax(T &a, const S &b){
    if(a < b){
        a = b; return true;
    }
    return false;
}
template<class T, class S> inline bool chmin(T &a, const S &b){
    if(b < a){
        a = b; return true;
    }
    return false;
}






int main(){
    int N; std::cin >> N;
    std::string s1, s2, ar; std::cin >> s1 >> s2;
    for(int i(0); i < N; ++i){
        if(s1[i] == s2[i]) ar += 'p';
        else{
            ar += 't'; ++i;
        }
    }
    long long cnt(1);
    int prv(0); //1ならp(縦) 2ならt(横)
    for(int i(0), i_len(ar.length()); i < i_len; ++i){
         if(!prv){
             if(ar[i] == 'p'){
                 cnt = 3; prv = 1;
             }else{
                 cnt = 6; prv = 2;
             }
         }
         else if(prv == 1){
             if(ar[i] == 'p'){
                cnt = cnt * 2 % MOD; prv = 1;
             }else{
                cnt = cnt * 2 % MOD; prv = 2;
             }
         }else{
             if(ar[i] == 'p'){
                 prv = 1;
             }else{
                 cnt = cnt * 3 % MOD; prv = 2;
             }
         }
    }
    std::cout << cnt << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll n;
    cin>>n;
    ll dp[n+5],a[n+5];
    ll ans = 0;
    fill(a,a+n+5,INF);
    rep(i,n) {
        cin>>a[i];
        // a[i] = -a[i];
    }
    ll mm=INF;
    rep(i,n){
        if(mm>=a[i]) {
            ans++;
            mm=a[i];
        }
    }
    cout<<ans<<endl;
return 0;}

Measured memory_bytes: 1792
#include<iostream>
#include<string>
#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>
#include<stdio.h>
#include <cstdint>
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;

int n, d, cnt;
double x[10][10];
double tmp, tmp1;

int main() {

	cin >> n >> d;

	rep(i, n) {
		rep(j, d) {
			cin >> x[i][j];
		}
	}
	rep(i, n) {
		REP(j, i + 1, n) {
			rep(k, d) {
				tmp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			rep(k, tmp + 1) {
				if (k * k == tmp)cnt++;
			}
			tmp = 0;
		}
	}

	cout << cnt << endl;

	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod  924844033LL
#define maxn 100005
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 1000000000
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;


class numberTheory{

public:
    numberTheory(){}

    pii extendedEuclid(i64 a, i64 b) { // returns x, y | ax + by = gcd(a,b)

        if(b == 0) return pii(1LL, 0LL);
        else {
            pii d = extendedEuclid(b, a % b);
            return pii(d.yy, d.xx - d.yy * (a / b));
        }

    }

    i64 modularInverse(i64 a, i64 n) {
        pair<i64,i64> ret = extendedEuclid(a, n);
        return ((ret.xx % n) + n) % n;
    }


    i64 bigMod(i64 a, i64 n , i64 m)
    {
        if(n==0) return 1 ;
        i64 ret = bigMod(a,n/2,m) ;
        ret = (ret*ret)%m ;
        if(n%2) ret = (ret*a)%m ;
        return ret ;
    }
};

const i64 N = 200000 ;

i64 fact[N+5] , invFact[N+5] ;

i64 C(i64 n, i64 r)
{
    if( n<0 || r<0 || r>n ) return 0 ;
    i64 ret = (fact[n]*invFact[r])%mod ;
    return (ret*invFact[n-r])%mod ;
}

void preprocess()
{
    numberTheory nt ;

    fact[0] = 1 ;
    for(i64 x=1 ; x<=N ; x++) fact[x] = (fact[x-1]*x)%mod ;

    invFact[N] = nt.modularInverse(fact[N],mod) ;

    for(i64 x=N-1 ; x>=0 ; x--) invFact[x] = (invFact[x+1]*(x+1) )%mod ;
}

i64 dp[2005] ;

int main()
{
    preprocess() ;

    i64 i , j , k , l , m , n ;

    scanf("%lld %lld",&n,&k) ;

    dp[0] = 1LL ;

    for(i=1 ; i<=k ; i++)
    {
        i64 len = ( n-i )/k ;
        for(j=n ; j>=0 ; j--)
        {
            i64 ret = 0LL ;
            for(l=0 ; l<=j && 2*l<=len+1 ; l++)
            {
                ret += dp[j-l]*C(len+1-l,l) ;
                ret %= mod ;
            }
            dp[j] = ret ;
        }
    //    for(j=0 ; j<=n ; j++) printf("%lld ",dp[j]) ;
     //   printf("-\n") ;
        for(j=n ; j>=0 ; j--)
        {
            i64 ret = 0LL ;
            for(l=0 ; l<=j && 2*l<=len+1 ; l++)
            {
                ret += dp[j-l]*C(len+1-l,l) ;
                ret %= mod ;
            }
            dp[j] = ret ;
        }
     //   for(j=0 ; j<=n ; j++) printf("%lld ",dp[j]) ;
      //  printf("--\n") ;
    }

    i64 ans = 0LL , fl= 1 ;

    for(i=0 ; i<=n ; i++)
    {
        ans += fl*fact[n-i]*dp[i] ;
        ans %= mod ;
        fl *= (-1) ;
    }

    printf("%lld\n" ,(ans%mod + mod)%mod ) ;

    return 0 ;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	ll q,h,s,d,n;
	cin >> q >> h >> s >> d;
	cin >> n;
	n *= 4;
	bool use_h = true,use_s = true,use_d = true;
	if(2 * q <= h) use_h = false;
	if(4 * q <= s || 2 * h <= s) use_s = false;
	if(8 * q <= d || 4 * h <= d || 2 * s <= d) use_d = false;
	ll ans = 0;
	if(use_d == true){
		ans += d * (n / 8);
		n %= 8;
	}
	if(use_s == true){
		ans += s * (n / 4);
		n %= 4;
	}
	if(use_h == true){
		ans += h * (n / 2);
		n %= 2;
	}
	ans += q * n;
	cout << ans << endl;
}

Measured memory_bytes: 256