akhauriyash/Code-Regression huggingface dataset:
### constant

MINUS = [[0] * 26 + [-1]]

### subroutines

def normalize(expr)
  return expr if expr.empty?

  expr.sort!
  term0 = expr.shift
  expr0 = []

  for term1 in expr
    if term0[0, 26] == term1[0, 26]
      term0[26] += term1[26]
    else
      expr0 << term0 if term0[26] != 0
      term0 = term1
    end
  end
  expr0 << term0 if term0[26] != 0

  expr0
end

def add_expr(expr0, expr1)
  #p ["add", expr0, expr1]
  expr = normalize(expr0 + expr1)
  #p ["add -> ", expr]
  expr
end

def mul_expr(expr0, expr1)
  #p ["mul", expr0, expr1]
  expr = []
  for term0 in expr0
    for term1 in expr1
      term = []
      (0...26).each{|i| term[i] = term0[i] + term1[i]}
      term[26] = term0[26] * term1[26]
      expr << term
    end
  end
  expr = normalize(expr)
  #p ["mul -> ", expr]
  expr
end

# <expr> := <term> ( ('+' | '-') <term>)*
# <term> := (<mult>)+
# <mult> := <num> | <var> ('^' <num>) | '(' <expr> ')'
# <num> := ('0'..'9')+
# <var> := 'a'..'z'

def skip_space(str)
  while str[$pos] == ' '
    $pos += 1
  end
end

def expr(str)
  skip_space(str)
  t0 = term(str)
  skip_space(str)

  while str[$pos] =~ /[\+\-]/
    op = str[$pos]
    $pos += 1

    skip_space(str)
    t1 = term(str)
    skip_space(str)

    t1 = mul_expr(t1, MINUS) if op == '-'
    t0 = add_expr(t0, t1)
  end

  t0
end

def term(str)
  skip_space(str)
  m0 = mult(str)
  skip_space(str)

  while str[$pos] =~ /[0-9a-z\(]/
    m1 = mult(str)
    skip_space(str)
    m0 = mul_expr(m0, m1)
  end

  m0
end

def mult(str)
  skip_space(str)

  m0 = [0] * 27

  case str[$pos]
  when '0'..'9'
    n = num(str)
    m0[26] = n
    return [m0]
  when 'a'..'z'
    v = str[$pos].ord - 'a'.ord
    $pos += 1
    skip_space(str)

    n = 1
    if str[$pos] == '^'
      $pos += 1
      skip_space(str)
      n = num(str)
      skip_space(str)
    end

    m0[v] = n
    m0[26] = 1
    return [m0]
  when '('
    $pos += 1
    skip_space(str)
    expr = expr(str)
    skip_space(str)
    $pos += 1
    return expr
  end
  nil
end

def num(str)
  n = 0
  while str[$pos] =~ /[0-9]/
    n = n * 10 + str[$pos].to_i
    $pos += 1
  end
  n
end

### main

loop do
  tstr = gets.strip
  break if tstr == '.'

  $pos = 0
  texpr = normalize(expr(tstr))
  #p [tstr, '=>' , texpr]

  loop do
    sstr = gets.strip
    break if sstr == '.'

    $pos = 0
    sexpr = normalize(expr(sstr))
    #p [sstr, '=>' , sexpr]

    puts (texpr == sexpr) ? 'yes' : 'no'
  end
  puts '.'
end

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

#define ll long long int
#define mp make_pair
#define pb push_back
using namespace std;

int main() {
    int a,b;
    cin >> a>> b;
    if(a == 2 || b == 2){
        printf("No");
    }
    else{
        printf("Yes");
    }
    return 0;
}

Measured memory_bytes: 256
n,a,b,c,d=map(int,input().split())
s=input()+"#"*2
f=False
for i in range(1,n+1):
    if s[i-1]+s[i]=="#"*2:
        if a<i<c or b<i<d:
            print("No")
            exit()
    else:
        if i>2:
            if s[i-2]+s[i-1]+s[i]=="."*3:
                if b<=i<=d:
                    f=True
else:
    if c<d:
        print("Yes")
    else:
        if f:
            print("Yes")
        else:
            print("No")

Measured memory_bytes: 3572
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <limits>
#include <numeric>
#include <type_traits>

#define roop(i, n) for(int i=0;i<n;i++)

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

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int myGCD(int a, int b) {
	while(1) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	swap(x, y);
	swap(x, z);
	cout << x << " " << y << " " << z << endl;;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define sum(v) accumulate(ALL(v),0)
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<" ";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    string s;
    cin>>s;
    string ans="";
    ll size = s.length();
for(ll i=0; i<size; i++) {
    if(i%2!=1){
        ans.push_back(s[i]);
    }
}

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


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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  vector<int> v(3);
  v.at(0) = a;
  v.at(1) = b;
  v.at(2) = c;
  sort(v.begin(), v.end());
  
  cout << v.at(0) << " " <<  v.at(1) << " " << v.at(2) << endl;

  return 0;
}


Measured memory_bytes: 3140
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    string s;
    cin>>s;
    string t="";
    rep(i,s.size())if(s[i]!='x')t+=s[i];
    string u=t;
    reverse(u.begin(),u.end());
    if(u!=t){
        cout<<-1<<endl;
        return 0;
    }
    int m=t.size();
    vector<int> cnt(m+11);
    int idx=0;
    rep(i,s.size()){
        if(s[i]=='x')++cnt[idx];
        else ++idx;
    }
    int ans=0;
    rep(i,(m+1)/2){
        ans+=abs(cnt[i]-cnt[m-i]);
    }
    cout<<ans<<endl;
    return 0;
}

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

