akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


string changetofour(int n,int digit){
  string text="";
  while (n>=4){
    int tmp=n%4;
    n/=4;
    text=to_string(tmp)+text;

  }
  
  text=to_string(n)+text;
 
  
  int textsize=int(text.size());
  
  if (textsize<digit){
    for (int i=0;i<digit-textsize;i++){
      text="0"+text;
    }
  }

  return text;
}


int main(){



  int n,a,b,c;
  cin>>n>>a>>b>>c;
  
  vector<int> data(n);
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    data.at(i)=tmp;
  }

  
  int answer=-1;
  
  for (int i=0;i<pow(4,n);i++){
    string group=changetofour(i,n);
    
    int sum0=0,sum1=0,sum2=0,count=0;
    
    for (int j=0;j<n;j++){
      if (group.at(j)=='0'){
        sum0+=data.at(j);
        count++;
      }
      else if (group.at(j)=='1'){
        sum1+=data.at(j);
        count++;
      }
      else if (group.at(j)=='2'){
        sum2+=data.at(j);
        count++;
      }
    }
    
    int tmp=abs(sum0-a)+abs(sum1-b)+abs(sum2-c)+10*(count-3);
    tmp=min(tmp,abs(sum0-a)+abs(sum2-b)+abs(sum1-c))+10*(count-3);
    tmp=min(tmp,abs(sum1-a)+abs(sum0-b)+abs(sum2-c))+10*(count-3);
    tmp=min(tmp,abs(sum1-a)+abs(sum2-b)+abs(sum0-c))+10*(count-3);
    tmp=min(tmp,abs(sum2-a)+abs(sum0-b)+abs(sum1-c))+10*(count-3);
    tmp=min(tmp,abs(sum2-a)+abs(sum1-b)+abs(sum0-c))+10*(count-3);
    
    if (sum0!=0 and sum1!=0 and sum2!=0){
      if (answer==-1){
        answer=tmp;
      }
      else {
        answer=min(answer,tmp);
      }
    }
  }
  
  cout<<answer<<endl;
  

        
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, haihun=0;
    string S;
    bool ans =false;
    
    cin >> a >> b;
    cin >> S;

    for(int i=0; i<a+b+1; i++){
	if(S[i]=='-')
	    haihun++;
    }

    if(S[a]=='-' && haihun==1)
	ans=true;    
    
    cout << (ans ? "Yes": "No")<<endl;
    
}



Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;
using System.Linq;
class Program
{
    static List<int> s = new List<int>();
      static List<int> v = new List<int>();
      static List<int> w = new List<int>();
    static decimal result;
static Hashtable ht=new Hashtable();
static StringBuilder sb = new StringBuilder();
static int N,M,K;
static long[,] table;
    static void Main()
    {
Read4();
      Read5();
decimal[] check=new decimal[100001];//現在価値を軸に考える。
      for(int i=0;i<=100000;i++){check[i]=K+1;}
      check[0]=0;
      for(int i=0;i<N;i++){
for(int j=100000-v[i];j>=0;j--){
if(check[j+v[i]]>check[j]+w[i]){check[j+v[i]]=check[j]+w[i];}
}
}
      for(int i=0;i<=100000;i++){if(check[i]<K){result=Math.Max(result,i);}}
      
                    Console.WriteLine(result.ToString());
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }
 
    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
   {
       string[] tmp = Console.ReadLine().Split(' ');
       for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
       N = int.Parse(tmp[0]);
       K = int.Parse(tmp[1])+1;
    }
    static void Read5()//N行K項
    {
for(int i=0;i<N;i++){
       string[] tmp = Console.ReadLine().Split(' ');
       w.Add(int.Parse(tmp[0]));
       v.Add(int.Parse(tmp[1]));
}
    }
}


Measured memory_bytes: 12512
import java.util.Scanner
import scala.io.StdIn._

object Main extends App {

  val Array(n, m) = readLine().split(" ").map(_.toInt)
  val H = readLine().split(" ").map(_.toInt)
  val A = Array.fill(m)(readLine().split(" ").map(_.toInt - 1))


  def solve() = {
    val default = Map.empty[Int, Seq[Int]]
    val hAndRootMap = A.foldLeft(default) { (acc, root) =>
      val s = root(0)
      val e = root(1)
      acc
        .updated(s, e +: acc.getOrElse(s, Seq.empty))
        .updated(e, s +: acc.getOrElse(e, Seq.empty))
    }
    H.zipWithIndex.foldLeft(0L) { case (acc, (h, index)) =>
      hAndRootMap.get(index) match {
        case None => acc+1
        case Some(list) => if(list.map(H).forall(_ < h)) acc+1 else acc
      }
    }
  }

  println(solve())

}



Measured memory_bytes: 91700
#include <stdio.h>

int n;
int a[100];

