akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
#define IOS cin.tie(0),ios::sync_with_stdio(false)
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
template<class Type>struct is_vector : std::false_type {};
template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T> inline ostream& operator << (ostream& out, const vector<T>& v) {
	if (v.empty())return out;
	constexpr bool is_vector_v = is_vector<T>::value;
	if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
	else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
	return out;
}
inline void put() {}
template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
inline void putn() {}
template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }


int main() {
	IOS;
	int n; 
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	REP(i, n) {
		cin >> s[i] >> t[i];
	}
	string x;
	cin >> x;
	bool flag = false;
	int res = 0;
	REP(i, n) {
		if (flag) {
			res += t[i];
		}
		if (s[i] == x) {
			flag = true;
		}
	}
	put(res);
	return 0;
}


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

using namespace std;

int main() {
	int N = 0, K = 0;
	cin >> N >> K;
	vector<int> l(N);

	for (int i = 0; i < N; ++i) {
		cin >> l[i];
	}

	sort(l.begin(), l.end(),greater<int>());
	int ans = 0;
	for (int i = 0; i < K; ++i) {
		ans += l.at(i);
	}
	
	cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    ll N;
    cin >> N;
    vecll A(N);
    for(auto& i : A) cin >> i;

    ll ans = 0;
    for(auto& i : A){
        for(auto& j :A){
            ll dif = i - j;
            if(dif < 0) dif *= -1;
            if(dif > ans) ans = dif;
        }
    }
    cout << ans << endl;
}

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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	bool ok = false;
	rep(i,100){
		int wa = 0;
		wa += 1*i*a;
		if(wa%b == c) {
			ok = true;
			break;
		}
	}
	if(ok) cout << "YES" << endl;
	else cout << "NO" << endl;
}

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

const int MOD = 998244353;
int N, S, a[3001], d[3001][3001], s[3001];

int main() {
    scanf("%d%d", &N, &S);

    for (int i=1;i<=N;++i) scanf("%d", &a[i]);
    for (int i=1;i<=N;++i) d[i][a[i]] = i;

    for (int i=1;i<=N;++i) {
        for (int j=a[i];j<=S;++j) d[i][j] = (d[i][j] + s[j-a[i]]) % MOD;
        for (int j=0;j<=S;++j) s[j] = (s[j] + d[i][j]) % MOD;
    }
    long long ans = 0;
    for (int i=1;i<=N;++i) {
        ans += 1LL * d[i][S] * (N-i+1);
        ans %= MOD;
    }

    printf("%lld", ans);


}

Measured memory_bytes: 35456
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn func(b: u64, n: u64) -> u64 {
    if n < b {
        return n;
    }
    func(b, n / b) + n % b
}

