akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.BitSet;
import java.util.StringTokenizer;

public class Main {
    private static void solve() throws Exception {
        char[] s = fs.next().toCharArray();
        int sum = 0;
        for (char c : s) {
            sum += (c-'0');
        }
        out.println(sum % 9 == 0 ? "Yes" : "No" );
    }

    private static FastScanner fs = new FastScanner();
    private static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) throws Exception {
        int T = 1;
        for (int t = 0; t < T; t++) {
            solve();
        }
        out.close();
    }

    static void debug(Object... O) {
        System.err.print("DEBUG ");
        System.err.println(Arrays.deepToString(O));
    }

    static class FastScanner {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer("");

        String next() {
            while (!st.hasMoreTokens())
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            return st.nextToken();
        }

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

        int[] readArray(int n) {
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = nextInt();
            return a;
        }

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

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

        String nextString() {
            return next();
        }
    }
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)


void aryan_p() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	return;
}


int32_t main() {


	string s;
	cin>>s;
	int i ; 
	for( i = 0 ; i< s.length() ; i++){
		if(i&1){
			if(s[i]=='L' or s[i]=='U' or s[i]=='D'){
				continue;
			}
			else{
				break;
			}
		}
		else{
			if(s[i]=='R' or s[i]=='U' or s[i]=='D'){
				continue;
			}
			else{
				break;
			}
		}
	}
	if(i!=s.length()){
		cout<<"No";
	}
	else{
		cout<<"Yes";
	}



	return 0;
}

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

vector<int> getDivisors(int x) {
    vector<int> ans;
    for (int i = 1; i * i <= x; i++) {
        if (x % i != 0) continue;
        ans.push_back(i);
        if (x / i == i) continue;
        ans.push_back(x / i);
    }
    sort(ans.begin(), ans.end());
    return ans;
}

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

    vector<int> divs = getDivisors(M);
    int ans;
    for (int i : divs) {
        if (i <= M / N) ans = i;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

#define swap(a,b) do {\
    a ^= b;\
    b ^= a;\
    a ^= b;\
} while(0)

typedef struct _Mobile {
    struct _Mobile *parent;
    struct _Mobile *left_vertex;
    struct _Mobile *right_vertex;
    int weight;
    int left_length;
    int right_length;
} Mobile;


int gcd(int a, int b) {
    int c;

    if (a < b) swap(a,b);

    c = a % b;
    while (c) {
        a = b;
        b = c;
        c = a % b;
    }

    return b;
}

void dive(Mobile *vertex) {
    int left_weight;
    int right_weight;
    int gcm;
    int new_left_weight;
    int new_right_weight;

    if (vertex->left_vertex) {
        dive(vertex->left_vertex);
        left_weight = vertex->left_vertex->weight;
    } else {
        left_weight = 0;
    }

    if (vertex->right_vertex) {
        dive(vertex->right_vertex);
        right_weight = vertex->right_vertex->weight;
    } else {
        right_weight = 0;
    }

    gcm = gcd(vertex->left_length, vertex->right_length);
    new_left_weight = vertex->right_length/gcm;
    new_right_weight = vertex->left_length/gcm;

    if (right_weight) {
            int factor = right_weight/gcd(right_weight, new_right_weight);
            new_right_weight *= factor;
            new_left_weight *= factor;
    } 

    if (left_weight) {
            int factor = left_weight/gcd(left_weight, new_left_weight);
            new_left_weight *= factor;
            new_right_weight *= factor;
    }

    vertex->weight = new_left_weight + new_right_weight;
    return;
}

int main() {
    while (1) {
        int i;
        int n;
        Mobile *most_parent;

        scanf("%d", &n);
        if (!n) return 0;

        Mobile vertexes[100];

        for (i=0;i<n;i++) {
            vertexes[i].parent = NULL;
            vertexes[i].weight = 0;
        }

        for (i=0;i<n;i++) {
            int p, q, r, b;
            scanf("%d %d %d %d", &p, &q, &r, &b);
            vertexes[i].left_length = p;
            vertexes[i].right_length = q;
            vertexes[i].left_vertex = (Mobile*)(r==0)?NULL:&vertexes[r-1];
            vertexes[i].right_vertex = (Mobile*)(b==0)?NULL:&vertexes[b-1];

            if (r) {
                vertexes[r-1].parent = &vertexes[i];
            }

            if (b) {
                vertexes[b-1].parent = &vertexes[i];
            }

        }

        Mobile *tmp = &vertexes[0];
        while (tmp->parent) {
            tmp = tmp->parent;
        }
        most_parent = tmp;

        dive(most_parent);

        printf("%d\n", most_parent->weight);
    }
}

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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

void pre(){


}

