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

using i64 = int64_t;

#define rep(i, x, y) for (i64 i = i64(x), i##_max_for_repmacro = i64(y); i < i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif

const int inf = 1.01e9;
const i64 inf64 = 4.01e18;
const double eps = 1e-9;

template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << ", " << p.second << ")";
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

void solve() {
    //const i64 mod = 1'000'000'007;
    i64 N;
    cin >> N;
    vector<i64> a(N);
    rep(i,0,N) cin >> a[i];

    const i64 size=3001;
    static i64 memo[size][size][2];
    static i64 done[size][size][2];
    rep(i,0,size) rep(j,0,size){
        memo[i][j][0]=-inf64;
        memo[i][j][1]=inf64;
    }
    fill_n((bool*)done,size*size*2,false);

    function<i64(i64,i64,i64)> rec=[&](i64 l,i64 r,i64 t){
        if(l>r) return i64(0);

        auto& res=memo[l][r][t];

        if(done[l][r][t]) return res;
        done[l][r][t]=true;

        if(t==0){
            chmax(res,rec(l+1,r,1-t)+a[l]);
            chmax(res,rec(l,r-1,1-t)+a[r]);
        }else{
            chmin(res,rec(l+1,r,1-t)-a[l]);
            chmin(res,rec(l,r-1,1-t)-a[r]);
        }
        return res;
    };

    cout << rec(0,N-1,0) << endl;
}

int main() {
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

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

    int num = 1;

    rep(i, n)
    {
        num = (num + k <= 2 * num ? num + k : 2 * num);
    }
    OP(num);
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())


N,M = inpl()
lines = defaultdict(set)

for _ in range(M):
    u,v = inpl()
    u -= 1
    v -= 1
    lines[u].add(v+N)
    lines[u+N].add(v+2*N)
    lines[u+2*N].add(v)

S,T = inpl()
S -= 1
T -= 1

def search (s,w_0): #s->t
	global weight
	global q

	for t in list(lines[s]):
		w = w_0 + 1
		if weight[t] > w:
			heapq.heappush(q, [w,t])
			weight[t] = w

# Start, S
weight = [INF]*(N*3)
weight[S] = 0
q = [[0,S]]
heapq.heapify(q)
while q:
	w,n = heapq.heappop(q)
	search(n,w)

ans = weight[T]

if ans == INF:
    print(-1)
