akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N, K, L, R;
  cin>>N>>K>>L>>R;
  vector<ll> arr1, arr2;
  ll tmp;
  for(int i=0;i<N;++i) {
    cin>>tmp;
    if(i<N/2) arr1.push_back(tmp);
    else arr2.push_back(tmp);
  }
  vector<vector<ll> > arr11(K+1), arr22(K+1);
  int num;
  for(int bit=0;bit<(1<<arr1.size());++bit) {
    tmp = 0;
    num = 0;
    for(int i=0;i<arr1.size();++i) {
      if((bit&(1<<i))!=0) {
        tmp += arr1[i];
        num++;
      }
    }
    if(num>K) continue;
    arr11[num].push_back(tmp);
  }
  for(int bit=0;bit<(1<<arr2.size());++bit) {
    tmp = 0;
    num = 0;
    for(int i=0;i<arr2.size();++i) {
      if((bit&(1<<i))!=0) {
        tmp += arr2[i];
        num++;
      }
    }
    if(num>K) continue;
    arr22[num].push_back(tmp);
  }
  for(int i=0;i<=K;++i) {
    sort(arr11[i].begin(), arr11[i].end());
    sort(arr22[i].begin(), arr22[i].end());
  }
  ll ans = 0;
  ll index1, index2;
  for(int i=0;i<=K;++i) {
    for(int j=0;j<arr11[i].size();++j) {
      index1 = lower_bound(arr22[K-i].begin(), arr22[K-i].end(), L-arr11[i][j]) - arr22[K-i].begin();
      index2 = upper_bound(arr22[K-i].begin(), arr22[K-i].end(), R-arr11[i][j]) - arr22[K-i].begin();
      ans += index2 - index1;
    }
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 23708
N = int(input())
U = set([i+1 for i in range(N)])
A = set([int(x) for x in input().split()[1:]])
B = set([int(x) for x in input().split()[1:]])
C = set([int(x) for x in input().split()[1:]])

result = ((U-A) & C) | (B & C)
print(len(result))

Measured memory_bytes: 7784
#include <cstdio>

const int kMaxn = 2e5 + 10, MOD = 1e9 + 7;

int n, DP[kMaxn], last[kMaxn], L[kMaxn];

inline void Add(int & x, long long y) {
	x = (x + y) % MOD;
}

int main() {
	scanf("%d", &n);
	for (int i = 1, ci; i <= n; i++) {
		scanf("%d", &ci);
		if (last[ci] && last[ci] + 1 != i) L[i] = last[ci];
		last[ci] = i;
	}

	DP[0] = 1;
	for (int i = 1; i <= n; i++) {
		Add(DP[i], DP[i - 1]);
		if (L[i]) {
			Add(DP[i], DP[L[i]]);
		}
	}

	printf("%d\n", DP[n]);
	return 0;
}


Measured memory_bytes: 2560
#include<stdio.h>

int main()
{
	int n;
	int m;
	int l;
	int** matrixA;
	int** matrixB;
	long long int** matrix;
	int iCount1;
	int iCount2;
	int iCount3;
	int Matrix_Num;
	

	//n,m,lの入力
	scanf("%d", &n);
	scanf("%d", &m);
	scanf("%d", &l);

	matrixA = (int*)malloc(sizeof(int *)*n);
	matrixB = (int*)malloc(sizeof(int*) * m);
	matrix = (long long int*)malloc(sizeof(long long int*) * n);

	//matrixAの初期化
	for (iCount1=0;iCount1<n;iCount1++)
	{
		matrixA[iCount1] = (int*)malloc(sizeof(int) * m);
	}

	//matrixBの初期化
	for (iCount1=0; iCount1 < m; iCount1++)
	{
		matrixB[iCount1] = (int*)malloc(sizeof(int) * l);
	}

	//matrixの初期化
	for (iCount1=0; iCount1 < n; iCount1++)
	{
		matrix[iCount1] = (long long int*)malloc(sizeof(long long int) * l);
	}

	//matrixAの代入
	for (iCount1=0; iCount1 < n; iCount1++)
	{
		for (iCount2=0; iCount2 < m; iCount2++)
		{
			scanf("%d", &Matrix_Num);
			matrixA[iCount1][iCount2] = Matrix_Num;
		}
	}

	//matrixBの代入
	for (iCount1 = 0; iCount1 < m; iCount1++)
	{
		for (iCount2 = 0; iCount2 < l; iCount2++)
		{
			scanf("%d", &Matrix_Num);
			matrixB[iCount1][iCount2] = Matrix_Num;
		}
	}

	//matrixの代入
	for (iCount1 = 0; iCount1 < n; iCount1++)
	{
		for (iCount2 = 0; iCount2 < l; iCount2++)
		{
			matrix[iCount1][iCount2] = 0;
		}
	}

	//行列計算
	for (iCount1 = 0; iCount1 < n; iCount1++)
	{
		for (iCount2 = 0; iCount2 < l; iCount2++)
		{
			for (iCount3 = 0; iCount3 < m; iCount3++)
			{
				matrix[iCount1][iCount2] += matrixA[iCount1][iCount3]*matrixB[iCount3][iCount2];
			}
		}
	}


	//計算結果の出力
	for (iCount1 = 0; iCount1 < n; iCount1++)
	{
		for (iCount2 = 0; iCount2 < l; iCount2++)
		{
			printf("%lld", matrix[iCount1][iCount2]);

			if (iCount2 != l - 1)
			{
				printf(" ");
			}
		}
		printf("\n");
	}

	//メモリの解放
	free(matrixA);
	free(matrixB);
	free(matrix);

}


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

#include<cstdio>
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  char a,b;
  cin>>a>>b;
  if(a=='9'||b=='9')cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
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;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int ans = 1e9;
bool field[505][505];
bool AllFalse = true;
bool tmp[505];
void f() {
    for(int h = 0; h < N; h++) {
        int now = 0;
        for(int w = 0; w < N; w++) {
            if(!field[h][w]) now++;
        }
        //if(now == 0) {
            int extra = 0;
            for(int w = 0; w < N; w++) {
                bool AllTrue = true;
                for(int i = 0; i < N; i++) {
                    if(!field[i][w]) AllTrue = false;
                }
                if(!AllTrue) extra++;
            }
            //chmin(ans, now + extra);
        //}
        int extra2 = 1;
        for(int i = 0; i < N; i++) {
            if(field[i][h]) extra2 = 0;
        }
        chmin(ans, now + extra + extra2);
    }
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 0; i < N; i++) {
        string S;
        cin >> S;
        for(int j = 0; j < N; j++) {
            if(S[j] == '#') field[i][j] = true;
            AllFalse &= !field[i][j];
        }
    }
    if(AllFalse) {
        cout << -1 << endl;
        return 0;
    }
    f();
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(int i=(l);i<(r);i++)
#define INF ((1LL<<62)-(1LL<<31))
#define min(p,q)((p)<(q)?(p):(q))
ll gcd(ll p,ll q){for(ll t;q;)t=p%q,p=q,q=t;return p;}
ll exgcd(ll p,ll q,ll*x,ll*y){
	ll tx,ty,t,x2=0,y2=1;
	*x=1;*y=0;
	while(q){
		tx=*x-p/q*x2;*x=x2;x2=tx;
		ty=*y-p/q*y2;*y=y2;y2=ty;
		t=p%q;p=q;q=t;
	}
	return p;
}
//非素数での逆元
ll inv(ll a,ll p){
	ll x,y;
	ll d=exgcd(a,p,&x,&y);
	if(d!=1)return-1;
	return x>0?x:x+p;
}

int main(){
	ll A,B;
	scanf("%lld%lld",&A,&B);
	//(A*n)/B>0 && (A*n)%B<A && n<(A*n)/B+(A*n)%B となる最小のn<B
	//(A*n)%Bで全探索
	ll d=gcd(A,B);
	ll invA=inv(A/d,B/d);
	ll ans=INF;
	for(int r=d;r<A;r+=d){
		ll n=(r/d)*invA%(B/d);
		if((A*n)/B>0 && (A*n)%B<A && n<(A*n)/B+(A*n)%B)ans=min(ans,n);
	}
	printf("%lld\n",ans==INF?-1:ans*A);
}


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


int main(){

    int a,b,c,x;
    cin >> a;
    cin >> b;
    cin >> c;
    cin >> x;

    int ans = 0;
    for(int i=0; i <= a; i++){
        for(int j=0; j <=b; j++){
            for(int k=0; k <= c; k++){
                if(500*i + 100*j +50*k == x){
                    ans++;
                }
             }   
        }       
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;

const ll MOD_CONST = 1000000007;



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

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


	int ai = a[n - 1];
	int aj = -1;
	for (int j = 0; j < n; j++) {
		if (std::abs(ai / 2.0 - a[j]) < std::abs(ai / 2.0 - aj)) {
			aj = a[j];
		}
	}

	cout << ai << " " << aj << endl;


}  



Measured memory_bytes: 1024
#include<iostream>
#include<map>

using namespace std;

map<long long int,long long int> mp;

int main(void)

{
    int a, i, n, c = 0;
    cin>>n;
    for(i = 1; i <= n; i++){
        cin>>a;
        if(i%2 == 1 && a%2 == 1){
            c++;
        }
    }
    cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 3148
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;
#define inf 100000007

int main(void){
    int n;
    cin >> n;
    int a[n], b[n];
    vector<vector<int>> data(n, vector<int>(2));
    for(int i = 0; i < n; i++){
        cin >> a[i]; cin >> b[i];
        data.at(i).at(0) = b[i];
        data.at(i).at(1) = a[i];
    }
    sort(data.begin(), data.end());
    int check = 0;
    for(int i = 0; i < n; i++){
        check += data.at(i).at(1);
        if(check > data.at(i).at(0)){
            cout << "No" << endl;
            break;
        }
        if(i == n-1)
            cout << "Yes" << endl;
    }
    return 0;
}

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

int main(){
 while(true){
  int M, T, P, R;
  cin >> M >> T >> P >> R;

  if(M==0 && T==0 && P==0 && R==0) break;

  int CP[T],  TT[T],  PT[T][P]; //正解数、時間計、ペナルティ
  for(int i=0; i<T; i++){
   CP[i] = TT[i] = 0;
   for(int j=0; j<P; j++){
    PT[i][j] = 0;
   }
  }

  for(int i=0; i<R; i++){ //各チームの正解数、時間計を求める
   int m, t, p, j;
   cin >> m >> t >> p >> j;
   
   if(j==0){ //正解
    CP[t-1]++;
    TT[t-1] += (m+PT[t-1][p-1]);
   }else{ //不正解
    PT[t-1][p-1] += 20;
   }
  }

   int t_now, t_pre = -1; //今のチーム、1つ前のチーム
   bool flag[50]; //処理済みフラグ
   for(int i=0; i<T; i++){
    flag[i] = false;
   }
   
   for(int i=0; i<T; i++){
    t_now = -1;
    for(int j=0; j<T; j++){ //今のチームを求める
     if(flag[j]) continue;
     if(t_now==-1){
      t_now = j;
     }else{
      if(CP[j]>CP[t_now] || (CP[j]==CP[t_now] && TT[j]<=TT[t_now])){
       t_now = j;
      }
     }
    }

    if(t_pre!=-1){
     if(CP[t_now]==CP[t_pre] && TT[t_now]==TT[t_pre]){
      cout << '=';
     }else{
      cout << ',';
     }
    }
    cout<<t_now+1;

    flag[t_now] = true;
    t_pre = t_now;
   }
   cout << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
import Control.Applicative ((<$>))
import Control.Monad (unless, replicateM)

import Data.List (foldl', group, sort, sortBy, intercalate)
import Data.Function (on)

import Data.Map (Map)
import qualified Data.Map as M


main :: IO ()
main = do
  n <- readLn
  unless (n == 0) $ do
    solve n >>= putStrLn
    main
    
solve :: Int -> IO String
solve n = do
  ss <- replicateM n (words <$> getLine)
  k <- head <$> getLine
  case M.lookup k (foldl' f M.empty (concat ss)) of
   Nothing -> return "NA"
   Just ls -> return . intercalate " " . map snd . take 5 . sortBy g . map (\x -> (length x, head x)) . group . sort $ ls
  where f m s = M.insertWith (++) (head s) [s] m
        g (l1, s1) (l2, s2) | l1 == l2 = compare s1 s2
                            | otherwise = compare l2 l1



Measured memory_bytes: 5568
import sys
c = list(map(int,input().split()))

for i in range(int(c[0])+1):
    for j in range(int(c[0]) - i + 1):
        if (10000*j + 5000*(int(c[0]) - i - j) + 1000*i) == int(c[1]):
            print("{} {} {}".format(j, int(c[0]) - i - j, i))
            sys.exit()

print("-1 -1 -1")


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

int main(){
  int N;
  cin>>N;
  vector<int> A(N),B(N),C(N-1);
  for(int &i:A)
    cin>>i;
  for(int &i:B)
    cin>>i;
  for(int &i:C)
    cin>>i;
  int j=0,k=30;
  for(int i:A){
    j+=B[i-1];
    if(i==k+1){
      j+=C[i-2];
    }
    k=i;
  }
  cout<<j<<endl;
}


Measured memory_bytes: 3580
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = 303;
int dis[N][N] , a[N][N] , n;

int main(){
    scanf("%d",&n);
    rep(i,0,n) rep(j,0,n) scanf("%d",a[i] + j) , dis[i][j] = a[i][j];
    rep(k,0,n) rep(i,0,n) rep(j,0,n) dis[i][j] = min(dis[i][j] , dis[i][k] + dis[k][j]);
    rep(i,0,n) rep(j,0,n) if(a[i][j] != dis[i][j]) return printf("-1\n") , 0;
    ll ans = 0;
    rep(i,0,n) rep(j,i+1,n) {
        bool fd = false;
        rep(k,0,n) if(k!=i&&k!=j) fd |= dis[i][k] + dis[k][j] == dis[i][j];
        if(!fd) ans += dis[i][j];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 896
#define Bobyama
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%m)
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

const int MAX_N = 10, MAX_M = 10;
int N, M;
int k[MAX_N];
int s[MAX_M][MAX_N];
int p[MAX_M];

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

  cin >> N >> M;
  rep(i, M) {
    cin >> k[i];
    rep(j, k[i]) {
      cin >> s[i][j];
    }
  }
  rep(i, M) cin >> p[i];

  ll ans = 0;
  for (int i = 0; i < (1<<N); ++i) {
    bool judge = true;
    for (int j = 0; j < M; ++j) {
      int count = 0;
      for (int l = 0; l < k[j]; ++l) {
        int t = s[j][l] - 1;
        if ((i>>t)&1) ++count;
      }
      if (count%2 != p[j]) judge = false;
    }
    if (judge) ++ans;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,int> pll;
 
int main(){
    #ifndef LOCAL
        fastIO;
    #endif
    int n,tope;
  	string s;
  	cin >> n >> s;
	tope=min(n,int(s.size()));
  	for(int i=0;i<tope;i++){
    	cout << s[i];
    }
  	if(s.size()>n) cout << "...";
   	cout << endl;
    return 0;
}

Measured memory_bytes: 3652
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MAX = 100000+24;
    private static boolean[] isPrime=new boolean[MAX];
    private static int[] Prime=new int[MAX];
    private static long[] Sum=new long[MAX];
    public static void makePrime(){
        Arrays.fill(isPrime,false);
        Arrays.fill(Sum,0);
        int tot=0; isPrime[1]=isPrime[0]=true;
        for(int i=2;i<MAX;i++){
            if(!isPrime[i]){
                Prime[tot++]=i;
            }
            for(int j=0;j<tot;j++){
                if(i*Prime[j]>=MAX) break;
                isPrime[i*Prime[j]] = true;
                if(i%Prime[j] == 0) break;
            }
            if( !isPrime[i] && !isPrime[(i+1)/2]){
                Sum[i]++;
            }
            Sum[i]+=Sum[i-1];
        }
    }
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);
        makePrime();
        while(in.hasNext()) {
            int Q=in.nextInt();
            for(int i=1;i<=Q;i++){
                int l=in.nextInt(),r=in.nextInt();
                out.println(Sum[r]-Sum[l-1]);
            }
            out.flush();
        }
        in.close();
        out.close();
    }

}


Measured memory_bytes: 65580
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
using namespace std;

int main()
{
   long long int r;cin>>r;
    long double ans;
    ans=2*3.1415926*r;
    cout<<setprecision(8)<<ans<<endl;
}


Measured memory_bytes: 3780
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <iterator>
#include <map>
const int MOD = 1e9+7;
using namespace std;


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if (!(a == b && b == c)){
		if (a == b || b == c || c == a){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=(n); i--)
#define LREP(lst,itr) for(auto itr = lst.begin(); itr != lst.end(); ++itr)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a, b) memcpy(b,a,sizeof(b))
#define P(s) cout<<(s)<<endl
#define P2(a, b) cout<<(a)<<" "<<(b)<<endl
#define P3(a, b, c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
#define V2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main(){
    int N,tmp,w=0,ans=0;
    cin >> N;
    map<int, int> mp;
    REP(i,0,N){
        cin >> tmp;
        mp[tmp]++;
    }

    for(auto m:mp){
        ans++;
        if(m.second%2==0){
            w++;
        }
    }
    if(w%2==1){
        ans--;
    }
    P(ans);
}

Measured memory_bytes: 4992
<?php
$NMXY = explode(" ", trim(fgets(STDIN)));
$x = explode(" ", trim(fgets(STDIN)));
$y = explode(" ", trim(fgets(STDIN)));

$min = $NMXY[2] + 1;
$max = $NMXY[3];

//0はWar,1はNo War
$judge = 1;

rsort($x);
if($x[0] < $max){
	if($min < $x[0] + 1){
		$min = $x[0] + 1;
	}
}else{
	$judge = 0;
}

sort($y);
if($y[0] >= $min){
	if($max > $y[0]){
		$max = $y[0];
	}
}else{
	$judge = 0;
}

if($min <= $max){
}else{
	$judge = 0;
}

if($judge == 0){
	printf("War");
}else{
	printf("No War");
}
?>

Measured memory_bytes: 3576
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main() {
    int n, h;
    cin >> n >> h;
    vector<P> a;
    REP(i,n){
        int x, y;
        cin >> x >> y;
        a.push_back(P(x, 1));
        a.push_back(P(y, 0));
    }
    sort(ALL(a));
    reverse(ALL(a));
    REP(i,2*n){
        h -= a[i].first;
        if (h <= 0){
            cout << i + 1 << endl;
            return 0;
        }
        if (a[i].second){
            cout << i + 1 + (h + a[i].first - 1) / a[i].first << endl;
            return 0;
        }
        // cout << h << endl;
    }
    return 0;
}





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

int main() {
    string n;
    cin >> n;
    long long sum = 0;
    for (int i=0; i < n.size(); ++i) {
        int x = n[i] - '0';
        sum += x;
    }
    if (sum % 9 == 0) cout << "Yes"  << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3752
#include<cstdio>

const int maxn = 20, maxC = 1005;

int dp[maxC];
int C[maxn], V[maxn];

inline void upt(int &x, int y)
{
	x = x < y ? y : x;
}

int main()
{
	int N;
	scanf("%d", &N);
	for(int i = 1; i <= N; ++i)
		scanf("%d", &V[i]);
	for(int i = 1; i <= N; ++i)
		scanf("%d", &C[i]);
	
	for(int i = 1; i <= N; ++i)
		for(int c = 1000; c >= C[i]; --c)
			upt(dp[c], dp[c - C[i]] + V[i]);
	
	int ans = 0;
	for(int c = 0; c <= 1000; ++c)
		upt(ans, dp[c] - c);
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N; cin >> N;

	int M = N / 2;
	if (N % 2 == 0) {
		cout << M * M << endl;	
	}else {
		cout << M * (M+1) << endl;	
	}
	return 0;
}


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

const int N = 2e5 + 5;

int n, a, b, c, d;
char s[N];

int main()
{
	scanf("%d%d%d%d%d%s", &n, &a, &b, &c, &d, s + 1);
	for (int i = a; i < c; i++) if (s[i] == '#' && s[i + 1] == '#')
		return puts("No"), 0;
	for (int i = b; i < d; i++) if (s[i] == '#' && s[i + 1] == '#')
		return puts("No"), 0;
	if (c < d) return puts("Yes"), 0;
	for (int i = b; i <= d; i++) if (s[i] == '.' && s[i - 1] == '.' && s[i + 1] == '.')
		return puts("Yes"), 0;
	return puts("No"), 0;
}

Measured memory_bytes: 3876
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int W = sc.nextInt();
		int H = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();
		int r = sc.nextInt();
		
		if(x-r<0 || y-r<0 || x+r>W || y+r>H){
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
	}
}

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

int main() {
    int n;
    
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        if (i % 3 == 0) {
            cout << " " << i;
        } else {
            for (int j=i; j>0; j /= 10) {
                if (j % 10 == 3) {
                    cout << " " << i;
                    break;
                }
            }
        }
    } cout << endl;
    return 0;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,n=0,d,f=0;
  string c;
  cin>>a>>b>>d;
  cin>>c;
  for(int i=0;i<c.size();i++){
    if(c[i]=='c') cout<<"No";
    else{
      if(n>=b+d) cout<<"No";
      else{
        if(c[i]=='b'){
          if(f<d) {
            f++;
            n++;
            cout<<"Yes";
          }
          else cout<<"No";
        }
        else{ n++;
             cout<<"Yes";}
        } 
      }
    cout<<"\n";
   }
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

using namespace std;

#define FOR(a,b) for(int a=0;a<b;a++)
#define F0R(a,b,c) for(int a = b; a<=c; a++)
#define f first
#define s second
#define m0(x) memset(x,0,sizeof(x))

typedef pair<int,int> pi;
typedef long long ll;
typedef vector<int> vi;
typedef vector<pi> vpi;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    string t; cin >> t;
    int n = t.length();
    FOR(i,n){
        if(t[i] == 'P') cout << 'P';
        else cout << 'D';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3788
import java.util.*;
 
public class Main{
	public static boolean[][] kanou = new boolean[50][50];
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		String[] paint = new String[H];
		for(int i=0;i<H;++i) paint[i] = sc.next();
		
		int[] dx = {1,0,-1,0};
		int[] dy = {0,1,0,-1};
		for(int i=0;i<H;++i){
			for(int j=0;j<W;++j){
				if(paint[i].charAt(j)=='#'&&!kanou[i][j]){
					boolean cant = true;
					for(int k=0;k<4;++k){
						if(inrange(i+dy[k],j+dx[k],H,W)&&paint[i+dy[k]].charAt(j+dx[k])=='#'){
							kanou[i][j] = true;
							kanou[i+dy[k]][j+dx[k]] = true;
							cant = false;
							break;
						}
					}
					if(cant){
						System.out.println("No");
						return;
					}
				}
			}
		}
		System.out.println("Yes");
		return;
	}
	
	public static boolean inrange(int a,int b,int x,int y){
		return ((a>=0)&&(a<x))&&((b>=0)&&(b<y));
	}
}

Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define MOD 998244353
#define MAX 200003

int main(){
  int N;
  cin>>N;
  vector<ll> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

  ll ans=0;
  for(int i=1;i<N;i++){
    if(A[i]<A[i-1]){
      ans+=A[i-1]-A[i];
      A[i]=A[i-1];
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;

typedef long long ll;

void failure () {
  cout << -1 << endl;
  exit(0);
}

const int MAX_N = 55;

ll taken [MAX_N];
int can_become [MAX_N][MAX_N];

void take_op (int k) {
  taken[k] = 1;
  for (int i = 0; i < MAX_N; i++) {
    for (int j = 0; j < MAX_N; j++) {
      if (can_become[i][j]) {
        can_become[i][j % k] = 1;
      }
    }
  }
}

int target [MAX_N];

int access [MAX_N];
int mna (int idx) {
  if (can_become[idx][target[idx]]) return 0;

  for (int i = 0; i < MAX_N; i++) {
    access[i] = 0;
  }
  access[target[idx]] = 1;

  for (int i = target[idx] + 1; i < MAX_N; i++) {
    for (int j = 0; j < i; j++) {
      if (access[j]) {
        for (int k = 1; k * i + j < MAX_N; k++) {
          access[k * i + j] = 1;
          if (can_become[idx][k * i + j]) return i;
        }
      }
    }
  }

  return MAX_N;
}

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

  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;

    can_become[i][a] = 1;
  }

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

  for (int i = 0; i < n; i++) {
    if (mna(i) == MAX_N) failure();
  }

  while (true) {
    int max_mna = 0;
    for (int i = 0; i < n; i++) {
      max_mna = max(max_mna, mna(i));
    }

    if (max_mna == 0) break;

    take_op(max_mna);
  }

  ll ans = 0;
  for (int i = 0; i < MAX_N; i++) {
    ans += taken[i] << i;
  }
  cout << ans << endl;
}


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

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  int K;
  cin >> K;
  int sum = A + B + C;
  int D = max(max(A, B), C);
  sum -= D;
  for (int i = 0; i < K; i++)
  {
    D *= 2;
  }
  sum += D;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
from bisect import bisect_left, bisect_right

n = int(input())

an = list(map(int, input().split()))
bn = list(map(int, input().split()))
cn = list(map(int, input().split()))

an.sort()
bn.sort()
cn.sort()

cnt = 0
for b in bn:
    a = bisect_left(an, b)
    c = bisect_right(cn, b)
    cnt += a * (n - c)

print(cnt)

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

int main(){
	string s;
	cin >> s;
	if(s[s.size()-1] == 's') cout << s << "es" << endl;
	else cout << s << "s" << endl;
}

// cout << fixed << setprecision(15) <<  << endl;

Measured memory_bytes: 3592
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#define ll long
#define INF 1000000000
#define N 10000000
using namespace std;

int gcd(int x, int y){
    if (y>x){
       swap(x,y); 
    }
    while (y!=0){
        int r=x%y;
        x=y;
        y=r;
    }
    return x;
}

int gcd3(int x, int y, int z){
    int p=gcd(x,y);
    return gcd(p,z);
}

int main(){
    int k;
    cin>>k;
    ll sum=0;
    for (int i=1; i<=k; i++){
        for (int j=1; j<=k; j++){
            for (int r=1; r<=k; r++) sum+=gcd3(i,j,r);
        }
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3592
#include <iostream>

using namespace std;

const int MOD = 1'000'000'007;

long long mul(long long a, long long b)
{
	return (a * b) % MOD;
}

long long fact(long long n)
{
	long long ans = 1;
	for (; n > 0; --n) {
		ans = mul(ans, n);
	}
	return ans;
}

long long solve(long long N, long long M)
{
	switch (abs(N - M)) {
	case 0:
		return mul(2, mul(fact(N), fact(M)));
	case 1:
		return mul(fact(N), fact(M));
	default:
		return 0;
	}
}

int main()
{
	long long N, M;
	cin >> N >> M;
	cout << solve(N, M) << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

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

	vector<vector<int>> dp(n, vector<int>(3));


	vector<vector<int>> a(n, vector<int>(3));
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			int x;
			cin >> x;

			a.at(i).at(j) = x;
		}
	}

	dp.at(0).at(0) = a.at(0).at(0);
	dp.at(0).at(1) = a.at(0).at(1);
	dp.at(0).at(2) = a.at(0).at(2);
	for (int i = 1; i < n; i++)
	{
		for (int j = 0; j < 3; j++)
		{
			for (int k = 0; k < 3; k++)
			{
				if (j != k)
				{
					dp.at(i).at(k) = max(dp.at(i).at(k), dp.at(i - 1).at(j) + a.at(i).at(k));
				}
			}
		}
	}

	int ans = -1;
	for (int i = 0; i < 3; i++)
	{
		ans = max(ans, dp.at(n - 1).at(i));
	}

	cout << ans << endl;
}


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

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

    for(ll i=0;i<s.length();i++)
    {
        ll v = s[i] - 'A';
        v = (v + n)%26;
        s[i] = v + 'A';
    }
    cout<<s;
    return 0;
}


Measured memory_bytes: 256
import sys

A = list()
for i in range(3):
    a = list(map(int,input().split()))
    A.append(a)
N = int(input())
for i in range(N):
    target = int(input())
    for a in range(len(A)):
        for k in range(len(A[a])):
            if target == A[a][k]:
                A[a][k] = 0

# 縦のビンゴを調べる
for i in range(3):
    if A[0][i] == 0 and A[1][i] == 0 and A[2][i] == 0:
        print('Yes')
        sys.exit()
# 横のビンゴを調べる
for i in range(3):
    if A[i][0] == 0 and A[i][1] == 0 and A[i][2] == 0:
        print('Yes')
        sys.exit()
# ナナメのビンゴを調べる
if A[0][0] == 0 and A[1][1] == 0 and A[2][2] == 0:
    print('Yes')
    sys.exit()
if A[0][2] == 0 and A[1][1] == 0 and A[2][0] == 0:
        print('Yes')
        sys.exit()

print('No')


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a==5 && b==7 && c==5){
		cout<<"YES"<<endl;
	}
	else if(a==5 && b==5 && c==7){
		cout<<"YES"<<endl;
	}
	else if(a==7 && b==5 && c==5){
		cout<<"YES"<<endl;
	}
	else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().execute();
	}

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		int[] counter = new int[100002];
		Arrays.fill(counter, 0);
		for (int i = 0; i < N; i++) {
			int ai = sc.nextInt();
			counter[ai]++;
			counter[ai + 1]++;
			counter[ai + 2]++;
		}

		int cnt = 0;
		for (int i = 0; i < counter.length; i++) {
			cnt = Math.max(cnt, counter[i]);
		}
		System.out.println(cnt);
		sc.close();
	}
}

Measured memory_bytes: 49048
#include <iostream>

using namespace std;
 
int main(){
    long long n, sum = 0;
 
    cin >> n;
    while(n--){
	int a,b;
	char c;
 
	cin >> a >> c >> b;
	if(c == '(') sum += b;
	else sum -= b;
  
	if(sum == 0) cout << "Yes" << endl;
	else cout << "No" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

ll n;
ll x, y;
ll ans;

int main()
{
    scanf("%lld", &n);
    x = -1;
    while(n--)
    {
        scanf("%lld", &y);
        if(x + 1 < y)
        {
            printf("-1\n");
            return 0;
        }
        else if(x + 1 == y) ans++;
        else ans += y;
        x = y;
    }
    printf("%lld\n", ans - 1);
    return 0;
}


Measured memory_bytes: 384
/*
          .  .
          |\_|\
          | a_a\
          | | "]
      ____| '-\___
     /.----.___.-'\
    //        _    \
   //   .-. (~v~) /|
  |'|  /\:  .--  / \
 // |-/  \_/____/\/~|
|/  \ |  []_|_|_] \ |
| \  | \ |___   _\ ]_}
| |  '-' /   '.'  |
| |     /    /|:  |
| |     |   / |:  /\
| |     /  /  |  /  \
| |    |  /  /  |    \
\ |    |/\/  |/|/\    \
 \|\ |\|  |  | / /\/\__\
  \ \| | /   | |__
       / |   |____)
       |_/
*/

#include <bits/stdc++.h>

#define FLASH ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long int
#define MAX 1e9
#define MIN -1e9
#define mod 1000000007
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr<<#x<<'='<<(x)<<endl;
#define mxn 100005
using namespace std;



int main()
{
    FLASH
    ll n,k;
    cin >> n >> k;
    ll a[n + 1];
    ll vis[n + 1];

    memset(vis,0,sizeof(vis));
    vector<ll> ans;
    for(int i = 1; i<= n;i++)
      cin >> a[i];
    int i = 1;
    ll cnt = 0;
    while(vis[i] == 0 || vis[i] == 1)
    {
      vis[i]++;
      /*if(i == a[i])
      {
          if(cnt <= k)
          {
            cout << i;
            return 0;
          }
          else{
            cout << ans[k];
            return 0;
          }
      }*/
      i = a[i];

      cnt++;
      ans.push_back(i);
    }
 //   ans.push_back(ans[0]);
   // ans.erase(ans.begin());
    vector<ll> ans1,ans2;
    set<ll> temp;
    i = 0;
    while( i < (int)ans.size())
    {
      if(vis[ans[i]] == 1)
        ans1.push_back(ans[i]);
      else
      {
        while(i < (int)ans.size())
        {
          ll nn = temp.size();
          temp.insert(ans[i]);
          if(nn == (int)temp.size())
          {
            i = ans.size();
            break;
          }
          ans2.push_back(ans[i]);
         i++; 
        }
      }
      i++;
    }
/*   for(int i = 0;i < ans.size() ;i++)
    {
      cout << ans[i] << " ";
    }
    cout << endl;
    for(int i = 0;i < ans1.size() ;i++)
    {
      cout << ans1[i] << " ";
    }
    cout << endl;
    for(int i = 0;i < ans2.size() ;i++)
    {
      cout << ans2[i] << " ";
    }
    cout << endl;*/
    if(k <= (int)ans1.size())
    {
      ll m = k % ans1.size();
      if(m == 0)
        m = ans1.size();
      cout << ans1[m - 1];
      return 0;
    }
    k -= (int)ans1.size();
    ll m = k % ans2.size();
    //cout << k << " " << ans2.size() << " " << m << endl;
    if(m == 0)
      m = ans2.size();
    cout << ans2[m - 1];
    return 0;
}



Measured memory_bytes: 19120
// Goods things are coming, just keep believing 
 
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
#define FOR(i, x, n) for(ll i = x; i < n; i++) 
#define pb push_back
#define pf push_front
#define ll long long
#define hii cout << "hii" << endl
#define okay cout << "okay" << endl
// #define hey cout << "hey" << endl
#define pii pair<int, int>
#define pll pair<ll, ll>
#define mpp make_pair
#define endl '\n'
#define ff first 
#define int long long
#define ss second
#define vi vector<int>
#define all(s) s.begin(), s.end()
#define si size()
 #define ld long double
#define INF 1000000000;
 
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; } 

 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE
 
typedef tree<
pair<int, int>,
null_type,
less<pair<int, int>>,
rb_tree_tag,
tree_order_statistics_node_update> ordered_set;
 
 
 
const int N = 2e5 + 10;
const int LG = 20;
const int mod = 998244353;

// int arr[N];
int n, k, p, x, y;
void solve()
{
	int h, w;
	cin >> h >> w;
	if(h == 1)
	{
		cout << 1 << endl;
		return;
	}
	if(w == 1)
	{
		cout << 1 << endl;
		return;
	}
	int row1 = (h + 1) / 2;
	int col1 = (w + 1) / 2;
	int row2 = (h) / 2;
	int col2 = (w) / 2;
	cout << row1 * col1 + row2 * col2 << endl;
} 

int32_t main() 
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

    int t;
    t = 1;
    // cin >> t;
    while(t--)
    	solve();
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
Ans = 0
for i in range(N-1):
    if A[i]==i+1:
        A[i],A[i+1] = A[i+1],A[i]
        Ans += 1
if A[N-1]==N:
    Ans += 1
print(Ans)

Measured memory_bytes: 14008
import sys
import math
input = sys.stdin.readline

def is_prime(x):
    if x <= 1: 
        return False
    for i in range(2,math.ceil(x**0.5)):
        if x%i==0: 
            return False
    return True
    
def main():
    x = int(input())
    for i in range(x, 100004):
        if is_prime(i):
            print(i)
            return

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        String S=  sc.next();

        List<Integer> list = new ArrayList<>();
        List<Character> list01 = new ArrayList<>();
        char prev = S.charAt(0);
        int count =1;
        for (int i = 1; i < S.length(); i++) {
            char c = S.charAt(i);
            if(prev==c){
                count++;
            }else{
                list.add(count);
                list01.add(prev);
                count=1;
            }
            prev=c;
        }
        list.add(count);
        list01.add(prev);

        if(list01.get(0)=='0'){
            list.add(0,0);
        }
        if(list01.get(list01.size()-1)=='0'){
            list.add(0);
        }
        int ans=0;
        int width = 2*K+1;

        //TLE  n^2
//        for (int i = 0; i < list.size() ; i=i+2) {
//            int len = 0;
//            for (int j = i; j <= Math.min( width+i-1,list.size()-1) ; j++) {
//                len += list.get(j);
//            }
//            ans = Math.max(ans,len);
//        }

//        //尺取り
//        int left =0;
//        int right =0;
//        int temp = 0;
//        for (int i = 0; i < list.size() ; i=i+2) {
//            int nextleft = i;
//            int nextright = Math.min(i+width-1,list.size()-1) ;
//            while(left<nextleft){
//                temp -= list.get(left);
//                left++;
//            }
//            while(right<=nextright){
//                temp += list.get(right);
//                right++;
//            }
//            ans = Math.max(ans,temp);
//        }

        int[] accuSum = new int[list.size()+1];
        for (int i = 0; i < list.size() ; i++) {
            accuSum[i+1] = accuSum[i]  + list.get(i);
        }

        //累積和
        for (int i = 0; i < list.size() ; i=i+2) {
            int nextleft = i;
            int nextright = Math.min(i+width-1,list.size()-1) ;
            int temp = accuSum[nextright+1] - accuSum[nextleft];
            ans = Math.max(ans,temp);
        }


        System.out.println(ans);
    }
}


Measured memory_bytes: 29156
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] c= new int[N];
        int x = 1;
        for(int i = 1; i < M/2; i++ ){
            if(M%i ==0){
                if(M/i>=N){
                    x=i;
                }
            }
        }
         if(M%M==0){
                if(M/M>=N){
                    x=M;
                }
            }
        System.out.println(x);
    }
}