void solve(){


}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin.exceptions(cin.failbit);
	pre();
	int n;cin>>n;
	cout<<(n-1)/2;
	return 0;
}



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

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    int N = 0, Q = 0;
    string S = "";

    cin >> N >> S >> Q;

    map<char, set<int>> area;
    for (size_t i = 0; i < S.length(); i++)
    {
        area[S[i]].insert(i);
    }

    for (int i = 0; i < Q; i++)
    {
        int type = 0;
        cin >> type;
        if (type == 1)
        {
            int iq = 0;
            char c = '#';
            cin >> iq >> c;
            iq--;

            area[S[iq]].erase(iq);
            S[iq] = c;
            area[S[iq]].insert(iq);
        }
        else
        {
            int l = 0, r = 0;
            cin >> l >> r;
            l--;
            r--;

            int cnt = 0;
            for (int j = 0; j < 26; j++)
            {
                auto it = area['a' + j].lower_bound(l);
                if (it != area['a' + j].end() && *it <= r)
                {
                    cnt++;
                }
            }
            cout << cnt << endl;
        }
    }

    return 0;
}


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

#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
template <typename T> inline void assign_max(T& x, const T& value) noexcept { x = max(x, value); }

static const int64_t MOD = 998244353;

int main() {
    int N, S; cin >> N >> S;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    // 条件を満たす組(L, R, {x_i})を数え上げる。
    // dp[i][s][0]: 0..i のみを使うとき和がsになるような(L, {x_i})の数
    // dp[i][s][1]: 0..i のみを使うとき和がsになるような(L, R, {x_i})の数
    vector dp(N, vector(S+1, vector(2, int64_t())));
    REP(i, N) REP(s, S+1) {
        // A[i] を使わない場合
        dp[i][s][0] = (i>0 ? dp[i-1][s][0] : 0) + (s == 0);
        dp[i][s][1] = (i>0 ? dp[i-1][s][1] : 0) + dp[i][s][0] + (s == 0);
        // A[i] を使う場合
        if (s-A[i] >= 0) {
            dp[i][s][0] += (i>0 ? dp[i-1][s-A[i]][0] : 0) + (s-A[i] == 0);
            dp[i][s][1] += (i>0 ? dp[i-1][s-A[i]][0] : 0) + (s-A[i] == 0);
        }
        dp[i][s][0] %= MOD;
        dp[i][s][1] %= MOD;
    }
    cout << dp[N-1][S][1] << '\n';
}


Measured memory_bytes: 495768
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD (long long)(1e9+7)
int main(){
	int n;
	cin>>n;
	vector<int>h(n);
	for(int i=0;i<n;i++)cin>>h[i];
	int ans=0;
	while(true){
		bool flag=true;
		for(int i=0;i<n;i++)if(h[i]>0)flag=false;
		if(flag)break;
		flag=false;
		for(int i=0;i<n;i++){
			if(h[i]>0){
				flag=true;
			}
			if(flag){
				if(h[i]>0){
					h[i]--;
					if(i==n-1)ans++;
				}
				else{
					ans++;
					flag=false;
				}
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){ int aa, bb;
	scanf ("%d %d", &aa, &bb);
	if (aa > bb)  printf ("a > b\n",  aa, bb);
	if (aa == bb) printf ("a == b\n", aa, bb);
	if (aa < bb)  printf ("a < b\n",  aa, bb);
	return 0;
}

Measured memory_bytes: 580
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      s: chars,
    }
    let n = s.len();
    let max = 1 << (n-1);
    let mut ans = 0u64;
    for bit in 0..max {
        let mut cur = s[0].to_digit(10).unwrap() as u64;
        for i in 1..n {
            if bit & (1 << (i-1)) > 0 {
                ans += cur;
                cur = 0;
            }
            cur *= 10;
            cur += s[i].to_digit(10).unwrap() as u64;
        }
        ans += cur;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;
//【156】
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
		int n =sc.nextInt();
		int[] xs =new int[n+1];
		int max=0;
		int min =100;
		for (int i=0;i<n;i++) {
			int xs_i =sc.nextInt();
			xs[i] =xs_i;
			max =Math.max(max, xs_i);
			min =Math.min(min, xs_i);
		}
		int minHp=0;
		for (int i=0;i<n;i++) {
			minHp +=(xs[i])*(xs[i]);
		}
		for (int i=min;i<=max;i++) {
			int hp =0;
			for (int j=0;j<n;j++) {
				hp +=(xs[j]-i)*(xs[j]-i);
			}
			minHp =Math.min(minHp, hp);
		}
		System.out.println(minHp);
		
//━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
	}
	//----------------------------------------
	//置き場
	
	//----------------------------------------
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
template <class T>
using Vec2 = vector<vector<T>>;
#define REP(i, m, n) for(ll i = (m); i < (n); ++i)
#define REPN(i, m, n) for(ll i = (m); i <= (n); ++i)
#define REPR(i, m, n) for(ll i = (m)-1; i >= (n); --i)
#define REPNR(i, m, n) for(ll i = (m); i >= (n); --i)
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define fs first
#define sc second
template <class T1, class T2>
bool chmax(T1 &a, const T2 b){if(a < b){a = b; return true;} return false;}
template <class T1, class T2>
bool chmin(T1 &a, const T2 b){if(a > b){a = b; return true;} return false;}
ll pow2(const int n){return (1LL << n);}
void co() { cout << endl; }
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    cout << head << ' ';
    co(forward<Tail>(tail)...);
}
void ce() { cerr << endl; }
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    cerr << head << ' ';
    ce(forward<Tail>(tail)...);
}
void sonic(){ios::sync_with_stdio(false); cin.tie(0);}
void setp(const int n){cout << fixed << setprecision(n);}
constexpr int INF = 1e9+1;
constexpr ll LINF = 1e18L+1;
constexpr ll MOD = 1e9L+7;
constexpr ll MOD_N = 998244353;
constexpr ld EPS = 1e-11;
const double PI = acos(-1);

