akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//登録しよう！→ https://www.youtube.com/channel/UCRXsI3FL_kvaVL9zoolBfbQ
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}//a,bの最大公約数(gcd)を求める
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}//a,bの最小公倍数(lcm)を求める
vector<ll> enum_div(ll n){vector<ll> ret;for(int i=1 ; i*i<=n ; i++){if(n%i == 0){ret.push_back(i);if(i!=1 && i*i!=n)ret.push_back(n/i);}}ret.push_back(n);return ret;}
//↑nの約数を求める
vector<bool> IsPrime; void sieve(size_t max){if(max+1 > IsPrime.size())IsPrime.resize(max+1,true);IsPrime[0] = false;IsPrime[1] = false;for(size_t i=2; i*i<=max; ++i)if(IsPrime[i])for(size_t j=2; i*j<=max; ++j)IsPrime[i*j] = false;}
//↑エラトステネスの篩で素数を求める
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend //切り上げ割り算
#define all(x) (x).begin(),(x).end() //xの初めから終わりまでのポインタ
#define size_t ll //size_tは自動でllに変換される
#define pb(x) push_back(x)
#define gre greater //sortを降順にする
#define pri_queue priority_queue //優先度付きキュー
#define syo(x) fixed << setprecision(x) //iostreamで小数をx桁表示
const int mod = 1000000007;
std::vector<std::vector<int>> a(3,std::vector<int>(3));
std::vector<std::vector<bool>> ans(3,std::vector<bool>(3));
int n;
std::vector<int> b;
int main(){ //srand((unsigned)time(NULL));
  for (size_t i = 0; i < 3; i++) {
    for (size_t l = 0; l < 3; l++) {
      cin >> a[i][l];
    }
  }
  cin >> n;
  b.resize(n);
  for (size_t i = 0; i < n; i++) {
    cin >> b[i];
    for (size_t x = 0; x < 3; x++) {
      for (size_t y = 0; y < 3; y++) {
        if(a[x][y] == b[i]){
          ans[x][y] = true;
        }
      }
    }
  }
  bool can =false;
  for (size_t i = 0; i < 3; i++) {
    if(ans[i][0] && ans[1][1] && ans[2-i][2]) can = true;
  }
  if(ans[0][0] && ans[1][0] && ans[2][0])can = true;
  if(ans[0][1] && ans[1][1] && ans[2][1])can = true;
  if(ans[0][2] && ans[1][2] && ans[2][2])can = true;
  if(ans[1][0] && ans[1][1] && ans[1][2])can = true;
  if(ans[0][0] && ans[0][1] && ans[0][2])can = true;
  if(ans[2][0] && ans[2][1] && ans[2][2])can = true;
  cout << (can?"Yes":"No") << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define MOD2 100000000
#define ll long long
#define cnl(d) cout<<d<<'\n'
#define cns(d) cout<<d<<' '
#define endl '\n'
#define cno cout<<"NO\n"
#define cyes cout<<"YES\n"
#define vl vector<ll>
#define pb push_back
#define mp make_pair
#define x first
#define y second
#define pl pair<ll,ll>
#define vll vector<pl>
#define sl set<ll>
#define sll set<pl>
#define msl map<string,ll>
#define mll map<ll,ll>
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(a);i<=(b);i++)
#define rdp(i,a,b) for(i=(a);i>=(b);i--)
#define lb(v,z) lower_bound(all(v),z)
#define ub(v,z) upper_bound(all(v),z)
#define trvl(c,it) for(vl::iterator it=(c).begin();it!=(c).end();it++)
#define trvll(c,it) for(vll::iterator it=(c).begin();it!=(c).end();it++)
#define trsll(c,it) for(sll::iterator it=(c).begin();it!=(c).end();it++)
#define trmsl(c,it) for(msl::iterator it=(c).begin();it!=(c).end();it++)
#define trmll(c,it) for(mll::iterator it=(c).begin();it!=(c).end();it++)
#define trsl(c,it) for(sl::iterator it=(c).begin();it!=(c).end();it++)
#define trsi(c,it) for(set<int>::iterator it=(c).begin();it!=(c).end();it++)

using namespace std;


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   set<string>se;
   string a;
   ll n;cin>>n;

   vector<string>ar;
   for(ll i=0;i<n;i++)
   {
       string b;
       cin>>b;
       ar.push_back(b);
       if(se.find(b)==se.end())
       {
           se.insert(b);
       }
       else
       {
           cout<<"No\n";return 0;
       }
       if(i&&ar[i][0]!=ar[i-1][ar[i-1].length()-1])
       {cout<<"No\n";return 0;}
   }
   cout<<"Yes\n";
}


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

using namespace std;

const int N = 2e5 + 5;

int n, a[N], dp[N], dp2[N], cnt = 0;
vector <int> g[N], vec, last[N];
map <int, int> mm;