else:
    print(ans//3)


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) begin(r),end(r)
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init))
#define mp(a,b) make_pair(a,b)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr ll inf = ((1<<30)-1)*2+1 ;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,0,-1,1,-1};
const int dx[] = {0,-1,0,1,0,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

const int W = 10,H = 10;
int tile[W][H];
int opt[W][H];
int flip[W][H];

int get(int x,int y){
  int c = tile[x][y];
  rep(i,5){
    int nx = x+dx[i],ny = y+dy[i];
    if(value(nx,ny,W,H)){
      c += flip[nx][ny];
    }
  }
  return c % 2;
}

int calc(){
  REP(i,1,W){
    rep(j,H){
      if(get(i-1,j) != 0){
        flip[i][j] = 1;
      }
    }
  }
  rep(j,H){
    if(get(W-1,j) != 0)
      return -1;
  }
  int res = 0;
  rep(i,W){
    rep(j,H){
      res += flip[i][j];
    }
  }
  return res;
}

void solve(){
  int res = -1;
  rep(i,1 << H){
    memset(flip, 0, sizeof(flip));
    rep(j,W){
      flip[0][H-j-1] = i >> j & 1;
    }
    if(calc() != -1){
      break;
    }
  }
  rep(i,W){
    rep(j,H){
      if(j) cout << ' ';
      cout << flip[i][j] ;
    }
    cout << endl;
  }
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  rep(x,n){
    rep(i,W){
      rep(j,H){
        cin >> tile[i][j];
      }
    }
    solve();
  }
  return 0;
}

Measured memory_bytes: 3116
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#define IO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, t, a[100000];

int main(){
	//IO("input.txt", "output.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n >> t;
	for(int i = 0; i < n; i++) cin >> a[i];
	map<int, int> mp;
	int mx = 0;
	for(int i = 0; i < n; i++){
		if(!mp.empty()) mx = max(mx, a[i] - (mp.begin() -> first));
		mp[a[i]]++;
	}
	mp.clear();
	int cnt = 0;
	for(int i = 0; i < n; i++){
		if(!mp.empty() && a[i] - (mp.begin() -> first) == mx){
			cnt += (mp.begin() -> second);
			mp.erase(mp.begin());
		}
		mp[a[i]]++;
	}
	cout << cnt << "\n";
	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int n,i;
    int save;
    int totalCost=0;
    int a[100004];
    cin>>n;
    a[0]=0;
    a[n+1]=0;
    for(i=1;i<=n;i++) {
        cin >>a[i];
        totalCost+=abs(a[i]-a[i-1]);
    }
    totalCost+=abs(a[n]);
    for(int i=1;i<=n;i++) {
        save=abs(a[i-1]-a[i])+abs(a[i]-a[i+1])-abs(a[i-1]-a[i+1]);
        printf("%d\n", totalCost-save);
    }
    return 0;
}

Measured memory_bytes: 1664
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const long long INF = 1000000007;
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){
    int N; cin >> N;
    cout << 800*N - 200*(N/15) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    int n;
    cin >> n;
    vector<int>p(n);
    vector<int>q(n);
    vector<int>v;
    rep(i,n) {
        cin >> p[i];
    }
    rep(i,n) {
        cin >> q[i];
    }
    rep(i,n) {
        v.push_back(i+1);
    }
    rep(i,n) {
        if(p[i] > q[i]) {
            swap(p,q);
            break;
        } else if (p[i] == q[i]) continue;
        else break;
    }
    int cnt = 0;
    int a = 0;
    int b = 0;
    bool oka = false;
    do{
        cnt++;
        bool ok = true;
        rep(i,n) {
            if(v[i] != p[i]) {
                ok = false;
                break;
            }
        }
        if(ok) {
            a = cnt;
            oka = true;
        }
        if(oka) {
            bool okb = true;
            rep(i,n) {
                if(v[i] !=  q[i]) {
                    okb = false;
                    break;
                }
            }
            if(okb) {
                b = cnt;
            }
        }
    } while(next_permutation(v.begin(),v.end()));
    cout << abs(a-b) << endl;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
	long long A, B, C;
	scanf("%lld%lld%lld", &A, &B, &C);
	if (~A & 1 || ~B & 1 || ~C & 1) puts("0");
	else printf("%lld\n", A > B ? A > C ? B * C : A * B : B > C ? A * C : A * B);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    typedef long long lint;
    typedef pair<int,int> pint;
    typedef vector<int> vint;
    #define rep(i, n) for(int i = 0; i < n; i++)
    #define rep2(i, m, n) for(int i = m; i < n; i++)
    #define rep3(elem, vec) for(auto elem: vec)
    #define SORT(V) sort((V).begin(),(V).end())
    #define RSORT(V) sort((V).rbegin(), (V).rend())
    #define COUT(N) cout<<fixed<<setprecision(N)
    lint gcd(int a,int b){return b?gcd(b,a%b):a;}
    lint lcm(int a,int b){return a*b/gcd(a,b);}
    lint comb(int a,int b){return b?comb(a-1,b-1)*a/b:1;}
    int dx[4] ={1,0,-1,0},dy[4] = {0,1,0,-1};
    int MOD = 1e9+7;

int main(){
    lint N,K;
    cin >> N >> K;
    vint A(N),B(N,0);
    rep(i,N)cin >> A[i];
    lint a=0,b=0,next=0;
    
    for(lint i=0; i<K; i++){
        if(i==K-1){
            cout << A[next];
            return 0;
        }
        B[next]=1;
        next = A[next]-1;
        a++;
        if(B[next]==1)break;
    }

    rep(i,a){
        B[next]=2;
        next =A[next]-1;
        b++;
        if(B[next]==2)break;
    }

    rep(i,(K-a+b-1)%b){
        next =A[next]-1;
    }
    cout << A[next];

    return 0;
}

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

int main()
{
  int l;
  double ans = 0;
  cin >> l;
  if (l % 3 == 0)
  {
    ans = pow(l / 3, 3);
  }
  else
  {
    double a = l / 3.0;
    double b = (l - a) / 2.0;
    double c = l - (a + b);
    ans = a * b * c;
  }
  cout << fixed << setprecision(12) << ans << "\n";
}

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

int main()
{
	ll a,b,x;
	while(cin >> a >> b >> x)
	{
	    ll cnt = 0;
	    if(a % x == 0)
	    cnt++;
	    cnt += (b / x - a / x);
	    cout << cnt << endl;
	}
	return 0;
}


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

int main () {
  int i, j, k, N, D, X[10][10], count=0, sum;
  
  cin >> N >> D;
  
  rep(i,N){
    rep(j,D){
      cin >> X[i][j];
    }
  }
  

  rep(i,N-1){
    for(j=i+1;j<N;j++){
      sum = 0;
      for(k=0; k<D; k++){
        sum += (X[i][k]-X[j][k])*(X[i][k]-X[j][k]);
      }
      for(k=0;k<1000;k++){
        if(sum==k*k){
          count +=1;
          break;
        }
      }
    }
  }
  cout << count;
}




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

int x,a,b,n;

int main(){
    cin>>x>>a>>b;
    cin>>n;
    string com;
    for (int i=0; i<n; i++){
        cin>>com;
        if(com=="nobiro"){
            x+=a;
            x=max(x,0);
        }
        else if (com=="tidime"){
            x+=b;
            x=max(x,0);
        }
        else{
            x=0;
        }
    }
    cout<<x<<endl;
    return 0;
}


Measured memory_bytes: 3208
import java.io.*;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] first = br.readLine().split(" ", 3);
		int h = Integer.parseInt(first[0]);
		int w = Integer.parseInt(first[1]);
		int d = Integer.parseInt(first[2]);
		int[] spaceX = new int[h * w + 1];
		int[] spaceY = new int[h * w + 1];
		for (int j = 0; j < h; j++) {
			String[] x = br.readLine().split(" ", w);
			for (int i = 0; i < w; i++) {
				int a = Integer.parseInt(x[i]);
				spaceX[a] = i;
				spaceY[a] = j;
			}
		}
		int[] darr = new int[h * w + 1];
		for (int i = 1; i <= d; i++) {
			for (int j = i; j < h * w + 1; j += d) {
				if (j == i) {
					darr[j] = 0;
				} else {
					darr[j] = darr[j - d] + Math.abs(spaceX[j] - spaceX[j - d]) + Math.abs(spaceY[j] - spaceY[j - d]);
				}
			}
		}
		
		int q = Integer.parseInt(br.readLine());
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < q; i++) {
			String[] second = br.readLine().split(" ", 2);
			int l = Integer.parseInt(second[0]);
			int r = Integer.parseInt(second[1]);
			sb.append(darr[r] - darr[l]).append("\n");
		}
		System.out.print(sb);
	}
}