int main(void){
    ll t;
    cin >> t;
    while(t--){
        ll n, m, a, b;
        cin >> n >> m >> a >> b;
        co(floor_sum(n, m, a, b));
    }

    return 0;
}


Measured memory_bytes: 3668
import java.util.Scanner;
//import java.lang.Math;

class Main{
	public static void main(String[] arg){
	
		
		Scanner sc = new Scanner(System.in);
		int[] str = new int[7];
		
		for(int i=1;i<7;i++){
		     
			str[i]=sc.nextInt();
		}
		
		char[] a=sc.next().toCharArray();
		for(int i=0;i<a.length;i++){
			if(a[i]=='N'){
				str[0]=str[1];
				str[1]=str[2];
				str[2]=str[6];
				str[6]=str[5];
				str[5]=str[0];
				
			}else if(a[i]=='S'){
				
				str[0]=str[1];
				str[1]=str[5];
				str[5]=str[6];
				str[6]=str[2];
				str[2]=str[0];
				
				
			}else if(a[i]=='E'){
				
				str[0]=str[1];
				str[1]=str[4];
				str[4]=str[6];
				str[6]=str[3];
				str[3]=str[0];
			}else {
				str[0]=str[1];
				str[1]=str[3];
				str[3]=str[6];
				str[6]=str[4];
				str[4]=str[0];
			}
		}
		sc.close();
	System.out.println(str[1]);
		
		}
}
		


