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

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int W = sc.nextInt();
        int[] v = new int[N+1];
        int[] w = new int[N+1];
        for (int i = 1; i <= N; i++) {
            v[i] = sc.nextInt(); w[i] = sc.nextInt();
        }
        int[][] dp = new int[N+1][W+1];
        for (int i = 1; i <= N; i++) {
            for (int j = 1; j <= W; j++) {
                dp[i][j] = dp[i-1][j];
                if(j < w[i])continue;
                if(dp[i][j] < dp[i-1][j-w[i]] + v[i]) dp[i][j] = dp[i-1][j-w[i]] + v[i];
                if(dp[i][j] < dp[i][j-w[i]] + v[i]) dp[i][j] = dp[i][j-w[i]] + v[i];
            }
        }
        System.out.println(dp[N][W]);
        sc.close();

    }

}



Measured memory_bytes: 31236
L,R=map(int,(input().split()))
LL=L
RR=R
L=L%2019
R=R%2019

l=min(L,R)
r=max(L,R)
x=[]
for i in range(l,(r+1)) :
    for j in range(i+1,r+1):
        x.append((i*j)%2019)
if L==0 or R==0:
    print(0)
elif RR-LL>=2019:
    print(0)
else:
    print(min(x))


Measured memory_bytes: 75412
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define FOR(i,n) for(int i=0;i<n;i++)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
#define all(s) s.begin(),s.end()

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,c,d;
    cin>>n;
    vector<int>a(n);
    rep(i,0,n){
        cin>>a[i];
    }
    sort(all(a));
    c=a[n-1];
    d=a[0];
    int mini=a[n-1];
    rep(i,0,n-1){
        if(abs(2*a[i]-c)<mini){d=a[i];mini=abs(2*a[i]-c);}
    }
    cout<<c<<' '<<d<<endl;
}

Measured memory_bytes: 1024
'''
Created on 2020/09/03

@author: harurun
'''
def main():
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  N=int(pin())
  A=1
  B=N-A
  m=10**9
  for i in range(N-1):
    f=0
    for j in str(A):
      f+=int(j)
    for k in str(B):
      f+=int(k)
    m=min(m,f)
    A+=1
    B-=1
  print(m)
  return 
main()

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


using namespace std;
typedef long long int ll;

int main()
{
    int N,K;
    while(cin>>N>>K){
        ll ans = 0;
        for(int i = 0 ; i < N ; i++){
            int x;
            cin>>x;
            ans += min(x*2 , 2*(K-x));
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int W;
    int H;
    int x;
    int y;
    int r;
    
    cin >> W >> H >> x >> y >> r;
    
    if (x + r <= W) {
        
        if (x - r >= 0) {
            
            if (y + r <= H) {
                
                if (y - r >= 0) {
                    
                    cout << "Yes" << endl;
                    
                } else {
                    
                    cout << "No" << endl;
                    
                }
                
            } else {
                
                cout << "No" << endl;
                
            }
            
        } else {
            
            cout << "No" << endl;
            
        }
        
    } else {
        
        cout << "No" << endl;
        
    }
    
}


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

vector<P>E[20], G[20];
bool used[20];

void C(int u) {
	used[u] = true;
	for (P v : E[u]) {
		if (0 < E[v.second].size() && !used[v.second]) {
			G[u].push_back(v); C(v.second);
		}
	}
}
int dfs(int u) {
	int sum = 0;
	for (P v : G[u]) {
		if (0 < G[v.second].size())
			sum += dfs(v.second) + v.first * 2;
	}
	return sum;
}
int dfs2(int u) {
	int Max = 0;
	for (P v : G[u]) {
		if (0 < G[v.second].size())
			Max = max(Max, dfs2(v.second) + v.first);
	}
	return Max;
}
int main() {
	int n;
	while (scanf("%d", &n), n) {
		rep(i, n) {
			E[i].clear();
			G[i].clear();
		}
		rep(i, n - 1) {
			int a, b, t; scanf("%d%d%d", &a, &b, &t); a--; b--;
			E[a].push_back(P(t, b)); E[b].push_back(P(t, a));
		}
		memset(used, 0, sizeof(used)); C(0);
		printf("%d\n", dfs(0) - dfs2(0));
	}
}

Measured memory_bytes: 3208
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn=1e5+10;
const ll mod=20180623;
int main(){
    string s;
    cin>>s;
    int res=0,cnt=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='R'){
            cnt++;
            res=max(cnt,res);
        }else{
            cnt=0;
        }
    }
    cout<<res;
    return 0;
}


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

using namespace std;

typedef long long ll;

int cmp(int a, int b)
{
    return a <= b;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, z, w;
    int tmp, size = 0;
    cin >> n >> z >> w;
    vector<int> v(n);
    for (auto &i : v)
        cin >> i;

    int s = v.size();
    if (s == 1)
        cout << abs(v[0] - w) << endl;
    else
        cout << max(abs(v[s - 1] - w), abs(v[s - 1] - v[s - 2])) << endl;

    return 0;
}

Measured memory_bytes: 256
//package javaapplication2;
import java.util.*;
import java.io.*;
import static java.lang.System.out;

public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println(solve(br.readLine()));
    }
    
    private static String solve(String s){
        if(s.equals("AAA") || s.equals("BBB")) return "No";
        return "Yes";
    }
}


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