int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
bool arr[4]={false};
if(a==1||b==1||c==1||d==1){
arr[0]=true;}
if(a==7||b==7||c==7||d==7){
arr[1]=true;}
if(a==9||b==9||c==9||d==9){
arr[2]=true;}
if(a==4||b==4||c==4||d==4){
arr[3]=true;}
int y;
for(y=0;y<4;y++){
if(arr[y]==false){
cout<<"NO";
break;}}
if(y==4){
cout<<"YES";}
return 0;}

Measured memory_bytes: 256
n = input()
x = map(int, raw_input().split())
c = 0
for i in range(n):
    mini = i
    for j in range(i, n):
        if x[j] < x[mini]:
            mini = j
    if i != mini:
        x[i], x[mini] = x[mini], x[i]
        c += 1
for e in x:
    print e,
print
print c

Measured memory_bytes: 4232
//ITP1_2_D#########################################
import java.util.*;
import java.io.*;

public class Main{

	public static void main(String[] args) throws Exception {
	
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();// br インスタンスのreadlineメソッドを利用
		//split関数で配列に入れる。
		String[] strArray=str.split(" ");

	
		//円と長方形のクラスからインスタンスを作成する
		Circle Ci =new Circle(Integer.parseInt(strArray[2]),Integer.parseInt(strArray[3]),Integer.parseInt(strArray[4]));
	
		Rectangle Re=new Rectangle(Integer.parseInt(strArray[0]),Integer.parseInt(strArray[1]));
		
		
		isCircleInRectangle(Re, Ci);
	}
    	
	public static void isCircleInRectangle(Rectangle rectangle, Circle circle) throws Exception{
		if (circle.getMaxX()<= rectangle.W
			&& circle.getMaxY() <=rectangle.H
			&& circle.getMinX()>=0
			&& circle.getMinY()>=0){
			System.out.println("Yes");
		} else{
			System.out.println("No");
		}
	}	
	
}

 class Circle{

	int x;
	int y;
	int r;
	//コンストラクタの記述
	Circle(int x_,int y_, int r_){
	this.x=x_;
	this.y=y_;
	this.r=r_;
	}
	
	int getMinX() {
		return  x - r;
	}
	int getMinY() {
		return  y - r;
	}
	int getMaxX() {
		return  x + r;
	}
	int getMaxY() {
		return  y + r;
	}
}
	
 class Rectangle{
	int H;
	int W;
	//コンストラクタの記述
	Rectangle(int W_, int H_){
	this.H=H_;
	this.W=W_;
	}
}



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

long long d, n, m;
vector<long long> shop;

int main() {
	while (cin >> d, d) {
		cin >> n >> m;
		shop.clear(); shop.resize(2*n);
		shop[0] = 0;
		for (int i = 1; i < n; i++) cin >> shop[i];
		sort(shop.begin(), shop.begin()+n);
		for (int i = n; i < 2*n; i++) shop[i] = shop[i-n]+d;

//		for (int i = 0; i < 2*n; i++) cout << shop[i] << ' ';
//		cout << endl;

		int total = 0;
		for (int i = 0; i < m; i++) {
			int house; cin >> house;
			long long close_left = *lower_bound(shop.begin(), shop.end(), house);
			if (close_left == house) continue;
			long long closer_right = *(lower_bound(shop.begin(), shop.end(), house)-1);
//			cout << house << ' ' << close_left << ' ' << closer_right << endl;
			total += min(close_left-house, house-closer_right);
		}

		cout << total << endl;
	}
	return 0;
}