struct SegmentTree {
    int node[N << 2];
    void init (int i, int l, int r) {
        if (l == r) {
            node[i] = 0;
            return;
        }
        
        int mid = l + r >> 1;
        init(i << 1, l, mid);
        init(i << 1 | 1, mid + 1, r);
        node[i] = max(node[i << 1], node[i << 1 | 1]);
    }
    
    void update (int i, int l, int r, int pos, int val, int type) {
        if (l == r) {
            if (type) node[i] = max(node[i], val);
            else node[i] = val;
            return;
        }
        
        int mid = l + r >> 1;
        if (pos <= mid) update(i << 1, l, mid, pos, val, type);
        else update(i << 1 | 1, mid + 1, r, pos, val, type);
        node[i] = max(node[i << 1], node[i << 1 | 1]);
    }
    
    int query (int i, int l, int r, int a, int b) {
        if (l > r || a > r || b < l) return 0;
        if (a <= l && r <= b) return node[i];
        
        int mid = l + r >> 1;
        return max(query(i << 1, l, mid, a, b), query(i << 1 | 1, mid + 1, r, a, b));
    }
} it;

void dfs (int u, int p) {
    dp[u] = max(1, 1 + it.query(1, 1, cnt, 1, mm[a[u]] - 1));
    last[mm[a[u]]].push_back(dp[u]);
    it.update(1, 1, cnt, mm[a[u]], dp[u], 1);
    
    for (auto v: g[u]) {
        if (v == p) continue;
        dfs(v, u);
    }
    
    last[mm[a[u]]].pop_back();
    it.update(1, 1, cnt, mm[a[u]], last[mm[a[u]]][last[mm[a[u]]].size() - 1], 0);
}

void redfs (int u, int p) {
    dp2[u] = max(dp2[u], dp[u]);
    for (auto v: g[u]) {
        if (v == p) continue;
        dp2[v] = max(dp2[v], dp2[u]);
        redfs(v, u);
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n - 1; i++) {
        int u, v;
        cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    
    for (int i = 1; i <= n; i++) vec.push_back(a[i]);
    sort(vec.begin(), vec.end());
    mm[vec[0]] = ++cnt;
    for (int i = 1; i < vec.size(); i++) {
        if (vec[i] > vec[i - 1]) {
            mm[vec[i]] = ++cnt;
        }
    }
    
    for (int i = 1; i <= cnt; i++) last[i].push_back(0);
    it.init(1, 1, cnt);
    dfs(1, 1);
    redfs(1, 1);
    for (int i = 1; i <= n; i++) cout << dp2[i] << "\n";
    return 0;
}


Measured memory_bytes: 58956
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <cmath>
#include <bitset>
#include <string>
#define REP(i,n) for(int i=0;i<n;i++)
using Int = long long;
using namespace std;
int main()
{
    int N; cin >> N;
    int C[100001] = {};
    REP(i, N) {
        int a; cin >> a;
        C[a]++;
    }
    int T = 0, D = 0;
    REP(i, 100001) {
        if (C[i] >= 1) {
            T++;
        }
        if (C[i] >= 2) {
            D += C[i] - 1;
        }
    }
    if (D % 2 == 0) cout << T << endl;
    else cout << T - 1 << endl;
    return 0;
}

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

#define LL long long
#define VI vector<int>
#define VB vector<bool>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14

const std::string YES = "YES";
const std::string Yes = "Yes";
const std::string NO = "NO";
const std::string No = "No";

using namespace std;

template <class T> int find_index(T x, const std::vector<T> &v) {
    auto it = std::find(v.begin(), v.end(), x);
    if (it != v.end()) { return (int)std::distance(v.begin(), it); }
    return -1;
}
template<class T> T ceil(T a, T b) { return (a + b - 1) / b; }

template <class T> void print(T x) {
    std::cout << x << std::endl;
}
// 4近傍（右, 下, 左, 上）
const vector<int> dy = { 0, -1, 0, 1 };
const vector<int> dx = { 1, 0, -1, 0 };


class Imos {
public:
    const unsigned int N;
    vector<long long> dp;
    Imos(unsigned int N) : N(N) {
        dp = vector<long long>(N + 10);
    }

    // [a, b]にkを加える
    void add(int a, int b, int k) {
        dp[a] += k;
        dp[b + 1] -= k;
    }

    // 円環状で[a, b]にk加える
    void add_circle(int a, int b, int k) {
        if (a <= b) {
            add(a, b, k);
        }
        else {
            add(b, N, k);
            add(0, b, k);
        }
    }

    void build() {
        for (int i = 0; i < dp.size() - 1; ++i) {
            dp[i + 1] += dp[i];
        }
    }

    void print() {
        for (int i = 0; i < dp.size(); ++i) {
            if (i != 0) { cout << " "; }
            cout << dp[i];
        }
        cout << endl;
    }

};


void solve(long long m, vector<long long> &a){

    Imos imos1(m), imos2(m);
    LL naive = 0;
    FOR(i, 0, a.size() - 1) {
        int b = a[i];
        int e = a[i + 1];

        if (b <= e){
            // [b + 1, e]
            imos1.add(b + 1, e, -(b + 1));
            imos2.add(b + 1, e, 1);

            naive += e - b;
        }
        else{
            imos1.add(b + 1, m - 1, -(b + 1));
            imos1.add(0, e, m - b - 1);

            imos2.add(b + 1, m - 1, 1);
            imos2.add(0, e, 1);

            naive += m - (b - e);
        }
    }
    imos1.build();
    imos2.build();

    LL ans = LONG_LONG_MAX;
    FOR(i, 0, m) {
        ans = min(ans, naive - (imos1.dp[i] + i * imos2.dp[i]));
    }

    cout << ans << endl;
}

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

    long long m;
    long long n;
    cin >> n >> m;
    vector<long long> a(n);

    for(int i = 0 ; i < n; i++){
        cin >> a[i];
        a[i]--;
    }
    solve(m, a);
    return 0;
}