int solve(int x) {
    int ans = 0;

    for (int i = 0; i < n; ++i) {
        ans += (x - a[i]) * (x - a[i]);
    }

    return ans;
}
int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", a + i);
    }

    int ans = solve(-100);
    int tmp;

    for (int j = -99; j <= 100; ++j) {
        tmp = solve(j);
        if (tmp < ans) ans = tmp;
    }

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

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int p[100009],f[100009];
main()
{
    p[1]=1;

    for (int i=2; i<=100000; i++)
    {
        for (int j=2*i; j<=100000; j+=i)
            p[j]=1;
    }
    p[2]=0;
    for (int i=1; i<=100000; i++)
    {
        if(p[i]==0 && p[(i+1)/2]==0 && i!=2)
            {
                f[i]=f[i-1]+1;
            }
        else f[i]=f[i-1];
    }
    int q;
    cin>>q;
    while(q--)
    {
        int l,r;
        cin>>l>>r;
        cout<<f[r]-f[l-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<bitset>
#define MOD 1000000007
#define md 998244353
#define INF LLONG_MAX
#define F first
#define S second
#define yes cout<<"YES\n";
#define no cout<<"NO\n";
#define sz(x) (long long)x.size()
#define vi vector<int>
#define vll vector<long long>
#define vpl vector<pair<long long,long long> >
#define vpi vector<pair<int,int> >
#define pb push_back
#define debug(x) cerr<<#x<<"= "<<x<<endl
#define all(v) v.begin(),v.end()
#define TT ll test;cin>>test; while(test--)
#define rep(i,a,n) for(ll i=a;i<(long long)n;++i)
#define repr(i,n,a) for(ll i=n;i>(long long)a;--i)
#define endl '\n'
#define SORT(v) sort(v.begin(),v.end())
#define REV(v) reverse(v.begin(),v.end())
#define MAXN 200005
typedef long long ll;
typedef long double ld;
using namespace std;

ll BigMod(ll base,ll pow,ll mod)
{
    if(pow==0||base==1)return 1;
    else if(pow==1)return base;
    else if(pow%2)return BigMod(base,pow-1,mod)*base%mod;
    else {ll x=(BigMod(base,pow/2,mod)%mod);x=(x*x)%mod;return x;}
}

ll isprime(ll prime)
{
	ll cnt=0;
	for(int i=2;i*i<=prime;i++)
	{
		if(prime%i==0)return false;
		
	}
	return true;
}

   void DBG() { cerr << "]" << '\n'; }
template<class H, class... T> void DBG(H h, T... t) {
    cerr << h;
    if (sizeof...(t)) cerr << ", ";
    DBG(t...);
}
 
#ifdef LOCAL // compile with -DLOCAL
    #define dbg(...) cerr << "LINE(" << __LINE__ << ") -> [" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#else
    #define dbg(...) 0
#endif 

//***************** GRAPH VISITED *****************************************************
const int dx[]={+1,-1,+0,+0};
const int dy[]={+0,+0,+1,-1};
const int f1x[]={+0,+0,+1,-1,-1,+1,-1,+1};   /// Kings Move
const int f1y[]={-1,+1,+0,+0,+1,+1,-1,-1};  /// Kings Move
const int f2x[]={-2, -2, -1, -1,  1,  1,  2,  2};  /// Knights Move
const int f2y[]={-1,  1, -2,  2, -2,  2, -1,  1}; /// Knights Move

const int maX=1e3+10;
ll vis[maX][maX];
ll n,m;
void DFS(ll x, ll y)
{
	cout<<x<<' '<<y<<endl;
	vis[x][y]=1;
	
	for(ll i=0;i<4;i++)
	{
		ll d=x+dx[i];
		ll dd=y+dy[i];
		
		if(d>=1 && d<=n && dd>=1 && dd<=m && vis[d][dd] !=1) DFS(d,dd);
	}
   	
	for(ll i=x;i<=n;i++)if(vis[i][y] ==0) DFS(i,y);
	for(ll i=x-1;i>=1;i--)if(vis[i][y]==0)DFS(i,y);
	for(ll i=y;i<=m;i++)if(vis[x][i]==0)DFS(x,i);
	for(ll i=y-1;i>=1;i--)if(vis[x][i]==0)DFS(x,i);
	 
 
	
}


//**********************************MAIN_FUNCTION ************************************************************
int main( ) {
 
      ll  k,l=0,q;
        ll t,i,j,x,y;
        cin>>n;
        ll ara[n];
        for(i=0;i<n;i++)cin>>ara[i];
        sort(ara,ara+n);
           for(i=0;i<n-2;i++)
           {
           	 for(j=i+1;j<n-1;j++)
           	 {
           	 	for(k=j+1;k<n;k++)
           	 	{
           	 		if(ara[i]!=ara[j] && ara[j]!=ara[k] && ara[i]!=ara[k] && ara[i]+ara[j] > ara[k])l++;
				}
			}
		   }
          cout<<l<<endl;
     
	return 0;
}
 

Measured memory_bytes: 3672
/* おまじない　*/
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
typedef long long ll;
typedef long double ld;
using namespace std;
const ll MOD=pow(10,9)+7;
const ll INF=(1LL<<62);
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
void init(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
}

int main(){
    init();
    ll N;cin>>N;
    vector<ll>p(N);
    ll sum=0;
    ll num=0;
    for(int i=0;i<N;i++){
        cin>>p[i];
        sum+=p[i];
        num=max(num,p[i]);
    }
    if(num<sum-num)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    
    
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int N;
int A[20];
int X[20][20];
int Y[20][20];


int singi[20] = {0};
int res = 0;
bool check() {
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < A[i]; j++)
        {
            if (singi[i] == 1) {
                if (singi[X[i][j]] != Y[i][j])
                    return false;                
            } 
        }
    }
    return true;
}

int rec(int n) {
    if (n == 0) {
        if(check()) {
            int tmp = 0;
            for (int i = 0; i < N; i++)
            {
                if (singi[i] == 1) tmp++;
            }
            res = max(res, tmp);
        }
    } else {
        singi[n-1] = 0;
        rec(n-1);
        singi[n-1] = 1;
        rec(n-1);
    }
    return res;
}

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


    cin >> N;
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        for (int j = 0; j < A[i]; j++)
        {
            cin >> X[i][j] >> Y[i][j];
            X[i][j]--;
        }
        
    }
    
    cout << rec(N) << "\n";

}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

