akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val R = sc.nextInt()
    val C = sc.nextInt()
    val k = sc.nextInt()
    val items = Array(R) { LongArray(C) }
    for (i in 0 until k) {
        val r = sc.nextInt() - 1
        val c = sc.nextInt() - 1
        val v = sc.nextLong()
        items[r][c] = v
    }
    var dp = Array(C) { LongArray(4) }
    for (i in 0 until R) {
        val newdp = Array(C) { LongArray(4) }
        for (j in 0 until C) {
            newdp[j][0] = dp[j].max()!!
            if (items[i][j] != 0L) {
                newdp[j][1] = newdp[j][0] + items[i][j]
            }
            for (k in 0 until 4) {
                val v = if (j > 0) newdp[j - 1][k] else 0L
                newdp[j][k] = maxOf(newdp[j][k], v)
                if (items[i][j] != 0L && k != 0) {
                    val w = if (j > 0) newdp[j - 1][k - 1] else 0L
                    newdp[j][k] = maxOf(newdp[j][k], w + items[i][j])
                }
            }
        }
        dp = newdp
    }
    println(dp[C - 1].max()!!)
}

fun main() {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}


Measured memory_bytes: 146340
s=input()
s_list=s.split("/")
year=int(s_list[0])
month=int(s_list[1])
day=int(s_list[2])

if year<2019:
    string="Heisei"
elif year==2019 and month<=4:
    string="Heisei"
else:
    string="TBD"

print(string)


Measured memory_bytes: 38256
from collections import Counter

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

c = Counter(A)
ans = 0
size = len(c.keys())

if size > K:
    temp = size - K
    ans += sum(v for _, v in sorted(c.items(), key=lambda x: x[1])[:temp])

print(ans)


Measured memory_bytes: 39352
/*suri_kumkaran*/

#include <bits/stdc++.h>

using namespace std;

#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define MP make_pair
#define EB emplace_back
#define endl "\n"
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long

typedef long long int64;
typedef vector<int> VI64;
typedef vector<pair<int,int>> VII64;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;

int32_t main()
{
	IOS;
	int T=1;
	//cin>>T;
	while(T--)
	{
		int n;
		cin>>n;
		cout<<(n+1)/2;
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int sum=0,c,x;
    scanf("%d",&x);
    
    c=x;
    
    while(x>0){
        sum+=x%10;
        x=x/10;
    }
    if(c%sum==0){
        printf("Yes");
    }
    else{
        printf("No");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);

	int N;
	ll X;
	cin >> N >> X;
	struct Test{
		ll b,l,r;
		Test(ll b_,ll l_,ll r_):b(b_),l(l_),r(r_){}
	};
	V<Test> tests;
	rep(i,N){
		ll b,l,r;
		cin >> b >> l >> r;
		tests.emplace_back(b,l,r);
	}
	auto score = [&](Test test, ll t){
		if(t <= test.b) return t * test.l;
		return test.b * test.l + (t-test.b) * test.r;
	};
	sort(all(tests),[&](Test& l, Test& r){
		return score(l,X) > score(r,X);
	});
	ll need = 0;
	rep(i,N) need += tests[i].b * tests[i].l;
	auto enough = [&](ll t){
		int full = t/X;
		int rem = t%X;
		ll sum = 0;
		ll mx = 0;
		rep(i,full) sum += score(tests[i],X);
		rep(i,N){
			if(i<full){
				chmax(mx,sum-score(tests[i],X)+score(tests[i],rem)+score(tests[full],X));
			}else{
				chmax(mx,sum+score(tests[i],rem));
			}
		}
		return mx >= need;
	};
	ll lb = -1, ub = N*X;
	while(ub-lb>1){
		ll m = (lb+ub)/2;
		if(enough(m)) ub = m;
		else lb = m;
	}
	cout << ub << endl;
}


Measured memory_bytes: 4980
/**
 *    author:  FromDihPout
 *    created: 2020-08-03
**/

#include <bits/stdc++.h>
using namespace std;

const int MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    string s1, s2;
    cin >> s1 >> s2;
    
    long long ans;
    int i;
    bool prev; // true if vertical, false if horizontal
    if (s1[0] == s2[0]) {
        ans = 3;
        i = 1;
        prev = true;
    }
    else {
        ans = 6;
        i = 2;
        prev = false;
    }
    while (i < n) {
        if (s1[i] == s2[i] && prev) {
            ans *= 2;
            i++;
            prev = true;
        }
        else if (s1[i] == s2[i]) {
            i++;
            prev = true;
        }
        else if (prev) {
            ans *= 2;
            i += 2;
            prev = false;
        }
        else {
            ans *= 3;
            i += 2;
            prev = false;
        }
        ans %= MOD;
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  V<int> a(1<<n);
  REP(i, 1<<n) cin >> a[i];

  V<int> b(1<<n);
  REP(i, n) {
    REP(j, 1<<n) {
      if((j&1<<i) == 0) {
        // j|1<<i に j が入る
        if(a[j|1<<i] < a[j]) {
          b[j|1<<i] = a[j|1<<i];
          a[j|1<<i] = a[j];
        } else if(b[j|1<<i] < a[j]) {
          b[j|1<<i] = a[j];
        }
        if(b[j|1<<i] < b[j]) {
          b[j|1<<i] = b[j];
        }
      }
    }
  }

  int ma = 0;
  FOR(i, 1, 1<<n) {
    chmax(ma, a[i]+b[i]);
    cout << ma << endl;
  }

  return 0;
}



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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    sort(A.rbegin(), A.rend());
    ll ans = 0;
    FOR(i, 1, N) {
        ans += A[i / 2];
    } 
    cout << ans << "\n";
}

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