Measured memory_bytes: 51068
#include <stdio.h>                                            
 
int i, j, k;
int t;
int N, K;
int d[10] = {0};
int nums[100000];
 
int main(){
  scanf("%d %d", &N, &K);
  for(i = 0; i < K; i++){
    scanf("%d", &t);
    d[t] = 1;
  }
  int tN = N;
  while(1){
    int ttN = tN; 
    int flag = 1;
    while(1){
      if(ttN==0) break;
      int keta = ttN%10;
      ttN/=10;
      if(d[keta]){
        flag = 0;
        break;
      }   
    }   
    if(flag)break;
    tN++;
  }
  printf("%d\n", tN);
 
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

void solve(){
	int a,b,c;
	cin >> a >> b >> c;
	if(b*c >= a){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


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


int main(){
  string s,t;
  cin >> s;
  cin >> t;
  sort(s.begin(),s.end());
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  if(s<t){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int N,T;
    cin>>N>>T;
    int c[N],t[N];
    for(int i=0;i<N;i++){
        cin>>c[i]>>t[i];
    }
    int min=1001;
    for(int i=0;i<N;i++){
        if(t[i]<=T&&min>c[i]) min=c[i];
    }
   if(min!=1001)cout<<min;
   else cout<<"TLE";
   return 0;
}


Measured memory_bytes: 256
import numpy as np
from collections import defaultdict

a1,b1=map(int, input().split())  #
a2,b2=map(int, input().split())  #
a3,b3=map(int, input().split())  #



map_dict  = defaultdict(list)
map_dict[a1].append(b1)
map_dict[b1].append(a1)
map_dict[a2].append(b2)
map_dict[b2].append(a2)
map_dict[a3].append(b3)
map_dict[b3].append(a3)

#print(map_dict)
res = 0
cnt = 0
for m in map_dict:
    if len(map_dict[m]) >= 3:
        res = -1
        break
    if len(map_dict[m]) >= 2:
        cnt += 1
        pass
    #print(map_dict[m])
if cnt >= 3:  res = -1

if res == -1:
    print("NO")
else:
    print("YES")


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

int main() {
  int a, b, c;
  char d;
  int rhombus = 0, rectangle = 0;
  while (cin >> a >> d >> b >> d >> c) {
    if (a + b > c) {
      if (a == b) {
        rhombus++;
      } else if (a * a + b * b == c * c) {
        rectangle++;
      }
    }
  }
  cout << rectangle << endl;
  cout << rhombus << endl;
  return 0;
}



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

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

int MOD = 1e9 + 7;
ll INF = 1e18;

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

int main(){
    int n, x; cin>>n>>x;
    vector<int> a(n);
    for(int i=0; i<n; i++) cin>>a[i];

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

    int ans=0;
    for(int i=0; i<n; i++){
        if(x >= a[i]){
            if(i == n-1){
                if(x == a[i]) ans++;
            }
            else{
                ans++;
                x-=a[i];
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef bitset<4000005> bs;

string g[505];
int n;

void solve() {
  cin >> n;
  int r = n;
  int c = n;
  for(int i = 0; i < n; i++) {
    cin >> g[i];
  }
  int ret = 0;
  for(int j = 0; j < c; j++) {
    bool bad = false;
    for(int i = 0; i < r; i++) {
      if(g[i][j] == '.') bad = true;
    }
    if(bad) ret++;
  }
  int minRow = 1e9;
  for(int i = 0; i < r; i++) {
    int cand = 0;
    for(int j = 0; j < c; j++) {
      if(g[i][j] == '.') {
        cand++;
      }
    }
    bool colPresent = false;
    for(int j = 0; j < c; j++) {
      if(g[j][i] == '#') colPresent = true;
    }
    if(!colPresent) cand++;
    minRow = min(minRow, cand);
  }
  if(minRow == n+1) {
    cout << "-1\n";
    return;
  }
  ret += minRow;
  cout << ret << "\n";
}

void casesolve() {
  int t;
  cin >> t;
  for(int i = 1; i <= t; i++) {
    cout << "Case #" << i << " ";
    solve();
  }
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL); cout.tie(NULL);
  solve();
  // casesolve();
}


Measured memory_bytes: 512
a,b,k = map(int,input().split())

for i in range(k//2):
    a = a//2*2
    b+= a/2
    a/=2
    b= b//2*2
    a+= b/2
    b/=2
if(k%2==1):
    a = a//2*2
    b+= a/2
    a/=2

print(int(a),int(b))

Measured memory_bytes: 3064
import java.util.Scanner;

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

    int n = input.nextInt();
    String s = input.next();

    StringBuilder sb = new StringBuilder();

    for (char c : s.toCharArray()) {
      char newc = (char)('A' + (c - 'A' + n) % 26);
      sb.append(newc);
    }

    System.out.println(sb.toString());
  }
}


Measured memory_bytes: 22100
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
vector<int> gr[114514];
int pat[114514];
lint st[114514],go[114514],inp[114514];
bool sumi[114514];
int num[3];
int out=0,ng1=-1,ng2=-1;
vector<int> cycle;
int tmp[114514];
void dfs(int v,int p){
	if(pat[v]>=0) return;
	pat[v]=p;num[pat[v]]++;
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(v==ng1 && w==ng2) continue;
		if(v==ng2 && w==ng1) continue;
		dfs(w,1-p);
	}
}
void dfs2(int v,int u){
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w==u) continue;
		if(v==ng1 && w==ng2) continue;
		if(v==ng2 && w==ng1) continue;
		dfs2(w,v);
		out+=abs(st[w]-go[w]);
		st[v]+=st[w];go[v]+=go[w];
	}
	if(pat[v]==1) st[v]++;else go[v]++;
}

lint cal(lint mi){
	memset(st,0,sizeof(st));
	memset(go,0,sizeof(go));
	st[ng1]=mi;go[ng2]=mi;out=0;
	dfs2(0,-1);
	return abs(mi)+out;
}

void dfscycle(int v,int u,int d){
	//cout<<v<<' '<<u<<' '<<d<<endl;
	if(sumi[v]){
		if(cycle.size()>0) return;
		int t=0;
		while(tmp[t]!=v && t<d) t++;
		//cout<<v<<' '<<t<<endl;
		REP(i,t,d) cycle.pb(tmp[i]);
		return;
	}
	tmp[d]=v;sumi[v]=true;
	rep(i,gr[v].size()){
		int w=gr[v][i];
		if(w==u) continue;
		dfscycle(w,v,d+1);
	}
	//sumi[v]=false;
	//tmp.pop_back();
}

int main()
{
	int n,m,a,b;
	scanf("%d %d",&n,&m);
	rep(i,m){
		scanf("%d %d",&a,&b);
		a--;b--;gr[a].pb(b);gr[b].pb(a);
	}
	if(n%2>0){
		cout<<-1<<endl;return 0;
	}
	memset(num,0,sizeof(num));
	memset(pat,-1,sizeof(pat));
	memset(st,0,sizeof(st));
	memset(go,0,sizeof(go));
	if(m==n-1){
		dfs(0,0);
		if(num[0]!=num[1]){
			cout<<-1<<endl;return 0;
		}
		dfs2(0,-1);
		cout<<out<<endl;
		return 0;
	}
	dfscycle(0,-1,0);
	ng1=cycle[0];ng2=cycle[1];
	//rep(i,cycle.size()) cout<<cycle[i]<<endl;
	if(cycle.size()%2==0){
		dfs(0,0);
		if(num[0]!=num[1]){
			cout<<-1<<endl;return 0;
		}
		int lo=-114514,hi=114514;lint out=1145141919810364364LL;
		while(hi>lo+5){
			lint m1=(lo+hi)/2,m2=m1+1,x1=cal(m1),x2=cal(m2);
			//cout<<m1<<' '<<x1<<' '<<m2<<' '<<x2<<endl;
			if(x1>x2) lo=m1;else hi=m2;
		}
		REP(i,lo,hi+1) out=min(out,cal(i));
		cout<<out<<endl;
		return 0;
	}
	dfs(ng1,0);pat[ng2]=0;
	if(num[0]>num[1]) st[ng1]=st[ng2]=(num[0]-num[1])/2;
	else go[ng1]=go[ng2]=(num[1]-num[0])/2;
	dfs2(0,-1);
	//cout<<num[0]<<' '<<num[1]<<endl;
	cout<<out+abs((num[0]-num[1])/2)<<endl;
}


Measured memory_bytes: 17276
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

#define ll long long int

int main() {
  int i;

  ll m, k;
  scanf("%lld %lld", &m, &k);

  ll *a;
  a = (ll *)malloc(sizeof(ll) * pow(2, m + 1));

  ll *b, *c;
  b = (ll *)malloc(sizeof(ll) * (pow(2, m) - 1));
  c = (ll *)malloc(sizeof(ll) * (pow(2, m) - 1));

  if(m == 0) {
    if(k == 0) printf("0 0\n");
    else       printf("-1\n");
  }
  else if(m == 1) {
    if(k == 0) printf("0 0 1 1\n");
    else       printf("-1\n");
  }
  else {
    if(k >= pow(2, m)) printf("-1\n");
    else {
      int p = 0;
      for(i = 0; i < pow(2, m); i++) {
        if(i != k) {
          b[p] = i;
          c[(int)pow(2, m) - 2 - p] = i;
          p++;
        }
      }
      for(i = 0; i < pow(2, m) - 1; i++) {
        a[i] = b[i];
        a[i + (int)pow(2, m)] = c[i];
      }
      a[(int)pow(2, m) - 1] = k;
      a[(int)pow(2, m + 1) - 1] = k;
      for(i = 0; i < pow(2, m + 1); i++) printf("%lld ", a[i]);
      printf("\n");
    }
  }

  return 0;
}


Measured memory_bytes: 5888
from math import gcd


N = int(input())
A = list(map(int, input().split()))

# setwise validation
tmp = 0
for a in A:
    tmp = gcd(tmp, a)
isSetwise = (tmp == 1)

# pairwise validation
M = 10 ** 6
sieve = [0] * (M + 1)
for a in A:
    sieve[a] += 1

cnt = 0
isPairwise = True
for i in range(2, M + 1):
    tmp = 0
    for j in range(i, M + 1, i):
        tmp += sieve[j]
    isPairwise &= (tmp <= 1)

# check
if isPairwise:
    ans = 'pairwise coprime'
elif isSetwise:
    ans = 'setwise coprime'
else:
    ans = 'not coprime'
print(ans)


Measured memory_bytes: 194804
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
ll N, M;

int main(){
	cin >> N >> M;
	ll ans;
	if(N==1&&M==1){
		ans = 1;
	} else if(N==1){
		ans = M-2;
	} else if(M==1){
		ans = N-2;
	} else {
		ans = (N-2)*(M-2);
	}
	cout << ans << endl;

	return 0;
}


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

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

        int i = 1;
        while (true) {
            if (i > n) {
                System.out.println(i / 2);
                return;
            }
            i *= 2;
        }
    }
}


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

int n, z, w;
int a[2000];

int main(void){
	cin >> n >> z >> w;
	for(int i=0; i<n; i++) cin >> a[i];
	if(n==1) cout << abs(a[0]-w) << endl;
	else cout << max(abs(a[n-1]-w),abs(a[n-2]-a[n-1])) << endl;
}

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

int main(){
    int n,m;
    cin>>n>>m;
    int sum=0;
    for (int i = 0; i < m; ++i) {
        int j;
        cin>>j;
        sum+=j;
    }
    if(n>=sum)cout<<n-sum<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <math.h>
#include <iomanip>
#define M_PI 3.14159265358979323846
using namespace std;
int main() {
  long long int a, b, c, k;
  cin >> a >> b >> c >> k;
  long long int sum = 0;
  if(k < a){
    cout << k;
    return 0;
  }else if(k >= a && k <= a+b){
    cout << a;
    return 0;
  }else{
    cout << a - (k-a-b);
    return 0;
  }
}

Measured memory_bytes: 3156
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int sz=1e7;

int cntdiv[10000003];

void cal()
{
    for(int i=1; i<=sz; i++)
    {
        for(int j=i; j<=sz; j+=i)
        {
            cntdiv[j]++;
        }
    }
}

int main()
{
 cal();

 ll sum=0, n, i;

 scanf("%lld",&n);

 for(i=1; i<=n; i++)
 {
    sum+=(i*cntdiv[i]);
 }

 printf("%lld\n",sum);

}

Measured memory_bytes: 42760
N = int(input())
A= [0]*110000
sum = 0
for i in map(int, input().split()):
    sum += i
    A[i] += 1
    
Q = int(input())
for i in range(Q):
    B,C = map(int,input().split())
    sum += (C-B)*A[B]
    A[C] += A[B]
    A[B] = 0
    print(sum)

Measured memory_bytes: 17988
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define bisea binary_search
#define unsort(vec) sort(vec); rever(vec);
#define cend cout<<endl;
#define F first
#define S second
using namespace std;

signed main() {
  int n;
  string a,b,c;
  cin>>n>>a>>b>>c;
  int cnt=0;
  rep(i,n) {
    char d=a.at(i);
    char e=b.at(i);
    char f=c.at(i);
    if(d!=e&&e==f) cnt++;
    else if(d==e&&e!=f) cnt++;
    else if(d!=e&&d==f) cnt++;
    else if(d!=e&&e!=f) cnt+=2;
    else continue;
  }
  cout<<cnt<<endl;
}

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

const ll siz = 1e6 + 10;
const ll mod = 1e9 + 7;
const ll maxx = 1e9;
const ll MAXX = 1e17;
const ll base = 31;

int n, m, k;
int x, y;
int p[siz], r[siz], len[siz];
int f[siz], b[siz];

void setup()
{
    for (int i = 1; i <= siz; i++)
    {
        p[i] = i;
        r[i] = 1;
        len[i] = 1;
    }
}

int findSet(int x)
{
    return (p[x] == x) ? x : (p[x] = findSet(p[x]));
}

bool isSameSet(int x, int y)
{
    return findSet(x) == findSet(y);
}

void unionSet(int x, int y)
{
    if (!isSameSet(x, y))
    {
        int a = findSet(x);
        int b = findSet(y);
        if (r[a] > r[b])
        {
            p[b] = a;
            len[a] += len[b];
        }
        else
        {
            p[a] = b;
            len[b] += len[a];
            if (r[a] == r[b]) r[b]++;
        }
    }
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
//    freopen ("IN.INP", "r", stdin);
//    freopen ("OUT.OUT", "w", stdout);
    setup();
    cin >> n >> m >> k;
    for (int i = 1; i <= m; i++)
    {
        cin >> x >> y;
        unionSet(x, y);
        f[x]++;
        f[y]++;
    }
    for (int i = 1; i <= k; i++)
    {
        cin >> x >> y;
        if (isSameSet(x, y))
        {
            b[x]++;
            b[y]++;
        }
    }
    for (int i = 1; i <= n; i++)
        cout << len[findSet(i)] - f[i] - b[i] - 1 << " ";
    return 0;
}


Measured memory_bytes: 30464
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		boolean isBothNumberMenus = true;
		int index = 1;
		while(isBothNumberMenus) {
			if(a - index < 0 && b - index < 0) {
				System.out.println("IMPOSSIBLE");
				break;
			}
			
			if(Math.abs(a - index) == Math.abs(b - index)) {
				System.out.println(index);
				break;
			}
			index++;
			
		}
		

		
		

		
		
	}	

}

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

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

    long long mul=1;
    for(int i=N; i>0; --i) {
        mul*=i;
        mul%=1000000007;
    }

    cout<<mul%1000000007<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

