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

int main()
{
    int i,j,n,t,a,b,c=0;
    cin>>a>>b;
    if(b>=(a*2)&&b<=(a*4)&&b%2==0)
        cout<<"Yes"<<"\n";
    else
        cout<<"No"<<"\n";
    return 0;

}


Measured memory_bytes: 3652
/*
 * atcoder/abc104/c.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

const ll INF = 100000000000000000;
const int MAX_N = 1100;
const int MAX_G = 110;
const int MAX = 11;
int D, G;
vector<ll> S, P, C;

/*
 * 全探索
 * 難易度nを全部解く or 一切解かない or 残っている最高得点のものを部分的に解く
 */
ll rec(int n = 0, ll acc = 0, bool partial = true) {
  if (n==D) return acc >= G ? 0 : INF;

  ll min_ = INF;
  // 全部解く
  chmin(min_, P[n] + rec(n + 1, acc + S[n] * P[n] + C[n], partial));
  // 一切解かない
  chmin(min_, rec(n + 1, acc, partial));

  // 部分的に解くことが可能、かつ意味があるなら
  if (partial and acc + (S[n] * (P[n] - 1)) >= G) {
    ll count = 0;
    while (S[n] * count + acc < G) count++;
    chmin(min_, count + rec(n + 1, acc + count * S[n], false));
  }

  return min_;
}

void solve() {
  cin >> D >> G;
  ll p, c;
  loop(d,0,D) {
    cin >> p >> c;
    P.push_back(p); C.push_back(c);
    S.push_back((d+1)*100);
  }

  // 部分的に解く場合未考慮のうち最高得点のものをGreedyに解く
  reverse(P.begin(), P.end());
  reverse(S.begin(), S.end());
  reverse(C.begin(), C.end());

  cout << rec() << endl;
}
int main() {
  // cout.precision(15);
  // cout << fixed << double

  solve();

  return 0;
}


Measured memory_bytes: 384
use std::cmp::*;
use std::io::*;

fn main() {
    let mut s: String = String::new();
    stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();

    let mut a: Vec<usize> = (0..3)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    a.sort();
    let one = a[2] - a[1];
    let two = a[2] - a[0];
    let three = two - one;
    if three % 2 == 0 {
        println!("{}", one + three / 2);
    } else {
        println!("{}", one + three / 2 + 2);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
#include <cstring>
using namespace std;

using ll = long long;
using P = pair<int, int>;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int dp[2005][2005];

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

    int N;
    cin >> N;
    vector<int> A(N * 3);
    for(int i = 0; i < N * 3; ++i){
        cin >> A[i];
        --A[i];
    }

    for(int i = 0; i <= N; ++i){
        for(int j = 0; j <= N; ++j){
            dp[i][j] = -INF;
        }
    }
    auto update = [&](int i, int j, int val) -> void {
        chmax(dp[i][j], val);
        chmax(dp[j][i], val);
        chmax(dp[i][N], val);
        chmax(dp[N][i], val);
        chmax(dp[j][N], val);
        chmax(dp[N][j], val);
        chmax(dp[N][N], val);
    };
    update(A[0], A[1], 0);

    int score = 0;
    for(int i = 2; i < N * 3 - 1; i += 3){
        int p = A[i], q = A[i + 1], r = A[i + 2];
        if(p == q && q == r){
            ++score;
            continue;
        }
        vector<tuple<int, int, int>> que;
        for(int loop = 0; loop < 3; ++loop){
            que.emplace_back(p, q, max(dp[N][N], dp[r][r] + 1));
            swap(p, q);
            swap(q, r);
        }
        for(int x = 0; x < N; ++x){
            for(int loop = 0; loop < 3; ++loop){
                int val = dp[x][N];
                if(p == q)  chmax(val, dp[x][p] + 1);
                que.emplace_back(x, r, val);
                swap(p, q);
                swap(q, r);
            }
        }
        for(auto& tup : que){
            int idx1, idx2, val;
            tie(idx1, idx2, val) = tup;
            update(idx1, idx2, val);
        }
    }

    int ans = max(dp[N][N], dp[A.back()][A.back()] + 1);
    ans += score;
    cout << ans << endl;
}

Measured memory_bytes: 19444
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define rep(i,n) for(int i=0;i<n;i++)
const int MOD = 1000000007;


int main(){
    int n;  cin >> n;
    vector<int> a(n);
    int res=0;
    rep(i,n) cin >> a[i];

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

    for(int i=0;i<n-2;i++){
        for(int j=i+1;j<n-1;j++){
            for(int k=j+1;k<n;k++){
                if(a[k]<a[i]+a[j]) res++;
                else break;
            }
        }
    }

    cout << res << endl;
}




Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
    static int N;
    static long[] a;
    static long[] b;

    private static void init() {
        Scanner scanner = new Scanner(System.in);
        N = scanner.nextInt();
        a = new long[N + 1];
        b = new long[N];
        for(int i = 0; i <= N; i++) {
            a[i] = scanner.nextLong();
        }
        for(int i = 0; i < N; i++) {
            b[i] = scanner.nextLong();
        }
        scanner.close();
    }


    public static void main(String[] args) {
        init();

        long kill = 0;
        for(int i = 0; i < N; i++) {
            long remainPowser = 0;
            if(b[i] > a[i]) {
                remainPowser = Math.min(b[i] - a[i], a[i + 1]);
                if(a[i + 1] > remainPowser) {
                    a[i + 1] = a[i + 1] - remainPowser;
                } else {
                    a[i + 1] = Math.max(a[i + 1] - (b[i] - a[i]), 0);
                }
            }
            kill += Math.min(a[i], b[i]) + remainPowser;
        }

        System.out.println(kill);
    }
}