Measured memory_bytes: 2560
#include<iostream>
#include<climits>
#include<vector>
#include<list>
#include<functional>
#include<algorithm>
#include<string>
#include<cmath>
#include<complex>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int X, Y;
	cin >> X >> Y;
	cout << X + Y / 2 << "\n";

	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int m1,d1,m2,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	bool f=false;
	if(m1==2 and d1==28)
	{
		cout<<'1'<<endl;
		f=true;
	}
	else if(m1==4 or m1==6 or m1==9 or m1==11)
	{
		if(d1==30)
		{
			cout<<'1'<<endl;
			f=true;
		}
	}
	else if(m1==1 or m1==3 or m1==5 or m1==7 or m1==8 or m1==10 or m1==12)
	{
		if(d1==31)
		{
			cout<<'1'<<endl;
            f=true;
		}
	}
	if(!f)
	{
		cout<<'0'<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        StringBuilder ans = new StringBuilder();
        for (int i = 0; i < K; i++) {
            ans.append("ACL");
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 35700
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 65;

inline int add(int x,int y)
{
    return (x + y)%MOD;
}

inline int sub(int x,int y)
{
    return (x+MOD-y)%MOD;
}

inline int mul(int x,int y)
{
    return (ll)x*y%MOD;
}

// 0:ぴったし, 1:一個下によってはぴったし, 2: 余裕あり
int dp[MAX_N][3];

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vi keta;
    while(n){
        keta.pb(n%2);
        n /= 2;
    }
    reverse(all(keta));
    dp[0][0] = 1;
    rep(i,len(keta)){
        if(keta[i]){
            // 繰り上がれない
            dp[i+1][0] = add(dp[i+1][0], dp[i][0]);
            dp[i+1][1] = add(dp[i+1][1], dp[i][0]);
            // 繰り上がれる
            dp[i+1][2] = add(dp[i+1][2], mul(dp[i][2], 3));
            dp[i+1][1] = add(dp[i+1][1], dp[i][1]);
            dp[i+1][2] = add(dp[i+1][2], add(dp[i][1], dp[i][1]));
        }else{
            // 繰り上がれない
            dp[i+1][0] = add(dp[i+1][0], dp[i][0]);
            // 繰り上がれる
            dp[i+1][2] = add(dp[i+1][2], mul(dp[i][2], 3));
            dp[i+1][0] = add(dp[i+1][0], dp[i][1]);
            dp[i+1][1] = add(dp[i+1][1], dp[i][1]);
            dp[i+1][2] = add(dp[i+1][2], dp[i][1]);
        }
    }
    cout << add(add(dp[len(keta)][0], dp[len(keta)][1]), dp[len(keta)][2]) << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main() {
  int N; cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  vector<int> r(N);
  for (int i = N-1; i >= 0; i--) {
    int p = -1;
    for (int j = 0; j < v.size(); j++) {
      if (v[j] == j+1) p = j;
    }
    if (p == -1) {
      cout << -1 << endl; return 0;
    }
    r[i] = p+1;
    v.erase(v.begin()+p);
  }
  for (int i = 0; i < N; i++) cout << r[i] << endl;
}

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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int n = s.length();
    vec po(n + 1);
    po[0] = 1;
    For(i, 1, n) po[i] = (po[i - 1] * 3) % MOD;

    int total = 0;
    int sunao = 1;
    rep (i, n) {
        if (s[i] == '1') {
            total += sunao * po[n - 1 - i];
            total %= MOD;
            sunao *= 2;
            sunao %= MOD;
        }
    }
    total += sunao;
    total %= MOD;
    print(total);

    return 0;
}


Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
   /* #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
  ll n,c=0;
  string s;
  cin>>s;
  n=s.length();
  for(int i=0;i<n/2;i++)
  {
    if(s[i]!=s[n-i-1])
        c++;
  }

cout <<  c << endl;
  
  


return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>

using namespace std;

//conversion
//------------------------------------------
inline long toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline long toLong(string s) {long v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-20;
const long INF = 1e10;
long gcd(long a,long b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	
	string str;
	while(cin>>str){
		if(str=="#")break;
		vector<int>mv;
		REP(i,SZ(str)){
			if(i<=SZ(str)-5&&str.substr(i,5)=="north"){
				mv.PB(-90);
				i+=4;
			}else if(i<=SZ(str)-4&&str.substr(i,4)=="west"){
				mv.PB(90);
				i+=3;
			}
		}
		reverse(ALL(mv));
		long a=max(mv[0],0);
		long b=1;
		FOR(i,1,SZ(mv)){
			a=2*a+mv[i];
			b*=2;
		}
		long g=gcd(a,b);
		a/=g;b/=g;
		if(b>1)cout<<a<<"/"<<b<<endl;
		else cout<<a<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
// ここから編集しろ
int dp[110][60][60];
int p[60];
int solve(int a,int b,int c){
	if(b>c||a==0)return 0;
	if(dp[a][b][c]!=-mod)return dp[a][b][c];
	int ret=-mod;
	ret=max(ret,solve(a-1,b+1,c)+p[b]);
	ret=max(ret,solve(a-1,b,c-1)+p[c]);
	if(a>1)ret=max(ret,solve(a-2,b+1,c));
	if(a>1)ret=max(ret,solve(a-2,b,c-1));
	return dp[a][b][c]=ret;
}
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);
	}
	for(int i=0;i<110;i++)for(int j=0;j<60;j++)for(int k=0;k<60;k++)
		dp[i][j][k]=-mod;
	int ret=0;
	for(int i=1;i<=b;i++)ret=max(ret,solve(i,0,a-1));
	printf("%d\n",ret);
}

Measured memory_bytes: 1664
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

string gs(int n){
	string ans = to_string(n);
	while(ans.length()<6)ans="0"+ans;
	return ans;
}

void solve(int test_case) {//228
	int n,m;
	cin>>n>>m;//{PID, Y, CID}
	vector<vpii> arr(n+1, vpii());
	vector<string> ans(m+1);
	REP(i,1,m) {
		int p,y;
		cin>>p>>y;
		arr[p].PUB({y,i});
	}
	REP(i,1,n)sort(arr[i].begin(),arr[i].end());
	REP(i,1,n) {
		string pid = gs(i);
		REP(j,0,(int)arr[i].size()-1){
			ans[arr[i][j].S]=pid+gs(j+1);
		}
	}
	REP(i,1,m)cout<<ans[i]<<"\n";
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 11872
# N = int(input())
# h = list(map(int, input().split()))
# 
# #大きな値
# INF = 9999
# 
# # DPtable
# dp = [INF]*9999
# 
# #初期条件
# dp[0] = 0
# dp[1] = abs(h[1]-h[0])
# 
# #ループ
# for i in range(N):
#     if i == 0 or i == 1:
#         continue
#     else:
#         dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]-h[i-2]))
# 
# print(dp[N-1])

N = int(input())
h = list(map(int, input().split()))
dp = [10 ** 10 for _ in range(N)]
dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, N):
    dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))

print(dp[-1])


Measured memory_bytes: 13976
#include <string>
#include <vector>
#include <iostream>
#include <queue>
#include <functional>
#include <algorithm>
#include <random>
#include <cmath>
#include <climits>
#include <iomanip>
#include <cfloat>
#include <set>
#include <map>
int main() {
	int n; std::cin >> n;
	std::map<long long int, int> map;
	int d;
	long long int prev = 0;
	auto max = 0;
	map.insert(std::make_pair(0, 0));
	for (auto i = 1; i <= n; ++i) {
		std::cin >> d;
		prev += d;
		auto res = map.emplace(std::make_pair(prev, i));
		if (!res.second) {
			if (max < i - (*res.first).second) max = i - (*res.first).second;
		}
	}
	std::cout << max << std::endl;
}


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

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)

typedef struct UnionFind{
	vector<lli> par; //par[i]:iの親番号 par[3] = 2 : 3の親が2
	vector<lli> size;//size[i]:iの大きさ 自分のみのときは1,根っこにsizeを持たせる*/

	UnionFind(int N){/*最初はすべてが根であると初期化*/
		REP(i,0,N){
			par.push_back(i);
			size.push_back(1);
		}
	}

	lli root(lli x){/*データxが属する木の根を再起で得る root(x) = {xの木の根}}*/
		if(par[x] == x)return x;
		return par[x] = root(par[x]);
	}

	void unite(lli x,lli y){/*xとyの併合*/
		lli rx = root(x);
		lli ry = root(y);
		if(rx == ry)return;
		par[rx] = ry; /*xとyの根が同じじゃない: xの根をrxをyの根ryに変更する */
		lli resize = size[rx] + size[ry];
		size[rx] = resize;
		size[ry] = resize;
	}

	bool same(lli x,lli y){
		lli rx = root(x);
		lli ry = root(y);
		return rx == ry;
	}

	lli getSize(lli x){
		lli rx = root(x);
		return size[rx];
	}
};

