akhauriyash/Code-Regression huggingface dataset:
k, a, b = map(int,input().split())

if a >= b:
    print(1+k)
else:
    p1 = [1,1]
    p2 = [b-a,2]
    proc = [p1,p2]
    proc.sort(key=lambda x:x[0]/x[1])
    proc.reverse()
    if proc[0] == p1:
        print(1+k)
    elif proc[0] == p2:
        if a-1 > k:
            print(1+k)
        else:
            print(a+((k-a+1)//2)*(b-a)+(k-a+1)%2)

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

int main () {

    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);

    long long a, b, x; cin >> a >> b >> x;
    cout << b/x - a/x + (a%x == 0) << '\n';
  
    return 0;
}



Measured memory_bytes: 3548
#include<iostream>
using namespace std;
#include<string>

class dice
{
public:
    int F[6];
    dice();
    void roll_a();
    void roll_b();
    bool check(const dice& d);
};

dice::dice()
{
    for(int i = 0; i < 6; i++) cin >> F[i];
}

void dice::roll_a()
{
    static int i, j;
    i = F[0]; F[0] = F[2]; F[2] = F[1]; F[1] = i;
    j = F[3]; F[3] = F[4]; F[4] = F[5]; F[5] = j;
}

void dice::roll_b()
{
    static int k;
    k = F[0]; F[0] = F[5]; F[5] = k;
    k = F[1]; F[1] = F[3]; F[3] = k;
    k = F[2]; F[2] = F[4]; F[4] = k;
}

bool dice::check(const dice& d)
{
	static int l, m;
    if((d.F[0] != F[0]) || (d.F[5] != F[5])) return false;

    for(l = 1; l <= 4; l++){
        for(m = 1; m <= 4; m++){
            if(d.F[m] != F[(l * m) % 5]) break;
        }
        if(m == 5) return true;
    }
    return false;
}

int main()
{
    dice d1 = dice();
    dice d2 = dice();
    bool eq = false;

    for(int i = 0; i < 2; i++){
        eq = d1.check(d2);
        if(!eq){ d1.roll_a(); eq = d1.check(d2); }
        if(!eq){ d1.roll_a(); eq = d1.check(d2); }
        if(eq || (i == 1)) break;
        d1.roll_b();
    }

	if(eq){ cout << "Yes" << endl; }else{ cout << "No" << endl; }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FOR(i,j,n,m) for(int i=j;i<n;i+=m)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define pob pop_back
#define MP make_pair
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.F<<","<<_p.S<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}

template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=(ll)1e18;

int main(){
  IOS();
  ll a,b;
  cin>>a>>b;
  ll ans=0;
  ans+=a;
  if(b<a) ans--;
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;

double sqr(double x) { return x*x; }

struct circle
{
  int x, y, r, c;
  bool covers(const circle& a) const
  {
    return sqrt(sqr(x - a.x) + sqr(y - a.y)) < r + a.r;
  }
};

int N;
circle cs[24];

map<int,int> memo;
int dfs(int used)
{
  map<int,int>::iterator it = memo.find(used);
  if (it != memo.end()) {
    return it->second;
  }
  int& ans = memo[used];

  ans = 0;
  bool top[24];
  fill_n(top, 24, true);
  for (int i = 0; i < N; i++) {
    if (used & (1<<i)) {
      continue;
    }
    for (int j = i+1; j < N; j++) {
      if (used & (1<<j)) {
        continue;
      }
      if (cs[i].covers(cs[j])) {
        top[j] = false;
      }
    }
  }
  for (int i = 0; i < N; i++) {
    if (used & (1<<i)) {
      continue;
    }
    if (!top[i]) {
      continue;
    }
    for (int j = i+1; j < N; j++) {
      if (used & (1<<j)) {
        continue;
      }
      if (!top[j]) {
        continue;
      }
      if (cs[i].c == cs[j].c) {
        ans = max(ans, 2 + dfs(used | (1<<i) | (1<<j)));
      }
    }
  }
  return ans;
}

int main()
{
  while (cin >> N && N != 0) {
    for (int i = 0; i < N; i++) {
      cin >> cs[i].x >> cs[i].y >> cs[i].r >> cs[i].c;
    }
    memo.clear();
    cout << dfs(0) << endl;
  }
  return 0;
}

Measured memory_bytes: 32000
///Nahid Hasan Raju
#include <bits/stdc++.h>

#define MS(ARRAY,VALUE) memset(ARRAY,VALUE,sizeof(ARRAY))
#define Fin freopen("input.txt","r",stdin)
#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define Fout freopen("output.txt","w",stdout)
#define rep(i,a,b) for(i=a;i<=b;i++)
#define EPS 0.00000001
#define INF INT_MAX
#define PI 2*acos(0.0)
#define P1(XX) cout<<"db1: "<<XX<<endl
#define P2(XX,YY) cout<<"db2: "<<XX<<" "<<YY<<endl
#define P3(XX,YY,ZZ) cout<<"db3: "<<XX<<" "<<YY<<" "<<ZZ<<endl
#define set(XX,POS) XX|=(1<<POS)
#define reset(XX,POS) XX&=(~(1<<POS))
#define check(XX,POS) (bool)(XX&(1<<POS))
#define toggle(XX,POS) (XX^(1<<POS))
#define SORT(v) sort(v.begin(),v.end())
#define REVERSE(V) reverse(v.begin(),v.end())
#define VALID(X,Y,R,C) X>=0 && X<R && Y>=0 && Y<C
#define SIZE(ARRAY) sizeof(ARRAY)/sizeof(ARRAY[0])
#define RT printf("Run Time : %0.3lf seconds\n", clock()/(CLOCKS_PER_SEC*1.0))
#define ll long long
#define pll pair<ll,ll>
#define pii pair<int,int>


using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
typedef tree< pair<int,int> , null_type, less< pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> odrst;

#define MOD 1000000007LL
#define MX 2000006


/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

ll a[MX];

ll n, k,c;
string s;
map<string, int>p;
int main()
{
    //Fin;
    int test, tc=0, i, j;
    ll m, d, l, ans,sum=0;
    int t;
    //scanf("%d", &test);
    test=1;
    while(test--)
    {
        //MS(a,0);
        cin>>n;
        for(i=0;i<n;i++)
        {
            cin>>s;
            p[s]++;
        }
        if(n==0)n=1000;
        cout<<"AC "<<"x "<<p["AC"]<<endl;
        cout<<"WA "<<"x "<<p["WA"]<<endl;
        cout<<"TLE "<<"x "<<p["TLE"]<<endl;
        cout<<"RE "<<"x "<<p["RE"]<<endl;
    }
    return 0;
}



Measured memory_bytes: 3604
N,Q=map(int,input().split())
S=input()
s_cnt=[]
cnt=0
for i in range(N-1):
    if S[i]=="A" and S[i+1]=="C":
        cnt+=1
        s_cnt.append(cnt)
    else:
        s_cnt.append(cnt)
for i in range(Q):
    l,r=map(int,input().split())
    l-=2
    r-=2
    if l<0:
        print(s_cnt[r])
    else:    
        print(s_cnt[r] - s_cnt[l])

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

#define MEM(a, b) memset(a, b, sizeof a);
#define REP(i, k) for(int i = (0); i < (k); i++ )

#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define debug puts("FANGO")
#define INF (int)INT_MAX
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;

template <class T>
T sqr(T val) {
  return val * val;
}

int gcd(int a, int b) {
  if (b == 0) return a;
  else if (a >= b) return gcd(b, a % b);
  else return gcd(b, a);
}

void solve(__attribute__((unused)) int tc = 0) {
  int n;
  cin >> n;
  vi v;
  REP(i, n) {
    int x;
    cin >> x;
    v.pb(x);
  }

  vi g1, g2;
  REP(i, n) {
    if (g1.empty()) g1.pb(v[i]);
    else g1.pb(gcd(g1.back(), v[i]));
    if (g2.empty()) g2.pb(v[n - i - 1]);
    else g2.pb(gcd(g2.back(), v[n - i - 1]));
  }

  int ans = -INF;

  REP(i, n) {
    if (i == 0) {
      ans = max(ans, max(gcd(v[i], g2[n - 2 - i]), g2[n - 2 - i]));
    }
    else if (i == n - 1) {
      ans = max(ans, max(gcd(v[i], g1[i - 1]), g1[i - 1]));
    }
    else {
      int q = gcd(g1[i - 1], g2[n - 2 - i]);
      ans = max(ans, max(gcd(v[i], q), q));
    }
  }

  cout << ans << endl;


  return;
}

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  /*int TC;
  cin >> TC;
  REP(tc, TC) {
    solve(tc);
  }*/
  solve();
}


Measured memory_bytes: 1912
#include <stdio.h>
#define HEAP 600000
 
void maxHeapify(int *, int);
void buildMaxHeap(int *);
int n;
 
int main(){
  int i, key[HEAP];
 
  scanf("%d", &n);
 
  for(i = 1; i <= n; i++){
    scanf("%d", &key[i]);
  }
 
  buildMaxHeap(key);
 
  for(i = 1; i <= n; i++)
    printf(" %d",key[i]);
  printf("\n");
 
  return 0;
}
 
void maxHeapify(int *A, int i){
  int left, right, largest, tmp;
  left = i * 2;
  right = i * 2 + 1;
   
  if(left <= n && A[left] > A[i])
    largest = left;
  else largest = i;
   
  if(right <= n && A[right] > A[largest])
    largest = right;
   
  if(largest != i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(A, largest);
  }
}
 
void buildMaxHeap(int *A){
  int i;
 
  for(i = n / 2; i >= 1; i--)
    maxHeapify(A, i);
}

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

namespace Distance
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            double[] ngo = new double[4];
            for(int i = 0; i < input.Length; ++i){
                ngo[i] = double.Parse(input[i]);
            }
            Console.WriteLine(Math.Sqrt(Math.Pow(ngo[2] - ngo[0], 2) + Math.Pow(ngo[3] - ngo[1], 2))); 
        }
    }
}


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