Measured memory_bytes: 2608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main(void){
    int n,m,pos = -1,ans = 0;
    cin >> n >> m;
    pair<int,int> p[110000];
    for(int i = 0;i < m;i++){
        cin >> p[i].second;
        cin >> p[i].first;
        p[i].second--;
        p[i].first--;
    }
    sort(p,p+m);
    for(int i = 0;i < m;i++){
        if(p[i].second > pos){
            pos = p[i].first;
            pos--;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1152
#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;
    cin >> a >> b;
    string S = "";
    if (a < b)
    {
        for (int i = 0; i < b; i++)
        {
            S += to_string(a);
            // S.push_back((char)a);
            // S[i] = (char)a;
        }
    } else
    {
        for (int i = 0; i < a; i++)
        {
            S += to_string(b);
            // S.push_back((char)b);
            // S[i] = (char) b;
        }
    }
    
    cout << S << endl;
  return 0;
}


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

ll gcd(ll x, ll y){ return y ? gcd(y, x%y) : x; }

vector<pair<ll, int>> prime_factorization(ll n){
	vector<pair<ll, int>> res;
	for(ll i = 2; i * i <= n; i++){
		if(n % i) continue;
		res.emplace_back(i, 0);
		while(n % i == 0){
			n /= i;
			res.back().second++;
		}
	}
	if(n != 1) res.emplace_back(n, 1);
	return res;
}

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	
	vector<int> l(n), r(n);
	rep(i, n-1){
		l[i+1] = gcd(l[i], a[i]);
	}
	for(int i=n-1; i>0; i--){
		r[i-1] = gcd(r[i], a[i]);
	}
	int ans = 1;
	rep(i, n){
		ans = max(ans, (int) gcd(l[i], r[i]));
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

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

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int k; cin >> k;
    
    char c = s[k-1];
    string ans = "";
    rep(i, s.size()) ans += (s[i]==c)? c:'*';
    
    cout << ans << endl;
}

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

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

fn main() {
    let n: usize = read();
    let a: Vec<Vec<usize>> = (0..2)
        .map(|_| (0..n).map(|_| read::<usize>()).collect())
        .collect();

    let mut max = 0;
    for i in 0..n {
        let mut cnt = 0;
        for j in 0..n {
            if j < i      { cnt += a[0][j]; }
            else if j > i { cnt += a[1][j]; }
            else          { cnt += a[0][j] + a[1][j]; }
        }
        if cnt > max { max = cnt; }
    }

    println!("{}", max);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const ll MOD = 1e9+7;
const bool debug = 0;
//-----------------------------------------------//

int N;
int A[112345], B[112345], C[112345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", A + i);
	REP(i, N) scanf("%d", B + i);
	REP(i, N) scanf("%d", C + i);
	
	sort(A, A + N);
	sort(C, C + N);
	
	ll ans = 0;
	REP(i, N) {
		ans += (ll)(lower_bound(A, A+N, B[i]) - A) * (N - (upper_bound(C, C + N, B[i]) - C));
	}
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1408
#include <stdio.h>

int main(void){
  
  long long x;
  scanf("%lld", &x);
  
  long long ans;
  int a;
  
  ans = x / 11;
  ans *= 2;
  a = x % 11;
  
  
  if( a > 6 ) ans++;
  if( a > 0 ) ans++;
  
  printf("%lld", ans);
    
  return 0;
}

Measured memory_bytes: 128
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int a[364364];
int main()
{
	int n;lint out=0;
	cin>>n;
	rep(i,3*n) cin>>a[i];
	sort(a,a+3*n);reverse(a,a+3*n);
	rep(i,n) out+=a[i*2+1];
	cout<<out<<endl;
}


Measured memory_bytes: 1408
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(sc.hasNext()){
			int a = sc.nextInt();
			int b = sc.nextInt();
			ArrayList<Integer> list = new ArrayList<Integer>();
			StringBuffer ans = new StringBuffer();
			
			while(true){
				if(a%b==0){
					System.out.println(ans);
					break;
				}else if(list.indexOf(a%b)!=-1){
					System.out.println(ans);
					for(int i=0;i<ans.length();i++){
						if(i<list.indexOf(a%b)) System.out.print(" ");
						else System.out.print("^");
					}
					System.out.println();
					break;
				}else{
					list.add(a%b);
					a = a%b*10;
				}
				ans.append(a/b);
			}
		
		}
	}	
}

Measured memory_bytes: 21352
#include<iostream>

using namespace std;

int main() {
	int p1[10000], p2[10000], n, point1, point2, i;
	while (true) {
		point1 = 0;
		point2 = 0;
		cin >> n;
		if (n == 0) { break; }
		for (i = 0; i < n; i++) {
			cin >> p1[i] >> p2[i];
		}
		for (i = 0; i < n; i++) {
			if (p1[i] == p2[i]) {
				point1 += p1[i];
				point2 += p2[i];
			}
			else if (p1[i] > p2[i]) {
				point1 += p1[i] + p2[i];
			}
			else {
				point2 += p1[i] + p2[i];
			}
		}
		cout << point1 << ' ' << point2 << endl;
	}
	return 0;
}

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

using namespace std;

int main(int argc, const char *argv[]) {
  int a, b;
  cin >> a >> b;
  if (b % a == 0) {
    cout << a + b << '\n';
  } else {
    cout << b - a << '\n';
  }
  return 0;
}

Measured memory_bytes: 256
using System;

class Program {
    static void Main() {
        for (string line; (line = Console.ReadLine()) != "0";) {
            var n = int.Parse(line);
            var ices = new int[10];
            
            for (var i = 0; i < n; i++) {
                var kind = int.Parse(Console.ReadLine());
                ices[kind]++;
            }

            foreach (var x in ices) {
                Console.WriteLine(x == 0 ? "-" : new string('*', x));
            }
        }
    }
}

Measured memory_bytes: 8948
#include<iostream>
using namespace std;
typedef long long int ll;

int main(){
	int n;
	cin>>n;
	ll i, j, x, y, z, sum[3] = {}, ans;
	ll a[n][3];
	for(i=0; i<n; i++) cin>>a[i][0]>>a[i][1]>>a[i][2];
    for(j=0; j<3; j++) sum[j] = a[0][j];
    for(i=1; i<n; i++){
        x = max(sum[1], sum[2]);
        y = max(sum[0], sum[2]);
        z = max(sum[0], sum[1]);
        sum[0] = a[i][0] + x;
        sum[1] = a[i][1] + y;
        sum[2] = a[i][2] + z;
    }
    ans = max(max(sum[0], sum[1]), sum[2]);
    cout<<ans;
    return 0;
}


Measured memory_bytes: 5896
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <vector>
#include <string>
using namespace std;
const int INF = 1e9 + 5;
int main() {
    
    int n;
    cin >> n;
    vector<int> v(n);

    for(int i = 0; i < n; i++) {
    	cin >> v[i];
    }
   int ev = 0;
   int in = 0;
   for(int j = 0; j < n; j++) {

   	    if(v[j] % 2 == 0) {
   	    	ev++;
   	    	if(v[j] % 3 == 0 || v[j] % 5 == 0) {
                  in++;
   	    		
   	    	} 
   	    }
   }
  cout << (ev == in ? "APPROVED" : "DENIED") << "\n";
	return 0;
}

Measured memory_bytes: 256
from collections import deque


Q=deque(list(input()))

q=int(input())

cnt=0

for i in range(q):
  x=input()
  if x[0]=='1':
    cnt+=1
    cnt%=2
    
  elif x[0]=='2':
    if x[2]=='1':
        if cnt%2==0:
            Q.appendleft(x[4])
        else:
            Q.append(x[4])

    else:
        if cnt%2==0:
            Q.append(x[4])
        else:
            Q.appendleft(x[4])
      
if cnt%2==1:
  Q.reverse()


print(''.join(Q))

Measured memory_bytes: 14108
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();

    long[] a = new long[n];

    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
    }

    long[][] dp = new long[n + 1][2];
    // dp(i, 0) : A0...Ai, wo Ai+1 flipping,
    // dp(i, 1) : A1...Ai, wi Ai+1 flipping.

    dp[0][0] = 0;
    dp[0][1] = -1000000001L;

    for (int i = 0; i < n; i++) {
      // dp[i][0] + a[i] (Ai+1 wo flipping).
      // dp[i][1] - a[i] (Ai+1 wi flipping).
      dp[i + 1][0] = Math.max(dp[i][0] + a[i], dp[i][1] - a[i]);

      // dp[i][0] - a[i] (Ai+1 wi flipping).
      // dp[i][1] + a[i] (Ai+1 wo flipping).
      dp[i + 1][1] = Math.max(dp[i][0] - a[i], dp[i][1] + a[i]);
    }
    os.println(dp[n][0]);
  }
}