int solve(string T, string P, int start)
{
    int n = T.size(), m = P.size();
    int k = start;
    int x, y;

    if(n < m) return -1;

    while(k <= n - m){
        for(x = m - 1; x >= 0; x--){
            if(P[x] != T[k + x]) break;
        }
        if(x < 0) return k;
        for(y = x; y >= 0; y--){
            if(P[y] == T[k + x]) break;
        }
        k += x - y;
    };
    return -1;
}

int main()
{
    string T, P; cin >> T >> P;
    int start = 0;

    while(1){
        start = solve(T, P, start);
        if(start < 0) break;
        cout << start << endl;
        start++;
    };
    return 0;
}

Measured memory_bytes: 1196
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define fileopen(filename) if (fopen(filename".INP", "r")) {freopen(filename".INP", "r", stdin);freopen(filename".OUT", "w", stdout);}
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define rep(i,n) for (int i=1;i<=n;++i)
#define eb emplace_back
#define pb push_back
#define memset(a,i) memset(a,i,sizeof(a))
#define upper(v,a) upper_bound(v.begin(), v.end(), a)
#define lower(v,a) lower_bound(v.begin(), v.end(), a)
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define gcd __gcd
const int maxn=1e5+3;
const int INF=1e9+1;
bool dp[2005][maxn];

signed main()
{
    fastio;
    int n;cin>>n;dp[0][0]=1;
    int a[n+1],pre[n+1];pre[0]=0;
    rep(i,n)
    {
    	cin>>a[i];
    	pre[i]=pre[i-1]+a[i];
    }
    rep(i,n)for (int j=0;j<=1e5;++j)
    	if (!dp[i][j])
    	{
    		if (j+a[i]<=1e5)dp[i][j]=dp[i-1][j+a[i]] | dp[i-1][abs(j-a[i])];
    		else dp[i][j]=dp[i-1][abs(j-a[i])];
    	}
    for (int i=0;i<=1e5;++i)if (dp[n][i]){cout<<(pre[n]+i)/2;return 0;}
}


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

#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define MAXX 100005

#define PI 3.14159265358979323846264338327950

#define ll signed long long int
int main()
{
	int b=0,f=0,k=0,l;
	string a;
	char n='0',s='1',z;
	cin>>a;
	l=a.size();
	while (l>b)
	{
		if (a[b]==n)
		f++;
		else
		k++;
		b++;
		z=s;
		s=n;
		n=z;
	}
	if (f<=k) 
	cout<<f;
	else
	cout<<k;
}

Measured memory_bytes: 512
#include <iostream> 
#include <string> 
 
int main(){
  std::string sent;
  int gyou,num=0;
  std::cin >> gyou;
  getline(std::cin, sent);
  for(int i=0;i<gyou;++i){
    num=0;
    getline(std::cin, sent);
    std::string bef="Hoshino",aft="Hoshina";
    while(num!=-1){
      num=(int)(sent.find(bef));
      if(num!=-1){
      sent.replace(num,bef.size(),aft);
      }
    }
    std::cout << sent << std::endl;
  }
  return 0; 
}


Measured memory_bytes: 3144
#include <stdio.h>
#include <string.h>
int main()
{
    int a, b;
    char op;
    while (1) {
        scanf("%d %s %d", &a, &op, &b);
        if (op == '?') {
            break;
        } else if (op == '+') {
            printf("%d\n", a + b);
        } else if (op == '-') {
            printf("%d\n", a - b);
        } else if (op == '*') {
            printf("%d\n", a * b);
        } else if (op == '/') {
            printf("%d\n", a / b);
        }
    }

    return 0;
}

Measured memory_bytes: 1032
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
# define mod 1000000007
# define INF (1 << 29)
# define MAX_N 1000010
/* ACはうれCすぎてうれD */