int main() {
  int N = 5;
  int max_v = 0, min_v = 123;
  int k;
  for (int i = 0; i < N; i++) {
    int v;
    cin >> v;
    max_v = max(max_v, v);
    min_v = min(min_v, v);
  }
  cin >> k;
  if (max_v - min_v <= k) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  return 0;
}


Measured memory_bytes: 256
// AOJ Volume 0 Problem 0023

#include <stdio.h>
#include <math.h>

int main(void)
{
	int n;
	double xa, ya, ra, xb, yb, rb;
	int i;
	double dd, d;
	double result;
	
	scanf("%d", &n);
	
	for (i = 0; i < n; i++){
		scanf("%lf%lf%lf%lf%lf%lf", &xa, &ya, &ra, &xb, &yb, &rb);
		
		dd = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);

		d = sqrt(dd);
		
		if (d > (ra + rb)){
			printf("0\n");
			continue;
		}
		
		if (ra + d < rb){
			printf("-2\n");
			continue;
		}
			
		if (rb + d < ra){
			printf("2\n");
			continue;
		}
		
		printf("1\n");
	}
	return (0);
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b;
  cin >> a >> b;
  
  if(a%2 != 0 && b%2 != 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c;
    cin>>a>>b;
    if(a==1&&b==2)
        cout<<"3"<<endl;
    else if(a==1&&b==3)
        cout<<"2"<<endl;
    else if(a==2&&b==3)
        cout<<"1"<<endl;
    else if(a==2&&b==1)
        cout<<"3"<<endl;
    else if(a==3&&b==1)
        cout<<"2"<<endl;
    else if(a==3&&b==2)
        cout<<"1"<<endl;
    return 0;

}


