akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for (int i = a; i <= b; i++) {
            String tmp = Integer.toString(i);
            if(tmp.substring(0, 1).equals(tmp.substring(4, 5)) &&
                    tmp.substring(1, 2).equals(tmp.substring(3, 4))) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 49520
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define FORR(i,a,b) for (int i=(a);i>=(b);i--)

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const double EPS = 1e-9;


int main() {
    int N;
    cin >> N;
    vector<int> x(N+1), y(N+1);

    FOR(i, 0, N) {
        cin >> x[i] >> y[i];
    }
    x[N] = x[0]; y[N] = y[0];

    double area = 0;
    FOR(i, 0, N) {
        area += (x[i + 1] - x[i]) * (y[i + 1] + y[i]) * 0.5;
    }

    cout << fixed << setprecision(1);
    cout << abs(area) << endl;

    return 0;
}

Measured memory_bytes: 3264
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<cstdio>
#include<queue>
#include<deque>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef pair<int,int> ii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int INF=1e9;
const ll MOD=1e9+7;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};

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

int dis2(int x1,int y1,int x2,int y2){
    return (x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
}
ll inf=998244353;
ll power(ll a,ll x){
    ll res=1;
    while(x>0){
        if(x&1) res=res*x%inf;
        x=x*x%inf;
        x>>=1;
    }
    return res;
}
int main(){
    string s;cin>>s;
    int n=(int)s.size(),p=0;
    for(int i=0;i<n;i++)if(s[i]=='p') p++;
    cout<<n/2-p<<endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll n,m,f[200001],a[200001],n1,ans[200001];
ll find(ll r,ll hh){
	ll l=1,mid,ha=0;
	while(l<=r){
		mid=(l+r)/2;
		if(a[mid]<=hh)ha=mid,l=mid+1;
		 else r=mid-1;
	}
	return ha;
}
int main(){
	ll i,x,id,now;
	scanf("%lld%lld",&n,&m);
	a[++n1]=n;
	for(i=1;i<=m;i++){
		scanf("%lld",&x);
		while(x<=a[n1])n1--;
		a[++n1]=x;
	}
	m=n1;
	f[m]=1;
	for(i=m;i;i--){
		now=a[i];
		id=find(i-1,now);
		while(id){
			f[id]+=now/a[id]*f[i];
			now%=a[id];
			id=find(id-1,now);
		}
		ans[now]+=f[i];
	}
	for(i=n;i;i--)ans[i]+=ans[i+1];
	for(i=1;i<=n;i++)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,i,j,x,y,k,b = 0,ans = 0,now = 0;bool ok;scanf("%d",&n);
  vector<pair<int,int>> A[n];
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&x,&y);x--;
      A[i].push_back(make_pair(x,y));
    }
  }
  while(b<(1<<n)){
    ok = true;now = 0;bitset<15> B(b);
    for(i=0;i<n;i++){
      if(B[i]==0) continue;
      for(j=0;j<A[i].size();j++){
        if(A[i][j].second != B[A[i][j].first]){
          ok = false;break;
        }
      }
      if(!ok) break;
      now++;
    }
    if(ok) ans = max(ans,now);
    b++;
  }
  printf("%d\n",ans);
}

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

bool is_one(int pi, int a) {
    if (pi <= a) return true;
    return false;
}

bool is_two(int pi, int a, int b) {
    if (pi >= a + 1 && pi <= b) return true;
    return false;
}

bool is_three(int pi, int b) {
    if (pi >= b + 1) return true;
    return false;
}


int p[30];
int main() {
    int n, a, b;
    cin >> n;
    cin >> a >> b;
    for (int i = 0; i < n; ++i) cin >> p[i];
    
    int count1 = 0;
    for (int i=0; i<n; i++) {
        if (is_one(p[i], a)) count1++;
    }

    int count2 = 0;
    for (int i=0; i<n; i++) {
        if (is_two(p[i], a, b)) count2++;
    }

    int count3 = 0;
    for (int i=0; i<n; i++) {
        if (is_three(p[i], b)) count3++;
    }

    int ret = min(count1, count2);
    ret = min(ret, count3);
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
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; }
template<class T> inline bool change(T& a, T b) { if (a != b) { a = b; return 1; } return 0; }
using namespace std;
typedef long long ll;

ll num[10000001];

