akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

list_alpha = ['A', 'B', 'C', 'D', 'E', 'F']

X, Y = map(str, input().split())

if(list_alpha.index(X) > list_alpha.index(Y)):
    print('>')
elif(list_alpha.index(X) < list_alpha.index(Y)):
    print('<')
else:
    print('=')

Measured memory_bytes: 3060
#include "iostream"
#include "algorithm"
#include "vector"
#include "string"
#include "cmath"
typedef long long ll;
using namespace std;

int main(int argc, char const *argv[]) {
  ll NN,MM;
  std::cin >> NN >> MM;

  std::vector<ll> X(MM);
  for (ll i = 0; i < MM; i++) {
    std::cin >> X[i];
  }

  // for (ll i = 0; i < MM; i++) {
  //   std::cout << X[i] << '\n';
  // }

  sort(X.begin(), X.end());

  // for (ll i = 0; i < MM; i++) {
  //   std::cout << X[i] << '\n';
  // }

  std::vector<ll> lens(MM-1);

  for (ll i = 0; i < MM-1; i++) {
    lens[i] = X[i+1] - X[i];
  }

  // for (ll i = 0; i < MM-1; i++) {
  //   std::cout << lens[i] << '\n';
  // }

  sort(lens.begin(), lens.end());

  // for (ll i = 0; i < MM-1; i++) {
  //   std::cout << lens[i] << '\n';
  // }

  ll ans = 0;

  for (ll i = 0; i < MM-1; i++) {
    if (i < MM  - NN) {
      ans += lens[i];
    }
  }

  std::cout << ans << '\n';


  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>


int str_chnum(const char *str, char o) {

  int count = 0;
  
  while (*str) {
    if (*str == o) {
      count++;
    }
    str++;
  }

  return count;
}
  

int main(void) {

  char str[100];
  char o;

  scanf("%s", str);

  getchar();

  o = 'o';

  if(str_chnum(str, o) == 0) {
    puts("700");
  }else if(str_chnum(str, o) ==1) {
    puts("800");
  }else if(str_chnum(str, o) == 2) {
    puts("900");
  }else {
    puts("1000");
  }

  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main(void){
    int n,m,ans=0;
    cin >> n;
    vector<int> t(n+1);
    for(int i=1; i<=n; i++){
        cin >> t[i];
        ans+=t[i];
    }
    cin >> m;
    int maxdif=-MOD,temp,prob;
    for(int i=0; i<m; i++){
        cin >> prob >> temp;
        cout << ans-(t[prob]-temp) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
 
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007;

int main(){
  string s;cin >> s;
  int sum[3] = {};
  for(int i = 0; i<s.size();i++){
    if(s.at(i)=='a') sum[0]+=1;
    else if(s.at(i)=='b') sum[1]+=1;
    else sum[2]+=1;
  }
  sort(sum,sum+3);
  if(sum[2] - sum[0] > 1){
    cout << "NO" << "\n";
  }else{
    cout << "YES" << "\n";
  }
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
int main()
{
    std::string str,exstr;
    while(std::cin >> str){
    if(str == "-"){
        break;
    }
    int exnum,b;
    std::cin >> exnum;
    std::vector<int> num;
    num.clear();
    for(int a = 0;a < exnum;a++){
        std::cin >> b;
        num.push_back(b);
        }
    for(int x : num){
        exstr = str.substr(0,x);
        str.erase(str.begin(),str.begin() + x);
        str += exstr;
        }
    std::cout <<str <<std::endl;
    }
    return 0;
}

Measured memory_bytes: 3180
#include <iostream>
#define INFTY 1000000001

using namespace std;

int count = 0;

void merge(int a[], int left, int mid, int right)
{
        int n1 = mid - left,
                n2 = right - mid;
        int *l = new int[n1 + 1],
                *r = new int[n2 + 1];

        for (int i = 0; i < n1; i++) {
                l[i] = a[left + i];
        }
        for (int i = 0; i < n2; i++) {
                r[i] = a[mid + i];
        }
        l[n1] = INFTY;
        r[n2] = INFTY;
        int i = 0, j = 0;
        for (int k = left; k < right; k++) {
                if (l[i] <= r[j]) {
                        a[k] = l[i];
                        i++;
                } else {
                        a[k] = r[j];
                        j++;
                }
                count++;
        }

        delete [] l;
        delete [] r;
}

void mergeSort(int a[], int left, int right)
{
        if (left + 1 < right) {
                int mid = (left + right) / 2;
                mergeSort(a, left, mid);
                mergeSort(a, mid, right);
                merge(a, left, mid, right);
        }
}

int main()
{
        int n;
        cin >> n;
        int *s = new int[n];
        for (int i = 0; i < n; i++) {
                cin >> s[i];
        }
        mergeSort(s, 0, n);
        for (int i = 0; i < n - 1; i++) {
                cout << s[i] << " ";
        }
        cout << s[n - 1] << endl << count << endl;
        delete [] s;

        return 0;
}

Measured memory_bytes: 5060
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <cmath>
#include <numeric>

#define rep(i,n) for(int i = 0;i < (n);i++)
#define repp(i,j, n) for(int i = (j);i < (n);i++)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define INF 1e9
#define MOD 1000000007

using namespace std;

typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<int, int> > vpi;
typedef vector<pair<ll, ll> > vpl;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  if(abs(n-m) > 1){
    cout << 0 << endl;
    return 0;
  }
  int mini = min(n, m), maxi = max(n, m);
  ll ans = 1;
  repp(i, 1, mini+1) ans = (ans*i)%MOD;
  if(m != n) ans = ((ans*ans)%MOD * maxi) % MOD;
  else ans = (2*ans*ans) % 1000000007;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long INF = 1e9 + 7;
using namespace std;
typedef long long ll;
map<int, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b;
	cin >> a >> b;
	cout << (a + b + 1) / 2 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define MAX 100000

ll N = 0;
ll p=0, g=0;
char temp;
string s;
int main() {
  cin >> s;

  rep(i,s.size()) {
    if (s[i] == 'g') {
      g++;
    } else {
      p++;
    }
    N++;
  }

  ll ans = N / 2;
  ans -= p;

  cout << ans << endl;
}


Measured memory_bytes: 512
#include <stdio.h>

int f(int x)
{
	return x * x;
}

int main(void)
{
	int d;
	int i;
	int ans;
	
	while (scanf( "%d", &d ) != EOF)
	{
		
		for (i = d, ans = 0; i < 600; i += d)
		{
			ans += f( i ) * d;
		}
		
		printf( "%d\n", ans );
	}
	
	return (0);
}

Measured memory_bytes: 592
#include <cstdio>

inline int min(int x, int y) {return x < y ? x : y;}

const int INF = 0x3f3f3f3f;
int a[105][105], f[105][105];

int main()
{
    //freopen("a.in", "r", stdin);
    int n, m;
    scanf("%d%d\n", &n, &m);
    for(int i = 1; i <= n; i++, getchar())
    for(int j = 1; j <= m; j++)
    {
        char c = getchar();
        a[i][j] = c == '.' ? 0 : 1;
    }
    for(int i = 1; i <= n; i++)
    for(int j = 1; j <= m; j++)
    {
        if(i == 1 && j == 1) {f[i][j] = a[i][j]; continue;}
        f[i][j] = INF;
        if(i != 1) f[i][j] = f[i - 1][j] + (a[i][j] && !a[i - 1][j] ? 1 : 0);
        if(j != 1) f[i][j] = min(f[i][j], f[i][j - 1] + (a[i][j] && !a[i][j - 1] ? 1 : 0));
    }
    printf("%d\n", f[n][m]);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <deque>

int main(){
  std::string S;
  std::cin >> S;
  int K;
  scanf("%d", &K);
  int n = S.length();
  std::string ans;
  for (int i=0; i<n; i++){
    int value = int(S[i])-int('a');
    if (value==0) {
      ans += S[i];
    } else if (K>=26-value){
      ans += 'a';
      K -= 26-value;
    } else {
      ans += S[i];
    }
  }
  //printf("K=%d\n", K);
  if (K>0) {
    int value = int(ans[n-1])-int('a');
    value += K%26;
    value %=26;
    ans[n-1] = 'a'+value;
  }
  std::cout << ans << std::endl;
  return 0;
}


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

int main () {
  int N ;
  cin >> N ;
  
  int line[N+1] ;
  int num[N+1] = {} ;
  
  for( int i = 1 ; i <= N ; i++ ) {
    cin >> line[i] ;
  }
  
  int pre = 1 ;
  
  bool can = false ;
  
  for(int i = 0 ; i < N ; i++ ){
    if( num[pre] != 1 ) {
      num[pre] += 1 ;
      if(line[pre] == 2 ){
        can = true ;
        break ;
      }
      pre = line[pre] ;
    } else {
      break ;
    }
  }
  
  int ans = 0 ;
  
  for(int i = 0 ; i < N + 1 ; i++ ) {
    ans += num[i] ;
  }
  
  if(can) cout << ans << endl ;
  else cout << -1 << endl ;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
# define ll  long long int
# define ld  long double
# define pb push_back
# define pp pop_back
# define ff first
# define ss second
# define mp make_pair
# define ac accumulate
# define mod 1000000007
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

void solve(){
	int n;
	cin >> n;
	int arr[n];
	int xo = 0;
	for(int i = 0; i < n; i++){
		cin >> arr[i];
		xo = xo^arr[i];
	}
	for(int i = 0; i < n; i++)
		cout << (xo^arr[i]) << " ";
}

int  main()
{
    #ifndef ONLINE_JUDGE
       freopen("input.txt", "r", stdin);
       freopen("output.txt", "w", stdout);
    #endif
     IOS;
     int t = 1;
     //cin >> t;
     while(t--){
     	solve();
     }
     return 0;
    
}

Measured memory_bytes: 4436
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
    int a,b,c;
int main(void){
    string S;
    cin>>S;
    for(int i=0;i<3;i++){
        if(S[i]=='a'){
            a++;
        }else if(S[i]=='b'){
            b++;
        }else if(S[i]=='c'){
            c++;
        }
    }
    if(a*b*c==0){
        cout<<"No"<<endl;
    }else{
        cout<<"Yes"<<endl;
    }
    
}


Measured memory_bytes: 256
// Dmitry _kun_ Sayutin (2019)

#include <bits/stdc++.h>

using std::cin;
using std::cout;
using std::cerr;

using std::vector;
using std::map;
using std::array;
using std::set;
using std::string;
using std::queue;

using std::pair;
using std::make_pair;

using std::tuple;
using std::make_tuple;
using std::get;

using std::min;
using std::abs;
using std::max;
using std::swap;

using std::unique;
using std::sort;
using std::generate;
using std::reverse;
using std::min_element;
using std::max_element;

#ifdef LOCAL
#define LASSERT(X) assert(X)
#else
#define LASSERT(X) {}
#endif

template <typename T>
T input() {
    T res;
    cin >> res;
    LASSERT(cin);
    return res;
}

template <typename IT>
void input_seq(IT b, IT e) {
    std::generate(b, e, input<typename std::remove_reference<decltype(*b)>::type>);
}

#define SZ(vec)         int((vec).size())
#define ALL(data)       data.begin(),data.end()
#define RALL(data)      data.rbegin(),data.rend()
#define TYPEMAX(type)   std::numeric_limits<type>::max()
#define TYPEMIN(type)   std::numeric_limits<type>::min()

int mod;

int add(int a, int b) {
    return (a + b >= mod ? a + b - mod : a + b);
}

int sub(int a, int b) {
    return (a >= b ? a - b : mod + a - b);
}

int mult(int a, int b) {
    return (int64_t(a)* b) % mod;
}

const int max_n = 3 * 2005;
int dp[max_n][2 * max_n];
// len, bal

int main() {
    std::iostream::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    // code here
    int n;
    cin >> n >> mod;

    dp[0][max_n] = 1;
    for (int len = 1; len <= 3*n; ++len) {
        for (int bal = -len; bal <= len; ++bal) {
            if (len >= 1)
                dp[len][max_n + bal] = add(dp[len][max_n + bal], dp[len - 1][max_n + bal - 1]);
            if (len >= 2)
                dp[len][max_n + bal] = add(dp[len][max_n + bal], mult(dp[len - 2][max_n + bal + 1], len - 1));
            if (len >= 3)
                dp[len][max_n + bal] = add(dp[len][max_n + bal], mult(dp[len - 3][max_n + bal], (len - 1) * (len - 2)));

            // if (dp[len][max_n + bal]) {
            //     cerr << len << "," << bal << "=" << dp[len][max_n + bal] << "\n";
            // }
        }
    }
    
    int result = 0;
    for (int bal = 0; bal < max_n; ++bal)
        result = add(result, dp[3*n][max_n + bal]);

    cout << result << "\n";

    return 0;
}


Measured memory_bytes: 281088
use proconio::{fastout, input};

#[fastout]
fn main() {
    input! {
        a: i64,
        b: i64,
        c: i64,
        k: i64,
    }
    if k <= a {
        println!("{}", k);
    } else if k <= a + b {
        println!("{}", a);
    } else if k <= a + b + c {
        println!("{}", 2 * a + b - k);
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;
ll const MOD = 1000000007;

vector<int> G[200010];


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

int N,M;
cin >> N >> M;

rep(i,M) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
}

// BFS のためのデータ構造
vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
queue<int> que;

// 初期条件 (頂点 0 を初期ノードとする)
dist[0] = 0;
que.push(0); // 0 を橙色頂点にする

// BFS 開始 (キューが空になるまで探索を行う)
while (!que.empty()) {
    int v = que.front(); // キューから先頭頂点を取り出す
    que.pop();

    // v から辿れる頂点をすべて調べる
    for (int nv : G[v]) {
        if (dist[nv] != -1) continue; // すでに発見済みの頂点は探索しない

        // 新たな白色頂点 nv について距離情報を更新してキューに追加する
        dist[nv] = dist[v] + 1;
        que.push(nv);
    }
}

if(dist[N - 1] == 2) puts("POSSIBLE");
else puts("IMPOSSIBLE");

return 0;
}

Measured memory_bytes: 13168
#include<stdio.h>
int main(void){
    int x,i,n;
    scanf("%d",&n);
    for(i=1; i<=n; i++){
        x = i;
        if(x%3==0){
            printf(" %d",i);
        }else if(x%10==3){
            printf(" %d",i);
        }else{
            while(x!=0){
                x/=10;
                if(x%10==3){
                    printf(" %d",i);
                    break;
                }
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string S; cin >> S;
    vector<Int> count(26, 0);

    rep(i, 0, S.size()) {
        count[S[i]-'A']++;
    }

    Int chars = 0, twos = 0;
    rep(i, 0, 26) {
        if (count[i] > 0) ++chars;
        if (count[i] == 2) ++twos;
    }

    if (chars == 2 and twos == 2) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

using LL = long long;
using PII = pair<int, int>;
using VI = vector<int>;

int n, ans = 0;
string a, b, c;

int main() {
    cin >> n >> a >> b >> c;
    set<char> tmp;
    REP(i, n) {
        tmp.clear();
        tmp.insert(a[i]);
        tmp.insert(b[i]);
        tmp.insert(c[i]);
        ans += (int)tmp.size() - 1;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <stdlib.h>
#include <queue>
#include <algorithm>
#include <vector>
#include <cstring>
#include <set>
#include <unordered_map>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
ll exgcd(ll a, ll b, ll &x, ll &y)
{
    if (!b)
    {
        x = 1;
        y = 0;
        return a;
    }
    ll d = exgcd(b, a % b, x, y);
    ll tmp = x;
    x = y;
    y = tmp - a / b * y;
    return d;
}
ll inv(ll a, ll m)
{
    ll x, y;
    ll d = exgcd(a, m, x, y);
    if (d == 1)
    {
        //处理负数
        return (x % m + m) % m;
    }
    return -1;
}
ll comb(ll numX,ll n){
    ll res=1;
    for(ll i=n;i>=n-numX+1;i--){
        res=(res*i)%mod;
    }
    for(ll i=2;i<=numX;i++){
        res=(res*inv(i,mod))%mod;
    }
    return res;
}
int main(){
    ll X,Y,tmp,n,numX,numY;
    scanf("%lld %lld",&X,&Y);
    if(X>Y){
        tmp=X;
        X=Y;
        Y=tmp;
    }
    if(((X+Y)%3!=0)||(Y>2*X)){
        printf("%d",0);
    }else{
        n=(X+Y)/3;
        numX=(n-(Y-X))/2;
        numY=numX+Y-X;
        printf("%lld",comb(numX,n));
    }
}

Measured memory_bytes: 384
// AtCoder Beginner Contest 129 - Problem A: Airplane (https://atcoder.jp/contests/abc129/tasks/abc129_a)
#include <bits/stdc++.h>

using namespace std;

int solve(int P, int Q, int R)
{
    return min({ P + Q, P + R, Q + R});
}

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

    int P, Q, R;
    cin >> P >> Q >> R;

    auto ans = solve(P, Q, R);

    cout << ans << '\n';

    return 0;
}


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

int main() {

    int N, W;
    cin >> N >> W;
    vector<int> v(N), w(N);
    rep(i, N) cin >> v[i] >> w[i];

    vector<int> dp(W + 1, -1);
    dp[0] = 0;

    for (int i = 0; i <= W; i++) {
        if (dp[i] != -1)
            for (int j = 0; j < N; j++) {
                if (i + w[j] <= W)
                    dp[i + w[j]] = max(dp[i + w[j]], dp[i] + v[j]);
            }
    }

    int ans = 0;
    rep(i, W + 1)
        ans = max(ans, dp[i]);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3156
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int gcd(int a,int b){
    if(a<b) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}

int k;

void solve(){
    cin >> k;
    ll ans=0;
    Rep(a,1,k+1){
        Rep(b,1,k+1){
            Rep(c,1,k+1){
                ans+=gcd(gcd(a,b),c);
            }
        }
    }
    cout << ans << endl;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int const MAX_N = 1000010;
vector<long long> prime;
vector<bool> is_prime(MAX_N,true);
void Eratosthenes() {
    is_prime[0] = is_prime[1] = false;
    for (long long i = 2;i*i < MAX_N;++i) if (is_prime[i]) for (long long j = 2*i;j < MAX_N;j += i) is_prime[j] = false;
    for (long long i = 0;i < MAX_N;++i) if (is_prime[i]) prime.push_back(i);
}

vector<pair<long long,int>> prime_factorization(long long a) {
    vector<pair<long long,int>> prime_factor;
    if (is_prime[0]) Eratosthenes();
    for (long long& i : prime) {
        if (i*i > a) break;
        if (a%i == 0) {
            pair<long long,long long> p = make_pair(i,0);
            while (a%i == 0) {
                a /= i;
                p.second++;
            }
            prime_factor.push_back(p);
        }
    }
    if (a != 1) prime_factor.push_back(make_pair(a,1));
    return prime_factor;
}

void rec(vector<long long>& div,vector<pair<long long,int>>& fact,int i,long long d) {
    if (i == fact.size()) {
        div.push_back(d);
        return;
    }
    for (int j = 0;j <= fact[i].second;++j) {
        rec(div,fact,i+1,d);
        d *= fact[i].first;
    }
}

// unsorted
vector<long long> divisor(long long a) {
    vector<long long> div;
    vector<pair<long long,int>> prime_factor = prime_factorization(a);
    rec(div,prime_factor,0,1);
    return div;
}

int main() {
    Eratosthenes();
    int n,g = 0;
    cin >> n;
    vector<int> cnt(1000010,0);
    for (int i = 0;i < n;++i) {
        int a;scanf("%d",&a);
        g = gcd(a,g);
        for (ll p : prime) {
            if (p*p > a) break;
            if (a%p) continue;
            cnt[p]++;
            while (a%p == 0) a /= p;
        }
        if (a > 1) cnt[a]++;
    }
    bool f = true;
    for (int i = 0;i < 1000010;++i) if (cnt[i] > 1) f = false;
    if (f) cout << "pairwise coprime" << newl;
    else if (g == 1) cout << "setwise coprime" << newl;
    else cout << "not coprime" << newl;
}

Measured memory_bytes: 8112
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <vector>
#include <stdio.h>
#include <cassert>

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

using namespace std;
using ll = long long;

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

    int a,b, t;
    cin >> a >> b >> t;
    cout << b * (t / a) << endl;
}

Measured memory_bytes: 384
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		while (true) {
			int H = sc.nextInt();
			int W = sc.nextInt();
			if (H==0&&W==0) {break;}
			for (int i=0; i<H; i++) {
				for (int j=0; j<W; j++) {
					System.out.print("#");
				}
				System.out.println();
			}
			System.out.println();
		}
	}
}



Measured memory_bytes: 35644
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>

using namespace std;

typedef  pair<int,int> P;
typedef long long LL;
typedef vector<LL> VEC;


const LL INF=1<<30;
const LL MOD=1000000007;

LL gcd(LL a,LL 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 kaijo(LL n){
    LL ans=1;
    for(LL i=1;i<=n;++i){
        (ans*=i)%=MOD;
    }
    return ans;
}


int main(){
    string s;
    cin>>s;
    string ans;
    for(int i=0;i<s.size();++i){
        if(i%2==0)ans+=s[i];
    }
    cout<<ans<<endl;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n;i>=0;i--)
#define rrepa(i,a,n) for(int i=n;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define maxs(a,b) a=max(a,b);
#define mins(a,b) a=min(a,b);

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;

int main(){
   
    string s;cin>>s;
    s+='<';
    // vi log;

    ll ans=0,c=0;
    int l=-1,tmp=-1;
    rep(i,s.length()){
        if(s[i]=='<'){
            if(l==-1){
                ans+=c*(c+1)/2;
                // rep(i,c)log.push_back(c-i);log.push_back(0);
                if(tmp>=c){
                    ans+=tmp-c+1;
                    // log[log.size()-1-c]=tmp+1;
                }
                c=0;
                l=0;
                tmp=0;
            }else{
                l++;
                tmp=l;
                ans+=l;
                // log.push_back(l);
            }
        }else{
            l=-1;
            c++;
        }
        // cerr<<s[i]<<"    ans="<<ans<<"  c="<<c<<"  l="<<l<<"  tmp="<<tmp<<endl;
    }
    // rep(i,log.size())cerr<<log[i]<<s[i];
    // cerr<<endl;
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 900
# solution

import sys
input = sys.stdin.readline

def find(x):
    if par[x] == x:
        return x
    else:
        return find(par[x])

def unite(x, y):
    x = find(x)
    y = find(y)

    if x != y:
        if rank[x] < rank[y]:
            par[x] = y
            size[y] += size[x]
        else:
            par[y] = x
            size[x] += size[y]
            if rank[x] == rank[y]:
                rank[x] += 1

def same(x, y):
    return find(x) == find(y)

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

par = [0] * N
for i in range(N):
    par[i] = i

rank = [1] * N
size = [1] * N
res = []

edge2 = [[0] for i in range(M)]
for i in range(M):
    edge2[i] = list(map(int, input().split()))

edge = [[0] for i in range(M)]
for i in range(M):
    edge[i] = [edge2[M - 1 - i][0] - 1, edge2[M - 1 - i][1] - 1]

for i in range(M):
    fi = find(edge[i][0])
    se = find(edge[i][1])

    if fi == se:
        res.append(0)
    else:
        res.append(size[fi] * size[se])
        unite(fi, se)

ans = 0
for i in range(M):
    ans += res[M - 1 - i]
    print(ans)

Measured memory_bytes: 48408
/* LETS SEE IF U CAN PULL IT UP THIS TIME OR NOT */
/* WORK HARD MAN ! IT DEFINETELY AIN'T EASY FOR THE PRIZE IT HOLDS .... */
/* GET YOUR ASS TO WORK ALREADY */
#include<bits/stdc++.h>

#define fast ios_base::sync_with_stdio(false); cin.tie(nullptr); cin.tie(nullptr);
#define int long long
#define pb emplace_back
#define ran(v) v.begin(),v.end()
#define mod 1000000007
#define inf 1e15
#define pii pair<int,int>
#define ff first
#define ss second
// #define N --

using namespace std;

int n;
vector<int> v;

int partySpy() {
	unordered_map<int, int> h;
	vector<pii> at(n);

	for (int i = 0; i < n; i++)
		at[i] = {v[i], i};

	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (h.count(at[i].ss - at[i].ff))
			cnt += h[at[i].ss - at[i].ff];
		h[at[i].ff + at[i].ss]++;
	}

	return cnt;
}

int32_t main() {
	fast
	cin >> n;
	v.resize(n);
	for (int &i : v)
		cin >> i;
	cout << partySpy() << endl;
}

Measured memory_bytes: 16096
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,s,f) for(i=s;i<f;i++)
#define print(v) for(auto &z:v) cout<<z<<' ';cout<<'\n'
#define hi cout<<'h'<<'i'<<'\n' 
#define pb push_back
#define pii pair<int,int>
#define F first
#define S second
#define B begin()
#define E end()
#define sz(v) (int)((v).size())
#define vi vector<int>
#define vii vector<pair<int,int>>
#define boost ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define clk1 clock_t start_time=clock()
#define clk2 cout<<(clock()-start_time)/(double)CLOCKS_PER_SEC
#define clean(arr) memset(arr,0,sizeof(arr))
#define mod 1000000007
#define mod2 998244353
#define space (1<<18)
//<<fixed << setprecision(9)
pii arr[18];
int dp[space][18];

int main()
{
    int n,i,j,t;
    boost;

    cin>>n;
    rep(i,0,n)cin>>arr[i].F;
    rep(i,0,n)cin>>arr[i].S;
    rep(i,0,1<<n)rep(j,0,n)dp[i][j]=1e9;
    int mask;
    rep(mask,1,(1<<n))
    {
        int lst,cnt=__builtin_popcount(mask);
        int empty=0;
        rep(lst,0,n)
        {
            if(mask&(1<<lst))
            {
                if(cnt==1)
                {
                    dp[mask][lst]=lst;break;
                }

                int pos=0;
                rep(j,0,n)
                {
                    if(lst==j)continue;
                    if(mask&(1<<j))
                    {
                        int prev=arr[j].F;
                        if((j-(cnt-2))%2!=0)prev=arr[j].S;
                        int cur=arr[lst].F;
                        if((lst-(cnt-1))%2!=0)cur=arr[lst].S;
                        if(cur>=prev)
                        {
                            dp[mask][lst]=min(dp[mask][lst],dp[mask^(1<<lst)][j] + empty);
                        }
                        
                    }
                }
            }
            else empty++;
        }
    }
    // rep(i,0,1<<n)
    // {
    //     rep(j,0,n)cout<<dp[i][j]<<" ";
    //     cout<<"\n";
    // }
    int mn=1e9;
    rep(i,0,n)mn=min(mn,dp[(1<<n)-1][i]);
    if(mn==1e9)cout<<"-1";
    else cout<<mn;

    return 0;
}



Measured memory_bytes: 18688
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
vector<ll> a;
vector<vector<int>> edge;
vector<int> used;

void dfs(int v,vector<ll>& c){
    if(used[v]) return;
    used[v]=true;
    c.push_back(a[v]);
    for(int i=0;i<edge[v].size();i++){
        dfs(edge[v][i],c);
    }
    return;
}


int main(){
    int n,m;
    cin>>n>>m;
    a.assign(n,0),edge.assign(n,vector<int>()),used.assign(n,false);
    for(int i=0;i<n;i++) cin>>a[i];
    for(int i=0;i<m;i++){
        int x,y;
        cin>>x>>y;
        edge[x].push_back(y);
        edge[y].push_back(x);
    }
    vector<vector<ll>> chunk;
    for(int i=0;i<n;i++){
        if(!used[i]){
            vector<ll> c;
            dfs(i,c);
            chunk.push_back(c);
        }
    }
    
    assert(chunk.size()==n-m);
    int cnt1=0;
    for(int i=0;i<chunk.size();i++) cnt1+=(chunk.size()==1);
    int cntb=n-m-cnt1;

    if(m==n-1){
        cout<<0<<endl;
    }
    else if(n==2 || cntb>=1 && n-cnt1-(cntb-1)*2>=cnt1){
        vector<ll> res;
        priority_queue<ll,vector<ll>,greater<>> que;
        for(int i=0;i<chunk.size();i++){
            int mi=0;
            for(int j=0;j<chunk[i].size();j++){
                if(chunk[i][j]<chunk[i][mi]) mi=j;
            }
            res.push_back(chunk[i][mi]);
            for(int j=0;j<chunk[i].size();j++){
                if(j!=mi) que.push(chunk[i][j]);
            }
        }
        while(res.size()<(n-m-1)*2){
            res.push_back(que.top());
            que.pop();
        }
        cout<<accumulate(res.begin(),res.end(),0LL)<<endl;
    }
    else{
        cout<<"Impossible"<<endl;
    }

    return 0;
}

Measured memory_bytes: 10932
N, K = map(int,input().split())
p = list(map(int,input().split()))
sumnation = sum(p[:K])
ans = sumnation
for i in range(N-K):
    sumnation -= p[i]
    sumnation += p[i+K]
    ans = sumnation if sumnation > ans else ans
ans = 0.5*K + 0.5*(ans)
print(ans)

Measured memory_bytes: 24804
#include<bits/stdc++.h>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
package main

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

func main() {
	defer flush()

	N := readInt()
	K := readInt()

	c := make([][]int, 2000+1)
	for i := 0; i < 2000+1; i++ {
		c[i] = make([]int, 2000+1)
	}
	c[0][0] = 1
	for i := 0; i < 2000+1; i++ {
		c[i][0] = 1
		for j := 1; j < i+1; j++ {
			c[i][j] = (c[i-1][j-1] + c[i-1][j]) % 1000000007
		}
	}

	f := func(n, k int) int {
		return c[n+k-1][k-1]
	}

	for i := 1; i <= K; i++ {
		println(f(K-i, i) * f(N-K-(i-1), i+1) % 1000000007)
	}
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

var stdoutWriter = bufio.NewWriter(os.Stdout)

func flush() {
	stdoutWriter.Flush()
}

func printf(f string, args ...interface{}) (int, error) {
	return fmt.Fprintf(stdoutWriter, f, args...)
}

func println(args ...interface{}) (int, error) {
	return fmt.Fprintln(stdoutWriter, args...)
}


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


int main() {
    ll N;
    cin >> N;
    vector<int> a(N);
    rep(i,N) cin >> a.at(i);
    ll ans = INFINITY;
    for (int i = -100; i <= 100; ++i) {
        ll sum = 0;
        ll base = i;
        rep(j,N) sum += (a.at(j) - base) * (a.at(j) - base);
        ans = min(ans, sum);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3616
#include<iostream>
#include<cstdio>
#include<cstring>
#define ll long long
#define N 100010
using namespace std;

ll l,last,ans,a,b,n,m,num[N],sum;

int main()
{
	ll i,j,p,q;
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&num[i]);
		sum+=num[i];
	}
	cin>>m;
	for(i=1;i<=m;i++)
	{
		scanf("%lld%lld",&p,&q);
		printf("%lld\n",sum+q-num[p]);
	}
}

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

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

    char c[n];
    scanf("%s", c);

    int sum[n];
    sum[0] = (c[0] == 'E');
    for (int i = 1; i < n; i++) {
        sum[i] = sum[i-1] + (c[i] == 'E');
    }

    int minNum = sum[n-1] - sum[0];
    for (int i = 1; i < n; i++) {
        int num = (i - sum[i-1]) + (sum[n-1] - sum[i]);
        minNum = min(minNum, num);
    }

    printf("%d\n", minNum);
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define dd double
#define MOD1 1000000007
#define MOD2 998244353
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ll t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=n-1;i>=0;i--)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<ll,ll> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m,ll MOD){if(m==0)return 1;ll t=mpowe(n,m/2,MOD);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;if(n==0) return -1;return logtwo(n/2)+1;}
#define maxn 1000005
int main()
{
    fastio();
 
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        ll a[n];
        cn(a,n);
        int prime[maxn]={0};
        for(int i=0;i<n;i++)
        {
            if(prime[a[i]]==0)
            {
                for(int j=1;j*a[i]<maxn;j++)
                {
                    prime[j*a[i]]++;
                }
            }
            else
            {
                prime[a[i]]++;
            }
        }
        int ans=0;
        for(int i=0;i<n;i++)
        {
            //cout<<a[i]<<" "<<prime[a[i]]<<endl;
            if(prime[a[i]]<=1)
                ans++;
        }
        cout<<ans<<endl;
    }
    
}

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

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

using Graph = vector<vector<int>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}

typedef pair<int,int> P;

bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int factorial(int a){
  int res = 1;
  while(a){
    res *= a;
    a--;
  }
  return res;
}

int main(){
  string s;
  cin >> s;
  int N = s.size();
  rep(i,N){
    if(s[i] == ',') cout << " ";
    else cout << s[i];
  }
  cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	string s;
	cin >> s;

	int N = 0;
	N = s.size();

	bool first = true, second = true, therd = true;

	for (int i = 0; i < N/2; ++i) {
		if (s.at(i) != s.at(N - i - 1)) {
			first = false;
		}
	}


	string s2;
	s2 = s.substr(0, (N - 1) / 2);

	int N2 = s2.size();

	for (int i = 0; i < N2 / 2; ++i) {
		if (s2.at(i) != s2.at(N2 - 1 - i)) {
			second = false;
		}
	}

	int N3 = (N + 3) / 2;
	string s3 = s.substr(N3 - 1);
	N3 = s3.size();

	for (int i = 0; i < N3 / 2; ++i) {
		if (s3.at(i) != s3.at(N3 - 1 - i)) {
			therd = false;
		}
	}

	if (first && second && therd) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 3632
a, b, x = map(int, input().split())

if a == b:
  if a%x == 0:
    print(1)
  else:
    print(0)
    
  exit(0)

a = a + (0 if a%x == 0 else x - a%x)
b = b - (0 if b%x == 0 else b%x)

print((b-a)//x + 1)

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

const int maxN = 2 * 1e5 + 1;

int n, q, cnt[maxN], lazy[maxN];
vector<int> G[maxN];

void push_down(int p) {
	if (lazy[p]) {
		for (int i = 0; i < G[p].size(); i++) {
			lazy[G[p][i]] += lazy[p];
		}
		lazy[p] = 0;
	}
}

void dfs(int u) {
	cnt[u] += lazy[u];
	push_down(u);
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		dfs(v);
	}
}

int main() {
	scanf("%d%d", &n, &q);
	for (int i = 1; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
	}
	for (int i = 1; i <= q; i++) {
		int u, d;
		scanf("%d%d", &u, &d);
		lazy[u] += d;
	}
	dfs(1);
	for (int i = 1; i <= n; i++) {
		printf("%d ", cnt[i]);
	}
	return 0;
}


Measured memory_bytes: 21120
// finish date: 2018/06/16
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <climits>
#include <functional>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
#define ll long long
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvvi vector<vector<vector<int>>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define pii pair<int,int>
const int bigmod = 1000000007;
#define INF 1050000000

ll solve(vvl xyz, vi sign, int M) {
    vl S(xyz.size());
    rep(i, S.size()) {
        S[i] = xyz[i][0] * sign[0] + xyz[i][1] * sign[1] + xyz[i][2] * sign[2];
    }
    sort(S.begin(), S.end(),greater<ll>());
    ll ans = 0;
    rep(i, M) {
        ans += S[i];
    }
    return ans;
}

int main() {
    int N, M;
    cin >> N >> M;
    vvl xyz(N, vl(3, 0));
    rep(i, N) {
        cin >> xyz[i][0] >> xyz[i][1] >> xyz[i][2];
    }
    ll ma = solve(xyz, {1, 1, 1}, M);
    ma = max(ma,solve(xyz,{1,1,-1},M));
    ma = max(ma,solve(xyz,{1,-1,1},M));
    ma = max(ma,solve(xyz,{1,-1,-1},M));
    ma = max(ma,solve(xyz,{-1,1,1},M));
    ma = max(ma,solve(xyz,{-1,1,-1},M));
    ma = max(ma,solve(xyz,{-1,-1,1},M));
    ma = max(ma,solve(xyz,{-1,-1,-1},M));
    cout << ma << endl;

    return 0;
}






Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    int N, M, A, d, sum=0, i;
    scanf("%d %d", &N, &M);

    for(i=1; i<=M; i++)
    {
        scanf("%d", &A);
        sum=sum+A;
    }
    d=N-sum;
    if(d<0)
    {
        printf("-1\n");
    }
    else
    {
        printf("%d\n", d);
    }
    return 0;

}


Measured memory_bytes: 1732
#include <cmath>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

double dp[40][40][40];
double p[40];

int main(){
	double pi = acos(-1.0);
	
	int n, m;
	double x;
	while( scanf("%d%d", &n, &m), n != 0 ){
		fill(**dp, **dp + sizeof(dp) / sizeof(double), -1e300);

		for(int i = 0; i < n; ++i){
			scanf("%lf", &x);
			p[i] = x * 2.0 * pi;
		}

		for(int i = 0; i < n; ++i)
		for(int j = i + 1; j < n; ++j){
			dp[1][i][j] = 0.5 * sin(p[j] - p[i]);
		}

		for(int i = 2; i < m; ++i)
		for(int s = 0; s < n; ++s)
		for(int k = s; k < n; ++k)
		for(int f = k + 1; f < n; ++f){
			x = dp[i - 1][s][k] + 0.5 * sin(p[f] - p[k]);
			dp[i][s][f] = max(dp[i][s][f], x);
		}
		
		double ans = 0.0;
		for(int s = 0; s < n; ++s)
		for(int f = s + m - 1; f < n; ++f){
			ans = max(ans, dp[m-1][s][f] + 0.5 * sin(p[s] - p[f]) );
		}
		
		printf("%f\n", ans);
	}
}

Measured memory_bytes: 1640
n, m = map(int, input().split())
a = [int(input()) for i in range(m)]

mod = 10**9+7
dp = [-1]*(n+1)
dp[0] = 1
dp[1] = 1

for i in a:
    dp[i] = 0

for i in range(2, n+1):
    if dp[i] < 0:
        dp[i] = (dp[i-1] + dp[i-2])%mod

print(dp[n])

Measured memory_bytes: 7848
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
void Say(bool say, string a = "Yes", string b = "No"){cout << (say ? a : b) << endl;};

int main(){

    ll N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B) << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


using namespace std;

#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = n-1;i >= 0;--i)
#define FOR(i, m, n) for(int i = m;i < n;++i)
#define FORR(i, m, n) for(int i = m-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>pii;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 1e9 + 7; constexpr int MAX = 200020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e16;
void yes(bool c) { if (c)print("Yes"); else print("No"); };


int p5(int x) {
	return x * x*x*x*x;
}

void solve() {
	int X; cin >> X;
	REP(A, 1e5) {
		int a5 = A * A*A*A*A;
		int rem = X - a5;
		if (rem >= 0) {
			int ok = 0, ng = 5e3;
			while (abs(ok - ng) > 1) {
				int mid = (ok + ng) / 2;
				if (p5(mid) <= rem)ok = mid;
				else ng = mid;
			}
			if (p5(ok) == rem) {
				pe(A); print(-ok);
				return;
			}
		}
		else {
			rem = -rem;
			int ok = 0, ng = 5e3;
			while (abs(ok - ng) > 1) {
				int mid = (ok + ng) / 2;
				if (p5(mid) <= rem)ok = mid;
				else ng = mid;
			}
			if (p5(ok) == rem) {
				pe(A); print(ok);
				return;
			}
		}
	}
}
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



Measured memory_bytes: 3620
#include <iostream>
#include <fstream>
#include <cassert>
#include <typeinfo>
#include <vector>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <iomanip>
#include <cctype>
#include <random>
#include <complex>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<28;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

const int M=10;

int n;
string s;

int main(){
	while(1){
		cin>>n;
		if(!n) break;
		cin>>s;
		s+="0u";
		vi dp(1<<M),b(M);
		dp[0]=1;
		vvi a;
		int I=0;
		for(int i=0;i<s.size();i++){
			if(s[i]=='u'){
				if(I!=i){
					string t=s.substr(I,i-I-1);
					int T=t.size();
					vi c(T);
					for(int j=0;j<T;j++){
						c[j]=t[j]-'0';
						b[t[j]-'0']++;
					}
					b[s[i-1]-'0']++;
					a.push_back(c);
				}
				I=i+1;
			}
		}
		b[0]--;
		int sum=0;
		for(int i=0;i<M;i++){
			sum+=b[i];
			if(!b[i]){
				vi c(1);
				c[0]=i;
				a.push_back(c);
			}
		}
		if(!sum){
			cout<<"SAFE"<<endl;
			continue;
		}
		int A=a.size();
		for(int i=0;i<A;i++){
			int S=a[i].size(),bit=0;
			for(int j=0;j<S;j++){
				int v=a[i][j];
				if(bit&1<<v) break;
				bit+=1<<v;
				for(int k=0;k<1<<M;k++) if((k&bit)==bit) dp[k]|=dp[k-bit];
			}
		}
		cout<<(dp[(1<<M)-1]?"UNSAFE":"SAFE")<<endl;
	}
}

Measured memory_bytes: 3284
r,g,b,n=map(int,input().split())
ctr=0
l=[r,g,b]
l.sort()
num_1=n//l[2]+1
for i in range(num_1):
    for k in range((n-i*l[2])//l[1]+1):
        if (n-i*l[2]-k*l[1])%l[0]==0:
            ctr+=1
print(ctr)


Measured memory_bytes: 3060
#include "iostream"

int main()
{
    int32_t a, b;
    std::cin >> a >> b;

    const int32_t mul = a * b;

    if (mul % 2 == 0) {
        std::cout << "Even" << std::endl;
    }
    else { 
        std::cout << "Odd" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll N, T;
  cin >> N >> T;
  vector<ll> t(N);
  for (int i = 0; i < N; i++) {
    cin >> t[i];
  }
  ll ans = T;
  ll cur = 0;
  for (int i = 1; i < N; i++) {
    if (t[i] < cur + T) {
      ans += t[i] - cur;
    } else {
      ans += T;
    }
    cur = t[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4852