Measured memory_bytes: 89880
#include <bits/stdc++.h>
// statics
using namespace std;
using int64 = long long;
using PAIR = pair<int, int>;
constexpr int INF = 1 << 30;
constexpr int64 LINF = 1LL << 60;
constexpr int MOD = 1e9 + 7;
constexpr int MAX_N = 1e5 + 1;

// init/input
#define int int64
#define INIT ios::sync_with_stdio(false);cin.tie(0);
#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);
template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}
template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}
#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;

// out
#define OUT(dist) cout<<(dist);
#define FOUT(n, dist) cout <<fixed<<setprecision(n)<<(dist);
#define SP cout<<" ";
#define BR cout<<"\n";
#define debug(x) cerr << #x << ":" << (x);BR;

// utility
#define ALL(a) (a).begin(), (a).end()
#define EACH(i, a) for(auto &&i:(a))
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)
#define REP(i, n) for(int i=0;i<(n);++i)
#define RREP(i, n) for(int i=(n)-1;i>=0;--i)

signed main() {
  INIT;

  VAR(int, n, i);
  OUT(n - i + 1)BR;
  return 0;
}


Measured memory_bytes: 256
/**
 *   @FileName	a.cpp
 *   @Author	kanpurin
 *   @Created	2020.08.17 19:02:25
**/

#include "bits/stdc++.h" 
using namespace std; 
typedef long long ll;