int main() {
  int a, b;
  int n;
    
  while( cin >> a >> b >> n )  {
    int s = 0;
    for( int i = 0; i < n; i ++ ) {
      a = a % b * 10;
      s += a / b;
    }

    cout << s << endl;
  }
  
  return 0;
}

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

int main()
{
    ll n, k;
    string str;
    cin >> n >> k >> str;
    vector<ll> ary;
#if 1
    int now = 1; //今見ている数
    int cnt = 0; //nowがいくつ並んでいるか
    for (int i = 0; i < n; i++)
    {
        if (str[i] == (char)('0' + now)) cnt++;
        else {
            ary.push_back(cnt);
            now = 1 - now; //0と1を切り替える時の計算 now ^= 1;
            cnt = 1; //新しいのをカウントし始める
        }
    }
    if (cnt != 0) ary.push_back(cnt);

    //1-0-1-0-1-0-1って感じの配列が欲しい
    //1-0-1-0みたいに0で終わってたら、適当に１つ足す
    if (ary.size() % 2 == 0) ary.push_back(0);
    if (str[0] == '0') {
        ary.push_back(0);
    }
#else
    char prev = 0;
    for (ll i = 0; (i < n); i++) {
        char curr = str[i];
        if (prev != curr) {
            prev = curr;
            ary.push_back(1);
        } else {
            ary[ary.size()-1]++;
        }
    }
    if (str[n-1] == '0') ary.push_back(0);
#endif

#if 0
        vector<int> sum(ary.size() + 1);
        for (int i = 0; i < ary.size(); i++)
        {
                sum[i + 1] = sum[i] + ary[i];
        }
#else
    vector<ll> sum(ary.size()+1, 0);
    for (ll i = 0; (i < ary.size()); ++i) {
        sum[i+1] = sum[i] + ary[i];
    }
#endif

#if 1
        int Add = 2 * k + 1;
        int maxv = 0;
        //1-0-1...の1から始めるので、偶数番目だけ見る
        for (int i = 0; i < ary.size(); i += 2)
        {
                //次のleft, rightを計算する [left, right)
                int left = i;
                int right = min(i + Add, (int)ary.size());
                int tmp = sum[right] - sum[left];

                maxv = max(tmp, maxv);
        }
#else
    ll maxv = 0;
    for(ll i = 1; (i < ary.size()); i+=2) {
        ll left = i - 1;
        ll right = min((ll)(sum.size()-1), i+(k-1)*2+1+1);
        maxv = max(maxv, sum[right] - sum[left]);
    }
#endif
    cout << maxv << endl;
    return 0;
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

string s[20];
int sum[20][1010];

signed main() {

    int h, w, k;
    cin >> h >> w >> k;

    for(int i = 0; i < h; i++)
        cin >> s[i];
    
    for(int i = 0; i < h; i++) {
        for(int j = 0; j < w; j++) {
            sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + (s[i][j] == '1');
        }
    }

    
    int miv = h * w;
    
    for(int bit = 0; bit < (1 << h); bit++) {
        int cnt = 0;
        
        for(int j = 0, pj = 0; j < w; j++) {
            bool f = false;
            for(int i = 0, pi = 0; !f and i < h; pi = ++i) {
                while(i < h - 1 and !((bit>>i)&1)) ++i;

                if(sum[i+1][j+1] + sum[pi][pj] - sum[i+1][pj] - sum[pi][j+1] > k) {
                    f = true;
                }
            }
            if(f) {
                if(j == pj) {
                    cnt = INF;
                    break;
                }
                cnt++;
                pj = j--;
            }
        }
        chmin(miv, cnt + __builtin_popcount(bit));
    }
    
    cout << miv << endl;
                
  
    return 0;
}



Measured memory_bytes: 384
N, M = map(int, input().split())
a = set([int(input()) for _ in range(M)])
INF = 1000000007

dp = [0] * (N + 1)
dp[0] = 1
if 1 not in a:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, N + 1):
	if i in a:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF

print(dp[N])


Measured memory_bytes: 13216
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;
typedef long long lng;
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define ALL(a) (a).begin(), (a).end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end()) //ATTENTION: <a> must be sorted in advance

lng power(lng b, lng n) {lng sol=1; while(n>0) {if(n&1) {sol=sol*b;} n>>=1; b*= b;} return sol;} //calculate b^n

const int MOD = 1000000007; //10^9+7


/*********** variables ************/
string s;
/**********************************/

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

    int len = int(s.size());
    REP(i, len) {
        if(i%2==0) cout << s[i];
    }
    cout << endl;
}


Measured memory_bytes: 592
N,M=map(int,input().split())
AC=[0]*N
WA=[0]*N
pts=0
pena=0
for i in range(M):
    a,b=map(str,input().split())
    if b=='AC':
        if AC[int(a)-1]==0:
            AC[int(a)-1]=1
            pts+=1
            pena+=WA[int(a)-1]
    else:
        WA[int(a)-1]+=1
print(pts,pena)

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


#define ll long long int

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fast_io std::ios::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)


#define trace(x) cout << '>' << #x << ':' << x << endl;
#define trace2(x,y) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y << endl;
#define trace3(x,y,z) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << endl;
#define trace4(x,y,z,w) cout<< '>' << #x << ':' << x << " | " << #y << ':' << y <<" | " << #z << ':' << z << " | " << #w << ':' << w << endl;

#define REP(i,n) for(ll i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define all(v) (v).begin(),(v).end()
#define print(x) cout<<(x)<<endl;

