akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

int main()
{
    int a[7]={1,3,5,7,8,10,12};
    int b[4]={4,6,9,11};
    int a1,b1,t,n,i,j;

    while(~scanf("%d %d",&a1,&b1))
    {
        if(a1==2&&b1==2)
            printf("Yes\n");
        else if(a1==2&&b1!=2||a1!=2&&b1==2)
            printf("No\n");
        else
        {
            t=n=0;
        for(i=0;i<7;i++)
        {
            if(a1==a[i])
                t++;
                if(b1==a[i])
                t++;
        }
        for(j=0;j<4;j++)
        {
            if(a1==b[j])
               n++;
            if(b1==b[j])
                n++;
        }
        if(t==2||n==2)
            printf("Yes\n");
        else
            printf("No\n");
        }

    }

    return 0;
}


Measured memory_bytes: 128
/* 165-A.cpp
 *     Created on : May 2, 2020 
 *     Time       : 6:11:48 PM
 *     Author     : null_ptr
 */
#include<iostream>

using namespace std;

int main()
{
	int k,a,b;
	cin>>k>>a>>b;
	bool chk=false;
	for(int i=a;i<=b;++i)
		if(!(i%k))chk=true;

	if(chk)cout<<"OK\n";
	else cout<<"NG\n";
}


Measured memory_bytes: 3636
n, k = gets.strip.split.map(&:to_i)
numbers = readlines.map {|line| line.strip.split.map(&:to_i) }.sort_by {|e| e.first }

#p [n,k]
#p numbers

count = 0
numbers.each {|number|
  count+=number.last
  if k <= count
    p number.first
    exit
  end
}

Measured memory_bytes: 19832
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (long long i = (a), max_i = (b); i <= max_i; i++)
using namespace std;
typedef long long ll;

ll gcd(ll C, ll D) { return D ? gcd(D,C%D) : C; }
ll lcm(ll C, ll D) { return C/gcd(C,D)*D; }

ll f(ll x, int C, int D) {
  ll res = x;
  res -= x/C;
  res -= x/D;
  res += x/lcm(C,D);
  return res;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll A,B; cin >> A >> B;
  int C, D; cin >> C >> D;
  ll ans = f(B,C,D) - f(A-1,C,D); 
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<vector>
#define ll long long
using namespace std;
const int wa=1e9+7;
int N, a[100];
int cnt = 0;
int main(void) {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
		for (int i = 0; i < N; i++) {
			int minj = i;
			for (int j=i; j < N; j++) {
				if (a[j] < a[minj]) {
					minj = j;
				}
			}
			if (minj != i) {
				swap(a[i], a[minj]);
				cnt++;
			}
		}
	
	for (int i = 0; i < N; i++) {
		cout << a[i];
		if (i != N - 1)cout << " ";
	}
	cout << endl;
	cout << cnt << endl;
	return 0;
}




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

int N = 0;
int K = 0;
bool card[100020] = {0};
bool wildCard = false;

void init() {
  N = K = 0;
  wildCard = false;
  fill(card, card+100020, 0);
}

bool input() {
  init();
  cin >> N >> K;
  if (!N && !K) return false;
  for (int i = 0; i < K; i++) {
    int temp;
    cin >> temp;
    if (temp) card[temp] = true;
    else wildCard = true;
  }
  return true;
}

int solve() {
  int ans = 0;
  if (wildCard) {
    vector<int> space;
    for (int i = 1; i <= N; i++) {
      if (!card[i]) space.push_back(i);
    }
    for (int i = 0, len = space.size(); i < len; i++) {
      int temp = 1;
      for (int j = space[i]-1; j > 0; j--) {
        if (card[j]) temp++;
        else break;
      }
      for (int j = space[i]+1; j <= N; j++) {
        if (card[j]) temp++;
        else break;
      }
      ans = max(ans, temp);
    }
  }
  else {
    int temp = 0;
    for (int i = 1; i <= N; i++) {
      if (card[i]) temp++;
      else {
        ans = max(ans, temp);
        temp = 0;
      }
    }
  }
  return ans;
}

int main() {
  while (input()) {
    printf("%d\n", solve());
  }
  return 0;
}



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

int gcd(int a, int b){
   if (a%b == 0){
       return(b);
   }else{
       return(gcd(b, a%b));
   }
}
int main() {
  int n,x;
  cin >>n>>x;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int kotae=abs(a[0]-x);
  for(int i=1;i<n;i++){
    kotae=gcd(kotae,abs(x-a[i]));
  }
  cout<<kotae<<endl;
  return 0;
}
    


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

int main(){
  int n;
  cin >> n;
  vector<int> vec;
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec.push_back(num);
    vec[i]--;
  }
  vector<int> place(n, 0);
  for(int i=0; i<n; i++){
    place[vec[i]] = i;
  }
  set<int> s;
  long long sum = 0;
  for(int i=n-1; i>=0; i--){
    s.insert(place[i]);
    vector<int> l(2, -1);
    vector<int> r(2, n);
    {
      auto it = s.find(place[i]);
      for(int j=0; j<2; j++){
        if(it == s.begin()) break;
        --it;
        l[j] = *it;
      }
    }
    {
      auto it = s.find(place[i]);
      for(int j=0; j<2; j++){
        ++it;
        if(it == s.end()) break;
        r[j] = *it;
      }
    }
    vector<long long> ls(2);
    vector<long long> rs(2);
    ls[0] = place[i] - l[0];
    ls[1] = l[0] - l[1];
    rs[0] = r[0] - place[i];
    rs[1] = r[1] - r[0];
    sum += (ls[0]*rs[1]+ls[1]*rs[0]) * (i+1);
  }
  cout << sum << endl;
  return 0;
}
    
      