Measured memory_bytes: 26256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { int n = d.size(); REP (i, n) s << d[i] << " "; return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& dd) { for (vector<T> d: dd) s << d << endl; return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "\t" << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl << "\t", dump_func(__VA_ARGS__);
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
constexpr int MOD = 1e9 + 7;
signed main() {
  VI pow(30, 2);
  REP (i, 29) {
    pow[i + 1] = pow[i] * 2;
  }
  dump(pow);
  int N; cin >> N;
  multiset<int> A;
  REP (i, N) {
    int a; cin >> a;
    A.insert(a);
  }
  int ans = 0;
  auto it = A.end();
  while (it != A.begin()) {
    it--;
    dump(*it);
    int re;
    REP (i, 30) {
      if (pow[i] > *it) {
        re = pow[i] - *it;
        break;
      }
    }
    auto pa = A.lower_bound(re);
    if (*pa != re || pa == it) continue;
    ans++;
    A.erase(pa);
    it++;
    A.erase(prev(it));
  }
  cout << ans << endl;
}


Measured memory_bytes: 10236
from itertools import combinations
_=list(map(int,input().split()))
print(min([i[0]*i[1]%2019 for i in list(combinations([i for i in range(_[0],_[1]+1)],2)if _[1]-_[0]<2019else combinations([i for i in range(_[0],_[0]+2020)],2))]))

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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld; 


#define F first
#define S second
#define pob pop_back
#define pb push_back
#define Time()	cerr << clock() * 1000 / CLOCKS_PER_SEC << "ms\n"
#define show(x)	cerr << #x << " = " << (x) << '\n'
#define inf 1e14
#define FASTER ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define invec(v) for(auto& x : v)cin>>x;
#define Test int T;cin>>T;while(T--)
#define vec vector<int> 


int main()
{
	FASTER;
	vec v = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	//invec(v);
  int k;
  cin>>k;
  cout<<v[k-1];
	
	return 0;
} 




Measured memory_bytes: 256
#include <stdio.h>


int a[22] = {};

int n;



int solve(int i,int m){

  if(m == 0) return 1;
  else if(i > n) return 0;

  return (solve(i + 1,m) || solve(i + 1, m - a[i]));
  
}

int main(){
  
  int q,m,i;
  
 scanf("%d",&n);
 for(i = 0;i < n;i++) scanf("%d",&a[i]);

 
 scanf("%d",&q); 
 for(i = 0;i < q;i++){
    scanf("%d",&m);
    if(solve(0,m) == 1) printf("yes\n");
    else printf("no\n");
  }
  
}
  

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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 (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    string S;
    cin >> S;
    stack<char> st;
    ll res = 0;
    REP(i, S.size()){
    	if(st.empty()){
    		st.push(S[i]);
    	}else{
    		char tmp = st.top();
    		if(tmp != S[i]){
    			res += 2;
    			st.pop();
    		}else{
    			st.push(tmp);
    		}
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i=0;i<((int)(n));i++)
#define reg(i,a,b) for(int i=((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i=((int)(n))-1;i>=0;i--)
#define ireg(i,a,b) for(int i=((int)(b));i>=((int)(a));i--)
typedef long long int lli;
typedef pair<int,int> mp;
#define fir first
#define sec second
#define IINF INT_MAX
#define LINF LLONG_MAX
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define pque(type) priority_queue<type,vector<type>,greater<type> >
#define memst(a,b) memset(a,b,sizeof(a))
#define iter(v,ite) for(auto ite=(v).begin();ite!=(v).end();ite++)
#define mimunum(v,x) distance((v).begin(),lower_bound((v).begin(),(v).end(),x))

int n;
lli seg[400005]={};
lli dat[100005];
int N;
void init(){
	N=1;
	while(N<=n+10)N*=2;
}

lli get(int l,int r,int a,int b,int k){
	if(r<=a || b<=l)return 0;
	if(a<=l && r<=b)return seg[k];
	return max(
		get(l,(l+r)/2,a,b,k*2),
		get((l+r)/2,r,a,b,k*2+1));
}

void upd(int p,lli t){
	p+=N;
	while(p>0){
		seg[p]=max(seg[p],t); p/=2;
	}
}

int main(void){
	scanf("%d",&n);
	init();
	lli s=0;
	rep(i,n){
		scanf("%lld",&dat[i]);
		s+=dat[i];
	}
	
	rep(i,n){
		lli g=get(0,N,0,dat[i],1);
		upd(dat[i],g+dat[i]);
		//printf("%lld %lld %lld\n",g,dat[i],get(0,N,0,dat[i],1));
	}

	printf("%lld\n",s-get(0,N,0,n+5,1));
		
	return 0;
}

Measured memory_bytes: 3560
read = input
s = read()
a = []
pc = '0' if s[0] == '1' else '1'
pcnt = 0
for c in s:
    if pc == c:
        a.append(pcnt)
        pcnt = 1
    else :
        pcnt = pcnt + 1
    pc = c
a.append(pcnt)
# print(a, s)
odd = sum(map(lambda tp:tp[1], filter(lambda tp:tp[0] % 2 != 0, enumerate(a))))
even = sum(map(lambda tp:tp[1], filter(lambda tp:tp[0] % 2 == 0, enumerate(a))))
print(min(odd, even))

Measured memory_bytes: 3956
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> c(n-1);
    vector<int> s(n-1);
    vector<int> f(n-1);

    for (int i=0; i<n-1; i++)
        cin >> c[i] >> s[i] >> f[i];

    for (int i=0; i<n; i++) {
        int ans = 0;
        int now = 0;
        for (int j=i; j<n-1; j++) {
            if (now < s[j]) now = s[j];
            if (now % f[j] != 0) {
                now += f[j] - (now % f[j]);
            }
            now += c[j];
        }
        cout << now << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    int n; cin >> n;
    if (n < 1000) {
        cout << "ABC" << endl;
    } else {
        cout << "ABD" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[n];
    map<int,int> mp;
    int ans=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        if(a[i]<=n)mp[a[i]]++;
        else ans++;
    }
    for(int i=1;i<=n;i++){
        if(mp[i]>i)ans+=(mp[i]-i);
        else if(mp[i]<i)ans+=mp[i];
    }
    cout << ans;
}

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

int main()
{
	ios::sync_with_stdio(false);
	
	int w,h,n;
	cin>>w>>h>>n;
	int p[110][110]={};
	
	for(int i=1;i<=w;i++)
		for(int j=0;j<h;j++)
			p[i][j]=1;
	
	for(int i=0;i<n;i++)
	{
		int x,y,a;
		cin>>x>>y>>a;
		
		if(a==1)
		{
			for(int j=1;j<=x;j++)
				for(int k=0;k<h;k++)
					p[j][k]=0;
		}
		
		else if(a==2)
		{
			for(int j=x+1;j<=w;j++)
				for(int k=0;k<h;k++)
					p[j][k]=0;
		}
		
		else if(a==3)
		{
			for(int j=1;j<=w;j++)
				for(int k=0;k<y;k++)
					p[j][k]=0;
		}
		
		else
		{
			for(int j=1;j<=w;j++)
				for(int k=y;k<h;k++)
					p[j][k]=0;
		}
	}
	
	int count=0;
	
	for(int i=0;i<=w;i++)
		for(int j=0;j<=h;j++)
			if(p[i][j]==1)
				count+=1;
	
	cout<<count<<endl;
	return 0;
}

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

int dp[1010][1010];

void solve() {
    string s, t;
    cin >> s >> t;
    memset(dp, 0, sizeof(dp));
    rep(i, s.size()) {
        rep(j, t.size()) {
            if (s[i] == t[j]) dp[i+1][j+1] = dp[i][j] + 1;
            else dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j]);
        }
    }
    cout << dp[s.size()][t.size()] << endl;
}

int main() {
    int q;
    cin >> q;
    rep(i, q) solve();
}


Measured memory_bytes: 7148
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int [] A = new int [102];
        double sum=0;
        double min=0;
        int cost=0;
        for(int i=0; i<N; i++){
            A[i] = sc.nextInt();
            sum+=A[i];
        }
        min=Math.round(sum/N);

        for(int i=0; i<N; i++){
        	cost+=(A[i]-min)*(A[i]-min);
        }
        System.out.println(cost);
    }

}