int main(){
	ll n,m;
	scanf("%lld%lld",&n,&m);
	printf("%lld",n-(n>m));
}

Measured memory_bytes: 128
import kotlin.math.max

fun main() {
    val s = nextString()
    val ans = solve(s)
    println(ans)
}


//A,C,G,T
fun solve(s: String): Int {
    val rainy = 'R'
    
    if(s == "SRS") return 1

    return max(s.takeWhile { it == rainy }.length, s.takeLastWhile { it == rainy }.length)
}

fun nextInt(): Int {
    return readLine()!!.toInt()
}

fun nextIntList(): List<Int> {
    return readLine()!!.split(" ").map { it.toInt() }
}

fun nextString(): String {
    return readLine()!!
}

Measured memory_bytes: 35768
H, W = map(int, input().split())
A = [list(input()) for _ in range(H)]

remove_H = []
w_count = [0] * W
for h in range(H):
    if "#" in A[h]:
        remove_H.append(A[h])
        for i, w in enumerate(A[h]):
            if w == "#":
                w_count[i] += 1
remove_W = set([i for i, x in enumerate(w_count) if x != 0])
for h in remove_H:
    ans = [h[i] for i in range(W) if i in remove_W]
    print("".join(ans))

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#define FI first
#define SE second
#define PF push_front
#define PB push_back
#define POF pop_front
#define POB pop_back
#define MA make_pair
#define ll long long
#define VE vector<int>
#define VP vector<pair<int,int> >
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int INF=1e9+7;
const int mod=1e9+7;
//
int main(){
  int N;
  int A[1000];
  while(1){
    cin>>N;
    if(N==0){
      break;
    }
    FOR(i,0,N){
      cin>>A[i];
    }
    sort(A,A+N);
    int mi=INF;
    FOR(i,1,N){
      mi=min(mi,abs(A[i]-A[i-1]));
    }
    cout<<mi<<endl;
  }
  return 0;
}