fn solve() {
    let n: u64 = read();
    let s: u64 = read();
    if s > n {
        println!("-1");
        return;
    }
    if s == n {
        println!("{}", n + 1);
        return;
    }
    for b in 2..((n as f64).sqrt() as u64 + 1) {
        if func(b, n) == s {
            println!("{}", b);
            return;
        }
    }
    for p in (1..((n as f64).sqrt() as u64 + 1)).rev() {
        if (n - s) % p != 0 {
            continue;
        }
        let b = (n - s) / p + 1;
        if func(b, n) == s {
            println!("{}", b);
            return;
        }
    }
    println!("-1");
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(32 * 1024 * 1024) // 32 MBのスタックサイズ
        .spawn(|| {solve()})
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 8572
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int x = in.i();
        int[] a = in.ii(N);
        long ans = 0;
        for (int i = 1; i < N; i++) {
            int e = Math.max(0, a[i - 1] + a[i] - x);
            ans += e;
            a[i] = Math.max(0, a[i] - e);
        }
        out.println(ans);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36092
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c; cin>>a>>b>>c;
  int cnt = 0;
  for(int i = a; i <= b; i++)
  {
    if (c % i == 0) cnt ++;
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#include <vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 5005
#define MOD 1000003
#define INF 1000000000000000000
#define EPS 0.0000000001
#define CHAINS 18
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
vector<long long> S[MAX];
int P[MAX],C[MAX];
void process(int ind)
{
    int i=ind;
    do
    {
        i=P[i];
        S[ind].push_back(C[i]);
    }while(i!=ind);
    for(i=1;i<S[ind].size();i++)
    {
        S[ind][i]=S[ind][i]+S[ind][i-1];
    }
}
long long Value(int ind,int k)
{
    int n=S[ind].size();
    int i;
    long long d=k/n,r=k%n;
    long long sum=S[ind][n-1];
    long long ans=-INF;
    for(i=0;i<n&&i<k;i++)
    {
        ans=max(ans,S[ind][i]);
    }
    if(d==0||sum<0) return ans;
    long long rem=0;
    for(i=0;i<n&&i<r;i++)
    {
        rem=max(rem,S[ind][i]);
    }
    ans=max(ans,(d-1)*sum+ans);
    ans=max(ans,d*sum+rem);
    return ans;
}
int main()
{
    int n,i,k;
    scanf("%d %d",&n,&k);
    for(i=0;i<n;i++)
    {
        scanf("%d",&P[i]);
        P[i]--;
    }
    for(i=0;i<n;i++)
    {
        scanf("%d",&C[i]);
    }
    for(i=0;i<n;i++)
    {
        process(i);
    }
    long long ans=-INF;
    for(i=0;i<n;i++)
    {
        ans=max(ans,Value(i,k));
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 218948
#include <bits/stdc++.h>
//using
using intl = long long;
using itnl = long long;//typo用
using uintl = unsigned long long;
using itn = int;//typo用
using ld = long double;
using namespace std;

//関数マクロ
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a) - 1; i >= (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl

//定数マクロ
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>

//定数
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-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; }
//intl gcd(intl a, intl b){ if(!b)return a; return gcd(b, a % b); } //c++17からある
//intl lcm(intl a,intl b){ return a / gcd(a, b) * b; } //c++17からある

//自作テンプレート関数
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}//Yes,Noの出力を楽にするよう
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}//上の関数のYes,Noを任意の文字列でできるようにしたもの
intl fact(intl k){ intl a = 1; for(int i = 2; i <= k; i++){ a *= i; } return a; }//k!を求める関数,O(N)
intl digit10(intl a){ intl b = 0; do{ a /= 10; b++; }while(a); return b; }//aを10進数で表したときの桁数を求める関数,O(logN)



signed main(){
    cout << fixed << setprecision(10);
    intl n,k;
    cin >> n >> k;
    intl a[n];
    rep(i,n)cin >> a[i];
    for(intl i = k; i < n; i++){
        fp(a[i] > a[i - k]);
    }
    return 0;
}


Measured memory_bytes: 5200
#include<bits/stdc++.h>
using namespace std;
bool tri(int a, int b,int c)
{
    if(a+b>c&&a+c>b&&b+c>a) {return true;}
    else {return false;}
}
int arr[10000];
int main()
{
int n,a,b,c,c1=0;
set<int>s;
cin>>n;

for(int i=0;i<n;i++)
{
    cin>>arr[i];

}
if(n<=2){cout<<"0"<<endl; return 0;}
sort(arr,arr+n);
for(int i=0;i<n-2;i++)
{
    a=arr[i];
    for(int j=i+1;j<n-1;j++)
    {
        b=arr[j];
        if(a==b){continue;}
        for(int k=j+1;k<n;k++)
        {
            c=arr[k];
            if(c==a||c==b){continue;}
            if(tri(a,b,c)==true){

                    c1++;}

        }
    }
}
cout<<c1<<endl;

}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>
using namespace std;
int main() {
    vector<vector<char>> vec(3, vector<char>(3));
    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> vec[i][j];
        }
    }
    printf("%c%c%c\n", vec[0][0], vec[1][1], vec[2][2]);
}

Measured memory_bytes: 3632
using System;
using System.Linq;
class P
{
    static void Main()
    {
        string s = Console.ReadLine();
        int a = s.Count(x => x == 'a');
        int b = s.Count(x => x == 'b');
        int c = s.Count(x => x == 'c');
        Console.WriteLine(Math.Abs(a - b) <= 1 && Math.Abs(b - c) <= 1 && Math.Abs(c - a) <= 1 ? "YES" : "NO");
    }
}

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