Measured memory_bytes: 9940
#include <iostream>
#include <vector>
using namespace std;
#define r(i,n) for(int i = 0; i < n; i++)

int main () {
    int n; 
    cin >> n; 
    int day[n][3]; 
    r(i,n) r(j, 3) cin >> day[i][j];
    int dp[n + 1][3];
    r(i, 1) r(j, 3) dp[i][j] = day[i][j];
    
    for(int i = 1; i < n; i++) {
        dp[i][0] = day[i][0] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = day[i][1] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = day[i][2] + max(dp[i - 1][0], dp[i - 1][1]);
    }
    
    // for(int i = 0; i < 3; i++) cout << dp[n - 1][i] << " "; cout << endl;

    cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << endl;

    return 0;
}


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

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

  ll ans = N - 1;
  for (int i = 2; i <= 1000000; i++) {
    if (N % i == 0) {
      ll n = N / i;
      ll m = i - 1 + n - 1;
      ans = min(ans, m);
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
c_list=[]
for i in range(3):
    c_list.append([int(i) for i in input().split()])

for a1 in range(101):
    b1 = c_list[0][0] - a1
    a2 = c_list[1][0] - b1
    a3 = c_list[2][0] - b1
    b2 = c_list[0][1] - a1
    b3 = c_list[0][2] - a1
    if a2 + b2 == c_list[1][1] and a2 + b3 == c_list[1][2] and a3 + b2 == c_list[2][1] and a3 + b3 == c_list[2][2]:
        print('Yes')
        exit()
print('No')


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

int main(){

int a,b,c;
int sum=0;
cin>>a>>c;

while(c--){
    cin>>b;
    sum+=b;
}
if(sum>a)
    cout<<"-1"<<endl;
else
    cout<<a-sum<<endl;


return 0;
}


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


int main(){
	string S;
	cin >> S;
	for(int i = 0; i < S.size() - 1; i++){
		if(S.substr(i,2) == "AC") {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;

}










Measured memory_bytes: 3524
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	static int n, k;
	static int[] a;

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
//		InputStream inputStream = new FileInputStream("/workspace/AOJ/src/section5/sample5_A.txt");

		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			n = in.nextInt();
			a = in.nextIntArray(n);
			int q = in.nextInt();
			int[] m = in.nextIntArray(q);

			for (int i = 0; i < q; i++) {
				k = m[i];
				if (dfs(0, 0)) {
					out.println("yes");
				} else {
					out.println("no");
				}
			}
		}
		static boolean dfs(int i, int sum) {
			if (sum == k) return true;
			if (i >= n) return false;
			boolean res = (dfs(i+1, sum) || dfs(i+1, sum+a[i]));
			return res;
		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}

	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}
}



Measured memory_bytes: 24760
from collections import Counter
s=input()
n=len(s)
ans=0
arr=[0]*(n+1)
if s=='0':
    print(1)
    exit()
elif n==1:
    print(0)
    exit()
for i in reversed(range(n)):
    arr[i]=(arr[i+1]+int(s[i])*pow(10,n-i-1,2019))%2019
m=Counter(arr)
for j in m.keys():
    ans+=m[j]*(m[j]-1)//2
print(ans)

Measured memory_bytes: 16524
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Main main = new Main();
		main.run();
	}

	public void run() {
		Scanner sc = new Scanner(System.in);
		int n=sc.nextInt();

		boolean notp[] = new boolean[55556];
		notp[0]=true;
		notp[1]=true;
		for(int i=2; i*i<=notp.length; i++) {
			if(!notp[i]) {
				for(int j=2; i*j<notp.length; j++) {
					notp[i*j]=true;
				}
			}
		}
		ArrayList<Integer> pl = new ArrayList<Integer>();
		for(int i=0; i<notp.length; i++) {
			if(!notp[i]&&i%5==1) {
				pl.add(i);
			}
		}
		for(int i=0; i<n; i++) {
			System.out.print(pl.get(i) + (i==n-1 ? "\n" :" "));
		}
		sc.close();
	}

}