int main(){
    ll n; cin >> n;
    for(ll i=3;i<=n;i++){
        for(ll j=i;j<=n;j+=i){
            num[j]++;
        }
    }
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=i*(num[i]+1+((i+1)%2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 81716
import java.util.ArrayList;
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
		long N = sc.nextLong();
		ArrayList<Long> multiArray = new ArrayList<>();
		
		// Nの平方根を取得
		long squareRoot= 1;
		for(long a = 1; a <= N; a++) {
			if(N < a * a) {
				squareRoot = a;
				break;
			}
		}
		
		// Nの約数の和を取得
		for(long i = 1; i <= squareRoot; i++) {
			if(N % i == 0 ) {
				multiArray.add(i + (N / i));
			}
		}

		// 和が最少となる約数を取得
		long culc = multiArray.get(0);
		for(int i = 0; i < multiArray.size(); i++) {
			if(multiArray.get(i) < culc) {
				culc = multiArray.get(i);
			}
		}
		
		// 和から２引いた結果を出力
		System.out.println(culc - 2);
		sc.close();
	}
}

Measured memory_bytes: 23892
#include<iostream>
#include<math.h>

using namespace std;

#define EPS (1e-10)
#define equals(a,b) (fabs((a)-(b))<EPS)

class Point {
public:
	double x, y;


	Point(double x = 0,double y=0):x(x),y(y){}

	Point operator + (Point p) { return Point(x + p.x, y + p.y); }
	Point operator - (Point p) { return Point(x- p.x, y - p.y); }
	Point operator * (double a) { return Point(a*x, y + a*y); }
	Point operator / (double a) { return Point(x/a, y /a); }

	double abs() { return sqrt(norm()); }
	double norm() { return x * x + y * y; };

	bool operator < (const Point& p)const {
		return x != p.x ? x < p.x : y < p.y;
	}

	bool operator ==(const Point& p)const {
		return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
	}

};

typedef Point Vector;

double dot(Vector a, Vector b) {
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b) {
	return a.x * b.y - a.y * b.x;
}

bool isOrthogonal(Vector a, Vector b) {
	return equals(dot(a, b) , 0.0);
}

bool isParallel(Vector a, Vector b) {
	return equals(cross(a, b), 0.0);
}

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


for (int i = 0; i < q; i++) {
	int x0, x1, x2, x3, y0, y1, y2, y3;
	cin >> x0 >> y0 >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;

	Vector v0 = Vector(x0, y0);
	Vector v1 = Vector(x1, y1);
	Vector v2 = Vector(x2, y2);
	Vector v3 = Vector(x3, y3);

	Vector s1 = v1 - v0;
	Vector s2 = v3 - v2;

	if (isOrthogonal(s1, s2)) {
		cout << "1" << endl;
	}
	else if (isParallel(s1, s2)) {
		cout << "2" << endl;
	}
	else {
		cout << "0" << endl;
	}

 }

return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,k;
    cin>>a>>b>>k;
    int ar=a+k-1;
    int bl=b-k+1;
    if(ar>=bl)
        for(int i=a;i<=b;i++)
            cout<<i<<endl;
    else
    {
        for(int i=a;i<=ar;i++)
            cout<<i<<endl;
        for(int i=bl;i<=b;i++)
            cout<<i<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const int MOD = 1e9+7, MAX = 1e9, larg = 1e5, INF = -1e9;
int A,B,C,D,E,F,G,H,I,J,K,L,N,M,O,P,Q,R,S,T,U,V,W,X,Y,Z;
int max_value = 0, max_index = 0;
int min_value = MAX, min_index = 0;
int sum = 0;

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

char m[2001][2001];
int col[2000][2000];
int row[2000][2000];

int main() {
    cin >> H >> W;
    rep(i, H){
        rep(j, W){
            cin >> m[i][j];
            col[i][j] = row[i][j] = 0;
        }
    }

    rep(i, H){
        int j=0;
        while(m[i][j] == '#') j++;
        while(j < W){
            int count = 0;
            while(m[i][j+count] == '.') count++;
            rep(k, count) row[i][j+k] = count;
            j += count;
            while(m[i][j] == '#') j++;
        }
    }

    rep(i, W){
        int j=0;
        while(m[j][i] == '#') j++;
        while(j < H){
            int count = 0;
            while(m[j+count][i] == '.') count++;
            rep(k, count) col[j+k][i] = count;
            j += count;
            while(m[j][i] == '#') j++;
        }
    }

    rep(i, H){
        rep(j, W){
            max_value = max(max_value, row[i][j]+col[i][j]-1);
        }
    }
    cout << max_value;

}

Measured memory_bytes: 35456
#include<stdio.h>
#include<stdlib.h>
#define MAX 2000001
#define VMAX 10000
main(){
  unsigned short *D, *E;
  int T[VMAX+1];
  int n, i, j;
  scanf("%d", &n);
  D = malloc(sizeof(short)*n+1);
  E = malloc(sizeof(short)*n+1);
  for ( i=0;i<=VMAX;i++) T[i]=0;
  for ( i=0;i<n;i++){
    scanf("%d", &D[i+1]);
    T[D[i+1]]++;
  }
  for ( i=1; i<= VMAX; i++ ) T[i] = T[i] + T[i-1];
  for ( j=1; j <= n;j++ ){
    E[T[D[j]]] = D[j];
    T[D[j]]--;
  }
  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", E[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 9576
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <cstdlib>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
 
using namespace std;

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

    int m,u;

    for(int i = 0; i < 4; i++){
        m = (S[0]-48)*10 + S[1]-48;
        u = (S[2]-48)*10 + S[3]-48;
    }

    if(m > 0 && m <= 12 && u > 0 && u <= 12){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }

    if((m == 0 || m > 12) && u > 0 && u <= 12){
        cout << "YYMM" << endl;
        return 0;
    }

    if((u == 0 || u > 12) && m > 0 && m <= 12){
        cout << "MMYY" << endl;
        return 0;
    }

    cout << "NA" << endl;

    return 0;
}

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

int main(){
  int N, X, sum = 0;
  cin >> N >> X;
  vector<int> vec(N);
  for ( int i = 0; i < N ; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  int ans = N;
  for ( int i = 0; i < N; i++){
    int p = N + (( X - sum ) / vec.at(i));
    if ( ans < p) ans = p; 
    }

   cout << ans << endl;
      
  
}

Measured memory_bytes: 256
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   main.cpp                                           :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: monoue <marvin@student.42.fr>              +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/22 12:30:15 by monoue            #+#    #+#             */
/*   Updated: 2020/05/04 10:12:32 by monoue           ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include <bits/stdc++.h>

/* #include <boost/multi_array.hpp> */
/* #include <boost/optional.hpp> */
/* #include <boost/range/irange.hpp> */
/* #include <boost/range/algorithm.hpp> */
/* #include <boost/range/adaptors.hpp> */
/* #include <boost/multiprecision/cpp_int.hpp> */
/* #include <boost/algorithm/string/classification.hpp> // is_any_of */
/* #include <boost/algorithm/string/split.hpp> */
/* #include <boost/algorithm/string/join.hpp> */
/* #include <boost/algorithm/string/replace.hpp> */
/* #include <boost/math/tools/minima.hpp> */
/* namespace adaptor = boost::adaptors; */
/* using boost::math::tools::brent_find_minima; */
/* using boost::irange; */
/* using boost::algorithm::join; */
/* using boost::algorithm::split; */
/* using boost::algorithm::replace_all; */
/* using boost::multiprecision::cpp_int; */

using namespace std;

#define	int	long long
#define MOD 1000000007
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

typedef long long 			ll;
typedef vector<int>			VI;
typedef vector<vector<int>>	VVI;
typedef pair<int, int>		PII;

// TOP
void	Main()
{
	bitset<110>	bs;
	int	n, x;
	cin >> n >> x;
	while (!(n == 0 && x == 0))
	{
		int	ans;
		ans = 0;
		rep2(i, 1, n - 1)
		{
			rep2(j, i + 1, n)
			{
				rep2(k, j + 1, n + 1)
				{
					if (i + j + k == x)
						ans++;
				}
			}
		}
		// rep(i, 1 << n)
		// {
		// 	int sum;

		// 	sum = 0;
		// 	// bs = i;
		// 	if (bs.count() != 3)
		// 		continue;
		// 	rep(j, n)
		// 	{
		// 		if (bs.test(j))
		// 			sum += j + 1;
		// 	}
		// 	if (sum == x)
		// 		ans++;
		// }
		cout << ans << endl;
		cin >> n >> x;
	}
}
// END

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



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

int main() {
	// your code goes here
	int a,b;
	cin >> a >> b;
	int count=1;

	while(1)
	{
	    if((count*a-count+1)>=b)
	    break;
	    else
	    count++;
	}
	if(b==1)
	count=0;
	cout << count;
	return 0;
}


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

int main()
{
	int k, n;
	cin >> n >> k;
	vector<int> v;
	while (n--) {
		int x;
		cin >> x;
		v.push_back(x);
	}
	sort(v.begin(), v.end());
	int sum = 0;
	for (int a = 0; a < k; ++a) {
		sum += v[a];
	}
	cout << sum;
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <regex>
#ifdef _DEBUG
#include "debug.h"
#endif
#define int ll
#define float double
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define all(v) (v).begin(),(v).end()
#define mkpr make_pair
#define mktp make_tuple
#define tv(tp, i) get<(i)>(tp)
#define CLEAR(obj) obj = decltype(obj)()
#define var auto
#define OUT(type) type &
#define IN(type) const type &
#define self (*this)
#define in :
#define True true
#define False false
using namespace std; using int32 = int32_t; using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vl = vector<ll>; using vvl = vector<vl>;
using vb = vector<bool>; using vvb = vector<vb>; using vc = vector<char>; using vvc = vector<vc>;
using vf = vector<float>; using vvf = vector<vf>; using vd = vector<double>; using vvd = vector<vd>;
using str = string; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using pff = pair<float, float>; using pdd = pair<double, double>;
using psl = pair<string, ll>; using tiii = tuple<int, int, int>; using tlll = tuple<ll, ll, ll>;
static const int MGN = 10; static const int ARYSZ_MAX = (int)1e7; static const ll LINF = LLONG_MAX/2;
#ifdef int
static const int INF = LINF;
#else
static const int INF = INT_MAX/2;
#endif
static double EPS = 1e-9;
#define FASTCIN() cin.tie(0);ios::sync_with_stdio(false);
#ifdef IMPORT_SAMPLE
#define DEBUG_IMPORT(file) vs args(argv, argv+argc);str sample = make_sample(args, file);ifstream ifs(sample); cin.rdbuf(ifs.rdbuf());
#else
#define DEBUG_IMPORT(file)
#endif
static inline int ord(char c) {return (int)c;}
static inline char chr(int n) {return (char)n;}
static inline bool DBLEQ(double a, double b) {return abs(a - b) < EPS;}
static inline void EPR(str msg) {cerr << msg << endl;}
static inline void AST(bool exp, str msg) {if(!exp){EPR(msg);} assert(exp);}
static inline void TAST(bool exp, str msg) {if(!exp){EPR(msg);} while(!exp){}}


int32 main(int32 argc, char* argv[]) {
    FASTCIN();
    DEBUG_IMPORT("sample-1");


    int S,W; cin>>S>>W;

    str ans = S<=W ? "unsafe" : "safe";
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 3652
x,k,d=map(int, input().split())

if k*d>=abs(x):
    n=abs(x)//d
    if (k-n)%2==0:
        print(abs(x)-n*d)
    else:
        print(min(abs(x)-n*d+d, abs(abs(x)-n*d-d)))
else:
    print(abs(x)-(k*d))

Measured memory_bytes: 61780
A,B=input().split()
a=int(A)
b=int(B)
ans=0
if a<b:
  while b>0:
    b-=1
    ans+=a*(10**b)
elif a==b:
  while b>0:
    b-=1
    ans+=a*(10**b)
else:
  while a>0:
    a-=1
    ans+=b*(10**a)
  
print(ans)

Measured memory_bytes: 3060
import sys
input = sys.stdin.readline

def main():
    N,M,K = map(int,input().split())
    
    for i in range(N+1):
        for j in range(M+1):
            b = N*M-(i*j+(N-i)*(M-j))
            if b == K:
                print("Yes")
                exit()
    
    print("No")
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
x = int(input())
def f():
    for i in range(x, 10**10):
        c = 0
        for j in range(2, i):
            if i%j != 0:
                c += 1
                if c == i-2:
                    return i
            else:
                break
if x == 2:
    print(2)
else:
    print(f())

Measured memory_bytes: 9184
#include<stdio.h>
#include<stdlib.h>
 
int main(){
 
int s;
scanf("%d",&s);
int a[200];
a[0] = s;
 
for (int i = 1; i <= 200; i++)
{
  if (a[i-1]%2==0)
  {
    a[i] = a[i-1]/2;
  }else
  {
    a[i] = a[i-1]*3+1;
  }
  
  if (i%100==0)
  {
    for (int j = i-100; j < i-1; j++)
    {
      for (int k = j+1; k <= j+100; k++)
      {
        if(a[k] == a[j]){
          printf("%d",k+1);
          exit(0);
        }
      }
    }
  }
}
 
return 0;
 
}

Measured memory_bytes: 1716
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

int main() {
	int t, n, m;
	int ima = 0;
	int tori = 0;
	cin >> n >> m >> t;
	int* a = new int[n];
	int kyori = m;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int study = 0;
	study = a[0] - m;
	for (int i = 1; i < n; i++) {
		if (a[i] - a[i - 1] > 2 * m) {
			study += a[i] - a[i - 1] - 2 * m;
		}
	}
	if (t - a[n - 1] > m) {
		study += t - a[n - 1] - m;
	}
	//study += t - a[n - 1] - m;
	cout << study << endl;
}
		/*
	ima = 0;
	kyori = m;
	tori = 0;
	int time = 0;
	for (int i = 0; i < t; i++) {
		if (kyori == m) {
			if (kyori == (a[ima] - i)) {
				kyori--;
			}
			time++;
		}
		else {
			if (kyori == (a[ima] - i)) {
				kyori--;
			}
			else {
				kyori++;
			}
		}
	}
	cout << time << endl;
}*/


/*#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>

using namespace std;

int main() {
	int n;
	cin >> n;
	int y, m, d;
	int zzz;
	map<string, int> mapper;
	for (int count = 0; count < n; count++) {
		cin >> y >> m >> d;
		y--;
		m--;
		d;
		zzz = 0;
		zzz+= 195 * y + (y / 3) * 5;
		if ((y+1) % 3 == 0) {
			zzz += 20 * m;
		} else {
			zzz += 20 * m - (m / 2);
		}
		zzz += d;
		cout << 196471 - zzz << endl;
	}
}*/


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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n;
string s[1000006];
vii neg,pos;
void solve(){
	cin>>n;
	string w;
	rep(i,0,n){
		cin>>s[i];
		int cur=0,res=hell;
		for(auto j:s[i]){
			if(j=='(') cur++;
			else cur--;
			res=min(res,cur);
		}
		if(res<0){
			if(cur>0) pos.pb({res,i});
			else neg.pb({res-cur,i});
		}
		else w+=s[i];
	}
	sort(all(pos));
	reverse(all(pos));
	sort(all(neg));
	for(auto i:pos) w+=s[i.y];
	for(auto i:neg) w+=s[i.y];
	int cur=0;
	for(auto i:w){
		if(i=='(') cur++;
		else cur--;
		if(cur<0){
			cout<<"No"<<endl;
			return;
		}
	}
	if(cur) cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
// cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Measured memory_bytes: 41324
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100000];
int b[100000];

int ans=0;
int main(){
    cin>>n;
    b[0]=1e8;
    for(int i=1;i<n;i++){
    	cin>>b[i];
	}
	for(int i=1;i<n;i++){
		
		ans+=min(b[i],b[i-1]);
	}
	cout<<ans+b[n-1];
    return 0;
    
}

Measured memory_bytes: 256
n, k = map(int, input().split())
p = list(map(int, input().split()))

ans = sum(p[:k])

psum = [0] * n
psum[0] = p[0]
for i in range(1, n):
  psum[i] = psum[i-1] + p[i]

anss = [0] * n
for i in range(n-k):
  anss[i] = psum[i+k] - psum[i]

print((max(ans, max(anss))+k)/2)

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

int main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N, M;
  string S;
  cin >> N >> M >> S;
  reverse(S.begin(), S.end());
  vector<int> ans;
  int pos = 0;
  while (pos != N)
  {
    for (int j = M; j >= 0; --j)
    {
      if (j == 0)
      {
        cout << -1;
        return 0;
      }
      if (pos + j <= N && S[pos + j] == '0')
      {
        pos += j;
        ans.push_back(j);
        break;
      }
    }
  }
  for (int i = ans.size() - 1; i >= 0; --i)
    cout << ans[i] << " \n"[i == 0];
  return 0;
}

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

#define INF INT_MAX
#define UINF UINT_MAX
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef std::pair<int,int> pii;

using namespace std;

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

    ll h,w,n;
    cin >> h >> w >> n;

    ll max = h > w ? h : w;

    int ans = 0;
    for(int i = 0;i < n;i+=max){
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

N = INT()
A = [input() for i in range(N)]

C = Counter(A)
mx = max(C.values())
ans = []
for k, v in C.items():
    if v == mx:
        ans.append(k)
ans.sort()
[print(s) for s in ans]


Measured memory_bytes: 35552
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <cmath>
#include <functional>
#include <queue>
#include <map>
using namespace std;

typedef long long ll;
const int M = 1e9 + 7;
const int N = 2e4 + 100;
const int MAX = 1e9 + 1;
//int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};

int main() {
    int i, j;
    int n;
    cin >> n;
    int p[N];
    for (i = 1; i <= n; ++i) {
        int t;
        cin >> t;
        p[t] = i;
    }
    for (i = 1; i <= n; ++i) {
        cout << 30000 * i << ' ';
    }
    cout << endl;
    for (i = 1; i <= n; ++i) {
        cout << 30000 * (n - i) + p[i] << ' ';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin>>n;
	string s;
	cin>>s;
	map<char, vector<int> > v;
	for(char c = 'a'; c <= 'z'; ++c){
		for(int i = 0; i < n; ++i){
			if(s[i] == c){
				v[c].push_back(i);
			}
		}
	}
	int res = 0;
	for(auto x : v){
		vector<int> vec = x.second;
		int r = 0;
		if(vec.size() != 0){
			r = 1;
		}
		for(int i = 0; i < vec.size() - 1; ++i){
			if(vec[i] == vec[i + 1] - 1)continue;
			else r++;
		}
		res += r;
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1656
# coding: utf-8
import sys
input = sys.stdin.readline

mod = int(1e9 + 7)

def f(N, K, A):
    m = [[0] * N for _ in range(N)]
    for i in range(N):
        m[i][i] = 1
    k = K
    a = A

    def mulmod(a, b):
        m = [[0] * N for _ in range(N)]
        for i, r, in enumerate(a):
            for j, c in enumerate(zip(*b)):
                m[i][j] = sum(x * y for x, y in zip(r, c)) % mod
        return(m)

    while k > 0:
        if k & 1:
            m = mulmod(m, a)
        a = mulmod(a, a)
        k >>= 1

    return(sum(sum(x) for x in m) % mod)

N, K = map(int, input().split()) # 1 <= N <= 50, 1 <= K <= 10^18
a = [list(map(int, input().split())) for _ in range(N)]

print(f(N, K, a))


Measured memory_bytes: 3316
// B - Shiritori
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int main(){
	int N; cin>>N;
	vector<string> W(N);
	rpz(now, N){
		cin>>W[now];
		rpz(pre, now){
			if(W[now] == W[pre]){
				puts("No");
				return 0;
			}
		}
	}
	rpz(now, N-1){
		if(W[now].back() != W[now+1].front()){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
}

Measured memory_bytes: 256
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    for t in range(int(input())):
        N = int(input())
        A = list(map(int, input().split()))
        S = input().rstrip('\n')
        A.reverse()
        S = S[::-1]

        A0 = [0] * 60
        A1 = [0] * 60
        zero = 0
        one = 0
        for i, a in enumerate(A):
            if S[i] == "0":
                for j in range(60):
                    A0[j] ^= ((a >> j & 1) << zero)
                zero += 1
            else:
                for j in range(60):
                    A1[j] ^= ((a >> j & 1) << one)
                one += 1

        B = [0] * 60
        for i in range(60):
            B[i] = A0[i] + (A1[i] << zero)

        rnk = 0
        for i in range(zero):
            #print(B)
            for j in range(rnk, 60):
                if B[j] >> i & 1:
                    B[j], B[rnk] = B[rnk], B[j]
                    b = B[rnk]
                    #print(b)
                    for jj in range(60):
                        if jj == rnk:
                            continue
                        if B[jj] >> i & 1:
                            B[jj] ^= b
                    rnk += 1
                    break

        cnt0 = 0
        cnt1 = zero
        r = -1
        win = 0
        for s in S:
            if s == "0":
                if r+1 >= len(B):
                    break
                if B[r+1] >> cnt0 & 1:
                    r += 1
                cnt0 += 1
            else:
                rr = -1
                for j in range(60):
                    if B[j] >> cnt1 & 1:
                        rr = j
                if rr > r:
                    win = 1
                    break
                cnt1 += 1
        print(win)


if __name__ == '__main__':
    main()


Measured memory_bytes: 70532
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;
const int INF = 1e9;
const ll INFll = 1e18;
#define put(n) cout<<(n)<<endl
#define Cout(n) cout<<(n)
#define rep(i,num,N) for(int(i)=(num);(i)<(N);++(i))
#define rrep(i,num,N) for(int (i)=(num);(i)>(N);--(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define MP make_pair
#define pb(q) push_back(q)
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};


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

    string ans = "";

    while(N){
        int mod = N%2;
        if(mod < 0) mod += 2;
        N = (N-mod)/-2;
        ans += to_string(mod);
    }

    reverse(all(ans));
    if(ans.empty()) ans = "0"; 

    put(ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#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)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001; // > 10^9
const int MOD = (int)1e9 + 7;
const ll INFLL = 1001001001001001001;  // > 10^18
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

    vector<int> sw;
    sw.push_back(1);
    sw.push_back(-1);

    vector<int> instance;
    bool flag = false;
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < 2; j++) {
            
            vector<int> t(n, 0);
            t[0] = sw[i];
            t[1] = sw[j];
            
            for (int k = 1; k < n-1; k++) {
                if (s[k] == 'o') {
                    t[k+1] = t[k]*t[k-1];
                } else {
                    t[k+1] = (-t[k])*t[k-1];
                } 
            }
            if (s[n-1] == 'o' && t[0] == t[n-1]*t[n-2]) {
                if (s[0] == 'o' && t[1] == t[0]*t[n-1]) {
                    flag = true;
                    instance = t;
                } 
                if (s[0] == 'x' && t[1] == (-t[0])*t[n-1]) {
                    flag = true;
                    instance = t;
                }
            } 
            if (s[n-1] == 'x' && t[0] == (-t[n-1])*t[n-2]) {
                if (s[0] == 'o' && t[1] == t[0]*t[n-1]) {
                    flag = true;
                    instance = t;
                } 
                if (s[0] == 'x' && t[1] == (-t[0])*t[n-1]) {
                    flag = true;
                    instance = t;
                }
            } 
        }
    }

    if (flag) {
        for (int i = 0; i < n; i++) {
            if (instance[i] == 1) {
                cout << "S";
            } else {
                cout << "W";
            } 
        }
        cout << endl;
    } else {
        cout << -1 << endl;
    } 
    
    return 0;
}



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

using ll = long long;

int main() {
    int N;
    cin >> N;
    rep(i, N + 1) {
        int a = i * 1.08;
        if (a == N) {
            cout << i << endl;
            return 0;
        }
    }
    cout << ":(" << endl;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
typedef long long ll;

int main() {
	ll n;
	cin >> n;
	double d = log(n) / log(3.0);
	cout << ceil(d) << endl;
	return 0;
}

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

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S[2] == S[3] && S[4] == S[5])
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  string s, t ;
  cin >> s >> t ;
  t = t+t ;

  if (t.find(s) != string::npos)
    cout <<"Yes" << endl ;
  else cout <<"No" << endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};


int main(){
    CIN(N);
    I vec;
    REP(a,N*2){
        CIN(b);
        vec.push_back(b);
    }
    sort(ALL(vec));
    int ans = 0;
    for(int a = 0;a < 2 * N;a+=2){
        ans+=vec.at(a);
    }
    COUT(ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {

    int n;
    std::cin >> n;

    int count = 0;

    for (int i=1; i<=n; ++i) {
        int t;
        std::cin >> t;
        if (i % 2 == 1 && t % 2 == 1) count++;
    }

    std::cout << count << std::endl;

    return 0;

}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;
const long long MOD=1e09+7;



#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,m,n) for(int i=m;i<n;i++)
#define vi vector<int>

int main(){


  ll n,k;
  cin>>n>>k;
  vi data(n);
  rep(i,n){
    ll tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }
  
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  
  ll answer=0;
  
  if (n<=k){
    answer=0;
  }
  else {
    for (ll i=k;i<n;i++){
      answer+=data.at(i);
    }
  }
  
  cout<<answer<<endl;
  
  
  
}



Measured memory_bytes: 1024
#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 rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp fixed << setprecision
#define pb(x) push_back(x)
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e9;
const ll INF = 1e18;
const ld EPS = 1e-10;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

const int MAX_N = 1e5;
vector<int> es[MAX_N];
bool used[MAX_N];
int par[MAX_N];
stack<int> s;

void dfs(int now){
    used[now] = true;
    s.push(now);
    for(auto &e: es[now]){
        if(used[e]) continue;
        par[e] = now;
        dfs(e);
    }
}

int main(){
    int N;
    cin >> N;
    rep(i, N-1){
        int u, v;
        cin >> u >> v;
        u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    fill(used, used+N, false);
    par[0] = -1;
    dfs(0);
    fill(used, used+N, false);
    bool able = true;
    //rep(i, N) cout << par[i] << endl;
    while(!s.empty()){
        int i = s.top();
        s.pop();
        if(used[i]) continue;
        used[i] = true;
        int j = par[i];
        if(j == -1 || used[j]){
            able = false;
            break;
        }
        used[j] = true;
    }
    if(able) cout << "Second" << endl;
    else cout << "First" << endl;
}

Measured memory_bytes: 6784
#include<stdio.h>
int main(void)
{
	int k,n,i;
	char s[100];
	scanf("%d", &k);
	scanf("%s", &s);
	scanf("%d", &n);
	for (i = 0; i < k; i++){
		if (s[n-1] != s[i])
			s[i] = '*';
	}
	printf("%s\n",s);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int n,m,a[100001],d[100001],t;

int main(){
  scanf("%d%d",&n,&m);
  for(int i=0;i<m;i++){
    scanf("%d",&t);
    a[t]=1;
  }
  if(a[0]){
    putchar('0');
    return 0;
  }
  d[0]=1;
  if(!a[1])d[1]=1;
  for(int i=2;i<=n;i++)if(!a[i])d[i]=(d[i-1]+d[i-2])%1000000007;
  printf("%d",d[n]);
  return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
using namespace std;
int main(void){
  long n,s=0,d;
  cin>>n;
  d=n;
  for(int i=9;i>=0;i--){
    s+=n/pow(10,i);
    n%=(int)pow(10,i);
  }
  if(d%s==0)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define min(p,q)((p)<(q)?(p):(q))

int a[100010];
int main(){
	int n,q;
	scanf("%d%d",&n,&q);
	for(int i=0;i<n;i++)scanf("%d",a+i);
	while(q--){
		long s;
		scanf("%ld",&s);
		long ans=0;
		int r=0;
		long sum=0;
		for(int l=0;l<n;l++){
			while(r<n&&sum<=s)sum+=a[r++];
			ans+=r-l-(sum>s);
			sum-=a[l];
		}
		printf("%ld\n",ans);
	}
}



Measured memory_bytes: 2112
#include <stdio.h>
 
int main() {
    
	int x=0, y= 0, z= 1;
	scanf("%d\n%d", &x, &y);
	for (int i = 0; i < x; i++) {
		if (2 * z <= z + y) {
			z *= 2;
		} else {
			z += y;
		}
	}

	printf("%d\n", z);
    return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    if (n <= 2) cout << 0 << endl;
    else if (n % 2 == 0) cout << (n - 2) / 2 << endl;
    else cout << (n - 1) / 2 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, l;
	cin >> n >> l;
	vector<int> a(n);
	for (auto &it : a) {
		cin >> it;
	}	
	int id = -1;
	for (int i = 0; i + 1 < n; i++) {
		if (a[i] + a[i + 1] >= l) {
			id = i;
			break;
		}
	}
	if (id == -1) {
		cout << "Impossible\n";
	}
	else {
		cout << "Possible\n";
		for (int i = 0; i < id; i++) {
			cout << i + 1 << '\n';
		}
		for (int i = n - 2; i >= id + 1; i--) {
			cout << i + 1 << '\n';
		}
		cout << id + 1 << '\n';
	}
}	

Measured memory_bytes: 1664
import java.util.*;

public class Main{

    public static void main(String args[]){

        //配列の宣言
        int[] number = new int[5];
        // スキャナーの宣言
        Scanner sc = new Scanner(System.in);
        // 整数の入力
		int n = sc.nextInt();
        // スペース区切りの整数の入力
        int k = sc.nextInt();
        String s = sc.next();
        String s2 = s.substring(0, k-1) + s.substring(k-1, k).toLowerCase() + s.substring(k, n);

        // 出力
        System.out.println(s2);

    }

}


Measured memory_bytes: 21844
#include<stdio.h>
#include<algorithm>
using namespace std;
int e[1100];
int main(){
	int a;scanf("%d",&a);
	int b,c;scanf("%d%d",&b,&c);
	int d;scanf("%d",&d);
	for(int i=0;i<a;i++){
		scanf("%d",e+i);
	}
	std::sort(e,e+a);
	int ret=d/b;
	int now=d;
	int cost=b;
	for(int i=a-1;i>=0;i--){
		now+=e[i];
		cost+=c;
		ret=max(ret,now/cost);
	}
	printf("%d\n",ret);
}

Measured memory_bytes: 1040
import java.util.*;
public class Main{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  Map<Integer,Boolean>map=new HashMap<>();
  for(int i=0;i<n;i++){
  int a=sc.nextInt();
    if(map.containsKey(a)){map.put(a,!map.get(a));}else map.put(a,true); 
  }
  int ans=0;
  for(Integer key:map.keySet())ans+=map.get(key)?1:0;
  System.out.println(ans);
}
}

Measured memory_bytes: 62784
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int f[205];
int main(){
        int n,l;
        while(~getII(n,l)){
                FE(i,1,n) f[i]=l+i-1;
                int tot=0,ans,minDiff=INF;
                FE(i,1,n) tot+=f[i];
                FE(i,1,n){
                        int sum=0;
                        FE(j,1,n) if(i!=j) sum+=f[j];
                        if(abs(tot-sum)<minDiff){
                                minDiff=abs(tot-sum);
                                ans=sum;
                        }
                }
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
using namespace std;

int main()
{
    map <char, int> mp;
    string s;
    cin >> s;

    for(int i = 0; i < s.length(); i ++)
    {
    	mp[s[i]] ++;
    }

    int flag = 0;
    for(auto it = mp.begin(); it != mp.end(); it ++)
    {
    	if(it -> second % 2 == 1)
    	{
    		flag = 1;
    		break;
    	}
    }

    if(flag == 1)
    	cout << "No" << endl;
    else
    	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)

char s[100010],t[100010];
int ss[100010],tt[100010];
int main(){
	scanf("%s%s",s,t);
	int sn=strlen(s),tn=strlen(t);
	//s[i]=[0,i)の和(sのindexは0-based)
	rep(i,0,sn)ss[i+1]=ss[i]+(s[i]=='A'?2:1);
	rep(i,0,tn)tt[i+1]=tt[i]+(t[i]=='A'?2:1);
	
	int q;
	scanf("%d",&q);
	while(q--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		a--;b--;c--;d--;
		if((ss[b+1]-ss[a])%3==(tt[d+1]-tt[c])%3)puts("YES");
		else puts("NO");
	}
	return 0;
}

Measured memory_bytes: 1536
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <algorithm>
#include <queue>
#include <iterator>
#include <functional>
#include <numeric>
#include <cmath>
#include <stack>
#include <limits>
#include <ctime>

using namespace std;

#define ll long long
#define sc(n) static_cast<ll>(n)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {
	IO;
#ifdef _DEBUG
	ifstream cin("In.txt");
#endif	
	ll n,t;
	cin >> n;
	t = (n + 1) >> 1;
	cout << t << endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <string.h>

using namespace std;

int main(){
  char S[11];
  char T[11];
  int cnt = 0;
  cin >> S >> T;
  
  for(int i = 0;i<strlen(S);i++){
    if(S[i] == T[i]){
      cnt++;
    }
  }
  
  if(cnt == strlen(S))
    cout << "Yes";
  else
    cout << "No";
  }

Measured memory_bytes: 3640
x,y=map(int,input().split())
A=[1,3,5,7,8,10,12]
B=[4,6,9,11]
C=[2]
if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std; 
typedef long long int ll;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin >> n;
    long long arr[n + 1];
    ll count = 1;
    for(ll i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    ll mini = arr[0];
    for(ll i = 1; i < n; i++)
    {
        if(arr[i] < mini)
        {
            count++;
            mini = arr[i];
        }
    }
    cout << count << endl;


    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
long long a,b,x;
int main()
{
	scanf("%lld",&x);
	for(a=-1000;a<=1000;++a)
	  for(b=-1000;b<=1000;++b)
	    if(a*a*a*a*a-b*b*b*b*b==x)
	      {
	      	printf("%lld %lld",a,b);
			return 0; 
		  }
}

Measured memory_bytes: 1724
n = int(input())

def main():
    a = 0
    for i in range(1,n+1):
        c = 0
        if i %2 != 0:
            for j in range(1,i+1):
                if i % j == 0:
                    c += 1
            if c == 8:
                a += 1
                
    return a

if __name__ == '__main__':
    print(main())



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

int main(){
	int n;
	cin >> n;
	vector<ll> a(n), b(n);
	rep(i, n) cin >> a[i] >> b[i];
	
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if(n % 2 == 1){
		cout << b[n / 2] - a[n / 2] + 1 << endl;
	}
	else{
		cout << (b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1]) + 1 << endl;
	}
	return 0;
}



Measured memory_bytes: 6420
#include <iostream>
#include <set>
#include <algorithm>
#include <utility>
#define INF (1e+9)
#define debug(x) cerr << #x << ": " << x << "\n";
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX_N = (int)2e5;

template <size_t N>
class unionFindTree{
	private:
		int par[N];
		int rank[N];
		int united[N];
	public:
		unionFindTree(){
			for(int i = 0; i < (int) N; i++){
				par[i] = i; rank[i] = 0; united[i] = 1;
			}
		}
		void init(){
			for(int i = 0; i < (int) N; i++){
				par[i] = i; rank[i] = 0; united[i] = 1;
			}
		}
		int find(int x){
			if(par[x] == x) return x;
			else return par[x] = find(par[x]);
		}
		void unite(int x, int y){
			x = find(x); y = find(y);
			if(x == y) return;

			if(rank[x] < rank[y]){
				par[x] = y;
				united[y] += united[x];
			}else{
				par[y] = x;
				united[x] += united[y];
				if(rank[x] == rank[y]) rank[x]++;
			}
		}
		bool same(int x, int y){
			return find(x) == find(y);
		}
		int count(int x){
			return united[find(x)];
		}
};


int main(void){
	unionFindTree<MAX_N> uf1, uf2;
	int N, K, L; cin >> N >> K >> L;

	for(int i = 0; i < K; i++){
		int p, q; cin >> p >> q;
		uf1.unite(--p, --q);
	}
	for(int i = 0; i < L; i++){
		int p, q; cin >> p >> q;
		uf2.unite(--p, --q);
	}

	multiset<P> st;
	P ls[N];
	for(int i = 0; i < N; i++) ls[i] = make_pair(uf1.find(i), uf2.find(i));
	// for(int i = 0; i < N; i++) st.insert(ls[i]);
	// for(int i = 0; i < N-1; i++) cout << st.count(ls[i]) << ' ';
	// cout << st.count(ls[N-1]) << '\n';

	sort(ls, ls+N);
	for(int i = 0; i < N-1; i++){
		cout << upper_bound(ls, ls+N, make_pair(uf1.find(i), uf2.find(i))) - lower_bound(ls, ls+N, make_pair(uf1.find(i), uf2.find(i))) << ' ';
	}
	int i = N-1;
	cout << upper_bound(ls, ls+N, make_pair(uf1.find(i), uf2.find(i))) - lower_bound(ls, ls+N, make_pair(uf1.find(i), uf2.find(i))) << '\n';


	return 0;
}


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

int main(){
  int N, K; cin >> N >> K;
  vector<int> a(N);
  vector<int> cnt;
  
  for(int i = 0; i < N; i++){
    cin >> a[i];
  }
  
  sort(a.begin(), a.end());
  
  int con = 1;
  for(int i = 1; i < N; i++){
    if(a[i] != a[i-1]) {
      cnt.push_back(con);
      con = 1;
    }
    else con++;
  }
  cnt.push_back(con);
  
  sort(cnt.begin(), cnt.end());
  
  int ans = 0;
  int ki = cnt.size();
  int now = 0;
  while(ki > K){
    ans += cnt[now];
    now++;
    ki--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 2168
def bubble(A):
    flag = True
    n = len(A)
    i = 0
    while flag:
        flag = False
        for j in range(n-1,i,-1):
            if A[j][1] < A[j-1][1]:
                A[j],A[j-1] = A[j-1],A[j]
                flag = True
        i += 1


def selection(A):
    n =len(A)
    for i in range(n):
        minj = i
        for j in range(i,n):
            if A[j][1] < A[minj][1]:
                minj = j
        A[i],A[minj] = A[minj],A[i]

n = int(input())
ss = [x for x in input().split()]
ss2 = ss.copy()

bubble(ss)
for i in range(len(ss)-1):
    print(ss[i],end=" ")
print(ss[-1])
print('Stable')

selection(ss2)
for i in range(len(ss2)-1):
    print(ss2[i],end=" ")
print(ss2[-1])
if ss == ss2:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5620
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
 
using namespace std;

long long int a[3];

int main(){
  cin>>a[0]>>a[1]>>a[2];
  
  cout<<a[2] << " " << a[0] << " " << a[1];
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdarg>
#include <cstdlib>
using namespace std;

int main(){
    int H, A;
    cin >> H >> A;
    cout << (H - 1) / A + 1 << endl;
    return 0;
}

Measured memory_bytes: 256