int main (){
  int A,B,C,X;
  cin >> A >> B >> C >>X;
  
  int cnt =0;
  for(int i =0;i<=A;i++){
   for(int j=0;j<=B;j++){
     for(int k=0;k<=C;k++){
       if(500*i+100*j+50*k ==X)cnt++;
     }
   }
  }
  
  cout <<cnt<<endl;
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int MOD = 1000000007;

ll max(ll a, ll b){
    if (a > b) return a;
    else return b;
}

int num_divisor(int num){
    int res = 0;
    for(int i = 1; i * i <= num; i++){
        if (num % i == 0){
            res++;
            if(i * i != num) res++;
        }
    }
    return res;
}

ll solve(ll N, ll M){
    ll ans = 1;
    for(int i = 1; i * i <= M; i++){
        if (M % i != 0) continue;
        if (M / i >= N) ans = max(ans, i);
        if (i >= N)     ans = max(ans, M / i);
    }
    return ans;
}

int main(void){
    ll N, M; cin >> N >> M;
    cout << solve(N, M) << endl;
}


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

using namespace std;

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

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

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

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

int main() {
	double d;
	cin >> d;
	double d2 = 0.0;
	FOR(i, 1, 10)
		if (0.0 <= (d*d) - (double)(i*i) && (d*d) - (double)(i*i) < 1)
			d2 = 1.0+(double)i;
	printf("%.10lf\n", max(d*sqrt(2), d2));
}

Measured memory_bytes: 3268
def Sum_xxor(ans_tmp,A,tmp,ind_max):

    ans_ret = 0
    ans_x = ans_tmp

    for i in range(ind_max):
        if Ones[i] <= N-Ones[i]:
            ans_x += bits[i]*1
        else:
            ans_x += bits[i]*0

    for a in A:
        ans_ret += ans_x ^ a

    return ans_ret

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

Ones   = [0 for _ in range(41)]
bits  = [0 for _ in range(41)]

for i in range(41):
    if i == 0:
        bit = 1
    else:
        bit *= 2
    bits[i] = bit

    Ones_i = 0

    for a in A:
        if a & bit:
            Ones_i += 1

    Ones[i] = Ones_i

t,ans = bit, 0
ind = 41
ans_tmp = 0
ch = 0
while t:
    if ch == 0:
        if not(t & (K+1)):
            ans_tmp += 0
        else:
            ch = 1

            ind_max = ind - 1
            ans = max(ans, Sum_xxor(ans_tmp,A,Ones,ind_max))

            ans_tmp += t

    else:
        if t & (K+1):

            ind_max = ind - 1
            ans = max(ans, Sum_xxor(ans_tmp,A,Ones,ind_max))

            ans_tmp += t


    t  //= 2
    ind -= 1


print(ans)


Measured memory_bytes: 14620
/* C++標準ヘッダファイル */
/* 文字列ライブラリ */
#include <string>

/* コンテナライブラリ */
#include <array>
#include <vector>
#include <deque>
#include <list>
#include <forward_list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <queue>

/* アルゴリズムライブラリ */
#include <algorithm>

/* 数値演算ライブラリ */
#include <cmath>
#include <math.h>

/* 入出力ライブラリ */
#include <iostream>

/* std使用<-namespace */
using namespace std;

/* define */
#define rpt(i, n) for(ll i = 0; i < (n); i++)  // リピート
#define PI (acos(-1))  // 円周率pi

/* typedef */
// long long
typedef long long ll;

// pair
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
typedef pair<double, double> d_d;

/* main関数 */
int main(void) {
	ll n, k, q;
	cin >> n >> k >> q;
	vector<ll> a;
	a.reserve(n);
	rpt(i, q) {
		ll e;
		cin >> e;
		a.push_back(e);
	}
	ll reg[100000 + 1];
	rpt(i, 100000 + 1) reg[i] = 0;
	rpt(i, q) {
		reg[a[i]]++;
	}
	for (ll i = 1; i <= n; i++) {
		if (q - reg[i] >= k) cout << "No";
		else cout << "Yes";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define PI 3.14159265
int main()
{
   double a , b, x;
    cin>>a>>b>>x;
    double ans ;

    if( a*a*b <= 2*x)
      ans =double (atan( 2*(a*a*b - x) / (a*a*a) ) );
    else
    {
        ans = double( atan(  b*b*a / ( 2*x)    )    );

    }
   ans = ans *180/PI;
   printf("%.15lf" , ans);
}

Measured memory_bytes: 4076
#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
  #include "_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  int n; cin >> n;
  vector<int> d(n);
  for(int i = 0; i < n; i++){
    cin >> d[i];
  }

  int m; cin >> m;
  vector<int> t(m);
  for(int i = 0; i < m; i++){
    cin >> t[i];
  }

  multiset<int> st, st2;
  for(int i = 0; i < n; i++){
    st.insert(d[i]);
  }
  for(int i = 0; i < m; i++){
    st2.insert(t[i]);
  }

  for(auto p : st2){
    auto pos = st.find(p);
    if(pos == st.end()){
      cout << "NO" << endl;
      return 0;
    }
    st.erase(pos);
  }
  cout << "YES" << endl;

  return 0;
}

Measured memory_bytes: 25072
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            int N = in.nextInt();
            String S = in.next();
            int cnt = 0;
            for (int i = 0; i < N - 2; i++) {
                if ("ABC".equals(S.substring(i, i + 3))) {
                    cnt++;
                }
            }
            out.println(cnt);
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long mod2 = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
const string abc = "abcdefghijklmnopqrstuvwxyz";
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;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N;
  long long x;
  cin >> N >> x;
  vector<long long> a(N);
  for (int i = 0; i < N; i++)
  {
    cin >> a.at(i);
  }
  
  sort(a.begin(), a.end());
  int ans = 0;
  long long sum = 0;
  for (int i = 0; i < N; i++)
  {
    sum += a.at(i);
    if (x < sum) break;
    ans++;
  }
  if (ans == N && sum != x) ans--;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
/**
 *	author:   fractal
 *	timus:    288481RF
 *	created: 08/15/20 19:49:18
**/

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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define szc(x) (int)strlen(x)
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound 
 
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 3e3 + 2;
const int M = 1e5;
const int mod = 998244353;
const int inf = 2e9 + 3;
const ll INF = 1e16;

/*
	BIN POISK EBANA V ROT
	DP EBANA V ROT
	DO EBANA V ROT
*/

ll mat[N][N], dp[N][N][5];
int k, n, m;

int main() {
	scanf("%d %d %d", &n, &m, &k);
	while (k--) {
		int x, y, v;
		scanf("%d %d %d", &x, &y, &v);
		mat[x][y] = v;
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= m; ++j) {
			dp[i][j][0] = max(dp[i - 1][j][4], dp[i][j - 1][0]);
			dp[i][j][1] = max(max(dp[i][j - 1][0], dp[i - 1][j][4]) + mat[i][j], dp[i][j - 1][1]);
			dp[i][j][2] = max(dp[i][j - 1][1] + mat[i][j], dp[i][j - 1][2]);
			dp[i][j][3] = max(dp[i][j - 1][2] + mat[i][j], dp[i][j - 1][3]);
			dp[i][j][4] = max({dp[i][j][0], dp[i][j][1], dp[i][j][2], dp[i][j][3]});
		}		
	}
	printf("%lld", dp[n][m][4]);
}


Measured memory_bytes: 425988
def main():
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    
    for k in range(K):
        B = [0 for i in range(N)]
        for i in range(N):
            low = max(0,i-A[i])
            high = min(N-1,i+A[i])
            B[low] += 1
            if high+1 < N:
                B[high+1] -= 1
        for i in range(1,N):
            B[i] += B[i-1]
        pre_A = A
        A = B
        if A == pre_A:
            break
    
    print(*A)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 168352
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <ctime>
#include <iterator>
#include <bitset>
#include <numeric>
#include <list>
#include <iomanip>
#include <cassert>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#define ALL(v) begin(v),end(v)
#else
#define ALL(v) (v).begin(),(v).end()
#endif

using namespace std;


namespace{
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T> inline T &chmin(T &x, const T &y){ return x = min(x, y); }
template <class T> inline T &chmax(T &x, const T &y){ return x = max(x, y); }
template <class F, class T>
void convert(const F &f, T &t){
	stringstream ss;
	ss << f;
	ss >> t;
}


#define REP(i,n) for(int i=0;i<int(n);++i)
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8


void mainmain(){
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	for(int i = 0; i < h; ++i){
		cin >> v[i];
	}

	int cnt[610][610] = {};
	for(int i = 0; i < h; ++i)
	for(int j = 0; j < w; ++j)
	if(v[i][j] == '#'){
		cnt[i + j + 2][i - j + 302] = 1;
	}
	int sumh[610][610] = {}, sumv[610][610] = {};
	for(int i = 1; i < 610; ++i)
	for(int j = 1; j < 610; ++j){
		sumh[i][j] = sumh[i][j - 1] + cnt[i][j];
		sumv[i][j] = sumv[i - 1][j] + cnt[i][j];
	}
	
	LL res1 = 0, res2 = 0;
	for(int y1 = 0; y1 < 610; ++y1)
	for(int x1 = 0; x1 < 610; ++x1)
	if(cnt[y1][x1]){
		for(int x2 = x1 + 1; x2 < 610; ++x2)
		if(cnt[y1][x2]){
			int d = x2 - x1;
			for(int s = -1; s <= 1; s += 2){
				int y2 = y1 + d * s;
				if(y2 < 0 || y2 >= 610){ continue; }
				res1 += cnt[y2][x1];
				res1 += cnt[y2][x2];
				if(d >= 2){
					res2 += sumh[y2][x2 - 1] - sumh[y2][x1];
				}
			}
		}
		for(int y2 = y1 + 1; y2 < 610; ++y2)
		if(cnt[y2][x1]){
			int d = y2 - y1;
			for(int s = -1; s <= 1; s += 2){
				int x2 = x1 + d * s;
				if(x2 < 0 || x2 >= 610){ continue; }
				res1 += cnt[y1][x2];
				res1 += cnt[y2][x2];
				if(d >= 2){
					res2 += sumv[y2 - 1][x2] - sumv[y1][x2];
				}
			}
		}
	}
	LL ans = res1 / 2 + res2;
	cout << ans << '\n';
}



}
int main() try{
	ios::sync_with_stdio(false); cin.tie(0);
	cout << fixed << setprecision(10);
	cerr << fixed << setprecision(4);
	mainmain();
}
catch(...){}


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

struct Range {
    string d;
    int l, r;
    int id;
    void print() {
        cout << d << " " << l << " " << r << " " << id << endl;
    }
};

int strToInt(string s) {
    int ret = 0;
    int sign = 1;

    int i = 0;
    if (s[0] == '-') {
        i++;
        sign = -1;
    }

    while (i < s.size()) {
        ret *= 10;
        ret += s[i] - '0';
        i++;
    }

    return ret * sign;
}

int convTime(string s) {
    int ret = 0;
    stringstream ss(s);
    string t;
    while (getline(ss, t, ':')) {
        ret *= 60;
        // ret += stoi(t);
        ret += strToInt(t);
    }
    return ret;
}

int common(const Range &a, const Range &b) {
    if (a.d != b.d) return 0;
    if (b.id == 0) return 0;
    int l = max(a.l, b.l);
    int r = min(a.r, b.r);
    return max(0LL, r - l);
}

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

    int n;
    while (cin >> n, n) {
        vector<stack<int>> v(1000);
        vector<Range> u;
        rep(i, n) {
            string d, hhmm, e;
            int id;
            cin >> d >> hhmm >> e >> id;
            int m = convTime(hhmm);
            if (v[id].empty()) {
                assert(e == "I");
                v[id].push(m);
            } else {
                assert(e == "O");
                int s = v[id].top(); v[id].pop();
                u.emplace_back((Range){d, s, m, id});
            }
        }

        // for (auto r : u) {
        //     cout << r.d << " " << r.l << " " << r.r << " " << r.id << endl;
        // }

        V len(1000, 0);
        for (auto a : u) {
            if (a.id == 0) {
                for (auto b : u) {
                    len[b.id] += common(a, b);
                    // a.print();
                    // b.print();
                    // cout << common(a, b) << endl;
                }
            }
        }

        cout << *max_element(all(len)) << endl;

        // rep(i, 5) {
        //     cout << len[i] << " ";
        // }
        // cout << endl;
    }
}