Measured memory_bytes: 3132
import math
n = int(input())
a = list(map(int,input().split()))
g_c = sum([1 for i in a if i%2==0]) 
c = 0
for i in a:
  if i%2==0:
    while(i%2==0):
      i = i//2
      c += 1
print(c)

Measured memory_bytes: 4148
#include <stdio.h>
#include <stdlib.h>
#define int long long
#define p (int)(1e9 + 7)

signed main(){
	int H, W, i, j;
	scanf("%lld%lld", &H, &W);
	char **a = (char **)malloc(sizeof(char *) * (H + 1));
	int **dp = (int **)malloc(sizeof(int *) * (H + 1));
	for(i = 0; i <= H; i++){
		a[i] = (char *)malloc(sizeof(char) * (W + 2));
		dp[i] = (int *)malloc(sizeof(int) * (W + 1));
		for(j = 0; j <= W; j++){
			a[i][j] = '#';
			dp[i][j] = 0;
		}
	}
	for(i = 1; i <= H; i++){
		scanf("%s", &a[i][1]);
	}
	dp[0][1] = 1;
	for(i = 1; i <= H; i++){
		for(j = 1; j <= W; j++){
			if(a[i][j] == '.'){
				dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % p;
			}
		}
	}
	printf("%lld\n", dp[H][W]);
	return 0;
}