int main(void){ 
    int n;
    cin >> n;
    double t, a;
    cin >> t >> a;
    vector<double> H;
    for(int i=0; i<n; i++){
        double tmp_h;
        cin >> tmp_h;
        H.push_back(tmp_h);
    }

    int ans;
    double min = 1000000000.0;
    for(int i=0; i<n; i++){
        double temp = t - H[i]*0.006;
        double tmp_min = fabs(a - temp);
        if(tmp_min < min){
            min = tmp_min;
            ans = i+1;
        }
    }
    cout << ans;
    return 0;
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
void sort2array(double *a,long *b,long n){
    for(int i=0;i<n;i++){
        b[i]=i;
    }
    sort(b,b+n,[a](long i,long j)->bool {return a[i]<a[j];} );
}
//bを何回足せばaを超えるか
int wtover(int a,int b){
    if(a%b>0)return (a/b)+1;
    else return a/b;
}
const int INF=100000001,ID_MAX=20;
int bi_e[ID_MAX]={0};
//2進数表示したときの最高桁
int bi_max(long n){
    int m=0;
    for(m;pow(2,m)<=n;m++);m=m-1;
    return m;
}
//bi_eに二進数表示したやつを代入
void bi_exs(long n){
    rep(i,ID_MAX){
        bi_e[i]=0;
    }
    if(n<pow(2,ID_MAX)){
        int m=bi_max(n);
        long l;
        for(m;m>-1;m--){
            l=pow(2,m);
            bi_e[m]=n/l;
            n=n%l;
        }
    }
}
//x^n mod m (nが負の時は０)
long myPow(long x, long n, long m){
  if(n<0)return 0;
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}


int main(){
    int i;
    //入力
    int n;
    cin>>n;
    vector<string> s;
    string b;
    for(int i=0;i<n;i++){
        cin>>b;
        s.push_back(b);
    }
    //処理
    sort(s.begin(),s.end());
    int cou=0;
    string a;
    rep(i,n){
        if(a!=s[i]){
            cou++;
            a=s[i];
        }
    }
    //出力
    cout<<cou<<endl;
}

Measured memory_bytes: 11664
#include <cstdio>

#define min(a,b) ((a<b)?a:b)

int n,k;
int x,y,t;

main(){
  scanf("%d%d", &n, &k);

  while(k--){
    scanf("%d%d", &x, &y);
    
    x = min(x,n-x+1);
    y = min(y,n-y+1);
    t = min(x,y)%3;

    printf("%d\n",(t==0)?3:t);
  }
}

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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

const long long mod = 998244353;

void milkshake() {
  int n, k;
  cin >> n >> k;
  vector<int> l(k), r(k);
  for(int i = 0; i < k; i++) {
    cin >> l[i] >> r[i];
  }
  vector<long long> dp(n+1);
  vector<long long> dps(n+1);
  dp[1] = dps[1] = 1;
  for(int i = 2; i <= n; i++) {
    for(int j = 0; j < k; j++) {
      int li = i - r[j];
      li = max(li, 1);
      int ri = i - l[j];
      if(ri < 1) continue;
      dp[i] = (dp[i] + dps[ri] - dps[li-1]) % mod;
    }
    dps[i] = (dps[i-1] + dp[i]) % mod;
  }
  cout << (dp[n] + mod) % mod << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) milkshake();

  return 0;
}


Measured memory_bytes: 6336
#include<map>
#include<cmath>
#include<stack>
#include<cstdio>
#include<queue>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n,minx=1ll<<32ll;
ll work(ll x,ll y){
    int s=0,c=0;
    while(x){
        x/=10;
        s++;
    }
    while(y){
        y/=10;
        c++;
    }
    return max(s,c);
}
int main(){
	scanf("%lld",&n);
	for(ll i=1;i*i<=n;i++){
        if(n%i==0)minx=min(minx,work(i,n/i));
	}
	printf("%lld\n",minx);
	return 0;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut aseq = vec![0; n];
    let mut zero_pos = 0;
    for i in 0..n {
        aseq[i] = read::<usize>() - 1;
        if aseq[i] == 0 {
            zero_pos = i;
        }
    }
    let left_cnt = (zero_pos + k - 2) / (k - 1);
    let left_rest = left_cnt * (k - 1) - zero_pos;
    let right_cnt = if left_rest > n - zero_pos - 1 {
        0
    } else {
        (n - zero_pos - 1 - left_rest + k - 2) / (k - 1)
    };
    let ans = left_cnt + right_cnt;
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
#define FOR(I,A,B) for(int I=int(A);I<int(B);++I)


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int h,w;
	while(cin>>h>>w,h+w){
		FOR(i,0,h){
			FOR(j,0,w){
				bool x = i==0||(i==h-1)||j==0||j==(w-1);
				cout << (x?'#':'.');
			}
			cout << '\n';
		}
		cout << '\n';
	}
}



Measured memory_bytes: 3120
/*JAI SHREE RAM
HAR HAR MAHADEV*/
 
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef stack<ll> sll;
typedef queue<ll> qll;
typedef vector<ll> vll;
typedef vector<char> vc;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef pair<ll, pll> ppll;
typedef vector<vector<ll>> vvll;
typedef priority_queue<ll> pqll;
 

#define mod 1000000007
#define pb push_back
#define mp make_pair
#define pob pop_back
#define beg begin
#define gcd __gcd
#define bs binary_search
#define lbd lower_bound
#define ubd upper_bound
#define npr next_permutation
#define ppr prev_permutation
#define bp __builtin_popcountll
#define ff first
#define ss second
#define pi 3.1415926535
#define TEST unsigned long long T; cin>>T; while(T--)
 
const char nl='\n';
const ll MAX=INT_MAX;
const ll MIN=INT_MIN;

bool sortbysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 