int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};
int toInt(string s){int r=0;istringstream sin(s);sin>>r; return r;}
///////////////////////////////////////////////////////

const int N = 1e5+5;

int n;
int t[N],x[N],y[N],cx,cy,ct;

int main()
{
	fast_io;
	cout<<fixed;

	cin>>n;
	FOR(i,1,n){
		cin>>t[i]>>x[i]>>y[i];
	}

	cx = cy = ct = 0;

	FOR(i,1,n){
		int dist = abs(cx-x[i])+abs(cy-y[i]);

		// trace3(dist,t[i],ct);

		if(dist<=(t[i]-ct) and (t[i]-ct-dist)%2 == 0){
			ct = t[i];
			cx = x[i];
			cy = y[i];
		}
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}

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


Measured memory_bytes: 1408
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x
    def size(self, x):
        return -self.parents[self.find(x)]
    def same(self, x, y):
        return self.find(x) == self.find(y)
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]
    def group_count(self):
        return len(self.roots())

n,m = map(int, input().split())
ab=[list(map(int,input().split())) for i in range(m)]

uf = UnionFind(n)
for a,b in ab:
    uf.union(a-1,b-1)
print(uf.group_count()-1)

Measured memory_bytes: 90840
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc088_c.txt"); \
  cin.rdbuf(in.rdbuf());
#else
#define INPUT_FILE
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N = 3;
  
  vector<vector<int>> c(N + 1, vector<int>(N + 1, 0));
  rep(i, N) rep(j, N) { cin >> c[i + 1][j + 1]; }

  bool ok = true;
  ok &= (c[1][1] - c[2][1] == c[1][2] - c[2][2] && c[1][2] - c[2][2] == c[1][3] - c[2][3]);
  ok &= (c[2][1] - c[3][1] == c[2][2] - c[3][2] && c[2][2] - c[3][2] == c[2][3] - c[3][3]);
  ok &= (c[1][1] - c[3][1] == c[1][2] - c[3][2] && c[1][2] - c[3][2] == c[1][3] - c[3][3]);

  ok &= (c[1][1] - c[1][2] == c[2][1] - c[2][2] && c[2][1] - c[2][2] == c[3][1] - c[3][2]);
  ok &= (c[1][2] - c[1][3] == c[2][2] - c[2][3] && c[2][2] - c[2][3] == c[3][2] - c[3][3]);
  ok &= (c[1][1] - c[1][3] == c[2][1] - c[2][3] && c[2][1] - c[2][3] == c[3][1] - c[3][3]);

  cout << (ok ? "Yes" : "No") << endl;
}

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

int main(){
  string a;
  int count=0;
  cin>>a;
  for(int i=0;i<3;i++){
    if(a.at(i)=='a'){
      count++;
      break;
    }
  }
  for(int i=0;i<3;i++){
    if(a.at(i)=='b'){
      count++;
      break;
    }
  }
  for(int i=0;i<3;i++){
    if(a.at(i)=='c'){
      count++;
        if(count==3) {
          cout<<"Yes"<<endl;
          return 0;
        }
      break;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
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 K = sc.nextInt();
        
        if( K == 0 ) {
            System.out.println( (long) N * N );
            return;
        }

        long ans = 0;
        for(int b = K+1; b <= N; b++ ) {
            ans += Math.max(N / b * (b-K), 0) + Math.max(N % b - K + 1, 0);
        }
        
        System.out.println(ans);
    }
}


Measured memory_bytes: 36300
package main 

import (
	"fmt"
	"strconv"
	"bufio"
	"os"
	"strings"

)

func int2str(nums []int) []string{
	var tmp []string

	for i:= 0; i<len(nums);i++{
		tmp = append(tmp,strconv.Itoa(nums[i]))
	}
	return tmp
}

func main() {
	var N int
	var nums []int
	var count int
	var tmp []string

	fmt.Scan(&N)

	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()

	tmp = strings.Split(sc.Text()," ")

	for i := 0; i < N ; i++{
		n,_:= strconv.Atoi(tmp[i])
		nums = append(nums,n)
	}

	// Selection Sort

	for i:= 0; i < N-1; i++ {
		minj := i

		for j:= i; j < N; j++ {
			if nums[j] < nums[minj]{
				minj = j
			}
		}

		if i != minj{
			nums[i],nums[minj] = nums[minj],nums[i]
			count++
		}
		

	}


	fmt.Println(strings.Join(int2str(nums)," "))
	fmt.Println(count)


}


Measured memory_bytes: 1232
def main():
    import sys
    from collections import defaultdict
    readline = sys.stdin.readline

    H, W, M = map(int, readline().rstrip().split())
    HB = [0] * H
    WB = [0] * W
    HW = defaultdict(lambda : False)
    for _ in range(M):
        h, w = map(int, readline().rstrip().split())
        h -= 1
        w -= 1
        HW[(h,w)] = True
        HB[h] += 1
        WB[w] += 1
    hb = max(HB)
    max_h = [i for i, x in enumerate(HB) if x == hb]
    wb = max(WB)
    max_w = [i for i, x in enumerate(WB) if x == wb]
    
    ans = hb + wb
    for mh in max_h:
        for mw in max_w:
            if HW[(mh, mw)] == False:
                print(ans)
                sys.exit(0)
    print(ans - 1)

if __name__ == "__main__":
    main()


Measured memory_bytes: 184760
#include <iostream>
#include <cstring>
#include <vector>

using namespace std;

int main(){
    int H,W,N;
    cin >> H >> W >> N;
    vector<vector<int> > grid(H, vector<int>(W));
    int x = 0,y = 0;
    int next_y = 1;
    for(int i=0;i<N;i++){
        int a;
        cin >> a;
        for(int k=0;k<a;k++){
            grid[x][y] = i+1;
            if(y + next_y < 0 || y + next_y > W-1){
                next_y *= -1;
                x++;
            }else{
                y += next_y;
            }
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout << grid[i][j] << " ";
        }
        cout << endl;
    }

    return 0;

}

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

#define ll long long

ll dp[100001];
int main()
{

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

//	freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	
    ll n,k;
    cin>>n>>k;

dp[1]=0;
ll a[n];
     
     for(ll i=1;i<=n;i++)
     	cin>>a[i];


    for(ll i=2;i<=k;i++)
    {
    	dp[i]=INT_MAX;
    	for(ll j=1;j<=i-1;j++)
    	{
    		dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));
    	}
    }

    for(ll i=k+1;i<=n;i++)
    {

        dp[i]=INT_MAX;

        for(ll j=i-k;j<=i-1;j++)
        {

    		dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));

        }

    }
  cout<<dp[n];

}