Measured memory_bytes: 3664
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;

#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, E, T;
int W[310], G[1010], C[1010], S[1010][15];

signed main() {
    cin >> N >> E >> T; T--;
    for(int i=0; i<N; i++) {
        cin >> W[i];
        if(W[i] == 0) W[i] = INF;
    }
    vector<int> used_rule(E);
    for(int i=0; i<E; i++) {
        cin >> G[i] >> C[i]; G[i]--;
        for(int k=0; k<C[i]; k++) {
            cin >> S[i][k];
            S[i][k]--;
        }
    }

    for(int z=0; z<E; z++) {
        bool change = false;
        for(int i=0; i<E; i++) {
            if(used_rule[i]) continue;
            bool ok = true;
            for(int k=0; k<C[i]; k++) {
                ok &= (W[ S[i][k] ] < INF);
            }
            if(!ok) continue;

            // use i-th rule
            change = true;
            used_rule[i] = true;

            vector<int> ws;
            for(int k=0; k<C[i]; k++) {
                ws.push_back(W[ S[i][k] ]);
            }
            sort(ws.rbegin(), ws.rend());

            int t = 0;
            for(size_t k=0; k<ws.size(); k++) {
                t = max<int>(t, k + ws[k]);
            }
            chmin(W[ G[i] ], t);
            // fprintf(stderr, "rule %lld: t = %lld\n", i, t);
        }
        if(!change) break;
    }
    if(W[T] == INF) cout << -1 << endl;
    else cout << W[T] << endl;
    return 0;
}