void solve()
{
    string a;int n;
    cin>>a;
    n=a.length();
    if(a[n-1]=='s')
    cout<<a<<"es";
    else
    cout<<a<<"s";
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<fixed<<setprecision(20);
    #ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);    
    #endif
    //cout<<fixed<<setprecision(20);
   //TEST
    solve();
    
return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int a, b, c; cin >> a >> b >> c;
	int ans = 0;
	FOR(i, a, b + 1) {
		if (c % i == 0) ++ans;
	}
	cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
}



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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define RALL(a)     (a).rbegin(),(a).rend()
#define PRINT(a)   cout << (a) << endl

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second

#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;

template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

int main(){
  ll x,k,d;
  cin >> x >> k >> d;
  if(x<0)x = -x;

  if(x<=d){
    if(k%2==0){
      cout << x << endl;
    }else{
      cout << d-x << endl;
    }
  }else{
    ll t = min((x/d),k);
    x -= t * d;
    k -= t;
    if(k>0){
      if(k%2==0){
        cout << x << endl;
      }else{
        cout << d-x << endl;
      }
    }else{
      cout << x << endl;
    }

  }
}



Measured memory_bytes: 3648
A,B = map(int,input().split())
c = [0 for _ in range(1+max(A,B))]

ans = 1
#AとBで割り切れるような自然数を求める
# 2 <= ans <= A*B
def prime(n):
	res = [0 for _ in range(n+1)]
	for i in range(2,int(n**0.5)+1):
		while n%i == 0:
			res[i] += 1
			n = n//i
	if n != 1:
		res[n] = 1
	return res
a = prime(A)
b = prime(B)
for i in range(1+max(A,B)):
	if len(a)<=i:
		c[i] = b[i]
	elif len(b)<=i:
		c[i] = a[i]
	else:
		c[i] = max(a[i],b[i])


for i in range(1,len(c)):
	ans *= i**c[i]

print(ans)


Measured memory_bytes: 5528
a,b=map(int,input().split())
x=0;md=0;min=4000
if a+2022<b:
    b=a+2022

for i in range(a,b,1):
    for j in range(a+1,b+1,1):
        x = i * j
        md = x % 2019
        if md < min:
            min = md


print(min)









Measured memory_bytes: 2940
import sys
input = sys.stdin.readline
def main():
  n = int(input())
  A = tuple(map(int, input().split()))
  U = 10**6
  D = list(range(U+1))
  i = 2
  while i*i <= U:
    if D[i] != i:
      i += 1
      continue
    for j in range(i*i, U+1, i):
      D[j] = min(D[j], i)
    i += 1
  C = [0]*(U+1)
  is_pairwise = True
  for a in A:
    while a > 1:
      d = D[a]
      while a%d == 0:
        a //= d
      if C[d]:
        is_pairwise = False
      C[d] += 1
  if max(C) == n:
    print("not coprime")
  else:
    if is_pairwise:
      print("pairwise coprime")
    else:
      print("setwise coprime")
if __name__ == "__main__":
  main()

Measured memory_bytes: 125888
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <queue>
#include <stack>
#include <algorithm>
#include <tuple>
#include <numeric>
#include <type_traits>
#include <limits>

/**
 * すべての約数を求める。
 *
 * @param x 約数を求めたい数
 * @return x の約数を小さい順に並べた vector
 * @note 1 や x 自身も返り値に含まれる。
 * @note 時間計算量は O(sqrt(x))
 */
template<typename T>
std::vector<T> get_all_divisors(T x)
{
	std::vector<T> result;

	if (x == 0)
		return result;

	T n;
	for (n = 1; n*n < x; ++n) {
		if (x % n == 0)
			result.push_back(n);
	}
	auto sz = result.size();
	if (n*n == x)
		result.push_back(n);
	for (auto i = sz - 1; i > 0; --i)
		result.push_back(x / result[i]);
	result.push_back(x);
	return result;
}

int main()
{
	long N, K;
	std::vector<long> A;

	std::cin >> N >> K;
	A.resize(N);
	for (auto& a : A)
		std::cin >> a;

	long sum = 0;
	for (auto a : A)
		sum += a;

	auto divisors = get_all_divisors(sum);
	std::reverse(divisors.begin(), divisors.end());
	for (auto d : divisors) {
		std::vector<long> R;
		R.resize(A.size());
		for (int i = 0; i < A.size(); ++i)
			R[i] = A[i] % d;
		sort(R.begin(), R.end());
		long adds = 0;
		long subs = 0;
		for (int i = 0; i < N; ++i)
			adds += d - R[i];
		int i = 0;
		do {
			if ((adds - subs) % d == 0 && std::max(adds, subs) <= K) {
				std::cout << d << "\n";
				return 0;
			}
			if (i < N) {
				adds -= d - R[i];
				subs += R[i];
			}
		} while (++i <= N);
	}
	std::cout << "1\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
    int n;
    string s;
    while(cin>>n>>s)
    {
        int x=0;
        int mx=x;
        for(int i=0;i<(int)s.size();i++)
        {
            if(s[i]=='I')x++;
            else x--;
            mx=max(mx,x);
        }
        pf("%d\n",mx);
    }
    return 0;
}
 









 




























Measured memory_bytes: 256
X = int(input())