int main() {
    int n,x;cin >> n >> x;
    if (x == 1 || x == 2 * n - 1) {
        puts("No");
        return 0;
    }
    puts("Yes");
    for (int i = 0; i < 2 * n - 1; i++) {
        cout << (i+x+n-1) % (2 * n - 1) + 1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define rep(i,n,m) for(int i=n;i<(int)(m);i++)
#define rrep(i,n,m) for(int i=((int)(n)-1);i>=m;i--)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
using namespace std;
int main(){
    string s;
    cin>>s;
    cout<<s.substr(0,4)<<" "<<s.substr(4,8)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int p, q, r;
	scanf("%d", &p);
	scanf("%d", &q);
	scanf("%d", &r);
	if (p <= q && p <= r) {
		if (q <= r) {
			printf("%d", p + q);
		}
		else {
			printf("%d", p + r);
		}
	}
	else if (q <= p && q <= r) {
		if (p <= r) {
			printf("%d", p + q);
		}
		else {
			printf("%d", q + r);
		}
	}
	else if (r <= p && r <= q) {
		if (p <= q) {
			printf("%d", p + r);
		}
		else {
			printf("%d", q + r);
		}
	}

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>

using namespace std;
int main(void)
{
   int a, b, c;

   cin >> a >> b >> c;

   bool ans = false;
   for (int i = 1; i <= 100; i++) {
       if (a * i % b == c) {
           ans = true;
       }
   }

   if (ans) {
       cout << "YES" << endl;
   }
   else {
       cout << "NO" << endl;
   }
   return 0;
}

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

#define x first
#define y second

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

const int mod=1000000000+7;

int addm(int& a,int b) {return (a+=b)<mod?a:a-=mod;}

template<class T,class U> bool smin(T& a,U b) {return a>b?(a=b,1):0;}
template<class T,class U> bool smax(T& a,U b) {return a<b?(a=b,1):0;}

ll N,M,dp[2][3001][3001];
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> N >> M;
	//fill(ma[0],ma[1],N);
	fill(dp[0][0]+1,dp[0][1],1);
	dp[1][0][0]=1;


	for (int i=0;i<M;i++) for (int c=0;c<2;c++) for (int j=0;j<=N;j++) for (int mask=0;mask<4;mask++) {
		int nc=c;
		if (mask&1) {
			if (j==N) continue;
		}
		else {
			if (j==0) continue;
			if (j==1) nc=1;
		}

		int nj=j-1+__builtin_popcount(mask);
		dp[nc][i+1][nj]=(dp[nc][i+1][nj]+dp[c][i][j])%mod;
	}

	cout << accumulate(dp[1][M],dp[1][M+1],0ll)%mod << endl;
}

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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;

#define FOR(i, begin, end) for(int i = (begin); i < (end); i++)
#define rep(i, n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define ZP(a, len) setfill('0') << setw(len) << right << a
const int INF = 1e9;
const int MOD = 1e9 + 7;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};

signed main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;

    auto ans = A * B;
    ans = max(ans, C * D);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>

#define X first
#define Y second
#define vsort(v) sort((v).begin(), (v).end())
#define vrev(v) reverse((v).begin(), (v).end())


// INT_MAX
// INT_MIN
// LLONG_MAX
// LLONG_MIN
// DBL_MIN
// DBL_MAX
// LDBL_MIN
// LDBL_MAX

// A-Z: 65~90
// a-z: 97~122
// |a-z| = 26

using namespace std;
using ll = long long;

int main(int argc, const char * argv[]) {
    int x;
    cin >> x;
    if(x == 3 || x == 5 || x == 7){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
import math
s=input()
n=len(s)
flist=[0]*n

rstreak=False
tmpl=0
tmpr=0
divindex=0

for i in range(n):
	if rstreak:
		if s[i] == "R":
			tmpr += 1
		else:
			rstreak = False
			divindex = i-1
			tmpl += 1
	else:
		if s[i] == "R":
			rstreak=True
			flist[divindex]=math.ceil(tmpr/2) + tmpl//2
			flist[divindex+1]=math.ceil(tmpl/2) + tmpr//2
			tmpl=0
			tmpr=1
		else:
			tmpl += 1

flist[divindex]=math.ceil(tmpr/2) + tmpl//2
flist[divindex+1]=math.ceil(tmpl/2) + tmpr//2

for f in flist:
	print(f,end=" ")


Measured memory_bytes: 10176
n,m,x,y=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
a.sort(reverse=True)
b.sort()
# xx=a[0]
f=0
# if xx<x:
#     xx=x 
for i in range(x+1,y+1):
    if i<=b[0] and i>a[0]:
        #print(i)
        f=1 
        break 
if f==1:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
#include<iostream>
#include<queue>
#include<unordered_set>
using namespace std;

struct edge { int to, company; };
typedef pair<int, int> P;// (minimum fare, station number)

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	vector<vector<edge>> es(n);
	vector<int> d(n, INT32_MAX);
	vector<unordered_set<int>> rosen(n);

	while(m--)
	{
		int pi,qi,ci;
		cin>>pi>>qi>>ci;
		pi--; qi--;
		es[pi].push_back({qi,ci});
		es[qi].push_back({pi,ci});
	}
	priority_queue<P> q;
	d[0]=0;q.push({0,0});
	while(q.size())
	{
		P p = q.top();q.pop();
		if (d[p.second] < -p.first) continue;
		for(const auto& j:es[p.second])
		{
			int dist=d[p.second];
			if(!rosen[p.second].count(j.company)) dist++;
			if (d[j.to] < dist) continue;
			if (dist < d[j.to])
			{
				d[j.to] = dist;
				rosen[j.to].clear();
				q.push({ -dist,j.to });
			}
			rosen[j.to].insert(j.company);
		}
	}
	cout<<(d[n-1]==INT32_MAX ? -1:d[n-1])<<endl;
	return 0;
}

Measured memory_bytes: 24948
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i = x; i < n; i++)
#define MAX 100
#define INF 1000000001
typedef long long ll;

ll n,k;
// char X[100][100];
// int dp[1000000001];

int main(void) {
    cin >> n >> k;
    if (k % 2 == 1) {
        ll t = (n/k);
        cout << t * t * t << endl;
        return 0;
    }
    
    // int t = kn;
    ll a = ((n + (k/2)) / k);
    ll b = (n/k);
    cout << a * a * a + b * b * b<< endl;
}

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

int main() {
	u64 H, W;
	cin >> H >> W;
	
	if(H == 1 || W == 1) {
		cout << 1;
	} else {
		cout << (H * W + 1) / 2;
	}
	
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
class Program
{
	//static int[] dp;
	//static decimal[,,] dp;
	//static decimal N;
	static void Main(string[] args)
	{
			// 入力フェーズ
			//N = Decimal.Parse(Console.ReadLine()); // N皿ある
			string[] input = Console.ReadLine().Split(' '); // A,B
			int A = Int32.Parse(input[0]);
			int B = Int32.Parse(input[1]);

			int num1 = A+B;
			int num2 = A-B;
			int num3 = A*B;
			int ret = Math.Max(num1, num2);
			ret = Math.Max(num3, ret);
			Console.WriteLine(ret + "");
    }


}


Measured memory_bytes: 11092
#define _GLIBCXX_DEBUG
#include<cmath>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
vector<int> arr;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;

/*int P[10010];
void init(int n){
    for(int i=0;i<n;++i)P[i]=i;
}
int root(int a) {
    if(P[a]==a)return a;
    return (P[a]=root(P[a]));
}
bool is_same_set(int a,int b){
    return root(a) == root(b);//代表元を求める
}
void unite(int a,int b){
    P[root(a)]=root(b);
}//対set,グラフ？
//セグメント木？？
*/

double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }//内積
double cross_product(xy_t a, xy_t b) { return (conj(a)*b).imag(); }//外積
xy_t projection(xy_t p, xy_t b) { return b*dot_product(p,b)/norm(b); }//投影
//対図形

#define mod 1000000007
/*ll f[2001];
//int n,k とかしておく

ll pw(ll x, ll y){//euclidの互除法より
    ll a= 1;
    while(y){
        if(y&1){//奇数なら
            a = a*x%mod;
        }
        x = x*x%mod;
        y /= 2;
    }
    return a;
}

ll modinv(ll x){//逆元を求める
    return pw(x, mod - 2 );
}

ll comb(int n,int r){
    if(n<r){
        return 0;
    }
    return f[n] * modinv(f[r])%mod*modinv(f[n-r])%mod;
}//対combination//ただしfは用意してね
*/

struct BIT{
    vector<int> dat;
    int sz;
    BIT(int n){
        for(sz=1;sz<n;sz *= 2);
        dat.resize(++sz);
    }
    int q(int n){
        int ret = 0;
        for(int i=n;i>0;i-=i&-i)ret +=dat[i];//和の計算　iから最後の１のbit(i&-i 多分＆はビット積)を減算
        for(int i=n;i<sz;i+=i&-i) dat[i]++;//値の加算　iから最後mの１のbitを加算
        return ret;
    }
};

int main(){
    int k,x;
    cin >> k>> x;
    int start=x-k+1;
    int end=x+k-1;
    for(int i=start;i<=end;i++){
        cout<<i<<" ";
    }
    cout<<endl;
    return 0;
}

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

int main(int argc, char *argv[])
{
  int n;
  int a[100] = {0};
  cin >> n;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << (a[n-1] - a[0]) << endl;
  return 0;
}


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

int main()
{
  int n, ans = 0;
  vector<int> vec;
  cin >> n;
  rep(i, n)
  {
    int c;
    cin >> c;
    vec.push_back(c);
  }
  int now = 1;
  while (1)
  {
    now = vec[now - 1];
    ans++;
    if (now == 2)
    {
      cout << ans << endl;
      return 0;
    }
    if (ans >= n)
    {
      cout << -1 << endl;
      return 0;
    }
  }
}


Measured memory_bytes: 892
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)







