akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>
#define NMAX (int )1e5+5

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
	std::fill( (T*)array, (T*)(array+N), val );
}

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

int N,ans = 0,M = -1;
char animal[NMAX],truth[NMAX];
char S[NMAX];
string dx[4] = {"SS","SW","WS","WW"};
bool check(int b){
	if(truth[b] == 'o'){
		if(animal[b-1] == animal[b+1]){
			return true;
		}else{
			return false;
		}
	}else{
		if(animal[b-1] != animal[b+1]){
			return true;
		}else{
			return false;
		}
	}
}
void made(int b){
	if(truth[b] == 'o'){
		animal[b+1] = animal[b-1];
	}else{
		if(animal[b-1] == 'S'){
			animal[b+1] = 'W';
		}else{
			animal[b+1] = 'S';
		}
	}
}

int solve(int a){
	animal[0] = dx[a][0];
	animal[1] = dx[a][1];
	animal[N] = animal[0];
	for (int i = 0; i < N; ++i)
	{
		if(animal[i] == 'S'){
			truth[i] = S[i];
		}else{
			if(S[i] == 'o'){
				truth[i] = 'x';
			}else{
				truth[i] = 'o';
			}
		}
		if(i == N-1){
			if(!check(i)){
				return -1;
			}else{
				if((truth[0] == 'o' && animal[N-1] != animal[1]) 
					|| (truth[0] == 'x' && animal[N-1] == animal[1])){
					return -1;
			}
		}
	}else if(i != 0){
		made(i);
	}
}
for (int j = 0; j < N; ++j)
{
	cout << animal[j];
}
cout << "\n";
return 0;
}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> S[i];
	}
	for (int i = 0; i < 4; ++i)
	{
		M = solve(i);
		if(M == 0){
			return 0;
		}
	}
	if(M == -1){
		cout << M << endl;
	}

	#ifdef DEBUG
	debug();
	#endif
	// answer();

	return 0;
}

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

int main() {

  long long int n;
  cin >> n;

  vector< long long int > v;

  for ( long long int i = 0; i < n; i++ ) {

    long long int in;
    cin >> in;

    v.push_back( in );

  }

  long long int dp[21][101] = {};

  dp[v[0]][0] = 1;

  for ( long long int i = 1; i < n - 1; i++ ) {

    for ( long long int j = 0; j <= 20; j++ ) {

      long long int k = j - v[i];
      if ( k >= 0 ) dp[k][i] += dp[j][i-1];
      k = j + v[i];
      if ( k <= 20 ) dp[k][i] += dp[j][i-1];

    }

  }

  cout << dp[v[n-1]][n-2] << endl;

  return 0;

}

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

using namespace std;

const int MAXN = 2e5;

int a[MAXN], n;