int main()
{
    int X;
    cin >> X;
    string ans = "NO";
    if (X == 3 || X == 5 || X == 7)
    {
        ans = "YES";
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
void main(){
  import std.stdio, std.string, std.conv, std.algorithm;
  import std.array;

  int h, w; rd(h, w);
  auto a=new int[][](h, w);
  foreach(i; 0..h){
    a[i]=readln.split.to!(int[]);
  }

  int py=-1, px=-1;
  int[][] moves;
  foreach(i; 0..h){
    foreach(j; 0..w){
      if(a[i][j]&1){
        if(j+1<w){
          a[i][j]--;
          a[i][j+1]++;
          moves~=[i, j, i, j+1];
        }
      }
    }
  }
  foreach(i; 0..h){
    if(a[i][w-1]&1){
      if(i+1<h){
        a[i][w-1]--;
        a[i+1][w-1]++;
        moves~=[i, w-1, i+1, w-1];
      }
    }
  }
  writeln(moves.length);
  foreach(move; moves) writefln("%(%s %)", move.map!(e=>e+1).array);
  // writeln(a);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x) e=l[i].to!(typeof(e));
}


Measured memory_bytes: 14588
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val a, b, c, x = sc.nextInt()
  val xs = for {
    a <- (0 to a).toIterator.map(_ * 500)
    b <- (0 to b).toIterator.map(_ * 100)
    c <- (0 to c).toIterator.map(_ * 50)
    if (a + b + c) == x
  } yield {
  }
  val ret = xs.toList.length
  println(ret)
}


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

vector<pair<long long, long long>> prime_factorize(long long N) {
    vector<pair<long long, long long>> res;

    for (long long a=2; a*a<=N; a++) {
        if (N % a != 0) continue;

        long long ex = 0;
        while (N % a == 0) {
            ex++;
            N /= a;
        }
        res.push_back({a, ex});
    }

    if (N != 1) res.push_back({N, 1});

    return res;
}

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

    const int MOD = 1000000007;
    vector<long long> ex(N + 1, 0);
    for (long long n = 2; n <= N; n++) {
        const auto &res = prime_factorize(n);
        for (auto p : res) ex[p.first] += p.second;
    }
    
    long long res = 1;
    for (int p = 2; p <= N; p++) {
        res *= ex[p] + 1;
        res %= MOD;
    }

    cout << res << endl;
}

Measured memory_bytes: 3560
#include<stdio.h>
const int N = 10000;
int main(void)
{
	int a[N] = {0}, n, maxn = -1000005, minn = 1000005;
	long long sum = 0;
	scanf("%d", &n);
	for(int i = 0;i < n; i++)
	{scanf("%d", &a[i]);
	if(a[i] > maxn)
	{
		maxn = a[i];
	}
	if(a[i] < minn)
	{
		minn = a [i];
	}
	sum += a[i];
	}
	printf("%d %d %lld\n", minn, maxn, sum);
	return 0;
} 


Measured memory_bytes: 2796
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define speed                     \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0);
#define ll long long
#define pb push_back
#define mem1(a) memset(a, -1, sizeof(a))
#define mem0(a) memset(a, 0, sizeof(a))
#define endl "\n"
#define mod1 1000000007
#define mod 998244353
#define ff first
#define ss second
#define MAX 500005
#define N 10004
#define INF 1000000009
#define all(v) v.begin(), v.end()
#define sbit(a) __builtin_popcount(a)
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
typedef pair<ll, ll> pll;
typedef pair<pll, ll> ppl;
typedef map<ll, ll> mpll;
typedef map<vector<ll>, ll> mpvl;
ll power(ll x, ll y, ll p)
{
    ll res = 1;

    x = x % p;

    if (x == 0)
        return 0;
    while (y > 0)
    {

        if (y & 1)
            res = (res * x) % p;

        y = y >> 1;
        x = (x * x) % p;
    }

    return res;
}
void solve()
{

    ll n, k;
    cin >> n >> k;
    pll p[k + 1];
    ll dp[n + 1];
    for(ll i=0;i<=n;i++)dp[i]=0;
    dp[1]=1;
    for (ll i = 1; i <= k; i++)
    {
        cin >> p[i].ff >> p[i].ss;
    }
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = 1; j <= k; j++)
        {
            ll l = p[j].ff;
            ll r = min(p[j].ss,i);
            if (i>l)
            { 
                if(i==r)r-=1;
                dp[i] += (dp[i-l]-dp[i-r-1]+ mod) % mod;//add in a range//discrete segments//actually dp[i]=dp[i-l1]+dp[i-l2]...
                //so we take prefix sums instead of adding each as they will form a non overlapping contiguous range
                dp[i] %= mod;
                
            }
        }
        dp[i]+=dp[i-1];//prefix sum
    }
    cout<<dp[n]-dp[n-1]<<endl;
}
int main()
{
    speed;
    ll kk;
    kk = 1;
    //cin >> kk;
    while (kk--)
    {

        solve();
    }

    return 0;
}

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

