akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;

const int MAX_N = 1000;
const int MAX_M = MAX_N * (MAX_N) / 2;

int n, m;
int a[MAX_N][MAX_N - 1];
int id[MAX_N][MAX_N];
vector<vector<int>> g;

bool visited[MAX_M];
bool calculated[MAX_M];
int memo[MAX_M];

int dfs(int to) {
  if (visited[to]) {
    if (!calculated[to]) {
      return -1;
    }
    return memo[to];
  }
  memo[to] = 0;
  visited[to] = true;
  for (auto next : g[to]) {
    int res = dfs(next);
    if (res == -1) {
      return -1;
    }
    memo[to] = max(memo[to], dfs(next) + 1);
  }
  calculated[to] = true;
  return memo[to];
}

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      id[i][j] = -1;
    }
  }
  m = n * (n - 1) / 2;
  g.resize(m);
  int id_cnt = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n - 1; j++) {
      cin >> a[i][j];
      a[i][j]--;
      if (id[i][a[i][j]] < 0) {
        id[i][a[i][j]] = id_cnt;
        id[a[i][j]][i] = id_cnt;
        id_cnt++;
      }
      if (0 < j) {
        g[id[i][a[i][j - 1]]].push_back(id[i][a[i][j]]);
      }
    }
  }
  int ans = 0;
  for (int i = 0; i < m; i++) {
    int res = dfs(i);
    if (res == -1) {
      cout << -1 << endl;
      return 0;
    }
    ans = max(ans, res + 1);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 40884
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main(){
    int n,k;
    cin >> n >> k;
    vint p(n);
    cin >> p;
    int max = 0;
    int idx = 0;
    for(int i=0; i<k;i++){
        max += p[i];
    }
    int tmp = max;
    for(int i=k; i<n;i++){
        tmp += p[i];
        tmp -= p[i-k];
        if(max < tmp){
            max = tmp;
            idx = i-k+1;
        }
    }
    double ans = 0;
    for(int i=idx;i<(idx+k);i++){
        ans += (p[i]+1)/((double)2);
    }
    cout << fixed << setprecision(10) <<ans << endl;

}

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

int n,pos;
string S1,S2;

int main()
{
	cin>>n>>S1>>S2;
	long long ans;
	bool v;
	if(S1[0]==S2[0])
	{
		ans=3;
		pos++;
		v=true;
	}
	else
	{
		ans=6;
		pos+=2;
		v=false;
	}
	while(pos<n)
	{
		if(S1[pos]==S2[pos])
		{
			if(v)
				ans*=2;
			pos++;
			v=true;
		}
		else
		{
			if(v)
				ans*=2;
			else 
				ans*=3;
			pos+=2;
			v=false;
		}
		if(ans>=1000000007)
			ans%=1000000007;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);

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

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

  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += p[i];
  }

  cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
string s;
int main(){
	cin>>s;
	int l=s.size();
	bool CC=false; 
	for(int i=0;i<l;i++){
		if(s[i]=='C')CC=true;
		if(s[i]=='F'&&CC){
			cout<<"Yes"; 
			return 0;
		}
	} 
	cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int i,n,m;
    for(i=1;;i++){
        scanf("%d %d",&n,&m);
        if (n!=0 || m!=0){
            if(n<m)
                printf("%d %d\n",n,m);
            else
                printf("%d %d\n",m,n);
        }else
            break;
    }
    return 0;
}


Measured memory_bytes: 2036
/*Shivam Bhalla */
/* f2016941@pilani.bits-pilani.ac.in */



#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <iostream>
#include <string>
#include <cmath>
#include <cassert>
#include <bits/stdc++.h>
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
using namespace std;
long long maxv = 1e9;

int main() {
  int N;
  cin>>N;
  int total=0;
  map<int,int>m;
  while(true){
    if(m.find(N)==m.end())
      m[N]=1;
    else
      break;
    if(N%2==0)
      N=N/2;
    else
      N=(3*N)+1;
    total+=1;
  }
  cout<<total+1;
  return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	int a,b;
	cin>>a>>b;
	if(a%3==0||b%3==0||(a+b)%3==0) cout<<"Possible"<<endl;
	else cout<<"Impossible"<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

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

int main(){

	ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0);

	string s;	
	cin >> s;

	int a , b;
	bool f1 = 1 , f2 = 1;

	for(int i = 0 ; i < s.size() ; i++){	   
	  
	   int t = max(i ,(int) s.size() - i - 1);

	   if(s[i] == '1'){
			if(f1)
			   a = t;
			else
			   a = min(a , t);
			f1 = 0;   
	   }
	   else{
		  if(f2)
			 b = t;
		  else
			 b = min(b , t);
		  
		  f2 = 0;
	   }
	}
		
	if(f1 && !f2)
	   cout << s.size();
	else if(f2 && !f1)
	   cout << s.size();
	else
	   cout << max(a , b);
	
	cout << endl;
	return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;

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

        int result = 0;
        int max = 0;
        for (int i = 0; i < n; i++) {
            int a = scanner.nextInt();
            if (a >= max) {
                max = a;
                result++;
            }
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  long int N;
  cin >> N;
  vector<int> A(N);
  vector<int> out(N, 0);
  for(int i = 0; i < N; i++){
    cin >> A.at(i);
  }
  for(int i = N - 1; i > (-1); i--){
    int syo = N / (i + 1);
    int sum = 0;
    for(int j = 1; j < syo + 1; j++){
      sum += out.at((i + 1) * j - 1);
    }
    if(sum % 2 != A.at(i)){
      out.at(i) = out.at(i) * (-1) + 1;
    }
  }
  int M = 0;
  for(int i = 0; i < N; i++){
    if(out.at(i) == 1){
      M++;
    }
  }
  cout << M << endl;
  for(int j = 0; j < N; j++){
    if(out.at(j) == 1){
    cout << j + 1 << " ";
    }
  }
    return 0;
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
	bool loop=true;
	while (loop) {
		int n, x;
		cin >> n >> x;
		if ((n==0)&&(x==0)) {
			loop = false;
			break;
		}

		int cnt=0;
		for (int i=1; i<=n-2; i++) {
			for (int j=i+1; j<=n-1; j++) {
					if (j<x-i-j && x-i-j<=n) cnt++;
			}
		}
		cout << cnt << endl;
	}
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long ll;
typedef pair<ll,ll> P;


int n, a, b;
string s;

int main(){
	cin >> n >> a >> b;
	cin >> s;
	
	int cnta = 0, cntb = 0;
	for(int i = 0; i < n; i++){
		if(s[i] == 'a' && cnta+cntb < a+b){ cout << "Yes" << endl; cnta++;}
		else if(s[i] == 'b' && cnta+cntb < a+b && cntb < b){ cout << "Yes" << endl; cntb++;}
		else cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <iomanip>
#include <map>
using namespace std;

void solve(){
  int n; cin >> n;
  int p[n]; for(int i = 0; i < n; i++) cin >> p[i];
  int i;
  for(i = 0; i < n - 1; i++){
    if(p[i] > p[i + 1]) break;
  }
  if(i == n - 1) cout << "YES\n";
  else{
    int minx = p[i], minj = i;
    for(int j = i + 1; j < n; j++){
      if(p[j] < minx){
        minx = p[j];
        minj = j;
      }
    }
    int t = p[minj];
    p[minj] = p[i];
    p[i] = t;
    int j;
    for(j = 0; j < n - 1; j++){
      if(p[j] > p[j + 1]) break;
    }
    if(j == n - 1) cout << "YES\n";
    else cout << "NO\n";
  }
  return;
}

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


Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

int main()
{
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, val;

    cin>>n;

    set<int> s;
    for(int i = 0; i < n; i++){
        cin>>val;
        s.insert(val);
    }

    if(s.size() == n){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }

    return 0;
}


Measured memory_bytes: 9600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
string a,b;
set<char> cnt[27];
set<char> cnt2[27];

int main(){
	cin>>a>>b;
	for(ll i=0;i<ll(a.size());i++){
		cnt[a[i]-'a'].insert(b[i]);
		cnt2[b[i]-'a'].insert(a[i]);
	}

	for(ll i=0;i<26;i++){
		if(cnt[i].size()>1||cnt2[i].size()>1){
			cout<<"No"<<endl;
			return 0;
		}
	}

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

Measured memory_bytes: 776
import sys

import numba as nb
import numpy as np

input = sys.stdin.readline


@nb.njit("i8(i8,i8,i8[:],i8[:])")
def solve(N, W, w, v):
    dp = np.full(shape=(N + 1, np.sum(v) + 1), fill_value=(N * W), dtype=np.int64)
    dp[:, 0] = 0
    for i in range(N):
        np.minimum(w[i], dp[i][:v[i]], dp[i + 1][:v[i]])
        np.minimum(w[i] + dp[i][: - v[i]], dp[i][v[i]:], dp[i + 1][v[i]:])
    return np.where(dp[-1] <= W)[0][-1]


def main():
    N, W = map(int, input().split())

    w = np.empty(shape=N, dtype=np.int64)
    v = np.empty(shape=N, dtype=np.int64)
    for i in range(N):
        w[i], v[i] = map(int, input().split())

    ans = solve(N, W, w, v)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 198232
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define allr(n) (n.rbegin(), n.rend())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

int main() {
  ve<char> C(6);
  rep(i, 6){
    ci(C.at(i));
  }
  if(C.at(0) == C.at(5) && C.at(1) == C.at(4) && C.at(2) == C.at(3)){
    co("YES");
  }
  else{
    co("NO");
  }
}

Measured memory_bytes: 256
def divisors(n):
    res = []
    for d in range(1, int(n**0.5)+1):
        if n%d==0:
            res.append(d)
            res.append(n//d)
    res = sorted(set(res))
    return res

# 素因数分解
def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

N, K = map(int, input().split())
invK = modinv(K)
P = [0] * (K+1)
mod = 10**9+7
for i in range(1, K+1):
    p = pow(K//i * invK, N, mod)
    P[i] = p
KN = pow(K, N, mod)
ans = 0


# https://kazuma8128.hatenablog.com/entry/2018/07/29/231819
for i in range(K, 1, -1):
    #print(i, divisors(i))
    for d in divisors(i):
        if d!=i:
            P[d] -= P[i]
for i, p in enumerate(P[1:], 1):
    n = p * KN % mod
    #print(i, n)
    ans = (ans + n * i) % mod
print(ans)


Measured memory_bytes: 70772
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define INF             1e14
#define dd              double
#define MOD             1000000007
#define my_sizeof(type) ((char *)(&type+1)-(char*)(&type)) 
#define nl              cout<<endl
#define fill(a,val)     memset(a,val,sizeof(a))
#define mp              make_pair
#define endl            "\n"
#define pb              push_back
#define ff              first    
#define ss              second
#define SIZE            200005
#define all(v)          v.begin(),v.end()
#define s(ar,n)         sort(ar,ar+n)
#define rs(ar,n)        sort(ar, ar+n, greater<ll>()) 
#define oa(a,n)         for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n)         for(ll i=0;i<n;i++)cin>>a[i];
#define maxa(ar,N)      *max_element(ar,ar+N)
#define mina(ar,N)      *min_element(ar,ar+N)
#define fastio()        ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define printclock      cerr<<"Time : "<<1000*(long double)clock()/(long double)CLOCKS_PER_SEC<<"ms\n";
ll power(ll x, ll y){
    ll res=1;x=x;
    while(y>0){
        if(y&1)
            res = (res*x);
        y = y>>1;
        x = (x*x);
    }
    return res;
}  
ll logtwo(ll n){
    if(n==1)
        return 0;
    return logtwo(n/2)+1;
}
signed main()
{
    fastio();   
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll N,M;
        cin>>N>>M;
        ll a;
        for(ll i=0;i<M;i++)
        {
            cin>>a;
            N-=a;
        }
        if(N>=0)
            cout<<N;
        else
            cout<<-1;
    }
}

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

int main() {
    long long N, T;
    cin >> N >> T;
    vector<long long > t(N);
    for (int i = 0; i < N; i++)
        cin >> t[i];

    long long res = 0;
    for (int i = 1; i < N; i++) {
        res += min(T, t[i] - t[i - 1]);
    }
    res += T;

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
using namespace std;
 
main() {
  int a[3];
  cin >> a[0] >> a[1] >> a[2];

  sort(a, a+3);

  cout << a[0] << ' '
       << a[1] << ' '
       << a[2] << endl;

  return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;

int main(int argc, char* argv[])
{
    ll n, m, d;
    scanf("%lld%lld%lld", &n, &m, &d);

    double t=0.0;
    if(d==0) {
        t = (double)1/n;
    }
    else if(n>=2*d) {
        t = (1 + (double)(n-2*d)/n)/n;
    }
    else {
        t = (double)(2*n-2*d)/n/n;
    }
    t *= (m-1);
    printf("%.10f\n", t);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long 
#define rap(i,n) for(int i=0;i<n;++i)
using namespace std;
signed main(){
int x,y,a=0,b=0;
  cin>>x>>y;
	if(x==1){
 	 a+=300000;
	}else if(x==2){
  	  a+=200000;
	}else if(x==3){
      a+=100000;
    }if(y==1){
	 b+=300000;
    }else if(y==2){
      b+=200000;
    }else if(y==3){
	  b+=100000;
    }
  if(x==1 && y==1) cout<<a+b+400000<<"\n";
  else cout<<a+b<<"\n";
}          

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<map>
#include<string>
#include<numeric>
#include<set>
using namespace std;

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

    vector<int> a(n), froml(n);
    cin >> a[0]; // only first element
    froml[0] = 0;

    for(int i = 1; i < n; i++){
        cin >> a[i];
        froml[i] = max(a[i-1], froml[i-1]);
    }

    vector<int> fromr(n);
    fromr[n-1] = 0;
    for(int i = n-2; i >= 0; i--) fromr[i] = max(a[i+1], fromr[i+1]);

    for(int i = 0; i < n; i++) cout << max(froml[i], fromr[i]) << endl;

    return 0;
}

Measured memory_bytes: 3968
// AOJ 0551
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<functional>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;

typedef pair<int,int> P;

const int NMAX = 1e5 + 8;
int N, L, ice[NMAX], ans[NMAX];
vector<P> table;

int solve() {
  sort(table.begin(), table.end(), greater<pair<int,int> >());
  for (int x = 0; x < N; x++) {
    int i = table[x].second;
    ans[i] = max(ans[i-1], ans[i+1]) + (L - ice[i]);
  }

  int a = 0;
  for (int i = 1; i <= N; i++) {
    a = max(a, ans[i]);
  }

  return a;
}

int main() {
  cin >> N >> L;
  for (int i = 1; i <= N; i++) {
    cin >> ice[i];
    table.push_back(P(ice[i], i));
  }

  cout << solve() << endl;
}

Measured memory_bytes: 2772
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;

#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define range(i,a,n) for(int i=(a);i<(n);i++)

#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

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

template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S acm(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
void YN(bool b){cout<<(b?"YES":"NO")<<"\n";}
void Yn(bool b){cout<<(b?"Yes":"No")<<"\n";}
void yn(bool b){cout<<(b?"yes":"no")<<"\n";}

ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}

void solve(int n,int l,int r){
	vl v(n);
	vb b(r+1,(n%2==0));
	rep(i,n)cin>>v[i];
	rrep(i,n){
		range(j,l,r+1){
			if(j%v[i]==0){
				b[j]=(i%2==0);
			}
		}
	}
	int cnt=0;
	range(i,l,r+1)if(b[i])cnt++;
	cout<<cnt<<endl;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,l,r;
	while(cin>>n>>l>>r,n)solve(n,l,r);
}


Measured memory_bytes: 3116
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <stack>
#include <map> 
#include <unordered_map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL X,Y;

string ans = "No";

void solve(){
	for(int i=0;i<=50;i++){
		for(int j=0;j<=25;j++){
			if(i+j==X && 2LL*i+4LL*j==Y){
				ans = "Yes";
				return;
			}
		}
	}
}

int main(){
    cin >> X >> Y;

    solve();

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3076
import java.util.Scanner;

public class Main {

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

	void run() {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		sc.close();

		if(a <= b) System.out.println(a);
		else System.out.println(a-1);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, d, cnt[13];
string str;

int main(){
	cin >> n;
	for(ll i = 1; i <= n; i++){
		cin >> d;
		cnt[d]++;
		if(d == 0 || cnt[d] > 2 || (d == 12 && cnt[d] > 1)){cout << 0 << endl; return 0;}
	}
	

	//if(n > 23){cout << 0 << endl; return 0;}
	if(n > 11){cout << 1 << endl; return 0;}	
	
	ll ans = 1;
	for(ll bit = 0; bit < (1 << n-1); bit++){
		vector<ll> v;
		v.push_back(0);

		ll itrb = 0;
		for(ll i = 1; i <= 12; i++){
			if(cnt[i] == 1){
				if(bit & (1 << itrb)){v.push_back(i);}
				else{v.push_back(-i);}
				itrb++;
			}
			if(cnt[i] == 2){
				v.push_back(i);
				v.push_back(-i);
				itrb++;
				itrb++;
			}
		}
		
		sort(v.begin(), v.end());
		ll ansbuf = 24;
		for(ll i = 1; i < v.size(); i++){
			ansbuf = min(v[i]-v[i-1], ansbuf);
		}
		ansbuf = min(min(v[v.size()-1]-v[0], 24 - (v[v.size()-1]-v[0])), ansbuf);
		ans = max(ansbuf, ans);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,W = map(int,input().split())
WV = [list(map(int,input().split())) for _ in range(N)]

#i個目を選ぶとき合計価値がjになる場合の重さの最小値
#(i-1,j)  or  (i-1,j-v)+w

dp = [[10**12-1]*100010 for i in range(N)]

dp[0][WV[0][1]] = WV[0][0]
res = WV[0][1]

for i in range(1,N):
  w = WV[i][0]
  v = WV[i][1]
  dp[i][WV[i][1]] = WV[i][0]
  res = max(res,WV[i][1])
  for j in range(1,100010):
    if j>=v:
      dp[i][j] = min(dp[i-1][j],dp[i-1][j-v]+w,dp[i][j])
    else:
      dp[i][j] = min(dp[i-1][j],dp[i][j])
    if 0 < dp[i][j] <= W:
      res = max(res,j)
    
print(res)

Measured memory_bytes: 151664
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define S second
#define F first

using namespace std;

const int N = 5e5 + 5, M = 1e7 + 5;

int arr[100];

int main()
{
    int n, c = 0;
    scanf("%d", &n);
    for(int i = 0 ; i < n ; i++) scanf("%d", arr + i);
    for(int i = 1 ; i < n ; i++) c += (arr[i] < arr[i - 1]);
    if(c == 0) return puts("YES"), 0;
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = i + 1 ; j < n ; j++)
        {
            c = 0;
            swap(arr[i], arr[j]);
            for(int i = 1 ; i < n ; i++) c += (arr[i] < arr[i - 1]);
            swap(arr[i], arr[j]);
            if(c == 0) return puts("YES"), 0;
        }
    }
    puts("NO");
    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


def main():
    N = int(readline())
    G = [[] for _ in range(N)]
    for _ in range(N - 1):
        u, v, w = map(int, readline().split())
        G[u - 1].append((v - 1, w))
        G[v - 1].append((u - 1, w))

    dist = [-1] * N
    color = [0] * N
    dist[0] = 0
    queue = deque([0])
    while queue:
        v = queue.popleft()
        for nv, cost in G[v]:
            if dist[nv] == -1:
                dist[nv] = dist[v] + cost
                color[nv] = dist[nv] % 2
                queue.append(nv)

    print(*color, sep='\n')
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 67344
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val
using namespace std;
using namespace __gnu_pbds;

#define sp << " " <<
#define mod 1000000007
#define PI 3.14159265358979323
#define y second
#define x first
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define pqueue priority_queue< ll >
//#define pdqueue priority_queue< ll,vector<ll> ,greater< ll > >
#define codejamDebug(x) cout<<"Case #"<<x<<": ";
#define debug(x) cout<<#x<<" :"<<x<<endl;
#define rep(i,n) for(long long i=0;i<n;i++)
#define f(i,a,b) for(long long i = a; i < b; i++)
#define fd(i,a,b) for(long long i = a; i >=b; i--)
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long int           ll;
typedef long double             ld;
typedef unsigned long long int ull;
typedef vector <int>            vi;
typedef vector <ll>            vll;
typedef pair <int, int>        pii;
typedef pair <ll, ll>          pll;
typedef vector < pii >        vpii;
typedef vector < pll >        vpll;
typedef vector <string>         vs;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

//Handle:cyber_rajat

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

	int n,m;
	cin>>n>>m;
	cout<<(n*(n-1))/2 + (m*(m-1))/2<<endl;

	return 0;
}


Measured memory_bytes: 256
def gcd(x, y):
    while y != 0:
        x, y = y, x % y
    return x

def main():
    N = int(input())
    a = list(map(int, input().split()))

    if N==2:
        print(max(a))
        return 

    l = [-1] * N
    r = [-1] * N

    l[0] = a[0]
    r[-1] = a[-1]

    for i in range(1, N):
        l[i] = gcd(l[i-1], a[i])

    for i in range(N-2, -1, -1):
        r[i] = gcd(r[i+1], a[i])

    # print(l)
    # print(r)

    ans = max(r[1], l[-2])
    for i in range(1, N-1):
        # print(i)
        g = gcd(l[i-1], r[i+1])
        ans = max(ans, g)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 14524
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}



///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(10); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


ll n; cin>>n;
vv<dd> dp(n+1,0);
dp[0]=1;
for(int i=0;i<n;++i){
	dd p; cin>>p;
	for(int j=n-1;j>=0;--j) {dp[j+1]+=dp[j]*p; dp[j]*=1-p;}
}	
dd ans=0;
for(int i=(n+1)/2;i<=n;++i) ans+=dp[i];

cout<<ans<<endl;

return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
#include <numeric>
using namespace std;

int parent[17][100000];
vector <int> child[100000];
int depth[100000];

int MAX_LOG_N = 17;

void set_depth(int v, int prev_depth){
    depth[v] = prev_depth + 1;
    for(int i = 0; i < child[v].size(); i++){
        set_depth(child[v][i], prev_depth + 1);
    }
}

void set_parents(int N){
    for(int i = 1; i < MAX_LOG_N; i++){
        for(int j = 0; j < N; j++){
            parent[i][j] = parent[i - 1][parent[i - 1][j]];
        }
    }
}

int lca(int u, int v){
    if(depth[u] > depth[v]){
        return lca(v, u);
    }
    for(int k = 0; k < MAX_LOG_N; k++){
        if((((depth[u] - depth[v]) >> k) & 1) == 1){
            v = parent[k][v];
        }
    }
    if(u == v){
        return u;
    }

    for(int k = MAX_LOG_N - 1; k >= 0; k--){
        if(parent[k][u] != parent[k][v]){
            u = parent[k][u];
            v = parent[k][v];
        }
    }
    return parent[0][u];
}

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

    for(int i = 0; i < N; i++){
        int k;

        cin >> k;
        for(int j = 0; j < k; j++){
            int c;
            cin >> c;
            child[i].push_back(c);
            parent[0][c] = i;
        }
    }
    parent[0][0] = 0;

    set_depth(0, -1);
    set_parents(N);

    int q;
    cin >> q;

    for(int i = 0; i < q; i++){
        
        int u;
        int v;
        cin >> u >> v;
        cout << lca(u, v) << endl;
    }

    return 0;
}



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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define rep(i, n) REP(i, 0, n)
const ll INF=1e9;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

ll cal(ll x){
    return  x*(x+1)/2;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    ll n = s.size();
    Vec a;
    ll tmp=0;
    rep(i,s.size()){
        if(s[i]=='<'){
            if(tmp<0){
                a.pb(tmp);
                tmp =0;
            }
            tmp++;
        }else{
            if(tmp>0){
                a.pb(tmp);
                tmp =0;
            }
            tmp--;
        }
    }
    a.pb(tmp);
//    Vec sm(a.size());
//    rep(i,a.size()){
//        if(i==0){
//            sm[i]=a[i];
//            continue;
//        }
//        sm[i] = sm[i-1]+a[i];
//    }
//dbg(a);
    ll ans = 0;
    ll now = 0;
    rep(i,a.size()){
        if(a[i]>0){
            // < パターン
            ans += cal(a[i]);
            now = a[i];
        }else{
            // > パターン
            a[i] = -1*a[i];
            ans += cal(a[i]);
            if(a[i]>now){
                ans -= now;
            }else{
                ans -= a[i];
            }
            now = 0;
        }
      //  dbg(ans);
    }
    cout<<ans<<endl;
    return  0;
}


Measured memory_bytes: 3352
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
					  cerr << "\n\n" << "Time elapsed: " << \
					  (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
					  return 0
#define ll long long int
#define ull unsigned long long int
#define db long double
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound 
#define pii pair<int , int>
#define pdd pair<db , db>
#define pll pair<ll , ll>
#define vpl vector<pll >
#define vll vector<ll >
#define mod 1000000007
#define inf 100000000000000007
#define eps 0.000001
#define stp fixed<<setprecision(20)
#define endl '\n'

ll dp[100005];

int main()
{
	start_routine();
	fastio;
	

    ll n;cin>>n;
    ll k=2;
    cin>>k;
    ll h[n+1]={0};

    for(ll i=1;i<=n;i++)
    {
    	dp[i]=inf;
    	cin>>h[i];
    }

    dp[1]=0;
    for(ll i=2;i<=n;i++)
    {
    	ll mn=inf;
    	for(ll j=i-1;j>=max(i-k,1ll);j--)
    		mn=min(mn,dp[j]+abs(h[j]-h[i]));
    	dp[i]=mn;
    }

    cout<<dp[n];
	end_routine();
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <stack>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

int main(){
    int n;
    cin >> n;
    REP(i, n){
        double xa, ya, ra, xb, yb, rb;
        cin >> xa >> ya >> ra >> xb >> yb >> rb;
        double dist;
        dist = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
        if (dist > ra + rb) cout << "0" << endl;
        else {
            if (ra > rb){
                if (dist+rb < ra) cout << "2" << endl;
                else cout << "1" << endl;
            } else {
                if (dist+ra < rb) cout << "-2" << endl;
                else cout << "1" << endl;
            }
        }
    }
}


Measured memory_bytes: 3024
#include <bits/stdc++.h>
using namespace std;
#define MAXN 2005
#define rint register int
inline int read(){int r;int s=0,c;for(;!isdigit(c=getchar());s=c);for(r=c^48;isdigit(c=getchar());(r*=10)+=c^48);return s^45?r:-r;}
int n, K, Q, A[2005], o[2005]; int c[2005], l[2005], r[2005], Min, Max, Ans = 2e9; inline bool cmp (int i, int j){return A[i]<A[j];}
inline void Add(int i, int v){for(; i <= n; c[i] += v, i += i&-i);} inline int Sum(int i){int r=0; for(; i; r += c[i], i -= i&-i); return r;}
int Work(int k)
{
	Max = Min = k; for(rint i = 1; i <= n; l[i] = A[i-1]>=k?l[i-1]:i, i++); for(rint i = n; i; r[i] = A[i+1]>=k?r[i+1]:i, i--); memset(c+1,0,n<<2);
	for(rint i = 1, q = Q; q--;){for(; i <= n && (A[o[i]]<k||r[o[i]]-l[o[i]]+1-(Sum(r[o[i]])-Sum(l[o[i]]-1))<K); i++);
	if(i>n) return 2e9; Max = max(Max,A[o[i]]), Add(o[i],1), i++;} return Max-Min;
}
int main()
{
	n = read(), K = read(), Q = read(); generate(A+1,A+n+1,read); for(rint i = 1; i <= n; o[i] = i, i++);
	sort(o+1,o+n+1,cmp); for(rint i = 1; i <= n; Ans = min(Ans,Work(A[i])), i++); cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  vector<long> v;
  for (int i=0; i<n; ++i) {
    long x;
    cin >> x;
    v.push_back(x);
  }
  sort(begin(v), end(v));
  long ans=10e9+10;
  for (int i=0; i < n-k+1; ++i) {
    int j=i+k-1;
    ans = min(ans, v[j]-v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1400
T = 1
# T = int(input())
##-----------------start coding-----------------
for ti in range(1, T + 1):
    n = int(input())
    a = []
    a.extend([int(e) for e in input().split()])
    money, stocks = 1000, 0
    rise = [i for i in range(n)]
    for _ in range(n - 1, 0, -1):
        if a[_] >= a[_ - 1]:
            rise[_ - 1] = rise[_]
    t = 0
    while t < n:
        if rise[t] == t:
            # sell
            money += a[t] * stocks
            stocks = 0
            t += 1
        else:
            deal = money // a[t]
            stocks += deal
            money -= deal * a[t]
            t = rise[t]
    print(money)
    # print('Case #{}: {}'.format(ti, '...'))


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pf printf
#define sc scanf
#define sf(n) scanf("%d",&n)
#define sff(n1,n2) scanf("%d %d",&n1,&n2)
#define sfff(n1,n2,n3) scanf("%d %d %d",&n1,&n2,&n3)
#define sl(n) scanf("%lld",&n)
#define sll(n1,n2) scanf("%lld %lld",&n1,&n2)
#define slll(n1,n2,n3) scanf("%lld %lld %lld",&n1,&n2,&n3)
#define rep0(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(i=1;i<=n;i++)
#define reps(i,a,n) for(i=a;i<=n;i++)
#define nl puts("");
#define pb push_back
#define MOD 1000000007
#define fi first
#define se second
#define N 100005
#define mem(ara,n) memset(ara,n,sizeof(ara))
#define memb(ara) memset(ara,false,sizeof(ara))
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define sz(x) x.size()
#define pi pair<int,int>
#define pii pair<pair<int,int>,pair<int,int> >
#define line puts("-------");
#define db(x) cout<<#x<<" :: "<<x<<"\n";
#define dbb(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define fr freopen("input.txt","r",stdin);
#define fw freopen("output.txt","w",stdout);
typedef long long int ll;
using namespace std;
int dp[N],ara[N];
int main()
{
    int i,n,m,k;
    sff(n,m);
    rep0(i,m)
    {
        sf(k);
        ara[k]=-1;
    }
    dp[0]=1;
    rep0(i,n)
    {
        if(ara[i+1]!=-1)
        {
            dp[i+1]+=dp[i];
            dp[i+1]%=MOD;
        }
        if(ara[i+2]!=-1)
        {
            dp[i+2]+=dp[i];
            dp[i+2]%=MOD;
        }
    }
    pf("%d\n",dp[n]);
}


Measured memory_bytes: 1024
S = input()
N = len(S)
for i in range(N//2):
    if S[i] != S[-i-1]:
        print('No')
        exit()
if N % 2 == 0:
    print('No')
    exit()
tmp = (N-1)//2
for i in range(tmp):
    if S[i] != S[tmp-i-1]:
        print('No')
        exit()
tmp = (N+3)//2
for i in range(tmp, N):
    if S[i] != S[N-i-1]:
        print('No')
        exit()
print('Yes')


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

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int[] numbers = new int[3];
        numbers[0] = in.nextInt();
        numbers[1] = in.nextInt();
        numbers[2] = in.nextInt();
        Arrays.sort(numbers);
        System.out.println((int) Math.pow(2, in.nextInt()) * numbers[2] + numbers[0] + numbers[1]);
        in.close();
    }
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;

int N;
long long C, x[100010], v[100010], opt[100010];

int main() {
   cin >> N >> C;
  for(int i = 0; i < N; ++i) {
    cin >> x[i] >> v[i];
  }
  long long ret = 0;
  for(int i = 0; i < 2; ++i) {
    long long  rsum = 0;
    for(int j = N-1; j >= 0; --j) {
      rsum += v[j];
      opt[j] = max(opt[j+1], rsum - 2*(C-x[j]));
    }
    ret = max(ret, opt[0]);
    long long sum = 0;
    for(int j = 0; j < N; ++j) {
      sum += v[j];
      ret = max(ret, sum + opt[j+1] - x[j]);
    }
    for(int j = 0; j < N; ++j) x[j] = C - x[j];
    reverse(x, x+N);
    reverse(v, v+N);
  }
  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>


using namespace std;

int main() {
	
	vector<int> v;
	v.resize(5);
	for(int i = 0; i < 5; i++) {
		cin >> v[i];
	}
	
	sort(v.begin(), v.end(), greater<int>());
	
	for(int i = 0; i < 4; i++) {
		cout << v[i] << " ";
	}
	cout << v[4];
	
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 3136
#include<stdio.h>
#include<stdlib.h>

int compare_int(const void *a,const void *b){
	return *(long long*)a-*(long long*)b;
}

int compare_int2(const void *a,const void *b){
	return -*(long long*)a+*(long long*)b;
}

struct p{
	long long a;
	long long f;
	long long s;
};

int compare_intp(const void *a,const void *b){
	struct p A=*(struct p*)a,B=*(struct p*)b;
	if(A.s-B.s>0)return 1;
	return -1;
}
int main(){
	int n,i,j;
	long long k,a[200000],f[200000];
	struct p pp[200000];
	scanf("%d%lld",&n,&k);
	for(i=0;i<n;i++)scanf("%lld",&a[i]);
	for(i=0;i<n;i++)scanf("%lld",&f[i]);
	qsort(a,n,sizeof(long long),compare_int);
	qsort(f,n,sizeof(long long),compare_int2);
	for(i=0;i<n;i++)pp[i].a=a[i],pp[i].f=f[i],pp[i].s=a[i]*f[i];
	qsort(pp,n,sizeof(pp[0]),compare_intp);
	long long r=pp[n-1].s,l=-1;
	while(r-l>1){
		long long kcp=k;
		long long mid=(r+l)/2;
		int rr=n,ll=-1;
		while(rr-ll>1){
			int mm=(rr+ll)/2;
			if(pp[mm].s>mid)rr=mm;
			else ll=mm;
		}
		for(i=rr;i<n;i++){
			kcp-=(pp[i].s-mid+pp[i].f-1)/pp[i].f;
		}
		if(kcp>=0)r=mid;
		else l=mid;
	}
	printf("%lld\n",r);
	return 0;
}

Measured memory_bytes: 14176
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

	s[3] = '8';

	cout << s << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);

    int ans = (b < d ? b : d) - (a > c ? a : c);

    if (ans < 0) {
        printf("0\n");
        return 0;
    }
    printf("%d\n", ans);
    return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i,x,y) for (int i=(x); i<=(y); i++)
#define per(i,x,y) for (int i=(x); i>=(y); i--)
#define ll long long
#define N 200010
#define mod 1000000007
using namespace std;
int n,m,a,b,ans,fac[N],inv[N];
int ksm(int x,int p){
	int ret=1;
	for (; p; p>>=1,x=(ll)x*x%mod) if (p&1) ret=(ll)ret*x%mod;
	return ret;
}
void pre(int n){
	fac[0]=1;
	rep (i,1,n) fac[i]=(ll)fac[i-1]*i%mod;
	inv[n]=ksm(fac[n],mod-2);
	per (i,n-1,0) inv[i]=(ll)inv[i+1]*(i+1)%mod;
}
int C(int n,int m){
	return (ll)fac[n]*inv[m]%mod*inv[n-m]%mod;
}
void upd(int &x,int y){ x+=y; if (x>=mod) x-=mod; }
int main(){
	scanf("%d%d%d%d",&n,&m,&a,&b);
	pre(n+m); ans=0;
	rep (i,b+1,m){
		int tmp=(ll)C(n-a+i-2,n-a-1)*C(a+m-i-1,a-1)%mod;
		//printf("i=%d,tmp=%d\n",i,tmp);
		upd(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    char c;
    cin >> c;
    char ans = c + 0x01;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int x;
  cin >> x;
  if(x >= 30) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3668
S = input()

flag = True
counter1 = 0
counter2 = 0

for s in S:
    if flag:
        if s == "0":
            counter1 = counter1 + 1
        else:
            counter2 = counter2 + 1
    else:
        if s == "1":
            counter1 = counter1 + 1
        else:
            counter2 = counter2 + 1

    flag = not flag

print(str(min(counter1, counter2)))

Measured memory_bytes: 3188
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))

import itertools

for i,R in enumerate(itertools.permutations(list(range(1,N+1)))):
    if P==R: a = i
    if Q==R: b = i
print(abs(a-b))

Measured memory_bytes: 3060
//2019.1.14 12:52~16:49 PaperCloud
#include<bits/stdc++.h>
#define ll long long
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
	return x*f;
}
#define MN 200005
#define mod 924844033
#define g 5
#define invg 554906420
struct edge{int to,nex;}e[MN<<1];
int N,en,hr[MN];
inline void ins(int f,int t)
{
	e[++en]=(edge){t,hr[f]};hr[f]=en;
	e[++en]=(edge){f,hr[t]};hr[t]=en;
}
int fac[MN],inv[MN],A[524288],B[524288],siz[MN];
inline int fpow(int x,int m){int r=1;for(;m;m>>=1,x=1ll*x*x%mod) if(m&1) r=1ll*r*x%mod;return r;}
inline int C(int m,int n){return 1ll*fac[m]*inv[n]%mod*1ll*inv[m-n]%mod;}
inline void init()
{
	register int i;
	for(i=fac[0]=1;i<=N;++i) fac[i]=1ll*fac[i-1]*i%mod;
	for(inv[N]=fpow(fac[N],mod-2),i=N-1;~i;--i) inv[i]=1ll*inv[i+1]*(i+1)%mod;
}
int cnt=0;
inline void dfs(int x=1,int f=0)
{
	register int i;siz[x]=1;
	for(i=hr[x];i;i=e[i].nex)if(e[i].to^f) dfs(e[i].to,x),siz[x]+=siz[e[i].to],A[siz[e[i].to]]--;
	A[N-siz[x]]--;
}
int M,di,pos[524288],invM;

inline void NTT(int *a,int type)
{
    register int i,j,p,k;
    for(i=0;i<M;++i)if(i<pos[i]) std::swap(a[i],a[pos[i]]);
    for(i=1;i<M;i<<=1)
    {
        ll wn=fpow(type>0?g:invg,(mod-1)/(i<<1));
        for(p=i<<1,j=0;j<M;j+=p) 
        {
            ll w=1;
            for(k=0;k<i;++k,w=w*wn%mod)
            {
                ll X=a[j+k],Y=w*a[j+i+k]%mod;
                a[j+k]=(X+Y)%mod;a[j+i+k]=(X-Y+mod)%mod;
            }
        }
    }
    if(type==-1) for(i=0;i<M;++i) a[i]=1ll*a[i]*invM%mod;
}
int main()
{
	N=read();
	register int i,x;
	for(i=1;i<N;++i) x=read(),ins(x,read());
	init();dfs();
	for(i=1;i< N;++i) A[i]=(A[i]+mod)%mod;A[N]=N;
	for(i=1;i<=N;++i) A[i]=1ll*A[i]*fac[i]%mod;
	for(i=0;i<=N;++i) B[i]=inv[N-i];A[0]=0;
	for(M=1,di=0;M<=N<<1;M<<=1,di++);invM=fpow(M,mod-2);
	for(i=0;i<M;++i) pos[i]=(pos[i>>1]>>1)|((i&1)<<(di-1));
	NTT(A,1);NTT(B,1);
	for(i=0;i<M;++i) A[i]=1ll*A[i]*B[i]%mod;
	NTT(A,-1);
	
	for(i=1;i<=N;++i)
	printf("%d\n",(1ll*A[N+i]*inv[i])%mod);
	return 0;
}

Measured memory_bytes: 18432