Measured memory_bytes: 3292
//失敗例である。
//大きすぎる値同士の掛け算が行われているぞい
//整数で値を小さくする=>modの利用を検討してみては？
/*失敗例

#include<bits/stdc++.h>
using namespace std;
#define For(start,end) for(int i = (int)start;i<(int)end;i++)
using Int = long long int;
using TDim = vector<vector<int>>;
int main(){
    Int X,K,D;cin>>X>>K>>D;
    //X>0のとき
    if(X>0)
    {
        if(X-K*D>0)cout<<X-K*D<<endl;//k*Dが保証されていない？
        else 
        {
            Int n = (X/D)+1;
          
            if((K-n)%2==0)cout<<(-(X-n*D))<<endl;
            else cout<<X-(n-1)*D<<endl;
        }
    }
    else if(X<0)
    {
        if(X+K*D<=0)cout<<-(X+K*D)<<endl;
        else 
        {
            Int n = ((-X)/D)+1;
            cout<<n<<endl;
            if((K-n)%2==0)cout<<X+n*D<<endl;
            else cout<<-(X+(n-1)*D)<<endl;
        }
    }
    else
    {
        if(K%2==0)cout<<0<<endl;
        else cout<<D<<endl;
    }
    
}
*/
#include<bits/stdc++.h>
using namespace std;
#define For(start,end) for(int i = (int)start;i<(int)end;i++)
using Int = long long int;
using TDim = vector<vector<int>>;
int main(){
    Int X,K,D;cin>> X >> K >> D;
    X = (X>0) ? X:-X;
    Int k = K-X/D;//X/D（回）で0の直前まで移動できる.
    if(k<0)//Xが0を超えないとき
    {
        X-=K*D;
    }
    else 
    {
        X%=D;
        if(k%2!=0)X-=D;
    }
     
    X = (X>0) ? X:-X;
    cout<<X<<endl;


    
}