Measured memory_bytes: 1792
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            //Out.Flush();
            Read();
        }

        static void Solve()
        {
            var s = ReadLine();
            var t = ReadLine();
            if ((s + s).Contains(t))
                WriteLine("Yes");
            else
                WriteLine("No");
        }
 
        static long Mod = 998244353;
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static public (T a, T b) Slice2<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)));
        }
        static public (T a, T b, T c) Slice3<T>()
        {
            var t = ReadLine().Split();
            return (
            (T)Convert.ChangeType(t[0], typeof(T)),
            (T)Convert.ChangeType(t[1], typeof(T)),
            (T)Convert.ChangeType(t[2], typeof(T)));
        }
    }
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;


#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	int a, p;
	cin>>a>>p;
	ll k = a*3 + p;
	cout<<k/2<<endl;
	
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader
import java.util.*
import kotlin.math.abs
import kotlin.math.min

fun main() = abc119d()

@OptIn(ExperimentalStdlibApi::class)
fun abc119d() = SimpleFastIOWithToken_abc119d().exec {
    val n = readInt()
    val (a, b, c) = IntArray(3) { readInt() }
    val bamboos = IntArray(n) { readInt() }

    fun minOf(a: Int, b: Int, c: Int, d: Int) = min(min(a, b), min(c, d))

    fun dfs(index: Int, lengthsA: Int, lengthsB: Int, lengthsC: Int): Int {
        if (index == n) return when {
            minOf(lengthsA, lengthsB, lengthsC) == 0 -> Int.MAX_VALUE / 100
            else -> abs(lengthsA - a) + abs(lengthsB - b) + abs(lengthsC - c) - 30
        }

        return minOf(
            dfs(index + 1, lengthsA, lengthsB, lengthsC),
            dfs(index + 1, lengthsA + bamboos[index], lengthsB, lengthsC) + 10,
            dfs(index + 1, lengthsA, lengthsB + bamboos[index], lengthsC) + 10,
            dfs(index + 1, lengthsA, lengthsB, lengthsC + bamboos[index]) + 10
        )
    }

    val answer = dfs(0, 0, 0, 0)

    println(answer)
}

// region kokokara template dayo (^o^)
@Suppress("unused", "HasPlatformType", "MemberVisibilityCanBePrivate", "ClassName")
private class SimpleFastIOWithToken_abc119d(private val separator: String = System.lineSeparator()) {
    private val br: BufferedReader = System.`in`.bufferedReader()
    private var st: StringTokenizer = StringTokenizer("")
    private val sb: StringBuilder = StringBuilder()
    private fun prepareNext() = run { if (!st.hasMoreTokens()) st = StringTokenizer(br.readLine()) }

    fun readString(): String = run { prepareNext() }.run { st.nextToken() }
    fun readInt(): Int = Integer.valueOf(readString())
    fun readLong(): Long = java.lang.Long.valueOf(readString())

    fun println(): Unit = run { sb.append(separator) }
    fun print(any: Any): Unit = run { sb.append(any) }
    fun println(any: Any): Unit = run { sb.append(any.toString() + separator) }

    fun exec(action: SimpleFastIOWithToken_abc119d.() -> Unit) {
        var t: Throwable? = null
        Thread(null, { action() }, "solve", 128 * 1024 * 1024)
            .apply { setUncaughtExceptionHandler { _, t1 -> t = t1 } }
            .apply { start() }.join()
        t?.let { throw it }
        kotlin.io.print(sb)
    }

    fun readLine(): Nothing = error("readLine is disabled.")
}
// endregion kokomade template dayo (^o^)


Measured memory_bytes: 36804
N = int(input())
A = list(map(int, input().split()))

def get_count(p):
  integers = [1 for _ in range(p+1)]
  integers[0] = 0
  integers[1] = 0
  counts = [0 for _ in range(p+1)]
  for a in A:
    counts[a] += 1
  answer = 0
  for i in range(p+1):
    if integers[i] >= 1:
      count = 0
      for j in range(i,p+1,i):
        count += counts[j]
        integers[j] = 0
      answer = max(answer,count)
  return answer

count = get_count(max(A))
if count == N:
  answer = 'not coprime'
elif count >= 2:
  answer = 'setwise coprime'