int main() {
	scanf("%d", &n);
	for(int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	int k = 1;
	for(int i = 0; i < n; i++) {
		if(a[i] == k) k++;
	}
	if(k == 1) puts("-1");
	else printf("%d\n", n - k + 1);
	return 0;
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    map<string, int> cnt;
    rep(i, N){
        string s;
        cin >> s;
        if (cnt.find(s) != cnt.end()){cnt[s] += 1;} else {cnt[s] = 0;}
    }
    int max_cnt = 0;
    vector<string> words;
    for (auto it : cnt) {
        if (max_cnt < it.second){
            max_cnt = it.second;
            words.clear();
            words.push_back(it.first);
        } else if (max_cnt == it.second){
            words.push_back(it.first);
        }
    }
    sort(words.begin(), words.end());
    for (auto it : words) {cout << it << endl; }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 25584
#include<bits/stdc++.h>
typedef  long long int ll;
typedef  long double ld;
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL) 
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#define  pb(x) push_back(x)
#define si(a) scanf("%lld",&a)
#define pi(a) printf("%lld",a)
#define mod 1000000007
#define f first
#define s second 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
//recursions\
#pragma comment(linker, "/stack:200000000")
//loops\
#pragma GCC optimize("unroll-loops")
using namespace __gnu_pbds;
#define ordered_set tree<ll, null_type,greater_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
using namespace std;
int main()
{
	sync;
	ll k,x;
	cin>>k>>x;
	for(int i=max((ll)-1000000,x-k+1);i<=min((ll)1000000,x+k-1);i++)
	cout<<i<<" ";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define fr first
#define sc second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define int long long
using namespace std;

int a,b,c;

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
    cin >> a >> b >> c;
    c=min(c,a+b+1);
    cout<<b+c;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;
 
int main () {
 
    int n,w; cin >>n>>w;
    vector<ll> c(n); vector<ll> v(n);
    REP(i,n) cin >> c[i] >> v[i];
 
    vector<vector<ll> > dp(n+1, vector<ll>(100100, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j <= w; j++) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
            if (c[i] <=  j) {
                dp[i+1][j] = max(dp[i+1][j], dp[i][j-c[i]]+v[i]);
            } 
        }
    }
 
    cout << dp[n][w] << endl;
    return 0;
}
 

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

using namespace std;

int main(){
  int N,sum;
  cin >> N;
  int a[N+10];
  for(int i=0; i<N; i++){
    cin >> a[i];
  }
  sort(a,a+N);
  sum=a[0];
  sort(a,a+N,greater<int>());
  sum=a[0]-sum;
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
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; }
const long long INF = 1LL << 60;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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


Measured memory_bytes: 256
<?php
$s = trim(fgets(STDIN));
$n = strlen($s);
$input=explode(' ',trim(fgets(STDIN)));
$x = $input[0];
$y = $input[1];
$initial_x = 0;
$group_x = array();
$group_y = array();

$i = 0;
while($s[$i] == 'F') {
  $initial_x++;
  $i++;
}

$is_dir_x = TRUE;
$count = 0;
for(;$i<$n;$i++) {
  if($s[$i] == 'T') {
    if($count > 0) {
      if($is_dir_x) {
        $group_x[] = $count;
      } else {
        $group_y[] = $count;
      }
      $count = 0;
    }
    $is_dir_x = !$is_dir_x;
  } else {
    $count++;
  }
}
if($count > 0) {
  if($is_dir_x) {
    $group_x[] = $count;
  } else {
    $group_y[] = $count;
  }
  $count = 0;
}

$set_x = array();
$set_x[$initial_x] = TRUE;
foreach($group_x as $gx) {
  $add_keys = array();
  foreach($set_x as $key => $value) {
    if($value === TRUE) {
      if(!isset($set_x[$key + $gx])) {
        $add_keys[] = $key + $gx;
      }
      if(!isset($set_x[$key - $gx])) {
        $add_keys[] = $key - $gx;
      }
    }
    $set_x[$key] = NULL;
  }
  foreach($add_keys as $key) {
    $set_x[$key] = TRUE;
  }
}

$set_y = array();
$set_y[0] = TRUE;
foreach($group_y as $gy) {
  $add_keys = array();
  foreach($set_y as $key => $value) {
    if($value === TRUE) {
      if(!isset($set_y[$key + $gy])) {
        $add_keys[] = $key + $gy;
      }
      if(!isset($set_y[$key - $gy])) {
        $add_keys[] = $key - $gy;
      }
    }
    $set_y[$key] = NULL;
  }
  foreach($add_keys as $key) {
    $set_y[$key] = TRUE;
  }
}

if(isset($set_x[$x]) && isset($set_y[$y])) {
  echo 'Yes'.PHP_EOL;
} else {
  echo 'No'.PHP_EOL;
}

//print_r($set_x);
//print_r($set_y);
?>

Measured memory_bytes: 4732
#include <iostream>
#include <cmath>
using namespace std;
int main(){
  int A,B,n;bool flag=false;
  cin >> A >> B;
  for(n=ceil(A/0.08);n<(A+1)/0.08;n++){
    if(n/10==B){
      flag=true;
      break;
    }
  }
  cout << (flag?n:-1) << endl;
  return 0;
}

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

int main() {
  int H,W;
  cin >> H >> W;
  
  string board[50];
  
  for (int i = 0; i < H; ++i) cin >> board[i];
  
  const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
  const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
  
  for ( int i = 0; i < H; ++i) {
    for (int j = 0; j < W; ++j) {
      
      if (board[i][j] == '#') continue;
      
      int num = 0;
      for (int d = 0; d < 8; ++d) {
         const int ni = i + dy[d];
         const int nj = j + dx[d];
        
         // out of bounds 防止
         if (ni < 0 or H <= ni ) continue;
         if (nj < 0 or W <= nj ) continue;
         if (board[ni][nj] == '#' ) num++;
      }

      board[i][j] = char(num + '0');   
    }
      
  }
    
  for (int i = 0; i < H; ++i) cout << board[i] << endl;
  
  return 0;
}
  



Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
#include <set>
//#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
//using vll = vector<ll> ;
//using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void fix_cout(){cout << fixed << setprecision(20) ;}]

int main(){
	ll n,d ;
	cin >> n >> d ;
	d = d*d ;
	ll ans = 0 ;
	for(int i=0;i<n;i++){
		ll a,b ;
		cin >> a >> b ;
		ans += (d>=a*a+b*b) ;
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3632
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>

//#include <tuple>

//#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back

int main() {
  int k, x;
  cin >> k >> x;
  int min_n = -1000000 - 1;

  int max_b = min(x + k, 1000000 + 1);
  int min_b = max(x - k, min_n);
  // cout << min_b << max_b;

  for (int i = min_b + 1; i < max_b - 1; i++){
    cout << i << " ";
  }
  cout << max_b - 1 << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
  int ans;
    map < int , long long  > mp;
    map<int, long long>::reverse_iterator it;
int main()
{
 int n, v;
 long long W, w;
 cin >> n >> W;
 mp[0]= W;
 for ( int i=0; i< n; i++){
    cin >> w >> v;
    for (it =mp.rbegin(); it!= mp.rend(); it++){
    int value = it ->first;
    long long capacity = it-> second;
   value += v;
   capacity-= w;
   if (mp[value] <= capacity) {
    mp[value] = capacity;
    if (value > ans) ans= value;
   }
        }
 }
  cout << ans;
    return 0;
}


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

int main()
{
	ll N, Q, x;
	cin >> N >> Q;
	vector<ll> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	while (Q--) {
		cin >> x;
		ll l = 0, r = 0, sum = 0, res = 0;
		while (r <= N) {
			if (sum <= x) {
				res += r - l;
				sum += a[r++];
			}
			else {
				sum -= a[l++];
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

int main()
{
  long long int n,ans=0;cin>>n;
  
  for(int i=1;i<=n;i++)
  {
      ans+=n/i;
      
      if(n%i==0)
      ans--;
  }
  
  cout<<ans;
  
    return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define MOD 1000000007
#define ll long long
#define mp make_pair
#define pb push_back 
#define N 100010
using namespace std;
int dp[N][4], A[N][3], n;
int fun(int a, int b){
	if(a == n)
		return 0;
	if(dp[a][b] != -1)
		return dp[a][b];
	int maxi = 0;
	for(int i = 0; i < 3; i++){
		if(i != b)
			maxi = max(maxi, A[a][i] + fun(a + 1, i));
	}
	return dp[a][b] = maxi;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++)
		cin >> A[i][0] >> A[i][1] >> A[i][2];
	memset(dp, -1, sizeof(dp));
	cout << fun(0, 3) << '\n';

}

Measured memory_bytes: 10752
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
from functools import reduce
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers):
    return reduce(math.gcd, numbers)

pi = math.pi

R = int(stdin.readline().rstrip())

print(2*pi*R)

Measured memory_bytes: 9960
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(9)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
 
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
	if(n==1 || r==0)return 1;
	ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=(((ans * n )/i)%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
		
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b%a, a); 
} 
 
int main()
{
	ll n,m,k;
	string s;
	cin>>n>>m;
	if(n==m)
	cout<<"Yes";
	else
	cout<<"No";
}

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

using namespace std;

int main()
{
    int N;
    cin >> N;
    if (N < 1000)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ABD" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace Dice
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] i = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            char[] j = Console.ReadLine().ToCharArray();
            foreach(char k in j)
            {
                int a = i[0]; int b = i[1]; int c = i[2];
                int d = i[3]; int e = i[4]; int f = i[5];
                i = k == 'S' ? new int[] { e, a, c, d, f, b } :
                    k == 'E' ? new int[] { d, b, a, f, e, c } :
                    k == 'W' ? new int[] { c, b, f, a, e, d } :
                    new int[] { b, f, c, d, a, e };
            }
            Console.WriteLine("{0}", i[0]);
        }
    }
}

Measured memory_bytes: 9608
#include<iostream>
using namespace std;
int main(){
  int n,sum=0;
  cin>>n;
  int a[n][2];cin>>a[0][0]>>a[0][1]>>a[1][0]>>a[1][1];
  for(int i=2;i<n;i++){
  cin>>a[i][0]>>a[i][1];
    if(a[i-2][1]==a[i-2][0]&&a[i-1][1]==a[i-1][0]&&a[i][1]==a[i][0]){sum++;cout<<"Yes";break;}
  }
  
  if(sum==0)cout<<"No";
  
  
  return 0;}


Measured memory_bytes: 3636
import Data.IORef
import Control.Monad
 
main :: IO()
main = getLine >> getContents >>= (\(x:y:xs) -> solve (y - x) (min x y) xs).map read.lines >>= print
 
solve :: Int -> Int -> [Int] -> IO Int
solve a b xs = do
                a' <- newIORef a
                b' <- newIORef b
                forM_ xs $ \z -> do
                    x <- readIORef a'
                    y <- readIORef b'
                    when (z - y > x) $ writeIORef a' (z - y)
                    when (z < y)     $ writeIORef b' z
                readIORef a'

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

int main()
{
    int H, N;
    cin >> H >> N;

    int d[20000];
    int A[1000];
    int B[1000];

    int amax = 0;
    for(int n=0; n<N; n++){
        cin >> A[n] >> B[n];
        amax = max(amax, A[n]);
    }

    d[0] = 0;

    for(int h=1; h<H+amax; h++){
        d[h] = 100000000;
        for(int n=0; n<N; n++){
            int r;
            if(h < A[n]){
                r = B[n];
            } else {
                r = B[n] + d[h - A[n]];
            }
            d[h] = min(d[h], r);
        }
    }

    int res = 100000000;
    for(int i=H; i<H+amax; i++){
        res = min(res, d[i]);
    }

    cout << res << endl;

	return 0;
}


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

int main() {
    string S;
    int K;
    cin >> S >> K;
    int N = S.size();

    //全探索。S[i]に対して部分文字列の配列を作っていく
    vector<string> vec;
    for (int i = 0; i < N; i++) {
        for (int j = 1; j <= K; j++) {
            vec.push_back(S.substr(i, j));
        }
    }

    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    string ans;
    ans = vec[K-1];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1660
// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

// AtCoder.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//


#define _USE_MATH_DEFINES
#include<math.h>

//#include<cmath>

#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>



//#include "Ants.h"
using namespace std;
typedef long long ll;
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i,n) for(int i=0;i<n;i++)
#define show(s) cout<<s<<endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define LINF (1000000000000000000ll)
//typedef pair < int, int> P;
ll gcd(ll a, ll b) {//最大公約数を求める///最大公倍数a*b/gcd(a,b)
	if (b == 0) return a;
	return gcd(b, a % b);
}
ll lcd(ll a, ll b) {//最小公倍数を求める　b=0のときaを返す
	if (b == 0) return a;
	return (a / gcd(a, b)) * b;
}
vector<int> divnum(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p;
}
int digiter(ll num) {
	int dig;
	vector<int>p;
	while (num) {
		dig = num % 10;
		p.push_back(dig);
		num /= 10;
	}
	return p.size();
}
vector<int> convertstring(string s) {
	vector<int> d;
	ll n = s.size();
	rep(i, n) {
		d.push_back(s[i] - '0');
	}
	return d;
}
map< int64_t, int > prime_factor(int64_t n) {
	map< int64_t, int > ret;
	for (int64_t i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}
vector<ll> divisor(ll n) {
	vector<ll>res;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i != 0)continue;
		res.push_back(i);
		if (i * i != n)res.push_back(n / i);
	}
	return res;
}
ll MOD = 1000000007;

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}
std::vector<int> Eratosthenes(const int N)
{
	std::vector<bool> is_prime(N + 1);
	for (int i = 0; i <= N; i++)
	{
		is_prime[i] = true;
	}
	std::vector<int> P;
	for (int i = 2; i <= N; i++)
	{
		if (is_prime[i])
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				is_prime[j] = false;
			}
			P.emplace_back(i);
		}
	}
	return P;
}
int sz[1000005];
bool judge[100005];
int Q,L[1000005], R[1000005];
int main()
{
	vector<int> p = Eratosthenes(int(1e5) + 5);
	for (int a : p) {
		judge[a] = true;
		if (judge[(a + 1) / 2]) {
			sz[a]++;
			if (a == 7) {
				cout << "Wrong" << endl;
			}
		}
	}
	rep(i, int(1e5) + 5) {
		if (sz[i+1] == 0) {
			sz[i + 1] = sz[i];
		}
		else {
			sz[i + 1] = sz[i] + 1;
		}
	}
	cin >> Q;
	rep(i, Q) {
		cin >> L[i] >> R[i];
		L[i]--; R[i]++;
	}
	rep(i, Q) {
		/*for (int j = L[i]; j <= R[i]; j++) {
			cout << sz[j] << " " << j <<" "<<judge[j+1/2]<<  endl;
		}*/
		cout << sz[R[i]] - sz[L[i]] << endl;

	}

	
}