lli cnt[100100];

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    long long K;
    scanf("%lld",&K);
    UnionFind uf(N);
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    std::vector<lli> ans(N);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
        A[i]--,B[i]--;
        uf.unite(A[i],B[i]);
        cnt[A[i]]++;
        cnt[B[i]]++;
    }
    REP(i,0,N)ans[i] = uf.getSize(i)-cnt[i];
    std::vector<long long> C(K);
    std::vector<long long> D(K);
    for(int i = 0 ; i < K ; i++){
        scanf("%lld",&C[i]);
        scanf("%lld",&D[i]);
        C[i]--,D[i]--;
        if(uf.same(C[i],D[i])){
            ans[C[i]]--;
            ans[D[i]]--;
        }
    }
    REP(i,0,N)cout<<ans[i]-1<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 7660
#include <iostream>

using namespace std;

int n;
int a[25];

int main(void)
{
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	int mx = 0, ans = 0;
	for(int i = 1; i <= n; i++){
		if(a[i] >= mx) ans++;
		mx = max(mx, a[i]);
	}
	cout<< ans << endl;
	return 0;
}

Measured memory_bytes: 256
//confilm 0LL and 1LL
//confilm cornercases such as 0
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecVec = vector<Vec>;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

ll gcd(ll a, ll b){
	if(!b) return a;
	return gcd(b, a%b);
}