Measured memory_bytes: 8960
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> v = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 15, 21, 24, 27, 20, 28, 32, 36, 25, 30, 35, 40, 45, 42, 48, 54, 49, 56, 63, 64, 72, 81 };

int main() {
  int n;
  cin >> n;
  auto r = find(v.begin(), v.end(), n);
  if (r == v.end()) {
    cout << "No";
  } else {
    cout << "Yes";
  }
  cout << endl;
}

Measured memory_bytes: 256
#!perl
use strict;
use warnings;
use utf8;
use feature qw/say/;
use List::Util qw/max min/;

# 20:49 - 21:33
my $N = <STDIN>;
my $a_N = <STDIN>;
my @a_N = split(/ /, $a_N);

my $min = min @a_N;
my $max = max @a_N;
my $max_cost;

for ($min..$max) {
    my $y = $_;
    my $cost = 0;
    $cost += ($_ - $y) ** 2 for @a_N;
    if (!defined($max_cost) || $max_cost > $cost ) {
        $max_cost = $cost;
    }
}

print $max_cost;

Measured memory_bytes: 896
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <deque>
#define rep(i, a, b) for (int i = (a), _ = (b); i <= _; ++ i)
#define per(i, a, b) for (int i = (a), _ = (b); i >= _; -- i)
#define For(i, a, b) for (int i = (a), _ = (b); i < _; ++ i)
#define ri rd<int>
#define rl rd<LL>
typedef long long LL;
using namespace std;
const int maxN = 207;
const int V = 200;