Measured memory_bytes: 9344
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) ((int)(a).size())
typedef long long int64;
int main(){
#ifdef LOCAL
  freopen(".a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int64 x,k,d;
  cin>>x>>k>>d;
  if(x<0)x=-x;
  if(x/d>=k){
    cout<<x-(d*k)<<'\n';return 0;
  }
  int64 cur=x-x/d*d;
  k-=x/d;
  if(k%2==0)cout<<cur<<'\n';
  else cout<<abs(cur-d)<<'\n';
  
  return 0;
}
//2020.08.15 20:09:19


Measured memory_bytes: 3644
// template version 1.11
using namespace std;
#include <iostream>
#include <bits/stdc++.h>

// varibable settings {{{
#define infile "../test/sample-1.in"
#define int long long
const int INF=1e18;
const int MOD=1e9+7;
// }}}

// define basic macro {{{
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)((b)-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define each(i,a) for (auto&& i : a)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ub upper_bound
#define lb lower_bound
template<class T> inline void chmax(T &a, const T &b) { if((a) < (b)) (a) = (b); }
template<class T> inline void chmin(T &a, const T &b) { if((a) > (b)) (a) = (b); }

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;

template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

#if defined(PCM) || defined(LOCAL)
  #include "lib/dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif
//}}}

int solve(){
  string s; cin>>s;
  int n = sz(s);
  int ac = 0;

  int res=0;
  rep(i, n){
    if (s[i]=='A'){
      ac++;
    }
    else if (s[i]=='B'){
      if (s[i+1]=='C'){
        res += ac;
        i++;
      }
      else{
        ac = 0;
      }
    }
    else if (s[i]=='C'){
      ac = 0;
    }
  }
  cout << res << endl;
  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 720
#![allow(unused_mut, non_snake_case,unused_imports)]
use std::iter;
use std::cmp::{max, min, Ordering};
use std::mem::{swap};
use std::collections::{HashMap,BTreeMap,HashSet,BTreeSet,BinaryHeap,VecDeque};
use std::iter::FromIterator;

//　高速 EOF要
//macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();input_inner!{iter, $($r)*}};($($r:tt)*) => {let mut s = {use std::io::Read;let mut s = String::new();std::io::stdin().read_to_string(&mut s).unwrap();s};let mut iter = s.split_whitespace();input_inner!{iter, $($r)*}};}
//macro_rules! input_inner {($iter:expr) => {};($iter:expr, ) => {};($iter:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($iter, $t);input_inner!{$iter $($r)*}};}
//macro_rules! read_value {($iter:expr, ( $($t:tt),* )) => {( $(read_value!($iter, $t)),* )};($iter:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()};($iter:expr, chars) => {read_value!($iter, String).chars().collect::<Vec<char>>()};($iter:expr, usize1) => {read_value!($iter, usize) - 1};($iter:expr, $t:ty) => {$iter.next().unwrap().parse::<$t>().expect("Parse error")};}
// 低速 EOF不要
macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_5_B&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

static MOD: i64 = 1_000_000_007;

fn main(){
    input!(n:i64,k:i64);
    let mut ans = 1;
    for i in 0..n{
        ans *= k-i;
        ans %= MOD;
    }
    println!("{}",ans);
}


Measured memory_bytes: 5036
w = gets.chomp.to_i
n = gets.chomp.to_i

nums = []
for i in 1..w
   nums[i] = i
end

a = []
b = []

for i in 1..n
   ln = gets
   a[i], b[i] = ln.chomp.split(",")
   a[i], b[i] = a[i].to_i, b[i].to_i
end

for i in 1..n
   tmp = nums[a[i]]
   nums[a[i]] = nums[b[i]]
   nums[b[i]] = tmp
end

for i in 1..w
   puts nums[i]
end


Measured memory_bytes: 6844
#include <iostream>
#include <cmath>
#include <vector>
#include <unordered_map>

using namespace std;

int main() {
    string s;
    cin >> s;
    int np = 0;
    int t = 0;
    string keyence = "keyence";
    for(long j = 0;j <= s.length();++j) {
        for (long i = j; i < s.length(); ++i) {
            if(s.substr(0,j) + s.substr(i,s.length()) == "keyence"){
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;

}







Measured memory_bytes: 256
# include "cstdio"
# include "iostream"
# include "algorithm"

using namespace std;

const int maxm=1e5+10;

int A[maxm],N;
long long B[maxm],Top;

int main(){
	register int i;
	scanf("%d",&N);
	for(i=1;i<=N;i++) scanf("%d",A+i);
	sort(A+1,A+1+N);
	for(i=1;i<=N;i++){
		if(A[i]==A[i+1]){
			B[++Top]=A[i];
			i++;
		}
	}
	printf("%lld",Top<2?0:B[Top]*B[Top-1]);
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	#define int  long long int
	#define pb push_back
	#define fe first
    #define lb lower_bound 
    #define ub upper_bound
    #define pii pair<pair<int,int>,pair<int,int> >
	#define se second
	#define endl "\n"
	#define pi pair<int, int>
	#define vi vector<int> 
	#define vvi vector<vi>
    #define bs   binary_search
	#define rep(i,a,b) for(int i=a;i<b;i++)
	#define rep1(i,a,b) for(int i=a;i<=b;i++)	
    #define all(c) (c).begin(),(c).end()
    #define sz(x)       (int)x.size() 
	#define PI 3.14159265358979323846
    
	const int N =1e5+10;
    
     int mod= 998244353;
     int dx[4]={0,0,+1,-1};
     int dy[4]={+1,-1,0,0};
  
  void solve() {
     int n;
     cin>>n;
     
     vi v(n+1,0),pw(n,0);
     
     rep(i,0,n+1)
      cin>>v[i];
     
     rep(i,0,n)
      cin>>pw[i];
     
     int tt=0; 
      
     rep(i,0,sz(pw)){
         
         if(pw[i]>=v[i]){
             pw[i]-=v[i];
             tt+=v[i];
             v[i]=0;
         
            
            if(pw[i]>=v[i+1]){
             pw[i]-=v[i+1];
             tt+=v[i+1];
             v[i+1]=0;            
           }
           
           else if(pw[i]!=0){
               tt+=pw[i];
               v[i+1]-=pw[i];
               pw[i]=0;
           }
       }
       
       
       else if(pw[i]!=0){
           tt+=pw[i];
           v[i]-=pw[i];
           pw[i]=0;
       }
     }
     
     cout<<tt<<endl; 
       
    
  }          
         
 
   
  int32_t main() {
    cool;
    int t=1;
    //cin>>t;
    while(t--)
       solve();
  
       return 0;	   
   }


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main() {
string s,t;
int a,b,c,i;
vector<int> v;
cin>>b;
for(i=0;i<b;i++){cin>>c;v.push_back(c);}
sort(v.begin(),v.end());
a=0;
for(i=0;i<b-1;i++){a=a+v[i];}
a = a+(v[b-1]/2);
cout<<a<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

N,A,B,C,D = map(int,input().split())
S = input()
A -= 1; B -= 1; C -= 1; D -= 1

def find_route(X,Y):
    for i in range(X,Y):
        if S[i] == S[i + 1] == '#':
            return False
    return True

if C < D:
    if find_route(A,C) and find_route(B,D):
        print('Yes')
    else:
        print('No')
else:
    flag = False
    for i in range(B - 1,D):
        if S[i] == S[i + 1] == S[i + 2] == '.':
            flag = True
            break
    if flag and find_route(A,C):
        print('Yes')
    else:
        print('No')




Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef long double DD;
const int inf = 1e9;
const int mo= 1e9+7;
const int N = 1e6+10;
int n, W, H, cnt, x[N], y[N], tmp[N];
int d[N][2], stk[N][2], top[2];
int mx[N << 2], tag[N << 2];

inline void add(int x){
	if(x >= 1 && x < H)
		tmp[++cnt] = x;
}

inline void update(int p){
	mx[p] = max(mx[p << 1], mx[p << 1 | 1]);
}

inline void ad(int p,int x){
	tag[p] += x;
	mx[p] += x;
}

void clear(int p){
	if(!tag[p])
		return;
	ad(p << 1, tag[p]);
	ad(p << 1 | 1, tag[p]);
	tag[p] = 0;
}

void build(int p, int l, int r){
	tag[p] = 0;
	if(l == r){
		mx[p] = -tmp[l];
		return;
	}
	int mid = (l + r) >> 1;
	build(p << 1, l, mid);
	build(p << 1 | 1, mid + 1, r);
	update(p);
}

void add(int p, int l, int r, int s, int t, int x){
	if(l == s && r == t){
		ad(p, x);
		return ;
	}
	clear(p);
	int mid = (l + r) >> 1;
	if(t <= mid)
		add(p << 1, l, mid, s, t, x);
	else{
		if(s > mid)
			add(p << 1 | 1, mid + 1, r, s, t, x);
		else {
			add(p << 1, l, mid, s, mid, x);
			add(p << 1 | 1, mid + 1, r, mid + 1, t, x);
		}
	}
	update(p);
}

int solve(){
	int mid = W >> 1;
	cnt = 0;
	add(1);
	add(H - 1);
	for(int i = 1; i <= n; i++){
		add(y[i]);
		add(y[i] + 1);
		add(y[i] - 1);
	}
	sort(tmp + 1, tmp + cnt + 1);
	cnt = unique(tmp + 1, tmp + cnt + 1) - tmp - 1;
	if(!cnt){
		cout << (W + H) * 2 << endl;
		exit(0);
	}
	build(1, 1, cnt);
	for(int i = 1; i <= cnt; i++){
		d[i][0] = mid;
		d[i][1] = W - mid;
	}
	for(int i = 1; i <= n ; i++){
		if(y[i] == 0 || y[i] == H)
			continue;
		int t = lower_bound(tmp + 1, tmp + cnt + 1, y[i]) - tmp;
		if(x[i] <= mid)
			d[t][0] = min(d[t][0], mid - x[i]); 
		else
			d[t][1] = min(d[t][1], x[i] - mid);
	}
	top[0] = top[1] = 0;
	int ans = H + 1;
	for(int i = 1; i <= cnt; i++){
		for(int k = 0; k < 2; k++){
			add(1, 1, cnt, i , i, d[i][k]);
			while(top[k] && d[ stk[top[k]][k] ][k] > d[i][k]){
				int l = stk[top[k] - 1][k] + 1, r = stk[top[k]][k];
				add(1, 1, cnt, l, r, d[i][k] - d[r][k]);
				top[k]--;
			}
			stk[++top[k]][k]=i;
		}
		ans = max(ans, tmp[i] + mx[1] + 2);
	}
	return ans << 1;
}


int main(){
	ios::sync_with_stdio(false);
	cin >> W >> H >> n;
	for(int i = 1; i <= n; i++)
		cin >> x[i] >> y[i];
	int t1 = solve();
	
	for(int i = 1; i <= n; i++)
		swap(x[i], y[i]);
	swap(W, H);
	int t2=solve();
	int ans = max(t1, t2);
	cout << ans;
	return 0;
}




Measured memory_bytes: 43264
#include <string>
#include <vector>
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <utility>
#include <map>
using namespace std;


#define prec(i) cout << fixed << setprecision(i)

const long long int MOD = 1000000007;


int ctoi(char c) {
	if (c >= '0' && c <= '9')
		return c - '0';
	else
		return -1;
}


void output_yn(bool b) {
	if (b)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}


int main()
{
	long long int n, sum = 0;

	cin >> n;

	vector<int> a(n);
	vector<int> b(n - 1);

	for (int i = 0; i < n; i++)
		a[i] = 1000000;

	for (int i = 0; i < n - 1; i++)
		cin >> b[i];

	for (int i = 0; i < n - 1; i++) {
		if (a[i] > b[i])
			a[i] = b[i];
		if (a[i + 1] > b[i])
			a[i + 1] = b[i];
	}

	for (int i = 0; i < n; i++) {
		sum += a[i];
	}

	cout << sum << endl;

	return 0;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 3.14159265358979323846
#define pdd pair<double,double>
bool comp(int a,int b)
{
	return a>b;
}
int main() 
{
	int x;
	cin>>x;
	if(x==0)cout<<1;
	else cout<<0;
	return 0;    
}

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

using namespace std;

int main(int argc, char const *argv[])
{
	int A, B, C, X, Y, ans = 0, m;
    cin >> A >> B >> C >> X >> Y;
    if(2*C < A+B){
        m = min(X, Y);
        ans += m * 2 * C;
        X -= m;
        Y -= m;
    }
    if(2*C < A){
        ans += X * 2 * C;
        X = 0;
    }
    if(2*C < B){
        ans += Y * 2 * C;
        Y = 0;
    }
    ans += X * A;
    ans += Y * B;
    cout << ans << endl;
}


Measured memory_bytes: 256
def check(P):
 i=0
 for _ in[0]*k:
  s=0
  while s+w[i]<=P:
   s+=w[i];i+=1
   if i==n: return n
 return i
n,k=map(int,input().split())
w=[int(input())for _ in[0]*n]
l=0;r=n*100000
while r-l>1:
 m=(l+r)//2
 if check(m)>=n:r=m
 else:l=m
print(r)


Measured memory_bytes: 10340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll N, W;
    cin >> N >> W;
    vll w(N), v(N);
    vll val[4], acc[4];
    for (size_t i = 0; i < N; i++)
    {
        cin >> w[i] >> v[i];
    }
    for (size_t i = 0; i < N; i++)
    {
        val[w[i] - w[0]].push_back(v[i]);
    }
    for (size_t i = 0; i < 4; i++)
    {
        acc[i].resize(N+1);
        sort(all(val[i]), greater<ll>());
        partial_sum(all(val[i]), acc[i].begin()+1);
    }
    ll ans = 0;
    ll a[4];
    for (a[0] = 0; a[0] <= N; a[0]++)
    {
        for (a[1] = 0; a[0] + a[1] <= N; a[1]++)
        {
            for (a[2] = 0; a[0] + a[1] + a[2] <= N; a[2]++)
            {
                if((W - (a[1] + 2 * a[2] + (a[0] + a[1] + a[2]) * w[0]))<0)
                continue;
                a[3] = min((W - (a[1] + 2 * a[2] + (a[0] + a[1] + a[2]) * w[0])) / (3 + w[0]),N-a[0]-a[1]-a[2]);
                ll tmp = 0;
                for (size_t i = 0; i < 4; i++)
                {
                    tmp += acc[i][a[i]];
                }
                chmax(ans, tmp);
            }
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]
def dfs(cur):
    if len(cur)==10:
        ans = 0
        if sum(cur)==0:
            return -(10**9)
        for i in range(n):
            match=0
            for j in range(10):
                if cur[j]==f[i][j]==1:
                    match+=1
            ans+=p[i][match]
        return ans
    ret1 = dfs(cur+[0])
    ret2 = dfs(cur+[1])
    return max(ret1,ret2)
print(dfs([]))

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{

    int n,k;
    scanf("%d%d",&n,&k);
    char s[n];
    scanf(" %[^\n]",&s);

    s[k-1]=s[k-1]+32;
    int i=0;
    for(i=0;i<n;i++){
        printf("%c",s[i]);
        if(i==n-1){
            printf("\n");
        }
    }
    return 0;
}




Measured memory_bytes: 128
N = int(input())
count = 0

values = [1]
# 金額のパターンを設定
for i in range(1, 7):
    values.append(6**i)
    values.append(9**i)

values.sort()

# dpの初期化
dp =  [99999999] * (N+1)
dp[0] = 0

for i in range(1, N+1):
    for j in values:
        if i - j >= 0:
            dp[i] = min(dp[i], dp[i-j]+1)

print(dp[N])


Measured memory_bytes: 3828
#include <iostream>
#include <cstdio>

using namespace std;

int main() {
	
	while (true) {

		int a,b;
		char op;

		cin >> a >> op >> b;

		if (op == '+') cout << a + b << endl;
		else if (op == '-') cout << a - b << endl;
		else if (op == '/')cout << a / b << endl;
		else if (op == '*')cout << a * b << endl;

		else return 0;
	}
}


Measured memory_bytes: 3100
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;

ll n, k, ans, h[200005];
int main() {
	int i;
	cin >> n >> k;
	for(i=0; i<n; i++) scanf("%lld", &h[i]);
	sort(h, h+n);
	for(i=0; i<n-k; i++) ans += h[i];
	cout << ans;
	return 0;
}

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

int main() 
{
	int a, b, c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a + b == c || b + c == a || c + a == b) {
		cout  << "Yes";
	}
	else {
		cout << "No";
	}

}

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

int main(){
  ll M1, D1, M2, D2;
  cin >> M1 >> D1 >> M2 >> D2;
  
  if(M1 != M2){
    cout << '1' << endl;
  } else {
    cout << '0' << endl;
  }

  return 0;
}

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

int main(){
   int a[10] = {}, n, poi;
   while(cin >> n){
     if(n == 0){
       cout << a[9] << endl;
       for(int i = 9;i > 0;--i){
           a[i] = a[i - 1];
          }
     }else{
       for(int i = 0;i < 9;++i){
           a[i] = a[i + 1];
       }
       a[9] = n;
     }
   }
  return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int INF=1001001001001001001ll;

int X,Y,Z;
int N;
int A[111111],B[111111],C[111111];

int tx[111111],ty[111111];

signed main(){
    cin>>X>>Y>>Z;
    vpint ord;
    N=X+Y+Z;
    rep(i,N)cin>>A[i]>>B[i]>>C[i];
    rep(i,N)ord.pb({B[i]-A[i],i});
    sort(all(ord));

    fill_n(tx,111111,-INF);
    fill_n(ty,111111,-INF);

    priority_queue<int>que;
    int sum=0;
    rep(w,N){
        int i=ord[w].se;
        sum+=A[i];
        que.push(C[i]-A[i]);
        if(que.size()>X){
            sum+=que.top();
            que.pop();
        }
        if(que.size()==X)tx[w+1]=sum;
    }


    que=priority_queue<int>();
    sum=0;
    for(int w=N-1;w>=0;w--){
        int i=ord[w].se;
        sum+=B[i];
        que.push(C[i]-B[i]);
        if(que.size()>Y){
            sum+=que.top();
            que.pop();
        }
        if(que.size()==Y)ty[w]=sum;
    }


    int ans=-INF;
    rep(i,N)chmax(ans,tx[i]+ty[i]);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7792
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord
import qualified Data.IntSet as IS


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    [n,k] <- r'
    ds <- IS.fromList <$> r'
    print $ head $ filter ((solve ds).map(read.pure).show) [n..] 

solve :: IS.IntSet -> [Int] -> Bool
solve is []     = True
solve is (x:xs) = x `IS.notMember` is && (solve is xs)





Measured memory_bytes: 1020
#%%
A = list(input())
B = list(input())
C = list(input())
tmp = 'a'
check = 0

while check == 0 :
    if tmp == 'a':
        if len(A) != 0:
            tmp = A[0]
            A.pop(0)
        else:
            ans = 'A'
            check = 1
    elif tmp == 'b':
        if len(B) != 0:
            tmp = B[0]
            B.pop(0)
        else:
            ans = 'B'
            check = 1
    elif tmp == 'c':
        if len(C) != 0:
            tmp = C[0]
            C.pop(0)
        else:
            ans = 'C'
            check =1

print(ans)




#%%


Measured memory_bytes: 3064
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
// typedef long double ld;
#define INF (1LL<<60)
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 大
int compare(const void *a, const void *b){return *(double *)b - *(double *)a;}

int main(void){
    ll n,k,i;
    scanf("%lld%lld",&n,&k);
    double p[n];
    double ans[n-k+1];
    for(i=0;i<n;i++){
        scanf("%lf",&p[i]);
        p[i] = (1+p[i])/2;
    }
    // qsort(p,n,sizeof(ll),compare);
    
    // q[]
    for(i=0;i<k;i++){
        ans[0]+= ((double) p[i]);
        // printf("?%f? ",ans[0]);
    }
    for(i=1;i<n-k+1;i++){
        ans[i]= ans[i-1]-((double)p[i-1]);
        ans[i]+= ((double)p[i+k-1]);
    }
    qsort(ans,n-k+1,sizeof(double),compare);
    // for(i=0;i<n-k+1;i++){
    //     printf("%.2f ",ans[i]);
    // }

    printf("%.7f\n",ans[0]);
    return 0;
}


Measured memory_bytes: 4860
#include<stdio.h>
#include <string.h>
int main(void)
{
	int n, i, num0, num1;
	char s[100001];
	scanf("%s",s);
	num0=0,num1=0;
	for(i=0;i<strlen(s);i++){
		if(s[i]=='0')num0++;
		if(s[i]=='1')num1++;
	}
	if(num1>=num0){
		printf("%d",(strlen(s)-num1)*2);
	}else{
		printf("%d",(strlen(s)-num0)*2);
	}
	return 0;
}

Measured memory_bytes: 256
<?php
$n = int();
$sqrtN = sqrt($n);
$a = (int)ceil($sqrtN);
$d = (int)ceil($sqrtN);
$left = $a*$d - $n;
if($left == 0){
  $b = 0;
  $c = 0;
}else{
  $b = 1;
  $c = $left;
}

echo "0 0 $a $b $c $d";


function factor($M){
    $f = [];
    $rootM = $M**0.5+1;
    for($j = 2; $j <= $rootM; $j++){
        if($M%$j == 0){
            $f[] = $j;
            $M/=$j;
            $rootM = $M**0.5+1;
            $j--;
        }
    }
    if($M>1){
        $f[] = $M;
    }
    return $f;
}


function str(){
  return trim(fgets(STDIN));
}
function ints(){
  return array_map("intval", explode(" ", trim(fgets(STDIN))));
}
function int(){
  return intval(trim(fgets(STDIN)));
}

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

class union_find_tree {
public:
	int n;
	vector<int> parent;
	vector<int> hight;

	union_find_tree(int sz) {
		n = sz;
		for (int i = 0; i < n; ++i) {
			parent.push_back(i);
			hight.push_back(0);
		}
	}

	int find_root(int x) {
		if (parent[x] == x)return x;
		else return parent[x] = find_root(parent[x]);
	}

	void unite(int x, int y) {
		x = find_root(x);
		y = find_root(y);
		if (x == y)return;

		if (hight[x] < hight[y]) parent[x] = y;
		else {
			parent[y] = x;
			if (hight[x] == hight[y])++hight[x];
		}
	}

	bool same(int x, int y) {
		return find_root(x) == find_root(y);
	}
};

int main() {
	ll n, m;
	cin >> n >> m;
	vector<ll> p(n);
	for (ll i = 0; i < n; ++i)cin >> p[i];
	for (auto& x : p)--x;
	union_find_tree uf(n);
	for (ll i = 0; i < m; ++i) {
		ll x, y;
		cin >> x >> y;
		uf.unite(x - 1, y - 1);
	}
	ll ans = 0;
	for (ll i = 0; i < n; ++i) {
		if (uf.same(i, p[i]))++ans;
	}
	cout << ans << endl;
}


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

int main(){
    string s;
  cin >> s;
  bool flag = false;
  for(int i = 0;i < 3;i++){
    if(s[i] == '7'){
      flag = true;
      break;
     }
    }
    if(flag){
      cout << "Yes" << endl;
    }else{
    cout << "No" << endl;
    }
}


Measured memory_bytes: 3576