akhauriyash/Code-Regression huggingface dataset:
// Remeber Choose Compiler: GCC9
#include <bits/stdc++.h>

using namespace std;

// Debug Output Utility
#ifdef LOCAL
#define dbg(args...)             \
    do {                         \
        cout << #args << " -> "; \
        err(args);               \
    } while (0)
void err() { std::cout << std::endl; }
template <typename T, typename... Args>
void err(T a, Args... args) {
    std::cout << a << ' ';
    err(args...);
}
template <template <typename...> class T, typename t, typename... A>
void err(const T<t> &arg, const A &... args) {
    for (auto &v : arg)
        std::cout << v << ' ';
    err(args...);
}
#else
#define dbg(...)
#endif

// Macro Definitions:
#define mp make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()

// Type Alias:
using int64 = long long;
using PII   = pair<int, int>;

// Global Const Variable
const int64 INF = 0x3f3f3f3f3f3f3f3f;
const int MOD   = 1000000007;
const int MAXN  = 1005;
const int M     = 1000005;

int a[MAXN];

void run() {
    int n,k;
    cin >> n >> k;
    for(int i=0;i<n;i++) cin >> a[i];
    sort(a,a+n);
    int ans = 0;
    for(int i=0;i<k;i++) ans += a[i];
    cout << ans << endl;
}

// Debug Input Redirection
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    run();
}

Measured memory_bytes: 3608
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<int, int>;

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int L, n; cin >> L >> n;
  vector<ll> x(n); rep(i, n) cin >> x[i];

  vector<ll> y(n);
  rep(i, n) {
    y[i] = L - x[n-1-i];
  }

  vector<ll> sumx(n+1);
  rep(i, n) {
    sumx[i+1] = sumx[i] + x[i];
  }
  vector<ll> sumy(n+1);
  rep(i, n) {
    sumy[i+1] = sumy[i] + y[i];
  }

  ll ans = 0;

  for(int d=0; d<n; d++) {
    ll now = 0;
    int cnt = n-d;
    now += (sumx[d+cnt/2] - sumx[d])*2;
    now += (sumy[(cnt-1)/2])*2;
    if (cnt%2 == 0) {
      now += y[(cnt-1)/2];
    } else {
      now += x[d+cnt/2];
    }
    chmax(ans, now);
  }

  for(int d=0; d<n; d++) {
    ll now = 0;
    int cnt = n-d;
    now += (sumy[d+cnt/2] - sumy[d])*2;
    now += (sumx[(cnt-1)/2])*2;
    if (cnt%2 == 0) {
      now += x[(cnt-1)/2];
    } else {
      now += y[d+cnt/2];
    }
    chmax(ans, now);
  }

  cout << ans << endl;
}


Measured memory_bytes: 6528
import sys,bisect
input = sys.stdin.readline

n = int(input())
c = list(map(int,input().split()))
c.sort()

mod = 10**9+7


se = pow(2,mod-2,mod)

res = 0
for i,e in enumerate(c):
    cnt = (pow(4,n,mod)%mod)*se%mod
    res = (res + (e*cnt))%mod
    res = (res + (e*pow(4,n-1,mod)%mod)*(n-1-i)%mod)%mod
print(res%mod)

Measured memory_bytes: 80852
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <queue>
using namespace std;
#define rep(i,n) for(i=0;i<n;i++)
typedef long long ll;
typedef pair <int,ll> pii;

double trap(double h1,double h2,double w)
{
  return 0.5*(h1+h2)*w;
}

int main(void)
{
  int n,tt;
  cin >> n;
  vector<int> t(n+5,0);
  cin >> t[0];
  vector<int> v(n+5,0);
  for(int i=1;i<n;i++)
    {
      cin >> tt;
      t[i]=tt+t[i-1];
    }
  for(int i=0;i<n;i++)
    {
      cin >> v[i];
    }
  v[n]=0;
  double cv=0.0,ans=0.0,prev=0.0;
  int ct=0;
  for(double i=0.5;i<=t[n-1];i+=0.5)
    {
      cv+=0.5;
      if(i>t[ct]) ct++;
      for(int j=0;j<n;j++)
	{
	  if(i<=t[j]) cv=min(cv,v[j+1]+(t[j]-i));
	}
      cv=min(cv,(double)v[ct]);
      ans+=trap(prev,cv,0.5);
      prev=cv;
    }
  cout  << fixed << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
using namespace std;
int main() {
	int r, c;
	int max = 0;
	char m[51][51];
	queue<int> bfs;
	queue<int> bfs1;
	int bfs2[50][50] = { 0 };
	int b1[4] = { 0,0,1,-1 };
	int b2[4] = { 1,-1,0,0 };
	cin >> r >> c;
	for (int a = 0; a < r; a++) {
		for (int b = 0; b < c; b++) {
			cin >> m[b][a];
		}
	}
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			if (m[j][i] == '#') {
				continue;
			}
			else {
				bfs.push(j);
				bfs1.push(i);
			}
			while (!bfs.empty()) {
				for (int i = 0; i < 4; i++) {
					if (m[bfs.front() + b1[i]][bfs1.front() + b2[i]] == '.' && bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]] == 0) {
						bfs.push(bfs.front() + b1[i]);
						bfs1.push(bfs1.front() + b2[i]);
						bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]] = bfs2[bfs.front()][bfs1.front()] + 1;
						if (bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]] > max) {
							max = bfs2[bfs.front() + b1[i]][bfs1.front() + b2[i]];
						}
					}
				}
				bfs.pop();
				bfs1.pop();
				bfs2[j][i] = -1000000;
			}
			for (int c = 0; c < 50; c++) {
				for (int d = 0; d < 50; d++) {
					bfs2[d][c] = 0;
				}
			}
		}
	}
	cout << max << endl;
}