template<class T> inline T rd() {
	bool f = 1; char c = getchar(); for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	T x = 0; for (; isdigit(c); c = getchar()) x = x * 10 + c - 48; return f ? x : -x;
}

LL n;
deque<int> ans;
int opr[maxN], kd[maxN], tt;

int main() {

	n = rl();
	int cur = 100;

	while (n) {
		++ tt;
		if (n % 2 == 0) {
			n--;
			opr[tt] = cur --;
			kd[tt] = 1;
		}
		else {
			n >>= 1;
			opr[tt] = cur --;
			kd[tt] = 2;
		}
	}
	per (i, tt, 1) kd[i] == 1 ? ans.push_front(opr[i]) : ans.push_back(opr[i]);
	per (i, tt, 1) ans.push_back(opr[i]);

	printf("%d\n", tt << 1);
	rep (i, 1, tt << 1) printf("%d%c", ans.front(), " \n"[i == tt << 1]), ans.pop_front();

	return 0;
}

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

long long x[60];
long long n,a;
long long dp[60][3000][60];
long long func(long long p,long long s,long long r){
	if(dp[p][s][r]!=-1)return dp[p][s][r];
	if(p==n){
		if(n==r)return 0;
		if((double)s/(n-r)==a){
			return 1;
		}else return 0;
	}
	return dp[p][s][r]=func(p+1,s,r+1)+func(p+1,s+x[p],r);
}

int main(){
	cin>>n>>a;
	rep(i,60)x[i]=0;
	rep(i,60)rep(j,3000)rep(k,60)dp[i][j][k]=-1;
	rep(i,n)cin>>x[i];
	cout<<func(0,0,0)<<endl;
	return 0;
}

Measured memory_bytes: 84608
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

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

const long long MOD = 1e9 + 7;
const long long INF = 1e15;
const int INF_INT = 1e9;

template<class TYPE>
struct edge{
    TYPE to,cost; 
    edge(TYPE t,TYPE c){
        to = t;
        cost = c;
    }
};