Measured memory_bytes: 61332
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        if(0<A&&0<B&&A<10&&B<10){
            System.out.println(A*B);
            return;
        }
		System.out.println("-1");
	}
}

Measured memory_bytes: 35704
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,x,l,i,sum=0;
    cin>>n>>x;
    for(i=0;i<n;i++){
        cin>>l;
        sum+=l;
        if(sum>x) break;
    }
    cout<<i+1<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define REP(i, n) for (signed long long i = 0; i < (n); i++)
#define MOD long(1e9 + 7)
#define INF 98765431219876543
#define bitcnt(a) (ll) __builtin_popcount((a))
#define lb(a, b) lower_bound((a).begin(), (a).end(), (b))
#define ub(a, b) upper_bound((a).begin(), (a).end(), (b))
using namespace std;

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

const int MAX_N = 200005;
long long fact[MAX_N];
long long fact_inv[MAX_N];
long long bin_pow_mod(long long x, long long y) {
  if (x == 0)
    return 0;
  long long prod = 1;
  while (y > 0) {
    if (y & 1) {
      prod = (prod * x) % MOD;
    }
    x = (x * x) % MOD;
    y >>= 1;
  }
  return prod % MOD;
}
void init_fact() {
  fact[0] = 1, fact_inv[0] = 1;
  for (int i = 1; i < MAX_N; ++i) {
    fact[i] = (fact[i - 1] * i) % MOD;
    fact_inv[i] = bin_pow_mod(fact[i], MOD - 2);
  }
}
ll calc(ll all, ll k) {
  if (k > all) {
    return 0;
  }
  return fact[all] * fact_inv[all - k] % MOD * fact_inv[k] % MOD;
}