Measured memory_bytes: 3640
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	source := 100
	X := nextInt()
	i := 0

	for {
		i++
		source = int(math.Floor(float64(source) * 1.01))
		if source >= X {
			fmt.Print(i)
			break
		}
	}
}


Measured memory_bytes: 1756
# -*- coding: utf-8 -*-
import math
n, m = map(int,input().split())
a = []
for i in range(m):
    a.append(int(input()))

if m == 0:
    dp = [0 for _ in range(n)] #i + 1段目に登る方法の数
    dp[0] = 1
    if n >= 2:
        dp[1] = 2
    for i in range(2, n):
        dp[i] = (dp[i - 1] + dp[i - 2]) % (pow(10, 9) + 7)
    print(dp[n - 1])
    exit()

tmp = 0
dp = [0 for _ in range(n)]
if 1 == a[tmp]:
    dp[0] = 0
    tmp += 1
else:
    dp[0] = 1
if n >= 2 and tmp < m and 2 == a[tmp]:
    dp[1] = 0
    tmp += 1
elif n >= 2 and (tmp >= m or 2 != a[tmp]):
    dp[1] = dp[0] + 1

for i in range(2, n):
    if tmp < m and i + 1 == a[tmp]:
        dp[i] = 0
        tmp += 1
    else:
        dp[i] = (dp[i - 1] + dp[i - 2]) % (pow(10, 9) + 7)
#print(dp)
print(dp[n - 1] % (pow(10, 9) + 7))


Measured memory_bytes: 7908
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=n-1; i>=m; i--)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
typedef pair<ll, ll> LP;
 
ll POW(ll m,ll n)
{
  if(n<0) return 0;
  if(n==0) return 1;
  return m*POW(m,n-1)%MOD;
}
 
ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a, ll m) {
    ll x, y;
    extGCD(a, m, x, y);
    return mod(x, m);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return m%MOD*COM(m-1,n)%MOD*modinv(m-n,MOD)%MOD;
}
 

int main()
{
  ll n,k,v[1100][1100],c;
  cin >> n;
  k=0;
  FOR(i,2,1100)if(i*(i-1)==2*n)k=i;
  if(k==0)printf("No");
  else
  {c=1;
   rep(i,k-1){
     FOR(j,i+1,k){
       v[i][j-1]=c;
       v[j][i]=c;
       c++;
     }
   }
   printf("Yes\n");
   printf("%lld\n",k);
   rep(i,k){
     printf("%lld",k-1);
     rep(j,k-1){printf(" %lld",v[i][j]);
             }
     printf("\n");
   }
  }
}