Measured memory_bytes: 23380
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <cmath>   
#include<cctype>
#include<string>
#include<set>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <utility> 

#define rep(i,m,n) for(int i = m;i < n;++i)
using namespace std;
using ll = long long;
using R = double;
const ll inf = 1LL << 50;
const ll MOD = 1e9 + 7;




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

	vector<int>a(n);
	rep(i, 0, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	
	ll temp = inf;
	ll ans;
	if (a[n - 1] % 2 == 0) {
		rep(i, 0, n - 1) {
			if (abs(a[i]-(a[n-1])/2) < temp) {
				ans = a[i];
				temp = abs(a[i] - (a[n - 1]) / 2);
			}
		}
	}
	else {
		rep(i, 0, n - 1) {
			if (abs(a[i] - (a[n - 1]+1) / 2) < temp) {
				ans = a[i];
				temp = abs(a[i] - (a[n - 1]+1) / 2);
			}
			else if (abs(a[i] - (a[n - 1] - 1) / 2) < temp) {
				ans = a[i];
				temp = abs(a[i] - (a[n - 1]-1) / 2);
			}
		}
	}

	cout << a[n-1] << " " << ans << endl;

	return 0;
}


Measured memory_bytes: 768
#include <stdio.h>

int main(void) {

    int N,M;

    scanf("%d %d", &N, &M);

    int s[M],c[M];
    int n[N],a[N];
    int i,j;
    int result = 0;

    for(i = 0;i < M;i++){
        scanf("%d %d", &s[i], &c[i]);
    }

    // for(i = 0;i < M;i++){
    //     printf("%d %d", s[i], c[i]);
    // }

    for(j = 0;j < N;j++){
        n[j] = 0;
        a[j] = 0;
    }

    for(i = 0;i < M;i++){
        if(a[s[i]-1] == 0){
            n[s[i]-1] = c[i];
            a[s[i]-1] = 1;
        }else if(a[s[i]-1] == 1 && n[s[i]-1] == c[i]){
        }else{
            result = -1;
        }
        //printf("result=%d\n", result);

    }

    // for(j=0;j<N-1;j++){
    //     printf("%d", n[j]);
    //     }
    //     printf("%d\n", n[N-1]);

    for(j = 0;j < N;j++){
        if(a[j] == 0 && j != 0){
            n[j] == 0;
        }else if(a[0] == 1 && n[0] == 0 && N != 1){
            result = -1;
        }else if(a[0] == 0 && N != 1){
            n[0] = 1;
        }else if(a[0] == 0 && N == 1){
            n[0] = 0;
        }
        //printf("n[%d]=%d\n a[%d]=%d\n result=%d\n", j, n[j], j, a[j], result);
    }

    //printf("result=%d\n", result);

    if(result != -1){
        for(j=0;j<N-1;j++){
            printf("%d", n[j]);
        }
        printf("%d\n", n[N-1]);
    }else{
        printf("-1\n");
    }


    return 0;
}