int main(void){
	ll n;
	cin >> n;
	Vec a(n);
	rep(i, n) cin >> a[i];
	Vec dp1(n), dp2(n);
	rep(i, n){
		if(!i) dp1[i] = a[i];
		else dp1[i] = gcd(dp1[i-1], a[i]);
	}
	repr(i, n){
		if(i == n-1) dp2[i] = a[i];
		else dp2[i] = gcd(dp2[i+1], a[i]);
	}
	ll ans = max(dp1[n-2], dp2[1]);
	rep(i, n-2){
		chmax(ans, gcd(dp1[i], dp2[i+2]));
	}
	co(ans);

	return 0;
}


Measured memory_bytes: 2560
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <map>
#include <cstdlib>
#include <vector>
#include <iostream>
using namespace std;


int main() {
    int m, n;
    scanf("%d%d", &n, &m);
    n--;
    n /= 2;
    int x = n * 2 + 1;
    int l = 1, r = x, f = 0;
    for(int i = 1; i <= m; i++) {
        if(f == 0) {
            printf("%d %d\n", l, l + n);
            n--;
            l++;
        } else {
            printf("%d %d\n", r, r - n);
            r--;
            n--;
        }
        f ^= 1;
    }
    return 0;
}

Measured memory_bytes: 3840
#include<iostream>
#include<cstdio>
#include<cmath>
#include<set>
#include<map>
using namespace std;

set<pair<int,int> > s;