Measured memory_bytes: 24148
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< int, int >   cp2;
typedef pair< int, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789


 

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

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



priority_queue< cp3, vector<cp3>, greater<cp3> >p;
cp3 now;

int g[112];

int find( int key ){
	//cout<<key<<" "<<g[key]<<endl;
	if( g[key] < 0 ) return key;
	return g[key] = find( g[key] );
}

void unite( int x, int y ){
	x = find( x );
	y = find( y );
	if( x == y ) return;
	
	if( g[x] < g[y] ) swap( x, y );
	if( g[x] == g[y] ) g[y]--;//??±??????x???????????????
	//g[y] += g[x];		 //????????°???x??????????°???????
	g[x] = y;
}

int a, b;
int c;
int N;
int M;
int ans;

int main(){
	
	while( cin>>N>>M, N && M){
		
		ans = 0;
		fill( g, g+112, -1 );
	
		REP( i, M ){
			scanf("%d %d %d",&a, &b, &c);
			p.push( cp3( c, cp2(a, b) ) );	
		}
	
		while( !p.empty() ){
			now = p.top();
			p.pop();
			
			if( find(now.sec) != find(now.thr) ){
				unite( now.sec, now.thr );
				ans += now.fi;
			}
		}
		
		cout<<ans<<endl;
	}


	return 0;

}

Measured memory_bytes: 3132
# coding: utf-8
#-------------------------------------------------------------------
import sys
def p(*a):
  s=" ".join(map(str,a))
  #print(s)
  sys.stderr.write(s+"\n")
#-------------------------------------------------------------------

R,G,B,N = map(int, input().split())

if R<G: R,G=G,R
if G<B: G,B=B,G
if R<G: R,G=G,R

r=g=b=0
ans=0

#p(N//R+2)
#p(N//G+2)
#X=[]
#p(r,g,b)