Measured memory_bytes: 5752
n = int(input())
s = int(input())

import math

ans = float('inf')

if s == n:
    print(n+1)
    exit()

for b in range(2, 10**6):
    res = n
    tmp = 0
    while res > 0:
        tmp += res % b
        res = (res-res % b)//b
    if tmp == s:
        ans = min(ans, b)

if n < 10**6:
    print(ans if ans != float('inf') else -1)
    exit()

for p in range(1, 10**6):
    if (n-s) % p != 0:
        continue
    else:
        b = (n-s)//p + 1
        if b > math.sqrt(n) and n % b == s-p:
            ans = min(ans, b)
        
print(ans if ans != float('inf') else -1)


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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	bool flag = true;
	while(a > 0 && c > 0){
		if(flag){
			c = c - b;
		}else{
			a = a - d;
		}
		flag =!flag;
	}
	cout << (a > 0 ? "Yes" : "No" )<< endl;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int n;
string s;
bool check(int x) {
    map<string,int> v;
    for(int i = 1; i <= n + 1 - x; i++) {
        string a = s.substr(i - 1, x);
        if(v[a]) {
            if(i - v[a] >= x) return true;
        }
        else v[a] = i;
    }
    return false;
}
int main() {
    cin >> n >> s;
    int l = 0, r = n;
    while(l <= r) {
        int m = (l + r) >> 1;
        if(check(m)) l = m + 1;
        else r = m - 1;
    }
    cout << r << endl;
}


Measured memory_bytes: 6660
import sys

stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

n = ni()
d = dict()
for _ in range(n):
    x = input()
    if x not in d: d[x] = 0
    d[x] += 1
f = max(d.values())
l = [x for x in d if d[x] == f]
l.sort()
print(*l, sep='\n')


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

using namespace std;

int n,i,k,j;
int tablica[100003];
int dp[100003];

int main() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for(i=0;i<n;i++){
        cin >> tablica[i];
    }
    fill(dp+1,dp+n,1000000000);
    for(i=1;i<n;i++){
        for (j=1;j<= min(i,k);j++){
            dp[i] = min(dp[i], dp[i-j]+abs(tablica[i-j]-tablica[i]));
        }
    }
    cout << dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        if (a == 3 || a == 5 || a == 7) {
            System.out.println("YES");
        } else {
            System.out.println("NO");
        }
    }
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  int count = 0;
  for (int i = a; i < b+1; i++) {
    if (i%c == 0) {
      count++;
    }
  }
  cout << count <<endl;
}


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

typedef long long ll ; 
typedef unsigned long long ull ; 
typedef vector<int> vi ; 
typedef vector<vi> vii ;
typedef vector<ll> vl ;
typedef vector<vl> vll ;
typedef set<int> si ; 
typedef map<int,int> mii ; 
typedef map<ll,ll>  mll ; 
typedef map<string,int> msi ;
typedef set<ll> sl ; 
typedef set<char> sc ; 
typedef pair<int,int> pii ;


#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1 << 29 ; 
#define MOD (ll)(1e9+7)
#define eps 1e-6
#define pb push_back 
#define mp make_pair 
#define DEBUG(x)		cout << '>' << #x << ':' << x << endl;
#define F first 
#define S second 

int main() 
{
	ios::sync_with_stdio(0) ;
	int n;
	cin >> n;
	int h[n];
	REP(i,n) cin >> h[i];
	
	int dp[n+5];
	REP(i,n+5) dp[i] = INT_MAX;
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	for(int i = 2; i < n; ++i) {
		dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]) , dp[i-2] + abs(h[i] - h[i-2]));
	}
	cout << dp[n-1] << endl;

	return 0 ; 
}


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

using namespace std;

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

  return 0;
}

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

int main(){
  int n;cin>>n;
  int p[n];
  rep(i,n){
    int x;cin>>x;
    p[x-1]=i;
    }
  rep(i,n)cout<<30000*(i+1)+p[i]<<" ";
  cout<<endl;
  rep(i,n)cout<<30000*(n-i)<<" ";
  cout<<endl;
  return 0;
  }
       

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		int a=Math.min(B/A, C);

		System.out.println(a);
	}
}

Measured memory_bytes: 23636
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		double r = sc.nextDouble();
		double a=r*r*Math.PI;
		double l=2*r*Math.PI;
		
		System.out.println((String.format("%.6f", a))+" "+(String.format("%.6f", l)));


	}

}


Measured memory_bytes: 28236
H,W = [int(i) for i in input().split()]
grid = [input() for i in range(H)]
dp = [[0]*(W+1) for i in range(H+1)]
for i in range(1,H+1):
    for j in range(1,W+1):
        if grid[i-1][j-1] == ".":
            dp[i][j] = dp[i-1][j] + dp[i][j-1]
        if i == j == 1:
            dp[i][j] = 1
print(dp[-1][-1]%(10**9+7))