Measured memory_bytes: 256
#include<algorithm>     //sort,二分探索,など
#include<bitset>        //固定長bit集合
#include<cmath>         //pow,logなど
#include<complex>       //複素数
#include<deque>         //両端アクセスのキュー
#include<fstream>       //ファイルストリーム（標準入力変更用）
#include<functional>    //sortのgreater
#include<iomanip>       //setprecision(浮動小数点の出力の誤差)
#include<iostream>      //入出力
#include<iterator>      //集合演算(積集合,和集合,差集合など)
#include<map>           //map(辞書)
#include<numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include<queue>         //キュー
#include<set>           //集合
#include<stack>         //スタック
#include<string>        //文字列
#include<unordered_map> //イテレータあるけど順序保持しないmap
#include<unordered_set> //イテレータあるけど順序保持しないset
#include<utility>       //pair
#include<vector>        //可変長配列

//名前
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef map<string, int> msi;
typedef map<string, ll> msll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pllll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef vector<vector<string>> vvs;
typedef vector<vector<bool>> vvb;

//定数
const ll MOD = 1000000007;
const ll INF = 1000000000000000000;

//マクロ
#define rep(i,n) for(int i=0;i<n;i++)
#define reps(i,s,e) for(int i=s;i<e;i++)
#define repse(i,s,e) for(int i=s;i<=e;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define in1(x1) cin >> x1
#define in2(x1, x2) cin >> x1 >> x2
#define in3(x1, x2, x3) cin >> x1 >> x2 >> x3
#define inN(x, N) rep(i, N) in1(x[i])
#define outl(x) cout << x << endl
#define out2l(x, y) cout << x << " " << y << endl 

//よく使う関数
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

    //標準入力をファイルに変更
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());

    int N;
    in1(N);

    vll L(N);
    inN(L, N);

    auto m = *max_element(all(L));
    auto s = accumulate(all(L), 0LL) - m;

    if (m < s)
    {
        outl("Yes");
    }
    else
    {
        outl("No");
    }

    return 0;
}


Measured memory_bytes: 3624
use std::io::{self, Read, BufRead};
use std::process::exit;