for r in range(N//R+2):
	if (R*r)>N: break

	for g in range(N//G+2):
		if (R*r)+(G*g)>N:
			break
			X.append("break")
		
		b = (N-(R*r)-(G*g))//B
		n = (R*r)+(G*g)+(B*b)
		if n==N:
			ans+=1
#			X.append([r,g,b])
#		p(r,g,b,n,N,ans)

print(ans)
#p(X)


Measured memory_bytes: 41564
#include<iostream>
#include<string.h>
#include<algorithm>
#include<vector>
#include<functional>
#include<queue>
using namespace std;

const double INF = 1e9;
typedef double Weight;

struct Edge{
  int src,dst;
  Weight weight;
  Edge(int src,int dst,Weight weight) : src(src), dst(dst), weight(weight) {;}
};
bool operator<(const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight :
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void dijkstra(const Graph &g, int s, vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF);
  dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q;

  for(Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top();
    Q.pop();
    if(prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    for(Edges::const_iterator it = g[e.dst].begin(); it != g[e.dst].end(); ++it) {
      if(dist[it->dst] > e.weight + it->weight) {
	dist[it->dst] = e.weight + it->weight;
	Q.push(Edge(it->src, it->dst, e.weight + it->weight));
      }
    }
  }
}

//dijkstraツづ継revツづーツ使ツづづ催短ツ路ツづーツ構ツ築ツつキツづゥ
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for(int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}

int main() {
  int n,m,p,a,b,ts,t,x,y,z;
  while(cin>>n>>m>>p>>a>>b) {
    if(n==0 && m==0 && p==0 && a==0 && b==0) break;
    ts = 1<<n;
    a--,b--;
    Graph g(ts*m);

    vector<int> tickets;
    for(int i=0; i<n; ++i) {
      cin>>t;
      tickets.push_back(t);
    }

    for(int i=0; i<p; ++i) {
      cin>>x>>y>>z;
      x--,y--;
      for(int j=0; j<ts; ++j) {
	for(int k=0; k<n; ++k) {
	  if((j&(1<<k)) == 0) {
	    g[x*ts+j].push_back( Edge(x*ts+j, y*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	    g[y*ts+j].push_back( Edge(y*ts+j, x*ts+(j|(1<<k)), (double)z/(double)tickets[k]) );
	  }
	}
      }
    }

    /*
    for(int i=0; i<m; ++i) {
      cout<<"City "<<i<<endl;
      for(int j=0; j<ts; ++j) {
	for(int k=0; k<g[i*ts+j].size(); ++k) {
	  cout<<g[i*ts+j][k].src/ts<<" to "<<g[i*ts+j][k].dst/ts<<" : "
	      <<j<<" to "<<g[i*ts+j][k].dst%ts<<endl;
	}
      }
    }
    */

    vector<Weight> dist(ts*m);
    vector<int> path(ts*m);
    dijkstra(g, a*ts, dist, path);

    double minw = INF;
    int goal = 0;
    for(int i=0; i<ts; ++i)
      minw = min(dist[b*ts+i], minw);

    if(minw == INF)
      cout<<"Impossible"<<endl;
    else
      cout<<minw<<endl;
  }
}

Measured memory_bytes: 28000
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin >>s;

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

    if ( s[0]==s[1] && s[2]==s[3] && s[1]!=s[2] )
        cout << "Yes";
    else
        cout << "No";
    return 0;
}


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

using namespace std;
using ll = long long;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll N;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << '\n';
    return 0;
  }
  ll res = N / 10;
  N /= 10;
  while (N / 5 > 0) {
    res += N / 5;
    N /= 5;
  }
  cout << res << '\n';
  return 0;
}


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


int main()
{
	string a, b, c;
	cin >> a >> b >> c;
	char diff = 'A' - 'a';
	char A = a[0] + diff;
	char B = b[0] + diff;
	char C = c[0] + diff;
	cout << A << B << C << endl;

	return 0;
}

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

int main()
{
ll n ;
cin >> n ;
vector<vector<pair<ll,ll>>> v(n);
rep(i,n){
  ll a ;
  cin >> a ;
  rep(j,a){
    ll x , y ;
    cin >> x >> y ;
    v[i].emplace_back(x-1,y);
  }
}

rep(i,1LL<<n){
  bool ok=1;
  rep(j,n){
    if((i>>j)&1LL){
      for(auto r:v[j]){
        if(((i>>r.first)&1LL)!=r.second)ok=0;
      }
    }
  }
  if(ok){
    ll an=0;
    rep(j,n)if((i>>j)&1LL)an++;
    ans=max(ans,an);
  }
}
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	d := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&d[i])
	}

	res := 0
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i == j {
				continue
			}
			res += d[i] * d[j]
		}
	}
	fmt.Println(res / 2)
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int n;
cin>>n;
long long int a[50],b[50];
int ans=n;
for(int i=0;i<n;i++){cin>>a[i]>>b[i];}
for(int i=0;i<n;i++){
	for(int j=i+1;j<n;j++){
		long long int p=a[i]-a[j];
		long long int q=b[i]-b[j];
		int hoge[50]={};
		int c=0;
      
		for(int k=0;k<n;k++){
			if(hoge[k]==0){
				c++;
				hoge[k]=c;
				long long int su=a[k]-p;
				long long int sd=a[k]+p;
				long long int tu=b[k]-q;
				long long int td=b[k]+q;
              
				while(1){
					bool piyo=false;
                  
					for(int i=0;i<50;i++){
						if(a[i]==su and b[i]==tu and piyo==false){hoge[i]=c;piyo=true;}
					}
						if(piyo==false){break;}
						su-=p;tu-=q;
				}
				while(1){
					bool piyo=false;
					for(int i=0;i<50;i++){
						if(a[i]==sd and b[i]==td and piyo==false){hoge[i]=c;piyo=true;}
					}
						if(piyo==false){break;}
						sd+=p;td+=q;
				}
			}
		}
     // cout<<p<<" "<<q<<endl;
      //cout<<hoge[0]<<hoge[1]<<hoge[2]<<hoge[3]<<endl;
		ans=min(ans,c);
	}
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
import itertools 
n=int(input()) 
p=list(map(int,input().split())) 
q=list(map(int,input().split())) 
ll=list(itertools.permutations([i for i in range(1,n+1)])) 

for i in range(len(ll)): 
    if list(ll[i])==p: 
        a=i 
    if list(ll[i])==q: 
        b=i 
print(abs(a-b))

Measured memory_bytes: 8052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a;
  cin >> a;
  int sum = 0;
  int MAX = 0;
  for(int i = 0;i<a;i++){
    int b;
    cin >> b;
    sum += b;
    if(MAX < b)
      MAX = b;
  }
  cout << sum - (MAX/2) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

//template<typename A, size_t N, typename T>
//void Fill(A(&array)[N], const T &val) {
	//std::fill((T*)array, (T*)(array + N), val);
//}

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

//解法
void solve() {

	ll r;
	cin >> r;
	cout << r * r;

}

int main() {

	//入力

	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
/**
 *    author:  border
 *    created: 06.01.2019 17:03:12     
**/
#include <bits/stdc++.h>

using namespace std;

#define debug(s) cout<< #s <<" = "<< s <<endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a,val,sizeof a)

#define ll long long
#define ff first
#define ss second
#define pb push_back
#define endl '\n'

int h[100010],dp[100010];

int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
  /*#ifndef ONLINE_JUDGE
    freopen("in", "r", stdin);
    freopen("out","w",stdout);
  #endif*/
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) cin >> h[i];
  dp[n-2] = abs(h[n-2]-h[n-1]);
  for(int i = n-3; i >= 0; --i){
    dp[i] = min(abs(h[i]-h[i+1])+dp[i+1],abs(h[i]-h[i+2])+dp[i+2]);
  }
  cout << dp[0] << endl;
}