int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << " " << a * 2 + b * 2 << endl;
}


Measured memory_bytes: 3096
program test
implicit none
integer(8) :: n,m,a(1000),i,j,k,total=0,count=0

read(*,*) n,m
read(*,*) (a(i),i=1,n)

do i=1,n
  total = total + a(i)
enddo

do i=1,n
  if(4*m*a(i) >= total) then
    count = count + 1
  endif
enddo

if(count >= m) then
  write(*,*) 'Yes'
else
  write(*,*) 'No'
endif

end

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

int main() {
	int N, x;
	cin >> N >> x;
	vector<int> a(N, 0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int ans = 0;
	while (x > 0 && ans<N) {
		int b = a[ans];
		if (x>= b) ans++;
		x -= b;
	}
	//全員に配っても余ってる
	if (x > 0) ans--;
	cout << ans;
}

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

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define rept(i,n) for(ll (i)=0;(i)<=(ll)(n);(i)++)
#define reps(i,s,n) for(ll (i)=(s);(i)<(ll)(n);(i)++)
#define repst(i,s,n) for(ll (i)=(s);(i)<=(ll)(n);(i)++)
#define repr(i,n) for(ll (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

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

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

ll x, y, r = 1;

int main() {
	cin >> x >> y;
	while (true) {
		x *= 2;
		if (x>y) break;
		r++;
	}
	cout << r << ln;
}

Measured memory_bytes: 256
from collections import Counter
def solve():
    N = int(input())
    A = list(map(int, input().split()))
    cnter = Counter(A)
    cnter_list = list(cnter.items())
    cnter_list.sort(key=lambda x:x[0], reverse=True)

    double_cnt = 0
    ans = 1
    for elem in cnter_list:
        if elem[1] >= 4:
            if double_cnt == 0:
                ans = elem[0] * elem[0]
                break

        if elem[1] >= 2:
            double_cnt += 1
            ans *= elem[0]
        if double_cnt >= 2:
            break
    else:
        print(0)
        return
    
    print(ans)

if __name__ == '__main__':
    solve()

Measured memory_bytes: 72344
import collections
n=int(input())
ab=[list(input()) for l in range(n)]

c=[0]*n
for i in range(n):
    c[i]=sorted(ab[i])
moji=[0]*n
for i in range(n):
    moji[i] = ','.join(c[i])

c = collections.Counter(moji)
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
d=c.values()
d=list(d)
ct=0
for i in range(len(d)):
    if d[i]==2:
        ct+=1
    elif d[i]>2:
        ct+=combinations_count(d[i], 2)
print(ct)

Measured memory_bytes: 62976
#include<bits/stdc++.h>
#define lli long long int
using namespace std;
 
lli fun(lli h)
{
   if(h>1)
    return 2*(fun(h/2))+1;
   else
    return 1;

}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    lli h;
    cin>>h;
    cout<<fun(h)<<"\n";
}