bool find(int a,int b){
	for(int i=-1;i<=1;i++){
		for(int j=-1;j<=1;j++){
			if(s.find(make_pair(a+i,b+j))!=s.end())
				return true;
		}
	}
	return false;
}
int main(){
	int N;
	double R,x,y;
	int a,b;
	int ans=0;
	scanf("%d %lf",&N,&R);
	while(N--){
		scanf("%lf %lf",&x,&y);
		a= (int)floor(x/R);
		b= (int)floor(y/R);
		if(!find(a,b)){
			s.insert(make_pair(a,b));
			ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 8740
n = int(input())
a = [int(i) for i in input().split()]

ans1 = max(a)
a.remove(ans1)
key = ans1
m = 0
for i in range(n - 1):
    if abs(a[i] - ans1 // 2) < key:
        key = abs(a[i] - ans1 // 2)
        m = i

print(ans1,end=" ")
print(a[m])

Measured memory_bytes: 14052
#include <iostream>
using namespace std; 
int A,B,C,X;
int kekka = 0;
void input() { 
  cin >> A >> B >> C >> X;
} 
void compute() { 
  for(int i = 0; A >= i; i++){
    for(int j = 0; B >= j; j++){
      for(int k = 0; C >= k; k++){
        if(500 * i + 100 * j + 50 * k == X){
          kekka++;
        }
      }
    }
  }
} 
void output() { 
  cout << kekka << endl;
} 
int main() { 
    input(); 
    compute(); 
    output(); 
    return 0; 
} 

Measured memory_bytes: 256
#include <stdio.h>

int cla[4][2];

int main(void)
{
	float eye[2];
	int i;
	
	while (scanf("%f %f", &eye[0], &eye[1]) != EOF){
		for (i = 0; i < 2; i++){
			if (eye[i] < 0.2){
				cla[3][i]++;
			}
			else if (eye[i] < 0.6){
				cla[2][i]++;
			}
			else if (eye[i] < 1.1){
				cla[1][i]++;
			}
			else {
				cla[0][i]++;
			}
		}
	}
	
	for (i = 0; i < 4; i++){
		printf("%d %d\n", cla[i][0], cla[i][1]);
	}
	
	return (0);
}

Measured memory_bytes: 624
n, m = map(int, input().split())
s = input()

from collections import deque
q = deque()

pre = [-1] * (n+1)
f = [float('inf')] * (n +1)
f[0] = 0

q.append((f[0], 0))
for i in range(1, n+1):
  while q and i - q[0][1] > m:
    q.popleft()
  if s[i] == '1': continue
  if q:
    f[i] = q[0][0] + 1
    pre[i] = q[0][1]
  while q and q[-1][0] > f[i]:
    q.pop()
  if f[i] != float('inf'):
    q.append((f[i], i))

if pre[n] == -1:
  print(-1)
else:
  now = n
  res = [n]
  while pre[now] != -1:
    now = pre[now]
    res.append(now)
  res = res[::-1]
  ans = [y -x for x, y in zip(res, res[1:])]
  print(*ans)


Measured memory_bytes: 60876
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;


typedef long long int ll;
typedef unsigned long long  ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef deque <int> di;
typedef deque <char> dc;
typedef vector<long long int> vll;

#define f(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i <=b; i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front;
int main() {
int x;
f(i, 0, 5) {
cin >> x;
if (x == 0) {
    cout << i+1;
}
}
return 0;
}


Measured memory_bytes: 3604
#include <cstdio>

using namespace std;

// (h,w) < (a,b)
bool cmp(int h,int w,int a,int b){
	return h*h+w*w<a*a+b*b || (h*h+w*w==a*a+b*b && h<a);
}

int main(){
	for(int h,w;scanf("%d%d",&h,&w),h;){
		int h0=149,w0=150;
		for(int a=1;a<=150;a++) for(int b=a+1;b<=150;b++) {
			if(cmp(h,w,a,b) && cmp(a,b,h0,w0)) h0=a, w0=b;
		}
		printf("%d %d\n",h0,w0);
	}

	return 0;
}

Measured memory_bytes: 1028
import heapq
n, k = map(int, input().split())
a = list(map(int, input().split()))

x = sum(a)
search = []
i = 1
while i ** 2 <= x:
    if x % i == 0:
        heapq.heappush(search, -i)
        heapq.heappush(search, -x//i)
    i += 1

while search:
    ans = -heapq.heappop(search)
    u = [a[i] % ans for i in range(n)]
    u.sort()

    plus = [0]
    minus = [0]
    for i in range(n):
        plus.append(plus[-1] + ans - u[i])
        minus.append(minus[-1] + u[i])

    for i in reversed(range(n+1)):
        # print(i)
        m = minus[i]
        p = plus[-1] - plus[i]
        if m == p and m <= k:
            print(ans)
            exit()



Measured memory_bytes: 9304
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

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


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string>

using namespace std;
using ll = long long int;
using vec = vector<int>;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define Sort(a)    sort(a.begin(), a.end())
#define gSort(b)   sort(b.begin(), b.end(), greater<int>())
const int INF = 2147483647;
const ll  MOD = 1000000007;

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

    vector<int> x(n);
    for(int i = 0; i < n; ++i) cin >> x[i];

    gSort(x);

    bool ans = false;
    int sum = 0;
    rep(i, n) {
        sum += x[i];
        if(h <= sum) {
            ans = true;
            break;
        }
    }

    cout << ((ans) ? "Yes" : "No");
}

Measured memory_bytes: 640
#include <bits/stdc++.h> // {{{
// clang-format off
#define ARG4(_1, _2, _3, _4, ...) _4
#define rep(...) ARG4(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define REP(i, a) FOR(i, 0, a)
#define FOR(i, a, b) for (int i = (a); i < (int)(b); ++i)
#define rrep(...) ARG4(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define RREP(i, a) RFOR(i, 0, a)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (int)(a); --i)
#define ALL(c) (c).begin(), (c).end()
#define TEN(n) ((ll)(1e##n))
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define USE1(T) template <typename T> inline
#define USE2(T, U) template <typename T, typename U> inline
#define mygc(c) (c) = getchar_unlocked()
#define mypc(c) putchar_unlocked(c)
 
template<typename T> using vec = std::vector<T>;
template<typename T> using withi = std::pair<T, int>;
using ll = long long;
USE2(T,U)bool chmax(T&x,U a){return x<a&&(x=a,1);}
USE2(T,U)bool chmin(T&x,U a){return a<x&&(x=a,1);}
USE1(T=int)T in(){T x;std::cin>>x;return x;}
USE1(T=int)vec<T>in(int n){vec<T>v;v.reserve(n);rep(i,n)v.pb(in<T>());return v;}
USE2(T,U=withi<T>)vec<U>zipi(const vec<T>&x,int s=0){int N=x.size();vec<U>v;v.reserve(N);rep(i,N)v.pb(x[i],s+i);return v;}
USE1(T)vec<T>ndvec(T v,int n){return vec<T>(n,v);}
USE2(T,...Ts)auto ndvec(T v,int n,Ts...ns)->vec<decltype(ndvec(v,ns...))>{return ndvec(ndvec(v,ns...),n);}
USE1(T)void pr(T x){std::cout<<x<<'\n';}
USE2(T,...Ts)void pr(T x,Ts...xs){std::cout<<x<<' ';pr(xs...);}
USE1(T=int)T rd(){T x=0,m=0,k;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){x=k-'0';break;}}for(;;){mygc(k);if(k<'0'||'9'<k)break;x=x*10+k-'0';}return x;}
USE1(T=int)void wr(T x,char c='\n'){int s=0,m=0;char b[32];if(x<0)m=1,x=-x;for(;x;x/=10)b[s++]=x%10;if(!s)b[s++]=0;if(m)mypc('-');for(;s--;)mypc(b[s]+'0');mypc(c);}
// clang-format on
// }}}
struct IoSetup { // {{{
  IoSetup() {
    std::ios::sync_with_stdio(0);
    std::cin.tie(0);
    std::cout.precision(10);
    std::cerr.precision(10);
  }
} iosetup; //}}}
using namespace std;
const int inf = 1001001001;
const ll infl = 1001001001001001001ll;
const int dd[] = {0, 1, 0, -1, 0};

signed main() {
  int R0, W0, C, R;
  while (R0 = in(), W0 = in(), C = in(), R = in()) {
    pr(max((C * W0 - R0 + R - 1) / R, 0));
  }
  return 0;
}

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

int main(){
	// your code goes here
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
	cout.tie(NULL);
	
	int a,b;
	cin>>a>>b;
	int x,y;
	if(a<=b){
	    x=a;
	    y=b;
	}
	else{
	    x=b;
	    y=a;
	}
	for(int i=0;i<y;i++){
	    cout<<x;
	}
	return 0;
}


Measured memory_bytes: 256
//2017-11-4
//miaomiao
//
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)

double Calc(int a, int b){
	return 1.0*b / (100.0*a+b);
}

int main(){
        int A, B, C, D, E, F;
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F);
	
	int tmp = F * (1.0*E / (100+E));
	int a = F/100/A, b = F/100/B, c = tmp/C, d = tmp/D;

	int ans1 = A, ans2 = 0;
	int totw, tots;

//	printf("a = %d b = %d c = %d d = %d\n", a, b, c, d);
	For(i, 0, a) For(j, 0, b) For(k, 0, c) For(l, 0, d){
		totw = i*A + j*A; tots = k*C + l*D;
		if(!totw || !tots || totw*100+tots > F) continue;
		if(totw*E < tots) continue;	

		if(Calc(ans1, ans2) < Calc(totw, tots)) ans1 = totw, ans2 = tots;
	}
	
	printf("%d %d\n", ans1*100+ans2, ans2);

	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)
minus = a.count{|x| x < 0}
ans = 0
a.each do |x|
  ans += x.abs
end
if minus % 2 == 1 && !a.include?(0)
  min = a[0].abs
  a.each do |x|
    min = x.abs if min > x.abs
  end
  ans -= min * 2
end
puts ans

Measured memory_bytes: 21912
//bismillahir rahmanir rahim            //Author:Fayed Anik
 
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;
 
/*
template <typename T>  using ordered_set =
    tree<T, null_type, less<T>,   /// greater<T> for sorting decreasingly
    rb_tree_tag, tree_order_statistics_node_update>;
*/

#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         mp(a,b)                     make_pair(a,b)
#define         mod                         1000000007
#define         INF                         2e18
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)
 