Measured memory_bytes: 128
NOT_FREE = 1
FREE = 0

q = [0 for i in range(8)]
row = [0 for i in range(8)]
col = [0 for i in range(8)]
dneg = [0 for i in range (16)]
dpos = [0 for i in range (16)]


def printBord():
    for r in range(8):
        for c in range(8):
            if q[r] == c:
                print("Q",end="")
            else: print(".",end="")
        print()


def putQueen(i):
    if i == 8:
        printBord()
        return
    
    if row[i]:
        if putQueen(i+1):return 

    for j in range(8):
        if (row[i] or col[j] or dpos[i+j] or dneg[i-j+7]) == NOT_FREE :continue
        q[i] = j
        col[j] = dpos[i+j] = dneg[i-j+7] = NOT_FREE
        if putQueen(i+1) : return
        col[j] = dpos[i+j] = dneg[i-j+7] = FREE
    return


if __name__=='__main__':
    k = int(input())
    for i in range(k):
        r, c = (int(x) for x in input().split())
        q[r] = c
        row[r] = col[c] = dpos[r+c] = dneg[r-c+7] = NOT_FREE
    putQueen(0)




Measured memory_bytes: 5620
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/04/04.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//  ABC163
//
//

#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)

using ll = long long;

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

// const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;
//#define __DBG__