int main() {
  ll n, m;
  map<ll, ll> prime;
  cin >> n >> m;

  ll kari = m;
  for (int i = 2; i * i <= m; i++) {
    while (kari % i == 0) {
      kari /= i;
      prime[i]++;
    }
  }
  if (kari != 1) {
    prime[kari]++;
  }
  init_fact();
  ll ans = 1;
  for (auto &a : prime) {
    //cout << a.first << " " << a.second << endl;
    ans *= calc(n - 1 + a.second, a.second);
    ans %= MOD;
  }

  cout << ans << endl;
}

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

while True:
    if abs(N - K) >= N:
        break
    else:
        if N >= K:
            N = N - (N // K) * K
        else:
            N = N - (N // (2 * N - K)) * (2 * N - K)

print(N)

Measured memory_bytes: 9164
//header{{{
#include<bits/stdc++.h>
  
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define Fixed fixed << setprecision(12)
#define int int64_t
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod = 1e9+7; 
constexpr int MOD = 998244353;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T> using min_heap = priority_queue<T,vector<T>,greater<T> >;
template <class T> using max_heap = priority_queue<T>;
template <class A, class B> using umap = unordered_map<A,B>;
  
int gcd(int a,int b){ return b ? gcd(b,a % b) : a;}
int lcm(int a,int b){ return a / gcd(a,b) * b;}

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

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

    int n;
    cin >> n;

    int res = 1;
    rep(i,n){
        int t;
        cin >> t;
        res = lcm(res,t);
    }

    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int N  = sc.nextInt();
      
        Map<Integer,String> m = new TreeMap<>(new Comparator<Integer>(){
           public int compare(Integer m , Integer n){
             return((Integer)m).compareTo(n) *-1;
           }
        });
      
        String[] shop01 = new String[N];
        int[] score01 = new int[N];
        
         for(int i = 0; i < N ; i++){
           shop01[i] = sc.next();
           score01[i] = sc.nextInt();
         }
          
        for(int i = 0; i < N ; i++){
           m.put(score01[i],shop01[i]);
        }
         

       Arrays.sort(shop01);
      
       List<Integer> ans = new ArrayList<>();
       for(int i = 0; i < N ; i++){
         String same = shop01[i];
         for(Map.Entry<Integer,String> m1 : m.entrySet()){
           if(same.equals(m1.getValue())){
             int num = m1.getKey();
             for(int j = 0; j < N ; j++){
               if(score01[j] == num){
                 ans.add(j+1);
               }
             }
           }
         }
       }
      
      List<Integer> answer = ans.stream().distinct().collect(Collectors.toList());
      for(int i = 0; i < N; i++){
        System.out.println(answer.get(i));
      }
      
	}
}

Measured memory_bytes: 38224
#include <queue>
#include <cstdio>
#include <set>
#include <string>
#include <stack>
#include <cmath>
#include <climits>
#include <map>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#define  LL long long
#define  ULL unsigned long long
using namespace std;

char s[220000];

int main() {
    scanf("%s", s);
    int n = strlen(s);
    map<char, int> M;
    LL ans = 0;
    for(int i = 0; i < n; i++)
        ans += i-M[s[i]], M[s[i]]++;
    cout<<ans+1<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
const ll MOD2 = 998244353;
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    int N, K;
    cin >> N >> K;
    int h[N];
    rep(i, N) cin >> h[i];
    sort(h, h+N);
    int ans = inf;
    rep(i, N-K+1){
        ans = min(ans, h[i+K-1]-h[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long H, long long W, long long A, long long B){
  For(i,H){
    For(j,W){
      if((i<B)==(j<A)){
        cout<<0;
      }else{
        cout<<1;
      }
    }
    cout<<endl;
  }
}

int main(){
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(H, W, A, B);
    return 0;
}


Measured memory_bytes: 1280
// Ver19.02
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define INF 1 << 29
#define LLINF 4545454545454545454
#define MOD 1000000007
#define ll long long
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))
int upll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? -1 : *(ll *)a > *(ll *)b ? 1 : 0; }
int downll(const void *a, const void *b) { return *(ll *)a < *(ll *)b ? 1 : *(ll *)a > *(ll *)b ? -1 : 0; }
void sortup(ll *a, int n) { qsort(a, n, sizeof(ll), upll); }
void sortdown(ll *a, int n) { qsort(a, n, sizeof(ll), downll); }

int main()
{
  int n;
  scanf("%d", &n);
  printf("%d\n", 24 - n + 24);
  return 0;
}