//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;


int main(){
   string s,t,x;
   ll a,b;
   cin>>s>>t;
   cin>>a>>b;
   cin>>x;
   if(x==s) a--;
   else b--;
   cout << a <<' '<<b << endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;


using namespace std;

int main()
{
  

  while(1){
    int n;
    cin >> n;
    if(n==0) break;
    
    vector< vector<int> > numList;

    rep(i,n){
      int tmp; cin >> tmp;
      vector<int> tmp2;
      rep(j,tmp){
        int a; cin >> a;
        tmp2.push_back(a);
      }
      numList.push_back(tmp2);
    }
    
    int data1[150],data2[150];
    memset(data1,0,sizeof(data1));
 
    int m; cin >> m;
    vector<int> ans;
    rep(i,m){
      int b; cin >> b;
      data1[b]=1;
      ans.push_back(b);
    } 
    
    int count=0;
    int hannin;
    rep(i,n){
      
      memset(data2,0,sizeof(data2));
      rep(j,numList[i].size()){
        data2[numList[i][j]]=1;
      //  cout << "debug" << numList[i][j] << endl;
      }
      bool flag=true;
      rep(j,ans.size()){
        if(data2[ans[j]]!=data1[ans[j]]) flag=false;
       // cout << data1[ans[j]] <<  " " << data2[ans[j]] << endl;
      }  
    
      if(flag){
        count++;
        hannin=i;
      } 
    }
    
    if(count==1) cout << hannin+1 << endl;
    else cout << -1 << endl;
    
  }
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int a[n+1];
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    int ans[n+1];
    for(int i=n;i>=1;i--){
        int sum=0;
        int k=i+i;
        while(k<=n){
            sum^=ans[k];
            k+=i;
        }
        ans[i]=sum^a[i];
    }
    int ball=0;
    for(int i=1;i<=n;i++){
        ball+=ans[i];
    }
    cout<<ball<<endl;
    for(int i=1;i<=n;i++){
        if(ans[i])cout<<i<<endl;
    }
}


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

// 插入此處

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	LL N, K; cin >> N >> K;
	if (N % K == 0)  cout << 0 << endl;
	else {
		LL res = N % K;
		cout << min(res, K - res) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<vector>
#include<complex>
#include<map>
#include<set>
using namespace std;
#define int long long
vector<int> SS;
int L;
int sum(int a, int b) {
	int res = SS[b];
	if (a > 0)res -= SS[a - 1];
	return (res / L);
}
signed main() {

	int N, M;
	cin >> N >> M >> L;
	vector<int> S(M);

	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		a--;
		mp[a]++;
	}
	for (int i = 0; i < M; i++) {
		cin >> S[i];
	}
	SS = S;
	for (int i = 1; i < M; i++) {
		SS[i] += SS[i - 1];
	}
	N = mp.size();
	vector<int> A(N);
	vector<int> C(N);
	int t = 0;
	for (auto m : mp) {
		A[t] = m.first;
		C[t] = m.second;
		t++;
	}

	int INF = (int)1 << 60;
	if (N == 1) {
		cout << sum(A[0],A[0]) * C[0] << endl;
	}
	else {
		int x = C[N - 1];
		C[N - 1] = 2;
		int res = 0;
		vector<vector<int> > dp(N, vector<int>(N, INF));
		dp[0][0] = 0;
		for (int i = 1; i < N; i++) {
			if (C[i] == 1) {
				for (int j = 0; j < i; j++) {
					dp[i][j] = min(dp[i][j], dp[i - 1][j] + sum(A[i - 1], A[i]));
					dp[i][i - 1] = min(dp[i][i - 1], dp[i - 1][j] + sum(A[j], A[i]));
				}
			}
			else {
				for (int j = 0; j < i; j++) {
					dp[i][i] = min(dp[i][i], dp[i - 1][j] + sum(A[j], A[i]) + sum(A[i - 1], A[i]));
					dp[i][j] = min(dp[i][j], dp[i - 1][j] + sum(A[i - 1], A[i]) + sum(A[i], A[i]));
					dp[i][i - 1] = min(dp[i][i - 1], dp[i - 1][j] + sum(A[j], A[i]) + sum(A[i], A[i]));
				}
			}
		}
		//cerr << dp[N - 1][N - 1] << endl;
		res += dp[N - 1][N - 1];
		res += (x - 1) * sum(A[N - 1], A[N - 1]);
		res += (C[0] - 1) * sum(A[0], A[0]);
		for (int i = 1; i < N - 1; i++) {
			if (C[i] > 2) {
				res += (C[i] - 2) * sum(A[i], A[i]);
			}
		}
		cout << res << endl;
	}
}


Measured memory_bytes: 35524
n,m=map(int,input().split())
s=input()
ans=[]
w=n
while w:
    x=0
    for i in range(1,m+1):
        if w-i>=0 and s[w-i]=='0':
            x=i
    if x==0:
        print(-1)
        exit()
    else:
        ans.append(x)
        w-=x
print(*ans[::-1])


Measured memory_bytes: 50544
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, pair<int,int>> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    int a,b;
    while(cin>>a>>b,a+b){
        map<int,int>mp;
        mp[1]=1;
        vector<pii>hoge;
        rep(i,b){
            pii temp; cin>>temp.first>>temp.second.first>>temp.second.second;
            hoge.push_back(temp);
            
        }
        sort(all(hoge));
        rep(i,hoge.size()){
            if(mp[hoge[i].second.first])mp[hoge[i].second.second]++;
            //if(mp[hoge[i].second.second])mp[hoge[i].second.first]++;
        }
        int ans=0;
        for(int i=1; i<=a;i++)
            if(mp[i])ans++;
        cout<<ans<<endl;
    }
}

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

int main(){
  string in;
  string out;
  cin >> in >> out;
  map<char, char> forthRelationship;
  map<char, char> backRelationship;
  for(char ch='a'; ch<='z'; ch++){
    forthRelationship[ch] = '0';
    backRelationship[ch] = '0';
  }
  for(int i=0; i<in.length(); i++){
    if(forthRelationship[in[i]] == '0' && backRelationship[out[i]] == '0'){
      forthRelationship[in[i]] = out[i];
      backRelationship[out[i]] = in[i];
    }else{
      if(forthRelationship[in[i]] != out[i] || backRelationship[out[i]] != in[i]){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}
      
      
      
      


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

int main(){
int N,A,B;
  cin>>N;
  A=0;
  B=0;
 vector<int>a(N);
  for(int i=0;i<N;i++){
   cin>>a[i];
  }
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  for(int i=0;i<N;i++){
    if(i%2==0){
      A+=a[i];
    }
    else{
      B+=a[i];
    }
  }
    cout<<A-B<<endl;
}


Measured memory_bytes: 256