void solve(void){
  
  int R;
  double PI=3.1415926;
  
  cin >> R;
  
  cout << fixed << setprecision(15);
  cout << 2*PI*R << endl;

  
  return;
   
}



#define TESTCASES 1

int main(int argc, const char * argv[]) {


    cin.tie(0);
    ios::sync_with_stdio(false);

    REP(i,TESTCASES){
      solve();
    }
 
    return 0;
}



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

int main()
{
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < n; i++)
    {
        cin >> a.at(i);
        if (a.at(i) == 0)
        {
            cout << 0 << endl;
            return 0;
        }
    }
    long long max = 1e18;
    long long ans = 1;
    for (long long i = 0; i < n; i++)
    {
        if ((max / ans) < a.at(i))
        {
            cout << -1 << endl;
            return 0;
        }
        ans *= a.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3984
//
//  main.cpp
//  CoderWork
//
//  Created by Minoru Hayashi on 2020/02/29.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//

#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)

//#define __DBG__


void solve(void){

  int N,M;
  cin >> N >> M;
  
  int S[M],C[M];
  
  int flag = 1;
  
  REP(i,M){
    cin >> S[i] >> C[i];
  }
  
  vector<int> ANS(N,-1);
  
  REP(i,M){
    if(ANS.at(S[i]-1)==-1){
      ANS.at(S[i]-1)=C[i];
    }
    else if(ANS.at(S[i]-1)!=C[i])
    {
      flag = 0;
      break;
    }
  }

#ifdef __DBG__
  REP(i,N){
    cout << ANS.at(i) << ' ';
  }
  cout << endl;
#endif
  
  if(ANS.at(0)==0 && N>1){
    flag = 0;
  }
  else if(ANS.at(0)==-1 && N>1)
  {
    ANS.at(0)=1;
  }
  if(flag){
    REP(i,N){
      if(ANS.at(i)==-1){
        ANS.at(i)=0;
      }
      cout << ANS.at(i);
    }
  }
  else
  {
    cout << "-1";
  }
  cout << endl;

  return;
}

int main(int argc, const char * argv[]) {

    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
  
    solve();
 
    return 0;
}





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

#include <iostream>
using namespace std;
int main() {
  uint64_t a, b, n;
  cin >> a >> b >> n;
  uint64_t x;
  if (b > n) {
    x = n;
  } else {
    x = b - 1;
  }

  cout << uint64_t(a * x / b) << endl;

  return 0;
}


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

#define pi 3.141592653589793
int main() {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double w=5.5*(H*60+M)*pi/180.0;
  cout << fixed << setprecision(20)<< sqrt(A*A+B*B-2*A*B*cos(w)) << endl;

}



Measured memory_bytes: 4224
#include<iostream>
using namespace std;
#define LEN 100

int main(){
    int n,k,u,v,M[LEN+1][LEN+1];
    cin>>n;

    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            M[i][j]=0;

    for(int i=0;i<n;i++){
      cin>>u>>k;
        for(int j=0;j<k;j++){
            cin>>v;
            M[u-1][v-1]=1;
        }
    }

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j) cout<<" ";
            cout<<M[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3120