akhauriyash/Code-Regression huggingface dataset:
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int n ;
	cin>>n;
	int a[n+1];
	int dp[n+1]={0};
	forci(1,n+1)	cin>>a[i];
	dp[2]=abs(a[2]-a[1]);
	for(int i=3;i<=n;i++)
	{
		if(dp[i-1]+abs(a[i]-a[i-1])<dp[i-2]+abs(a[i-2]-a[i]))
		{
			dp[i]=dp[i-1]+abs(a[i]-a[i-1]);
		}
		else
			dp[i]=dp[i-2]+abs(a[i]-a[i-2]);
	}
	cout<<dp[n]<<endl;
}

Measured memory_bytes: 1792
n, m = map(int,input().split())
da = list(map(int,input().split()))
 
now = 0
for i in range(m):
    now += da[i]/2 + 0.5
ans = now
for i in range(m,n):
    now -= da[i-m]/2 - da[i]/2
    ans = max(ans, now)
print(ans)

Measured memory_bytes: 25060
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var array = Console.ReadLine().Split(' ').ToList();

        var result = ( int.Parse(array[0]) * int.Parse(array[1]) ) * 0.5f;

        Console.WriteLine(result);
    }
}

Measured memory_bytes: 13268
#include <iostream>
#include <array>

int main() {
  int a,b;
  while(std::cin >> a >> b){

    if(a!=0&&b!=0){
      int c;
      std::cin >> c;
      int town[a+1][b+1]={};
      int x,y;

      for(int n=0;n<c;++n){
        std::cin >> x >> y;
        town[x][y]=-1;
      }

      town[1][1]=1;

      for(int sum=3;sum<=a+b;++sum){
        for(int t=std::min(sum-1,a);t>0 &&sum-t<=b;--t){

          if(town[t][sum-t]==-1){
            town[t][sum-t]=0;

          }else{
            town[t][sum-t] = town[t-1][sum-t]+town[t][sum-t-1];
          }
        }

      }
      std::cout << town[a][b] << std::endl;
    }else{
      break;
    }

  }
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;
using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;
const int INF=1<<30,MOD=1000000007;const ll LINF=1ll<<60;
#define _ol3(_1,_2,_3,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,v.size())
#define all(v) (v).begin(),(v).end()
#define bit(n) (1ll<<(n))
#define clamp(n,mi,ma) max(min(n,ma),mi)
#define uniq(v) sort(all(v));v.erase(unique(all(v)),v.end())
#define pb push_back
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b) cout<<((n)?a:b)<<endl
#define YES(n) cho(n,"YES","NO")
#define Yes(n) cho(n,"Yes","No")
#define Poss(n) cho(n,"Possible","Impossible")
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(a>b){a=b;return 1;}return 0;}
template<class T>ostream&operator<<(ostream&o,const vector<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>ostream&operator<<(ostream&o,const set<T>&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>ostream&operator<(ostream&o,const T&t){return o<<t;}
template<class T>istream&operator>(istream&i,T&t){return i>>t;}
#ifndef LOCAL
struct ostdmy{
template<class T>ostdmy&operator<<(const T&t){return*this;}
template<class T>ostdmy&operator<(const T&t){return*this;}};ostdmy cer_;
#define cerr cer_
#endif
constexpr int len=100000;
int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    vector<bool> primes(len+1,true);
    REP(i,2)primes[i]=false;
    REP(i,2,len+1){
        if(primes[i])
            for(int p=i*2;p<len+1;p+=i)primes[p]=false;
    }
    //cerr<<primes<<endl;
    vi cs(len+2);
    REP(i,1,len+1){
        cs[i]=cs[i-1];
        if(i%2 && primes[i] && primes[(i+1)/2]){
            cerr<<i<<endl;
            ++cs[i];
        }

    }
    //REP(i,15)cerr<cs[i]<' ';cerr<'\n';
    int q;
    cin>q;
    REP(i,q){
        int l,r;
        cin>l>r;
        cout<cs[r]-cs[l-1]<endl;
    }

    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define DEBUG(x)           cout << '>' << #x << ':' << x << endl;
#define forn(i,n)          for(int i=0;i<(int)n;++i)
#define for1(i,n)          for(int i=1;i<=(int)n;++i)
#define forr(i,n)          for(int i=(int)n-1;i>=0;--i)
#define forre(i,a,b)       for(int i=(int)b;i>=(int)a;--i)
#define fore(i,a,b)        for(int i=(int)a;i<=(int)b;++i)
#define input(arr,n)       for(int i=0;i<n;i++)cin>>arr[i]
#define output(arr,n)      for(int i=0;i<n;i++)cout<<arr[i]<<" "
#define for_each(arr)      for(auto& it:arr)cout<<it<<" "
#define ff                 first
#define ss                 second
#define PI                 acos(-1.0)
#define all(a)             a.begin(),a.end()
#define rall(a)            a.rbegin(),a.rend()
#define Unique(a)          sort(all(a)),a.erase(unique(all(a)),a.end())
#define pb(x)              push_back(x)
#define eb(x)              emplace_back(x) 
#define ppb(x)             pop_back(x)
#define pf(x)              push_front(x)
#define ppf(x)             pop_front(x)
#define in(x,y)            insert({x,y})
#define Sort(a)            sort(a.begin(),a.end())
#define mem(arr,a)         memset(arr,a,sizeof arr)
#define ins(a)             insert(a)
#define max2(a,b)          max(a,b)
#define max3(a,b,c)        max(a,max(b,c))
#define max4(a,b,c,d)      max(a,max3(b,c,d))
#define min2(a,b)          min(a,b)
#define min3(a,b,c)        min(a,min(b,c))
#define min4(a,b,c,d)      min(a,min3(b,c,d))
typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<char> vc;
typedef vector<double> vd;
/*inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void Set(int & n, int b) { n |= two(b); }
inline void Reset(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }*/
/*int fx1[]={+1,-1,+0,+0};
int fy1[]={+0,+0,+1,-1};
int fx2={+0,+0,+1,-1,-1,+1,-1,+1};
int fy2={-1,+1,+0,+0,+1,+1,-1,-1};
*/

int a,b,c,n,ans,cn1,cn2,cn3,t;
string s,s1,s2;


int main()
{
    FIO;
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    cin>>a>>b;
    b=2*b;
    cout<<max2(0,a-b)<<endl;

    
   	
    #ifdef ONLINE_JUDGE
    cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
    #endif
   return 0;
}
 


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,string> P;

string dif = "01234567";
int dx[]={-1,1,-4,4};
map<string,int> used;

void bfs(){
  queue<P> que;
  que.push(P(0,dif));
  used[dif] = 1;
  while(!que.empty()){
    P p = que.front(); que.pop();
    int pos = p.first;
    string now = p.second;
    for(int i=0;i<4;i++){
      int next = pos+dx[i];
      if(next >= 0 && next <= 7 && !(pos==3&&i==1) && !(pos==4&&i==0)){
	string tmp = now;
	swap(tmp[pos],tmp[next]);
	if(used[tmp] == 0){
	  used[tmp] = used[now] + 1;
	  que.push(P(next,tmp));
	}
      }
    }
  }
}

int main(){
  string str;
  bfs();
  while(cin >> str){
    string puzzle = "";
    puzzle += str;
    for(int i=0;i<7;i++){
      cin >> str;
      puzzle += str;
    }
    cout << used[puzzle] - 1 << endl;
  }
}

Measured memory_bytes: 3452
import sys
sys.setrecursionlimit(10**6)

d={}

def c(s):
	a = [0] * 10
	for i in s:
		a[int(i)] += 1
	if a[3] != 0 and a[5] != 0 and a[7] != 0:
		return True
	else:
		return False

def r(m, s):
	global d
	if s == "":
		pass
	elif m < int(s) or (s in d):
		return 0
	ret = 0
	if c(s):
		ret += 1
	d[s] = 1
	ret += r(m,s+"3")
	ret += r(m,s+"5")
	ret += r(m,s+"7")
	ret += r(m,"3"+s)
	ret += r(m,"5"+s)
	ret += r(m,"7"+s)
	return ret

def main():
	n = int(input())
	print(r(n,""))
	return
main()

Measured memory_bytes: 6816
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int X = scan.nextInt();
    String ans;
    if(X == 7 || X == 5 || X == 3){
      ans = "YES";
    }else{
      ans = "NO";
    }
    System.out.print(ans);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<string>
#include<stdbool.h>
using namespace std;
typedef long long ll;
#define N (1000000000+7)

int main(void) {
	ll n, ans = 1, i = 0;
	string s, t;
	cin >> n;
	cin >> s >> t;
	if (n == 1) {
		cout << 3 << endl;
		return 0;
	}
	while (i < n) {
		if (i == 0) {
			if (s[i] == s[i + 1]) {
				ans = (ans * 3 * 2) % N;
				i += 2;
			}
			else {
				ans = (ans * 3) % N;
				i++;
			}
		}
		else {
			if (s[i] == s[i + 1]) {
				if (s[i - 1] == t[i - 1]) {
					ans = (ans * 2) % N;
					i += 2;
					if (i == n - 1) {
						break;
					}
				}
				else {
					ans = (ans * 3) % N;
					i += 2;
					if (i == n - 1) {
						break;
					}
				}
			}
			else {
				if (s[i - 1] == t[i - 1]) {
					ans = (ans * 2) % N;
					i++;
					if (i == n - 1) {
						ans = (ans * 2) % N;
						break;
					}
				}
				else {
					i++;
					if (i == n - 1) {
						ans = (ans * 2) % N;
						break;
					}
				}
			}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CSharpPractice
{
	class Program
	{
		private static Boolean[] prime;
		static void Init()
		{
			prime = new Boolean[10000000];
			for (int i = 2; i * i < 10000000; i++)
			{
				if (prime[i]) continue;
				for (int j = i * i; j < 10000000; j+=i)
				{
					prime[j] = true;
				}
			}
		}
		static void Main(string[] args)
		{
			Init();
			string tmp = "";
			while ((tmp = Console.ReadLine()) != null)
			{
				int n = int.Parse(tmp);
				int ans = 0;
				for (int i = 2; i <= n; i++)
				{
					if(!prime[i])ans++;
				}
				Console.WriteLine(ans);
			}
		}
	}
}

Measured memory_bytes: 15332
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0; i<n ;i++){
    double x1,y1,x2,y2,x3,y3;
    cin>>x1>>y1>>x2>>y2>>x3>>y3;
    
    double a1 = 2*(x2-x1);
    double b1 = 2*(y2-y1);
    double c1 = (x1*x1) - (x2*x2) + (y1*y1) - (y2*y2);
    double a2 = 2*(x3-x1);
    double b2 = 2*(y3-y1);
    double c2 = (x1*x1) - (x3*x3) + (y1*y1) - (y3*y3);
    double x = (b1*c2 - b2*c1)/(a1*b2-a2*b1);
    double y = (c1*a2 - c2*a1)/(a1*b2-a2*b1);
    double d = sqrt(fabs(x-x1) * fabs(x-x1) + fabs(y-y1) * fabs(y-y1));
    
    printf("%.3f %.3f %.3f\n",x,y,d);
  }
}

Measured memory_bytes: 1244
#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans;
 
signed main(){
	string s;
	cin>>s;
	int w;
	for(int i=0;i<s.size();i++){
		if(s[i]=='W')w++;
	}
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'){
			ans+=w;
		}
		else w--;
	}
	cout<<ans<<endl;
}

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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100003;
struct Que{
    int v;
    int d;
    int c;
};

vector<int> S[MAX];
int N,color[MAX],dis[MAX];//iからdis[i]までの距離はもうみた

void BFS(int v,int d,int c){
    queue<pair<int,int>> q;
    if(d<=dis[v]) return;
    if(color[v]==0) color[v]=c;
    dis[v]=d;
    q.push(make_pair(v,dis[v]));
    while(!q.empty()){
        int a=q.front().first,b=q.front().second;
        q.pop();
        for(int i=0;i<S[a].size();i++){
            int e=S[a][i];
            if(b-1<=dis[e]) continue;
            if(color[e]==0) color[e]=c;
            dis[e]=b-1;
            q.push(make_pair(e,dis[e]));
            //cout<<dis[e];
        }
    }
}

int main(){

  int M,Q;cin>>N>>M;
    for(int i=0;i<M;i++){
        int a,b;cin>>a>>b;
        a--;b--;
        S[a].push_back(b);
        S[b].push_back(a);
    }
    
    for(int i=0;i<N;i++){
        color[i]=0;
        dis[i]=-1;
    }
    
    cin>>Q;
    vector<Que> T(Q);
    
    for(int i=0;i<Q;i++){
        cin>>T[i].v>>T[i].d>>T[i].c;
        T[i].v--;
    }
    
    for(int i=Q-1;i>=0;i--){
        BFS(T[i].v,T[i].d,T[i].c);
        
        /*for(int j=0;j<N;j++){
            cout<<color[j]<<endl;
        }*/
    }
    
    for(int i=0;i<N;i++){
        cout<<color[i]<<endl;
    }
}



Measured memory_bytes: 8912
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def max_heapify(index):
    left, right, largest = 2 * index, 2 * index + 1, -1

    if left <= array_length and array[left] > array[index]:
        largest = left
    else:
        largest = index

    if right <= array_length and array[right] > array[largest]:
        largest = right

    if largest != index:
        array[index], array[largest] = array[largest], array[index]
        max_heapify(largest)

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    # assert len(array) == array_length

    array.insert(0, None)
    for j in range(array_length // 2, 0, -1):
        max_heapify(j)
    print('', end=' ')
    print(*array[1:])

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

const int M = 1000005;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> cnt(M);
  for (int x : a) {
    if (cnt[x] != 0) {
      cnt[x] = 2;
      continue;
    }
    for (int i = x; i < M; i += x) cnt[i]++;
  }
  int ans = 0;
  for (int x : a) {
    if (cnt[x] == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;
 
#define Pr(f,...) printf(f,##__VA_ARGS__),fflush(stdout)

const int N=2e5+50; 

int n,a[N],cnt;
long long ans;

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	//freopen("dat.in","r",stdin); 
	//freopen("my.out","w",stdout); 
#endif
	scanf("%d",&n);
	rep(i,1,n){
		scanf("%d",a+i); 
		if(a[i]>i-1){
			return puts("-1"),0; 
		}
		if(a[i]<=a[i-1]){
			ans+=a[i];
		}else if(a[i]==a[i-1]+1){
			ans+=1;	
		}else{
			return puts("-1"),0; 
		}
	}
	printf("%lld\n",ans); 
	return 0; 
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll a[100010],b[100010];
bool A[100010];
int main() {
	ll n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>b[i];
	}
	A[0]=true;
	for(int i=1;i<n;i++){
		if(a[i-1]!=a[i]){
			A[i]=true;
		}
	}
	if(A[n-1]==true&&a[n-1]!=b[n-1]){
		cout << 0;
		return 0;
	}	
	A[n-1]=true;
	for(int i=n-2;i>=0;i--){
		if(b[i]!=b[i+1]){
			if(A[i]==true){
				if(a[i]!=b[i]){
					//cout << i<<endl<<b[i]<< " "<< b[i+1]<<endl;
					cout << 0;
					return 0;
				}
			}
			if(a[i]<b[i]){
				cout << 0;
				return 0;
			}
			A[i]=true;
		}
	}
	ll ans=1;

	for(int i=0;i<n;i++){
		if(A[i]!=true){
			ans*=min(b[i],a[i]);
			ans%=inf;
		}
	}
	cout << ans;
	return 0;
}

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


int main() {
   int n;
   cin>>n;
   int arr1[n],arr2[n];

    for(int i=0;i<n;i++)cin>>arr1[i];

    for(int i=0;i<n;i++)cin>>arr2[i];

    int arr3[n];

    for(int i=1;i<=n;i++)arr3[i-1]=i;

    int first = 1,ans1 = 0,ans2=0;


    do{

        bool  flag1 =1,flag2=1;

        for(int i=0;i<n;i++){
            if(arr1[i]!=arr3[i]){
                flag1 = 0;
            }
            if(arr2[i]!=arr3[i]){
                flag2 = 0;
            }
        }


        if(flag1)ans1=first;
        if(flag2)ans2=first;

        //cout<<ans1<<" "<<ans2<<endl;

        first++;
    }while(next_permutation(arr3,arr3+n));

    cout<<abs(ans1-ans2)<<endl;



    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
int main() {
  while(1){
      int a,b,n,c,d;
      cin >> a >> b ;
      if(a==0&&b==0) break;
      cin >> n;
      vector<vector<int>> dp(a,vector<int>(b));
      vector<vector<bool>> ok(a,vector<bool>(b,true));
      for(int i=0;i<n;i++){
        cin >> c >> d;
        ok.at(c-1).at(d-1) = false;
      }
      for(int i=0;i<a;i++){
        for(int j=0;j<b;j++){
          if(!ok.at(i).at(j))  dp.at(i).at(j) =0;
          else if(i==0&&j==0) dp.at(i).at(j) = 1;
          else if(i==0) dp.at(i).at(j) = dp.at(i).at(j-1);
          else if(j==0) dp.at(i).at(j) = dp.at(i-1).at(j);
          else dp.at(i).at(j) = dp.at(i-1).at(j)+dp.at(i).at(j-1);
        }
      }
      cout << dp.at(a-1).at(b-1) << endl;
    }
}


Measured memory_bytes: 3032
const input = require("fs").readFileSync("/dev/stdin", "utf8")
const lines = input.split('\n')
const s = lines[0].trim()

let ans = 1
if (s === 'SSS') {
    ans = 0
} else if (s === 'RRR') {
    ans = 3
} else if (s === 'RRS') {
    ans = 2
} else if (s === 'SRR') {
    ans = 2
}
console.log(ans)

Measured memory_bytes: 29680
# coding: utf-8
# Your code here!

import math
N,A,B,C,D = map(int,input().split())

a = N/A
x = math.ceil(a)
X = x*B

c = N/C
y = math.ceil(c)
Y = y*D

if (X > Y):
    print(Y)
else:
    print(X)


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

int main() {
  int N, K, Q;
  cin >> N >> K >> Q;
  
  vector<int> P(N, K-Q);
  
  vector<int> Answerer(Q);
  for (int i=0; i<Q; i++) {
    cin >> Answerer.at(i);
    P.at(Answerer.at(i)-1)++;
  }
  
  for (int i=0; i<N; i++) {
    if (P.at(i) > 0) {
      cout << "Yes" << endl;
    }
    else {
      cout << "No" << endl;
    }
  }
}

Measured memory_bytes: 1408
n = list(input())
k = int(input())
if len(n) == 1:
    print(int(n[0]))
    exit()
x = 0
for i in range(len(n)):
    if n[i] != "1":
        x = i
        break
if x+1 > k:
    print(1)
    exit()
else:
    print(n[x])


Measured memory_bytes: 3060
import std.algorithm;
import std.array;
import std.ascii;
import std.bigint;
import std.complex;
import std.container;
import std.conv;
import std.functional;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

auto readInts() {
	return array(map!(to!int)(readln().strip().split()));
}
auto readInt() {
	return readInts()[0];
}
auto readLongs() {
	return array(map!(to!long)(readln().strip().split()));
}
auto readLong() {
	return readLongs()[0];
}

void readlnTo(T...)(ref T t) {
    auto s = readln().split();
    assert(s.length == t.length);
    foreach(ref ti; t) {
        ti = s[0].to!(typeof(ti));
        s = s[1..$];
    }
}

const real eps = 1e-10;

const long p = 1_000_000_000 + 7;

//n!
long P(long n) {
    if(n == 0) {
        return 1;
    }
    return n * P(n-1) % p;
}

void main(){
    long n, m;
    readlnTo(n, m);

    if(abs(n-m) > 1) {
        writeln(0);
        return;
    }

    writeln((P(n) * P(m) % p) * (n == m ? 2: 1) % p);
}



Measured memory_bytes: 3452
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define per(i, n, s) for (int i = (n-1); i >= (int)(s); i--)
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<x<<endl
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll LINF = LLONG_MAX;
const int INF = INT_MAX;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	ll a,b,m; cin>>a>>b>>m;
	vector<ll> A(a);
	vector<ll> B(b);
	ll amin=LINF;
	ll bmin=LINF;
	rep(i,0,a){
		cin>>A[i];
		chmin(amin,A[i]);
	}
	rep(i,0,b) {
		cin>>B[i];
		chmin(bmin,B[i]);
	}
	ll ans=amin+bmin;
	rep(i,0,m){
		ll o,p,q;
		cin>>o>>p>>q;
		chmin(ans,A[o-1]+B[p-1]-q);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1792
from collections import Counter

N = int(input())
S = input()

c = Counter(S)

ans = c['R'] * c['G'] * c['B']

for d in range(1, 4000):
    for i in range(N):
        j = i + d
        k = j + d
        if k >= N:
            continue

        if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
            ans -= 1

print(ans)


Measured memory_bytes: 74384
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <utility>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

const ll inf = (ll)1e9;
const ll mod = (ll)1e9 + 7;

int main()
{
	string s;
	vector<int> a;
	while (cin >> s)
	{
		stringstream ss;
		ss << s;

		int id;
		double w, h;
		ss >> id;
		ss.ignore();
		ss >> w;
		ss.ignore();
		ss >> h;

		if (w / (h * h) >= 25.0)
		{
			a.push_back(id);
		}
	}

	for (int i : a)
	{
		cout << i << endl;
	}
}



Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
#include<stdint.h>
#include<inttypes.h>
#include<string.h>

typedef int32_t i32;
typedef int64_t i64;

static void print_int(i64 n){if(n<0){putchar('-');n=-n;}if(n==0){putchar('0');return;}int s[20],len=0;while(n>0){s[len++]=n%10+'0';n/=10;}while(len>0){putchar(s[--len]);}}
static i64 read_int(void){int prev='\0';int c=getchar();while(!('0'<=c && c<='9')){prev=c;c=getchar();}i64 res=0;while('0'<=c && c<='9'){res=10*res+c-'0';c=getchar();}return prev=='-'?-res:res;}

void add (i32 *bit, i32 x, i32 v) {
  i32 n = bit[0];
  for (i32 i = x; i <= n; i += i & -i) {
    bit[i] += v;
  }
}

i32 find (i32 *bit, i32 x) {
  i32 sum = 0;
  for (i32 i = x; i > 0; i -= i & -i) {
    sum += bit[i];
  }
  return sum;
}

typedef struct range {
  i32 l;
  i32 next;
} range;

void run (void) {
  i32 n = read_int();
  i32 m = read_int();
  range *a = (range *) calloc (n, sizeof (range));
  i32 *start = (i32 *) calloc (m + 1, sizeof (i32));
  memset (start, -1, sizeof (i32) * (m + 1));
  for (i32 i = 0; i < n; ++i) {
    i32 l = read_int();
    i32 r = read_int() + 1;
    i32 d = r - l;
    a[i] = (range) {l, start[d]};
    start[d] = i;
  }
  i32 *bit = (i32 *) calloc (m + 2, sizeof (i32));
  bit[0] = m + 1;
  for (i32 d = 1, i = 0; d <= m; ++d) {
    for (i32 p = start[d - 1]; p != -1; p = a[p].next) {
      ++i;
      add (bit, a[p].l, 1);
      add (bit, a[p].l + d - 1, -1);
    }
    i32 ans = n - i;
    for (i32 j = d; j <= m; j += d) {
      ans += find (bit, j);
    }
    print_int (ans);
    putchar ('\n');
  }
}

int main (void) {
  run();
  return 0;
}


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

typedef long long LL;

const int N = 5005;
const int MOD = 1000000007;

int n, po[N], f[N], g[N], h[N], dp[N][N], a[N], m;

int find(int x)
{
	return f[x] == x ? x : f[x] = find(f[x]);
}

int main()
{
	scanf("%d", &n);
	po[0] = 1;
	for (int i = 1; i <= n; i++) f[i] = i, g[i] = 1, po[i] = (LL)po[i - 1] * (n - 1) % MOD;
	int tot = 0;
	for (int i = 1; i <= n; i++)
	{
		int x; scanf("%d", &x);
		if (x == -1) {tot++; continue;}
		if (find(x) == find(i)) h[find(x)] = 1;
		else h[find(x)] ^= h[find(i)], g[find(x)] += g[find(i)], f[find(i)] = find(x);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++) if (f[i] == i)
	{
		if (h[i]) (ans += po[tot]) %= MOD;
		else a[++m] = g[i], (ans += (LL)(g[i] - 1) * po[tot - 1] % MOD) %= MOD;
	}
	for (int i = 1; i <= m; i++)
	{
		dp[i][1] = (dp[i - 1][1] + a[i]) % MOD;
		for (int j = 2; j <= i; j++)
			dp[i][j] = (dp[i - 1][j] + (LL)dp[i - 1][j - 1] * (j - 1) % MOD * a[i] % MOD) % MOD;
	}
	for (int i = 2; i <= m; i++) (ans += (LL)dp[m][i] * po[tot - i] % MOD) %= MOD;
	printf("%d\n", ((LL)n * po[tot] % MOD + MOD - ans) % MOD);
	return 0;
}

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    string ans = "";
    for (int i = 0; i < n; ++i) {
        ans += s.at(i);
        ans += t.at(i);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define int long long
#define ll long long
#define vi vector <int>
#define vii vector <pair<int,int> >
#define rep(i,a,b) for (int i=a;i<b;i++)
#define repD(i,a,b) for (int i=a;i>b;i--)
#define pb push_back
#define pii pair <int,int>
#define ff first
#define ss second
#define all(a) a.begin(),a.end()
#define MOD 1000000007
#define PI 3.14159265359
 
#define deb(x) {x}
#ifndef local
	#define deb(x) ;
#endif
///----------------------------------------------------------------------------------

int n,arr[500005];


void solve()
{
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	
	
	
}
signed main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
 	
 	#ifdef local
    //freopen("input.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    clock_t qwertyuiop = clock();
    #endif
 
 	int t=1;
    ///cin>>t;
    
    
    rep(a,0,t)
    {
        ///cout<<"Case #"<<a+1<<": ";
        solve();
	}
	
    #ifdef local
    {qwertyuiop = clock() - qwertyuiop;double time_taken = ((double)qwertyuiop)/CLOCKS_PER_SEC;cerr<<fixed<<setprecision(5)<<"\n\nTime Taken : "<<time_taken<<" seconds\n";}
	#endif
}



Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))

a.sort()

left = 0
right = n - 1
mid = right // 2
ans1 = abs(a[mid] - a[right])
while(True):
    if(left == mid or right == mid): break
    ans1 += abs(a[right] - a[left])
    right -= 1

    if(left == mid or right == mid): break
    ans1 += abs(a[right] - a[left])
    left += 1
    

left = 0
right = n - 1
mid = right // 2
if(right % 2 != 0): mid += 1
ans2 = abs(a[mid] - a[left])
while(True):
    if(left == mid or right == mid): break
    ans2 += abs(a[right] - a[left])
    left += 1

    if(left == mid or right == mid): break
    ans2 += abs(a[right] - a[left])
    right -= 1

if(ans1 > ans2): print(ans1)
else: print(ans2)

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

int main() {
	int n, m;
	std::cin >> n >> m;

	std::vector<std::vector<int>> s(m);
	for (auto&& v : s) {
		int k;
		std::cin >> k;

		for (int i = 0; i < k; ++i) {
			int x;
			std::cin >> x;
			v.push_back(x - 1);
		}
	}

	std::vector<int> p(m);
	for (auto&& e : p)
		std::cin >> e;

	int ans = 0;
	for (int state = 0; state < (1 << n); ++state) {
		bool isOK = true;
		for (int i = 0; i < m; ++i) {
			bool sw = false;
			for (int j = 0; j < s[i].size(); ++j)
				sw = sw != ((state >> s[i][j]) & 1);

			if (sw != p[i]) {
				isOK = false;
				break;
			}
		}

		if (isOK)
			++ans;
	}

	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define _rep(i,n) _repl(i,0,n)
#define rep(...) GET_MACRO(__VA_ARGS__, _repl, _rep)(__VA_ARGS__)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream &o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream &o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

template<typename T>
class SegTree {
public:
  int n;
  T e;
  T (*op)(T, T);
  vector<T> data;
  SegTree(int m, T _e, T (*_op)(T, T)) : e(_e), op(_op){
    n=1;
    while(n<m) n*=2;
    data.resize(2*n, e);
  }
  T query(int l, int r){
    T vl = e, vr = e;
    for(l+=n, r+=n; l<r; l/=2, r/=2){
      if(l&1) vl = op(vl, data[l++]);
      if(r&1) vr = op(data[--r], vr);
    }
    return op(vl,vr);
  }
  void update(int k, T a){
    k+=n;
    data[k]=a;
    while(k>0){
      k = k/2;
      data[k] = op(data[k*2], data[k*2+1]);
    }
  }
  inline T operator[](int idx){ return data[idx+n]; }
};

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

  SegTree<int> st(n, (1LL<<31) - 1, [](const int l, const int r){return min(l,r);});
  rep(i,q){
    int t,x,y;
    cin>>t>>x>>y;
    if(t==0) st.update(x,y);
    else cout << st.query(x,y+1) << "\n";
  }

  return 0;
}

Measured memory_bytes: 3888
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    ll n,k;cin>>n>>k;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    rep(i,k){
        vector<ll>b(n+1);
        rep(j,n){
            b[max(0LL,j-a[j])]++;
            b[min(n,j+a[j]+1)]--;
        }
        REP(j,1,n+1){
            b[j]+=b[j-1];
        }
        bool f=1;
        rep(j,n){
            if(a[j]!=b[j])f=0;
        }
        if(f)break;
        a=b;
    }
    rep(i,n){
        cout<<a[i]<<' ';
    }
    cout<<endl;
}

Measured memory_bytes: 7956
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
bool sortbysec(const pair<int,int>&a,const pair<int,int>&b)
{
    return (a.second<b.second);
}
int main()
{
    ios;
    ll l,r;
    ll mn=2019;
    cin>>l>>r;
    for(ll i=l;i<=min(r,l+2019);i++)
    {
        for(ll j=l;j<=min(r,l+2019);j++)
        {
            if(i==j)
                continue;
            mn=min((i*j)%2019, mn);
        }
    }
    cout<<mn<<endl;


}












































Measured memory_bytes: 3688
import Control.Monad.State
import Data.List

main :: IO ()
main = fmap fst $ runStateT stateIO ""

stateIO :: StateT String IO ()
stateIO = do
  str <- lift $ getLine
  q <- lift $ readLn

  put str

  replicateM_ q $ do
    (q:qs) <- fmap words $ lift getLine

    s <- get

    case q of
      "replace" -> do
        let
          [a,b] = map read $ init qs
          p = last qs
          (t,r) = splitAt a s
          (_,r2) = splitAt (b-a+1) r
        put $ t ++ p ++ r2
      "reverse" -> do
        let 
          [a,b] = map read qs
          (t,r) = splitAt a s
          (r1,r2) = splitAt (b-a+1) r
        put $ t ++ reverse r1 ++ r2
      "print" -> let
          [a,b] = map read qs
          (_,r) = splitAt a s
          (r1,_) = splitAt (b-a+1) r
        in lift $ putStrLn r1

Measured memory_bytes: 5308
#include<stdio.h>
int main(void)
{
	int a,b,c,d;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	while(1){
		c=c-b;
		if(c<=0){
			printf("Yes\n");
			break;
		}
		a=a-d;
		if(a<=0){
			printf("No\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1632
#!/usr/bin/env ruby
# encoding: utf-8

while line = gets do
	a, b, c, d, e, f = line.split.map(&:to_f)
	y = ( a * f - c * d ) / ( a * e - b * d )
	x = ( c - b * (( a * f - c * d ) / ( a * e - b * d ))) / a
	puts sprintf("%.3f %.3f", x, y )
end

Measured memory_bytes: 6132
n, x = list(map(int, input().split()))
l = list(map(int, input().split()))

d = [0]
total = 0
for i in range(n):
  total += l[i]
  d.append(total)

ans = n+1
for i in range(n+1):
  if x < d[i]:
    ans = i
    break
  
print(ans)

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

int main() {
  int N, l, r, x;
  x = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    x += r - l + 1;
  }
  cout << x << endl;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

int n, m;
vector<int> vec[100000];
bool vis[100000];

vector<int> ans_a, ans_b;
void dfs(int v, vector<int> & l) {
	l.PB(v);
	vis[v] = true;
	inc(i, vec[v].size()) {
		if(vis[ vec[v][i] ]) { continue; }
		dfs(vec[v][i], l);
		break;
	}
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		vec[a].PB(b);
		vec[b].PB(a);
	}
	
	vis[ vec[0][0] ] = true;
	dfs(0,         ans_a);
	dfs(vec[0][0], ans_b);
	
	int as = ans_a.size();
	int bs = ans_b.size();
	cout << as + bs << endl;
	dec(i, as) { cout << (i == as - 1 ? "" : " ") << ans_a[i] + 1; }
	inc(i, bs) { cout << " " << ans_b[i] + 1; }
	cout << endl;
	
	return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(2e1 + 5);

int n;
vector<vector<pair<int, int>>> data(MAX_N);

int tmp[MAX_N];

bool check() {
  // printf(":");
  // for (int j = 0; j < n; ++j) {
  //   printf("%d ", tmp[j]);
  // }
  // printf("\n");

  for (int i = 0; i < n; ++i) {
    bool is_honest = tmp[i] == 1;
    // printf("-%d, %d %d\n", i, tmp[i], is_honest);

    if (!is_honest) continue;

    auto confess = data[i];

    // printf("size: %d\n", confess.size());

    // for (auto &e : confess) {
    //   printf("%d %d\n", e.first, e.second);
    // }

    for (auto &e : confess) {
      // printf("~~~~~~%d, %d\n", e.first, tmp[e.first]);
      if (tmp[e.first] != e.second) {
        return false;
      }
    }
  }

  return true;
}

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);
    for (int j = 0; j < a; ++j) {
      int x, y;
      scanf("%d %d", &x, &y);
      data[i].push_back(make_pair(x - 1, y));
    }
  }

  int ans = 0;

  for (int i = 0; i < (1 << n); ++i) {
    for (int j = 0; j < n; ++j) {
      tmp[j] = (i >> j) & 1 ? 1 : 0;
    }

    if (!check()) continue;

    // for (int j = 0; j < n; ++j) {
    //   printf("%d ", tmp[j]);
    // }
    // printf("\n");

    int cnt = 0;
    for (int j = 0; j < n; ++j) {
      cnt += tmp[j];
    }

    ans = max(ans, cnt);
  }

  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split(" ")))
ans = 0

minusList = [i for i in A if i < 0]
absList = list(map(abs,A))
ans = sum(absList)
if len(minusList) % 2 != 0:
	minimum = min(absList)
	ans = ans - minimum*2

print(ans)


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

#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

/*****************************************************START******************************************************************/


int main()
{
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	int T = 1;
	 //cin >> T;
	// cin.ignore(); must be there when using getline(cin, s)
	while (T--)
	{
		int a; cin >> a;
		cout << a + a*a + a*a*a << endl; 
				
	}
	return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    char w;
    cin >> w;
    if ('a' <= w && w <= 'z'){
        cout << 'a' << endl;
    }else{
        cout << "A" << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  bool prime[1000005]={};//true   
  int n,x,i,j,k;

  rep(i,1000005)
    prime[i]=true;
  for(i=2;i<1000005;i++){
    if(prime[i])
      for(j=2;i*j<1000005;j++)
	prime[i*j]=false;
  }

  while(1){
    int price[30]={};
    int cost[2000005]={};
    cin>>n>>x;
    if(n==0 && x==0)break;
    rep(i,n){
      cin>>price[i];
      cost[price[i]]++;
    }

    rep(i,x)
      if(cost[i])
	rep(j,n)
	  cost[i+price[j]]++;


    for(i=x;i>0;i--)
      if(cost[i]>0 && prime[i])break;

    if(i)
      cout<<i<<endl;
    else
      cout<<"NA"<<endl;
  }
}

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


def main():
    """Function."""
    a, b = map(int, input().split())

    counter = 0
    for num in range(a, b+1):
        line = list(str(num))
        if line == line[::-1]:
            counter += 1

    print(counter)


if __name__ == "__main__":
    main()


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

using namespace std;

const int N = 1e2+7;

int n;
string s, t;

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    cin >> n >> s >> t;
    for (int i = 0; i < n; ++i) {
        cout << s[i] << t[i];
    }
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

val br = BufferedReader(InputStreamReader(System.`in`))
val out = PrintWriter(System.out)

fun main() {
    br.use { out.use {
        solve()
        out.flush()
    } }
}

fun solve() {
    val (n, k) = readLongList()
    val aList = readLongList()

    if (k == 0L) {
        out.println(aList.max())
        return
    }

    var ng = 0L
    var ok = 1_000_000_001L
    while (ok - ng > 1) {
        val mid = (ok + ng) / 2
        val check = {
            var count = 0L
            for (a in aList) {
                count += (a - 1) / mid
            }
            count <= k
        }
        if (check()) {
            ok = mid
        } else {
            ng = mid
        }
    }

    out.println(ok)
}




fun readInteger() = Integer.parseInt(br.readLine())
fun readLong() = java.lang.Long.parseLong(br.readLine())
fun readStringList() = br.readLine()!!.split(' ')
fun readIntegerList() = readStringList().map(Integer::parseInt)
fun readLongList() = readStringList().map(java.lang.Long::parseLong)
fun readDoubleList() = readStringList().map(java.lang.Double::parseDouble)


Measured memory_bytes: 64260
#include<stdio.h>

 int main(){
 	char name[5];
 	scanf("%s",&name);
 	if(name[0]==name[1] && name[1]!=name[2] && name[0]!=name[2]){
 		printf ("Yes");
	 }
	 else if (name[1]==name[2] && name[0]!=name[1] && name[0]!=name[2] ){
	 	printf("Yes");
	 }
	 else if (name[0]==name[2] && name[1]!=name[2] && name[0]!=name[1]){
	 	printf("Yes");
	 }
 	else {
 		printf("No");
	 }
 	
 	return 0;
 }

Measured memory_bytes: 3184
#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int lli;
#define optimize ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define forab(i,a,b) for(int i = a; i<b; i++)
#define forll(i,a,b) for(lli i = a; i<b; i++)
#define mp make_pair
#define pb push_back
#define sortv(v) sort(v.begin(), v.end())
#define mod1 1000000007
#define mod2 998244353
#define debug(x) cout<<#x<<" : "<<x<<endl

int main()
{
	optimize

	lli n;
	cin>>n;

	lli ans = 0LL;

	lli y;

	forab(i,1,n+1)
	{
		y = n/i;
		ans += (y*(y+1)*i)/2; 
	}
		

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

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

int main() {
  int in,a,b,c,d;
  cin >> in;
  a=in%10;
  b=in%100/10;
  c=in%1000/100;
  d=in/1000;
  if(b==c){
    if(a==b||c==d)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  else
    cout << "No" << endl;
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	switch(n%10) {
		case 0:
		case 1:
		case 6:
		case 8: cout<<"pon\n";
			break;
		case 2:
		case 4:
		case 5:
		case 7:
		case 9: cout<<"hon\n";
			break;
		case 3: cout<<"bon\n";
			break;
	}
}



Measured memory_bytes: 3596
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<limits>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define INF 1e18
using ll = long long;
using namespace std;
/*
< > > > < < > < < < < < > > > <
0 3 2 1 0 1 2 0 1 2 3 4 5 2 1 0 1

< > >
0 2 1 0
*/
int main(){
  string s;  cin >> s;
  vll a(s.size()+1);
  rep0(i,s.size()){
    if(s[i] == '<'){
      a[i+1] = a[i]+1;
    }
  }
  rrep0(i,s.size()){
    if(s[i] == '>'){
      a[i] = max(a[i+1]+1,a[i]);
    }
  }
  ll ans = 0;
  rep0(i,s.size()+1){
    ans += a[i];
  }
  cout << ans;
}


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

int main() {
  char str[11];
  scanf("%s",str);
 
  int result = 0;
  if( str[0]!='A' ) result = 1;
  else {
    int numC = 0;
    int ncount = 0;
    for(int i=2;i<strlen(str)-1;i++) {
      if( str[i]=='C' ) numC = i, ncount++;
    }
    if( ncount!=1 ) result = 2;
    else {
    	for(int i=1;i<strlen(str);i++) {
        if(i!=numC&&str[i]<='Z') {
          result = 3;
          break;
        }
      }
    }

  }

  if( !result ) printf("AC");
  else printf("WA");

  return 0;
}


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

int main(){
  int n,m;
  cin >> n >> m;
  vector<string> a(n);
  vector<string> b(m);
  for(int i=0;i<n;i++) cin >> a.at(i);
  for(int i=0;i<m;i++) cin >> b.at(i);
  
  int ans=0;
  
  for(int i=0;i<=n-m;i++){
    for(int j=0;j<=n-m;j++){
      int k=1;
      for(int y=0;y<m;y++){
        for(int x=0;x<m;x++){
          k*=(a.at(y+i).at(x+j)==b.at(y).at(x));
        }
      }
      ans+=k;
    }
  }
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256