Measured memory_bytes: 7040
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const long long INF = 1LL << 60;

long long Con(long long a){
    return a * (a - 1) / 2;
}

int main(){
    int N;
    if(N == 1){
        cout << 0 << endl;
        return 0;
    }
    scanf("%d", &N);
    vector<long long> A(N);
    vector<long long> B(N + 1, 0);//配列Aの累積和
    
    for(int i = 0; i < N; i++){
        scanf("%lld", &A[i]);
        B[i + 1] = B[i] + A[i];
    }
    
    sort(B.begin(), B.end());//同じ数が何個あるか数えるので
    reverse(B.begin(), B.end());
    B.push_back(INF);//番兵
    
    long long ans = 0;
    long long now = B[0];
    int cnt = 1;
    
    for(int i = 1; i <= N + 1; i++){
        if(B[i] == now){//同じ数を数える
            cnt++;
        }else{//異なったら cntC2を求める(カウント < 2 のときは選べないので求めない)
            if(cnt > 1){
                ans += Con(cnt);
            }
            now = B[i];//今見ている数とカウントを更新
            cnt = 1;
        }
    }
    
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 6400
#include<iostream>
#include<algorithm>

using namespace std;

int main() {
	int x, y;
	cin >> x >> y;

	switch (x) {
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		x = -1;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		x = -2;
		break;
	case 2:
		x = -3;
		break;
	default:
		break;
	}

	switch (y) {
	case 1:
	case 3:
	case 5:
	case 7:
	case 8:
	case 10:
	case 12:
		y = -1;
		break;
	case 4:
	case 6:
	case 9:
	case 11:
		y = -2;
		break;
	case 2:
		y = -3;
		break;
	default:
		break;
	}

	if (x == y)cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int k =sc.nextInt();
		int lb=sc.nextInt();
		int ub=sc.nextInt();
		int x = lb/k;
		int y = ub/k;
		if(lb%k==0 || ub%k==0)
			System.out.println("OK");
		else if(y>x)
			System.out.println("OK");
		else
			System.out.println("NG");
	}

	static class Pair {
		int x;
		int y;

		public Pair(int x, int y) {
			this.x = x;
			this.y = y;
		}

	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws IOException {
			return Long.parseLong(next());
		}

		public String nextLine() throws IOException {
			return br.readLine();
		}

		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}

		public boolean ready() throws IOException {
			return br.ready();
		}

	}
}