else:
  answer = 'pairwise coprime'

print(answer)

Measured memory_bytes: 217448
from math import ceil
n, m = map(int, input().split())
for i in range(n, ceil(m**.5), 1):
    if not m % i:
        print(m//i)
        exit()
for i in range(int(min((m / n), m**.5)), 0, -1):
    if not m % i:
        print(i)
        break

Measured memory_bytes: 3060
S = input()
N = len(S)
x = int(S[0])
c = 0
for i in range(1,N):
  if int(S[i]) == x:
    c +=1
    if x == 0:
      x = 1
    else:
      x = 0
  else:
    x = int(S[i])
print(c)


Measured memory_bytes: 3188
import java.util.*;
import java.io.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		int size=in.nextInt();
		myMaxHeap heap=new myMaxHeap();
		
		for(int i=0;i<size;i++)heap.add(Integer.parseInt(in.next()));
		
		heap.build();
		heap.dump(new PrintWriter(System.out));
	}

}

class myMaxHeap{
	private int size=0,array[]=new int[500001];
	
	myMaxHeap() {
		
	}
	
	
	
	public void add(int v) {
		size++;
		array[size]=v;
	}
	
	public void build() {
		for(int i=size/2;i>=1;i--) {
			tailor(i);
		}
	}
	
	private void tailor(int i) {
		int indexL=i*2,indexR=i*2+1,max=i;
		
		if(indexL<=size && array[indexL] > array[max])max=indexL;
		if(indexR<=size && array[indexR] > array[max])max=indexR;
		
		if(max!=i) {
			//System.out.println("swap "+array[max]+" "+array[i]);
			int tt=array[i];
			array[i]=array[max];
			array[max]=tt;
			
			tailor(max);
		}
	}
	
	public void dump(PrintWriter out) {
		for(int i=1;i<=size;i++)out.print(" "+array[i]);
		out.println();
		out.flush();
	}
	
	
}


Measured memory_bytes: 105968
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#define ll long long
#define mod 998244353
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int main()
{
	int a=read(),b=read();
	writeln(a<b?0:10);
	return 0;
}

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

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

    s += s;

    for (int i = 0; i < s.length() - p.length(); i++) {
        if (s.substr(i, p.length()) == p) return cout << "Yes" << endl, 0;
    }
    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3156
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define ms(s,x) memset(s,x,sizeof(s))
#define ls rt<<1
#define rs rt<<1|1
#define pb push_back
#define inf 0x3f3f3f3f
typedef long long ll;
using namespace std;

const double PI = acos(-1.0);
const double eps = 1e-8;
const int MAXN = 1e5+5;
const ll MOD = 1e9+7;

int main()
{
    double l, vol;
    cin >> l;
    l /= 3;
    vol = l * l * l;
    printf("%.12f\n", vol);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ld double
#define ll long long
#define pb emplace_back
#define mk make_pair
#define mod 1000000007
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define all(x) x.begin(),x.end()
ll power(ll a, ll b) {ll res = 1; a = a % mod; while (b) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b /= 2;} return res;}
ll invmod(ll a) {return power(a, mod - 2);}
int main(void)
{
	FIO
	int t = 1;
	// cin>>t;
	while (t--)
	{
		int n, m;
		cin >> n >> m;
		vector<string> arr(n);
		for (auto &i : arr) cin >> i;
		vector<vector<ll>> dp(n, vector<ll>(m));
		int ls = 1;
		for (int i = 0; i < n; i++) {
			if (arr[i][0] == '#') ls = 0;
			dp[i][0] = ls;
		}
		ls = 1;
		for (int i = 0; i < m; i++) {
			if (arr[0][i] == '#') ls = 0;
			dp[0][i] = ls;
		}
		dp[0][0] = 0;
		for (int i = 1; i < n; i++) {
			for (int j = 1; j < m; j++) {
				dp[i][j] = 0;
				if (arr[i - 1][j] != '#') dp[i][j] = dp[i - 1][j] % mod;
				if (arr[i][j - 1] != '#') dp[i][j] = (dp[i][j] + dp[i][j - 1]) % mod;
			}
		}
		cout << dp[n - 1][m - 1] << "\n";
	}
	return 0;
}

Measured memory_bytes: 12156
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from bisect import bisect_right

N = int(readline())
m = map(int,read().split())
AB = zip(m,m)

graph = [[] for _ in range(N+1)]
for a,b in AB:
    graph[a].append(b)
    graph[b].append(a)

def make_pairs(A,S):
    half = S//2
    A.sort()
    complete = 0
    while A and A[-1] == S:
        A.pop()
        complete += 1
    i = bisect_right(A,half)
    U = A[i:][::-1]
    D = A[:i][::-1]
    cand = []
    rest_U = []
    for y in U:
        while D and D[-1] + y <= S:
            cand.append(D.pop())
        if cand:
            cand.pop()
            complete += 1
        else:
            rest_U.append(y)
    cand += D[::-1]
    L = len(cand)
    if L & 1:
        # 一番小さいものを余らせる
        complete += L // 2 + len(rest_U)
        return complete, cand[0]
    else:
        complete += L // 2
        if rest_U:
            return complete + len(rest_U) - 1, rest_U[-1]
        else:
            return complete, 0

root = 1
parent = [0] * (N+1)
order = []
stack = [root]
while stack:
    x = stack.pop()
    order.append(x)
    for y in graph[x]:
        if y == parent[x]:
            continue
        parent[y] = x
        stack.append(y)