Measured memory_bytes: 128
function main(input) {
  var list = input[1].split(" ");
  var ans = "APPROVED";
  list.forEach(v=>{
    if(v%2==0){
      if(!(v%5==0||v%3==0)){
        ans = "DENIED";
      }
    }
  });
  console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split("\n"))


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair


int main(){
    ll N; cin>>N;
    ll a[N+1];
    for(int i=1;i<=N;++i){
        cin >> a[i];
    }
    ll left_r[N+1];
    ll left_b[N+1];
    ll left_g[N+1];

    left_r[1] = 0;
    left_b[1] = 0;
    left_g[1] = 0;
    
    for(int i=1;i<N;++i){
        left_r[i+1] = left_r[i];
        left_b[i+1] = left_b[i];
        left_g[i+1] = left_g[i];
        if(left_r[i]==a[i]){
            left_r[i+1] += 1;
        }else if(left_b[i]==a[i]){
            left_b[i+1] += 1;
        }else{
            left_g[i+1] += 1;
        }
    }
    
    ll ans = 1;
    for(int i=1;i<=N;++i){
        ll num = 0;
        num += (left_r[i]==a[i]);
        num += (left_b[i]==a[i]);
        num += (left_g[i]==a[i]);
        ans *= num;
        ans %= MOD;
    }
    
    cout << ans << "\n";
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define EPS (1e-10)    //誤差
typedef complex<double> P;

//内積
double dot(P a, P b){
    return (a.real() * b.real() + a.imag() * b.imag());
}

P projection(P a, P b, P c){
    return a + dot(b-a, c-a) / norm(b-a) * (b-a);
}

P reflection(P a, P b, P c){

    P h = projection(a, b, c);
    P res;
    res.real() = 2 * h.real() - c.real();
    res.imag() = 2 * h.imag() - c.imag();
    return res;    
}

int main(){

    P p1, p2;
    cin >> p1.real() >> p1.imag() >> p2.real() >> p2.imag();
    int q; cin >> q;
    for(int i = 0; i < q; i++){
        int x, y; cin >> x >> y;
        P ans = reflection(p1, p2, P(x, y));
        printf("%.10f %.10f\n", ans.real(), ans.imag());
    }
}


Measured memory_bytes: 3328
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
for i in range(N):
    tmp = s[i]
    cnt = 0
    for i in range(N):
        if tmp == s[i]:
            cnt += 1
    for j in range(M):
        if tmp == t[j]:
            cnt -= 1
    ans = max(ans,cnt)
      
print(ans)     
    
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_(i, n, m) for (int i = n; i < (int)(m); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define stoi stoll
//#define _GLIBCXX_DEBUG


signed main() {
  int N; cin >> N;
  vector<pair<int,int>> v(N);
  rep(i, N) {
    int a, b; cin >> a >> b;
    v[i] = make_pair(b, a);
  }
  sort(all(v));
  
  int t = 0;
  for(auto p : v) {
    t += p.second;
    if(t > p.first) {
      cout << "No" << endl;
      return 0;
    }
  }
  
  cout << "Yes" << endl;
        

}


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

using namespace std;

//int aa[] = {0, 2,3,4,5,6,7,8,9,10,11,12,13,1} ;

int main () {
    int a, b; cin >> a >> b;
    if (a == 1) {
        a += 13;
    }
    if (b == 1) {
        b += 13;
    }
    if (a > b) {
        cout << "Alice";
    } else if (a < b){
        cout << "Bob";
    } else {
        cout << "Draw";
    }
    return 0;
}


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

string solve(int arr[], int n){

    for(int i=0;i<n;++i){
        if(arr[i]%2==0){
            if(arr[i]%3==0 || arr[i]%5==0){
                continue;
            }else{
                return "DENIED";
            }
        }
    }
    return "APPROVED";
}
int main() {
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;++i){cin>>arr[i];}
    cout<<solve(arr, n)<<endl;

    return 0;
}


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

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

	int sum = 0;

	for(int i = 0; i < m; i++){
		int a;
		cin >> a;
		sum += a;
	}

	if(sum > n){
		cout << "-1" << endl;
	} else {
		cout << n - sum << endl;
	}
}


