akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
signed main(){
	string s;cin >> s;
	sort(s.begin(),s.end());
	if(s[0] == s[1] && s[2] == s[3]){
		if(s[0] != s[2]){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

bool is_aru(vector<int> a, int num){
    rep(i, a.size()){
        if(a[i]==num) return true;
    }
    return false;
}

int main(){
    int H, W, M; cin >> H >> W >> M;
    int h[M], w[M];
    rep(i, M) cin >> h[i] >> w[i];

    int max_h=0, max_w=0;
    int num_h[H]={0}, num_w[W]={0};
    set<P> s;
    rep(i, M){
        s.emplace(h[i]-1, w[i]-1);
        num_h[h[i]-1]++;
        if(num_h[h[i]-1] > max_h) max_h=num_h[h[i]-1];
        num_w[w[i]-1]++;
        if(num_w[w[i]-1] > max_w) max_w=num_w[w[i]-1];
    }

    vector<int> h_l_num;
    vector<int> w_l_num;

    rep(i, H){
        if(num_h[i]==max_h) h_l_num.push_back(i);
    }
    rep(i, W){
        if(num_w[i]==max_w) w_l_num.push_back(i);
    }

    int ans=max_h+max_w;
    int numnum=0;
    // rep(i, M){
    // rep(i, h_l_num.size()) cout<<h_l_num[i]+1<<" ";
    // cout<<endl;
    // rep(i, w_l_num.size()) cout<<w_l_num[i]+1<<" ";
    // cout<<endl;
    rep(i, int(h_l_num.size())){
        rep(j, int(w_l_num.size())){
            if(s.count(P(h_l_num[i], w_l_num[j]))) continue;
            cout<<ans<<endl;
            return 0;
        }
    }

        // if(is_aru(h_l_num, h[i]-1)){
        //     if(is_aru(w_l_num, w[i]-1)){
        //         numnum++;
        //     }
        // }
    // }

    // int a=h_l_num.size(), b=w_l_num.size();
    // if(numnum>=a*b) ans=max_h+max_w-1;
    // else ans=max_h+max_w;

    cout << ans-1 << endl;

    return 0;
}

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

int main(){
  while(true){
    int m, f, r;
    cin >> m >> f >> r;
    if(m == -1 && f == -1 && r == -1){
      break;
    }
    if(m == -1 || f == -1){
      cout << "F" << endl;
    }
    else if(m + f < 30){
      cout << "F" << endl;
    }
    else if(m + f >= 80){
      cout << "A" << endl;
    }
    else if(m + f >= 65 && m + f < 80){
      cout << "B" << endl;
    }
    else if(m + f >= 50 && m + f < 65){
      cout << "C" << endl;
    }
    else if(m + f >= 30 && m + f < 50){
      if(r >= 50){
        cout << "C" << endl;
      }
      else{
        cout << "D" << endl;
      }
    }

  }
}




Measured memory_bytes: 3108
#include <iostream>
#include <cmath>
using namespace std;
 
int main() {
	int n;
	int tmp;
	int i,j;
	int a,b;
	
	cin >> n;
	
	int ary[n];
	int number[n];
	
	for(i = 0; i < n; i++){
		cin >> ary[i];
		number[i] = ary[i];
	}
	
	
	for (i=0; i<n; ++i) {
	    for (j=i+1; j<n; ++j) {
			if (number[i] > number[j]) {
				tmp =  number[i];
	        	number[i] = number[j];
	        	number[j] = tmp;
	      	}
	    }
	}
	
	tmp = 0;
	
	for(i = 0; i < n; i++){
		if(ary[i] != number[i])tmp++;
	}
	
	if(tmp == 0){
		cout << "YES";
	}
	else if(tmp == 2){
		for(i = 0; i < n; i++){
			if(ary[i] != number[i]){
				a = i;
				break;
			}
		}
		for(j = i+1; j < n; j++){
			if(ary[j] != number[j]){
				b = j;
				break;
			}
		}
		
		tmp =  ary[a];
       	ary[a] = ary[b];
	    ary[b] = tmp;
		
		tmp = 0;
		
		for(i = 0; i < n; i++){
			if(ary[i] != number[i]){
				cout << "NO";
				return 0;
			}
		}
		
		cout << "YES";
		
	}
	else{
		cout << "NO";
	}
	
	
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int m = scan.nextInt();
		
		int count = 0;
		for (int i = 1; i <= n - 1; i++) {
			count+= i;
		}
		for (int i = 1; i <= m - 1; i++) {
			count+= i;
		}
		System.out.println(count);
	}

}


Measured memory_bytes: 21844
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

int main(){
  int n, B[110], s=0;
  cin >> n;
  rep(i, n-1) {
    cin >> B[i];
  }
  s += B[0];
  if(n>2) s += B[n-2];
  if(n>2) {
    REP(i, 1, n-1) {
      if(B[i-1] <= B[i]) {
        s += B[i-1];
      }
      else {
        s += B[i];
      }
    }
  }
  else {
    s += B[0];
  }
  cout << s << endl;
}

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

int op(int a,int b){
  return max(a,b);
}

int e(){
  return -1;
}

int v;

bool f(int k){
  return k < v;
}

int main(){
  int n,q;
  cin >> n >> q;
  vector<int> A(n);
  for(int i=0;i<n;i++){
    cin >> A[i];
  }
  segtree<int,op,e> seg(A);
  for(int i=0;i<q;i++){
    int t;
    cin >> t;
    if(t == 1){
      int x;
      cin >> x >> v;
      x--;
      seg.set(x,v);
    }
    else if(t == 2){
      int l,r;
      cin >> l >> r;
      l--;
      cout << seg.prod(l,r) << endl;
    }
    else if(t == 3){
      int x;
      cin >> x >> v;
      x--;
      cout << seg.max_right<f>(x)+1 << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 6220
#import numpy as np
#import math
#from decimal import *
#from numba import njit

#@njit
def main():
    N = int(input())
    AC, WA, TLE, RE = 0,0,0,0
    for _ in range(N):
        i = input()
        if i == 'AC':
            AC += 1
        elif i == 'WA':
            WA += 1
        elif i == 'TLE':
            TLE += 1
        elif i == 'RE':
            RE += 1
    
    print('AC x ' + str(AC))
    print('WA x ' + str(WA))
    print('TLE x ' + str(TLE))
    print('RE x ' + str(RE))

main()


Measured memory_bytes: 9196
from sys import stdin, exit
input = stdin.readline


INFTY = 2 ** 40
lines = stdin.readlines()
v, e = list(map(int, lines[0].split()))

A = [[INFTY] * v for i in range(v)]
#shokika
for i in range(v):
    A[i][i] = 0

for i in range(e):
    s, t, d = list(map(int, lines[i+1].split()))
    A[s][t] = d

for k in range(v):
    for i in range(v):
        if A[i][k] == INFTY:
            continue
        for j in range(v):
            if A[k][j] == INFTY:
                continue
            a = A[i][j]
            b = A[i][k] + A[k][j]
            if a > b:
                A[i][j] = b

for i in range(v):
    if A[i][i] < 0:
        print('NEGATIVE CYCLE')
        exit()


for i in range(v):
    for j in range(v):
        if j < (v-1):
            if A[i][j] == INFTY:
                print('INF', end=' ')
            else:
                print(A[i][j], end=' ')
        else:
            if A[i][j] >= INFTY:
                print('INF')
            else:
                print(A[i][j])


Measured memory_bytes: 6928
#include<stdio.h>

int A[20000000];

int partition(int, int);

main(){
  int k,r,mid;
  int i;

  scanf("%d",&k);

  for(i=0;i<k;i++){
    scanf("%d",&A[i]);
  }

  r=k-1;

  mid=partition(0,r);

  for(i=0;i<mid;i++){
    printf("%d ",A[i]);
  }

  printf("[%d] ",A[mid]);

  for(i=mid+1;i<=r;i++){
    printf("%d",A[i]);
    if(i!=r){
      printf(" ");
    }
  }

  printf("\n");

  return 0;

}


int partition(int p,int r){

  int i=0,j,ex=0;


 for(j=p;j<r;j++){
   if(A[j]<=A[r]){     
     ex=A[i];
     A[i]=A[j];
     A[j]=ex;
     i++;
   } 
 }

 ex=A[r];
 A[r]=A[i];
 A[i]=ex;
 
 return i;
}

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

using namespace std;

bool cmp1(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
    return a.first.first < b.first.first;
}

bool cmp2(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
    return a.first.second < b.first.second;
}

int n, p[100005];
vector< pair<pair<int, int>, int> > gr;
vector< pair<int, pair<int,int> > > edges;

int get_root(int a) {
    if (a == p[a]) {
        return a;
    } else {
        return p[a] = get_root(p[a]);
    }
}

bool merge(int a, int b) {
    a = get_root(a);
    b = get_root(b);
    if (a == b) {
        return true;
    } else {
        p[a] = b;
        return false;
    }
}

void solve() {
    cin >> n;
    for(int i=0; i < n; ++i) {
        int x, y;
        cin >> x >> y;
        gr.push_back(make_pair(make_pair(x,y), i));
        p[i] = i;
    }

    sort(gr.begin(), gr.end(), cmp1);

    for (int i=1; i < n; ++i) {
        edges.push_back(make_pair(gr[i].first.first - gr[i-1].first.first, make_pair(gr[i].second, gr[i-1].second)));
    }

    sort(gr.begin(), gr.end(), cmp2);

    for (int i=1; i < n; ++i) {
        edges.push_back(make_pair(gr[i].first.second - gr[i-1].first.second, make_pair(gr[i].second, gr[i-1].second)));
    }

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

    long long ans=0;
    for (int i=0; i<edges.size(); ++i) {
        int x = edges[i].second.first;
        int y = edges[i].second.second;
        if (!merge(x, y)) {
            ans += (long long)edges[i].first;
        }
    }
    cout << ans;
}

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


Measured memory_bytes: 7480
#include <iostream>
#include <vector>

using namespace std;

const int MOD = 1000 * 1000 * 1000 + 7;

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

	const int L = 2010;
	vector<vector<long long>> c(L + 1, vector<long long>(L + 1, 0));
	for (int i = 0; i < L; ++i) {
		c[i][0] = c[i][i] = 1;
	}
	for (int i = 1; i <= L; ++i) {
		for (int j = 1; j <= L; ++j) {
			c[i][j] = (c[i - 1][j - 1] + c[i - 1][j]) % MOD;
		}
	}

	for (int i = 1; i <= K; ++i) {
		auto ans = c[N - K + 1][i] * c[K - 1][i - 1] % MOD;
		cout << ans << endl;
	}
}


Measured memory_bytes: 31872
N = int(input())

A = list(map(int, input().split()))
A.sort()
A.reverse()

colors = [0] * 8
any_c = 0

for a in A:
    if a // 400 > 7:
        any_c += 1
    else:
        colors[a // 400] += 1

min_ans = 0

for color in colors:
    if color > 0:
        min_ans += 1

max_ans = min_ans + any_c
if min_ans == 0: min_ans += 1

print(str(min_ans) + " " + str(max_ans))


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

int main() {
    int r, d, x;
    cin >> r >> d >> x;
    for(int i=1; i<11; i++){
        int next = r*x-d;
        cout << next << endl;
        x = next;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    char s[100001];
    int cnt=0;
    cin >> s;
    for(int i=0;s[i]!='\0';i++) {
        char a=s[i];
        while(s[i+1]==a) i++;
        if(s[i+1]!='\0') cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 512
#include<iostream>
#include<math.h>
#include<algorithm>
#define ll long long int
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n)

using namespace std;

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


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(n);(i)++)
#define repr(i,n) for(int (i)=(n)-1;(i)>=0;(i)--)
#define forin(i,array) for(auto& x:array)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mod 1000000007
#define inf 10000000000000


typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int,int> pint;
typedef pair<ll,ll> pll;
typedef vector<pint> vpint;

struct PAIR{
    ll apos,bpos,cpos;
};

int x,y,z,k;

int main(){
    cin>>x>>y>>z>>k;
    vll a(x),b(y),c(z);
    rep(i,x)cin>>a[i];
    rep(i,y)cin>>b[i];
    rep(i,z)cin>>c[i];

    sort(all(a),greater<ll>());
    sort(all(b),greater<ll>());
    sort(all(c),greater<ll>());

    vll d,e;
    rep(i,x)rep(j,y)d.pb(a[i]+b[j]);
    sort(all(d),greater<ll>());

    int dsize=d.size();

    rep(i,min(k,dsize)) rep(j,z)e.pb(d[i]+c[j]);
    sort(all(e),greater<ll>());

    rep(i,k)cout<<e[i]<<endl;

    return 0;
}

Measured memory_bytes: 43368
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Collections;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EGluttony solver = new EGluttony();
        solver.solve(1, in, out);
        out.close();
    }

    static class EGluttony {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            long l = 0;
            long r = 1000000_000000_000000L;
            int n = in.nextInt();
            long k = in.nextLong();
            ArrayList<Integer> a = new ArrayList<>();
            ArrayList<Integer> b = new ArrayList<>();
            for (int i = 0; i < n; i++) a.add(in.nextInt());
            for (int i = 0; i < n; i++) b.add(in.nextInt());
            Collections.sort(a);
            Collections.sort(b, Collections.reverseOrder());
            while (l < r) {
                long mid = (l + r) / 2;
                long temp = 0;
                for (int i = 0; i < n; i++) temp += Math.max(0L, a.get(i) - (mid / b.get(i)));
                if (temp > k) l = mid + 1;
                else r = mid;
            }
            out.println(r);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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

    }
}



Measured memory_bytes: 63780
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
double pai = acos(-1.0);
int main(){
  int n;
  while( cin >> n , n){
    double suma = 0,sumb = 0;
    double s = 360;
    for(int i = 0 ; i < n-1 ; i++ ){
      double m;
      cin >> m;
      suma += (0.5)*sin((m/180.0)*pai); 
      s -= m;
    }
    suma += (0.5)*sin((s/180.0)*pai); 
    s = 360;
    cin >> n;
    for(int i = 0 ; i < n-1 ; i++ ){
      double m;
      cin >> m;
      sumb += (0.5)*sin((m/180.0)*pai);
      s -= m; 
    }
    sumb += (0.5)*sin((s/180.0)*pai); 
    if((float)suma > (float)sumb)cout << 1;
    else if((float)suma < (float)sumb)cout << 2;
    else cout << 0;
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1260
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
//void inputer();
int S;
int a[4];

int main() {
	cin >> S;
	a[0] = floor(S / 1000.0);
	a[1] = floor((S - a[0] * 1000.0) / 100.0);
	a[2] = floor((S - a[0] * 1000.0 - a[1] * 100.0) / 10.0);
	a[3] = floor((S - a[0] * 1000.0 - a[1] * 100.0 - a[2] * 10.0)/1.0);

		if (a[0] == a[1] || a[1] == a[2] || a[2] == a[3]) {
			cout << "Bad" << endl;
		} else {
			cout << "Good" << endl;

		}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cmath>
#include <string>
#include <string.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <stdlib.h>
#include <deque>  
#include <iomanip>

using namespace std;

#define ll long long
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define rep(i, n) for(int i = 0; i < n; i++)
#define loop(i, a, n) for(int i = a; i < n; i++)
#define all(in) in.begin(), in.end()
#define vint vector<int>

int main(){
    int a, b;
    cin >> a >> b;
    int count = a;
    int ans = 1;
    while(true){
        if (count >= b){
            break;
        }else{
            count += (a - 1);
            ans++;
        }

    }
    if (b == 1) ans = 0;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
string s;
int l;
int main()
{
    cin>>s;
    l=s.size();
    for(int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(int j=i+1;j<l;j++)
                if(s[j]=='F'){printf("Yes");return 0;}
        }
    }
    printf("No");
    return 0;
}

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

using namespace std;

#define f cin
#define g cout

int a[4];

int main()
{
    f >> a[1] >> a[2] >> a[3];

    sort(a + 1, a + 1 + 3);

    if(a[1] == 5 && a[2] == 5 && a[3] == 7){
        g << "YES" << '\n';
    }else{
        g << "NO" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define int long long 
#define pp pair<int,int> 
#define ss second 
#define ff first 
#define pb push_back
#define mod 1000000007
#define mk(arr,n,type)  type *arr=new type[n];
#define sl s1.length();
using namespace std; 
void fastio()
{
  #ifndef ONLINE_JUDGE
  freopen("INPUT.txt","r",stdin);
  freopen("OUTPUT.txt","w",stdout); 
  #endif
  ios_base :: sync_with_stdio(false); 
  cin.tie(NULL) ; 
  cout.tie(NULL);
}
signed main()
{
    fastio();
    int n,m;
    cin>>n>>m;
    if(n==m)
    cout<<"Yes";
    else
    cout<<"No";
    
}
    


Measured memory_bytes: 3536
#include <iostream>

using namespace std;

int main() {
    int W, H, x, y;
    cin >> W;
    cin >> H;
    cin >> x;
    cin >> y;

    double max = (double)W * (double)H / 2; 
    int flag = 0;

    if((x + x == W) && (y + y == H)) {
        flag = 1;
    }
    
    cout << max << " " << flag << endl;

    return 0;
}   

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

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

  ll K; cin >> K;
  ll q = K / 50;
  ll r = K - q * 50;
  cout << 50 << '\n';
  for (ll i = 0; i < 50; i++) {
    if (i < r) {
      cout << (50 + q + 50 - r) << " ";
    } else {
      cout << (50 + q - (r + 1)) << " ";
    }
  }

  return 0;
}

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

vector<vector<ll>> v;

void dfs(ll n, ll m, ll t = 1, vector<ll> x = vector<ll>())
{
  if (x.size() >= n) {
    v.push_back(x);
    return;
  }
  x.push_back(t);
  for (int i=t; i<=m; i++) {
    dfs(n, m, i, x);
  }
}

int main()
{
  ll n;
  cin >> n;
  ll m;
  cin >> m;
  ll q;
  cin >> q;
  vector<ll> a(q);
  vector<ll> b(q);
  vector<ll> c(q);
  vector<ll> d(q);
  for (int i=0; i<q; i++){
    cin >> a[i];
    cin >> b[i];
    cin >> c[i];
    cin >> d[i];
    a[i]--; b[i]--;
  }

  dfs(n, m);

  ll ans = 0;
  for (auto u:v) {
    ll tmp = 0;
    for (int i=0; i<q; i++) {
      if (u[b[i]]-u[a[i]] == c[i]) tmp += d[i];
    }
    ans = max(ans, tmp);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 14000
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<sstream>
#include<iomanip>
#include<limits>
#include<deque>
#include<map>
#include<list>
#include<set>
#include <unordered_set>
#include<vector>
#include<cmath>
#include<cstdio>
#include<memory>
#include<bitset>
#include<stack>
#include<functional>
#include<queue>
#include<regex>
#include<time.h>
#include<type_traits>

using namespace std;
using ll = long long;

constexpr ll MOD = 1000000007;
constexpr ll INF = 1050000000;
constexpr ll LONGINF = 1050000000000000000;


vector<vector<int>> g;
vector<int> q;
vector<int> ans;
vector<int> tootta;

void dfs(int i, int sum) {//深さ優先探索によって、各頂点にクエリの値を入れていく。
	if (tootta[i]) {
		tootta[i] = false;
		for (auto x : g[i]) {
			if (tootta[x]) {
				ans[x] = sum + q[x];
				dfs(x, sum + q[x]);
			}
		}
	}
}

int main() {
	int n, Q; cin >> n >> Q;//入力

	g = vector<vector<int>>(n);
	ans = vector<int>(n);
	q = vector<int>(n);//各頂点のクエリあたりの総和が格納される。
	tootta = vector<int>(n, true);//通ったかどうかを判定する。

	///////////////////////////////////入力部分
	for (int i = 0; i < n - 1; i++) {
		int a, b; cin >> a >> b;
		a--; b--;
		g[a].emplace_back(b);
		g[b].emplace_back(a);
	}

	for (int i = 0; i < Q; i++) {
		int p, x; cin >> p >> x;
		p--;
		q[p] += x;
	}
	////////////////////////////////////

	//ここで、根付き木の頂点が1(実装では0)であることを利用し、深さ優先探索を行う。
	dfs(0, q[0]);
	ans[0] = q[0];

	for (auto x : ans) {//答えの出力
		cout << x << " ";
	}


	return 0;
}

Measured memory_bytes: 21888
class UnionFind():
    def __init__(self, n):
        self._n = n
        self._table = [-1]*n

    def _root(self, x):
        stack = []
        while self._table[x] >= 0:
            stack.append(x)
            x = self._table[x]
        for y in stack:
            self._table[y] = x
        return x
    
    def unite(self, x, y):
        x, y = self._root(x), self._root(y)
        if x == y:
            return
        if x > y:
            x, y = y, x
        self._table[x] += self._table[y]
        self._table[y] = x
    
    def same(self, x, y):
        return self._root(x) == self._root(y)

    def count_members(self, x):
        return -self._table[self._root(x)]
    
    def count_groups(self):
        return len({self._root(i) for i in range(self._n)})
    
    def __str__(self):
        return str([self._root(i) for i in range(self._n)])
    
    def __repr__(self):           
        return repr([self._root(i) for i in range(self._n)])

n, m, *AB = map(int, open(0).read().split())
uf = UnionFind(n)
for a, b in zip(AB[::2], AB[1::2]):
    uf.unite(a-1, b-1)
print(max(uf.count_members(group) for group in {uf._root(i) for i in range(n)}))

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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define pb emplace_back

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

int n;
vi S;
int dp[110][101010];

int dfs(int i = 0, int s = 0) {
	if (i == n) {
		if (s % 10 == 0) {
			return 0;
		}
		return s;
	}

	int &ret = dp[i][s];
	if (ret != -1) return ret;

	ret = 0;

	ret = max(dfs(i + 1, s + S[i]), dfs(i + 1, s));

	return ret;
}

int main() {
	n = in();
	rep(i, n) S.pb(in());

	memset(dp, -1, sizeof(dp));
	cout << dfs() << endl;
}



Measured memory_bytes: 43648
#include <stdio.h>
#include <math.h>

int	main(void)
{
	long long int a,b,c;

	scanf("%lld %lld %lld", &a, &b, &c);
	long long int d = c - a - b;
	if (d <= 0)
	{
		printf("No");
	}
	else if (d*d > 4*a*b)
	{
		printf("Yes");
	}
	else
		printf("No");

	return(0);
}


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

int main(){
  int A, B;
  cin >> A >> B;
  int a = A + B;
  int b = A - B;
  int c = A * B;
  
  int S = max(a,max(b,c));
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

N = int(input())
W = np.array(list(map(int, input().split())))

diff = abs(np.sum(W[0:0]) - np.sum(W[1:N]))

for i in range(N):
    sum1 = np.sum(W[0:i+1])
    sum2 = np.sum(W[i+1:N])

    delta = abs(sum1 - sum2)

    if delta < diff:
        diff = delta


print(diff)

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

int main() {
 int N;
 vector<int>a(1000000);  
 cin >> N;
 for(int i=0; i<N; ++i) {
  cin >> a.at(i);
 }
 sort(a.begin(), a.end());
 reverse(a.begin(), a.end());
 int ans;
 ans = a.at(N/2-1)-a.at(N/2);
 cout << ans <<endl;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  int p[5];
  for (int i = 0; i < 5; i++) {
    cin >> p[i];
  }
  int k;
  cin >> k;
  for (int i = 0; i < 5; i++) {
    for (int j = 0; j < 5; j++) {
      if (abs(p[i] - p[j]) > k) {
        cout << ":(" << endl;
        return 0;
      }
    }
  }
  cout << "Yay!" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
using ll = long long;
using P = pair<int,int>;
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
const ll INF = 1LL<<60;




int main()
{
    int N;
    cin >> N;
    vector<int> a(N);
    vector<int> b(N);
    vector<int> c(N);
    rep(i,N) cin >> a[i];
    rep(i,N) cin >> b[i];
    rep(i,N) cin >> c[i];

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

    ll ans = 0;
    rep(i,N){
        ll anum,cnum;
        auto Iter_a = lower_bound(a.begin(),a.end(),b[i]);
        auto Iter_c = upper_bound(c.begin(),c.end(),b[i]);
        if(b[i] <= a[Iter_a - a.begin()]) anum = Iter_a - a.begin();
        else anum = a.size();
        if(b[i] < c[Iter_c - c.begin()]) cnum = c.end() - Iter_c;
        else cnum = 0;
        ans += anum * cnum;
    }

    cout << ans << endl;

    return 0;
}
//Ctrl+Shift+Bでコンパイルと実行を行ってデバッグすること

Measured memory_bytes: 1408
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int a = scan.nextInt();
	int b = scan.nextInt();

	if(a+b < 10){
	    System.out.println(a+b);
	}else{
	    System.out.println("error");
	}
    }
}


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

int main(){
  int N,K;
  cin >> N >> K;
  int num = 1;
  for(int i = 0;i<N;i++){
    if(num <= K){
      num *= 2;
    }
    else{
      num += K;
    }
  }
  cout << num << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(void)
{
    char s[202];
    char scopy[101];
    char p[101];
    fgets(s,sizeof(s),stdin);
    fgets(p,sizeof(p),stdin);

    int i,j;
    i=j=0;
    int sn,pn;
    sn = strlen(s)-1; // \n을 빼줌.
    pn = strlen(p)-1;
    s[sn] = '\0';
    p[pn] = '\0';

    strcpy(scopy,s);
    strcat(s,scopy);

    int ctr=0;
    for (i=0;i<2*sn-pn;i++)
    {
        for (j=i;j<i+pn;j++)
        {
            if (s[j] == p[j-i]) ctr+=1;
        }
        if (ctr == pn) break;
        else ctr=0;
    }


    if (ctr == pn) printf("Yes\n");
    else printf("No\n");
    //printf("%d %d",sn,pn);
    return 0;
    //abaabbaabbaaaaaabbaabba
    //aabbaabaabb

}


Measured memory_bytes: 2144
N = int(input())
a = list(map(int,input().split()))
count = 0
while True:
    flag = 0
    for i in range(N):
        if a[i] % 2 is 0:
            a[i] = a[i] // 2
        else:
            flag = 1
    if flag:
        break;
    else:
        count += 1
print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
vector<P> ki[110000];
int dist[110000];
void dfs(int now,int last = -1){

    for(auto tmp:ki[now]){
        int next = tmp.first,d = tmp.second;
        if(next == last)continue;
        dist[next] = dist[now] + d;
        dfs(next,now);
    }
}
signed main(){
    int n;cin >>n;
    rep(i,n-1){
        int a,b,c;cin >>a  >> b >> c;
        --a;--b;
        ki[a].emplace_back(b,c);
        ki[b].emplace_back(a,c);
    }
    dfs(0);
    vector<int> black,white;
    rep(i,n){
        if(dist[i]%2 == 0){
            black.push_back(i);

        }
        else{
            white.push_back(i);

        }
    }
    vector<int> ans(n);
    for(auto p:black){
        ans[p] = 1;
    }
    rep(i,n)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 14592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <iomanip>

#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

#include <utility>
#include <list>

#include <cmath>
#include <algorithm>
#include <cassert>
#include <bitset>
#include <complex>
#include <climits>
#include <functional>
#include <unordered_set>
#include <unordered_map>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> l4;
typedef pair<double, double> dd;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back

#define debug(x) cerr << #x << " = " << x << " "
// n = m * x + x = (m+1) * x , and x < m -> x < (m+1)

int main()
{
    ll n;
    cin >> n;
    unsigned long long sum = 0;
    for (ll i = 1; i * i <= n; ++i)
        if (n % i == 0)
        {
            ll x = i;
            ll m = n/i-1;
            if (x >= m) continue;
            sum += m;
            assert(n%m==n/m);
        }
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<cstdlib>
#include<iomanip>
#include<queue>
#include<set>
#include <valarray>
#include<stack>
#include<sstream>
#include<math.h>

using namespace std;

void Solution()
{
    string str;
    cin>>str;
    
    int n;
    cin>>n;
    
    while(n--)
    {
        string rule;
        int a, b;
        string p;
        
        cin>>rule>>a>>b;
        if(rule == "replace")
        {
            cin>>p;
            int j = 0;
            
            for(int i = a; i <= b; i++)
            {
                str[i] = p[j];
                j++;
            }
        }
        else if (rule == "reverse")
        {
            string reverse = str;
            int temp = b;
            for(int i = a; i <= b; i++) 
            {
                str[i] = reverse[temp];  // notice : b+a-j
                //can not use b-- , if use, then can not reverse digit to the end
                temp--;  // or use function "reverse(str.begin() + a, str.begin() + b + 1)"
            }
        }
        else if(rule == "print")
        {
            for(int i = a; i <= b; i++ )
            {
                cout<<str[i];
            }
            cout<<endl;
        }
    }
}
int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
ll a[100000];
ll ans[100000];
int main()
{
	int n;
	ll kei=0;
	ll mini=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		kei+=a[i];
		if((i&1)==0 && i!=n-1)
			mini+=a[i]*2;
	}
	ans[n-1]=kei-mini;
	ans[0]=a[n-1]*2-ans[n-1];
	for(int i=0;i<n-1;i++)
	{
		ans[i+1]=2*a[i]-ans[i];
	}
	for(int i=0;i<n;i++)
		cout<<ans[i]<<" ";
	cout<<endl;
	return 0;
}

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

int main(){
    long long N,M,res;
    cin >> N >> M;

    if (N>=2 && M>=2) res = (N-2)*(M-2);
    else if (N>=2 || M>=2) res = max(N,M)-2;
    else res = 1;


    cout << res << endl;
}
    //sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});

Measured memory_bytes: 256
N, W = map(int, input().split())
weight = []
value = []
for i in range(N):
    w, v = map(int, input().split())
    weight.append(w)
    value.append(v)
dp = [[0 for _ in range(W+1)] for _ in range(N+1)]
for i in range(N):
    for j in range(W+1):
        dp[i+1][j] = max(dp[i+1][j], dp[i][j])
        if j - weight[i] >= 0:
            dp[i+1][j] = max(dp[i+1][j], dp[i][j-weight[i]]+value[i])
print(dp[N][W])



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

namespace B___Resale
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var Vi = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var Ci = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int sum = 0;

            for (int i = 0; i < N; i++)
            {
                if (Vi[i] - Ci[i] > 0)
                {
                    sum += Vi[i] - Ci[i];
                }
            }

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin>>x>>a>>b;
    x-=a;
    while(x>=b){
        x-=b;
    }
    cout<<x<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int l,r;
    cin>>l>>r;
    int flag=0;
    long long int m=0,a;
    if(l+2022<r){
        r=l+2022;
    }
    for(long long i=l;i<r;i++){
       for(long long j=i+1;j<=r;j++){
        if(flag==0){
            m=(l*j)%2019;
            flag++;
            //cout<<i<<" "<<j<<endl;
        }
        else{
        a=(i*j)%2019;
        if(a<m){
            m=a;
            //cout<<i<<" "<<j<<endl;
        }
        }
    }
    }
    cout<<m<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define r1(i, n) for (int i=0;i<n;i++)
#define r2(i, n) for (int i=1;i<n+1;i++)
#define intc(n) int n; cin >> n;
#define ll long long
#define llc(n) ll n; cin >> n;
#define stringc(s) string s; cin >> s;
using namespace std;
int main() {
  llc(n);
  set<string> s;
  r1(i,n) {
    string t;
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << endl;
}

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

min_cost = 10 ** 9 + 7
for i in range(-100, 101):
    cost = 0
    for j in range(N):
        cost += (A[j] - i) ** 2
    min_cost = min(cost, min_cost)

print(min_cost)


Measured memory_bytes: 9028
/*author : Yashvardhan
Tuesday, April 07, 2020
8:24 PM
*/

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

#define int ll
#define pb push_back
#define vi vector<int>
#define pi pair<int,int>
#define vpi vector<pi>
#define ff first
#define ss second
#define mp make_pair
#define endl '\n'
#define all(a) a.begin(), a.end()
#define initialise(a, x) memset(a, x, sizeof(a))
#define rev(Y) reverse(all(Y))
#define printArr(name,from,to) for(int x = from; x < to; x++) cout << name[x] << " ";


#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS

#ifdef __APPLE__
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){cerr << name << " : " << arg1 << endl;}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << "  ";
	__f(comma + 1, args...);}
#else
#define debug(...)
#endif

template <typename T> ostream& operator << (ostream& os,const vector<T>& v){for(int i=0;i<v.size();++i) os<<v[i]<<" ";return os;} 
template <typename T> ostream& operator << (ostream& os,const set<T>& v){for(auto it:v) os<<it<<" ";return os;} 
template <typename T, typename S> ostream& operator << (ostream& os, const pair<T,S>& v) {os<<v.ff<<" "<<v.ss;return os;}

const int mod = 1e9 + 7;
const int inf = 2e18;
const int ninf = -2e18;

int takemod(int a){return ((a%mod)+mod)%mod;}

int pow(int a, int b, int m)
{
	int ans = 1;
	a %= m;
	while (b)
	{
		if (b & 1)
			ans = (ans * a) % m;
		b /= 2;
		a = (a * a) % m;
	}
	return ans;
}

int modinv(int a){return takemod( pow( takemod(a), mod-2,mod ) );}

bool isPali(string s){
	int j = s.size() - 1;
	for(int i  = 0; i < s.size(); i++){
		if(j < i) break;
		if(s[i] != s[j]) return false;
		j--;
	}
	return true;
}
signed main()
{

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

	#ifdef __APPLE__
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
		freopen("error.txt","w",stderr);
	#endif

	time_t t1, t2;
	t1 = clock();
	
	string s;
	cin >> s;
	int n = s.size();
	int n1 = (n - 1)/2;
	int n2 = (n + 3)/2;
	string a = s.substr(0,n1);
	string b = s.substr(n2 - 1);

	if(isPali(s) && isPali(a) && isPali(b)){
		cout << "Yes" << endl;
	}
	else cout << "No" << endl;
	

	t2 = clock();
	cerr << endl << t2-t1 << 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++)
int main(){
  int h,n;
  int inf=2000000000;
  cin >> h >> n;
  map<int,int> k;
  rep(i,n){
    int a,b;
    cin >> a >> b;
    if(k.count(a)) k[a]=min(k[a],b);
    else k[a]=b;
  }
  int q[h+1];
  fill(q,q+h+1,inf);
  q[0]=0;
  rep(i,h){
    for(pair<int,int>p : k){
      int f=p.first;
      int s=p.second;
      if(i+1<=f){
        q[i+1]=min(q[i+1],s);
      }
      else q[i+1]=min(q[i+1],q[i+1-f]+s);
    } 
  }
  cout << q[h] << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) {if (a > b) { a = b; return true; } return false; }

const int mod = 998244353;
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    
    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    ll n, a, b, k;
    cin>>n>>a>>b>>k;

    combination comb(n + 10);
    mint ans = 0;
    rep(i, n + 1) {
        if ((k - i * a) % b == 0 && (k - i * a) / b <= n) {
            ans += comb(n, i) * comb(n, (k - i * a) / b);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4992
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import Data.List.Split (splitOn)

main :: IO ()
main = do
  n <- getl toInt
  xs <- rgetl n solve
  mapM_ putStrLn xs

solve :: String -> String
solve = intercalate "Hoshina" . splitOn "Hoshino"

toInt :: String -> Int
toInt s = read s

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

Measured memory_bytes: 4132