def num_of_seg(B):
    # 長さBまで許容したとき、いくつの線分が必要になるか
    dp = [0] * (N+1)
    seg_lens = [[] for _ in range(N+1)]
    for v in order[::-1]:
        p = parent[v]
        A = seg_lens[v]
        pair, r = make_pairs(A,B)
        dp[v] += pair
        if v == root:
            if r:
                return dp[v] + 1
            else:
                return dp[v]
        dp[p] += dp[v]
        seg_lens[p].append(r + 1)

opt_A = num_of_seg(N+10)
left = 0 # むり
right = N + 10 # 可能
while left + 1 < right:
    x = (left + right) // 2
    if num_of_seg(x) == opt_A:
        right = x
    else:
        left = x
B = right
A = opt_A
print(A,B)

Measured memory_bytes: 143108
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <unordered_set>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define ull unsigned long long
#define pi (acos(-1))
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
#define vec std::vector
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);
int main()
{
    int n;
    cin >> n;
    vec<int> v(n);
    rep(i, n) { cin >> v[i]; }
    int ind = n / 2;
    sort(all(v));
    if (n % 2 != 0) { cout << 0 << endl; }
    else
    {
	    if (v[ind - 1] == v[ind]) {
		    cout<<0<<endl;return 0;
	    }
	    cout<<v[ind]-v[ind-1]<<endl;
    }

    return 0;
}

ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