fn main() {
    let n: i64 = {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim().parse().unwrap()
    };
    let mut x = 1i64;
    let x_max = ((0.75 * n as f64) + 0.01) as i64;
    while x <= x_max {
        let mut y = 1i64;
        let y_max = (((2 * n * x) as f64 / (4 * x - n) as f64) + 0.01) as i64;
        while y <= y_max {
            let a = x * y * n;
            let b = 4 * x * y - y * n - x * n;
            if b > 0 && a % b == 0 {
                println!("{} {} {}", x, y, a / b);
                exit(0);
            }
            y += 1;
        }
        x += 1;
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <stdio.h>
#include <string>
#include <string.h>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <stdlib.h>

using namespace std;

int main (void)
{
	int a,b,c,d;
	cin >> a >> b >> c >> d;

	int w = 0,y = 0,z = 0;
	w = a - c;
	y = a - b;
	z = b - c;
	if (w < 0)
	{
		w = w - w - w;
	}
	if (y < 0)
	{
		y = y - y - y;
	}
	if (z < 0)
	{
		z = z - z - z;
	}

	if (w <= d)
	{
		cout << "Yes" << endl;
	}
	else if (y <= d && z <= d)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


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


class Program
{
    public static List<long> ret = new List<long>();

    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        var n = long.Parse(Console.ReadLine());
        //int[] n = Console.ReadLine().Split().Select(int.Parse).ToArray();

        divisor(n);
        //Array.Sort(ret);

        var ans = long.MaxValue;
        for (int i = 0; i < ret.Count; i++)
        {
            var tmp1 = ret[i].ToString().Length;
            var tmp2 = (n/ret[i]).ToString().Length;
            ans = Math.Min(ans , Math.Max(tmp1,tmp2));
        }

        // 出力
        Console.WriteLine(ans);
    }

    public static void divisor(long n)
    {
        for (long i = 1; i * i <= n; i++)
        {
            if (n % i == 0)
            {
                ret.Add(i);
                if (i * i != n) ret.Add(n / i);
            }
        }
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <cmath>
#include <string>
#include <sstream>
#include <iomanip>
#include <complex>
using namespace std;

#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
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;}

#define intmax 1299710
int isprime[intmax];
void makeprime(){
	REP(i,intmax) if(i%2!=0) isprime[i] = true;
	isprime[1] = false;
	isprime[2] = true;
	for(ll int i=3;i<sqrt(intmax);i+=2){
		for(ll int j=i+2;j<intmax;j+=2){
			if(j%i==0) isprime[j] = false;
		}
	}
}
int main(){
	int cnt = 0;
	int n;
	cin >> n;
	REP(i,n){
		ll int tmp;
		cin >> tmp;
		if(tmp==1) continue;
		if(tmp==2||tmp==3){
			cnt++;
			continue;
		}
		if(tmp%2==0) continue;
		bool flag = true;
		for(ll int j=3;j<sqrt(tmp)+1;j+=2){
			if(tmp%j==0){
				flag = false;
			}
		}
		if(flag) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1168
N = int(input())
F = []
P = []

# F(i,j,k): 0:biz, 1:holiday
# i:shop
# j:week (1-5)
# F(i,j,0),F(i,j,1), F(i,j+1,0), F(i,j+1,0)
for _ in range(N):
    F.append([int(x) for x in input().split()])
for _ in range(N):
    P.append([int(x) for x in input().split()])

maxprofit = None
for i in range(1, 2**10):
    schedule = [int(x) for x in "{:010b}".format(i)]

    profit = 0
    for f,p in zip(F, P):
        c = sum(schedule[x] == f[x] and schedule[x] for x in range(10))
        profit += p[c]
    if maxprofit is None:
        maxprofit = profit
    else:
        maxprofit = max(maxprofit, profit)
        
print(maxprofit)




Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
using namespace std::chrono; 
#define ll long long
#define fo(i,v,e) for(v=i;v<e;v++)
#define pb(x) push_back(x)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define fi first 
#define se second
#define vl vector<ll>
#define vi vector<int>
#define vb vector<bool>
#define all(v) v.begin(),v.end()
#define sz(x) (int)x.size()
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x);
#else
#define deb(x...)
#endif

vector<ll> sieveOfErthnosis(ll n)
{
    vector<bool>flag(n+5,false);
    vector<ll>primes;
    for(int i=2;i*i<=n;i++)
    {
        if(!flag[i])
        {
            for(int j=i*i;j<=n;j+=i)
            {flag[j]=true;}
        }
    }
    for (int  i = 2; i < n+1; i++)
    {
        if(!flag[i])primes.pb(i);
    }
    return primes;
}
void solve()
{
  ll n,i,j;
  string s,res="";cin>>s;
  n = sz(s);
  while(sz(res)<n)
  {
      res+="hi";
  }
  if(s==res)
  {
      cout<<"Yes";
  }
  else
  {
      cout<<"No";
  }
  
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    // freopen("input.txt","r",stdin);
    // freopen("output.txt","w",stdout);
    #endif
    auto start = high_resolution_clock::now(); 
    int T = 1;  
    // cin>>T;
	while(T--)
	{
		solve();
	}
    auto stop = high_resolution_clock::now(); 
	auto duration = duration_cast<microseconds>(stop - start); 
    #ifndef ONLINE_JUDGE
	// cout << "time taken : "<<duration.count()<<" ms" << endl;
     #endif
}

Measured memory_bytes: 256
N = int(input())
li = list(map(int,input().split()))

def main():
    count = 1

    for i in range(len(li)):
        #print(i)
        for j in range(i):
            if li[j] > li[i]:
                #print("li[j]:%d vs li[i]:%d", %(li[j], li[i]))
                break
            elif j == i-1:
            #    print(j)
                count += 1
            #else:
            #    print('j:%d vs i:%d' % (j, i))
            #    print('li[j]:%d vs li[i]:%d' % (li[j], li[i]))
            #    print("error")

    print(count)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
function Main(input) {
	var len = parseInt(input.split("\n")[0]);
  var list = input.split("\n")[1].split(" ").map((list)=>Number(list));
   var output = 0;
  list.sort(function(a,b){
  	return b - a;
  });
  
  var count = 0;
  while(count < len){
    output += parseInt(list[(count * 2) + 1]);
    count++
  }
  console.log(output);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 37704
#include "stdio.h"

int main() {

  int a[3][3];
  for(int i = 0; i < 3; i++)
  	scanf("%d %d %d", &a[i][0], &a[i][1], &a[i][2]);
  
  int n;
  scanf("%d", &n);
  
  int b;
  
  int c[3][3] = {0};
  
  for(int i = 0; i < n; i++) {
	scanf("%d", &b);
    
    for(int i = 0; i < 3; i++) {
      for(int j = 0; j < 3; j++) {
      	if(b == a[i][j])
          c[i][j] = 1;
      }
    }
  }
  
  int p, q, r = 0;
  for(int i = 0; i < 3; i++) {
    for(int j = 0; j < 3; j++) {
      p += c[i][j];
      q += c[j][i];
    }
    if(p == 3 || q == 3)
      break;
    else {
      p = 0;
      q = 0; 
    } 
  }
    
  r = c[0][0] +	c[1][1] + c[2][2];
  
  if(r != 3) {
    r = c[0][2] + c[1][1] + c[2][0];
  }
  
  if(p == 3 || q == 3 || r == 3)
  	printf("Yes");
  else
    printf("No");
  
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
 
int main(){
    int K;
    int A;
    int B;
    scanf("%d\n",&K);
    scanf("%d %d",&A,&B);
    if (A%K==0) {
        printf("OK\n");
    }
    if (A%K!=0) {
        while(A%K>=0){
            if(A>B){
            printf("NG\n");
                break;
            }
            if (A%K==0) {
                printf("OK\n");
                break;
              }
            A=A+1;
        }
    }
  return 0;
}


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

int main() {
  int N , a , b , c , d ;
  cin >> N;
  a = N/1000;
  b = (N-1000*a)/100;
  c = (N-1000*a-100*b)/10;
  d = N-1000*a-100*b-10*c;
  if (((a==b)&&(b==c))||((b==c)&&(c==d))) {
    cout << " Yes " << endl;
  }
  else {
    cout << " No " << endl;
  }
}

Measured memory_bytes: 256
#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(){

  int x;
  cin >> x;

  for(int a = 1; a < 1000; ++a){
    ll a5 = 1;   //a^5
    REP(i,5) a5 *= a;

    for(int b = -1000; b < 1000; ++b){
      ll b5 = 1;
      REP(i,5) b5 *= b;
      if(a5 - b5 == x){
        cout << a << " "<< b << endl;
        return 0;
      }
    }
  }
  return 0;

}

Measured memory_bytes: 3624
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

const int N = 2e3 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 2e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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 pair <ll, ll> pll;


mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int n, cnt;
pii a[11];
double ans;
main() {
    file("censor");
    ios;
    cin >> n;
    fo(i, 1, n, 1) cin >> a[i].F >> a[i].S;
    sort(a + 1, a + n + 1);
    do {
        double len = 0;
        fo(i, 2, n, 1) len += sqrt((a[i].F - a[i - 1].F) * (a[i].F - a[i - 1].F) + (a[i].S - a[i - 1].S) * (a[i].S - a[i - 1].S));
        ans += len;
        ++cnt;
    } while (next_permutation(a + 1, a + n + 1));
    ans = ans * 1.0 / cnt;
    cout << fixed << setprecision(12) << ans;
    return 0;
}
/**

*/


Measured memory_bytes: 256
/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
  double n;
  cin >> n;
  cout << 2*n*3.1415<<endl;
}


Measured memory_bytes: 3784
#include <iostream>
#include <string>
#include <algorithm>
#include <ctime>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cassert>
#include <bitset>
#include <list>
#include <cstdio>
#include <stdio.h>
#include <string.h>
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
using namespace std;

int main()
{
    int a, b, t;
    cin >> a >> b >> t;
    int n = t/a;
    cout << n*b << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;

typedef struct Box{
    int num;
    bool red;
} Box;

int main(int argc, char const *argv[]) {
    int n, m;
    cin >> n >> m;
    vector<Box> b(n);
    b[0].red = true; b[0].num = 1;
    for (int i = 1; i < n; ++i) b[i].red = false, b[i].num = 1;

    REP(i,m) {
        int x, y;
        cin >> x >> y;
        --x; --y;
        if (b[x].red) {
            b[y].red = true; b[y].num++;
            b[x].num--;
            if (b[x].num == 0) b[x].red = false;
        }
        else {
            b[y].num++; b[x].num--;
        }
    }

    int ans = 0;
    REP(i,n) if (b[i].red) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#define rep(i,N) for(int i=0;i<(int)N;i++)
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  string S,T;
  cin>>N>>S;
  rep(i,N/2){T.push_back(S.at(i));}
  T=T+T;
  if(S==T){cout<<"Yes"<<endl;}
  else{cout<<"No"<<endl;}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _SCL_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <limits>
#include <numeric>
#include <valarray>
#include <fstream>

using namespace std;
typedef unsigned int uint;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<LL, LL> PP;
#define REP(i,a,n) for(LL i = (a); i < (LL)(n); ++i)
#define REM(i,a,n) for(LL i = ((n) - 1); i >= (a); --i)
#define FLOAT fixed << setprecision(16)
#define SPEEDUP {cin.tie(NULL); ios::sync_with_stdio(false);}
const int INF = 0x3FFFFFFF;
const LL INFLL = 0x3FFFFFFF3FFFFFFF;
const double INFD = 1.0e+308;
const string INFSTR = "\x7f";
const double EPS = 1.0e-9;

void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }
template <class T, class U>
istream& operator>>(istream& ist, pair<T, U>& right) { return ist >> right.first >> right.second; }
template <class T, class U>
ostream& operator<<(ostream& ost, const pair<T, U>& right) { return ost << right.first << ' ' << right.second; }
template <class T, class TCompatible, size_t N>
void Fill(T(&dest)[N], const TCompatible& val) { fill(dest, dest + N, val); }
template <class T, class TCompatible, size_t M, size_t N>
void Fill(T(&dest)[M][N], const TCompatible& val) { for (int i = 0; i < M; ++i) Fill(dest[i], val); }
template<class T>
T Compare(T left, T right) { return left > right ? 1 : (left < right ? -1 : 0); }
istream& Ignore(istream& ist) { string s; ist >> s; return ist; }
bool Inside(int i, int j, int h, int w) { return i >= 0 && i < h && j >= 0 && j < w; }
template <class ForwardIterator, class T>
bool All_of(ForwardIterator first, ForwardIterator last, const T& value) {
	for (; first < last; ++first) if (*first != value) return false; return true;
}
// all_of

#ifdef ONLY_MY_ENVIR
#include "IntMod.h"
#include "Union_Find.h"
#include "Graph.h"
#include "Range.h"
#include "Global.h"
#include "Flow_Solver.h"
#include "Tree.h"
#include "Suffix_Array.h"
#include "Geometry.h"
#include "Matrix.h"
#include "Segment_Tree.h"
#endif

#ifdef __GNUC__
typedef __int128 LLL;
istream& operator>> (istream& ist, __int128& val) { LL tmp;  ist >> tmp; val = tmp; return ist; }
ostream& operator<< (ostream& ost, __int128 val) { LL tmp = val; ost << tmp; return ost; }
#endif

#if 1234567891
#include <array>
#include <random>
#include <unordered_set>
#include <unordered_map>
template<typename T>
using PriorityQ = priority_queue<T, vector<T>, greater<T> >;	// コスト小を優先
#endif

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

	int ans = 0;
	if (s.size() == 1) {
		ans = s[0] - '0';
	} else if (all_of(s.begin() + 1, s.end(), [](char c) {return c == '9'; })) {
		ans = s[0] - '0' + (s.size() - 1) * 9;
	} else {
		ans = s[0] - '1' + (s.size() - 1) * 9;
	}
	cout << ans << endl;
	return 0;
}

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

int main () {
  int a,b;
  cin >> a>>b;
  if (b==100)
    b = 101 ;
  
  
  if( a ==0){
    cout << b  << endl;
  }
  
  else if(a ==1){
   cout << b*100 << endl;
  }
  
else{
  cout << b*10000 << endl;
}
}


Measured memory_bytes: 256
x, n = map(int, input().split())
listp = list(map(int, input().split()))
ans = []

if x in listp:
    for i in range(1,101):
        a = x + i
        b = x - i
        if a in listp and b in listp:
            continue
        else:
            if not a in listp:
                ans.append(a)
            
            if not b in listp:
                ans.append(b)

            if len(ans) > 0:
                break
else:
    print(x)
    exit()

print(min(ans))


Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
#define ll long long int  
#define lh long double
#define f(a,b,i) for(ll i=a;i<b;i++)

int main() {

  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
   string s;
   cin>>s;
   ll len=s.length();
   string r = s.substr(0, ((len-1)/2)); 
   string w=s.substr((len+3)/2-1,len-1); 
   string s1 = string(s.rbegin(), s.rend());
    string r1=string(r.rbegin(), r.rend());
    string w1=string(w.rbegin(), w.rend());

   if(s==s1 && r1==r && w1==w)
   	cout<<"Yes";
   else
   	cout<<"No";
  
  

}

   

    


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<int>>;

int main(){
  int H,W;
  vector<vector<int>> c(10,vector<int>(10));
  cin>>H>>W;
  for(int i=0;i<10;i++){
    for(int j=0;j<10;j++){
      cin>>c.at(i).at(j);
    }
  }
  vector<vector<int>> A(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>A.at(i).at(j);
    }
  }

  vector<int> point(10);
  vector<bool> seen(10,false);
  for(int i=0;i<10;i++){
    point.at(i)=c.at(i).at(1);
  }
  seen.at(1)=true;
  for(int i=0;i<10;i++){
    int k;
    int tmp=1000000;
    for(int j=0;j<10;j++){
      if(seen.at(j)){
        continue;
      }
      if(point.at(j)<tmp){
        tmp=point.at(j);
        k=j;
      }
    }
    seen.at(k)=true;
    for(int j=0;j<10;j++){
      point.at(j)=min(point.at(j),point.at(k)+c.at(j).at(k));
    }
  }

  int ans=0;
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(A.at(i).at(j)==-1){
        continue;
      }
      ans+=point.at(A.at(i).at(j));
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 384
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
//#include <intrin.h>

#define fore(i,a,b) for(int i = a; i < (b); i++)
#define fr(i,a,b) for(int i = a - 1; i >= b; i--)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define N 300005
#define inf 2000000000
#define EPS 1e-6
#define MOD (ll)1e15
#define __builtin_popcount(x) __popcnt(x)

using namespace std;

typedef long long ll;
typedef pair<int, int> pr;
typedef pair<int, pair<int, int>> tup;

inline void solve()
{
	int n;
	cin >> n;
	vector<int> v(n);
	fore(i, 0, n)
		cin >> v[i];

	int otv = inf;

	fore(i, 0, 101)
	{
		int o = 0;
		fore(j, 0, n)
			o += (v[j] - i) * (v[j] - i);
		otv = min(o, otv);
	}

	cout << otv;
}

int main()
{
	fast;
#if defined(_DEBUG)
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	int q = 1;
	//cin >> q;
	while (q--)
	{
		solve();
		cout << '\n';
	}
}

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

int main()
{
	int N;
	cin>>N;
	vector<int> A(N);
	for(int i=0; i<N; i++) cin>>A[i];
	
	for(int i=0; i<N; i++)
		if(A[i]%2==0 && A[i]%3!=0 && A[i]%5!=0)
		{
			cout<<"DENIED";
			return 0;
		}
	
	cout<<"APPROVED";
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static int INF = 1 << 30;
	static long LINF = 1L << 55;
	static int MOD = 1000000007;
	static int[] mh4 = { 0, -1, 1, 0 };
	static int[] mw4 = { -1, 0, 0, 1 };
	static int[] mh8 = { -1, -1, -1, 0, 0, 1, 1, 1 };
	static int[] mw8 = { -1, 0, 1, -1, 1, -1, 0, 1 };

	static class TaskX {

		public void solve(int testNumber, InputReader in, PrintWriter out) {

			char[] s = in.nextString().toCharArray();
			boolean ok = true;

			if (s[0] != 'A') ok = false;
			int c = 0;
			for (int i = 2; i < s.length-1; i++) {
				if (s[i] == 'C') c++;
			}
			if (c != 1) ok = false;
			for (int i = 0; i < s.length; i++) {
				if (s[i] == 'A' || s[i] == 'C') {
					continue;
				}
				if (!Character.isLowerCase(s[i])) ok = false;
			}

			out.println(ok ? "AC" : "WA");

		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(nextString());
		}

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public double nextDouble() {
			return Double.parseDouble(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public int[] nextIntArrayDec(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt() - 1;
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public long[] nextLongArrayDec(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong() - 1;
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}
	}

}


Measured memory_bytes: 21460
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
#define sz(x) (int)(x).size();
#define all(x) x.begin(), x.end()
#define trav(i,a) for(auto &i:a) 
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int n=in();
	string s;
	cin>>s;
	int ob=0,cb=0;
	for(auto i:s)
	{
		if(i==')')
		{
			if(ob)ob--;
			else cb++;
		}
		if(i=='(')ob++;
	}
	string a(cb,'(');cout<<a;
	cout<<s;string b(ob,')');
	cout<<b;
	
}

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

int main(void) {
	char c;
	cin >> c;
	
	if (c == 'a' || c == 'e' || c =='i' || c == 'o' || c == 'u') {
		cout << "vowel" << endl;
	} else {
		cout << "consonant" << endl;
	}
	return 0;
}
	

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var s string
	fmt.Scan(&s)

	if strings.Count(s, "A") > 0 && strings.Count(s, "B") > 0 {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")

}


Measured memory_bytes: 640
/*  -*- coding: utf-8 -*-
 *
 * a.cc: A - Security
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

/* typedef */

/* global variables */

char s[8];

/* subroutines */

/* main */

int main() {
  scanf("%s", s);

  for (int i = 1; s[i]; i++)
    if (s[i - 1] == s[i]) {
      puts("Bad");
      return 0;
    }

  puts("Good");
  return 0;
}


Measured memory_bytes: 256
n=int(input())
li=[]
for i in range(n):
    s=list(input())
    s.sort()
    li.append(s)
li.sort()

ans=0
f=1
for i in range(n-1):
    if li[i]==li[i+1]:
        f+=1
    else:
        ans+=f*(f-1)//2
        f=1
print(ans+f*(f-1)//2)


Measured memory_bytes: 26256
import java.util.*;


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

    String[] S = new String[ N ];

    for(int i = 0 ; i < N ; i ++){
      S[ i ] = sc.next();
    }
    Arrays.sort(S);

    StringBuilder sb = new StringBuilder();
    for(int i = 0 ; i < N ;i ++){
      sb.append( S[ i ] );
    }

    System.out.println(sb);
  }
}


Measured memory_bytes: 21716
#include <stdio.h>
int main (){
int a,b,i,k,s[100]={0},d=0;
  scanf ("%d%d%d",&a,&b,&k);
  for (i=1;i<a*b;i++){
if (a%i==0 && b%i==0){
s[d]=i;
d++;
}
  }
printf ("%d",s[d-k]);
return 0;
}


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

using namespace std;

#define ll long long
#define pii pair<int,int>
#define N 500500
#define dracarys ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = 998244353;

int n;
int a[N];

void solve() {
    cin >> n;
    for (int i = 1; i <= n; ++i) cin >> a[i];

    ll money = 1000, stocks = 0;
    for (int i = 1; i <= n; ++i) {
        stocks += money / a[i];
        money %= a[i];

        int j = i + 1;
        while (j <= n && a[j] >= a[j - 1]) ++j;
        --j;

        money += a[j] * stocks;
        stocks = 0;

        while (j <= n && a[j] > a[j + 1])
            ++j;

        i = j - 1;
    }

    cout << money << "\n";
}


int main() {
//    freopen("sample.in", "r", stdin);
    dracarys
    int t = 1;
//    cin >> t;
    for (int i = 1; i <= t; ++i) {
//        cout << "Case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <vector>

using lint = long long;
constexpr lint INF = 1LL << 60;

void solve() {
    int n;
    std::cin >> n >> n >> n;

    std::vector<std::pair<lint, lint>> ps(n);
    std::vector<lint> xs, ys;
    for (auto& p : ps) {
        std::cin >> p.first >> p.second;
        for (int i = 0; i < 2; ++i) {
            xs.push_back(p.first);
            ys.push_back(p.second);
        }
    }

    std::sort(xs.begin(), xs.end());
    std::sort(ys.begin(), ys.end());

    std::vector<lint>
        xmid{xs[n - 1], xs[n]},
        ymid{ys[n - 1], ys[n]};

    std::vector<lint> xsum(2, 0), ysum(2, 0);
    for (int i = 0; i < 2; ++i) {
        for (auto x : xs) xsum[i] += std::abs(x - xmid[i]);
        for (auto y : ys) ysum[i] += std::abs(y - ymid[i]);
    }

    int bxi = 1, byi = 1;
    lint ans = INF;
    for (int i = 0; i < n; ++i) {
        int xi = (ps[i].first <= xmid[0]),
            yi = (ps[i].second <= ymid[0]);
        lint sum = (xsum[xi] - std::abs(ps[i].first - xmid[xi])) +
                   (ysum[yi] - std::abs(ps[i].second - ymid[yi]));

        if (sum < ans || (sum == ans && xi < bxi) ||
            (sum == ans && xi == bxi && yi < byi)) {
            ans = sum;
            bxi = xi;
            byi = yi;
        }
    }

    std::cout << ans << "\n"
              << xmid[bxi] << " " << ymid[byi] << "\n";
}

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

    solve();

    return 0;
}



Measured memory_bytes: 7948
#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
 
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// using namespace __gnu_pbds;
using namespace std;
// typedef pair<int,int> pii;
// tree <pii,null_type,greater<pii>,rb_tree_tag,tree_order_statistics_node_update> tr;
// cin.tie(0);
// std::ios::sync_with_stdio(false);
typedef long long LL;
const LL N = 7005;
const LL M = 205;
// const LL V = 207;
// const LL E = 60007;
const LL INF = 0x3f3f3f3f3f3f3f;
const double inf = 2e9;
const double Pi = acos(-1);
const LL MOD = 1e9+7;
const double eps = 1e-8;
LL n,m;
struct nd
{
    LL h,p;
}s[N];
LL dp[N];
bool cmp(nd a,nd b) {return a.h+a.p < b.h+b.p; }
int main()
{
    while (~scanf("%lld",&n))
    {
        memset(dp,INF,sizeof dp);
        for (LL i=1;i<=n;i++)
            scanf("%lld%lld",&s[i].h,&s[i].p);
        sort(s+1,s+1+n,cmp);
        dp[0]=0;
        for (LL i=1;i<=n;i++)
            for (LL j=i;j>=1;j--)
                if (dp[j-1]<=s[i].h)
                    dp[j] = min(dp[j],dp[j-1]+s[i].p);
        LL ans = 1;
        for (LL i=1;i<=n;i++)
            if (dp[i]<INF)
                ans = i;
        printf("%lld\n", ans);
    }
    return 0;
}
/*

3
0 2
1 3
3 4

3
2 4
3 1
4 1

10
1 3
8 4
8 3
9 1
6 4
2 3
4 2
9 2
8 3
0 1

*/

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


#define FOR(i, start, end) for(uint64_t i=start; i<end; i++)
#define REP(i, n) FOR(i, 0, n)

// 最大公約数gcd
// 最小公倍数lcm=m*n/gcd
uint64_t gcd(uint64_t m, uint64_t n) {
  uint64_t temp;
  while (m % n != 0){
    temp = n;
    n = m % n;
    m = temp;
  }
  return n;
}

uint64_t lcm(uint64_t m, uint64_t n) {
  return (m*n)/gcd(m,n);
}

void comb(vector<vector <uint64_t> > &v){
  for(uint64_t i = 0;i <v.size(); i++){
    v[i][0]=1;
    v[i][i]=1;
  }
  for(uint64_t k = 1;k <v.size();k++){
    for(uint64_t j = 1;j<k;j++){
      v[k][j]=(v[k-1][j-1]+v[k-1][j]);
    }
  }
}

// 掛け算オーバーフロー判定
bool is_product_overflow(uint64_t a, uint64_t b) {

	uint64_t prod = a * b;
	
	return (prod / b != a);
}

//素因数分解
void primeFactorization(uint64_t a, list<uint64_t> &factors){ //素因数分解を出力するプログラム
  long i,sq;
  if(a%2==0){ //偶数の場合
    factors.push_back(2);
    primeFactorization(a/2,factors); //2で割った値で再帰
    return;
  }
  sq = sqrt(a);
  for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
	if(a%i==0){
	  factors.push_back(i);
      primeFactorization(a/i,factors); //割れた値で再帰
      return;
	}
  }
  //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
  if(a!=1){ //aが1でないなら、a自身は素数
    factors.push_back(a);
  }
}

// 円周率
// M_PI

// #include <iomanip> // setprecisionを使用するのに必要
// cout << std::fixed << std::setprecision(15) << y << endl;

// 昇順
// priority_queue<int, vector<int>, greater<int> > queue;

signed main() {
  int n,m,x;
  cin >> n >> m >> x;
  int c[n] = {};
  int a[m*n] = {};
  int minCost = 0;
  for(int i=0;i<n;i++){
    cin >> c[i];
    minCost += c[i];
    for(int j=0;j<m;j++){
      cin >> a[m*i+j];
    }
  }

  bool found = false;
  for(int i=1;i<(1<<n); i++)
  {
    int cost = 0;
    int score[m] = {0};
    for(int j=0;j<n;j++){
      if((i&(1<<j)) == 0) continue;
      cost += c[j];
      bool isCleared = true;
      for(int k=0;k<m;k++){
        score[k] += a[j*m+k];
        if(score[k]<x) isCleared=false;
      }
      if(isCleared){
        found = true;
        if(minCost>=cost){
          minCost = cost;
        }
        continue;
      }
    }    
  }
  
  if(found) cout << minCost << endl;
  else cout << "-1" << endl;
   
  return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
const ll ddx[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const ll ddy[8]={ 1, 0,-1, 0, 1,-1, 1,-1};
ll modfac(ll a){
    ll ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
ll modinv(ll a,ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) {}

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
ll modpow(ll a, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
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(){
    ll a,b;cin >> a >>b;
    ll ans=0;
    if(a!=0)ans+=a*(a-1)/2;
    if(b!=0)ans+=b*(b-1)/2;
    cout << ans <<endl;
}


Measured memory_bytes: 256
A,B,C,D=map(int,list(input()))
if A+B+C+D==7:
  print('%d+%d+%d+%d=7'%(A,B,C,D))
  exit()
elif A+B+C-D==7:
  print('%d+%d+%d-%d=7'%(A,B,C,D))
  exit()
elif A+B-C+D==7:
  print('%d+%d-%d+%d=7'%(A,B,C,D))
  exit()
elif A-B+C+D==7:
  print('%d-%d+%d+%d=7'%(A,B,C,D))
  exit()
elif A+B-C-D==7:
  print('%d+%d-%d-%d=7'%(A,B,C,D))
  exit()
elif A-B+C-D==7:
  print('%d-%d+%d-%d=7'%(A,B,C,D))
  exit()
elif A-B-C+D==7:
  print('%d-%d-%d+%d=7'%(A,B,C,D))
  exit()

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<=n;i++)
#define per(i,a,n) for (int i=n;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define mem(a,b) memset(a,b,sizeof (a))
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
const ll mod=1000000007;
ll ksm(ll a,ll b){ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

const int N=1e5+10;

int main(){
	ll x;
	scanf("%lld",&x);
	for(ll i=1;i<=1000;i++){
		for(ll j=-1000;j<=1000;j++){
			if(i*i*i*i*i-j*j*j*j*j==x){
				printf("%lld %lld\n",i,j);
				return 0;
			}
		}
	}
    return 0;
}


Measured memory_bytes: 3760
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define M 1000000007
#define opt ios_base::sync_with_stdio(false); cin.tie(NULL);

void freak__()
{
    string s;
    cin >> s;
    vector<char> v(s.length()+1);
    int i=0,x=-1,f;
    while(s[i])
    {
        if(s[i]=='0')
        {
            v[++x]='0';
            f=1;
        }
        else if(s[i]=='1')
        {
            v[++x]='1';
            f=1;
        }
        else if(s[i]=='B') 
        {
            if(x>=0) x--;
            f=0;
        }
        i++;
    }
    //if(f) for(i=0;i<x;i++) cout << v[i];
    for(i=0;i<=x;i++) cout << v[i];
    cout << "\n";
}

int main()
{
    opt;
    freak__();
    return 0;
}

Measured memory_bytes: 256
import sys
n, m = map(int, input().split())
ball = [1 for i in range(n+1)]
box = [0 for i in range(n+1)]
box[1] = 1
for a in sys.stdin.readlines():
    x, y = map(int, a.split())
    ball[x] -= 1
    ball[y] += 1
    if box[y] == 0 and box[x]:
        box[y] = 1
    if box[x] and ball[x] == 0:
        box[x] = 0

print(sum(box))

Measured memory_bytes: 11820
// https://atcoder.jp/contests/abc081/tasks/arc086_b

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 50;
const int A_I_MAX = 1e6;

int N;
int a[N_MAX];

vector<pair<int, int>> ans;

void solve() {
  int ai = A_I_MAX + 1;
  int ax = -(A_I_MAX + 1);
  int ii = -1;
  int ix = -1;
  REP(i, N) {
    if (a[i] < ai) {
      ai = a[i];
      ii = i;
    }
    if (a[i] > ax) {
      ax = a[i];
      ix = i;
    }
  }
  bool positive = true;
  if (ai >= 0) {
    positive = true;
  } else if (ax <= 0) {
    positive = false;
  } else if (abs(ax) >= abs(ai)) {
    REP(i, N) if (a[i] < 0) {
      ans.push_back({ix, i});
      a[i] += ax;
    }
    positive = true;
  } else {
    REP(i, N) if (a[i] > 0) {
      ans.push_back({ii, i});
      a[i] += ai;
    }
    positive = false;
  }
  if (positive) {
    REP(i, N - 1) if (a[i + 1] < a[i]) {
      ans.push_back({i, i + 1});
      a[i + 1] += a[i];
    }
  } else {
    for (int i = N - 1; i > 0; i--) if (a[i - 1] > a[i]) {
      ans.push_back({i, i - 1});
      a[i - 1] += a[i];
    }
  }
  printf("%d\n", ans.size());
  for (auto p : ans) printf("%d %d\n", p.first + 1, p.second + 1);
}

void input() {
  scanf("%d", &N);
  REP(i, N) scanf("%d", a + i);
}

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


Measured memory_bytes: 764