Measured memory_bytes: 3656
#include<iostream>
#include<iomanip>
#include<string>
#include<array>
using namespace std;

int main() {
	int n,c=0;
	array<int, 60> p;
	cin >> n;
	for (int i = 0; i < n;i++) {
		cin >> p[i];
		if (p[i]!=i+1) {
			c++;
		}
	}
	if (c==0||c==2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
     
    using i64 = int64_t;
    using u64 = uint64_t;
    using f32 = float;
    using f64 = double;
    using f80 = __float80;
     
    template<typename C>
    i64 Size(const C& c) { return static_cast<i64>(c.size()); }
     
    template<typename C>
    void Sort(C &c) { std::sort(c.begin(), c.end()); }
     
    template<typename C>
    void SortR(C &c) { std::sort(c.rbegin(), c.rend()); }
     
    template<typename T, typename U, typename Comp=std::less<>>
    bool ChMax(T& x_max, const U& x, Comp comp={}) {
      if(comp(x_max, x)) {
        x_max = x;
        return true;
      }
      return false;
    }
     
    template<typename T, typename U, typename Comp=std::less<>>
    bool ChMin(T& x_min, const U& x, Comp comp={}) {
      if(comp(x, x_min)) {
        x_min = x;
        return true;
      }
      return false;
    }
     
    struct ProconInit {
      static constexpr int IOS_PREC = 15;
      static constexpr bool AUTOFLUSH = false;
     
      ProconInit() {
        std::cin.tie(nullptr);
        std::ios::sync_with_stdio(false);
        std::cout << std::fixed << std::setprecision(IOS_PREC);
        if (AUTOFLUSH) std::cout << std::unitbuf;
      }
    } PROCON_INIT;
     
    void solve() {
      f80 r; std::cin >> r;
     
      std::cout << r * 2.0 * 3.1415926535 << "\n";
    }
     
    signed main() {
      solve();
     
      return 0;
    }

Measured memory_bytes: 3804
#!/usr/bin/env python3
import sys


def solve(n: int, m: int):
    print((n - 1) * (m - 1))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    m = int(next(tokens))  # type: int
    solve(n, m)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(10**7)

N = int(input())
AB = [tuple(map(int,input().split())) for i in range(N-1)]
es = [[] for i in range(N)]
st = -1
for a,b in AB:
    es[a].append(b)
    es[b].append(a)
    if len(es[a]) >= 3: st = a
    if len(es[b]) >= 3: st = b
if st < 0:
    print(1)
    exit()

def rec(v,p=-1):
    ret = 0
    child_anntena = 0
    for to in es[v]:
        if to==p: continue
        tmp = rec(to,v)
        ret += tmp
        if tmp:
            child_anntena += 1
    n = len(es[v]) - 2
    if p<0: n += 1
    ret += max(0, n - child_anntena)
    return ret
print(rec(st))

Measured memory_bytes: 76452
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <queue>

using namespace std;

int HV[][2]{
        {0,  1},
        {1,  1},
        {1,  0},
        {0,  -1},
        {-1, -1},
        {-1, 0},
};

int main() {
    int t, n;
    while (cin >> t >> n) {
        if ((t | n) == 0) break;

        unordered_map<int, unordered_set<int>> o;   //obstacle

        while (n--) {
            int x, y;
            cin >> x >> y;
            o[x].insert(y);
        }

        int sx, sy;
        cin >> sx >> sy;
        o[sx].insert(sy);

        int ans = 1;
        queue<tuple<int, int, int>> que;

        que.emplace(sx, sy, 0);
        while (!que.empty()) {
            int x, y, c;
            x = get<0>(que.front());
            y = get<1>(que.front());
            c = get<2>(que.front());
            que.pop();
            if (c == t) continue;
            for (auto hv : HV) {
                int nx, ny;
                nx = x + hv[0];
                ny = y + hv[1];
                if (o.find(nx) == o.end() || o[nx].find(ny) == o[nx].end()) {
                    que.emplace(nx, ny, c + 1);
                    o[nx].insert(ny);
                    ans++;
                }
            }
        }

        cout << ans << endl;
    }
}


Measured memory_bytes: 3324
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0028
{
    class Program
    {
        static void Main(string[] args)
        {
            string str = "";
            int[] list = new int[101];
            List<int> list1 = new List<int>();
            int max = 0;
            while ((str = Console.ReadLine()) != null)
            {
                int number = int.Parse(str);
                list[number]++;
            }
            max = list.Max();
            for(int i = 0; i < list.Length; ++i)
            {
                if (list[i] == max)
                {
                    list1.Add(i);
                }
            }
            list1.Sort();

            foreach (var item in list1)
            {
                Console.WriteLine(item);
            }
        }
    }
}



Measured memory_bytes: 14220
#include <bits/stdc++.h>
#define len(x) (int) (x.size())
#define PI (long double)4.0*atan(1.0)
using namespace std;
typedef long long ll;

int main(){
    int a, b, h, m;
    cin >> a >> b >> h >> m;

    long double angle = (abs(11*m-60*h)/2.0L);
    long double angleComplement = 360-angle;

    angle = min(angle, angleComplement);
    angle *= PI/180.0;
    
    printf("%.15Lf\n", sqrt((long double)a*a+b*b-2.0*a*b*cos(angle)));

    return 0;
}

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

int main(){
    int N, A, B;
    scanf("%d\n%d %d", &N, &A, &B);

    for (int i=A; i<=B; i++)
        if (i % N == 0) {
            printf("OK\n");
            return 0;
        }
    printf("NG\n");
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int p[n];
  for(int i=0;i<n;++i) cin>>p[i];
  sort(p,p+n);
  int s=0;
  for(int i=0;i<k;++i) 
  s+=p[i];
  cout<<s;
  return 0;
}

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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int h1, m1, h2, m2, K; cin >> h1 >> m1 >> h2 >> m2 >> K;
    cout << (h2-h1)*60 + (m2-m1) - K << endl;
    return 0;
}

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

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

int dfs(graph &G, vector<int> &dp, int v) {
  if (dp[v] != -1) return dp[v];
  if (G[v].size() == 0) {
    dp[v] = 0;
    return 0;
  }
  for (auto nv : G[v]) {
    chmax(dp[v], dfs(G,dp,nv)+1);
  }
  return dp[v];
}

int main() {
  int n,m;
  cin >> n >> m;
  graph G;
  rep(i,0,m) {
    int x,y;
    cin >> x >> y;
    G[x].push_back(y);
  }
  vector<int> dp(n+1,-1);
  int ans = -1;
  rep(i,1,n+1) {
    chmax(ans, dfs(G,dp,i));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 19280
#include<bits/stdc++.h>
using namespace std;
int main(){
	//ios::sync_with_stdio(0);
	//cin.tie(0);
	int n,a,b,ans;
	while(cin>>n>>a>>b){
		ans=0;
		for(int i=1;i<=n;i++){
			int q=0,c=i;
			while(c>0){
				q+=c%10;
				c/=10;
			}if(q>=a&&q<=b)ans+=i;
		}cout<<ans<<"\n";
	}
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
using namespace std;

int main(){
  int n,a,b;
  cin >> n >> a >> b;
  cout << min(n*a,b) << endl;
  return 0;
}


Measured memory_bytes: 256
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int a, b, k;
  cin >> a >> b >> k;
  if (2 * k >= b - a + 1) {
    FOR(i, a, b + 1) {
      cout << i << endl;
    }
  }
  else {
    FOR(i, a, a + k) {
      cout << i << endl;
    }
    FOR(i, b - k + 1, b + 1) {
      cout << i << endl;
    }
  }


  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<62;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll n;cin>>n;
    ll a[n];
    rep(i,0,n)cin>>a[i];
    sort(a,a+n);
    ll ans=0;
    ans+=a[n-1];
    ll cnt=1;
    ll now=n-2;
    bool bo=true;
    for(;;){
        if(cnt==n-1)break;
        ans+=a[now];
        if(bo==false){
            now--;
        }
        bo^=1;
        cnt++;
    }
    cout<<ans<<endl;
}



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

using namespace std;
const int N=3e5+5;
int a[N];
vector<int> adj[N];
void solve(int u,int p)
{
    for(auto v:adj[u])
        if(v!=p)
        {
            a[v]+=a[u];
            solve(v,u);
        }
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,q;
    cin>>n>>q;
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        a[x]+=y;
    }
    solve(1,-1);
    for(int i=1;i<=n;i++){
        if(i!=1) cout<<" ";
        cout<<a[i];
    }
    cout<<'\n';
    return 0;
}


Measured memory_bytes: 26240
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#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++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

int main()
{
    string table[6] = {	"abcde", "fghij", "klmno", "pqrst", "uvwxy", "z.?! "	};
	
	for(string line; cin >> line;)
	{
		if(line.size() % 2)
		{
			cout << "NA" << endl;
			continue;
		}
		
		string ans;
		rep(i, line.size() / 2) if('1' <= line[i * 2] && line[i * 2] <= '6' && '1' <= line[i * 2 + 1] && line[i * 2 + 1] <= '5')
			ans += table[line[i * 2] - '1'][line[i * 2 + 1] - '1'];
		
		if(ans.size() * 2 == line.size())
			cout << ans << endl;
		else
			cout << "NA" << endl;
	}
}

Measured memory_bytes: 0
N = int(input())
sheet = [[0 for i in range(10)] for i in range(10)]
cnt = 0

for i in range(1, N + 1):
  str_i = str(i)
  sheet[int(str_i[0])][int(str_i[-1])] += 1

res = 0
for i in range(10):
  for j in range(10):
    res += sheet[i][j] * sheet[j][i]

print(res)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool itp1_2_d(int &W, int &H, int &x, int &y, int &r){
    
    if (x < 0 || y < 0){
        return false;
    }
        
    if(x + r > W){
        return false;
    }
    if(y + r > H){
        return false;
    }
    
    return true;
}

int main(void){
    string input;
    
    while(getline(cin, input), !cin.eof()){
        int W, H, x, y, r;
        
        sscanf(input.c_str(), "%d %d %d %d %d", &W, &H, &x, &y, &r);
        
        if(itp1_2_d(W, H, x, y, r)){
            printf("Yes\n");
        }
        else{
            printf("No\n");
        }
        
    }
    
    return(0);
}



Measured memory_bytes: 3204
//in the name of god
#include <bits/stdc++.h>
using namespace std;
#define MAX_N (int)1e6+20
#define INF 1e9+20
#define pb push_back
#define F first
#define S second
typedef long long LL;
#define int LL
typedef pair<int,int> pii;
const int delta=(int)1e9+7;
int n,a,b,ans=6,x,y,z;
main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin>>n>>a>>b>>z;
	if(n+a==b+z) cout<<"Balanced";
	else if(n+a>b+z) cout<<"Left";
	else cout<<"Right";
	return cout<<endl,0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	string s; cin >> s;
	int ans = 0; int cnt = 0;
	rep(i, s.size()) {
		if (s[i] == 'W') {
			ans += i - cnt;
			cnt++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 720
#include<iostream>
#include<string>
using namespace std;
int main()
{
  int k;
  string word,temp="";
  cin>>k;
  cin>>ws;
  cin>>word;
  if(word.length()<=k)
  {
    cout<<word;
    exit(0);
  }
  
  else
  { 
    for(int i=0;i<k;i++)
       temp+=word[i];      
   }
  temp+="...";
  cout<<temp;
  return 0;
}


Measured memory_bytes: 3628
K,N = map(int,input().split())
A = list(map(int,input().split()))

dist = []
for i in range(len(A)-1):
    dist.append(A[i+1] - A[i])

dist.append(A[0] + K - A[N-1])
dist.sort()
dist.pop(-1)


print(sum(dist))





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

using namespace std;

using ll = long long;

constexpr ll MOD = 1000000007;

#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
#else
#define print(...)
#endif

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

    string s;

    cin >> s;


    cout << s.substr(0,3) << endl;

    return 0;
}

Measured memory_bytes: 3612
N = int(input())
As = input().split()
As = [int(A) for A in As]
count = 0
terminate = False
for _ in range(100):
    new_As = []
    for A in As:
        if A % 2 == 1:
            terminate == True
            break
        else:
            new_As.append(int(A/2))
    if len(new_As) == len(As):
        As = new_As
        count += 1
    else:
        break
print(count)

Measured memory_bytes: 3064
N,M=map(int,input().split())

D={}
for _ in range(N):
    A,B=map(int,input().split())

    if A in D:
        D[A]+=B
    else:
        D[A]=B

L=[]
for m in D:
    L.append((m,D[m]))

L.sort(key=lambda x:x[0])

S=0
I=0
while M>0:
    (A,B)=L[I]
    B=min(B,M)
    S+=A*B
    M-=B
    I+=1
print(S)


Measured memory_bytes: 96308
using System;
using System.Collections.Generic;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int N = cin.nextInt();

        long max = 0;
        long min = 1000000001;
        for (int i = 0; i < N; i++)
        {
            int a = cin.nextInt();
            max = Math.Max(a, max);
            min = Math.Min(a, min);
        }

        Console.WriteLine(max - min);
    }
}

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
import java.util.*;

public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    String x = sc.next();
    int f =0;
    int l =0;
    for (int i=0; i<x.length(); i++) {
      if (x.charAt(i) == 'A') {
        f = i;
        break;
      }
    }
    for (int i=x.length()-1; i>=0; i--) {
      if (x.charAt(i) == 'Z') {
        l = i;
        break;
      }
    }
    System.out.println(l-f+1);
  }
}