int main(){
    int n;
    cin >> n;
    if(n==1){
        cout << "Hello World" << endl;
    }else{
        int a,b;
        cin >> a >> b;
        cout << a+b << endl;
    }
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
	boolean eof;

	List<Integer>[] g1, g2;
	int n;

	static final int INF = 1_000_000_000;

	int[][] bfs(List<Integer>[] g, int root) {
		int[] dist = new int[n];
		Arrays.fill(dist, INF);
		int[] par = new int[n];
		par[root] = root;
		int[] q = new int[n];
		int head = 0, tail = 0;
		q[tail++] = root;
		dist[root] = 0;

		while (head < tail) {
			int v = q[head++];
			for (int u : g[v]) {
				if (dist[u] > dist[v] + 1) {
					dist[u] = dist[v] + 1;
					par[u] = v;
					q[tail++] = u;
				}
			}
		}

		return new int[][] { dist, par };
	}

	boolean badEdge(int v, int u, int[] par) {
		return (par[v] == u || par[u] == v) || // distance 1
				(par[par[v]] == u || par[par[u]] == v || par[v] == par[u]); // distance
																			// 2
	}

	void solve() throws IOException {
		n = nextInt();
		int x = nextInt() - 1;
		int y = nextInt() - 1;

		g1 = new List[n];
		for (int i = 0; i < n; i++) {
			g1[i] = new ArrayList<>();
		}

		g2 = new List[n];
		for (int i = 0; i < n; i++) {
			g2[i] = new ArrayList<>();
		}

		for (int i = 0; i < n - 1; i++) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;
			g1[v].add(u);
			g1[u].add(v);
		}

		for (int i = 0; i < n - 1; i++) {
			int v = nextInt() - 1;
			int u = nextInt() - 1;
			g2[v].add(u);
			g2[u].add(v);
		}

		int[][] info1 = bfs(g1, x);
		int[][] info2 = bfs(g2, y);
		
//		System.err.println(Arrays.toString(info2[1]));

		boolean[] safeNodes = new boolean[n];
		for (int v = 0; v < n; v++) {
			for (int u : g1[v]) {
				if (u < v) {
					continue;
				}
				
//				System.err.println(v + " " + u + " " + badEdge(v, u, info2[1]));
				
				if (!badEdge(v, u, info2[1])) {
					safeNodes[v] = safeNodes[u] = true;
				}
			}
		}

		int[] dist = new int[n];
		Arrays.fill(dist, INF);
		int[] q = new int[n];
		int head = 0, tail = 0;
		q[tail++] = x;
		dist[x] = 0;

		int ans = 0;

		while (head < tail) {
			int v = q[head++];
			if (safeNodes[v]) {
				out.println(-1);
				return;
			}
			ans = Math.max(ans, info2[0][v]);
			for (int u : g1[v]) {
				if (info1[0][u] >= info2[0][u]) {
					continue;
				}
				if (dist[u] > dist[v] + 1) {
					dist[u] = dist[v] + 1;
					q[tail++] = u;
				}
			}
		}
		
		out.println(ans * 2);

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		solve();
		out.close();
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				eof = true;
				return null;
			}
		}
		return st.nextToken();
	}

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			eof = true;
			return null;
		}
	}

	int nextInt() throws IOException {
		return Integer.parseInt(nextToken());
	}

	long nextLong() throws IOException {
		return Long.parseLong(nextToken());
	}

	double nextDouble() throws IOException {
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 129544
import math
import itertools

N=int(input())

def primes(x):
    if x<2: return[]

    primes = [i for i in range(x)]
    primes[1] = 0

    for prime in primes:
        if prime > math.sqrt(x): break
        if prime == 0: continue
        for non_prime in range(2 * prime, x, prime): primes[non_prime]=0

    return [prime for prime in primes if prime!=0 and prime%5==1]

ans = primes(1400)[:N]

for i in range(N):
    if i!=N-1:
        print(ans[i],end=" ")
    else:
        print(ans[i])

Measured memory_bytes: 3064
# ABC129D - Lamp
def main():
    H, W, *S = open(0).read().split()
    H, W = int(H), int(W)
    L, R = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    U, D = [[0] * W for _ in range(H)], [[0] * W for _ in range(H)]
    for x1 in range(H):
        for y1 in range(W):
            if S[x1][y1] == ".":  # left and upper sides of S[i][j]
                U[x1][y1] = U[x1 - 1][y1] + 1
                L[x1][y1] = L[x1][y1 - 1] + 1
            x2, y2 = -x1 - 1, -y1 - 1
            if S[x2][y2] == ".":  # right and under sides
                D[x2][y2] = D[x2 + 1][y2] + 1
                R[x2][y2] = R[x2][y2 + 1] + 1
    ans = -float("inf")
    for i in range(H):
        for j in range(W):
            ans = max(ans, L[i][j] + R[i][j] + U[i][j] + D[i][j] - 3)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 177880
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#include <cmath>
#include <random>

#define mod 1000000007

using namespace std;
using ll = long long;

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

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


Measured memory_bytes: 256
int a[9][9][11],b,f,r,v,n;
main(){
  for(scanf("%d",&n);n--;scanf("%d%d%d%d",&b,&f,&r,&v),a[b][f][r]+=v);

  for(b=0;b++<4;b>3?:puts("####################"))
    for(f=0;f++<3;puts(""))
      for(r=0;r++<10;printf(" %d",a[b][f][r]));
exit(0);
}

Measured memory_bytes: 612
N, K = map(int, input().split())
h = [int(i) for i in input().split()]
INF = 10**9
dp = [0]*N
for i in range(1,N):
  m = INF
  for j in range(1,K+1):
    if i-j<0:
      break
    x = dp[i-j]+abs(h[i]-h[i-j])
    if m>x:
      m = x
  dp[i] = m
print(dp[-1])

Measured memory_bytes: 52448
import java.io.*;
import java.util.*;


public class Main {

	private static Scanner sc;
	private static Printer pr;

	private static void solve() {
		int n = sc.nextInt();
		int a = sc.nextInt();

		pr.println(n * n - a);
	}

	// ---------------------------------------------------
	public static void main(String[] args) {
		sc = new Scanner(System.in);
		pr = new Printer(System.out);

		solve();

		pr.close();
		sc.close();
	}

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}


Measured memory_bytes: 21844
import math

def main(X):
    lst = f(X)
    for L in lst:
        for l in L:
            for B in range(-120, 120, 1):
                A = B + l[0]
                if g(A, B):
                    print(A, B)
                    exit()

def f(X):
    return [[[X // i, i], [i, X // i]] for i in range(1, math.floor(X ** 0.5) + 1) if X % i == 0]

def g(A, B):
    return A ** 5 - B ** 5 == X



if __name__ == '__main__':
    X = int(input())
    main(X)


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

vector<char> beautiful(char* s,int* o){
    vector<char>chackchar;
    int count = 0;
    for (int i = 0; i < *o; ++i) {
        if (i == 0){
            chackchar.push_back(s[0]);
        } else {
            for (int j = 0; j < chackchar.size(); ++j) {
                if (s[i] != chackchar[j]) {
                    count++;
                }
            }
            if (count == chackchar.size()){
                chackchar.push_back(s[i]);
            }
            count = 0;
        }
    }
    return chackchar;
}

void chack(char* a, char* b,int* c, int* d){
    int count = 0;
    int no = 0;
    for (int i = 0; i < *d; ++i) {
        for (int j = 0; j < *c; ++j) {
            if (b[i] == a[j]){
                count++;
            }
        }
        if (count % 2 != 0){
            cout << "No";
            no = 1;
            break;
        }
    }
    if (no != 1){
        cout << "Yes";
    }
}

int main() {
    string s;
    vector<char> bb;
    cin >> s;
    int o = s.size();
    bb = beautiful(&s[0],&o);
    int x = bb.size();
    chack(&s[0],&bb[0],&o,&x);
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main()
{
   int n,i,s,j,c,k,b;
   while(~scanf("%d",&n))
   {
       if(n==0)
        break;
       s=0,i=2,c=0,k=1;
       while(1)
       {
           b=sqrt(i);
           for(j=1;j<=b;j++)
           {
               if(i%j==0&&j!=1)
                     {k++;break;}
           }
            if(k==1)
            {
                s+=i;
                c++;
            }
           k=1;
           if(c==n)
           {
               break;
           }
           i++;
       }
       printf("%d\n",s);

   }

}



Measured memory_bytes: 2044
#include <iostream>
#include <string>
#include <cctype>
#include <cassert>
using namespace std;

// ??§????????°
string S;
size_t cur = 0; // ?§£???????§???????

// ?¬??????°??????????????¢??°
int digit(){
    assert(isdigit(S[cur]));
    int n = S[cur] - '0'; // ASCII?????????????????¨?????????'0'???0?????????
    cur = cur + 1;
    return n;
}

// ??°???????????¨????????¨???????????°?????????????????¢??°
int number(){
    int n = digit(); // ?????????digit
    while(cur < S.size() && isdigit(S[cur])){ // ?????????????????????????¬??????°??????
        n = n*10 + digit();
    }
    return n;
}

int expression(); // ????????£?¨?

// ()???????????°????????????????????¨???????¨????????????¢??°
int factor(){
    if(S[cur] != '('){
        return number();
    }
    cur += 1;
    int n = expression();
    assert(S[cur] == ')');
    cur += 1;
    return n;
}

// 0?????\?????????????????????????????????????????¨??????????¨????????????¢??°
int term(){
    int a = factor();
    while(cur < S.size() && (S[cur] == '*' || S[cur] == '/')){ // ?¬????number???????????¨???????¨????????????????????????????cur++???????????????????????????????????¨????????§??????
        char op = S[cur++]; // cur???????????§??????+1?????????
        int b = factor();
        if(op == '*'){
            a *= b;
        } else {
            a /= b;
        }
    }
    return a;
}

// 0?????\???????¶?????????????????????????????????¨??????????¨????????????¢??°
int expression(){
    int a = term();
    while(cur < S.size() && (S[cur] == '+' || S[cur] == '-')){ // ?¬????term???????????¨???????¨????????????????????????????cur++???????????????????????????????????¨????????§??????
        char op = S[cur++];
        int b = term();
        if(op == '+'){
            a += b;
        } else {
            a -= b;
        }
    }
    return a;
}

int parse(){
    return expression();
}

int main(){
    int N;
    cin >> N;
    for(int i=0; i<N; ++i){
        cur = 0;
        cin >> S;
        S.resize(S.size()-1); // ?????????=?????????

        int a = parse();
        assert(cur == S.size());

        cout << a << endl;
    }
}

Measured memory_bytes: 3004
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int binarySearch(vector<int> v,int key) {
	int left = 0;
	int right = v.size();
	int mid;
	while (left < right) {
		mid = (left + right) / 2;
		if (key > v.at(mid)) {
			left = mid + 1;
		}
		else if (key < v.at(mid)) {
			right = mid;
		}
		else {
			return 1;
		}
	}
	return 0;
}

int main() {
	int n;
	cin >> n;
	int ans = 0;
	vector<int> vec(n);
	for (int i = 0; i < n; i++) {
		cin >> vec.at(i);
	}
	int q;
	cin >> q;
	vector<int> t(q);
	for (int i = 0; i < q; i++) {
		cin >> t.at(i);
		ans += binarySearch(vec, t.at(i));
	}
	cout << ans << endl;
}


Measured memory_bytes: 3916
# https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/all/GRL_3_A
# P350に図による説明はあるのだが端折られているところもあり、少し苦しんだ。
# 関節点を求めるには主に2パートに分かれる
# 1. dfsによる各ノードのprenum(深さ優先探索でたどる順番), parent(深さ優先探索でたどる木構造), lowest(こいつはわかりにくいので求め方を図解した)
# 2. 以上で求めた情報に基づいて、そのノードが関節点か決定する。

# 1について`dfs()`で求めて
# 2について`art_points()`で求める
INF = 10**6 + 1
import sys
sys.setrecursionlimit(2**16 - 1)
from collections import defaultdict
G = defaultdict(lambda: [])
# input data
n_V, n_E = list(map(int, input().split()))

for _ in range(n_E):
    s, t = list(map(int, input().split()))
    G[s].append(t)
    G[t].append(s)


def get_art_point(G, n_V):
    # graph Gがdefaultdictで定義された隣接リストであること前提とする。
    # n_Vは頂点数
    prenum = [None] * n_V
    parent = [None] * n_V
    lowest = [INF] * n_V
    timer = 0  # dfsに入った順番を記録(prenum用)
    is_visited = [False] * n_V  # 木を作るために循環してはいけない
    root = 0

    # 1のフェーズ、prenumとparent,lowestについて確定していく。
    def dfs(cur, prev):  # 次に訪問するノードが以前のノードprevではないことを識別する必要があるので引数がこうなっている
        # 関数に入るときにprenumとparentを確定してく
        nonlocal timer  # nonlocalは指定した変数が見つかるまでスコープを広げて探す
        prenum[cur] = lowest[cur] = timer  # 教科書の説明とは違ってprenumは0スタートだが本質的な違いはない
        timer += 1
        parent[cur] = prev
        is_visited[cur] = True

        # 次のノードに訪問していく
        for nx in G[cur]:  # nxは次に探索すべきノード
            if (not is_visited[nx]):
                dfs(nx, cur)
                lowest[cur] = min(lowest[cur], lowest[nx]
                                  )  # 子のlowestの最小値が取得できる
            elif nx != prev:  # 探索済みにつながる木以外の経路 いわゆるback-edge
                # back-edge先のノードの方とどっちが小さいか比較
                lowest[cur] = min(lowest[cur], prenum[nx])

    # 2のフェーズ。次にprenumとlowestに注目して間接点を決定してく
    def art_points(root):
        # 間接点の重複を許したくないので集合型で管理
        ret = set()
        n_p_is_root = root  # 螺旋本でいうところのnp。rootから2つ以上の子が存在するならば、rootは間接点
        # 0を根にしているのでその親はNoneであり、これを考慮する必要はない
        for u, p in enumerate(parent):
            if p is None:
                # rootの親はないので
                continue
            elif p == root:
                # uはあるノード。pはその親.
                n_p_is_root += 1

            if prenum[p] <= lowest[u]:
                ret.add(p)
        if n_p_is_root == 1:
            # rootが間接点でないならroot(0)を消す
            ret.remove(0)
        return ret

    # ここから具体的な処理
    dfs(root, None)
    return art_points(root)


ans = list(get_art_point(G, n_V))
ans.sort()
if ans:
    print(*ans, sep='\n')
else:
    pass



Measured memory_bytes: 22184