Measured memory_bytes: 256
from math import gcd
from sys import exit
n, m = map(int, input().split())
s = input()
t = input()
x = gcd(n, m)
y = n * m // x
a = n // x
b = m // x
for i in range(x):
    if s[i * a] != t[i * b]:
        print(-1)
        exit()
print(y)

Measured memory_bytes: 9300
#include<iostream>

using namespace std;

int main(){
    int n,ma=-1e10,mi=1e10,r;
    cin>>n;
    while(n--){
        cin>>r;
        ma = max(ma,r-mi);
        mi = min(mi,r);
    }
    cout<<ma<<endl;
    return 0;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ll long long int
#define INF 1000000007
#define llINF 1000000000000000007
#define v(i) vector<i>
#define vv(i) vector<vector<i>>
// cin.eof() 入力個数の問題
// int num = atoi(string.c_str()); 文字列の整数変換

int main() {
    int h, w;
    cin >> h >> w;
    int a[] = {1, 0, -1, 0};
    int b[] = {0, 1, 0, -1};
    char A[h][w];
    int point[h][w];
   queue<pair<int,int>> que;
    rep(i, h) {
        rep(j, w) {
            cin >> A[i][j];
            point[i][j] = 0;
            if (A[i][j] == '#') {
                que.push(make_pair(i, j));
            }
        }
    }

    while (!que.empty()) {
        int ny = que.front().first, nx = que.front().second;
        que.pop();

        rep(i, 4) {
            int y = ny + a[i], x = nx + b[i];
            if (y < 0 || y >= h || x < 0 || x >= w || A[y][x] == '#')
                continue;
            point[y][x] = point[ny][nx] + 1;
            A[y][x] = '#';
            que.push(make_pair(y,x));
        }
    }
    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, point[i][j]);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 16244
#include<iostream> 
using namespace std;
int main(){
int x,y,i;
for(i=1;i<3000;i++){
cin>>x>>y;
if(x==0&&y==0)break;
if(x<y){
cout<<x<<" "<<y<<endl;
}else if(x>y){
cout<<y<<" "<<x<<endl;
}if(x==y){
cout<<x<<" "<<y<<endl;
}
}
return 0;
}


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

int main() {
    int64 N; cin >> N;
    for(int n = 1; n < 3501; ++n) {
        for(int w = 1; w < 3501; ++w) {
            int64 u = 4 * n * w - N * w - N * n;
            if(u <= 0) continue;
            int64 b = N * n * w;
            if(b % u) continue;
            int64 h = b / u;
            if(1 <= h && h <= 3500) {
                cout << h << " ";
                cout << n << " ";
                cout << w << '\n';
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define all(a)  (a).begin(),(a).end()
typedef long long ll;
const ll mod=1000000007;
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)

int main() {
  int n,k,s;cin>>n>>k>>s;
  vector<int> v(n,s);
  if(s==1000000000){
    for(int j=k;j<n;++j)v[j] = 1;
  } else {
    for(int j=k;j<n;++j)v[j] = s+1;
  }
  for(int i=0;i<n;++i) cout << v[i] << " ";
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

ll fn(int x, int y, int z) {
    return x * x + y * y + z * z + x * y + y * z + z * x;
}

int main() {
    int n;
    cin >> n;
    vector<int> ans(n + 1, 0);
    rrep(x, 100) {
        rrep(y, 100) {
            rrep(z, 100) {
                ll m = fn(x, y, z);
                if(m <= n) {
                    ans[m]++;
                }
            }
        }
    }

    rrep(i, n) cout << ans[i] << endl;
    
    return 0;
}

Measured memory_bytes: 3540
def gridbfs(grid,sy,sx):
    INF = 10**18

    gridy = len(grid)
    gridx = len(grid[0])

    dist = [[INF]*gridx for _ in range(gridy)]
    dist[sy][sx] = 0
    q = [(sy,sx)]
    d = 1

    while q:
        qq = []
        for y,x in q:
            for dy,dx in [(-1,0),(1,0),(0,-1),(0,1)]:
                yy,xx = y+dy, x+dx
                if not (0 <= yy < gridy and 0 <= xx < gridx):
                    continue
                if grid[yy][xx] == '#':
                    continue
                if dist[yy][xx] != INF:
                    continue
                dist[yy][xx] = d
                qq.append((yy,xx))
        q = qq
        d += 1

    return dist

h,w = map(int,input().split())
s = [input() for i in range(h)]
c = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == '#':
            continue
        d_list = gridbfs(s,i,j)
        for k in range(h):
            for l in range(w):
                if d_list[k][l] != 10**18:
                    c = max(c,d_list[k][l])
print(c)

Measured memory_bytes: 3064
import java.util.*;import java.io.*;import java.math.*;
public class Main
{
    public static void process()throws IOException
    {
        // pn(997764507000l%6079);
        long n=nl();
        int ans=0;
        for(int i=2;i<=Math.sqrt(n);i++)
        {
            int c=0;
            while(n%i==0)
            {
                c++;
                n/=i;
                // pn(c+" "+i);
            }
            ans+=tri(c);
            // pn(ans);
        }
        // pn(n);
        if(n>1)
            ans++;
        pn(ans);
    }
    static int tri(int n)
    {
        int ans=((int)Math.sqrt(8*n+1)-1)/2;
        return ans;
    }
    static AnotherReader sc;
    static PrintWriter out;
    public static void main(String[]args)throws IOException
    {
        boolean oj =true;
        if(oj){sc=new AnotherReader();out=new PrintWriter(System.out);}
        else{sc=new AnotherReader(100);out=new PrintWriter("output.txt");}
        int t=1;
        // t=ni();
        while(t-->0) {process();}
        out.flush();out.close();  
    }

    static void pn(Object o){out.println(o);}
    static void p(Object o){out.print(o);}
    static void pni(Object o){out.println(o);out.flush();}
    static int ni()throws IOException{return sc.nextInt();}
    static long nl()throws IOException{return sc.nextLong();}
    static double nd()throws IOException{return sc.nextDouble();}
    static String nln()throws IOException{return sc.nextLine();}
    static int[] nai(int N)throws IOException{int[]A=new int[N];for(int i=0;i!=N;i++){A[i]=ni();}return A;}
    static long[] nal(int N)throws IOException{long[]A=new long[N];for(int i=0;i!=N;i++){A[i]=nl();}return A;}
    static long gcd(long a, long b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int gcd(int a, int b)throws IOException{return (b==0)?a:gcd(b,a%b);}
    static int bit(long n)throws IOException{return (n==0)?0:(1+bit(n&(n-1)));}

/////////////////////////////////////////////////////////////////////////////////////////////////////////

    static class AnotherReader{BufferedReader br; StringTokenizer st;
    AnotherReader()throws FileNotFoundException{
    br=new BufferedReader(new InputStreamReader(System.in));}
    AnotherReader(int a)throws FileNotFoundException{
    br = new BufferedReader(new FileReader("input.txt"));}
    String next()throws IOException{
    while (st == null || !st.hasMoreElements()) {try{
    st = new StringTokenizer(br.readLine());}
    catch (IOException  e){ e.printStackTrace(); }}
    return st.nextToken(); } int nextInt() throws IOException{
    return Integer.parseInt(next());}
    long nextLong() throws IOException
    {return Long.parseLong(next());}
    double nextDouble()throws IOException { return Double.parseDouble(next()); }
    String nextLine() throws IOException{ String str = ""; try{
    str = br.readLine();} catch (IOException e){
    e.printStackTrace();} return str;}}
   
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
}


Measured memory_bytes: 33116
#include<iostream>

using namespace std;

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

int cell[101], n;
double mem[101][101];

double solve(int k, int t) {
  if (mem[k][t] > -0.5) return mem[k][t];
  if (k == n) return 1;
  if (t <= 0) return 0;
  double res = 0;
  rep (i, 6) {
    int next = k + i + 1;
    if (next > n) next = 2 * n - next;
    if (cell[next] == 2) next = 0;
    res += solve(next, t - 1 - (cell[next] == 1 ? 1 : 0));
  }
  return mem[k][t] = res /= 6;
}

int main() {
  int t, l, b, c;
  cout.setf(ios::fixed, ios::floatfield);
  cout.precision(12);
  while (cin >> n >> t >> l >> b, n) {
    rep (i, n + 1) rep (j, t + 1) mem[i][j] = -1;
    rep (i, n + 1) cell[i] = 0;
    rep (i, l) {
      cin >> c;
      cell[c] = 1;
    }
    rep (i, b) {
      cin >> c;
      cell[c] = 2;
    }
    cout << solve(0, t) << endl;
  }
  return 0;
}

Measured memory_bytes: 1312
#include<bits/stdc++.h>
using namespace std;
const int inf=0x3f3f3f3f, maxn=200007, mod=1e9+7;

int a[maxn];
long long h[maxn];
int n,ans;
int main(){
	h[0]=1;
	for(int i=1;i<=31;i++)h[i]=h[i-1]<<1;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int k=30;k>=1;k--){
		for(int i=1,j=n;i<j;i++){
			if(a[i]!=inf){
				while(j>i&&a[i]+a[j]>h[k])j--;
//				cout<<a[i]<<' '<<a[j]<<' '<<h[k]<<endl;
				if(j>i&&a[i]+a[j]==h[k])ans++,a[i]=a[j]=inf;
			}
		}
	}
	printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long x[100003];
int main()
{
    long long i,n,z=0;
    cin>>n;
    for(i=1;i<=n;++i)
    {
        cin>>x[i];
    }
    for(i=1;i<=n;++i)
    {
        if(x[i]==i)
        {
            swap(x[i],x[i+1]);
            z++;
        }
    }
    cout<<z<<endl;
    
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main(void)
{
    char num[1001];
    int sum, i;
     
    while(1) {
        sum=0;
        scanf("%s", num);
        if(num[0]=='0') break;
        for(i=0; num[i]!='\0'; i++) {
            sum+=num[i]-'0';
        }
    printf("%d\n", sum);
    }
     
    return 0;
}


Measured memory_bytes: 2124
#include "bits/stdc++.h"
#include <functional>
using namespace std;
int fac(int N) {
	if (N == 1) return 1;
	else return N * fac(N - 1);
}
int main() {
	int N; cin >> N;
	vector<int> v(N);
	iota(v.begin(), v.end(), 1);
	vector<vector<int>>A(fac(N), vector<int>());
	for (int i = 0; i < fac(N); i++) {
		for (auto x : v) A.at(i).push_back(x);
		next_permutation(v.begin(), v.end());
	}
	vector<int>P(N), Q(N);
	for (int i = 0; i < N; i++) {
		cin >> P.at(i);
	}
	for (int i = 0; i < N; i++) {
		cin >> Q.at(i);
	}
	int ans = 0;
	for (int i = 0; i < fac(N); i++) {
		int num = 0;
		for (int j = 0; j < N; j++) {
			if (P.at(j) != A.at(i).at(j))num++;
		}
		if (num == 0) {
			ans = i;
			break;
		}
	}
	for (int i = 0; i < fac(N); i++) {
		int num = 0;
		for (int j = 0; j < N; j++) {
			if (Q.at(j) != A.at(i).at(j))num++;
		}
		if (num == 0) {
			ans -= i;
			break;
		}
	}
	cout << abs(ans) << endl;
	return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  ll N,M;
  cin >> N >> M;
  vector<pair<ll, ll>> a(N);
  REP(i,N){
    cin >> a.at(i).first >> a.at(i).second;
  }
  sort(ALL(a));

  ll num = 0;
  ll sum = 0;
  REP(i,N){
    if(M > num + a.at(i).second){
      num += a.at(i).second;
      sum += a.at(i).first*a.at(i).second;
    }else{
      sum += a.at(i).first*(M-num);
      break;
    }
  }
  cout << sum << endl;
}

Measured memory_bytes: 1792
S = input()
n = len(S)
 
def check_is_kaibun(s):
    is_kaibun = True
    if len(s)//2 ==0:return True
    for i in range(len(s)//2):
         if s[i] != s[len(s)-1-i]:
                return False
    return is_kaibun
  
if check_is_kaibun(S) == check_is_kaibun(S[:(n-1)//2]) == check_is_kaibun(S[(n+1)//2:]) == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3060
n,x = map(int, input().split())
l = [0] + list(map(int, input().split()))
d = 0
i = 0
c = 0
while d <= x:
  d += l[i]
  i += 1
  if n+1 == i and d <= x:
    c = 1
    break
if c == 1:
  print(n+1)
else:
  print(i-1)

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n)  { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x)         { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};

int main() {
	int  n;
	cin >> n;
	vll numa(n);
	vll numb(n);
	REP(i, n) {
		cin >> numa[i] >> numb[i];
	}
	ll cnt = 0;
	for (int i = n - 1;i >= 0;i--) {
		if (numb[i] >= numa[i]+cnt) {
			cnt += (numb[i] - numa[i]-cnt) % numb[i];
		}
		else {
			if ((numa[i] + cnt) % numb[i] == 0)
				continue;
			cnt += (numb[i]-((numa[i] + cnt) % numb[i]));
		}
	}
	cout << cnt << endl;
}

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

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

	double len = N.size();
	double count=0;
	for(double i=0; i<len; i++){
		int num = N.at(i) - '0';
		count+=num;

	}

	double flg = count/9 - floor(count/9);
	if(flg==0){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 3720
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

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

	int N,M;
	cin >> N >> M;
	vector<int> v[N+1];
	FOR(i,0,M){
		int a,b;
		cin >> a >> b;
		v[a].push_back(b);
		v[b].push_back(a);
	}

	bool did[N+1] = {};
	deque<int> deq;
	deq.push_back(1);
	did[1] = true;
	bool f=false,b=false;
	while( (not f) || (not b) ){
		f = true;
		b = true;
		for(auto x:v[deq.front()]){
			if(not did[x]){
				deq.push_front(x);
				did[x] = true;
				f = false;
				break;
			}
		}
		for(auto x:v[deq.back()]){
			if(not did[x]){
				deq.push_back(x);
				did[x] = true;
				b = false;
				break;
			}
		}
	}
	cout << deq.size() << "\n";
	int i=0;
	for(auto x:deq){
		if(i!=0)cout << " " ;
		cout << x;
		i++;
	}
	cout << "\n";
}

Measured memory_bytes: 6784
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

int main() {
  uint32_t K = 0;
  std::cin >> K;

  uint32_t sum = 0, res = 7;
  for (size_t i = 0; i < K; i++)
  {
    res %= K;
    sum += res;
    res *= 10;
    sum %= K;
    if(sum == 0){
      std::cout << i+1 << std::endl;
      break;
    }
  }
  if(sum){std::cout << -1 << std::endl;}

  return 0;
}

Measured memory_bytes: 3500
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define endl '\n'
using namespace std;
const int N=1e5+1;


int32_t main()
 {
 ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
string s; cin>>s; int ans;
if(s=="SSS"){ans=0;}
else if(s=="RRR"){ans=3;}
else if(s=="RRS" || s=="SRR"){ans=2;}
else{ans=1;}
cout<<ans<<endl;
 }


Measured memory_bytes: 3624
N = int(input())
A = list(map(int, input().split()))
z = 0
for i in range(N):
    if i == 0:
        z += abs(A[i])
    else:
        z += abs(A[i]-A[i-1])
z +=abs(A[N-1])


for j in range(N):
    if j == 0:
        x = abs(abs(A[j]-0)+abs(A[j+1]-A[j])-abs(A[j+1]-0))
    elif j < N-1:
        x = abs(abs(A[j]-A[j-1])+abs(A[j+1]-A[j])-abs(A[j+1]-A[j-1]))
    else:
        x = abs(abs(A[j]-A[j-1])+abs(0-A[j])-abs(0-A[j-1]))
    print(z-x)

Measured memory_bytes: 14176
import copy


def partition(A,p,r):
    x=A[r]
    i=p-1
    for j in range(p,r):
        if A[j][1]<=x[1]:
            i +=1
            A[i],A[j]=A[j],A[i]
    A[i+1],A[r]=A[r],A[i+1]
    return i+1


def quickSort(A,p,r):
    if p<r:
        q=partition(A,p,r)
        quickSort(A,p,q-1)
        quickSort(A,q+1,r)


n=int(input())
data=[]
for i in range(n):
    mark,num=map(str,input().split())
    data.append([mark,int(num)])

data_copy=copy.deepcopy(data)
data_copy=sorted(data_copy, key=lambda x:x[1])

quickSort(data,0,n-1)

print("Stable" if data==data_copy else "Not stable")

for mark,num in data:print(mark,num)


Measured memory_bytes: 39512
n = int(input())
hs = list(map(int, input().split()))

cnt_ind_minus_height = {}
cnt_ind_plus_height = {}
cnt_height_minus_ind = {}
cnt_minus_ind_minus_height = {}

for ind in range(n):
    height = hs[ind]
    if ind - height not in cnt_ind_minus_height:
        cnt_ind_minus_height[ind - height] = 0
    cnt_ind_minus_height[ind - height] += 1

    if ind + height not in cnt_ind_plus_height:
        cnt_ind_plus_height[ind + height] = 0
    cnt_ind_plus_height[ind + height] += 1


    if height - ind not in cnt_height_minus_ind:
        cnt_height_minus_ind[height - ind] = 0
    cnt_height_minus_ind[height - ind] += 1



    if - ind - height not in cnt_minus_ind_minus_height:
        cnt_minus_ind_minus_height[- ind - height] = 0
    cnt_minus_ind_minus_height[- ind - height] += 1
    

ans = 0
    
for val in cnt_height_minus_ind:
    if val in cnt_minus_ind_minus_height:
        ans += cnt_height_minus_ind[val] * cnt_minus_ind_minus_height[val]

for val in cnt_ind_minus_height:
    if val in cnt_ind_plus_height:
        ans += cnt_ind_minus_height[val] * cnt_ind_plus_height[val]

print(ans//2)

Measured memory_bytes: 86836
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>
#include<time.h>
typedef long long int ll;
//#include<bits/stdc++.h>


using namespace std;



int main()
{

    int n, r;

    cin >> n >> r;
    if (n < 10)cout << r + 100 * (10 - n) << endl;
    else cout << r << endl;


    return 0;

}

Measured memory_bytes: 3576
#include <iostream>
#include <math.h>
using namespace std;

int main() {
	// your code goes here
	int a,b;
	cin>>a>>b;
	if(a<b) cout<<"a < b"<<endl;
	else if(a>b) cout<<"a > b"<<endl;
	else if(a==b) cout<<"a == b"<<endl;
	return 0;
}

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

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


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

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

int n,m;

vint graph[100010];
bool visit[100010];

vint path,path2;

void dfs(int t){
    visit[t]=true;
    path.pb(t);
    for(auto e:graph[t]){
        if(visit[e]==false){
            dfs(e);
            return ;
        }
    }
}



signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>n>>m;
    rep(i,0,m){
        int a,b;
        cin>>a>>b;
        graph[a].pb(b);
        graph[b].pb(a);
    }
    
    dfs(1);
    swap(path,path2);
    dfs(1);
    
    cout<<path.size()+path2.size()-1<<endl;
    rrep(i,1,path2.size())cout<<path2[i]<<" ";
    for(auto e:path)cout<<e<<" ";
    cout<<endl;
    
    
    
    
    
    return 0;
}

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

signed main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  if(B>=A)ans=A;
  if(B<A)ans=A-1;
  cout<<ans<<endl;
}

Measured memory_bytes: 256
public class Main {

  private static void solve() {
    int m = ni();

    long sum1 = 0;
    long sum2 = 0;
    for (int i = 0; i < m; i++) {
      long d = ni();
      long c = nl();

      sum1 += d * c;
      sum2 += c;
    }

    long k = (sum1 - 1) % 9 + 1;
    System.out.println(sum2 + (sum1 - k) / 9 - 1);

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 43180
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,sum=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if((i%10==i/10000) && (i/10%10==i/1000%10)){
            sum+=1;
        }
    }
    cout<<sum<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ri register int
typedef long long ll;
namespace io {
	const int SIZE = (1 << 21) + 1;
	char ibuf[SIZE], *iS, *iT, obuf[SIZE], *oS = obuf, *oT = oS + SIZE - 1, c, qu[55]; int f, qr;
	// getchar
	#define gc() (iS == iT ? (iT = (iS = ibuf) + fread (ibuf, 1, SIZE, stdin), (iS == iT ? EOF : *iS ++)) : *iS ++)
	// print the remaining part
	inline void flush () {
		fwrite (obuf, 1, oS - obuf, stdout);
		oS = obuf;
	}
	// putchar
	inline void putc (char x) {
		*oS ++ = x;
		if (oS == oT) flush ();
	}
	// input a signed integer
	template <class I>
	inline void gi (I &x) {
		for (f = 1, c = gc(); c < '0' || c > '9'; c = gc()) if (c == '-') f = -1;
		for (x = 0; c <= '9' && c >= '0'; c = gc()) x = (x << 1) + (x << 3) + (c & 15); x *= f;
	}
	// print a signed integer
	template <class I>
	inline void print (I x) {
		if (!x) putc ('0'); if (x < 0) putc ('-'), x = -x;
		while (x) qu[++ qr] = x % 10 + '0',  x /= 10;
		while (qr) putc (qu[qr --]);
	}
	// no need to call flush at the end manually!
	struct Flusher_ {~Flusher_(){flush();}}io_flusher_;
} 
using io :: gi;
using io :: putc;
using io :: print;
const int N=105,mod=1e9+7;
int h[N],f[N][N],a[N],pos[N];
// f[i][j] 表示第i列前a[i]个格子没有出现 xx/oo ，前a[i+1]个格子出现了 xx/oo 
inline int fpow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1) ans=(ll)ans*a%mod;
	return ans;
}
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
inline int calc(ri x){  
	return (fpow(2,x)-1+mod)%mod; 
}
inline int solve(ri l,ri r){
	ri i,j,k,m,res;
	m=0;
	for(i=l;i<=r;++i) a[++m]=h[i];
	sort(a+1,a+1+m);
	m=unique(a+1,a+1+m)-a-1;
	for(i=l;i<=r;++i) pos[i]=lower_bound(a+1,a+1+m,h[i])-a;
	f[l][0]=2ll*calc(a[1]-1)*fpow(2,h[l]-a[1])%mod; 
	for(i=1;i<pos[l];++i)
		f[l][i]=2ll*calc(a[i+1]-a[i])*fpow(2,h[l]-a[i+1])%mod;
	f[l][pos[l]]=2; 
	for(i=l+1;i<=r;++i){ 
		if(h[i]<=h[i-1]){
			for(j=0;j<pos[i];++j)
				f[i][j]=f[i-1][j];
			for(k=pos[i];k<=pos[i-1];++k)
				add(f[i][j],f[i-1][k]*2ll%mod);
		}
		else{
			for(j=0;j<pos[i-1];++j)
				f[i][j]=(ll)f[i-1][j]*fpow(2,h[i]-h[i-1])%mod;
			for(;j<pos[i];++j)
				f[i][j]=(ll)f[i-1][pos[i-1]]*2*calc(a[j+1]-a[j])%mod*fpow(2,h[i]-a[j+1])%mod;
			f[i][pos[i]]=f[i-1][pos[i-1]]*2ll%mod;
		}
	//	for(j=0;j<=pos[i];++j)
	//		printf("dp %d %d %d\n",i,j,f[i][j]);
	} 
	res=0;
	for(i=0;i<=m;++i)
		add(res,f[r][i]);
	return res;
}
int main(){
	ri n,i,last,ans;
	gi(n);
	for(i=1;i<=n;++i) gi(h[i]);
	last=0;ans=1;
	for(i=1;i<=n;++i)
		if(h[i]==1){
			ans=(ans<<1)%mod;
			if(last+1<=i-1) ans=(ll)ans*solve(last+1,i-1)%mod;
			last=i; 
		}
	if(last+1<=n) ans=(ll)ans*solve(last+1,n)%mod;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 2304
#include<cstdio>
#include<string>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<set>
#include<vector>
#define INF 100000000

#define MAX_N 10000
#define MAX_M 100

typedef long long int ll;
using namespace std;



int main(){

	int x;
	int i = 0;
	while(true){
	
		scanf("%d", &x);
		if(x != 0){
			i++;
			printf("Case %d: %d\n", i, x);
		}
		else
			break;
	
	}


	return 0;

}

Measured memory_bytes: 1188
#include <cstdio>
#include <iostream>
using namespace std;
int t[100000];

int judge(){
	int cnt = 0;
	int tmp = 1;
	while(1){
		if(cnt > 100000) return -1;
		tmp = t[tmp];
		cnt++;
		if(tmp == 2) return cnt;
	}
} 


int main(){
	int time;
	cin >> time;
	for(int i = 1; i <= time; i++){
		cin >> t[i];
	}

	int ans = judge();

	cout << ans << endl;
}

Measured memory_bytes: 640
n=int(input())
A=sorted(list(map(int,input().split())))

XY=[]
left,right=A[0],A[-1]
for i in range(1,n-1):
    num=A[i]
    if num<0:
        XY.append([right,num])
        right -=num
    else:
        XY.append([left,num])
        left -=num
XY.append([right,left])
print(right-left)
for x,y in XY:print(x,y)

Measured memory_bytes: 69028
#include<stdio.h>
#include<algorithm>
typedef unsigned int wolf;
char set[]="0123456789abcdef";
wolf b[9];
char str[9];
char out[9];
int main(){
	int a;
	scanf("%d",&a);
	while(a--){
		for(int i=0;i<9;i++)b[i]=0;
		for(int i=0;i<9;i++){
			scanf("%s",str);
			for(int j=0;str[j];j++){
				b[i]*=16;
				for(int k=0;k<16;k++)if(set[k]==str[j])b[i]+=k;
			}
		}
		wolf ans=0;
		//int c=0;
		int d=0;
		for(int i=0;i<32;i++){
			int c=0;
			//int d=0;
			for(int j=0;j<8;j++){
				if(b[j]&(1<<i))c++;
			}
			int e=0;
			if(b[8]&(1<<i))e++;
			if((c+d+e)%2){
				ans+=(1<<i);
				d=(8-c+d)/2;
			}
			else d=(c+d)/2;
		}
		int now=0;
		if(ans==0){
			printf("0\n");
			continue;
		}
		while(ans){
			out[now++]=set[ans%16];
			ans/=16;
		}
		for(int i=now-1;i>=0;i--)printf("%c",out[i]);
		printf("\n");
	}
}

Measured memory_bytes: 1016
#![allow(non_snake_case)]

use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    let mut ws = buf.split_whitespace();
    let a: i32 = ws.next().unwrap().parse().unwrap();
    let b: i32 = ws.next().unwrap().parse().unwrap();

    if a < b {
        println!("a < b");
    } else if a > b {
        println!("a > b");
    } else {
        println!("a == b");
    }
}



Measured memory_bytes: 5032
#include <bits/stdc++.h>
 #define ll long long
 #define int long long
 #define MOD  1000000007
 #define MAX 500005
 #include<iomanip>
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define x first
 #define y second
using namespace std;
int gcd(int a, int b);
  
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
  
    return (y%2 == 0)? p : (x * p) % m;
}
ll modInverse(int a, int m)
{
    int g = gcd(a, m);
   
    {
        // If a and m are relatively prime, then modulo inverse
        // is a^(m-2) mode m
      
             return power(a, m-2, m);
    }
}
int gcd(int a, int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
 /*  ll n,k;
    cin>>n>>k;
    ll a[100005]={0};
    fore(i,0,n)cin>>a[i];
    ll p[100005]={0};
    p[0]=a[0];
    for(ll i=1;i<n;i++)
    {
        p[i]=p[i-1]+a[i];
    }
    ll ans=0,m=0;
    for(ll i=1;i<n;i++)
    {
        ll l,r;
        l=1;ll mid;
        r=i;
        while(l<=r)
        {
             mid=(l+r)>>1;
            ll sum=p[i]-p[mid-1];
            ll d=i-mid+1;
            if(a[i]*d-sum<=k && d>ans)
            {
                r=mid-1;
                ans=d;
                m=a[mid];
                cout<<a[i]<<endl;
            }
            else
            {
                l=mid+1;
            }
        }
        
    }
    cout<<ans<<" "<<m<<endl;*/
 int32_t main()
{
    Need_for_speed(activated);
//    satisfy
//    {}
    set<ll>a;
    ll n;cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll x;cin>>x;
        a.insert(x);
    }
    if(a.size()==n)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
    }



Measured memory_bytes: 9600
#include <stdio.h>

int main(void){
	int a,b,c,d,e,f;
	int i,countx=0,county=0;
	float x,y;
	float tempx,tempy;
	
	while(scanf("%d %d %d %d %d %d",&a,&b,&c,&d,&e,&f) != EOF){
	
		x = (float)(c*e-f*b)/(a*e-b*d);
		y = (float)-(c*d-f*a)/(a*e-b*d);

		tempx = x;
		tempy = y;
		for(i = 0;i < 4;i++){
			tempx *= 10;
			tempy *= 10;
		}
		if(-0.0005<x && x<=0){
			x=0;
		}
		if(-0.0005<y && y<=0){
			y=0;
		}

		while(1){
			tempx -= 1;
			countx++;
			if(countx == 10){
				countx = 0;
			}
			if((int)tempx % 10 == 0){
				break;
			}
		}
		while(1){
			tempy -= 1;
			county++;
			if(county == 10){
				county = 0;
			}
			if((int)tempy % 10 == 0){
				break;
			}
		}
		if(countx > 4){
			x += 0.001;
		}
		if(county > 4){
			y += 0.001;
		}

		printf("%.3f %.3f\n",(float)x,(float)y);
	}
	return 0;
}

Measured memory_bytes: 636
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <deque>
#include <string>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <stack>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    array<int, 3> two_count = {0, 0, 0};
    loop(i, N){
        scanInt(ai);
        if (ai % 4 == 0){
            ++two_count[2];
        }else if (ai % 2 == 0){
            ++two_count[1];
        }else{
            ++two_count[0];
        }
    }
    if (two_count[0] <= two_count[2] ||
        (N % 2 == 1 && two_count[1] == 0 && two_count[0] <= two_count[2] + 1)){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

bool check(const std::string& s)
{
  const std::string KEYENCE = "keyence";

  for (int i = 0; i < KEYENCE.length(); ++i) {
    if (s[i] != KEYENCE[i]) {
      return s.substr(s.length() - KEYENCE.length() + i) == KEYENCE.substr(i);
    }
  }
  return true;
}

int main(int argc, char* argv[])
{
  std::string s;
  std::cin >> s;

  if (check(s)) {
      std::cout << "YES";
  }
  else {
      std::cout << "NO";
  }

  return 0;
}

Measured memory_bytes: 256