Measured memory_bytes: 209780
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <queue>
#include <cstdio>
#include <cmath>
#define RG register
#define il inline
#define iter iterator
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
using namespace std;
typedef long long ll;
const int N=100005;
int n,m;
struct node{
	int x,y;
}a[N];
ll ans=0;
void work()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	ll tot=0,li=0;m++;
	for(int i=30;i>=0;i--){
		if(m&(1<<i)){
			li^=(1<<i);tot=0;
			for(int j=1;j<=n;j++)
				if((a[j].x&li)==0)tot+=a[j].y;
		   ans=Max(tot,ans);
			li^=(1<<i);
		}
		else li^=(1<<i);
	}
	printf("%lld\n",ans);
}

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


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i = 0; i < (n); i++)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())
typedef long long ll;

int n;

int main(int argc, char const *argv[]) {
	ios_base::sync_with_stdio(false);
	cin >> n;
	ll cnt = 0, last = 0;
	FOR(i, n) {
		ll a;
		cin >> a;
		if (last == 1 && a > 0) {
			a--;
			cnt++;
		}
		cnt += a/2;
		last = a % 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll inf = LLONG_MAX/4;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  ll n,k;
  cin >> n >> k;
  vector<ll> h(n),cost(n,inf);
  for(ll i = 0; i < n; ++i) cin >> h[i];
  cost[0] = 0;
  for(ll i = 1; i < n; ++i){
    for(ll j = 1; j <= min(i,k); ++j){
      cost[i] = min(cost[i],cost[i-j]+abs(h[i]-h[i-j]));
    }
  }
  cout << cost[n-1];
  return 0;
}

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

int main(){
    int n, w; cin >> n >> w;
    vector<vector<int> > dp(n+1, vector<int>(w+1, 0));
    vector<int> W(n);
    vector<int> V(n);
    for(int i = 0; i < n; i++){
        cin >> V[i] >> W[i];
    }
    int ans = 0;
    for(int i = 1; i <= n; i++){
        for(int l = 0; l <= w; l++){
            if(l-W[i-1] >= 0){
                dp[i][l] = max(dp[i-1][l], dp[i-1][l-W[i-1]] + V[i-1]);
            }else{
                dp[i][l] = dp[i-1][l];
            }
            ans = max(ans, dp[i][l]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6840
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    VL cnt(112345);
    VL A(N);
    LL sum = 0;
    REP(i,N){
        cin >> A[i];
        cnt[A[i]]++;
        sum += A[i];
    }
    int Q; cin >> Q;
    REP(i,Q){
        int B,C; cin >> B >> C;
        sum -= B * cnt[B];
        sum += cnt[B] * C;
        cnt[C] += cnt[B];
        cnt[B] = 0;
        cout << sum << endl;
    }

}

Measured memory_bytes: 4764
def main
  h = gets.chomp.to_i
  if h == 0
    puts 0
    return
  elsif h == 1
    puts 1
    return
  end

  h2 = h / 2
  n = 1
  loop do
    if 2 ** n > h2
      puts (2 ** (n+1) - 1)
      return
    end
    n = n + 1
  end
end

main

Measured memory_bytes: 1788
def rt(i):
    while i!=G[i][0]:
        i = G[i][0]
    return i
N,M = map(int,input().split())
G = {i:[i,1] for i in range(1,N+1)}
for _ in range(M):
    X,Y,Z = map(int,input().split())
    rx = rt(X)
    ry = rt(Y)
    if rx!=ry:
        if G[rx][1]>=G[ry][1]:
            G[ry][0] = rx
            G[rx][1] += G[ry][1]
        else:
            G[rx][0] = ry
            G[ry][1] += G[rx][1]
cnt = 0
A = []
for i in range(1,N+1):
    A.append(rt(i))
A = list(set(A))
print(len(A))

Measured memory_bytes: 32544
#include <bits/stdc++.h>
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;
  

int main(){
    int len_array,num_query;
    int command,key,val;
    
    scanf("%d %d",&len_array,&num_query);
    vector<vector<int>> int_array(len_array); 

    for(int i = 0; i < num_query;i++){
        scanf("%d %d",&command,&key);
        if(command == 0){
            scanf("%d",&val);
            int_array[key].push_back(val);
        }else if(command == 1){
            if(!int_array[key].empty()){
                for(int j = 0;j < int_array[key].size();j++){
                    if(j != (int)int_array[key].size()-1) printf("%d ",int_array[key][j]);
                    else printf("%d",int_array[key][j]);
                }
            }
            printf("\n");
        }else if(command == 2){
            int_array[key].clear();
        }
    }
    return 0;
}


Measured memory_bytes: 5816
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
using namespace std;
typedef unsigned long long ui64;
typedef long long i64;
void Multipleof2andN(){
	i64 N;
	cin >> N;
	if (N % 2 == 0) {
		cout << N;
	}else{
		cout << (N * 2);
	}
}
int main() {
	Multipleof2andN();
	return 0;
}


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

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

    map<ll, int> a;
    rep(i, 0, n)
    {
        int aa;
        cin >> aa;
        a[aa] ++;
    }

    bool ans = true;

    vector<ll> values;
    vector<int> cnts;
    for (auto v_cnt: a)
    {
        values.push_back(v_cnt.first);
        cnts.push_back(v_cnt.second);
    }

    if (a.size() == 3)
    {
        int cnt = cnts[0]; 
        rep(i, 0, 3)
            ans &= cnt == cnts[i];
        ans &= (values[0] ^ values[1]) == values[2];
    }
    else if (a.size() == 2)
    {
        int i = 0, j = 1;
        if (cnts[0] > cnts[1])
            i = 1, j = 1;
        ans &= 2 * cnts[i] == cnts[j];
        ans &= (values[i] ^ values[j]) == values[j];
    }
    else if (a.size() == 1)
    {
        ans &= values[0] == 0;
    }
    else
        ans = false;
    // cout << ((values[0] ^ values[1]) == values[2]) << ' ' << cnt << ' ' << a.size() << endl;

    if(ans)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 6648
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val a = (0 until n).map {
        sc.nextInt()
    }
 
    abc154c(n ,a)
}
 
fun abc154c(n: Int, a: List<Int>) {
    val a = a.sorted()
    var ans = "YES"
    var pre = 0
    for (i in 0 until n) {
        if (a[i] == pre) {
            ans = "NO"
            break
        }
        pre = a.get(i)
    }
 
    println(ans)
}

Measured memory_bytes: 76420
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>
#define vecb vector<bool>
#define vecd vector<double>
template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<long long int>> &v)
{
	for (size_t i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (size_t k = 1; k < v.size(); k++)
	{
		for (size_t j = 1; j < k; j++)
		{
			v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
		}
	}
}
ll repeat_squaring(ll n, ll p, ll m)
{
	if (p == 0)
		return 1;
	if (p % 2 == 0)
	{
		ll t = repeat_squaring(n, p / 2, m);
		return t * t % m;
	}
	return n * repeat_squaring(n, p - 1, m);
}

int main()
{
	int n;
	cin >> n;
	vector<int> v(100005, 0);
	rep(i, n)
	{
		int tmp;
		cin >> tmp;
		v[tmp]++;
	}
	int ans = 0;
	for (size_t i = 1; i < 100002; i++)
	{
		ans = max(ans, v[i - 1] + v[i] + v[i + 1]);
	}
	cout << ans << endl;

	return 0;
}

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

using namespace std;
long long dp[3005][3305];

int main() {
    string s, t;
    cin >> s >> t;
    string ans;
    int n = s.length();
    int m = t.length();
    memset(dp, 0, sizeof(dp));
    for (int i = n - 1; i >= 0; i--) {
        for (int j = m - 1; j >= 0; j--) {
            if (s[i] == t[j]) {
                dp[i][j] = dp[i + 1][j + 1] + 1;
            } else {
                dp[i][j] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    int i = 0;
    int j = 0;
    while (i < n && j < m) {
        if (s[i] == t[j]) {
            putchar(s[i]);
            i++;
            j++;
        } else if (dp[i][j] == dp[i + 1][j]) {
            i++;
        } else {
            j++;
        }
    }

    return 0;
}

Measured memory_bytes: 77824
#include<stdio.h>
int main()
{
 	int n;
  	scanf("%d",&n);
  	int a[100];
  int p = 0;
  	for(int i = 1 ; i <= 9 ; i++)
      for(int j = 1 ; j <=9 ; j++)
          a[++p] = i * j;
  int count = 0;
  for(int i = 1 ; i <= p ; i++)
  {
   	if(a[i] == n)
    {
      count = 1;
      break;
    }
    
  }
  if(count) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 128
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
//package dp;

/**
 *
 * @author aakas
 */
import java.util.*;
public class Main {
    static int n;
    static int k;
    static boolean[] v1;
    static int[] dp4;
    static int[] height;
    public static void main(String args[])
    {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        k = sc.nextInt();
        v1 = new boolean[n];
        dp4 = new int[n];
        height = new int[n+k+1];
        for(int i=0;i<n;i++)
        {
            height[i] = sc.nextInt();
        }
        for(int i=0;i<=k;i++)
        {
            height[n+i] = 100000;
        }
        System.out.println(dp3(0));
    }
    public static int dp3(int i)
    {
        if(i==n-1)
            return 0;
        if(i>=n)
            return 100000;
        if(v1[i])
            return dp4[i];
        v1[i] = true;
        dp4[i] = Integer.MAX_VALUE;
        for(int j=1;j<=k;j++)
        {
            dp4[i]=Math.min(dp4[i],dp3(i+j)+Math.abs(height[i+j]-height[i]));
        }
        return dp4[i];
       
    }
}


Measured memory_bytes: 70932
#include <stdio.h>

int main(){
    long int a,b,k;
    scanf("%ld %ld %ld",&a,&b,&k);
    if(a>k){
        printf("%ld %ld\n",a-k,b);
    }
    else if(a+b>k){
        printf("%d %ld\n",0,a+b-k);
    }
    else{
        printf("%d %d\n",0,0);
    }
}

Measured memory_bytes: 128
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int main(){
  int i,j;
  int a[17][16],b[17][16],w,h;
  int sm;
  while(cin>>w>>h&&w+h){
    memset(a,-1,sizeof(a));
    for(i=0;i<h;i++){
      for(j=1;j<w+1;j++){
	cin>>a[j][i];
	a[j][i]*=-1;
      }
    }
    for(i=1;i<w+1;i++)
      a[i][h]=0;
    memset(b,0,sizeof(b));
    for(i=1;i<w+1;i++){
      if(a[i][0]==0)
	b[i][0]=1;
    }
    for(i=0;i<h-1;i++){
      for(j=1;j<w+1;j++){
	if(b[j][i]){
	  if(a[j][i]){
	    if(a[j][i+2]==0||a[j][i+2]==-2)
	      b[j][i+2]+=b[j][i];
	  }else{
	    if(a[j-1][i+1]==0)
	      b[j-1][i+1]+=b[j][i];
	    if(a[j+1][i+1]==0)
	      b[j+1][i+1]+=b[j][i];
	    if(a[j][i+1]==0||a[j][i+1]==-2)
	      b[j][i+1]+=b[j][i];
	  }
	}
      }
    }
    sm=0;
    for(i=1;i<w+1;i++)
      sm+=b[i][h-1]+b[i][h];
    cout<<sm<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize ("Ofast")
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

using namespace __gnu_pbds;
using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<long long,long long> ii; 	
typedef complex<long double> com;

const ll mod = 1e9+7;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
   ll n;
   cin >> n;
   vector <ll>arr(n);
   map <ll,ll> mapp;
   for (int z=0;z<n;z++){
      cin >> arr[z];
      mapp[arr[z]]++;
   }
   sort(arr.begin(),arr.end());
   vector <bool> sieve(1e6+1,false);
   ll ans = 0;
   for (int z=0;z<n;z++){
      ll temp = arr[z];
      if (sieve[arr[z]]) continue;
      if (mapp[arr[z]] == 1)
      ans++;
      while (temp < sieve.size()){
         sieve[temp] = true;
         temp += arr[z];
      }
   }
   cout << ans << endl;
} 

Measured memory_bytes: 17464
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        a--;
    }
    return ans;
}
int main(){
    ll n,k,count=0;
    cin >> n >> k;
    vector<pair<ll,ll>> v(n);
    rep(i,n){
        cin >> v[i].fi >> v[i].se;
    } 
    sort(all(v));
    rep(i,n){
        count+=v[i].se;
        if(count>=k){
            cout << v[i].fi << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep0(i,n) for(i=0;i<n;i++)
#define test(a) cout << "*" << a << endl;
#define ll long long
int main(){
  int i,j,k;
  int N;
  int x[100];
  int y[100];
  ll h[100];
  ll tmpH;
  ll H;
  int xC,yC;
  bool exist = false;
  int count=0;
  
  cin >> N;
  rep0(i,N){
    cin >> x[i] >> y[i] >> h[i];
  }
  rep0(i,101){
    if(exist)
      break;
    rep0(j,101){
      if(exist)
        break;
      rep0(k,N){
        if(h[k]!=0)
          tmpH = h[k] + abs(x[k]-i/*xC*/) + abs(y[k]-j/*yC*/);
      }
      rep0(k,N){
        if(h[k]==0){
          if(0 != max(tmpH-abs(x[k]-i/*xC*/)-abs(y[k]-j/*yC*/),(ll)0) )  
            break;
        }      
        else{
          if(h[k] != tmpH-abs(x[k]-i/*xC*/)-abs(y[k]-j/*yC*/))
            break;        
        }         
        /*else if(h[k]!=0 && count==0){
          tmpH = h[k] + abs(x[k]-i) + abs(y[k]-j);
          count += 1;
        }
        H = h[k] + abs(x[k]-i) + abs(y[k]-j);
        if(H != tmpH){
          break;
        }*/        
        if(k==N-1){
          exist = true;
          xC = i;
          yC = j;
          break;
        }       
      }
      count = 0;
      
    }
  }
  
  cout << xC << " " << yC << " " << tmpH << endl;
  
 
  
  
}

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

void ichigoYes(int &cnt,int a,int h,int w,vector<string> &s,
               vector<vector<int>> &ans){
  /* ichigoがあるa行目。xxxxxoxxxxxooxxxxoxxって感じ
   基本的に左と同じ分類にする。1111o1111o222o333って感じ
  */
  bool firstichigo = true;
  for (int i=0; i<w; i++){
    if (firstichigo){
      if (s.at(a).at(i)=='#'){
        for (int j=0; j<=i; j++) ans.at(a).at(j) = cnt;
        firstichigo = false;
      }
    }else if(s.at(a).at(i)=='#'){
      cnt++; ans.at(a).at(i) = cnt;
    }else{
      ans.at(a).at(i) = cnt;
    }
  }
  cnt++;
  return;
}

void ichigoNo(int a,int h,int w,vector<string> &s,
               vector<vector<int>> &ans){
  /* ichigoがないa行目。上側と一緒にする */
  for (int i=0; i<w; i++){
    ans.at(a).at(i) = ans.at(a-1).at(i);
  }
  return;
}

void ichigoNoV2(int a,int h,int w,vector<string> &s,
               vector<vector<int>> &ans){
  /* ichigoがないa行目。下側と一緒にする */
  for (int i=0; i<w; i++){
    ans.at(a).at(i) = ans.at(a+1).at(i);
  }
  return;
}

void solve(int h,int w,int k,vector<string> &s,
           vector<bool> &noichigo,
           vector<vector<int>> &ans){
  
  int checkindex = -1;
  for (int i=0; i<h; i++){
    if (noichigo.at(i) == false) break;
    else checkindex = i;
    // xxxooooxxxoxoxoxoxxx なら左から3番目がcheckindex
  }
  int cnt = 1;
  for (int i=0; i<h; i++){
    // とりあえずイチゴのある行を埋める
    if (!noichigo.at(i)){
      ichigoYes(cnt,i,h,w,s,ans);
    }
  }
  if (checkindex != -1){
    for (int i=0; i<=checkindex; i++){
      ichigoNoV2((checkindex-i),h,w,s,ans);
    }
  }
  for (int i=checkindex+1; i<h; i++){
    if (noichigo.at(i)){
      ichigoNo(i,h,w,s,ans);
    }
  }
  
  return;
}

int main() {
  int h,w,k; cin >>h >>w >>k;
  vector<string> s(h);
  for (int i=0; i<h; i++) cin >>s.at(i);
  vector<bool> noichigo(h);
  // i行目にイチゴなかったらtrueにしとくつもり
  vector<vector<int>> ans(h, vector<int>(w,0));
  int cnt = 1;
  bool ichigo;
  for (int i=0; i<h; i++){
    ichigo = false;
    for (int j=0; j<w; j++){
      if (s.at(i).at(j) == '#'){
        ans.at(i).at(j) = cnt; cnt++;
        ichigo = true;
      }
    }
    if (!ichigo) noichigo.at(i) = true;
    // i行目にはichigoなかったよー
  }
  
  solve(h,w,k,s,noichigo,ans);
  // ansにはとりあえずichigoに番号を振ってある感じ
  for (int i=0; i<h; i++){
    for (int j=0; j<w; j++){
      cout <<ans.at(i).at(j);
      if (j==w-1) cout <<endl;
      else cout <<" ";
    }
  }
}


Measured memory_bytes: 1280
function main()
n=parse(Int,readline())
a=map(x->parse(Int,x),split(readline()))
r=maximum(a)
l=-1
while r-l>1
	b=zeros(2*n)
	m=div(r+l,2)
	s=n
	b[s]=1
	N=c=0
	for i=1:n
		if a[i]>m
			s+=1
			N-=b[s]
		else
			N+=b[s]
			s-=1
		end
		c+=N
		b[s]+=1
	end
	if c*4>n*(n+1)
		r=m
	else
		l=m
	end
end
println(r)
end
main()

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

int main() {
  char c;
  cin >> c;
  
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  }
  else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

template <class M, class N>
common_type_t<M, N> gcd(M a, N b) {
  if (b == 0) {
    return a;
  } else {
    return gcd(b, a % b);
  }
}

int main(int argc, const char *argv[]) {
  int k, ans = 0;
  cin >> k;

  for (int a = 1; a <= k; a++) {
    for (int b = 1; b <= k; b++) {
      for (int c = 1; c <= k; c++) {
        ans += gcd(gcd(a, b), c);
      }
    }
  }

  cout << ans << '\n';

  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define concat(xs, ys) (xs).insert((xs).end(), (ys).begin(), (ys).end())

const int mod = 1000000007;

struct edge {
    int to;
    long cost;
};

const int MAX_V = 100005;
vector<edge> G[2][MAX_V];
long d[2][2][MAX_V];
int n;

void dijkstra(int s, int g, int sid) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d[sid][g], d[sid][g]+n, INF*INF);
    d[sid][g][s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        int v = p.second;
        if (d[sid][g][v] < p.first) continue;

        for (int i=0; i<G[g][v].size(); ++i) {
            edge e = G[g][v][i];
            if (d[sid][g][e.to] > d[sid][g][v] + e.cost) {
                d[sid][g][e.to] = d[sid][g][v] + e.cost;
                que.push(P(d[sid][g][e.to], e.to));
            }
        }
    }
}

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

  int m, s, t;
  cin >> n >> m >> s >> t;
  s--;
  t--;

  rep(i, m) {
    int u, v;
    long a, b;
    cin >> u>>v>>a>>b;
    u--;
    v--;
    G[0][u].push_back({v, a});
    G[0][v].push_back({u, a});
    G[1][u].push_back({v, b});
    G[1][v].push_back({u, b});
  }

  dijkstra(s, 0, 0);
  dijkstra(s, 1, 0);

  dijkstra(t, 0, 1);
  dijkstra(t, 1, 1);

  long res = INF * INF;
  vector<long> v;
  for(int j = n-1; j >= 0; j--) {
    res = min(res, d[0][0][j] + d[1][1][j]);
    v.push_back(1000000000000000L - res);
  }
  reverse(v.begin(), v.end());
  rep(i, v.size()) {
    cout << v[i] << endl;
  }
}

Measured memory_bytes: 21512
#include <cstdio>
#define ll long long
using namespace std;
ll a[1010],sum[1000010];
int n,m,cnt=0;
int main ()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		ll tot=0;
		for(int j=i;j<=n;j++) tot+=a[j],sum[++cnt]=tot;
	}
	ll ans=0;
	for(int j=44;j>=0;j--)
	{
		int num=0;
		for(int i=1;i<=cnt;i++) if((sum[i]>>j)&1) num++;
		if(num>=m)
		{
			ans|=(1ll<<j);
			for(int i=1;i<=cnt;i++)
				if(!((sum[i]>>j)&1)) sum[i]=0;
		}
	}
	printf("%lld",ans);
	return 0;
}
		

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

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

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

  ll sum=a+b;
  ll ans=n/sum*a + min(a,n%sum);
  cout<<ans<<endl;

}


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

using namespace std;

int main(){
	int n; cin >> n;
	vector<int> P(n,0);
	for(int i = 0; i < n; ++i)cin >> P[i];
	int wall = 1;
	long long ans = 0;
	ans += (long long)P[0] -1;
	wall++;
	
	for(int i = 1; i < n; ++i){
		if(P[i] < wall) continue;
		else if(P[i] == wall){
			wall++;
			continue;
		}
		else{
			ans += (long long)(P[i] - 1)/ wall;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>
#include <math.h>
#define lop(i, n) for(i=1; i<=n; i++)

int main()
{
	int x, cnt=0;
	
	scanf("%d", &x);
	
	while(x >= 500){
		x=x-500;
		cnt+=1000;
	}
	
	while(x >= 5){
		x=x-5;
		cnt+=5;
	}
	
	printf("%d", cnt);
	
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-12;
template<typename T>
inline void read(T &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=20;
int L,n=20;
struct EDGE {
	int x,y,v;
	inline void print() {
		printf("%d %d %d\n",x,y,v);
	}
}e[66]; int E=0;
inline void add(int u,int v,int w) {
	e[++E]=(EDGE) {u,v,w};
}
signed main() {
	read(L);
	int tmp=L,V=0;
	while(tmp) {
		++V; tmp>>=1;
	}
	for(int i=1;i<V;i++) {
		add(i,i+1,0);
		add(i,i+1,1<<(V-i-1));
	}
	int now=1<<(V-1);
	for(int i=V-1;i>=1;i--) {
		if(L&(1<<(i-1))) {
			add(1,V-i+1,now);
			now+=1<<(i-1);
			// L-=1<<i;
		}
	}
	printf("%d %d\n",V,E);
	for(int i=1;i<=E;i++) {
		e[i].print();
	}
	return 0;
}

Measured memory_bytes: 256
### ----------------
### ここから
### ----------------

import sys
from io import StringIO
import unittest

def yn(b):
    print("Yes" if b==1 else "No")
    return

def resolve():
    readline=sys.stdin.readline

    n,k=map(int, readline().rstrip().split())

    mod = 10**9+7
    a=0
    z=0
    ans=0
    n+=1
    for i in range(1,n+1):
        a+=i
        z+=(n-i+1)
        cnt=z-a+1
        if i>=k:
            ans+=cnt
            ans%=mod
    print(ans)

    return

if 'doTest' not in globals():
    resolve()
    sys.exit()

### ----------------
### ここまで 
### ----------------


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

ll solve() {
    ll N;
    cin >> N;
    vector<ll> f(N+1);
    for ( ll x = 1; x < 101; x++ ) {
        for ( ll y = 1; y < 101; y++ ) {
            for ( ll z = 1; z < 101; z++ ) {
                ll t = x*x + y*y + z*z + x*y + y*z + z*x;
                if ( t <= N ) {
                    f[t]++;
                }
            }
        }
    }
    for ( int i = 0; i < N; i++ ) {
        cout << f[i+1] << "\n";
    }
    return 0;
}

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

Measured memory_bytes: 3592
s=input()
n=len(s)
ng=0
for i in range(n//2):
    #print(s[i], s[-i-1])
    if s[i]!=s[-i-1]:
        ng=1

for i in range(((n-1)//2)//2):
    #print(s[i], s[-i-1+(n-1)//2])
    if s[i]!=s[-i-1+(n-1)//2]:
        ng=1

for i in range(((n-1)//2)//2):
    #print(s[i-1+(n+3)//2])
    if s[i-1+(n+3)//2]!=s[-i-1]:
        ng=1

if ng==0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,x,y,t1,t2,t3,ans;
int main()
{
	scanf("%lld%lld%lld%lld%lld",&a,&b,&c,&x,&y);
	t1=a*x+b*y;
	if(x<y) {
		t2=x*c*2+(y-x)*b;
		t3=y*c*2;
	}
	else{
		t2=y*c*2+(x-y)*a;
		t3=x*c*2;
	}
	ans=min(t1,t2);
	ans=min(ans,t3);
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
bool Check(int a,int b){
    if(a > 0){
        if(b > 0) return true;
        else return false;
    }
    else{
        if(b == 0) return true;
        else return false;
    }
}
int main(){
    
    string S; cin >> S;
    int len = S.size();
    int data[4];
    for(int i=0;i<4;i++) data[i] = 0;
    for(int i=0;i<len;i++){
        if(S[i] == 'N') data[0]++;
        else if(S[i] == 'W') data[1]++;
        else if(S[i] == 'S') data[2]++;
        else data[3]++;
    }
    
    if(Check(data[0],data[2]) && Check(data[1],data[3]) ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

using namespace std;

typedef long long ll;

#define REP(i,p,q) for(ll i = p; i < q; i++)

int main(void){
    ll x,n;
    ll ans = 0;
    cin >> x >> n;
    if(n == 0) cout << x << endl;
    else{
        vector<ll> v = vector<ll>(n);
        REP(i,0,n) cin >> v[i];

        REP(i,1,200){
            vector<ll>::iterator it = find(v.begin(), v.end(), i);
            if(it == v.end()){
                if(abs(x - ans) > abs(x - i)) ans = i;
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define REP(i, k, n) for(long long i=(long long)(k); i<(long long)(n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define PQ(T) priority_queue<T>
#define PQS(T) priority_queue<T, vector<T>, greater<T> >
#define deci cout << fixed << setprecision(15);
typedef long long ll;
const ll inf = 1020304050607080910;
const int INF = 2000000000;
const ll mod = 998244353;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
template<class T> bool chmin(T&x,T y){if(x>y){x=y;return true;}return false;}
template<class T> bool chmax(T&x,T y){if(x<y){x=y;return true;}return false;}
ll gcd(ll x,ll y){if(x>y)swap(x, y);while(x!=0){y%=x;swap(x, y);}return y;}
ll mpow(ll x,ll r){if(r==0)return 1;if(r%2==1){return x*mpow(x,r-1)%mod;}else{ll aa=mpow(x,r/2);return aa*aa%mod;}}

ll dp[200010], sum[200010];

int main(){
	ll N, K; cin >> N >> K;
	ll L[K], R[K];
	rep(i, K) cin >> L[i] >> R[i];
	sum[0] = 0, dp[0] = 0;
	dp[1] = 1, sum[1] = 1;
	for(int i=2; i<=N; i++){
		rep(j, K){
			if(i - L[j] >= 1) dp[i] = (dp[i] + sum[i-L[j]] + mod - sum[max((ll)1, i-R[j])-1]) % mod;
		}
		sum[i] = (sum[i-1] + dp[i]) % mod;
	}
	cout << dp[N] << endl;
	return 0;
}


Measured memory_bytes: 6744
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define X first
#define Y second

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

int dx[] = { 1, 1, 0,-1,-1, 0};
int dy[] = { 0, 1, 1, 0,-1,-1};

const int kOffset = 100;

int main(void){
    for(int n, t, res; cin >> t >> n, t; cout << res << endl){
        res = 0;

        vvi used, hasTrap;
        used = hasTrap = vvi(2 * kOffset, vi(2 * kOffset));

        rep(i, n){
            int x, y; cin >> x >> y;
            x += kOffset; y += kOffset;

            hasTrap[y][x] = true;
        }

        pii s; cin >> s.X >> s.Y;
        s.X += kOffset; s.Y += kOffset;

        queue< pair<pii, int> > q;
        q.push(mp(s, 0));

        while(!q.empty()){
            pii cur_pos = q.front().first;
            int cur_turn = q.front().second;
            q.pop();

            if(used[cur_pos.Y][cur_pos.X] || hasTrap[cur_pos.Y][cur_pos.X] || t < cur_turn) continue;

            used[cur_pos.Y][cur_pos.X] = true;
            res++;

            rep(i, 6){
                pair<pii, int> next(mp(cur_pos.X + dx[i], cur_pos.Y + dy[i]), cur_turn + 1);
                q.push(next);
            }
        }
    }

	return 0;
}

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

#define Online 1
// #define multitest 1
// #define Debug
typedef long long ll;
typedef long double ld;
#define f first
#define s second
#define pb push_back
#define mp make_pair
const long long mod = 1000000007;
const long long High = 1e16;
void ControlIO();
void TimerStart();
void TimerStop();
#ifdef Debug
#define db(...) ZZ(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void ZZ(const char *name, Arg1 &&arg1)
{
	std::cerr << name << " = " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void ZZ(const char *names, Arg1 &&arg1, Args &&... args)
{
	const char *comma = strchr(names + 1, ',');
	std::cerr.write(names, comma - names) << " = " << arg1;
	ZZ(comma, args...);
}
#else
#define db(...)
#endif

void solve()
{
	int n;
	cin >> n;
	vector<int> V(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> V[i];
		V[i]--;
	}
	stack<int> St;
	int size = n;
	while (size > 0)
	{
		int i;
		bool t = false;
		for (i = size - 1; i >= 0; --i)
		{
			if (V[i] == i)
			{
				St.push(V[i]);
				for (int j = i; j < size; ++j)
				{
					V[j] = V[j + 1];
				}
				size--;
				t = true;
				break;
			}
		}
		if (t)
			continue;
		cout << -1 << '\n';
		return;
	}
	while (!St.empty())
	{
		cout << St.top() + 1 << '\n';
		St.pop();
	}
	cout << '\n';
}

main()
{
	ControlIO();
	int t = 1;
#ifdef multitest
	cin >> t;
	// cout << t << '\n';
#endif
	TimerStart();
	while (t--)
		solve();
	TimerStop();
	return 0;
}

void ControlIO()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
#ifndef Online
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

auto TimeStart = chrono::steady_clock::now();
auto TimeEnd = chrono::steady_clock::now();

void TimerStart()
{
#ifndef Online
	TimeStart = chrono::steady_clock::now();
#endif
}

void TimerStop()
{
#ifndef Online
	TimeEnd = chrono::steady_clock::now();
	auto ElapsedTime = TimeEnd - TimeStart;
	cout << "\n\nTime elapsed: " << chrono::duration<double>(ElapsedTime).count() << " seconds.\n";
#endif
}

Measured memory_bytes: 256
a,b,c,d = map(int,input().split())

if b>=0 and d>=0:
    print(max(b*d,a*c))
if b>=0 and d<0:
    print(max(b*d,max(a*c,a*d)))
if b<0 and d>=0:
    print(max(b*d,max(a*c,b*c)))
if b<0 and d<0:
    print(a*c)

Measured memory_bytes: 9192