Measured memory_bytes: 1024
import java.util.*;
import static java.lang.System.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int keta = 0;
		int num = n;
		int ans = 0;
		while (num > 0) {
			num /= 10;
			keta++;
		}
		for(int i = 1; i < keta; i = i + 2) {
			int x = 1;
			for(int j = 0; j < i; j++) {
				x *=10;
			}
			ans = ans + (x - (x / 10));
		}
		if (keta % 2 == 1) {
			int x = 1;
			for(int i = 1; i < keta; i++)
				x *= 10;
			ans = ans + ( n - x) + 1;
		}
		out.println(ans);

	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 1000000000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<class T>//usage rand<long long>()
T rand() {
    return uniform_int_distribution<T>()(rng);
}

// string to integer stuuu()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

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

#define S second
#define F first
#define int long long  

//////////
int mo=1000000007;
int n,x;
int ans[201][100001];
	int a[201];
int f[201]={};
long long modinverse(long long a, long long b)
{
    long long b0 = b, t, q;
    long long x0 = 0, x1 = 1;
    if (b == 1) return 1;
    while (a > 1) {
        q = a / b;
        t = b, b = a % b, a = t;
        t = x0, x0 = x1 - q * x0, x1 = t;
    }
    if (x1 < 0) x1 += b0;
    return x1;
}
int fu(int i,int v)
{
	// cout<<i<<" "<<v<<"\n"; 
	if(ans[i][v]!=-1)
		return ans[i][v];
	if(i==0){
		return ((v%a[i]))%mo;
	}
	int u=0;
	for(int j=0;j<i;++j)
	{
		int r=fu(j,v%a[i]);
		// cout<<r<<"\n";
		u+=r;
		u%=mo;
	}
	u*=modinverse(i,mo);
	u%=mo;
	ans[i][v]=u;
	// cout<<i<<" "<<v<<" "<<u<<"\n";
	return u;
}
signed main()
{
	fastio;
	cin>>n>>x;
	f[0]=1;
	for(int i=1;i<=200;++i)
		f[i]=(i*f[i-1])%mo;
	memset(ans,-1,sizeof(ans));
	for(int i=0;i<n;++i)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	int res=0;
	for(int i=0;i<n;++i)
	{
		if(i!=0)
		res+=(((fu(i,x)*f[n-1])%mo))%mo;
		else
		res+=(((fu(i,x)*f[n-1])%mo))%mo;
		// cout<<fu(i,x)<<"\n";
		res%=mo;
	}
	cout<<res;
}

Measured memory_bytes: 157312
#include <algorithm>
#include <cstdio>

int main() {
  int n, r, Max = -999999999, Min;
  scanf("%d%d", &n, &r);
  Min = r;
  for (int i = 1; i < n; i++) {
    scanf("%d", &r);
    Max = std::max(r - Min, Max);
    Min = std::min(r, Min);
  }
  printf("%d\n", Max);
  return 0;
}



Measured memory_bytes: 2756
import * as fs from 'fs'
const reader = (s: string) =>
  s
    .split('\n')
    .join(' ')
    .split(' ')
    .map(t => parseInt(t, 10))

function Main(input: string) {
  const [_, K, ...h] = reader(input)

  console.log(h.filter(cm => cm >= K).length)
}

Main(fs.readFileSync('/dev/stdin', 'utf8'))


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

int main() {
	long long ans;
	int i,k,n,o[10];
	for (i=1,o[0]=1;i<10;i++) o[i]=o[i-1]*8;
	while(cin >> n && n>0) {
	ans=0;	
	for (i=9;i>=0;i--) {
		if (n>=o[i]) { k=n / o[i]; n=n % o[i];
		               if (k==4) k=5; else  if (k>4) k+=2;
		               ans+=k;
		                }
		if (i>0) ans=ans*10;
		}
	cout << ans << endl; 		   
}
	return 0;
}

Measured memory_bytes: 1156
#include <cstdio>
#include <iostream>
#include <vector>
#include <string>
#include <utility>
using namespace std;

int main(){
	int a,b,max;
	cin>>a>>b;
	max=a+b;
	if(max<a-b){
		max=a-b;
	}
	if(max<a*b){
		max=a*b;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 256
n,m,q=map(int,input().split())
Q=[list(map(int,input().split())) for i in range(q)]
ans=0
#めっちゃfor文あるならdfs
R=[range(i,m) for i in range(m)]
def dfs(d,s,l):
    global n,m,Q,ans
    if d==n:
        ans_=0
        for k in Q:
            a,b,c,e=k
            if int(s[b-1])-int(s[a-1])==c:
                ans_+=e
        ans=max(ans,ans_)
    else:
        for i in R[l]:
            dfs(d+1,s+str(i),i)
dfs(0,"",0)

print(ans)

Measured memory_bytes: 9216