Measured memory_bytes: 27824
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():

    X =int(input())
    if X==1:
        print("NO")
        exit()
    if 105 % X ==0:
        print("YES")
    else:
        print("NO")





if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
  int n;
  int a[1<<17][3];
  int m[1<<17][3];
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i][0] >> a[i][1] >> a[i][2];
    m[i][0] = m[i][1] = m[i][2] = 0x80000000;
  }
  m[0][0] = a[0][0];
  m[0][1] = a[0][1];
  m[0][2] = a[0][2];
  for (int i = 1; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
	if (k == j) continue;
	m[i][j] = max(m[i-1][k]+a[i][j], m[i][j]);
      }
    }
  }
  cout << max(max(m[n-1][0], m[n-1][1]), m[n-1][2]) << endl;
  return 0;
}


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

#define TRACE(x) x
#define WATCH(x) TRACE(cout << #x" = " << x << endl)
#define WATCHR(a, b) TRACE(for (auto it=a; it!=b;) cout << *(it++) << " "; cout << endl)
#define WATCHC(V) TRACE({cout << #V" = "; WATCHR(V.begin(), V.end());})

#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vs = vector<string>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    int N;
    cin >> N;

    vs grid(N);
    vi row(N), col(N);
    bool white = true;

    for (int i = 0; i < N; i++) {
        cin >> grid[i];
        for (int j = 0; j < N; j++) {
            if (grid[i][j] == '#') {
                row[i]++;
                col[j]++;
                white = false;
            }
        }
    }

    if (white) {
        cout << -1 << endl;
        return 0;
    }

    int ans = INT_MAX;
    for (int i = 0; i < N; i++) {
        ans = min(ans, N - row[i] + !col[i]);
    }

    for (int v : col) {
        if (v < N) ans++;
    }

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



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  string S;
  cin >> S;
  int K;
  cin >> K;
  for(int i=0; i<S.size(); i++){
    if(S[i] == 'a') continue;
    int diff = 26 - (S[i] - 'a');
    if(diff <= K){
      K -= diff;
      S[i] = 'a';
    }
  }
  S[S.size()-1] = ((S[S.size()-1] - 'a') + K)%26 + 'a';
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 512