for a in range(1000):
    for b in range(1000):
        if a ** 5 - b ** 5 == X:
            print(f"{a} {b}")
            exit()
        elif (-a) ** 5 - b ** 5 == X:
            print(f"{-a} {b}")
            exit()
        elif a ** 5 - (-b) ** 5 == X:
            print(f"{a} {-b}")
            exit()
        elif (-a) ** 5 - (-b) ** 5 == X:
            print(f"{-a} {-b}")
            exit()
        

Measured memory_bytes: 9100
#include<iostream>
#include<queue>
#include<string>
#include<map>
using namespace std;

class Puzzle{
public:
    string p;
    int n;

    int zero(){
        for(int i=0;i<8;i++)
            if(p[i]=='0')
                return i;
        return -1;
    }

    void swapup(){
        int iz=zero();
        if(4<=iz&&iz<=7){
            swap(p[iz],p[iz-4]);
        }
    }
    void swapdown(){
        int iz=zero();
        if(0<=iz&&iz<=3){
            swap(p[iz],p[iz+4]);
        }
    }
    void swapleft(){
        int iz=zero();
        if(iz!=0&&iz!=4){
            swap(p[iz],p[iz-1]);
        }
    }
    void swapright(){
        int iz=zero();
        if(iz!=3&&iz!=7){
            swap(p[iz],p[iz+1]);
        }
    }
};

int main(){
    queue<Puzzle> que;
    map<string,int> m;
    Puzzle c;
    c.p="01234567";
    c.n=0;
    que.push(c);
    m[c.p]=c.n;
    while(!que.empty()){
        c=que.front();
        que.pop();
        Puzzle nextup=c;
        nextup.swapup();
        nextup.n++;
        if(m.find(nextup.p)==m.end()){
            que.push(nextup);
            m[nextup.p]=nextup.n;
        }
        Puzzle nextdown=c;
        nextdown.swapdown();
        nextdown.n++;
        if(m.find(nextdown.p)==m.end()){
            que.push(nextdown);
            m[nextdown.p]=nextdown.n;
        }
        Puzzle nextleft=c;
        nextleft.swapleft();
        nextleft.n++;
        if(m.find(nextleft.p)==m.end()){
            que.push(nextleft);
            m[nextleft.p]=nextleft.n;
        }
        Puzzle nextright=c;
        nextright.swapright();
        nextright.n++;
        if(m.find(nextright.p)==m.end()){
            que.push(nextright);
            m[nextright.p]=nextright.n;
        }
    }

    while(true){
        string q;
        cin>>q;
        if(cin.eof())
            break;
        for(int i=0;i<7;i++){
            string a;
            cin>>a;
            q=q+a;
        }
        cout<<m[q]<<endl;
    }
    return 0;
}



Measured memory_bytes: 5420
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) {rep(a,x.size()) cout << x[a] << " "; cout << endl;}
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 2e5;

int main() {
    int n; cin >> n;
    string s, t; cin >> s >> t;
    int len = 0;
    rep(i,n) {
        if (s.substr(i) == t.substr(0,n-i)) {
            len = n-i;
            break;
        }
    }
    cout << 2*n-len << endl;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define why(n,x) int n;while(cin >>n,n!=x)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define unless(flg) if ( !(flg) )
#define read cin<<
#define echo cout<<
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define SWAP(a,b) ((a != b) && (a += b,b = a - b,a -= b))
#define cinf(n,x) for(int UNCH=0;UNCH<(n);UNCH++) cin >> x[UNCH];
#define fcin(n,x) for(int UNCH=1;UNCH<=(n);UNCH++) cin>> x[UNCH];
#define memmin(x) memset((x),-1,sizeof((x)))
#define memzer(x) memset((x), 0,sizeof((x)))
#define meminf(x) memset((x),0x3f,sizeof((x)))
//#define int long long
typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
typedef map < string , int > mstit;
typedef vector < pii > vpi ;
typedef greater < pii > gpi;
typedef priority_queue < pii , vpi , gpi > dijk ;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve(){

  int n,b[105],c[105];
  bool hoge = true;
  cin >> n;
  iFOR(i,1,n+1){
    cin >> b[i];
  }
  int x=0;
  for(int i= n;i > 0 ;i--){
    
    if(b[i]==i){
      c[x++]=b[i];
      for(int j=i;j<n;j++){
        b[j]=b[j+1];
      }
      i=n-x+1;
    }
  }
  if(x!=n) cout << -1 fin;
  else{
    for(int i = n-1;i>= 0 ; i--)
      cout << c[i] fin;
  }
}
struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}


