akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const long long INF = 1LL << 60;
using namespace std;

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

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

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

  rep(i, 1000)
  {
    char s1 = '0' + (i / 100);
    char s2 = '0' + ((i % 100) / 10);
    char s3 = '0' + ((i % 10));

    char chars[] = {s1, s2, s3};
    char tmp = 0;
    rep(i, n)
    {
      if (chars[tmp] == s[i])
      {
        if (tmp == 0)
        {
          tmp = 1;
          continue;
        }
        if (tmp == 1)
        {
          tmp = 2;
          continue;
        }
        if (tmp == 2)
        {
          ans++;
          break;
        }
      }
    }
  }

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


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

int main( void )
{
    int n,a,b;
    cin >> n >> a >> b;
    
    int ans = min(a*n,b);
    
    cout << ans << endl;
}


Measured memory_bytes: 256
/**
 * Created by hiramekun at 19:43 on 2019-10-25.
 */
#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template<typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for(auto& i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template<class T>
ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template<class T>
istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template<class T>
ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll k;
    cin >> k;
    vl a(k);
    cin >> a;
    reverse(all(a));

    ll low = 2, high = 2;
    for (ll i = 0; i < k; ++i) {
        if (high - low >= a[i] || low % a[i] > high % a[i] || low % a[i] == 0 || high % a[i] == 0) {
            low = ll(ceil(double(low) / a[i])) * a[i];
            high = (high / a[i]) * a[i] + a[i] - 1;
        } else {
            cout << -1 << '\n';
            return;
        }
    }
    cout << low << ' ' << high << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{	
	int num=0,i,ge,shi,bai,qian,wan,a,b;
	
	scanf("%d%d",&a,&b);
	
	for (i=a;i<=b;i++)
	{
		ge=i%10;
		shi=i%100/10;
		//bai=i%1000/100;
		qian=i%10000/1000;
		wan=i/10000;
		
		if (ge==wan&&shi==qian)
		{
			num++;
		}
	}
	
	printf("%d",num);
	return 0;
 } 

Measured memory_bytes: 128
/*input
3
0.30 0.60 0.80
*/
#include <bits/stdc++.h>
using namespace std;

double dp[3005][3005], p[3005];

int main(){
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		scanf("%lf", p + i);
	}
	dp[1][0] = 1.0 - p[1], dp[1][1] = p[1];
	for(int i = 2; i <= n; i++){
		dp[i][0] = dp[i - 1][0] * (1.0 - p[i]);
		for(int j = 1; j <= i; j++){
			dp[i][j] = dp[i - 1][j] * (1.0 - p[i]) + dp[i - 1][j - 1] * p[i]; 
		}
	}
	double ans = 0.0;
	for(int i = n / 2 + 1; i <= n; i++){
		ans += dp[n][i];
	}
	printf("%.9lf\n", ans);

	return 0;
}