typedef long long int ll;
#define INF 1999999999
#define MODA 1000000007
#define PI 3.1415926535897932384626433

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(0);
    string b;
    cin >> b;
    if(b[0] == 'A')
    {
        cout << "T" << endl;
    }
    else if(b[0] == 'T')
    {
        cout << "A" << endl;
    }
    else if(b[0] == 'G')
    {
        cout << "C" << endl;
    }
    else if(b[0] == 'C')
    {
        cout << "G" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
import java.util.*
import kotlin.comparisons.*

fun main(args : Array<String>) {
  val (n, m) = readLine()!!.split(' ').map(String::toInt)
  val ss = (1..m).map { readLine()!!.split(' ').drop(1).map { it.toInt() - 1 } }
  val pp = readLine()!!.split(' ').map(String::toInt)

  val t = Math.pow(2.0, n.toDouble()).toInt()
  val ans = (0 until t).count { i ->
    ss.withIndex().all { s ->
      pp[s.index] == s.value.map { (i shr it) and 1 }.sum() % 2
    }
  }
  println(ans)
}


Measured memory_bytes: 39476
object Main extends App {
  import scala.io.StdIn._

  val n = readInt
  val s = readLine.trim
  val t = readLine.trim
  val sCounts = ('a' to 'z').map(c ⇒ s.count(_ == c)).sorted
  val tCounts = ('a' to 'z').map(c ⇒ t.count(_ == c)).sorted
  println(
    sCounts.zip(tCounts).map{case (a, b) ⇒ math.abs(a - b)}.sum / 2
  )
}


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

using namespace std;
#define lli long long int
#define ff first
#define ss second
#define lld long double
#define mp make_pair
#define pb push_back
#define mod 1000000007
const int nax=1000*1007;
lli revi(lli i){lli rev=0; while(i>0){rev=(rev*10)+(i%10); i=i/10;}  return rev;}


int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    string s;
    int k,n;
    cin>>n>>k;
    cin>>s;
    char ch=s[k-1];
    ch=ch+32;
    s[k-1]=ch;
    cout<<s<<endl;
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
	int A, B, r;
	scanf("%d %d", &A, &B);
	A = A-1;
	B = B-1;	
	r = (B - B % A) / A; 
	
	if (B%A == 0){
		printf("%d", r);
	}
	else printf("%d", r+1);
	
	return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<iomanip>
using namespace std;
int main(){
    double n,k,f,sum=0;
    cin>>n>>k;
    for(int i=1;i<=n;i++){
        if(i>=k){
            sum++;
        }
        else{
            f=i;
            double f2=1;
            while(f<k){
                f*=2;
                f2*=0.5;
            }
            sum+=f2;
        }
    }
    cout<<fixed<<setprecision(12)<<sum/n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
using namespace std;

int main() {
    ll n, ans=0;
    cin >> n;
    vector<int> l(n);
    rep(i, n)cin >> l.at(i);
    sort(l.begin(), l.end());
    rep(i, n){
        rep(j, i){
            ans += lower_bound(all(l), l.at(j)+l.at(i)) - l.begin() - i - 1;
        }
    }
    cout << ans;
}


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

using namespace std;
typedef long long ll;
static const ll MOD = 1e9 + 7;

#define rep(i,s,n)for(int i = s;i<n;i++)
#define rep_r(i,s,n)for(int i = n-1;i>=s;i--)
#define repe(i,s,n)for(int i = s;i<=n;i++)
#define repe_r(i,s,n)for(int i = n;i>=s;i--)

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

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

int main() {
	ll a, b, c, d; cin >> a >> b >> c >> d;
	ll T = b - a + 1;
	ll L = lcm(c, d);

	ll X = (b / c) - (a / c) + (!(a % c) ? 1 : 0);
	ll Y = (b / d) - (a / d) + (!(a % d) ? 1 : 0);;
	ll Z = (b / L) - (a / L) + (!(a % L) ? 1 : 0);;

	cout << T - (X + Y - Z) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int val;
  int gp1, gp2, gp3;
  
  cin >> val;
  
  gp1 = val / 100;
  gp2 = (val / 10) - (10 * gp1);
  gp3 = val - (10*gp2) - (100*gp1);
  
  cout << gp1 + gp2 + gp3 << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int d=0,t=0,e=0,a,b,c,A,B,C,h;
	while(1){
		scanf("%d%d%d",&a,&b,&c);
		if(a>b&&a>c){
			C=a;
			A=b;
			B=c;
		}else if(b>a&&b>c){
			B=c;
			C=b;
			A=a;
		}else{
			A=a;
			B=b;
			C=c;
		}
		if(A+B<=C){
			printf("%d %d %d %d\n",d+t+e,t,e,d);
			break;
		}
		h=A*A+B*B-C*C;
		if(h>0){
			e++;
		}else if(h<0){
			d++;
		}else{
			t++;
		}
	}
	return 0;
}

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

using namespace std;

#define PI acos(-1)

int main(void){
  int a, b, theta;
  double rtheta, c, s, l, h;
  scanf("%d %d %d", &a, &b, &theta);
  rtheta = PI * theta / 180.0;
  c = sqrt((double) a*a + ((double)b*b) - (2.0 * a * b * cos(rtheta)));
  s = ((a * b) / 2.0) * sin(rtheta);
  l = a + b + c;
  h = b * sin(rtheta);
  printf("%lf\n%lf\n%lf\n", s, l, h);
  return 0;
}



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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

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(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int32 cnt[26] = {};
	REP(i, s.size()) cnt[s[i]-'a']++;
	if(s.size() < 26){
		cout << s;
		REP(j, 26){
			if(cnt[j] == 0){
				cout << (char)('a'+j) << endl;
				return 0;
			}
		}
	}else{
		int32 c2[26] = {};
		for(int32 i = s.size()-1;i >= 0;i--){
			FOR(j, s[i]-'a'+1, 26){
				if(c2[j]){
					cout << s.substr(0, i) << (char)(j+'a') << endl;
					return 0;
				}
			}
			c2[s[i]-'a']++;
		}
	}
	cout << -1 << endl;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))

cnt = [0] * 10**5
for v in a:
    cnt[v] += 1

res = 0
for i in range(10**5-2):
    res = max(res, cnt[i] + cnt[i+1] + cnt[i+2])

print(res)

Measured memory_bytes: 84724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N;
    cin >> N;

    if(N%2 != 0){
        cout << 0 << endl;
        return 0;
    }
    
    ll ten = 10, ans = 0;
    while(ten <= N){
        ans += N/ten;
        ten = ten*5;
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
using namespace std;
int main(){
    int a,b,c,x,y;
    scanf("%d %d %d %d %d\n",&a,&b,&c,&x,&y);
    int sum=a*x+b*y;
    int d=min(x,y);
    //cout<<sum<<endl;
    sum=min(sum,d*2*c+(x-d)*a+(y-d)*b);
    //cout<<sum<<endl;
    d=max(x,y);
    sum=min(sum,d*2*c);
    printf("%d\n",sum);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
//もう二度とつかわん//
//    ↓ ↓　↓　　 //
#define ll long long
//    ↑　↑　↑    //
//フェルマー方程式の恨み//
#define rep(i,n) for(int i=0;i<n;i++)
#define ggr getchar(); getchar();return 0;
using namespace std;
//素数判定
bool prime(ll n) {
	if (n == 1)return false;
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
signed main() {
	string a, b, c;
	cin >> a >> b >> c;
	ll i = 1, j = 0, k = 0;
	char s = a[0];
	while (i <= a.size() && j <= b.size() && k <= c.size()) {
		if (s == 'a') {
			s = a[i];
			i++;
		}
		else if (s == 'b') {
			s = b[j];
			j++;
		}
		else {
			s = c[k];
			k++;
		}
	}
	if (i == a.size() + 1)puts("A");
	else if (j == b.size() + 1)puts("B");
	else puts("C");
}


Measured memory_bytes: 256
N,A,B,C,D = map(int,input().split())
S = input()
sunuke = A
hunuke = B

def syori1(sunuke,hunuke):
    while hunuke<D:
        if hunuke+1 == N:
            return "Yes"
        if S[hunuke+1] == ".":
            hunuke += 2
        elif S[hunuke] == ".":
            hunuke += 1
        else:
            return "No"
    
    while sunuke<C:
        if sunuke + 1 == N:
            return "Yes"
        if S[sunuke+1] == ".":
            sunuke += 2
        elif S[sunuke] == ".":
            sunuke += 1
        else:
            return "No"
    
    return "Yes"

def canover():
    for i in range(B-2,D-1):
        if S[i] == "." and S[i+1] == "." and S[i+2]==".":
            return True
        else:
            pass
    return False
    
def tonari():
    if S[B]==".":
        return True
    else:
        return False

if C > D:
    if A+1 == B:
        if tonari():
            print(syori1(sunuke,hunuke))
            exit()
            
    if canover():
        print(syori1(sunuke,hunuke))
    else:
        print("No")
else:
    print(syori1(sunuke,hunuke))

Measured memory_bytes: 3572
console.log((args=>{
  const [[N],A] = args.trim().split('\n').map( r=>r.split(' ').map(v=>v|0) );
  let C = Math.abs(A[0]) + Math.abs(A[N-1]);
  for ( let i = 1; i < N; i++ ) {
    C += Math.abs( A[i] - A[i-1] );
  }
  const c = [C - Math.abs(A[0]) - Math.abs(A[1]-A[0]) + Math.abs(A[1])];
  for ( let i = 1; i < N-1; i++ ) {
    c.push( C - Math.abs(A[i+1]-A[i]) - Math.abs(A[i]-A[i-1]) + Math.abs(A[i+1]-A[i-1]) );
  }
  c.push( C - Math.abs(A[N-1]) - Math.abs(A[N-2]-A[N-1]) + Math.abs(A[N-2]));
  return c.join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 45948
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  string s;cin >> s;
  YesNo(s.length()>=4 && s.substr(0,4) == "YAKI");
  return 0;
}


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

#define M 1046527
#define L 14

char H[M][L]; /* Hash Table */

int getChar(char ch){
  if ( ch == 'A') return 1;
  else if ( ch == 'C') return 2;
  else if ( ch == 'G') return 3;
  else if ( ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key)+i*h2(key)) % M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key,i,h;
  key = getKey(str);
  for(i = 0;;i++){
    h = (h1(key)+i*h2(key) )% M;
    if(strcmp(H[h],str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h],str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++) H[i][0] = '\0';
  //命令する数
  scanf("%d", &n);
  
  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);
    //一文字目がiならinsertを実行
    if ( com[0] == 'i' ){
      insert(str);
      //違ったらfind
    } else {
      if (find(str)){
	printf("yes\n");
      } else {
	printf("no\n");
      }
    }
  }
  return 0;
}
    


Measured memory_bytes: 16052
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      aa: [i64; n],
    }
    let mut aa = aa;
    aa.sort();
    let mut c = vec![2; n];
    c[0] = 1;
    c[n-1] = 1;
    for i in 0..n {
      if i % 2 == 0 {
        c[i] = -1 * c[i];
      }
    }

    c.sort();
    let mut s1 = 0;
    for i in 0..n {
      s1 += c[i] * aa[i];
    }

    let mut s2 = 0;
    for i in 0..n {
      c[i] = c[i] * -1;
    }
    c.sort();
    for i in 0..n {
      s2 += c[i] * aa[i];
    }
    println!("{}", max(s1, s2));
}


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

int a[100100];
const int mod = 1e9+7;



long long quick_mul(ll a,ll b)
{
	ll yaoyuan = 0;
	while(b)
	{
		if(b&1)
		{
			yaoyuan = (yaoyuan+a)%mod;
		}
		a = (a+a)%mod;
		b>>=1; 
	}
	return yaoyuan;
}

long long quick_pow(ll a,ll b)
{
	ll yaoyuan = 1;
	while(b)
	{
		if(b&1)
		{
			yaoyuan = quick_mul(yaoyuan,a)%mod;
		}
		a = quick_mul(a,a)%mod;
		b>>=1; 
	}
	return yaoyuan;
}


int main()
{
	int n;
	
	while(~scanf("%d",&n))
	{
		memset(a,0,sizeof(a));
		int sum = 0;
		ll ans = 0ll;
		int ai;
		for(int i = 0; i < n;i++)
		{
			scanf("%d",&ai);
			a[ai]++;
		}
		int F = 0;
		if(n%2)
		{
			if(a[0] == 1)
			{
				for(int i = 2;i < n;i+=2)
				{
					if(a[i]!=2)
					{
			//			printf("%d %d",i,a[i]);
						F = 1;
						break;
					}
				}
				
				
			}
			else
			{
				F = 1;
			}
		}
		else
		{
			for(int i = 1;i < n;i+=2)
			{
				if(a[i]!=2)
				{
					F = 1;
					break;
				}
			}
				
			
		}
		
		if(F)
		{
			printf("0\n");
		}
		else
		{
			
			printf("%I64d\n",quick_pow(2,n/2));
		}
		
		
		
		
	}

/*
5
2 4 4 0 2
 
7
6 4 0 2 4 0 2
 
8
7 5 1 1 7 3 5 3

*/


 return 0;
}



Measured memory_bytes: 640
H,W=map(int,input().split())
D={chr(code): 0 for code in range(ord('a'), ord('z') + 1)}
for i in range(H):
  A=list(input())
  for i in A:
    D[i]+=1
if H%2==0 and W%2==0:
  for i in D.values():
    if i%4!=0:
      print('No')
      exit()
  print('Yes')
elif H%2==1 and W%2==1:
  E=[]
  for i in D.values():
    if i%4!=0:
      E.append(i%4)
  E=sorted(E)
  a=H+W-1
  if H==1 or W==1:
    for i in range(a//2+1):
      if E==[1]+[2]*i:
        print('Yes')
        exit()
    print('No')
    exit()    
  if (a+1)//2 <len(E):
    print('No')
    exit()
  for i in range(a//2+2):
    if E==[1]+[2]*i:
      print('Yes')
      exit()
  print('No')
else:
  E=[]
  for i in D.values():
    if i%4!=0:
      E.append(i%4)
  E=sorted(E)
  if H%2==0:
    a=H
  else:
    a=W
  if a//2 <len(E):
    print('No')
    exit()
  for i in range(a//2+1):
    if E==[2]*i:
      print('Yes')
      exit()
  print('No')


Measured memory_bytes: 3064
ABCD = input()
f = ""
for i in range(2 ** (len(ABCD) - 1)):
    f = ""
    for j in range(len(ABCD)):
        f += ABCD[j]
        if j != len(ABCD)-1:
            if (i >> (len(ABCD)-1-1-j)) & 1:
                f += "+"
            else:
                f += "-"
    if eval(f) == 7:
        print(f + "=7")
        exit()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;cin>>n;
  int a1[n],a2[n];for(int i=0;i<n;i++)cin>>a1[i];
  for(int i=0;i<n;i++)cin>>a2[i];
  int m=0;
  for(int i=0;i<n;i++){
    int sum=0;
    for(int j=0;j<=i;j++)sum+=a1[j];
    for(int j=i;j<n;j++)sum+=a2[j];
    m=max(m,sum);
  }
  cout<<m<<endl;
}

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

using namespace std;

int main() {
	Int N, a, b;
	cin >> N >> a >> b;

	Int diff = abs(a - b);
	if (diff % 2 == 0) {
		cout << diff / 2 << endl;
		return 0;
	}

	Int ans = 1e18;
	Int M = max(a, b);
	Int m = min(a, b);
	ans = min(ans, max(a, b) - 1);
	ans = min(ans, N - min(a, b));
	ans = min(ans, m + (M - m - 1) / 2);
	ans = min(ans, N - M + 1 + (M - m - 1) / 2);
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));

int main()
{
    cout << fixed << setprecision(30);
    ll n;
    cin >> n;
    vec a(n);
    loop(i, n) cin >> a[i];
    bool check = false;
    if (a[0] != 0)
        check = true;
    loop(i, n - 1)
    {
        if (a[i + 1] - a[i] > 1)
            check = true;
    }
    if (check)
    {
        putout(-1);
        return 0;
    }
    ll ans = 0;
    loop(i, n - 1)
    {
        if (a[i + 1] == a[i] + 1)
            ans++;
        else
            ans += a[i + 1];
    }
    putout(ans);
    return 0;
}


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

int main(){
  string a, b;
  cin >> a >> b;
  
  if(a.size() > b.size())
    cout << "GREATER" << endl;
  
  else if(a.size() < b.size())
    cout << "LESS" << endl;
  
  else{
    for(int i = 0; i < a.size(); i++){
      if(a[i] > b[i]){
        cout << "GREATER" << endl;
        break;
      }
      
      else if(a[i] < b[i]){
        cout << "LESS" << endl;
        break;
      }
      else{
        if(i == a.size() - 1){
          cout << "EQUAL" << endl;
        }
      }
    }
    
  }
}
    
    

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

int main(){
  int a, b, c;
  int i;
  int num;
  
  while(scanf("%d", &a)!=EOF){
    scanf("%d", &b);
    
    i = 10;
    num = 1;
    c = a + b;
    while(1){
      if(c/i!=0){
        num++;
        i *= 10;
      }else{
        break;
      }
    }
    std::cout << num << std::endl;
  }
  
  return 0;
  
}

Measured memory_bytes: 3160
N = int(input())
xyh = [list(map(int, input().split())) for i in range(N)]
# print(N, xyh)

height = None
found = False
for cx in range(0, 101):
    for cy in range(0, 101):
        candidate = 0
        for x, y, h in xyh:
            if h == 0: continue
            dx = abs(x - cx)
            dy = abs(y - cy)
            candidate = dx + dy + h 
            break

        found = True
        for x, y, h in xyh:
            _h = max(candidate - abs(x - cx) - abs(y - cy), 0)
            if h != _h:
                found = False
                break
        
        if found is True: break
    if found is True: break
height = candidate if candidate is not None else 0

print(cx, cy, height)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector <pii> vpii;
typedef vector <pll> vpll;
typedef map <str,int> mapsi;
typedef map <str,int> :: iterator mapsitr;
typedef map <int , int> mint;
typedef map <ll , ll> mll;
typedef set <int> si;
typedef set <ll> sll;
typedef si :: iterator sitr;
typedef si :: reverse_iterator rsitr;
typedef sll :: iterator sltr;
typedef sll :: reverse_iterator rsltr;
#define mset multiset
typedef mset <int> msi;
typedef mset <ll> msll;
typedef msi :: iterator msitr;
typedef msi :: reverse_iterator msritr;
typedef msll :: iterator msltr;
typedef msll :: reverse_iterator mslritr;
#define mp make_pair
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define fs first.second
#define ss second.second
#define ff first.first
#define sf second.first
#define newl '\n'
char to_upper (char x){
    if( 97 <= int(x) && int(x) <= 126)return char(x-32);
    else if( 65 <= int(x) && int(x) <= 90)return x;
}
char to_lower (char x){
    if( 97 <= int(x) && int(x) <= 126)return x;
    else if( 65 <= int(x) && int(x) <= 90)return char(x+32);
}
int numerize (char x){
    if(48 <= int(x) && int(x) <= 57)return int(x-'0');
    else if( 97 <= int(x) && int(x) <= 126)return int(x-96);
    else if( 65 <= int(x) && int(x) <= 90)return int(x-64);
}
//void IO(){
//	#ifndef ONLINE_JUDGE
//	    freopen("input.txt", "r", stdin);
//	    freopen("output.txt", "w", stdout);
//	#endif
//}
// end of Template

bool isprime[300010];
vi prime,ans;
void sieve(int x){
    for(int i=2;i<=x;i++)isprime[i]=true;
    for(int i=2;i<=x;i++){
        if(isprime[i]){
            if(i%5==1)prime.pb(i);
            for(int j=i*2;j<=x;j+=i){
                isprime[j]=false;
            }
        }
    }
}
int n,idx;
int main(){
	//IO();
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    sieve(300000);
    cin>>n;
    cout<<prime[0];
    for(int i=1;i<n;i++){
        cout<<" "<<prime[i];
    }cout<<newl;


}


Measured memory_bytes: 640
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import math
import collections


def simple_count(S, changed=False):
    count = 0
    for i in range(len(S) - 1):
        if changed:
            changed = False
        else:
            if S[i] == S[i + 1]:
                changed = True
                count += 1
    return count, changed


def solve(S, K):
    if K == 1:
        return simple_count(S)[0]
    if S[0] != S[-1]:
        return simple_count(S)[0] * K
    else:
        count2, changed = simple_count(S * 2)
        # print(count2, changed)
        if changed:
            return count2 * (K // 2) + simple_count(S, changed=False)[0] * (K % 2)
        else:
            return (count2) * (K // 2) + 1 * (K // 2-1 + K % 2) + simple_count(S, changed=True)[0] * (K % 2)
        # return simple_count(S + S[0])[0] * K


def test(S, K):
    SS = "".join([c for c in reversed(S)])
    # assert solve(S, K) == solve(SS, K), "{} {} = {} {}".format(S, SS, solve(S, K), solve(SS, K))
    assert solve(S, K) == simple_count(S * K)[0], "{} {} = {} {}".format(S, K, solve(S, K), simple_count(S * K)[0])


assert solve("cooooooooonteeeeeeeeeest", 999993333) == 8999939997
assert solve("aqqq", 2) == simple_count("aqqq" * 2)[0]
test("qq", 81)
# print(solve("qqq", 2), simple_count("qqq" * 2)[0])
assert solve("qqq", 2) == simple_count("qqq" * 2)[0]
# print(solve("qqq", 3), simple_count("qqq" * 3)[0])
assert solve("qqq", 3) == simple_count("qqq" * 3)[0]
assert solve("issii", 2) == simple_count("issii" * 2)[0]

test("iqi", 3)
test("iqqqqiiii", 1)
test("iqi", 2)
test("iqqqqiiii", 2)
test("iqii", 3)
test("iqii", 4)
test("iqqqqiiii", 6)
test("iqqqqiiii", 7)
test("qqqqqiiiii", 7)
test("q", 7)
test("qiq", 1)
test("qiq", 3)
test("qiq", 7)
test("qqq", 7)
test("qq", 7)
test("abcdef", 7)
test("qbbbq", 7)
test("qqqq", 7)
test("qqqqq", 7)

S = sys.stdin.readline().rstrip()
K, = map(int, sys.stdin.readline().rstrip().split(" "))
SS = "".join([c for c in reversed(S)])
print(min(solve(S, K), solve(SS, K)))

exit(0)


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

int main() {
  char a, t;
  cin >> a >> t;
  if (a == 'H' && t == 'H') {
    cout << 'H' << endl;
  }
  if (a == 'H' && t == 'D') {
    cout << 'D' << endl;
  }
  if (a == 'D' && t == 'H') {
    cout << 'D' << endl;
  }
  if (a == 'D' && t == 'D') {
    cout << 'H' << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {   
	    public static void main(String[] args) {
	      Scanner sc = new Scanner(System.in);
	      long N= sc.nextLong(); long M = sc.nextLong();
	      System.out.println(Math.abs((N-2)*(M-2))); sc.close();    
	}
}

Measured memory_bytes: 22996
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <cmath>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
typedef long long ll;
using namespace std;
int main(){
    int n,k,x,y;
    cin>>n>>k>>x>>y;
    if(n<=k) cout<<n*x<<endl;
    else cout<<k*x+(n-k)*y<<endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int n = s.length();
  if(s[n-1] == '1' || s[0] == '0'){
    cout << -1 << endl;
    return 0;
  }
  for(int i = 0; i < n-1; ++i){
    if(s[i] != s[n-2-i]){
      cout << -1 << endl;
      return 0;
    }
  }
  int v = 1;
  for(int i = 0; i < n-1; ++i){
    cout << v << " " << i+2 << endl;
    if(s[i] == '1') v = i+2;
  }
  return 0;
}


Measured memory_bytes: 1664
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
string A, B;
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>A>>B;
    A += B;

    int n = stoi(A);
    double nn = double(n);


    if((int)sqrt(nn) * (int)sqrt(nn) == (int)nn){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;
}


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

using namespace std;
typedef long long ll;

ll nums[5];

int main(){
    double N;
    double m[5];
    cin >> N; 
    for (int i = 0; i < 5; i++) cin >> m[i];

    double minflow = *min_element(m, m+5);

    ll res = ceil((double)(N / minflow)) + 4;
    cout << res << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n;
char s[maxn];

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	
	LL ans=0;
	int w=1;
	fo(i,1,n) if (s[i]=='W') ans+=i-(w++);
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
 
int main() {
  string S, T; cin >> S >> T;
  string result = "UNRESTORABLE";
  if ( S.length() < T.length() ) {
    cout << result << endl;
    return 0;
  }

  for (int i=0; i<=S.length()-T.length(); i++) {
    bool match = true;
    for (int j=0; j<T.length(); j++) {
      if ( S[i+j] != T[j] && S[i+j] != '?' ) match = false;
    }
    if (match) {
      string s = S;
      for (int j=0; j<S.length(); j++) {
        if (j>=i && j<i+T.length()) s[j] = T[j-i];
        else if ( s[j] == '?' ) s[j] = 'a';
      }
      if ( result == "UNRESTORABLE" ) result = s;
      else result = min(result, s);
    }
  }
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 256
x = y = z = 0
ans = 0

n = int(input())
for _ in range(n):
    s = input()
    ans += s.count("AB")

    if s[0] == 'B' and s[-1] == 'A':
        x += 1
    elif s[-1] == 'A':
        y += 1
    elif s[0] == 'B':
        z += 1

if y == 0 and z == 0:
    ans += max(x - 1, 0)
else:
    ans += x + min(y, z)

print(ans)

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

using namespace std;
typedef long long ll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)

/*Solve*/

int main(){
    ll n;
    vector<ll> ai,aj;
    cin >> n;
    map<ll,ll> mpi,mpj;
    ll maxi=0,maxj=0;
    
    vector<ll> v;
    rep(i,n){
        ll x;
        cin >> x;
        v.push_back(x);
    }
    
    ll tmpe[2];
    for(int i=0;i<n;i+=2){
        mpi[v[i]]++;
        if(maxi<mpi[v[i]]){
            maxi++;
            if(v[i]!=tmpe[0])tmpe[1]=tmpe[0];
            tmpe[0]=v[i];
        }
    }
    ll tmpo[2];
    bool flg=false;
    for(int i=1;i<n;i+=2){
        if(v[i]!=tmpe[0]){
            mpj[v[i]]++;
            if(maxj<mpj[v[i]]){
                if(v[i]!=tmpo[0])tmpo[1]=tmpo[0];
                maxj++;
                tmpo[0]=v[i];
            }
        }
    }

    ll x,y;
    x=n-(maxi+maxj);
    maxi=0;maxj=0;
    map<ll,ll> mp1,mp2;
    for(int i=1;i<n;i+=2){
        mp2[v[i]]++;
        if(maxj<mp2[v[i]]){
            maxj++;
            tmpo[0]=v[i];
        }
    }
    for(int i=0;i<n;i+=2){
        if(v[i]!=tmpo[0])
        mp1[v[i]]++;
        if(maxi<mp1[v[i]]){
            maxi++;
        }
    }
    y=n-(maxi+maxj);
    cout << min(x,y);
}


Measured memory_bytes: 13556