akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

namespace Part2 {
    class Program {
        static void Main(string[] args) {
            var input = Console.ReadLine();
            var num = int.Parse(input);
            var counter = 0;
            for (var i = 0; i < 10; i++) {
                for (var j = 0; j < 10; j++) {
                    if (i * j == num) counter++;
                }
            }
            if(counter > 0) {
                Console.WriteLine("Yes");
            } else {
                Console.WriteLine("No");
            }
        }
    }
}


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

const int maxn = 100010;
int n, m, v, p, a[maxn];
long long s[maxn];

int main() {
    scanf("%d %d %d %d", &n, &m, &v, &p);
    for (int i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }
    sort(a + 1, a + n + 1, greater<int>());
    for (int i = 1; i <= n; i++) {
        s[i] = s[i - 1] + a[i];
    }
    int ans = 0, lst = 1;
    for (int i = 1; i <= n; i++) {
        if (a[i] == a[i - 1]) {
            ans += lst;
        } else {
            if (i <= p) {
                lst = 1, ans++;
            } else {
                if (a[p] > a[i] + m) {
                    lst = 0;
                } else {
                    long long sum = 1LL * (a[i] + m) * (i - p) - (s[i - 1] - s[p - 1]);
                    long long r = 1LL * max(0, v - (p - 1) - (n - i + 1)) * m;
                    if (r <= sum) lst = 1, ans++;
                    else lst = 0;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>

using namespace std;
const int mod = 1e9+7;
int a[10010];
int main()
{
    int n;
    while(~scanf("%d", &n))
    {
        long long ans = 1;
        memset(a, 0, sizeof(a));
        for(int j = 2; j <= n; j++)
        {
            int k = j;
            for(int i = 2;i < 10000 && k != 1; i++)
            {
                while(k%i == 0)
                {
                    a[i]++;
                    k /= i;
                }
            }
        }
        for(int i = 2;i < 10000;i++)
            if(a[i]) ans = (ans*(a[i] + 1))%mod;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  ll k,a,b; cin >> k >> a >> b;
  ll now=1;
  if(now+k<a){
    cout<<now+k<<endl;
    return 0;
  }
  k-=a-now;
  now=a;
  
  if(b-a<=2){
    cout<<now+k<<endl;
    return 0;
  }
  now+=(k/2)*(b-a);
  now+=k-k/2*2;
  cout<<now<<endl;
}


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

int main() {
    int h, w;
    while (1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for (int i = 0;i < h;i++){
            for (int j = 0;j < w;j++){
                if((i +j) % 2 == 0){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << "\n";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
using namespace std;
int a,c;
int b=1;
int main(){
  cin>>a;
  for(int i=0;i<a;i++){
    cin>>c;
    if((c%2==0)&&(c%3!=0)&&(c%5!=0))b=0;
  }
  if(b)cout<<"APPROVED"<<endl;
  else cout<<"DENIED"<<endl;
}

Measured memory_bytes: 256
N, T = map(int, input().split(" "))
path = [list(map(int, input().split(" "))) for i in range(N)]
path = [path[i] for i in range(N) if path[i][1] <= T]
path.sort()
if path:
    print(path[0][0])
else:
    print("TLE")

Measured memory_bytes: 3064
#include <stdio.h>
#include <math.h>

#define diff(a, b) ((a > b) ? (a - b) : (b - a))

double	minute_hand_degree(int m)
{
	return ((long double)m * 6);
}

double	hour_hand_degree(int h, int m)
{
	return ((long double)h * 30 + (long double)m / 2);
}

double	triangle_len(double a, double b, double degree)
{
	return (sqrt(a * a + b * b - 2 * a * b * cos(degree * M_PI / 180)));
}

int		main(void)
{
	int			A, B, H, M;
	long double	deg, len;

	scanf("%d %d %d %d", &A, &B, &H, &M);
	deg = diff(hour_hand_degree(H, M), minute_hand_degree(M));
	len = triangle_len((long double)A, (long double)B, deg);
	printf("%20.20Lf\n", len);
	return (0);
}

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

typedef long long ll;
typedef pair<int,int> ii;

const int mod=1e9+7;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; string s; cin>>n>>s;
	map<char,ll> ct;
	for (const char &ch : s)
		ct[ch]++;
	ll ret=1;
	for (const auto &it : ct)
		ret=(ret*(it.second+1))%mod;
	ret--;
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 512
n = int(input())
a = list(map(int,input().split()))
hold = 0
money  = 1000
for i in range(n-1):
    if a[i+1] > a[i]:#buy
        hold += money//a[i]
        money = money % a[i]
    elif a[i+1] < a[i]:#sell
        money += hold*a[i]
        hold = 0
print(money+a[n-1]*hold)

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second

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

signed main ()
{
    fastio
    lli a[5] , sum = 0 , la , la1 ;
    loopcin(5 , a) ;
    la = 10 - a[0] % 10 ;
    la1 = 0 ;
    forr(1, 5){
        if (la <= 10 - a[i] % 10 && a[i] % 10 != 0){
            la = 10 - a[i] % 10 ;
            la1 = i ;
        }
    }
    loop(5){
        if (i != la1){
            if (a[i] % 10 != 0)
                a[i] += 10 - (a[i] % 10) ;
            sum += a[i]  ;
        }
    }
    sum += a[la1] ;
    cout << sum << endl ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



Measured memory_bytes: 256
while True:
    try:
        a=[int(i) for i in input().split()]
        b=[int(i) for i in input().split()]
    except:
        break
    hit,blow=0,0
    for i,j in zip(a,b):
        if i==j:
            hit+=1
        elif j in a:
            blow+=1
    print(hit,blow)

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

int main() {
  long long A,B,K;
  cin>>A>>B>>K;
  if(A>K) {
    cout<<A-K<<endl;
    cout<<B<<endl;
  }
  else if(A+B>K){
    cout<<0<<endl;
    cout<<B-(K-A)<<endl;
  }
  else {
    cout<<0<<endl;
    cout<<0<<endl;
  }
}


Measured memory_bytes: 256
SX, SY, TX, TY = [int(n) for n in input().split()]

def main():
    xd = TX - SX
    yd = TY - SY
    first = ['R' * xd, 'U' * yd, 'L' * xd, 'D' * yd]
    second = ['D', 'R' * (xd + 1), 'U' * (yd + 1), 'L', 'U', 'L' * (xd + 1), 'D' * (yd + 1), 'R']

    ans = first + second
    print(''.join(ans))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#pragma GCC optimize("O3") //コンパイラ最適化用

#define _GLIBCXX_DEBUG //配列に[]でアクセス時のエラー表示
#include <algorithm>   //sort,二分探索,など
#include <bitset>      //固定長bit集合
#include <chrono>      //実行時間計測
#include <cmath>       //pow,logなど
#include <complex>     //複素数
#include <deque>       //両端アクセスのキュー
#include <functional>  //sortのgreater
#include <iomanip>     //setprecision(浮動小数点の出力の誤差)
#include <iostream>    //入出力
#include <iterator>    //集合演算(積集合,和集合,差集合など)
#include <map>         //map(辞書)
#include <numeric>     //iota(整数列の生成),gcdとlcm,accumulate
#include <queue>       //キュー
#include <set>         //集合（順序保持）
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility> //pair
#include <vector>  //可変長配列
using namespace std;
typedef long long ll;
typedef long double ld;

#define REP(i, n) for (int i = 0; i < ll(n); i++)
#define REPD(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = a; i < ll(b); i++)
#define FORD(i, a, b) for (int i = a; i > ll(b); i--)
// xにはvectorなどのコンテナ
#define ALL(x) x.begin(), x.end()
#define SIZE(x) ll(x.size()) // sizeをsize_tからllに直しておく
const long long INF = 1e12;
const int MOD = 1e9 + 7;
#define MAXR 100000 // 10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define Umap unordered_map
#define Uset unordered_set
#define int long long
const unsigned int BIT_FLAG_0 = (1 << 0); // 0000 0000 0000 0001
const unsigned int BIT_FLAG_1 = (1 << 1); // 0000 0000 0000 0010
const unsigned int BIT_FLAG_2 = (1 << 2); // 0000 0000 0000 0100
const unsigned int BIT_FLAG_3 = (1 << 3); // 0000 0000 0000 1000
const unsigned int BIT_FLAG_4 = (1 << 4); // 0000 0000 0001 0000
const unsigned int BIT_FLAG_5 = (1 << 5); // 0000 0000 0010 0000
const unsigned int BIT_FLAG_6 = (1 << 6); // 0000 0000 0100 0000
const unsigned int BIT_FLAG_7 = (1 << 7); // 0000 0000 1000 0000

// https://qiita.com/Lily0727K/items/06cb1d6da8a436369eed#c%E3%81%A7%E3%81%AE%E5%AE%9F%E8%A3%85
void print() { cout << endl; }

template <class Head, class... Tail> void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail) != 0)
        cout << " ";
    print(forward<Tail>(tail)...);
}

template <class T> void print(vector<T> &vec) {
    for (auto &a : vec) {
        cout << a;
        if (&a != &vec.back())
            cout << " ";
    }
    cout << endl;
}

template <class T> void print(vector<vector<T>> &df) {
    for (auto &vec : df) {
        print(vec);
    }
}

void add(long long &a, long long b) {
    a += b;
    if (a >= MOD)
        a -= MOD;
}
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
#include <cmath>
#include <iostream>

signed main() {

    int r;
    cin >> r;
    print(r * r);
}


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

int main()
{
  int n;
  cin >>n;
  int max=0;int ans=0;
  for(int i=1;i<=n;i++){
    int count=0;
    int j=i;
    while(j>=1){
      j=j/2; 
      count++;
    }
    if(count>max) {
      ans=i;
      max = count;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    int N = scanner.nextInt();
    long sum = 0;
    for(long i = 1;i < N + 1;i++){
      if(!(i % 3 == 0 || i % 5 == 0)){
        sum = sum + i;
      }
    }
    System.out.println(sum);
  }
}

Measured memory_bytes: 27100
#include <algorithm>
#include <atcoder/all>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

int main()
{
    int n, m;
    cin >> n >> m;
    atcoder::dsu uf(n);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        uf.merge(a, b);
    }

    int component = uf.groups().size();
    cout << component - 1 << endl;
    return 0;
}

Measured memory_bytes: 8364
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include<numeric>
#include<cmath>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vll;
const ll inf = 1LL << 60;

int main(){
    cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
    string S;
    cin>>S;
    REP(i,3){
        cout<<S[i];
    }
    cout<<endl;
}

Measured memory_bytes: 3640
n, m = map(int, input().split())

cond = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    for i in range(10):
        num = str(i)
        check = True
        for j in range(m):
            if num[cond[j][0] - 1] != str(cond[j][1]):
                check = False
        if check == True:
            print(i)
            break
    else:
        print(-1)
else:
    for i in range(10**(n-1), 10**n):
        num = str(i)
        check = True
        for j in range(m):
            if num[cond[j][0] - 1] != str(cond[j][1]):
                check = False
        if check == True:
            print(i)
            break
    else:
        print(-1)

Measured memory_bytes: 3064
import collections
import sys
N,K=map(int,raw_input().split())
a=[]
a=collections.Counter( map(int,raw_input().split()) )
b=sorted(a.items(), key=lambda x:x[1])

if len(b)=="K":
	print 0
	sys.exit()
else:
	sum=0
	for i in range(len(b)-K):
		sum+=b[i][1]
	else:
		print sum


Measured memory_bytes: 43596
import java.util.Scanner;
import java.util.ArrayList;
public class Main {
    public static void main (String[] args) {
	Scanner scan = new Scanner(System.in);
	String[] initial = scan.nextLine().split(" ");
	int n = Integer.parseInt(initial[0]);
	int q = Integer.parseInt(initial[1]);
	ArrayList<Process> processes = new ArrayList<Process>();
	for (int i = 0; i < n; i++) {
	    String[] input = scan.nextLine().split(" ");
	    String name = input[0];
	    int time = Integer.parseInt(input[1]);
	    Process p = new Process(name, time);
	    processes.add(p);
	}
	
	int processTime = 0;
	while (!processes.isEmpty()) {
	    Process p = processes.remove(0);
	    if (p.time > q) {
		processTime += q;
	    } else {
		processTime += p.time;
	    }
	    p.time = p.time - q;
	    if (p.time > 0) {
		processes.add(p);
	    } else {
		System.out.println(p.name + " " + processTime);
	    }
	}
    }
    
}
class Process {
    String name;
    int time;
    Process (String name, int time) {
	this.name = name;
	this.time = time;
    }
}

Measured memory_bytes: 107088
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(int i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    vector<int> a(s.size() + 1);
    rep (i, s.size()) a[i_len - i - 1] = (int)(s[i] - '0');
    rep (i, a.size()) eprintf("%d ", a[i]); eprintf("\n");
    int dp[1000002][2] = {};
    rep (i, s.size() + 2) rep (j, 2) dp[i][j] = 10000000;
    dp[0][0] = 0;
    rep (i, s.size() + 1) {
        chmin(dp[i + 1][1], dp[i][1] + (9 - a[i]));
        chmin(dp[i + 1][0], dp[i][1] + a[i] + 1);
        chmin(dp[i + 1][1], dp[i][0] + (10 - a[i]));
        chmin(dp[i + 1][0], dp[i][0] + a[i]);
    }
    rep (j, 2) {
        rep (i, s.size() + 2) eprintf("%d ", dp[i][j]); eprintf("\n");
    }
    cout << dp[s.size() + 1][0] << "\n";
    return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
template <class Z> Z rng(Z l, Z r) {
  return uniform_int_distribution<Z>(l, r - 1)(mt);
}

struct chash {
  static uint64_t splitmix64(uint64_t x) {
    x += 0x9e3779b97f4a7c15;
    x = (x ^ x >> 30) * 0xbf58476d1ce4e5b9;
    x = (x ^ x >> 27) * 0x94d049bb133111eb;
    return x ^ x >> 31;
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t r = rng<uint64_t>(0, 0);
    return splitmix64(x ^ r);
  }
};

template <class T, class Op = function<T(T, T)>> struct segtree {
  const Op op;
  const T e = T();
  const long long n = 0;
  gp_hash_table<long long, T, chash> t;
  T& operator[](long long i) { return t[n + i]; }
  T at(long long i) { return t.find(i) != end(t) ? t[i] : e; }
  T fold(long long l, long long r) {
    T a = e, b = e;
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
      if (l & 1) a = op(a, at(l++));
      if (r & 1) b = op(at(--r), b);
    }
    return op(a, b);
  }
  void set(long long i, T a) {
    t[i += n] = a;
    while (i >>= 1) t[i] = op(at(2 * i), at(2 * i + 1));
  }
};
template <class T, class Op> auto make_segtree(long long n, Op op, T e) {
  return segtree<T, Op>{op, e, n};
}
auto maximum = [](auto l, auto r) { return l < r ? r : l; };

template <unsigned M> struct modular {
  using m = modular;
  unsigned v;
  modular(long long x = 0) : v((x %= M) < 0 ? x + M : x) {}
  m operator-() const { return m() -= *this; }
  m& operator+=(m b) { if ((v += b.v) >= M) v -= M; return *this; }
  m& operator-=(m b) { if (v < b.v) v += M; v -= b.v; return *this; }
  m& operator*=(m b) { v = (uint64_t)v * b.v % M; return *this; }
  m& operator/=(m b) { return *this *= power(b, M - 2); }
  friend m operator+(m a, m b) { return a += b; }
  friend m operator-(m a, m b) { return a -= b; }
  friend m operator*(m a, m b) { return a *= b; }
  friend m operator/(m a, m b) { return a /= b; }
  friend bool operator==(m a, m b) { return a.v == b.v; }
  friend string to_string(m a) { return to_string(a.v); }
};

constexpr long long mod = 998244353;
using mint = modular<mod>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<long long> x(n), d(n);
  for (int i = 0; i < n; ++i) {
    cin >> x[i] >> d[i];
    x[i] += 1e9;
  }
  vector<int> idx(n);
  iota(begin(idx), end(idx), 0);
  sort(begin(idx), end(idx), [&](int i, int j) {
    return x[i] > x[j];
  });
  auto st = make_segtree<long long>(2e9 + 1, maximum, -1e10);
  map<long long, mint> dp;
  dp[1e10] = 1;
  for (int i : idx) {
    long long cur = max(x[i] + d[i], st.fold(x[i], x[i] + d[i]));
    st.set(x[i], cur);
    dp.emplace(x[i], begin(dp)->second);
    dp[x[i]] += dp.lower_bound(cur)->second;
  }
  cout << begin(dp)->second.v << '\n';
}


Measured memory_bytes: 311652
#include <math.h>
#include <vector>
#include <cstdio>
#include <iostream>

using namespace std;

const int MAXN = 1e5+5;
const int logs = (int)log2(MAXN)+5;
int parent[MAXN][logs];
int depth[MAXN];

vector<int> edges[MAXN];

bool seen[MAXN];

int N,u,v;
int n;

void calc(int c) {
  seen[c] = true;
  for (int ed : edges[c]) {
    if (seen[ed]) {continue;}
    parent[ed][0] = c;
    depth[ed] = depth[c]+1;
    calc(ed);
  }
}


/*
 * lca 1
 */

// parent[u][k] is the 2^k-th parent of u
void preprocess() {
  for (int i = 0; i < n; i++) {
    // assume parent[i][0] (the parent of i) is already filled in
    for (int j = 1; (1<<j) < n; j++) {
      parent[i][j] = -1;
    }
  }

  // fill in the parent for each power of two up to n
  for (int j = 1; (1<<j) < n; j++) {
    for (int i = 0; i < n; i++) {
      if (parent[i][j-1] != -1) {
        // the 2^j-th parent is the 2^(j-1)-th parent of the 2^(j-1)-th parent
        parent[i][j] = parent[parent[i][j-1]][j-1];
      }
    }
  }
}


/*
 * lca 2
 */

int lca (int u, int v) {
  // make sure u is deeper than v
  if (depth[u] < depth[v]) swap(u,v);
  
  // log[i] holds the largest k such that 2^k <= i
  for (int i = log2(depth[u]); i >= 0; i--) {
    // repeatedly raise u by the largest possible power of two until it is the same depth as v
    if (depth[u] - (1<<i) >= depth[v]) u = parent[u][i]; 
  }

  if (u == v) return u;

  for (int i = log2(depth[u]); i >= 0; i--)
    if (parent[u][i] != -1 && parent[u][i] != parent[v][i]) {
      // raise u and v as much as possible without having them coincide
      // this is important because we're looking for the lowest common ancestor, not just any
      u = parent[u][i];
      v = parent[v][i];
    }

  // u and v are now distinct but have the same parent, and that parent is the LCA
  return parent[u][0];
}

int from_mid() {
  int lc = lca(u,v);
  int minD = u;
  int minlc = u;
  int minlc2 = lc;
  for (int i=0;i<N;i++) {
    int tm = lca(u,i);
    int tm2 = lca(i,v);
    if (depth[v]-depth[tm2]+depth[i]-depth[tm2] > depth[v]-depth[minlc2]+depth[minD]-depth[minlc2] && 
        (depth[u]-depth[tm]+depth[i]-depth[tm] < depth[v]-depth[tm2]+depth[i]-depth[tm2])) {
      minD = i;
      minlc = tm;
      minlc2 = tm2;
    }
  }
  return depth[v]-depth[minlc2]+depth[minD]-depth[minlc2]-1;
}

int from_root() {
  int lc = lca(u,v);
  int minD = u;
  for (int i=0;i<N;i++) {
    if (depth[i] < depth[minD]) {
      minD = i;
    }
  }
  return depth[v]-depth[lc]+depth[minD]-depth[lc]-1;
}

int main() {
  scanf("%d %d %d",&N,&u,&v);
  n=N;
  u--;v--;
  int A,B;
  for (int i=0;i<N-1;i++) {
    scanf("%d %d",&A,&B);
    edges[A-1].push_back(B-1);
    edges[B-1].push_back(A-1);
  }
  depth[0] = 0;
  parent[0][0] = -1;
  calc(0);
  preprocess();
  if (depth[v] <= depth[u]) {
    printf("%d\n",from_mid());
  } else {
    printf("%d\n",from_mid());
  }
  return 0;
}

Measured memory_bytes: 18432
#include <bits/stdc++.h>
#define rep(i, n) for (long i = 0; i < long(n); i++)
 
using ul = unsigned long;
using namespace std;
 
int main(){
    long n; cin >> n;
    
    string ans = "";

    long nn;
    rep(i,15){
        if(n > (pow(26,i)-1)/25*26 && n <= (pow(26,i+1)-1)/25*26){
            nn = i; break;
        }
    }
    // nnは桁数-1
    n -= (pow(26,nn)-1)/25*26;
    while(nn>=0){
        long b = (n-1)/pow(26,nn);
        ans += 'a'+b;
        n -= pow(26,nn)*b;
        nn--;
    }
    cout << ans << endl;
}




Measured memory_bytes: 4044
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <algorithm>
using namespace std;


int main(){
	int n,d;
	int dd;
	int ans;

	cin >> n >> d;
	
	dd=2*d+1;

	ans=n/dd;
	if(n%dd!=0){
		ans++;
	}
	
	cout << ans <<endl;
	
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define rrep(i,n) for(int i=(n);i>=0;--i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define INF 10101010

int main()
{
    ld W,H,x,y;
    cin >> W >> H >> x >> y;
    ld sq=W*H/2.;
    int count=0;
    if((x==W/2&&y==H/2)){
        count++;
    }
    cout << setprecision(9)<<sq <<" " <<count << endl;


}

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

int main(){
	int a[10]={0};
	int i,j,k=0;
	for( i=0; i<10; i++){
		cin >> a[i] ;

		if(0 > a[i]) i--;
		if(10000 < a[i]) i--;

	}

	for(i=0;i<10;i++){
  for(j=i+1;j<10;j++){
 if(a[i] < a[j]){
  k = a[j];
  a[j] = a[i] ;
  a[i] = k ;
 }
 }
 }
 for(i=0;i<3;i++){
  cout << a[i] <<"\n" ;
 }

    return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
//#include <cstdio>
//#include <algorithm>
//#include <cmath>
//#include <cstring>
//#include <iostream>
using namespace std;
typedef long long ll;
const int maxx=1e5+100;
const int INF=1e9;
const int MOD=1e9+7;
char s[maxx];

int main()
{
    scanf("%s",s);
    int v=strlen(s);
    for(int i=0; i<v; i+=2){
        printf("%c",s[i]);
    }
    printf("\n");
    return 0;
}
 

Measured memory_bytes: 384
#include "bits/stdc++.h"
 
using namespace std;
 
 
const int N = 100100;
const long long inf = 1e9;
#define ll long long
#define fr(i,a,n) for (int i=a;i<n;i++)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vipb(v) int x;cin>>x;v.pb(x);
#define vllpb(v) ll x;cin>>x;v.pb(x);
#define in(x) cin>>x;
#define in2(x,y) cin >> x >> y;
#define in3(x,y,z) cin>>x>>y>>z;
#define in4(a,x,y,z) cin>>a>>x>>y>>z;
#define in5(a,b,x,y,z) cin>>a>>b>>x>>y>>z;
 
 
typedef vector<int> VI;
typedef vector<ll> VL;
 
ll n, m, k;

int main() {
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int main() {
        int n, s;
        scanf("%d%d", &n, &s);
        vector<long long> x(n), p(n);
        for (int i = 0; i < n; i ++) {
                scanf("%lld%lld", &x[i], &p[i]);
        }
        long long ans = 0;
        auto update = [&](long long a) {
                ans += abs(a - s);
                s = a;
        };
        function<void (int, int)> calc = [&](int l, int r) {
                if (x[r] < s) update(x[l]);
                else if (s < x[l]) update(x[r]);
                else if (p[l] >= p[r]) {
                        p[l] += p[r];
                        calc(l, r - 1);
                        update(x[r]);
                } else {
                        p[r] += p[l];
                        calc(l + 1, r);
                        update(x[l]);
                }
        }; 
        calc(0, n - 1);
        printf("%lld\n", ans);
        return 0;
}



Measured memory_bytes: 5632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  int X,Y;
  cin >> s >> X >> Y;
  vector<int> x,y;
  int n=s.size();
  bool w=true;
  int cnt=0;
  for(int i=0;i<n;i++){
    if(w){
      if(s[i]=='F'){
        cnt++;
      }
      else{
        x.push_back(cnt);
        w=false;
        cnt=0;
      }
    }
    else{
      if(s[i]=='F'){
        cnt++;
      }
      else{
        y.push_back(cnt);
        w=true;
        cnt=0;
      }
    }
  }
  if(cnt){
    if(w){
      x.push_back(cnt);
    }
    else{
      y.push_back(cnt);
    }
  }
  bool dpx[n+1][16001],dpy[n+1][16001];
  dpx[0][8000]=true;
  dpy[0][8000]=true;
  dpx[1][8000+x[0]]=true;
  int xs=x.size(),ys=y.size();
  for(int i=1;i<xs;i++){
    for(int j=0;j<=16000;j++){
      if(dpx[i][j]){
        dpx[i+1][j+x[i]]=true;
        dpx[i+1][j-x[i]]=true;
      }
    }
  }
  for(int i=0;i<ys;i++){
    for(int j=0;j<=16000;j++){
      if(dpy[i][j]){
        dpy[i+1][j+y[i]]=true;
        dpy[i+1][j-y[i]]=true;
      }
    }
  }
  if(dpx[xs][8000+X]&&dpy[ys][8000+Y]){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 125824
n=int(input())
a=[int(x) for x in input().split()]

b=[0]*n
b[0]=a[0]
for i in range(n-1):
  b[i+1]=b[i]+a[i+1]

c=0
for j in range(n-1):
  c+=a[j]*(b[n-1]-b[j])
  
print(c%(10**9+7))

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

int main(){
	while(true){
		int N;
		cin>>N;
		if(N==0)
			break;
		int k[N];
		for(int i=0;i<N;i++){
			cin>>k[i];
		}
		int count=0,count2=0;
		for(int i=0;i<N;i++){
			if(k[i]==0){
				count++;
				count2++;
			}else if(k[i]-1==0){
				count2++;
			}
		}
		if(N==1){
			if(k[0]>1){
				cout<<2<<endl;
			}else{
				cout<<"NA"<<endl;
			}
		}else{
			if(count2==N){
				cout<<"NA"<<endl;
			}else{
					cout<<(N-count)+1<<endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 3040
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define INF 10000000000000009
//#define INF 9223372036854775807
typedef long long ll;
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define ORREP(i,n) for(int i=(n);i>=1;--i)
#define ZREP(i,n) for(int i=1;i<(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define rollcall cout<<"I'm Sucu."<<endl;
#define YES(s) s?cout << "YES" << endl:cout << "NO" << endl
#define Yes(s) s?cout << "Yes" << endl:cout << "No" << endl
#define Taka(s) s?cout << "Takahashi" << endl:cout << "Aoki" << endl
#define out(s,t,u) s?cout << t << endl:cout << u << endl
#define int ll
#define Endl endl

signed main(){
    int a,b,N;
    int s[104],f[104];
    cin >> a >> b >> N;
    REP(i,N){
        cin >> s[i] >> f[i];
    }
    int imos[1020]={};
    REP(i,N){
        imos[s[i]]++;
        imos[f[i]]--;
    }
    imos[a]++;
    imos[b]--;
    REP(i,1019){
        imos[i+1]+=imos[i];
    }
    REP(i,1020){
        if(imos[i]>=2){
            cout << 1 << endl;return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}   


Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,s[3],su=0;
    for(i=0;i<3;i++)
        cin>>s[i];
    sort(s,s+3);
    if(s[0]==s[1]&&s[0]==s[2])
        cout<<"0"<<endl;
    else
    {
        su=s[2]-s[1];
        s[0]+=su;
        s[1]+=su;
        if((s[1]-s[0])%2==0)
            cout<<su+(s[1]-s[0])/2<<endl;
        else cout<<su+(s[1]-s[0])/2+2<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


def dc(n, m):
    return -(-n // m)

# @mt
def slv(H, N, AB):

    dp = [INF] * (H+1)
    dp[0] = 0
    for a, b in AB:
        for h, bb in enumerate(dp):
            if bb == INF:
                continue
            n = min(H, h+a)
            dp[n]  = min(dp[n], bb+b)
    return dp[-1]


def main():
    H, N = read_int_n()
    AB = [read_int_n() for _ in range(N)]
    print(slv(H, N, AB))
    # H = 10**4
    # N = 10
    # AB = [[random.randint(1, 100), random.randint(1, 100)] for _ in range(N)]
    # print(slv(H, N, AB))


if __name__ == '__main__':
    main()


Measured memory_bytes: 63848
from operator import attrgetter


class Line:
    def __init__(self, a, b):
        self.a = a
        self.b = b


N, M = map(int, input().split())
lines = []
for _ in range(M):
    a, b = map(int, input().split())
    lines.append(Line(a, b))

lines = sorted(lines, key=attrgetter("a"))

start_num = lines[0].a
min_num = 1000000
cnt = 0

for line in lines:
    if line.a != start_num:
        if min_num <= line.a:
            cnt += 1
            min_num = line.b
        start_num = line.a
    if line.b < min_num:
        min_num = line.b
cnt += 1
print(cnt)


Measured memory_bytes: 29244
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N;
  cin >> N;
  // vll a(N - 1);
  // vll b(N - 1);
  // vll c(N - 1);

  vector<vector<pair<ll, ll>>> to(N);
  rep(i, N - 1) {
    ll a, b, c;
    cin >> a >> b >> c;
    a--;
    b--;
    to[a].pb({b, c});
    to[b].pb({a, c});
  }

  ll Q, K;
  cin >> Q >> K;
  K--;
  vector<P> q(Q);
  rep(i, Q) {
    ll x, y;
    cin >> x >> y;
    x--;
    y--;
    q[i] = {x, y};
  }

  vll dp(N, -1);
  queue<pair<ll, ll>> que;
  que.push({K, 0});

  while (!que.empty()) {
    pair<ll, ll> p = que.front();
    que.pop();

    if (dp[p.first] != -1) {
      continue;
    }
    dp[p.first] = p.second;

    rep(i, to[p.first].size()) {
      pair<ll, ll> a = to[p.first][i];
      que.push({a.first, p.second + a.second});
    }
  }

  rep(i, Q) {
    ll ans = dp[q[i].first] + dp[q[i].second];
    COUT(ans);
  }

  return 0;
}

Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  
  cin >> a >> b;

  double y = (a + b) % 2;
  int x = (a + b) / 2;
  if (y != 0) {
    x += y;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,K;
    cin>>N>>K;
    vector<bool> have(N,true);
    rep(i,K){
        int d;
        cin>>d;
        rep(j,d){
            int A;
            cin>>A;
            --A;
            have.at(A)=false;
        }
    }
    int count=0;
    rep(i,N){
        if(have.at(i))count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3632
#include <iostream> 
#include <string>
#include <cstdint>

int main() {
	std::string s;
	std::int64_t k;
	std::cin >> s >> k;

	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != '1') {
			std::cout << s[i] << std::endl;
			return 0;
		}
		if (i + 1 == k) {
			std::cout << 1 << std::endl;
			return 0;
		}
	}
}

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

long long int x,i,n;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>x;n=100;i=0;
	while (n<x) i++,n=n+n/100;
	cout<<i;
}


Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define f(i, n)         for(int i=0; i<n; i++)
#define fo(i, k, n)     for(int i=k; i<n; i++)
#define forr(i, a, b)   for(int i=a; i<=b; i++)
#define rf(i,n)         for(int i=n;i>=0;i--)
typedef unsigned long long ull;
typedef pair<int,int> pr;
#define MAX 100005
#define INF 1000000009
#define   sq(n)         (n*n)
#define p(n) cout<<n<<endl
#define pb push_back
#define py cout<<"YES"<<endl;
#define pn cout<<"NO"<<endl;
#define __FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
ll lcm ( ll a, ll b )
{
    return ( a / __gcd ( a, b ) ) * b;
}
ll pow1(ll n,ll i)
{
    ll p=1;
    for(int j=0;j<i;j++)
    {
        p*=n;
    }
    return p;
}
int main()
{
    __FastIO;

    string s,t;
    cin>>s;
    cin>>t;
    int l=s.length();

    int c=0;
    f(i,l)
    {
        if(s[i]!=t[i])
        {
            c++;
        }
    }
    p(c);

    return 0;
}




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

signed main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int h, w, n; cin >> h >> w >> n;
  vector<pair<int, int>> a(n); for (int i = 0; i < n; i++) cin >> a[i].first >> a[i].second;
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 3; j++) {
      for (int k = 0; k < 3; k++) {
        int x = a[i].first + j - 1, y = a[i].second + k - 1;
        if (2 <= x and x <= h - 1 and 2 <= y and y <= w - 1) mp[pair<int, int>(x, y)]++;
      }
    }
  }
  vector<long long> res(10, 0);
  for (auto i : mp) res[i.second]++;
  res[0] = (long long) (h - 2) * (w - 2) - accumulate(res.begin() + 1, res.end(), 0LL);
  for (int i = 0; i < 10; i++) cout << res[i] << '\n';
  return 0;
}

Measured memory_bytes: 57344
#include <iostream>
using namespace std;
using ll = long long;
const int AMAX = 100000;
ll cnt[AMAX + 1];

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

    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        cnt[A] += B;
    }

    for (int ans = 1; ans <= AMAX; ++ans){
        if (K <= cnt[ans]) {
        cout << ans << endl;
        break;
        }
        
        K -= cnt[ans];
    }

    return 0;
}

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

fn cnt(mut u: u64) -> i32 {
    let mut a = 0;
    loop {
        a += 1;
        u /= 10;
        if u == 0 {
            break;
        }
    }
    a
}

fn solve(n: u64) -> u64 {
    let s = (n as f64).sqrt() as u64;
    let mut ret: u64 = s;

    for i in 0..s {
        let tmp = s - i;
        if tmp * (n / tmp) == n {
            ret = n / tmp;
            break;
        }
    }
    ret
}

fn main() {
    let n: u64 = read();

    println!("{}", cnt(solve(n)));
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;
int n,sum=0;
int main()
{
	scanf("%d",&n);
	int temp=n;
	while(temp>0)
	{
		sum+=temp%10;
		temp/=10;
	}
	if(n%sum==0) printf("Yes");
	else printf("No");
} 

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")*/

using namespace __gnu_pbds;
using namespace std;

#define ll long long
#define ld long double
#define mp make_pair
#define what_is(x) cerr << #x << " is " << x << endl;

typedef tree<
        int,
        null_type,
        less<int>,
        rb_tree_tag,
        tree_order_statistics_node_update>
        ordered_set;


const int p = 1e9 + 7;


int mul(int a, int b) {
    return (1LL * a%p * b%p) % p;
}

int add(int a, int b) {
    int s = (a+b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int sub(int a, int b) {
    int s = (a-b);
    s = s%p;
    if (s<0) s+=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

vector<int> Z(vector<int> s)
{
    int n = s.size();
    vector<int> z(n);
    int L = 0, R = 0;
    for (int i = 1; i < n; i++) {
        if (i > R) {
            L = R = i;
            while (R < n && s[R-L] == s[R]) R++;
            z[i] = R-L; R--;
        } else {
            int k = i-L;
            if (z[k] < R-i+1) z[i] = z[k];
            else {
                L = i;
                while (R < n && s[R-L] == s[R]) R++;
                z[i] = R-L; R--;
            }
        }
    }
    return z;
}

mt19937 rnd(time(0));
/*
struct Line {
    mutable ll k, m, p;
    bool operator<(const Line& o) const { return k < o.k; }
    bool operator<(ll x) const { return p < x; }
};

struct CHT : multiset<Line, less<>> {
    // (for doubles, use inf = 1/.0, div(a,b) = a/b)
    const ll inf = LLONG_MAX;
    ll div(ll a, ll b) { // floored division
        return a / b - ((a ^ b) < 0 && a % b); }
    bool isect(iterator x, iterator y) {
        if (y == end()) { x->p = inf; return false; }
        if (x->k == y->k) x->p = x->m > y->m ? inf : -inf;
        else x->p = div(y->m - x->m, x->k - y->k);
        return x->p >= y->p;
    }
    void add(ll k, ll m) {
        auto z = insert({k, m, 0}), y = z++, x = y;
        while (isect(y, z)) z = erase(z);
        if (x != begin() && isect(--x, y)) isect(x, y = erase(y));
        while ((y = x) != begin() && (--x)->p >= y->p)
            isect(x, erase(y));
    }
    ll query(ll x) {
        assert(!empty());
        auto l = *lower_bound(x);
        return l.k * x + l.m;
    }
};
*/

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr);

    int n;
    cin>>n;
    cout<<3*n*n;

}

Measured memory_bytes: 256
l, r = map(int, input().split())

ans = float('inf')
for i in range(l, min(r, l + 2019)):
    for j in range(i + 1, min(r + 1, l + 2019 + 1)):
        x = i * j % 2019
        ans = min(ans, x)
        
print(ans)

Measured memory_bytes: 9092
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val n = sc.nextInt()
    val a = Array(n) { sc.nextInt() }
    val count = mutableMapOf<Int, Int>()
    for (i in 0 until n) {
        count[a[i]] = (count[a[i]] ?: 0) + 1
    }
    var ans = 0
    for ((key, value) in count) {
        if (value >= key) {
            ans += value - key
        } else {
            ans += value
        }
    }
    println(ans)
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

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

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

        return st.nextToken()
    }

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


Measured memory_bytes: 46148
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
typedef pair<int, int> P;
typedef pair<P, int> Q;
int main() {
    int n, ans = 0;
    vector<Q> p;
    set<int> s;
    cin >> n;
    for(int i=0;i<n*2;i++){
        int x, y;
        cin >> x >> y;
        p.push_back(Q(P(x, y), i/n));
    }
    sort(p.begin(), p.end(), greater<Q>());
    for(int i=0;i<n*2;i++){
        int y = p[i].first.second;
        int c = p[i].second;
        if(c == 1){
            s.insert(y);
        }else{
            auto itr = s.upper_bound(y);
            if(itr != s.end()){
                ans++;
                s.erase(itr);
            }
        }
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [0 for i in range(N)]
num = [0 for i in range(N)]
Max = 0

for i in range(N):
    S[i] = input()

dic = sorted(S)

i = 0
while i < N-1:
    j = 0
    while i+j+1 < N and dic[i+j] == dic[i+j+1]:
        j += 1
    num[i] = j
    i += j + 1

flag = 1
for i in range(N):
    if flag == 1:
        if num[i] > 0:
            Max = num[0]
            flag = 0
    if flag == 0:
        if num[i] >= Max:
            Max = num[i]

i = 0
while i < N:
    if num[i] == Max:
        print(dic[i])
    i += num[i] + 1




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

int main () {
  int x, y;
  cin >> x >> y;
  int a = abs(x), b = abs(y);
  if (x == a && y == b) {
    if (x < y) cout << y-x << endl;
    else cout << min(x+y+1, x-y+2) << endl;
  }
  else if (x != a && y == b) {
    cout << min(abs(a-y)+1, b-x) << endl;
  }
  else if (x == a && y != b) {
    cout << abs(x-b)+1 << endl;
  }
  else {
    if (x < y) cout << y-x << endl;
    else if (x == y) cout << 1 << endl;
    else cout << b-a+2 << endl;
  }
}

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

d = {}
for _ in range(q):
    command = list(map(str, input().split()))
    query = int(command[0])
    key = command[1]
    if query == 0:
        d[key] = int(command[2])
    elif query == 1:
        if key in d:
            print(d[key])
        else:
            print(0)
    else:
        if key in d:
            del d[key]



Measured memory_bytes: 37496
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long

const int N = 1000300;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =    1e9+7;
ll n,k;
int main()
{
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n;
cin>>n;
ll arr[n];
rep(i,0,n)
cin>>arr[i];
ll ans=0;
ll cnt=0;
rep(i,0,n)
{

if(arr[i]<0)
cnt++;
}
bool b=false;
rep(i,0,n)
if(!arr[i])
b=true;

ll mn=1e16;
rep(i,0,n)
{

ans+=abs(arr[i]);
if(abs(arr[i])<mn)
mn=abs(arr[i]);}
//cout<<ans<<endl;
if(cnt%2&&b==false)

ans-=2*(mn);
cout<<ans;

}

Measured memory_bytes: 1024