Measured memory_bytes: 68992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, k, a, ans;
int main()
{
	scanf("%lld%lld", &n, &k);
	for (ll i = k+1; i <= n; i++)
	{
		// imagine it is b
		a = n/i;
		ll b = i-k;
		ans += a * (b);
		ans += max((ll)0, n-(a*i)-k+(!!k));

		//printf("%lld %lld\n", i, ans);
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int l[5];
	char c;
	while (cin >> l[0] >> c >> l[1] >> c >> l[2] >> c >> l[3] >> c >> l[4]) {
		sort(l, l + 5);
		if (l[0] == l[1] && l[1] == l[2] && l[2] == l[3])
			cout << "four card";
		else if (l[4] == l[1] && l[1] == l[2] && l[2] == l[3])
			cout << "four card";
		else if (l[0] == l[1] && l[1] == l[2] && l[4] == l[3])
			cout << "full house";
		else if (l[0] == l[1] && l[3] == l[2] && l[4] == l[3])
			cout << "full house";
		else if (l[4] == l[3] + 1 && l[3] == l[2] + 1 && l[2] == l[1] + 1 && l[1] == l[0] + 1)
			cout << "straight";
		else if (l[0] == 1 && l[1] == 10 && l[2] == 11 && l[3] == 12 && l[4] == 13)
			cout << "straight";
		else if (l[0] == l[1] && l[1] == l[2])
			cout << "three card";
		else if (l[3] == l[1] && l[1] == l[2])
			cout << "three card";
		else if (l[3] == l[4] && l[3] == l[2])
			cout << "three card";
		else if (l[0] == l[1] && l[2] == l[3])
			cout << "two pair";
		else if (l[0] == l[1] && l[4] == l[3])
			cout << "two pair";
		else if (l[2] == l[1] && l[4] == l[3])
			cout << "two pair";
		else if (l[0] == l[1] || l[1] == l[2] || l[2] == l[3] || l[3] == l[4])
			cout << "one pair";
		else cout << "null";
		cout << endl;
	}
}

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

using namespace std;

int main(void){
    
    string s,t;
    cin >> s >> t;
    
    string ans = "";
    for (int i = 0; i < (int)t.size()-1; i++) ans += t[i];
    
    if (s == ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3628
#include<stdio.h>
int main()
{
    int N,a,b,x,y;
    scanf("%d %d %d",&N,&a,&b);
    x=N*a;
    if(x<b)
    {
        printf("%d\n",x);
    }
    else
    {
        printf("%d\n",b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

template<typename H> void print(H head) { std::cout << head << std::endl; }

// nCa を求める
ll mod_combination(ll n, ll a, ll sum)
{
  const ll MAX_LOG_V = 30;

  ll ans = sum;
  for (ll i = n; i >= n - a + 1; i--) {
    ans = (ans * i) % MOD;
  }

  for (ll i = 1; i <= a; i++) {

    std::vector<ll> vd(MAX_LOG_V, i);
    for (ll k = 0; k+1 < MAX_LOG_V; k++) {
      vd[k+1] = (vd[k] * vd[k]) % MOD;
    }

    // Aで割りたい時は, A の M-2 乗で掛ければ良い
    ll calc = 1LL;
    for (ll k = MAX_LOG_V - 1; k >= 0; k--) {
      if ((MOD-2) >> k & 1) {
	calc = (calc * vd[k]) % MOD;
      }
    }
    ans = (ans * calc) % MOD;
  }

  return ans;
}

int main()
{
  ll N, M, K;
  std::cin >> N >> M >> K;

  // 2個の距離を求めて, それぞれの組み合わせを掛ける場合,
  // ......
  // ...B..
  // ......
  // .A..C.
  //
  // のような K=3のケースで A, B の距離を求めると, B, C の距離が混ざってくるような勘違いをしたが,
  // 上図のように A, B を固定して距離を求めた場合の C の配置の通り数を掛け算し,
  // A, B の組合わせを列挙しては C の配置のパターンで掛けたものを足していくと,
  //
  // ......
  // ...A..
  // ......
  // .C..B.
  //
  // A, B を 上図のような配置にした場合の, C の配置の通り数の掛け算も, もれなく足されるので,
  // (A, B の全て配置の組み合わせでの距離の総和) ✕ Combination(N*M-2, K-2) になる
  //
  // 高さN = 4, 幅 M = 6 のgridで, A, B の高さ方向の距離を求める場合, 距離 d=2 の場合を考えると
  //
  // ★ ケース 1
  // ......
  // ...#..  A で M 通り取れる
  // ......
  // .#....  B で M 通り取れる
  //
  // ★ ケース 2
  // ...#..  A で M 通り取れる
  // ......
  // .#....  B で M 通り取れる
  // ......
  //
  // というように, 高さ 4 - 2 で 2通り取れる (N-d)
  // M * M * (N-d) の　Σ を取れば良い.
  ll distance_sum = 0LL;
  for (ll d = 1; d < N; d++) {
    distance_sum = (distance_sum + d * M * M * (N-d)) % MOD;
  }

  // 同様に 横方向も 距離を求める
  for (ll d = 1; d < M; d++) {
    distance_sum = (distance_sum + d * N * N * (M-d)) % MOD;
  }

  // distance_sum * mod_combination(N*M-2, K-2) だと溢れたため,
  // combination 処理で, distance_sum に少しずつ掛け算していくことにした
  distance_sum = mod_combination(N*M-2, K-2, distance_sum);
  print(distance_sum);

  return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
typedef unordered_map<ll,unordered_map<ll,ll>> graph;

const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;

ll h,w;
string s;
ll a[e3][e3];
ll ans = 0;
queue<vl> q;

int main(){
  cin >> h >> w;
  for(ll i = 1;i <= h;i++){
    cin >> s;
    for(ll j = 1;j <= w;j++){
      a[i][j] = s[j-1];
    }
  }
  for(ll i = 1;i <= h;i++){
    for(ll j = 1;j <= w;j++){
      if(a[i][j] == '#') q.push(vl({i,j,0}));
    }
  }
  while(!q.empty()){
    ll x = q.front()[0];
    ll y = q.front()[1];
    ll c = q.front()[2];
    ans = max(ans,c);
    if(a[x+1][y] == '.') q.push(vl({x+1,y,c+1}));
    if(a[x-1][y] == '.') q.push(vl({x-1,y,c+1}));
    if(a[x][y+1] == '.') q.push(vl({x,y+1,c+1}));
    if(a[x][y-1] == '.') q.push(vl({x,y-1,c+1}));
    a[x+1][y] = a[x-1][y] = a[x][y+1] = a[x][y-1] = '#';
    q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 119604
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <iostream>
#include <vector>
#include <bitset>
#include <queue>
#include <map>
#include <utility>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define MOD 10000000000+7    //10億　= 10^9になってる
#define juu 100000               //10万 10e5
#define hyaku 1000000            //100万　10e6
#define mINF -922337200085470000 //llのmax-1桁の小さい方
#define pINF 922337203600070000  //llのmax-1桁のデカい方
#define uINF 1844674407300000000 //ullのmax-1桁してる
#define pi 3.1415926535897932384
ll factor[300];
ll memory[300];
/*素朴法で計算
factorは必ずmemset(factor,0,sizeof(factor));
グローバルであるmemoryに個数を書き込む
memory配列の走査にはfactorの要素を使う*/
void primefac(ll num)
{
    int i = 0, kosuu = 0;
    while (*(factor + i) != 0)
    {
        while (num % *(factor + i) == 0)
        {
            num /= *(factor + i);
            memory[*(factor + i)] += 1;
        }
        if (num == 1)
            break;
        i++;
    }
}
/*グローバルにあるfactorに素数書き込む.個数を返すので配列は-1しろforは<*/
int elast(ll number)
{
    ll tmp = 0;
    int flag = 0;
    *factor = 2;
    for (int i = 3; i <= number; i++)
    {
        flag = 0;
        for (int j = 0; j <= tmp; j++)
        {
            if (i % (*(factor + j)) == 0)
            {
                flag = 1;
                break;
            }
        }
        if (flag)
            continue;
        tmp += 1;
        *(factor + tmp) = i;
    }
    return tmp + 2;
}
/*整数をqsortする為だけのもの*/
long long compare(const long long *a, const long long *b)
{
    if (*a < *b)
        return -1;
    else if (*a > *b)
        return 1;
    return 0;
}
/*intで収まる範囲であってくれ*/
ll nCr(int n, int r)
{
    ll val = 1;
    int i;
    if (r == 0)
        return 1;
    for (i = 0; i < n - r; i++)
    {
        val *= (n - i);
        val /= (i + 1);
    }
    return val;
}
/*intで収まる範囲であってくれ*/
ll nPr(int n, int r)
{
    ll val = 1;
    int i;
    for (i = 0; i < r; i++)
    {
        val *= (n - i);
    }
    return val;
}

void chmin(ll &a, ll b)
{
    if (a > b)
        a = b;
}
void chmax(ll &a, ll b)
{
    if (a < b)
        a = b;
}

/*
qsort(array,length,sizeof(int),(int(*)(const int*, const int*))compare);
使う時これをコピペ
*/


int main()
{
    string a;
    cin >> a;
    for(int i=0;i < a.size();i++)
    {
    	if(a[i] == 'B')
    	{
    		a.erase(a.begin()+i);
    		if((a.begin()+i)!=a.begin()){
    		a.erase(a.begin()+i-1);
    		i-=2;
    			//cout << i<<endl;
    		continue;}
    		i--;
    		//cout << i<<endl;
    	}
    }
    cout << a;
   // cout << "owari";
    return 0;
}


Measured memory_bytes: 256
function main(stdin) {
  var splited = stdin.split('\n');
  var NKQ = splited[0].split(' ');
  var N = Number(NKQ[0]); //参加者数
  var K = Number(NKQ[1]); //開始時点の特典
  var Q = Number(NKQ[2]); //問題数
  splited.shift();  //splited : 正解者を格納した配列
  var points = [];  //参加者の得点
  for (var i = 0; i < N; i++){
    //intで開始時点の点数を格納
    points.push(K-Q);
  }
  for (var j = 0; j < Q; j++){
    points[Number(splited[j]) - 1] += 1;
  }
  for (var i = 0; i < N; i++) {
    if (points[i] > 0) {
      console.log('Yes');
    } else {
      console.log('No');
    }
  }
}

//console.log(main(require("fs").readFileSync("/dev/stdin", "utf8")));
main(require("fs").readFileSync("/dev/stdin", "utf8").trim());


Measured memory_bytes: 29488
n = int(input())
l = [int(x) for x in input().split()]

res = 0
for i in range(n-2):
    for j in range(i+1, n-1):
        if i == j: continue
        for k in range(j+1, n):
            if i == k or j == k:
                continue;
            if l[i] + l[j] > l[k] and l[k] + l[j] > l[i] and l[i] + l[k] > l[j] \
                    and l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
                #  print(l[i], l[j], l[k])
                #  print(i+1, j+1, k+1)
                res += 1


print(res)


Measured memory_bytes: 9228
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

int main() {

   int N;
   cin >> N;
   int x[N];
   int y[N];
   int h[N];

   for (int i = 0; i < N; i++) {
      cin >> x[i] >> y[i] >> h[i];
   }
   for (int cx = 0; cx <= 100; cx++) {
      for (int cy = 0; cy <= 100; cy++) {
         bool flg = false;
         map<int, int> mp;
         int H;
         for (int i = 0; i < N; i++) {
            if (h[i] != 0) {
               int Htmp = abs(x[i] - cx) + abs(y[i] - cy) + h[i];
               mp[Htmp]++;
            } 
         }
         if (mp.size() != 1) flg = false;
         else {
            H = mp.begin()->first;
            flg = true;
         }
         for (int i = 0; i < N; i++) {
            if (h[i] == 0) {
               if (H - abs(x[i] - cx) - abs(y[i] - cy) > 0) {
                  flg = false;
                  break;
               }
            }
         }
         if (flg) {
            cout << cx << " " << cy << " " << H << endl;
            return 0;
         }
      }
   }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	vector<int>v(9);
	{
		for (int i = 0; i < 9; ++i)cin >> v[i];
	}
	vector<int>perms(9);
	iota(perms.begin(), perms.end(), 0);
	int ans = 0;
	do {
		vector<int>nums(9);
		for (int i = 0; i < 9; ++i) {
			nums[perms[i]] = i+1;
		}
		bool flag = true;
		for (int i = 0; i < 9; ++i) {
			if (v[i] != -1 && v[i] != nums[i])flag = false;
		}
		if (!flag)continue;
		int aa = (nums[0] + nums[2] + nums[5]) * 1+ (nums[1] + nums[4]) * 10 + nums[3] * 100;
		int bb = (nums[8]) * 1 + (nums[7]) * 10 + (nums[6]) * 100;
		if (aa == bb)ans++;
	} while (next_permutation(perms.begin(), perms.end()));
	cout << ans << endl;
	return 0;
}

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

int x[(int)1e5+7];

int main()
{

    int n, a, b; cin >> n >> a >> b;


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

    long long ans = 0;
    for(int i = 1; i < n; ++i)
    {
        ans += (long long)min((x[i]-x[i-1])*1LL*a, (long long)b);
    }
    cout << ans << endl;





    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

ll binomialCoeff(ll n, ll k) 
{ 
    ll C[k+1]; 
    memset(C, 0, sizeof(C)); 
  
    C[0] = 1;  // nC0 is 1 
  
    for (ll i = 1; i <= n; i++) 
    { 
        // Compute next row of pascal triangle using 
        // the previous row 
        for (ll j = min(i, k); j > 0; j--) 
            C[j] = C[j] + C[j-1]; 
    } 
    return C[k]; 
} 

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=nxt();
    vector <ll> v(n);
    generate(all(v),nxtl);
    map <int,int> m2;
    for(auto i:v)
        m2[i]+=1;
    vector <ll> temp;
    for(auto it=m2.begin();it!=m2.end();it++)
        if(it->second>1){
            int val=it->second;
            val/=2;
            for(int i=0;i<val;i++)
                temp.push_back(it->first);
        }
        sort(all(temp),greater<int>());
    if(temp.size()<2)
        cout<<"0\n";
    else
        cout<<temp[0]*temp[1]<<endl;
    
    
    
    return 0;   
}




 
 


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define Would
#define you
#define please

int main() {
	int N;
	cin >> N;
	int A[100];
	rep(i, N) cin >> A[i];

	int minimum = 1000000001;
	int maximum = 0;
	rep(i, N) {
		minimum = min(A[i], minimum);
		maximum = max(A[i], maximum);
	}
	cout << maximum - minimum << "\n";

	Would you please return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010

ll N;
vector<ll> A;

signed main()
{
    cin >> N;
    A.resize(N);
    REP(i, N) { cin >> A[i]; }

    // 負の数をカウント
    ll minus = 0;
    REP(i, N) {
        if(A[i] < 0) { minus++; }
    }

    // 負の数が偶数なら全て消せる
    // 奇数なら一つ残るし、どこへでも移動可能
    ll sum = 0;
    ll min_a = LLINF;
    REP(i, N) {
        sum += abs(A[i]);
        min_a = min(min_a, abs(A[i]));
    }

    ll ans = 0;
    if(minus % 2 == 0) {
        ans = sum;
    }
    else {
        ans = sum - min_a * 2;
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 1024
N, M = map(int, input().split())
import sys
ans = 0
lst = []
kari = []
for i in range(N):
    if i == 0:
        lst += list(map(int, input().split()))
        lst = lst[1:]
#        print (lst)
    else:
        if lst == []:
            print (0)
            sys.exit()
        else:      
            kari = list(map(int, input().split()))
#            print ('kari ', kari)
            sakujo = []
            for j in lst:
                if j in kari[1:]:
                    pass
                else:
                    sakujo += [j]
#                    lst.remove(j) #ループの途中でlstから削除すると場所がずれる
#                    print (j)
            for k in sakujo:
                lst.remove(k)

#        print ('lst ', lst)
        if lst == []:
            print (0)
            sys.exit()

#print (lst)
ans = len(lst)
print (ans)


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

int32_t main(){
	fast;
	int k,s,ans =0;
	cin >> k >> s;
	for(int i=0 ; i<=k ; i++)
	{
		for(int j=0 ; j<=k ; j++)
			if(s - i - j >= 0 && s - i - j <= k)
				ans++;
	}
	cout << ans;
}



Measured memory_bytes: 3516
#include<iostream>
#include<map>
using namespace std;
#define df 0
#define rep(i,n) for(int i=0;i<(n);i++)

typedef long int li;
li ord(li a){
  li i=0;
  while(a%2==0){
    a/=2;
    i++;
  }
  return i;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n; cin >>n;
  li s=0;
  rep(i,n){
    li a; cin  >>a;
    s+=ord(a);
  }
  cout << s;
}

/// confirm df==0 ///


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#define int long long
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=2005;
int n,a[N],ans;
char s[N];

inline void dfs(int d){
	if(d==n){
		int ret=0,sum=0;
		for(int i=0;i<n;i++){
			sum=sum*10+s[i]-'0';
			if(a[i+1]) ret+=sum,sum=0;
		}
		ret+=sum;
//		cout<<"ret="<<ret<<endl;
		ans+=ret;
		return ;
	}
	dfs(d+1);
	a[d]=1;dfs(d+1);a[d]=0;
}

signed main(){
	cin>>s;n=strlen(s);
	dfs(1);
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
'''
考え方

なんらかの文字列IDを降って、指定した位置の文字の文字列IDが完全一致していること。
（アルファベットが何か、は関係ないので考慮しなくても良い）

なので、同一アルファベットがどの位置にあるか、というのが一致していればOK。

辞書型の変数を持つ。キーは「Sの文字列ID」、値は「その文字列IDが出現する位置」
'''


S = input()
T = input()
len_S = len(S)
len_T = len(T)

dict_s = {}
dict_t = {}
alphabets = 'abcdefghijklmnopqrstuvwxyz'

# INPUTの文字列ごとに、出現位置を辞書に格納する
for alphabet in alphabets:
  cnt = S.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_s[alphabet] = [i for i, x in enumerate(S) if x == alphabet]


# OUTPUTでも同じことをする
for alphabet in alphabets:
  cnt = T.count(alphabet)
  if cnt == 0:
    continue
  else:
    dict_t[alphabet] = [i for i, x in enumerate(T) if x == alphabet]


# 突合
dict_used = {}
cnt = 0
for key_src, value_src in dict_s.items():
  for key_trg, value_trg in dict_t.items():
    if value_src == value_trg and key_src not in dict_used:
      dict_used[key_src] = 1
      cnt += 1
      break


if len(dict_s) == cnt:
  print("Yes")
else:
  print("No")

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

using pint = pair<int,int>;
int main() {
    int N, K; cin >> N >> K;
    int ma = (N-1)*(N-2) / 2;
    if (ma < K) cout << -1 << endl;
    else {
        vector<pint> res;
        for (int i = 1; i <= N-1; ++i) res.push_back({i, N});
        
        int rem = ma - K;
        int ci = 1, cj = 2;
        for (int _ = 0; _ < rem; ++_) {
            res.push_back({ci, cj});
            
            ++cj;
            if (cj == N) {
                ++ci;
                cj = ci + 1;
            }
        }
        
        cout << res.size() << endl;
        for (auto p : res) cout << p.first << " " << p.second << endl;
    }
}

Measured memory_bytes: 384
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

n,m = map(int,input().split())
ans = 1
for i in make_divisors(m):
    if m // i >= n:
        ans = i
    else:
        break
print(ans)

Measured memory_bytes: 3064
import collections

n = int(raw_input())
v = map(int, raw_input().split())

even = [vi for i,vi in enumerate(v) if i % 2 == 0]
odd  = [vi for i,vi in enumerate(v) if i % 2 == 1]

evenc = collections.Counter(even)
oddc = collections.Counter(odd)

evenc_most_common = evenc.most_common(len(set(even))) + [(None, 0)]
oddc_most_common = oddc.most_common(len(set(odd))) + [(None, 0)]

m = []

for i in range(2):
    for j in range(2):
        if evenc_most_common[i][0] != oddc_most_common[j][0]:
            a = len(even) - evenc_most_common[i][1]
            b = len(odd) - oddc_most_common[j][1]
            m.append(a+b)
print(min(m))


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



int main(){
    int N;
    cin >> N;
    std::vector<int> d(N);
    for(int i=0; i < N; i++){
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    int margin = d[N/2] - d[N/2 - 1];
    cout << margin << endl; 
}


Measured memory_bytes: 640
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
if a[0]>x:
    d=a[0]-x
    ans+=d
    a[0]=x

for i in range(N-1):
    tmp=a[i]+a[i+1]
    ans+=max(tmp-x,0)
    a[i+1]=a[i+1]-max(tmp-x,0)

print(ans)

Measured memory_bytes: 14544
#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 ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
using namespace std;

int main(){
    int n,c=0;
    cin>>n;
    vector<int> a(n),b(n);
    rep(i,n){
        cin>>a[i];
        b[i]=i+1;
        if (a[i]!=b[i]) c++;
    }
    if (c<=2) {
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll [[maybe_unused]] = long long;
using ull [[maybe_unused]] = unsigned long long;
using ld [[maybe_unused]] = long double;

[[maybe_unused]] static constexpr int mod = (int)1e9 + 7;
[[maybe_unused]] static constexpr int inf = 100100100;
[[maybe_unused]] static constexpr ll linf = (ll)1e18;
[[maybe_unused]] static constexpr double eps = 1e-9;
[[maybe_unused]] static constexpr double pi = 3.14159265359;
[[maybe_unused]] static constexpr double e = 2.71828182846;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, a, b) for (ll i = a; i < b; ++i)
#define rrrep(i, a, b) for (ll i = a; i >= b; --i)
#define all(obj) begin(obj), end(obj)
#define rall(obj) rbegin(obj), rend(obj)
#define pb push_back
#define fst first
#define snd second



int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    set<int> AD;
    for (int i = 1; i <= A; ++i) {
        if (A % i == 0) AD.insert(i);
    }
    set<int> BD;
    for (int i = 1; i <= B; ++i) {
        if (B % i == 0) BD.insert(i);
    }
    vector<int> ans;
    for (int i : AD) {
        if (BD.count(i)) {
            ans.pb(i);
        }
    }
    sort(rall(ans));
    cout << ans[K - 1] << endl;
}


Measured memory_bytes: 888
S = input()
l = len(S)
for i in range(1 << (l-1)):
    a = int(S[0])
    sum_t = int(S[0])
    st = S[0]
    for j in range(l-1):
        if ((i >> j) & 1):
            st += "+"
            st += S[j+1]
            sum_t += int(S[j+1])
        else:
            st += "-"
            st += S[j+1]
            sum_t -= int(S[j+1])
    if sum_t == 7:
        print("{}=7".format(st))
        break

Measured memory_bytes: 3064
#include<bits/stdc++.h> 
using namespace std;
int n;
long long ans , s[3100][3100] , c[3100][3100] , p[3100 * 3100];
long long t , v = -1 , vv , mod;
inline long long exp( long long a , long long b , long long mod )
{
	long long ans = 1 , t = a;
	while(b)
	{
		if(b & 1)
		{
			ans *= t; ans %= mod;
		}
		b >>= 1;
		t *= t; t %= mod;
	}
	return ans;
}
void init()
{
	p[0] = 1; c[0][0] = s[0][0] = 1;
	for(int i = 1 ; i <= n * n ; i++ ) p[i] = p[i - 1] * 2 % mod;
	for(int i = 1 ; i <= n + 1 ; i++ )
	{
		s[i][0] = 0; c[i][0] = 1;
		for(int j = 1 ; j <= i ; j++ )
		{
			s[i][j] = (s[i - 1][j - 1] + s[i - 1][j] * j) % mod;
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}
	return ;
}
int main()
{
	scanf("%d%lld" , &n , &mod);
	init();
	for(int i = 0 ; i <= n ; i++ )
	{
		v *= -1;
		vv = exp(2 , exp(2 , n - i , mod - 1) , mod) * c[n][i] % mod;
		t = 0;
		for(int j = 0 ; j <= i ; j++ )
		{
			t += s[i + 1][j + 1] * p[(n - i) * j] % mod; t %= mod;
		}
		ans += t * v * vv % mod; ans = (ans % mod + mod) % mod;
	}
	printf("%lld" , (ans % mod + mod) % mod);
	return 0;
}

Measured memory_bytes: 167004
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  cout << z << " " << x << " " << y << endl;
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> v[n];
  rep(i,m){
    int x,y,z;
    cin >> x >> y; x--; y--;
    v[x].emplace_back(y);
  }
  for(auto to:v[0]){
    for(auto nxnx:v[to]){
      if(nxnx==n-1){
        cout << "POSSIBLE" << endl; return 0;
      }
    }
  }
  cout << "IMPOSSIBLE" << endl;
  return 0;
}

Measured memory_bytes: 8576
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 100005
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int d, cnt, num[MAXN], f[MAXN][105];
char k[MAXN];

int solve(int x, int res, int lead, int lim)
{
	if(x==cnt+1) return ((!lead) && res==0);
	if(f[x][res]!=-1 && !lim && !lead) return f[x][res];
	int temp=0;
	for(rint i=0; i<=(lim?num[x]:9); ++i)
	{
		int t=(res+d*10-i)%d;
		temp=(temp+solve(x+1, t, lead&&(i==0), lim&&(i==num[x])))%p;
	}
	if(!lim && !lead) f[x][res]=temp;
	return temp;
}

int main()
{
	memset(f, -1, sizeof(f));
	scanf("%s%d", k+1, &d);
	cnt=strlen(k+1);
	for(rint i=1; i<=cnt; ++i) num[i]=k[i]-'0';
	printf("%d\n", solve(1, 0, 1, 1));
	return 0;
}

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

int main(){
    string s;
    cin>>s;
    int n=s.size();
    rep(i,8){
        string ret=s.substr(0,i)+s.substr(n-7+i);
        if(ret=="keyence"){
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
// 

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

// bが二番目に小さいか否か
bool check(int a, int b, int c) {
    if ((a < b && b < c) || (c < b && b < a)) {
        return true;
    }
    return false;
}

int main() {
    int n;
    cin >> n;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }

    int count = 0;

    for (int i = 1; i < n - 1; i++) {
        if (check(p[i - 1], p[i], p[i + 1])) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


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

using namespace std;

int main(void)
{
  int n;
  int a,b;

  cin>>n;
  cin>>a>>b;

  for(int i=a;i<=b;i++)
  {
    if(i%n==0)
    {
      cout<<"OK"<<endl;
      return 0;
    }
  }

  cout<<"NG"<<endl;
  return 0;
}


Measured memory_bytes: 3632
#include <iostream>
 
 
using namespace std;
 
  
 
int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if (a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if (b <= c && c <= a)
        cout << b << " " << c << " " << a << endl;
    else if (b <= a && a <= c)
        cout << b << " " << a << " " << c << endl;
    else if (c <= b && b <= a)
        cout << c << " " << b << " " << a << endl;
    else if (c <= a && a <= b)
        cout << c << " " << a << " " << b << endl;
}


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

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    cout << c << " " << a << " " << b << endl; 
}

Measured memory_bytes: 256
import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def prime_numbers(n):
    if n < 2:
        return []

    m = (n + 1) // 2
    p = [1] * m
    for i in range(1, int((n ** 0.5 - 1) / 2) + 1):
        if p[i]:
            p[2 * i * (i + 1) :: 2 * i + 1] = [0] * (((m - 1) - 2 * i * (i + 1)) // (2 * i + 1) + 1)

    return {2} | {2 * i + 1 for i in range(1, m) if p[i]}


def main():
    primes = prime_numbers(10 ** 5)
    A = [n % 2 and n in primes and (n + 1) // 2 in primes for n in range(10 ** 5 + 1)]
    B = [0]
    B.extend(accumulate(A))

    Q, *LR = map(int, read().split())
    ans = [0] * Q
    for i, (l, r) in enumerate(zip(LR[::2], LR[1::2])):
        ans[i] = B[r + 1] - B[l]

    print(*ans, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29720
#include <bits/stdc++.h>
#define rep(i, l, r) for (int i = l; i <= r; ++i)
#define red(i, r, l) for (int i = r; i >= l; --i)
#define re(i, n) for(int i = 0; i < n; ++i)
#define db(x) cout << #x << "=" << (x) << " "
#define el cout << endl
using namespace std;
const int MXN = 200010;

char str[MXN];
int nxt[MXN][26], far[MXN], l[MXN], n;
void calc(int i, int len)
{
    if (len == 0)
        return;
    re(k, 26)
        if (l[nxt[i][k] + 1] + 1 == len)
        {
            putchar('a' + k);
            calc(nxt[i][k] + 1, len - 1);
            break;
        }
}
int main()
{
    scanf("%s", str + 1); n = strlen(str + 1);
    re(k, 26)
        nxt[n + 1][k] = n + 1, l[n + 1] = 1, l[n + 2] = 0;
    red(i, n, 1)
    {
        re(k, 26)
            nxt[i][k] = nxt[i + 1][k];
        nxt[i][str[i] - 'a'] = i;
        int j = str[i] - 'a';
        re(k, 26)
            if (nxt[i][j] < nxt[i][k])
                j = k;
        far[i] = j;
        l[i] = l[nxt[i][far[i]] + 1] + 1;
        //db(l[i]), db(far[i]), el;
    }
    calc(1, l[1]);
    putchar('\n');
    return 0;
}


Measured memory_bytes: 22272
#include <valarray>
#include <cstdio>
using namespace std;
typedef valarray<int>V;
int n,m,t;
V e,x,z,w;
void M(const V &_x,const V &_y){
	int i=0,j;
	if(t&1){
		for(;i<n;i++)for(j=0;j<n;j++)z[i*n+j]=(_x[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m,w[i*n+j]=(_y[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
		e=z;
	}else{
		for(;i<n;i++)for(j=0;j<n;j++)w[i*n+j]=(_y[slice(i*n,n,1)]*_y[slice(j,n,n)]).sum()%m;
	}
	x=w;
}
void O(const V &r,const V &s){
	int i=0;
    for(;i<n-1;i++)printf("%d ",(r[slice(i*n,n,1)]*s).sum()%m);
    printf("%d\n",(r[slice(i*n,n,1)]*s).sum()%m);
}
main(){
	int i,a,b,c;
	for(;scanf("%d%d%d%d%d%d",&n,&m,&a,&b,&c,&t),n;){
		x.resize(0);
		x.resize(n*n);
		e.resize(0);
		e.resize(n*n);
		z.resize(n*n);
		w.resize(n*n);

		x[0]=b;
		x[1]=c;
		e[0]=1;
		for(i=1;i<n-1;i++){
			x[i*n+i-1]=a;
			x[i*n+i]=b;
			x[i*n+i+1]=c;
			e[i*n+i]=1;
		}
		x[i*n+i-1]=a;
		x[i*n+i]=b;
		e[i*n+i]=1;
		for(;t;t>>=1)M(e,x);
		V s(n);
		for(i=0;i<n;i++)scanf("%d",&s[i]);
		O(e,s);
	}
}

Measured memory_bytes: 1100
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stdlib.h>
#include <map>
#include <cmath>
#define MOD_P 1000000007
#define ll long long
using namespace std;



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

	printf("%s", n < 3200 ? "red" : test.c_str());

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<map>
#include<cmath>
#include<vector>
#include<queue>
#include<set>
#include<stdio.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define INF 1e9

int main()
{
	int n, k;
	cin >> n >> k;
	int count = 0;
	while(n >= 1) {
		n -= 2;
		count++;
		if (count == k) break;
	}
	cout << (count == k ? "YES":"NO") << endl;
	return 0;
}

Measured memory_bytes: 508
#include <bits/stdc++.h>
#define arep(a,i,n) for(ll i=(a);i<(n);i++)
#define rep(i,n) for(ll i=0;i<(n);i++)
#define cinf(x,n) for(ll i=0;i<(n);i++)cin>>x[i];
#define coutf(x,n) for(ll i=0;i<(n);i++)cout<<x[i]<<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

bool chart[101][101];
int a[101],x[101],y[101];
int cnt;

int main(){
	int w,h,n;
	cin >> w >> h >> n;
	rep(i,n){
		cin >> x[i] >> y[i] >> a[i];
	}

	rep(i,n){
		switch(a[i]){
			case 1:
			rep(j,x[i]){
				rep(k,h){
					chart[j][k]=true;
				}
			}
			break;
			case 2:
			arep(x[i],j,w){
				rep(k,h+1){
					chart[j][k]=true;
				}
			}
			break;
			case 3:
			rep(j,y[i]){
				rep(k,w){
					chart[k][j]=true;
				}
			}
			break;
			case 4:
			arep(y[i],j,h){
				rep(k,w){
					chart[k][j]=true;
				}
			}
			break;
		}
	}
	rep(i,w){
		rep(j,h){
			if(!chart[i][j])
				cnt++;
		}
	}
	cout << cnt << endl;

	/*for(ll j=h-1;j>=0;j--){
		rep(i,w){
			if(chart[i][j])
				cout << "*";
			else
				cout << "#";
		}
		cout << endl;
	}*/
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define MOD 1000000007LL
# define INF (1 << 29)
/* ちゃんと考えてわかって実装 */


ll mul_mod(ll a, ll b, ll modp){
    return (a * b) % modp;
}


ll mod_pow(ll x, ll n, ll modp){
    ll res = 1;
    while(n > 0){
        if(n & 1) res = res * x % modp;
        x = x * x % modp;
        n >>= 1;
    }
    return res;
}

ll mod_comb(ll n, ll k, ll modp){
    ll X = 1;
    for(int i=0; i<k; i++){
        X = mul_mod(X, n-i, modp);
    }
    ll Y = 1;
    for(int i=0; i<k; i++){
        Y = mul_mod(Y, k-i, modp);
    }
    ll Y_pow = mod_pow(Y, modp-2, modp);
    return mul_mod(X, Y_pow, modp);
}

int main(void){
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = mod_pow(2LL, n, MOD) - 1LL;
    ans = (ans + MOD - mod_comb(n, a, MOD)) % MOD;
    ans = (ans + MOD - mod_comb(n, b, MOD)) % MOD;
    cout << ans << endl;
    return 0;
}

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


ll dp[101010][3];
int main(){
    int n;cin>>n;
    ll a[n][3];
    rep(i,n)rep(j,3)cin>>a[i][j];
    rep(i,n){
        dp[i+1][0]=a[i][0]+max(dp[i][1],dp[i][2]);
        dp[i+1][1]=a[i][1]+max(dp[i][0],dp[i][2]);
        dp[i+1][2]=a[i][2]+max(dp[i][1],dp[i][0]);
    }
    cout<<max(dp[n][0],max(dp[n][1],dp[n][2]))<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<math.h>
#include<algorithm>
#include<cstring>
using namespace std;
int n, x, d[100007], tmp, ans;
int gcd(int a, int b)
{
	return b ? gcd(b, a%b) : a;
}
int main()
{

	cin >> n >> x;
	scanf("%d", &tmp);
	ans = abs(tmp - x);
	for (int i = 1; i < n; i++) {
		scanf("%d", &tmp);
		ans = gcd(abs(tmp - x), ans);
	}
	cout << ans << endl; system("pause");
	return 0;

}



Measured memory_bytes: 504
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i, n) for (int i=0; i<n; ++i)
#define all(obj) (obj).begin(),(obj).end()
using namespace std;
typedef long long ll;
long long GCD(long long x, long long y) { return y ? GCD(y, x%y) : x; }

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


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

ans = 0
while True:
    tmp = 0
    for i in range(n):
        k = -(-(a[i]+1)//n)-1
        tmp += k
        a[i] -= k*n
        a[i] -= k
    for i in range(n):
        a[i] += tmp
    if not tmp:
        break
    ans += tmp

print(ans)

Measured memory_bytes: 39664
d = int(input())
c = list(map(int, input().split()))
score = []
for i in range(d):
    score.append(list(map(int, input().split())))
last_day = [0 for i in range(26)]
for i in range(d):
    ans = 0
    max_score = -10**9
    for j in range(1, 27):
        s = score[i][j-1]
        for k in range(1,27):
            if j == k:
                continue
            else:
                s -= c[k-1] * (d - i+1 - last_day[k-1])
        if s > max_score:
            ans = j
            max_score = s
    print(ans)


Measured memory_bytes: 69008
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);



int main(){
  string s;
  string t;
  cin >> s;
  REP(i,s.size()){
    if(i == 4 || i == 7) continue;
    t += s[i];
  }
  if(t > "20190430") cout << "TBD" << endl;
  else cout << "Heisei" << endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
const int INF = 1000000001;

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  if(c-b>a) cout << "dangerous" <<endl;
  if(c-b<=0) cout <<"delicious" <<endl;
  if(0 < c-b && c-b<=a) cout << "safe" <<endl;
}

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

using namespace std;

int main(){
	int N;
	int count = 0;

	cin >> N;
	int a[N];

	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	while(true){
		bool odd = false;
		for(int j = 0; j < N; j++){
			if(a[j]%2 == 0) a[j] /= 2;
			else odd = true;
		}
		if(odd) break;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func abs(n int) int {
	return int(math.Abs(float64(n)))
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	k := nextInt()

	//2N ≤ Kのとき、操作0回で最小値を得る
	if 2*n < k {
		fmt.Println(n)
	} else {
		//N ≤ K < 2Nのとき、1回の操作で最小値を得る
		//K < Nのとき、N/K回またはN/K+1回の操作で最小値を得る
		if n < k {
			fmt.Println(abs(n-k))
		} else {
			fmt.Println(min(n%k, abs(n%k-k)))
		}
	}
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
using namespace std;

#define ll long long int

const int MOD = 1000000007;

int main() {

	char a, b;

	cin >> a >> b;

	if (a == 'H'&&b == 'H')cout << "H" << endl;
	else if (a == 'H'&&b == 'D')cout << "D" << endl;
	else if (a == 'D'&&b == 'H')cout << "D" << endl;
	else cout << "H" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	char a,b;
	cin >> a >> b;
	if ((a - 'A') == (b - 'A')){
		cout << '=' << endl;
	}
	else if((a  - 'A')> (b - 'A')){
		cout << '>' << endl;
	}
	else{
		cout << '<' << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = 0;
		char[] s = sc.next().toCharArray();
		if (s[0] == '1') count++;
		if (s[1] == '1') count++;
		if (s[2] == '1') count++;
		System.out.println(count);
	}
}


Measured memory_bytes: 22612
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    A = sorted([int(x) for x in input().strip().split()], reverse=True)
    ans = A[0]
    for n in range(2, N):
        ans += A[n//2]
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 31676
def InsertionSort(A, n, g):
    c = 0
    for i in range(g, n):
        v, j = A[i], i - g
        while j>=0 and A[j] > v:
            A[j+g] = A[j]
            j -= g
            c += 1
        A[j+g] = v
    return c
def shellSort(n, A):
    cnt, G, gm = 0, [], 1
    while True:
        G = [gm] + G
        if gm*5+1 > n: break
        gm = 5*gm +1
    m = len(G)
    print(m)
    print(*G)
    for i in range(m):
        cnt += InsertionSort(A,n,G[i])
    return cnt


def ALDS1_2D():
    N = int(input())
    A = [int(input()) for n in range(N)]
    print(shellSort(N, A))
    for i in range(N):print(A[i])

if __name__ == '__main__':
    ALDS1_2D()

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

int N;
int x[10], y[10];

double dist(int i, int j) {
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return pow(dx * dx + dy * dy, 0.5);
}

void solve() {
    cin >> N;
    for(int i = 1; i <= N; i++) cin >> x[i] >> y[i];
    double ans = 0.0;
    for(int i = 1; i <= N; i++) {
        for(int j = i + 1; j <= N; j++) ans += dist(i, j) * 2 / N;
    }
    cout << fixed << setprecision(10) << ans << endl;
    return;
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

int main()
{
  i64 n;
  cin >> n;
  vector<i64> x(n);
  for (i64 i = 0; i < n; i++)
    cin >> x[i];
  sort(x.begin(), x.end());
  i64 p = (x[0] + x[n - 1]) / 2;
  cout << max(abs(p - x[0]), abs(p - x[n - 1])) << endl;
  return 0;
}



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

using namespace std;
typedef long long ll;

int main() {
    ll h,w;
    ll a;
    cin >> h >> w;
    if (h == 1)
        cout << h;
    else if (w == 1)
        cout << w;
    else {
        a = h * w;
        if (a % 2 == 0)
            cout << a / 2;
        else
            cout << a / 2 + 1;
    }
}


Measured memory_bytes: 256