Measured memory_bytes: 3636
//#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	int x = (c + b - 1) / b;
	int y = (a + d - 1) / d;
	cout << (x <= y ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define N 250
int it = 0, tree[N + 1];
int main() {
	int n, i;
	
	scanf("%d", &n);
	for (i = 1; i <= n; i++) {
		scanf("%d", &tree[i]);
		it++;
	}

	for (i = 1; i <= n; i++) {
		printf("node %d: key = %d, ", i, tree[i]);
		if (i / 2 > 0)
			printf("parent key = %d, ", tree[i / 2]);
		if (i * 2 <= it)
			printf("left key = %d, ", tree[2 * i]);
		if (i * 2 + 1 <= it)
			printf("right key = %d, ", tree[2 * i + 1]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>

int main(void)
{
	int a,b,c,d;
	int n,num;
	
	
	
	while(scanf("%d",&n)!=EOF)
	{
		num=0;
		if(n<=36)
		{
			for(d=0;d<=9;d++)
			{
				for(c=0;c<=9;c++)
				{
					for(b=0;b<=9;b++)
					{
						for(a=0;a<=9;a++)
						{
							if(a+b+c+d==n)
								num++;
						}
					}
				}
			}
		}
		printf("%d\n",num);
	}
	
	
	return 0;
}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A, B;
  cin >> A >> B;
  if(A > 0){
    cout << "Positive" << endl;
  }
  else if(B < 0 && (B - A)%2  != 0){
    cout << "Positive" << endl;
  }
  else if(B < 0){
    cout << "Negative" << endl;
  }
  else if(A * B <= 0){
    cout << "Zero" << endl;
  }
}

Measured memory_bytes: 256
a, b, n = map(int, input().split())
d, m = divmod(n, b)
if m>=b-1: x = d*b + b-1
else: x = max(0, d*b-1)
y = d*b+m
print(max((a*x)//b - a*(x//b), (a*y)//b - a*(y//b)))

Measured memory_bytes: 9136
#coding:utf-8

n = int(input())
mtrx = [[0 for _ in range(10)] for _ in range(10)]

for i in range(1, n + 1):
    num = str(i)
    s = int(num[0]) - 1
    e = int(num[-1]) - 1

    mtrx[s][e] += 1
    
sumv = 0
for i in range(10):
    for j in range(10):
        sumv += mtrx[i][j] * mtrx[j][i]
print(sumv)

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>

template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}

template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}

template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

#endif
#if __has_include(<any>)
#include <any>
#endif

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

using namespace std;

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

template <class T>
istream& operator>>(istream& is, vector<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int n;
    cin >> n;
    switch(n%10){
        case 2: case 4: case 5: case 7: case 9:
            cout << "hon\n";
            break;
        case 0: case 1: case 6: case 8:
            cout << "pon\n";
            break;
        case 3:
            cout << "bon\n";
            break;
    }
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    solution();
    return 0;
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=1e6+5,inf=0x3f3f3f3f;
#define mst(a) memset(a,0,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first 
#define se second
int a[N],p[M];
int main(){
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for(int i=1;i<=n;i++){
		 if(!p[a[i]]){
		 	 if(a[i]!=a[i+1]) ans++;
		 	 for(int j=a[i];j<=a[n];j+=a[i])
		 	 	p[j]=1;
		 }
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8280
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

int main (void)
{
    intmax_t r;
    intmax_t ans = 0;

    scanf("%jd", &r);

    ans = 3 * r * r;

    printf("%jd\n", ans);

    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
  	cin >> N;
  set<string> S;
  for(int i = 0; i < N; i ++){
    	string a;
    	cin >> a;
    	S.insert(a);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 19252
#include "atcoder/all"
#include "bits/stdc++.h"
using namespace std;
using namespace atcoder;
using mint = modint998244353;
using vm = vector<mint>;
int main() {
	int N;
	cin >> N;
	int N2 = N * 2;
	vector<int>A;
	{
		map<int, int>mp;
		for (int i = 0; i < N * 2; ++i) {
			int h;
			cin >> h;
			mp[h]++;
		}
		for (auto p : mp) {
			A.push_back(p.second);
		}
	}
	vm f(N2 + 1);
	vm invf(N2 + 1);
	vm f2(N + 1);
	{
		f[0] = 1;
		for (int i = 0; i < N2; ++i) {
			f[i + 1] = f[i] * (i + 1);
		}
		invf[N2] = 1 / f[N2];
		for (int i = N2; i >= 1; --i) {
			invf[i - 1] = invf[i] * i;
		}
		f2[0] = 1;
		for (int i = 0; i < N; ++i) {
			f2[i + 1] = f2[i] * (2 * i + 1);
		}
	}
	int M = A.size();
	vector<vm>d(M);
	for (int i = 0; i < M; ++i) {
		int na = A[i];
		int e = na / 2;
		d[i] = vm(e + 1);
		for (int j = 0; j < e + 1; ++j) {
			d[i][j] = f[na] * invf[na - 2 * j] * invf[j * 2] * f2[j];
		}
	}
	while (d.size() > 1) {
		vector<vm> p;
		swap(d, p);
		for (int i = 0; i < p.size(); i += 2) {
			int j = i + 1;
			if (j >= p.size()) {
				d.emplace_back(p[i]);
				break;
			}
			d.emplace_back(convolution(p[i], p[j]));
		}
	}
	mint ans = 0;
	for (int i = 0; i < d[0].size(); ++i) {
		mint now = d[0][i] * f2[N - i];
		if (1 == i%2) {
			ans -= now;
		}
		else {
			ans += now;
		}
	}
	cout << ans.val() << endl;
	return 0;
}


Measured memory_bytes: 12864
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
#define all(v) (v).begin(), (v).end()
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

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

	int A, B, C;
	cin >> A >> B >> C;
	int rsl = 0;

	rsl += B;
	rsl += min(B, C);
	C -= min(B, C);
	rsl += min(A, C);
	C -= min(A, C);
	if(C > 0) rsl++;
	cout << rsl << endl;

				

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
const int MAX_N = 15;
int x[MAX_N],l[MAX_N],r[MAX_N];
int kase;
void dfs(int i,int j,int k)
{
	if(i>10)
	{
		kase=1;
		return;
	}
	if(kase)
	{
		return;
	}
	if(x[i]>l[j-1])
	{
		l[j]=x[i];dfs(i+1,j+1,k);
	}
	if(x[i]>r[k-1])
	{
		r[k]=x[i];dfs(i+1,j,k+1);
	}
}
int main()
{
	int t; 
	scanf("%d",&t);
	while(t--)
	{
		for(int i=1;i<=10;++i)
		{
			scanf("%d",&x[i]);
		}
		kase=0;
		dfs(1,1,1);
		if(kase)
		{
			printf("YES\n");
		}
		else
		{
			printf("NO\n");
		}
	}
	return 0;
} 


Measured memory_bytes: 2576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;

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

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 long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}



int main() {
    int n,ans = 0;
    cin >> n;
    for (int i = 1; i <= n ; ++i) {
        for (int j = 1; j <= n/i; ++j) {
            if(i*j < n) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
N,K = map(int,input().split())
h = list(map(int,input().split()))

dp = [0]*N

#iは知りたいdp[i]
for i in range(1,N):
    #for j in range(max(i-K,0),i)はジャンプできる段数
    dp[i] = min(dp[j]+abs(h[j]-h[i]) for j in range(max(i-K,0),i))
print(dp[N-1])

Measured memory_bytes: 53216
using System;

class main{
  static void Main(string[] args){
    string[] s = Console.ReadLine().Split(" ");
    int tap = int.Parse(s[0])-1;
    int sockets = int.Parse(s[1]);
    
    for(int i = 0; i != -1; i++){
      if(tap * i + 1>= sockets){
        Console.Write(i);
        break;
      }
    }
  }
}

Measured memory_bytes: 27504
import java.util.*;

public class Main {
    private static Scanner scanner;

    public static int[] inputIntArray(int n) {
        int[] res = new int[n];
        for (int i = 0; i < n; ++i) {
            res[i] = scanner.nextInt();
        }

        return res;
    }

    // public static String[] <T> ToStringArray(T[] arr) {
    // String[] res = new String[arr.length];
    // for(int i = 0; i < arr.length; ++i) {
    // res[i] = String.valueOf(arr[i]);
    // }

    // return res;
    // }

    private static List<Integer> asIntergerList(int[] arr) {
        List<Integer> intList = new ArrayList<Integer>();
        for (int i = 0; i < arr.length; i++) {
            intList.add(arr[i]);
        }

        return intList;
    }

    private static int[][] deepCopy(int[][] arr) {
        int[][] res = new int[arr.length][];
        for (int i = 0; i < arr.length; ++i) {
            res[i] = arr[i].clone();
        }

        return res;
    }

    private static String asString(int[][] arr) {
        String str = new String();

        for (int i = 0; i < 2; ++i) {
            str += "" + arr[i][0] + arr[i][1] + arr[i][2] + arr[i][3];
        }

        return str;
    }

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

        int[] counter = new int[26];
        try {
            while (true) {
                String s = scanner.nextLine().toLowerCase();

                for (int i = 0; i < s.length(); ++i) {
                    char c = s.charAt(i);
                    if ('a' <= c && c <= 'z') {
                        ++counter[c - 'a'];
                    }
                }

            }
        } catch (Exception e) {

        }

        for (int i = 0; i < 26; ++i) {
            System.out.printf("%c : %d\n", 'a' + i, counter[i]);
        }
    }
}



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

const int MAX_N = 100010;
int N,M;
vector<vector<int>> graph;
int dp[MAX_N];

int dfs(int i){
    int cnt = 0;
    
    if(dp[i] != -1) return dp[i];
    if(graph[i].empty()) return 0;
    for(int u :graph[i]){
        cnt = max(dfs(u) + 1,cnt);
    }

    return dp[i] = cnt;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> N >> M;
    
    graph.resize(N);
    
    for(int i = 0; i < M; i++){
        int x,y;
        cin >> x >> y;
        
        x--;
        y--;
        
        graph[x].push_back(y);
    }
    
    for(int i = 0; i < MAX_N; i++) dp[i] = -1;
    
    int ans = 0;
    
    for(int i = 0; i < N; i++){
        dfs(i);
    }
    
    for(int i = 0; i < N; i++) ans = max(ans,dp[i]);
    
    cout << ans << endl;

}


Measured memory_bytes: 8192