Measured memory_bytes: 32680
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  string s;
  cin>>s;
  int n = s.size();
  int now = 0;
  REP(i,n){
    if(s[i]=='C' && now == 0){
      now++;
    }else if(s[i]=='F' && now == 1){
      now++;
      break;
    }else{
      ;
    }
  }
  
  if(now == 2){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
    
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()

bool checkRow(const vvi& c, int i0, int i1, int j0, int j1) {
  return c[i0][j0] - c[i0][j1] == c[i1][j0] - c[i1][j1];
}

bool checkCol(const vvi& c, int i0, int i1, int j0, int j1) {
  return c[i0][j0] - c[i1][j0] == c[i0][j1] - c[i1][j1];
}

int main() {
  //
  vvi c(3, vi(3));
  rep(i, 3) rep(j, 3) cin >> c[i][j];
  rep(i, 3) {
    rep(j, 3) {
      if (!checkRow(c, i, (i + 1) % 3, j, (j + 1) % 3)) {
        cout << "No" << endl;
        return 0;
      }
      if (!checkCol(c, i, (i + 1) % 3, j, (j + 1) % 3)) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int judge(int t, int x, int y) {

    if (((x + y) <= t) & ((x + y - t) % 2 == 0)) {
        return 1;
    } else {
        return 0;
    }
}

int main() {

    int N;
    cin >> N;

    int t[N], x[N], y[N];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;

    for (int i = 1; i <= N; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    int flag = 1;
    int tp, xp, yp;

    for (int i = 1; i <= N; i++) {
        tp = t[i] - t[i-1];
        xp = x[i] - x[i-1];
        yp = y[i] - y[i-1];

        if (!judge(tp, xp, yp)) {
            flag = 0;
            break;
        }
    }

    if (flag) {
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
 
    return 0;
}

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

using namespace std;

int main(){
	int n;
	string s;
	bool flag = true;
	cin >> n;
	cin >> s;

	if(n%2==1){
		cout << "No";
		return 0;
	}
	int half_n=n/2;
	
	for(int i=0;i<half_n;i++){
		if(s[i]!=s[half_n+i]){
			flag = false;
			break;
		}
	}

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

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  char s[11], t[11];
  int i=0, j=0;

  scanf("%s", s);

  while(s[i]!='\0'){
    if((s[i]=='0')||(s[i]=='1')){
      t[j]=s[i];
      j++;
    }else if(s[i]=='B'){
      if(j>0){
        t[--j]='\0';
      }
    }
    i++;
  }

  t[j]='\0';
  printf("%s\n", t);
  return 0;
}


Measured memory_bytes: 1664
n, m = map(int, input().split())
ans = ["0"] * n
flag = True
ansnum = ""
for i in range(m) :
    num = [int(i) for i in input().split()]
    if ans[num[0]-1] == "0" :
        ans[num[0]-1] = num[1]
    elif ans[num[0]-1] == num[1] :
        continue
    else :
        flag = False
        
if n != 1 :
    if ans[0] == 0 :
        flag = False
    elif ans[0] == "0" :
        ans[0] = 1
        
if flag == True :
    for j in range(n) :
        ansnum = ansnum + str(ans[j])
    print(ansnum)
else :
    print(-1)

Measured memory_bytes: 3064
#include <iostream>
#include <cassert>
//#define NDEBUG
int main(void){
    using namespace std;
 
    static const int SEC_MIN = 0;
    static const int SEC_MAX = 86400;
    int total_sec =0;
    int hour =0;
    int min =0;
    int sec =0;
    cin >> total_sec;
     
    assert(SEC_MIN <= total_sec && total_sec < SEC_MAX); /* Precondition */
     
    /* Calculation */
    hour = total_sec/60/60;
    min = total_sec%3600/60;
    sec = total_sec%60%60;
    cout << hour<<":"<<min<<":"<<sec<< endl;
     
    return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  if (A+B == C+D) {
    cout << "Balanced" << endl;
  }
  else if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <iomanip>
#include <cmath>
#include <queue>
#include <bitset>
#include <numeric>
#include <array>
#include <cstring>
#include <random>
#include <chrono>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
typedef long long ll;
typedef long double ld;
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 2e5 + 42;
int a[N], b[N], ans[N], n;
int main() {

  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

  cin >> n;

  for(int i = 0; i < n; ++i) cin >> a[i];

  for(int i = 0; i < n; ++i) cin >> b[i];

  for(int i = 0; i < n; ++i) ans[i] = b[n - i - 1];

  int t;

  for(int i = 0; i < n; ++i) {
    if(ans[i] == a[i]) {
      for(int j = n - 1; j >= 0; --j) {
        if(ans[i] != a[j] && ans[j] != a[i]) {
          t = ans[i];
          ans[i] = ans[j]; ans[j] = t;
          break;
        }
        if(j == 0) { cout << "No\n"; return 0; }
      }
    }
  }

  cout << "Yes\n";

  for(int i = 0; i < n ; ++i) cout << ans[i] << ' ';

  return 0;
}
/*

*/


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

#define INF 10000001

#define MOD 1000000007

typedef long long ll;

int main(void){
  int n,i,j;
  std::cin >> n;
  std::map<int,int> mp;
  for(i=2;i<=n;i++){
    int x = i;
    for(j=2;j<=x;j++){
      while(x%j==0){
        x /= j;
        mp[j]++;
      }
    }
  }
  ll ans = 1;
  for(auto &t:mp){
    ans = ((ans%MOD)*(t.second+1)%MOD)%MOD;
  }
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    char s1[10], s2[10], s3[10];
    scanf("%s %s %s",&s1, &s2, &s3);

    s1[0]=s1[0]-32;
    s2[0]=s2[0]-32;
    s3[0]=s3[0]-32;

    printf("%c%c%c", s1[0], s2[0], s3[0]);

    return 0;
}


Measured memory_bytes: 1708
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
ll sum, x, n;
void gcd(ll x, ll y)
{
	if (y == 0) 
	{
		sum -= x; 
		return;
	}
	sum += x / y * y * 2;
	gcd(y, x % y);
}

int main()
{
	scanf("%lld%lld", &n, &x);
	gcd(x, n - x);
	cout << sum + n << endl;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 	long long N;
 	cin >> N;
 	if(N&1)
 		cout << 2 * N << endl;
 	else
 		cout << N << endl;

    return 0;
}

Measured memory_bytes: 256