Measured memory_bytes: 256
import java.util.*;

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

        System.out.println("ABC" + n);
    }

    public static void printArray(int[] array){
        for(int i=0; i<array.length; i++){
            if(i == array.length){
                System.out.println(array[i]);
            } else {
                System.out.print(String.format("%d ", array[i]));
            }
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

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;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

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

//末桁の1~5に注目するのは？
//5000000max
//1000回が限度

int main(){
    int X;
    int KK=1000;
    cin>>X;
    rep(i,KK){
        ll a=i*100;
        if(a>X)break;
        rep(j,KK){
            ll b=(j*101);
            if(a+b>X)break;
            rep(k,KK){
                ll c=(k*102);
                if(a+b+c>X)break;
                rep(l,KK){
                    ll d=(l*103);
                    if(a+b+c+d>X)break;
                    rep(m,KK){//節約できそう
                        ll e=(m*104);
                        if(a+b+c+d+e>X)break;
                        ll O=X-(a+b+c+d+e);
                        if(O%105==0){
                            //cout<<i<<endl<<j<<endl<<k<<endl<<l<<endl<<m<<endl<<a<<endl<<a+b+c+d+e<<endl;
                            //if(i*100+j*101+k*102+l*103+m*104==a+b+c+d+e)cout<<"AWAW"<<endl;
                            cout<<1<<endl;
                            return 0;
                        }
                    }
                }
            }
        }
    }
    cout<<0<<endl;

    return 0;
}

//a=97,z=122

Measured memory_bytes: 256
//C++ template-------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//define-------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++) //指定回数ループマクロ
#define reps(i, n) for (int i = 1; i < (int)(n); i++) //1-origin
#define rrep(i, n) for (int i = ((int)(n)-1); i>=0; i--) //逆順
#define rreps(i, n) for (int i= ((int)(n)); i>0; i--) //逆順1-origin
#define all(x) (x).begin(), (x).end() //先頭と末尾のイテレータを渡す
#define sz(x) ((int)(x).size()) //size()のunsignedを回避
#define pb push_back
#define mp make_pair
#define m0(x) memset(x,0,sizeof(x)) //すべて0で塗り替え
#define m1(x) memset(x,63,sizeof(x)) //すべて１で塗り替え
#define fill(x,y) memset(x,y,sizeof(x)) //すべてyで置き換え
/* #define clr(ar,val) memset(ar, val, sizeof(ar)) //よくわからんので保留*/
#define ZERO(a) memset(a,0,sizeof(a)) //すべて0に置き換え
#define MINUS(a) memset(a,0xff,sizeof(a)) //すべて-で置き換え
#define MEMSET(v, h) memset((v), h, sizeof(v)) //すべて置き換える場合のmemsetの省略
#define sqrt(x) sqrt(abs(x)) //sqrtの絶対値の記入の省略
//typedef------------------------------------------------------
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<string> vs;
//const--------------------------------------------------------
const ll MOD = 1000000007;
const int INF = 1061109567;
const double PI = acos(-1.0); //3.141592....
int dx[4] = {1,0,-1,0};
int dy[4] = {0,1,0,-1};
//main---------------------------------------------------------
int main() {
    int n;
    ll a[200010];
    cin >> n; //入力
    ll fronTall = 0;
    ll sum = 0;
    rep(i, n) { 
        cin >> a[i]; //n数の入力
        if (fronTall > a[i]) {
            sum = sum + fronTall - a[i];
        }else {
            fronTall = a[i];
        }
    }
    cout << sum << endl; //出力
    return 0; //終了
}

Measured memory_bytes: 5156
#include <iostream>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 100100
//#define NIL -1

int main() {
    LL a;
    LL b;
    cin >> a >> b;
    if(a<=b){
        cout << a << endl;
    }else{
        cout << a-1 << endl;
    }

    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
 
#define pb push_back
// #define mp make_pair
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define hell1 1000000007
#define hell2 1000000009
#define pi 3.1415926535
#define ms(s, n) memset(s, n, sizeof(s))
#define prec(n) fixed<<setprecision(n)
#define eps 0.000001
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define ll unsigned long long
#define ld long double 
#define no_of_digits(n) floor(log10(n)) + 1
#define see(x) cerr << (#x) << " is " << (x) << endl
#define INF 1e13
#define LL_MAX 1e18
// memset(array, -1, sizeof(array[0][0]) * row * count)
using namespace std;
 
ll mult(ll a,ll b, ll p=hell1){   return ((a%p)*(b%p))%p; }
ll multbig(ll a,ll b,ll mod=hell1){   if(a==0 or b==0) return 0;if(a==1 or b==1) return (a*b)%mod;ll cur=multbig(a,b/2,mod);cur=(2*cur)%mod;if(b%2) cur=(cur+a)%mod;return cur;}
ll add(ll a, ll b, ll p=hell1){ if(a>=p) a%=p; if(b>=p) b%=p; if(a+b>p) return (a + b)%p; else return a+b;}
ll sub(ll a, ll b, ll p=hell1){return (a%p - b%p + p)%p;}
ll fpow(ll n, ll k, ll p = hell1) {ll r = 1; for (; k; k >>= 1) {if (k & 1) r = mult(r,n,p); n = mult(n,n,p);} return r;}
ll inv(ll a, ll p = hell1) {return fpow(a, p - 2, p);}
ll inv_euclid(ll a, ll m = hell1){ll m0 = m;ll y = 0, x = 1;if (m == 1)return 0;while (a > 1){ll q = a / m;ll t = m;m = a % m, a = t;t = y;y = x - q * y;x = t;}if (x < 0)x += m0;return x;}
int isPowerof2(ll x) { return (x && !(x & x-1)); } 
ll log2(ll x) { ll res = 0; while (x >>= 1) res++; return res; } 
bool isPerfectSquare(long double x) {long double sr = sqrt(x); return ((sr - floor(sr)) == 0); }
bool check(ll i,ll j,ll n){return (i>=0 && i<n && j>=0 &&  j<n);} //matrix boundary checking
 
 
ll ceil(const ll &a, const ll &b){return (a - 1)/b + 1;}
 
// max({a, b, c, d})
// cout << fixed for removing e notation
 
bool comp(pair<ll, ll>a, pair<ll, ll>b)
{
    if(a.se*b.fi + b.se > b.se*a.fi + a.se) return true;
    else return false;
}
 
void convert(int arr[], int n) 
{ 
    int temp[n+1];
    for(int i=1;i<=n;i++)
        temp[i] = arr[i]; 
    // memcpy(temp, arr, n*sizeof(int)); 
  
    sort(temp+1, temp+n+1);   
    unordered_map<int, int> umap;
    int val = 1; 
    for (int i = 1; i <= n; i++) 
        umap[temp[i]] = val++;
    for (int i = 1; i <= n; i++) 
        arr[i] = umap[arr[i]]; 
}
 
bool prime[10000005];
void SieveOfEratosthenes(int n) 
{
    memset(prime, true, sizeof(prime)); 
    prime[0] = prime[1] = 0;
    for (int p=2; p*p<=n; p++) 
    {
        if (prime[p] == true) 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
    }
}

int foo(int a, int b, int c)
{
    return (abs(a-b) + abs(b-c) + abs(a-c));
}


ll getFirstSetBitPos(ll n) 
{ 
    return log2(n & -n) + 1; 
} 

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

    string s;
    cin >> s;

    vector<char>temp;

    temp.pb(s[0]);

    ll ans = 1;

    for(int i=1;i<s.size();i++)
    {
        if(s[i] == temp[0]){}
        else
        {
            temp.clear();
            temp.pb(s[i]);
            ans++;
        }
    }

    cout << ans << "\n";
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  double N, T, A;
  cin >> N >> T >> A;

  vector<double> H(N);
  REP(i, N) cin >> H[i];

  double MIN = INF;
  REP(i, N){
    chmin(MIN, abs(A-(T-H[i]*0.006)));
  }

  REP(i, N){
    if(abs(A-(T-H[i]*0.006)) == MIN){
      cout << i+1 << "\n";
      return 0;
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //  repマクロ
#define leng(n) (int)(log10(n)+1)  //  桁数
using namespace std;

signed main() {
  int A, B;
  cin >> A >> B;
  if (A >= 13) cout << B << endl;
  else if (A >= 6 && A <= 12) cout << B / 2 << endl;
  else cout << 0 << endl;
}

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

//gcdやり直す

void swap (int *x, int *y) {
  int temp;    

  temp = *x;
  *x = *y;
  *y = temp;
}




/***
* pivotを決め、
* 全データをpivotを境目に振り分け、
* pivotの添え字を返す
***/
int partition (int array[], int left, int right) {
  int i, j, pivot;
  i = left;
  j = right + 1;
  pivot = left;   // 先頭要素をpivotとする

  do {
    do { i++; } while (array[i] < array[pivot]);
    do { j--; } while (array[pivot] < array[j]);
    // pivotより小さいものを左へ、大きいものを右へ
    if (i < j) { swap(&array[i], &array[j]); }
  } while (i < j);

  swap(&array[pivot], &array[j]);   //pivotを更新

  return j;
}

/* クイックソート */
void quick_sort (int array[], int left, int right) {
  int pivot;

  if (left < right) {
    pivot = partition(array, left, right);
    quick_sort(array, left, pivot-1);   // pivotを境に再帰的にクイックソート
    quick_sort(array, pivot+1, right);
  }
}




/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);
  int ans=0;
  for(int i=3;i<=n;i++){
    int div=1;
    int now=i;
    for(int j=2;j*j<=i;j++){
      int count=1;
      while(now%j==0){
        count++;
        now/=j;
      }
      div*=count;
    }
    //
    //N=*...*p^1
    if(now!=1){
      div*=2;
    }
    //

    if(div==8 && i%2==1){
      ans++;
    }
  }
  printf("%d\n",ans);
}

Measured memory_bytes: 1724
#include <stdio.h>
 
int main(void) {
int N;
int count=0;
int i;
scanf("%d", &N);
int H[N], m=0;
 
for(i=0;i<N;i++){
	scanf("%lld",&H[i]);
}


for(i=0;i<N-1;i++){

if(i>1 && m!=0 && m-H[i]>=2){
 	count=2;
 }
 
	if(H[i]-H[i+1]>1){
			//printf("No");
			count=1;
			break;
			return 0;
	}
	if(H[i]-H[i+1]==1){
		if(m-H[i]<0){	
			m=H[i];
		}
		if(H[i-1]-H[i]==1){
				count=1;
				
			}
	}
}
if(count==0){
	printf("Yes");
}else{
	printf("No");
}

return 0;
 
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<double> A(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> A[i];
	}

	double result = 0;
	for (auto i = 0; i < N; ++i)
	{
		result += 1.0 / A[i];
	}


	cout << fixed << setprecision(10) << 1.0 / result << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int k;
    cin>>k;
    vector<ll> a;
    for(int i=1;i<=9;i++){
        a.push_back(i);
    }
    while(1){
        if(k <= a.size()){
            cout<<a[k-1]<<endl;
            return 0;
        }
        k-=a.size();
       // cout<<k<<endl;
        vector<ll> old;
        swap(old,a);
        for(ll x : old){
            for(int i=-1;i<=1;i++){
                int d=x%10+i;
                if(d<0||d>9) continue;
                ll nx=x*10+d;
                a.push_back(nx);
            }
        }
    }
}

Measured memory_bytes: 1712
#include <iostream>
#include <vector>
int main() {
    int n;
    std::vector<int> v;
    std::cin >> n; //skip
    while (std::cin >> n) {
        v.push_back(n);
    }
    for (auto&& e = v.crbegin(); e != v.crend(); ++e) {
        std::cout << ((e == v.crbegin()) ? "" : " ") << *e;
    }
    std::cout << std::endl;
}



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

int main() {
  int a[10], v1, v2;
  while (~scanf("%d", &a[0])) {
    int dis = a[0];
    for (int i = 1; i < 10; i++) {
      scanf(",%d", &a[i]);
      dis += a[i];
    }
    scanf(",%d,%d", &v1, &v2);
    double t = (double)dis / (v1 + v2);
    double p = v1 * t;
    double sum = 0.0;
    for (int i = 0; i < 10; i++) {
      sum += a[i];
      if (p <= sum) {
        printf("%d\n", i + 1);
        break;
      }
    }
  }
}


Measured memory_bytes: 3200
#include <iostream>


bool comp(const std::pair<int, int>& firstElem, const std::pair<int, int>& secondElem) {
  return firstElem.second > secondElem.second;
}


void swap(std::pair<int, int> *array, int i) {
  std::pair<int, int> temp = std::make_pair(array[i].first, array[i].second);
  array[i] = std::make_pair(array[i + 1].first, array[i + 1].second);
  array[i + 1] = temp;
}


void sort(std::pair<int, int> *array, int size) {
  for (int i = size - 1; i >= 0; i --) {
    bool flag = false;
    for (int j = 0; j < i; j ++) {
      if (array[j].second < array[j + 1].second) {
        swap(array, j);
        flag = true;
      }
    }
    //if (flag == true) break;
  }
}

int main() {
  int n, m;
  int temp;
  while(1) {
    std::cin >> n >> m;
    if (n == 0 && m == 0) break;
    std::pair<int, int> sums[100]; 

    for (int j = 0; j < m; j ++)
      sums[j].first = j + 1;

    for (int i = 0; i < n; i ++) for (int j = 0; j < m; j ++) {
        std::cin >> temp;
        sums[j].second += temp;
    }

    // std::sort(std::begin(sums), std::end(sums), comp);
    sort(sums, m);

    int k = 0;
    while (1) {
      std::cout << sums[k ++].first;
      //std::cout << sums[k - 1].second;
      if (k != m) std::cout << " ";
      else break;
    }
    std::cout << std::endl;
  }
  return 0;
}

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

int main()
{
    int n, out;
    cin >> n;
    int cnt=0, k=n;
    while (k!=0){
        cnt+=k%10;
        k /= 10;
    }
    if (n%cnt==0){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define prin(arg) cout<<arg<<"\n"
#define prin2(arg1,arg2) cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;
const int INF=1e+9;
const ll INFLL=1e+17;
int main(){
  int n;
  cin>>n;
  if(n==1){
    prin(1);
  }
  else if(n<4){
    prin(2);
  }
  else if(n<8){
    prin(4);
  }
  else if(n<16){
    prin(8);
  }
  else if(n<32){
    prin(16);
  }
  else if(n<64){  
    prin(32);
  }
  else{
    prin(64);
  }
  
  
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate

N, *S = map(int, open(0).read().split())

ans = 0
for dx in range(1, N - 1):

    k, r = divmod(N - 1, dx)
    if r == 0:
        k = (k + 1) // 2

    ans = max(ans, max(accumulate(a + b for a, b in zip(S[:dx * k:dx], S[N - 1:(N - 1) - dx * k:-dx]))))

print(ans)

Measured memory_bytes: 14468
N, M = map(int, input().strip().split(" "))


p = []
s = []
ans = [0]*N
c_wa = [0]*N
pena = 0

for i in range(M):
    temp1, temp2 = input().strip().split(" ")
    p.append(int(temp1))
    s.append(str(temp2))
  

for j in range(M):
    
    if s[j] == "WA":
        if ans[p[j]-1] == 0:
            c_wa[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
                
            
    elif s[j] == "AC":
        if ans[p[j]-1] == 0:
            ans[p[j]-1] += 1
        elif ans[p[j]-1] == 1:
            pass
        
for k in range(N):
    if ans[k] == 1:
        pena += c_wa[k]
    

            
print(sum(ans), pena)

Measured memory_bytes: 15320