int main(){
    string s,t;
    cin >> s >> t;
    string st = s + t;
    int a = stoi(st);
    int isq = sqrt(a);
    double dsq = sqrt(a);
    if(isq == dsq) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
ans = float('inf')
for i in range(N+1):
    count = 0
    n = i
    while n > 0:
        count += n % 6
        n //= 6
    n = N-i
    while n > 0:
        count += n % 9
        n //= 9
    ans = min(ans, count)

print(ans)


Measured memory_bytes: 41456
#include<iostream>
#include<cmath>
#include<string>
#include<vector>
using namespace std;

int  main(){
    int A, B;
    string S;
    int a,b;
    int tmp = 1e9, ans = 0;
    bool flag = true;
    cin >> A >> B;
    cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(i == A){
            if(S[i] != '-')flag = false;
        }else{
            if(S[i] == '-')flag = false;
        }
    }
    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 888
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//		new Main().solveA();
		new Main().solveB();
		// new Main().solveC();
		// new Main().solveD();
	}

	private void solveA() {
		Scanner scanner = null;
		int numN = 0;
		int numA = 0;
		int numB = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();
			numA = scanner.nextInt();
			numB = scanner.nextInt();

			System.out.println(Math.min(numA * numN, numB));

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveB() {
		Scanner scanner = null;
		int numN = 0;

		try {
			scanner = new Scanner(System.in);
			numN = scanner.nextInt();

			int digit = 0;
			int wkNum = numN;
			while (wkNum > 0) {
				wkNum /= 10;
				digit++;
			}
			int res = 0;
			wkNum = numN;
			for (int i = 0; i < digit; i++) {
				res += wkNum % 10;
				wkNum /= 10;
			}

			if (numN % res == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");

			}

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveC() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}

	private void solveD() {
		Scanner scanner = null;
		int lineAB = 0;
		int lineBC = 0;
		int lineCA = 0;

		try {
			scanner = new Scanner(System.in);
			lineAB = scanner.nextInt();

			System.out.println("");

		} finally {
			if (scanner != null) {
				scanner.close();
			}
		}
	}
}

Measured memory_bytes: 22740
#pragma GCC optimize(2)
#pragma G++ optimize(2)
#include<bits/stdc++.h>
#define si(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define sd(a) scanf("%lf",&a)
#define ss(a) scanf("%s",a)
#define ms(a) memset(a,0,sizeof(a))
#define repi(i,a,b) for(register int i=a;i<=b;++i)
#define repd(i,a,b) for(register int i=a;i>=b;--i)
#define reps(s) for(int i=head[s],v=e[i].to;i;i=e[i].nxt,v=e[i].to)
#define ce(i,r) i==r?'\n':' '
#define pb push_back 
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define pr(x) cout<<#x<<": "<<x<<endl
using namespace std;
typedef long long ll;
const int MAX_N=2e5+5;
inline int qi(){
    int f=0,fu=1; char c=getchar();
    while(c<'0'||c>'9'){ if(c=='-')fu=-1; c=getchar(); }
    while(c>='0'&&c<='9'){ f=(f<<3)+(f<<1)+c-48; c=getchar(); }
    return f*fu;
}
struct Union_Find{
	int fa[MAX_N],siz[MAX_N];
	void init(int n){repi(i,0,n)fa[i]=i,siz[i]=1;} 
	int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
	void unit(int x,int y){x=find(x),y=find(y);if(x!=y)fa[y]=x,siz[x]+=siz[y];}
	bool same(int x,int y){return find(x)==find(y);}
}uf;
int main()
{
	int n=qi(),m=qi(); uf.init(n);
	while(m--) uf.unit(qi(),qi());
	int ans=1;
	repi(i,1,n)if(uf.find(i)==i) ans=max(ans,uf.siz[i]);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8372
x = int(input())

if x <= 599:
  print(8)
elif x <= 799:
  print(7)
elif x <= 999:
  print(6)
elif x <= 1199:
  print(5)
elif x <= 1399:
  print(4)
elif x <= 1599:
  print(3)
elif x <= 1799:
  print(2)
elif x <= 1999:
  print(1)

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

int n, h[100500];
pair <int, int> p[100500];


int main() {
	cin >> n;
	REP(i,1, n+1) cin >> h[i]; 
	REP(i,1, n+1) {
		p[i] = make_pair(h[i],i);
	}
	sort(p + 1, p + n + 1);
	REP(i,1, n+1) {
		if (i == n) {
			cout << p[i].second << endl;
		}
		else {
			cout << p[i].second << ' ';
		}
	}



}



Measured memory_bytes: 2048
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll po[10005];

int main() 
{
    FAST;
    ll n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    ll pre[n+1];
    pre[n]=0;
    ll ans=0;
    ll x=1;
    for(int i=n-1;i>=0;i--)
    {
        pre[i]=(pre[i+1]+((ll)(s[i]-'0')*x))%p;
        x=(x*10)%p;
    }
    if(p==2 || p==5)
    {
        if(p==2)
            for(int i=0;i<n;i++)
                if(s[i]=='0' || s[i]=='2' || s[i]=='4' || s[i]=='6' || s[i]=='8')
                    ans+=i+1;
        if(p==5)
            for(int i=0;i<n;i++)
                if(s[i]=='5' || s[i]=='0')
                    ans+=i+1;
    }
    else
    {
        for(int i=n;i>=0;i--)
        {
            ans+=po[pre[i]];
            po[pre[i]]++;
        }
    }
    cout<<ans;
    subt;
    return 0;
}

Measured memory_bytes: 2196
#include "bits/stdc++.h"
using namespace std;

int main() {
	int D, C[26];
	cin >> D;
	for (int i = 0; i < 26; i++) cin >> C[i];
	vector<vector<int> > S(D, vector<int>(26));
	for (int i = 0; i < D; i++) {
		for (int j = 0; j < 26; j++) cin >> S[i][j];
	}
	for (int i = 0; i < D; i++) cout << 26 << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n;
  cin >> n;
  vector <ll> s(n);
  rep(i, n) cin >> s.at(i);
  ll m;
  cin >> m;
  vector <ll> t(m);
  rep(i, m) cin >> t.at(i);
  ll ans = 0;
  rep(i, m) {
    ll tmp = 0;
    rep(j, n) {
      if (s.at(j) == t.at(i)) tmp++;
    }
    if (tmp > 0) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3176
n,W = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(n)]

dp = {}
dp[0] = 0
for w, v in a:
    pre_dp = dp.copy()
    for pw, pv in pre_dp.items():
        if pw + w <= W:
            dp[pw + w] = max(dp.get(pw + w, 0), pv + v)

print(max(dp.values()))

Measured memory_bytes: 3704
# include <iostream>
# include <stdint.h>
# include <stdio.h>
# include <math.h>
using namespace std;


int main(){
	int n ,a,b,c ,d;
	cin >>n;
	for(int i =1; i <n+1;i++){
		int x[i];
		int a =i%3;
		int b =i %10;
        int c =i/10;
         x[i]= 0;
        while(c >2){
        	int d = c%10;
        	if (d ==3)
        	{
        		x[i]=3;/* code */
        	}
        	c =c/10;
        }
		if (a ==0 ||b ==3 ||x[i] ==3){
			cout <<" "<<i ;
		}
	}
	cout << endl;
return 0;
}



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

int main(){
    int n,ans=0;
    cin >> n ;
    vector<int> a(n);
    for(int i=0;i<n;i++){
        cin >> a.at(i);
    }
    for(int i=1;i<n-1;i++){
        if(a.at(i)<a.at(i+1) && a.at(i-1)<a.at(i)){
            ans++;
        }
        if(a.at(i)>a.at(i+1) && a.at(i-1)>a.at(i)){
            ans++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j,n,k;
  long long int s;
  cin>>n>>k>>s;
  for(i=0;i<k;i++)
  {
    cout<<s<<" ";
  }
  int a=0;
  for(i=n-1;i>=k;i--)
  {
    if(a==0)
    {
      if(s!=1)
      cout<<"1"<<" ";
      else
      {
          cout<<"5"<<" ";
      }
    }
    else if(a==1)
    {
      if(s!=1000000000)
      cout<<s+1<<" ";
      else
      {
        cout<<s-1009<<" ";
      }
    }
    a=1-a;
  }
}


Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
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 dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    string a,b,c;
    cin >> a >> b >> c;
    // cout << a.size() << " " << a.substr(a.size()-1,1) << endl; 
    if(a.substr(a.size()-1,1)==b.substr(0,1) && b.substr(b.size()-1,1)==c.substr(0,1) )
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256