akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <bitset>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef long long ll;

#define ALL(obj) (obj).begin(), (obj).end() 
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)

int main(){
    int n;
    ll sum=0;
    cin >> n;
    vector<ll> a(n+2);
    FOR(i,1,n+1) cin >> a[i];
    a[0] = 0;
    a[n+1] = 0;
    rep(i,n+1){
        sum += a[i] < a[i+1] ? a[i+1] - a[i] : a[i] - a[i+1];
    }
   // cout << "sum" << sum << endl;
    FOR(i,1,n+1){
        //cout << i << " : "<< (a[i+1]-a[i]) << endl;
        if(((a[i+1]-a[i]) <= 0 && (a[i]-a[i-1]) <= 0) || ( (a[i+1]-a[i]) >= 0 && (a[i]-a[i-1]) >= 0))  cout << sum << endl;
        else cout << sum - abs(a[i]-a[i-1]) - abs(a[i+1]-a[i]) + abs(a[i+1]-a[i-1]) << endl;
    }

    return 0;
}

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

using namespace std;

#define pb push_back
#define fs first
#define sc second
#define sz size
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 2; i <= (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using ll = long long;
const ll inf = 1e9+7; 

const double PI =  3.141592653589793;

int main(){
	IO;
	ll a,b;
	cin>>a>>b;
	cout<<(((b-a)*(b-a+1))/2)-b<<"\n";
	return 0;
}

// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""

Measured memory_bytes: 256
#include<iostream>

long long abs(long long a)
{
    return (a < 0) ? -a : a;
}

int sgn(long long a)
{
    return (a < 0) ? -1 : 1;
}

int main()
{
    long long X, K, D;
    std::cin >> X >> K >> D;
    
    while(K > 0){
        if(abs(X - sgn(X) * D) < abs(X)){
            long long times = abs(X) / D;
            if(times == 0) times = 1;
            if(K < times) times = K;
            K -= times;
            X -= sgn(X) * times * D;
        }else{
            if(K > 1){
                K %= 2;
            }else{
                X -= sgn(X) * D;
                K--;
            }
        }
    }

    std::cout << abs(X) << '\n';
    return 0;
}

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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repd(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
}

int ans = 0;
bool check = 0;
string s, t;
int N = 3;
vector<int> v(N);
int a, b;
int x, y;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  cin >> a >> b;
  if (a <= 8 && b <= 8)
    pr("Yay!");
  else
    pr(":(");
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main 
{

	public static void main(String[] args) 
	{
		Scanner sc = new Scanner(System.in);
		
		float value = sc.nextFloat();
		
		
		float max = value/3;
		
		float result = max*max*max;
		System.out.println(result);
	}
}


Measured memory_bytes: 23124
import java.util.*;

public class Main {
	public static void main (String[] args)  {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		ArrayDeque<Integer> deq = new ArrayDeque<>();
		for (int i = 0; i < n; i++) {
			if (i % 2 == 0) {
				deq.addLast(sc.nextInt());
			} else {
				deq.addFirst(sc.nextInt());
			}
		}
		StringBuilder sb = new StringBuilder();
		while (deq.size() > 0) {
			if (deq.size() < n) {
				sb.append(" ");
			}
			if (n % 2 == 0) {
				sb.append(deq.pollFirst());
			} else {
				sb.append(deq.pollLast());
			}
		}
		System.out.println(sb);
	}
}


Measured memory_bytes: 95472
<?php
    while($num = array_map('intval',explode(" ",trim(fgets(STDIN))))){
        if($num[0]==0 && $num[1]==0){
            break;
        }
        for($j=0;$j<$num[0];$j++){
            for($i=0;$i<$num[1];$i++){
                echo "#";
            }
            echo "\n";
        }
        echo "\n";
    }
?>


Measured memory_bytes: 9220
N,C,K = map(int,input().split())
T = [int(input()) for _ in range(N)]
T.sort()
cnt = 0
pas = 0
time = T[0]
for i in range(N-1):
    pas += 1
    if pas and T[i] - time > K:
        pas,time = 1,T[i]
        cnt += 1
        continue
    if pas == C:
        pas,time = 0,T[i+1]
        cnt += 1
print(cnt+1+(pas and T[N-1]-T[N-2]>=K))

Measured memory_bytes: 13244
#include <stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

void dfs(void);
void visit(int);
int n,time,d[N],f[N],color[N],M[N][N] = {};

int main(){
int i,j,u,k,v;

  scanf("%d",&n);
  
  for(i=0; i<n; i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0; j<k; j++){
      scanf("%d",&v);
      M[u-1][v-1] = 1;   
    }
  }

  dfs();

  for(u=0; u<n;u++)
    printf("%d %d %d\n",u+1,d[u],f[u]);
  
  return 0;
}

void dfs(){
  int u;

  for(u=0; u<n; u++){
    color[u] = WHITE;
  }

  time = 0;

  for(u=0; u<n; u++){
    if(color[u] == WHITE)
      visit(u);
  }

}

void visit(int u){
  int v;

  color[u] = GRAY;
  d[u] = ++time;

  for(v=0; v<n; v++){
    if(M[u][v] == 0)
      continue;
    if(color[v] == WHITE)
      visit(v);
  }

  color[u] = BLACK;
  f[u] = ++time;
}

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

int main() {
  int N;
  cin >> N;
  string A = "Three";
  
  for (int i = 0; i < N; i++){
    string S;
    cin >> S;
    
    if (S == "Y"){
      A = "Four";
      break;
    }
    
  }
    
  cout << A << endl; 
  
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	// sovle max-flow problem by Ford-Fulkerson algorithm.
	// time complexity: O(F|E|) where F is a max-flow and E is a set of edges.
	// from: "プログラミングコンテストチャレンジブック[第2版]"(http://amzn.asia/3MkgFHb) p188
	static int MAX_V = 100;
	static int INF = 10000000;
	static ArrayList<ArrayList<Edge>> G = new ArrayList<ArrayList<Edge>>(MAX_V); // {{
//		for(int i=0; i<MAX_V; i++) {
//			G.add(new ArrayList<Edge>());
//		}
//	}};
	// TODO: https://stackoverflow.com/questions/8559092/create-an-array-of-arraylists
	// もっとマシな設計にできないか
	static boolean[] used = new boolean[MAX_V];
	
	static void addEdge(int from, int to, int cap) {
		G.get(from).add(new Edge(to, cap, G.get(to).size()));
		G.get(to).add(new Edge(from, 0, G.get(from).size()-1));
	}
	
	static int dfs(int v, int t, int f) {
		if(v==t) return f;
		used[v] = true;
		for(int i=0; i<G.get(v).size(); i++) {
			Edge e = G.get(v).get(i);
			if(!used[e.to] && e.cap > 0) {
				int d = dfs(e.to, t, Math.min(f, e.cap));
				if(d>0) {
					e.cap -= d;
					G.get(e.to).get(e.rev).cap += d;
					return d;
				}
			}
		}
		return 0;
	}
	
	static int maxFlow(int s, int t) {
		int flow = 0;
		for(;;) {
			Arrays.fill(used, false);
			int f = dfs(s, t, INF);
			if(f==0) return flow;
			flow += f;
		}
	}
	
	static void initGraph(int maxV) {
		for(int i=0; i<maxV; i++) {
			G.add(new ArrayList<Edge>());
		}
	}
	
	static class Edge {
		int to, cap, rev;
		Edge(int to, int cap, int rev) {
			this.to = to; this.cap = cap; this.rev = rev;
		}
	}
	
	// VERIFIED at http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_6_A&lang=jp
	static public void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int V = sc.nextInt();
		int E = sc.nextInt();
		int s = 0;
		int t = V-1;
		initGraph(V);
		for(int i=0; i<E; i++) {
			int u = sc.nextInt(); int v = sc.nextInt(); int c = sc.nextInt();
			addEdge(u, v, c);
		}
		System.out.println(maxFlow(s, t));
	}
}



Measured memory_bytes: 34492
// defines
#define boost_io ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define casti static_cast<int>
#define cast static_cast
#define ll long long int
#define vi vector<int>
#define vpi vector<pair<int,int >>

// includes
#include <bits/stdc++.h>

using namespace std;

ll modF=1e9+7;

// topcoder


//codechef and codeforces

void solve1(){
    int inp;
    for(int i=1;i<=5;i++){
        cin>>inp;
        if(inp==0){
            cout<<i<<"\n";
        }
    }
}

int main(){
    boost_io;
    solve1();
    return 0;
}


Measured memory_bytes: 3656
#pragma GCC optimize("O3")
#pragma GCC optimize("O1")
#pragma GCC optimize("O2")
#pragma GCC optimize("Os")
#pragma GCC optimize("Ofast")
#pragma GCC target("avx2")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(ll i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcountll(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<pair<int,int>,int> &a, const pair<pair<int,int>,int> &b)
{
    return (a.first.second<b.first.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
void vok()
{
    FAST
    FO
    FI
    // #ifndef ONLINE_JUDGE
    //     freopen("input.txt","r",stdin);
    //     freopen("output.txt","w",stdout);
    // #endif
}
int main()
{
    vok();
    int a,b;
    IN a>>b;
    if(a<=b)
    {
        OUT "unsafe"<<endl
    }
    else
    {
        OUT "safe"<<endl
    }
    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int maxnum = max(A,max(B,C));
    int sum = A + B + C;

    if(sum % 2 != maxnum % 2){
        maxnum++;
    }
cout << (3*maxnum - sum)/2 << endl; 

}

Measured memory_bytes: 256
use proconio::input;

fn main() {
  input! {
    n: usize,
    mut tasks: [(usize, usize);n]
  }
  tasks.sort_by(|a, b| a.1.cmp(&b.1));

  if tasks[0].0 > tasks[0].1 {
    println!("No");
    return
  }
  
  let mut last_time = tasks[0].0;
  for i in 1..tasks.len() {
    let (take_time, dead_line) = tasks[i];
    
    if last_time + take_time > dead_line {
      println!("No");
      return
    }
    last_time += take_time;
  }
  
  if last_time > tasks[tasks.len()-1].1 {
    println!("No");
  } else {
    println!("Yes");
  }
}

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

using namespace std;

const long long NS = (long long)1e5 + 4;
long long N, M;
long long arr[NS];
struct data{
    long long num, val;
    bool operator<(const data&r)const{
        return val > r.val;
    }
}cha[NS];

int main(){
    scanf("%lld %lld", &N, &M);
    for(long long i = 1; i <= N; ++i) scanf("%lld", arr + i);
    sort(arr + 1, arr + N + 1);
    for(long long i = 1; i <= M; ++i) scanf("%lld %lld", &cha[i].num, &cha[i].val);
    sort(cha + 1, cha + M + 1);
    long long j = 1;
    for(long long i = 1; i <= M; ++i){
        while(cha[i].num-- && j <= N){
            if(arr[j] < cha[i].val){
                arr[j] = cha[i].val;
            }
            ++j;
        }
    }
    long long ans = 0;
    for(long long i = 1; i <= N; ++i) ans += arr[i];
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll MOD=1000000007;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
long long gcd(long long a,long long b){
    ll gcdmax=max(a,b);
    ll gcdmin=min(a,b);
    while(true){
        if(gcdmax%gcdmin==0)break;
        else gcdmax%=gcdmin;
        swap(gcdmin,gcdmax);
    }
    return gcdmin;
}
ll powerup(ll N,ll P,ll M){
    if(P==0)return 1;
    else if(P%2==0){
        ll t=powerup(N,P/2,M);
        return t*t%M;
    }
    else return N*powerup(N,P-1,M)%M;
}
int main()
{
  ll N,M,sum;
  cin>>N>>M;
  sum=0;
  vector<ll> A(N);
  rep(i,N){
    cin>>A.at(i);
    sum+=A.at(i);
  }
  sort(A.begin(),A.end(),greater<ll>());
  if(A.at(M-1)*4*M>=sum)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<utility>
#include<map>
#include<complex>
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<ll, ll> P;

#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define all(x) (x).begin(),(x).end()
#define stop char nyaa; cin>>nyaa;

typedef long double ld;
typedef complex<ld>com;
typedef vector<com> poly;
const ld pi = acos(-1.0);
const ld eps = 0.01;
poly dft(poly f, bool inverse = false) {
	int n = f.size(); int i, j, k;
	for (int i = 0, j = 1; j < n - 1; j++) {
		for (k = n >> 1; k > (i ^= k); k >>= 1);
		if (i > j)swap(f[i], f[j]);
	}
	for (int m = 2; m <= n; m *= 2) {
		com zeta = com(cos(2 * pi / (ld)m), sin(2 * pi / (ld)m));
		if (inverse) {
			zeta = com(cos(2 * pi*(m - 1) / (ld)m), sin(2 * pi*(m - 1) / (ld)m));
		}
		for (i = 0; i < n; i += m) {
			com powzeta = 1;
			for (k = i; k < i + m / 2; k++) {
				com t1 = f[k], t2 = powzeta * f[k + m / 2];
				f[k] = t1 + t2; f[k + m / 2] = t1 - t2;
				powzeta *= zeta;
			}
		}
	}
	if (inverse) {
		for (i = 0; i < n; i++) {
			f[i] /= (ld)n;
		}
	}
	return f;
}
poly multiply(poly g,poly h) {
	int n = 1; int sz = g.size() + h.size();
	while (n <= sz)n *= 2;
	while (g.size() < n) {
		g.push_back(0);
	}
	while (h.size() < n) {
		h.push_back(0);
	}
	poly gg = dft(g);
	poly hh = dft(h);
	poly ff;
	rep(i, n) {
		ff.push_back(gg[i] * hh[i]);
	}
	return dft(ff, true);
}

char mp[500][500];
int num[500][500];

int sum[500][500];
ll cnt[500][500];

void solve() {
	int n, m, k, l; cin >> n >> m >> k >> l;
	rep(i, n) {
		rep(j, n) {
			cin >> mp[i][j];
		}
	}
	string s; cin >> s;
	int x = 0, y = 0;
	rep(i, l) {
		if (s[i] == 'R') {
			y++;
		}
		else if (s[i] == 'L') {
			y--;
		}
		else if (s[i] == 'U') {
			x--;
		}
		else {
			x++;
		}
		num[x][y]++;
	}
	poly a1;
	rep(i, m) {
		rep(j, m) {
			a1.push_back(num[i][j]);
		}
	}
	poly a2;
	rep(i, m) {
		rep(j, m) {
			if (i < n&&j < n) {
				if (mp[i][j] == 'X') {
					a2.push_back(1);
				}
				else {
					a2.push_back(0);
				}
			}
			else {
				a2.push_back(0);
			}
		}
	}
	poly aft = multiply(a1, a2);
	int ans = 0;
	rep(i, m*m) {
		//cout << aft[i] << endl;
		int t = (real(aft[i]) + eps);
		if (t >= k)ans++;
	}
	cout << ans << endl;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//find_prime();
	solve();
	//stop
		return 0;
}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define sz(x) ((int)(x).size())

int main(){
  string s,t; cin >> s >> t;

  map<char,char> mp,mpi;
  rep(i,sz(s)){
    if(mp.count(s[i]) == 0 and mpi.count(t[i]) == 0){
      mp[s[i]] = t[i];
      mpi[t[i]] = s[i];
    }else if(mp[s[i]] == t[i] and mpi[t[i]] == s[i]) continue;
    else{
      cout << "No\n";
      return 0;
    }
  }
  
  cout << "Yes\n";
}

Measured memory_bytes: 900
fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(' ').map { it.toInt() }

    val graph = Graph1(n)
    repeat(m) {
        val (x, y) = readLine()!!.split(' ').map { it.toInt() }
        graph.add(x - 1, y - 1)
    }

    println(graph.solve())
}

class Graph1 constructor(private val n: Int) {
    private val graph = Array(n) { mutableListOf<Int>() }
    private val dp = IntArray(100000) { -1 }

    fun add(x: Int, y: Int) {
        graph[x].add(y)
    }

    private fun rec(v: Int): Int {
        if (dp[v] != -1) return dp[v]

        var res = 0
        graph[v].forEach {
            res = Math.max(res, rec(it) + 1)
        }
        dp[v] = res
        return res
    }

    fun solve(): Int {
        var res = 0
        (0 until n).forEach {
            res = Math.max(res, rec(it))
        }
        return res
    }

}

Measured memory_bytes: 70552
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007;
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
  int a, b, c;
  cin >> a >> b >> c;
  D((b - a == c - b ? "YES" : "NO"));
  return 0;
}



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

#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

typedef unsigned long long ull;
typedef long long ll;

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

using namespace std;

typedef pair<int ,int > P;

int MAX_N=1000007;
bool prime[1000007];

int main()
{
	fill(prime,prime+MAX_N,true);

	prime[0]=prime[1]=false;
	for(int i=2;i<MAX_N;i++)
	{
		if(prime[i])
		{
			for(int j=i*2;j<MAX_N;j+=i) prime[j]=false;
		}
	}

	int n;
	while(cin>>n)
	{
		int ans=0;
		rep(i,n+1)
			if(prime[i])
				ans++;
		cout<<ans<<endl;
	}
	


	return 0;
}

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

int main(){
int n;
cin >> n;
int a;
a=100000;
int b;
b=0;
while(b<n){
a=a/20*21;
if((a%1000)!=0){a=a/1000*1000+1000;}
b=b+1;}
cout << a<<endl;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll sw, sv;

ll dfs(ll now_limit, vector<vector<ll>> &wv, int n, ll rest, ll cnt) {
	if(n == 4) {
		return cnt;
	}
	ll ans = 0;
	for(int i=0;i<=min(now_limit, (ll)wv[n].size()-1);i++) {
		ll next_limit = (rest - i * (n + sw)) / (n + 1 + sw);
		ans = max(ans, dfs(next_limit, wv, n + 1, rest - i * (n + sw), cnt + wv[n][i]));
	}
	return ans;
}

signed main() {
	int N;
	ll W;
	cin >> N >> W;
	vector<vector<ll>> wv(5);
	cin >> sw >> sv;
	wv[0].push_back(sv);
	for(int i=0;i<5;i++) wv[i].push_back(LLONG_MAX);
	for(int i=1;i<N;i++) {
		ll w, v;
		cin >> w >> v;
		wv[w-sw].push_back(v);
	}
	// 各重さでそれぞれ何個選ぶか決める
	for(int i=0;i<4;i++) {
		sort(wv[i].rbegin(), wv[i].rend());
	}
	for(int i=0;i<5;i++) wv[i][0] = 0;

	// 累積和
	for(int i=0;i<4;i++) {
		for(int j=1;j<wv[i].size();j++) {
			wv[i][j] += wv[i][j-1];
		}
	}
	ll now_limit = W / sw;
	cout << dfs(now_limit, wv, 0, W, 0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int h, w, K;
string s[6];

signed main() {
	int i, j, k, l;
	
	cin >> h >> w >> K;
	rep(i, h) cin >> s[i];
	
	int ans = 0;
	rep(i, (1 << h)) {
		rep(j, (1 << w)) {
			int cnt = 0;
			rep(k, h) {
				rep(l, w) {
					if ((i >> k) % 2 == 0 && (j >> l) % 2 == 0 && s[k][l] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == K) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3592
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try(Scanner sc = new Scanner(System.in);){
			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();
			
			int count = 0;
			
			for(int i = a; i <= b; i++) {
				if(c % i == 0) {
					count++;
				}
			}
			
			System.out.println(count);
		}
	}
}


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

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

const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;

#define rep(i, a, b) for(ll (i) = (a); (i) < (b);++i)

int N, M;
const int MAX_N = 8;
const int MAX_M = 28;
bool graph[MAX_M][MAX_M];
bool visited[MAX_N] = {};

int dfs(int v){
  visited[0] = true;
  visited[v] = true;

  bool all_visited = true;
  rep(i, 0, N){
    if (visited[i] == false)
    {
      all_visited = false;
    }
  }

  if (all_visited)
  {
    // cout << "ret" << endl;
    return 1;
  }

  int cnt = 0;
  rep(i, 0, N){
    if (i != v && graph[v][i] && visited[i] == false)
    {
      // cout << v << " " << i << ", ";
      cnt += dfs(i);
      visited[i] = false;
    }
  }
  return cnt;
}

int main()
{
  cin >> N >> M;
  rep(i, 0, M){
    int a, b;
    cin >> a >> b;
    graph[a-1][b-1] = graph[b-1][a-1] = true;
  }
  cout << dfs(0) << endl;
  return 0;
}

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

using namespace std;

int main() {
  int n, v;
  cin >> n;
  vector<vector<int>> V(2, vector<int>(100001));
  for (int i = 0; i != n; ++i) {
    cin >> v;
    ++V[i % 2][v];
  }

  vector<vector<int>> I(2, vector<int>(100001));
  for (auto i : {0, 1}) {
    iota(begin(I[i]), end(I[i]), 1);
    partial_sort(begin(I[i]), begin(I[i]) + 2, end(I[i]),
                 [&](int a, int b) { return V[i][a] > V[i][b]; });
  }
  auto ans = n - ((I[0][0] != I[1][0]) ? V[0][I[0][0]] + V[1][I[1][0]]
                                       : max(V[0][I[0][0]] + V[1][I[1][1]],
                                             V[0][I[0][1]] + V[1][I[1][0]]));
  cout << ans << endl;
}


Measured memory_bytes: 5188
cnt = 0 
memory = 0
s=input()
for x in s: #文字列Sから1文字ずつ取り出してXに代入
  if x in ['A','G','C','T']: #取り出した文字xが[]内の文字いずれかの場合
    cnt += 1
  else:
    memory = max(memory,cnt) #退避先memoryとcntを比較し大きい方を更新
    cnt = 0
print(max(memory,cnt))  #ACGT以外の文字が現れなかった時(全てACGTいずれか又はXAAAA等)

Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String input = br.readLine();
			
			if(input == null){
				break;
			}
			
			System.out.printf("%.6f\n",PolandCalc.calc(input));
		}
	}

}

class PolandCalc{
	public static double calc(String exp){
		Stack<Double> stack = new Stack<Double>();
		String[] tmpArray = exp.split(" ");
		
		for(int i = 0; i < tmpArray.length ;i++){
			if(tmpArray[i].equals("+")){
				stack.push(stack.pop() + stack.pop());
			}
			else if(tmpArray[i].equals("*")){
				stack.push(stack.pop() * stack.pop());
			}
			else if(tmpArray[i].equals("-")){
				stack.push(-(stack.pop() - stack.pop()));
			}
			else if(tmpArray[i].equals("/")){
				double tmp1 = stack.pop();
				double tmp2 = stack.pop();
				stack.push(tmp2/tmp1);
			}
			else {
				stack.push(Double.parseDouble(tmpArray[i]));
			}
		}
		
		return stack.pop();
	}
}

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

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

  int now=h[0], l=0, ans=0;
  for(int i=1; i<n; ++i){
    if(now>=h[i]){++l; now=h[i];}
    else {ans=max(ans, l); l=0; now=h[i];}
  }
  ans=max(ans, l);

  cout<<ans<<endl;
}


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

//type
#define ll long long
typedef pair<int, int> P;
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first      //pairの一つ目の要素
#define S second     //pairの二つ目の要素
#define Z class
// OTHER
// xの二乗を返す (関数テンプレート版)
template <typename T>
T square(T x) { return x * x; }
#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))
// loop
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= ll(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= ll(b); i--)
#define FORA(i, I) for (const auto &i : I)

// vector
#define ALL(x) x.begin(), x.end()

// output
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ln cout << '\n'
template <Z A>
void pr(A a)
{
  cout << a;
  ln;
}
template <Z A, Z B>
void pr(A a, B b)
{
  cout << a << ' ';
  pr(b);
}

int ans = 0;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

int main()
{
  string s;
  cin >> s;
  rep(i, s.length())
  {
    if (i % 2 == 0 && s[i] != 'U' && s[i] != 'D' && s[i] != 'R')
    {
      No();

      return 0;
    }

    if (i % 2 != 0 && s[i] != 'U' && s[i] != 'L' && s[i] != 'D')
    {
      No();

      return 0;
    }
    }
  Yes();
  return 0;
}


Measured memory_bytes: 3596
from collections import deque

N=int(input())
IN=[[] for i in range(N)]
OUT=[-1 for i in range(N)]
p=list(map(int,input().split()))
for i in range(N):
    IN[p[i]-1].append(i)
    OUT[i]=p[i]-1

deg=[len(IN[i]) for i in range(N)]

deq=deque([v for v in range(N) if deg[v]==0])
res=[]
while deq:
    v=deq.popleft()
    res.append(v)
    deg[OUT[v]]-=1
    if deg[OUT[v]]==0:
        deq.append(OUT[v])

if len(res)==N:
    print("POSSIBLE")
    exit()

start=-1
for i in range(N):
    if deg[i]>0:
        start=i
        break

cycle=[start]
while True:
    nv=OUT[cycle[-1]]
    if nv!=start:
        cycle.append(nv)
    else:
        break


dp=[-1]*N
for v in res:
    mex=[False]*(len(IN[v])+1)
    for pv in IN[v]:
        if dp[pv]<=len(IN[v]):
            mex[dp[pv]]=True
    for i in range(len(mex)):
        if not mex[i]:
            dp[v]=i
            break

m0=-1
m1=-1
mex=[False]*(len(IN[start])+2)
for pv in IN[start]:
    if dp[pv]!=-1 and dp[pv]<=len(IN[v])+1:
        mex[dp[pv]]=True
for i in range(len(mex)):
    if not mex[i]:
        if m0==-1:
            m0=i
        else:
            m1=i
            break

#m0
dp[start]=m0
for i in range(1,len(cycle)):
    v=cycle[i]
    temp=-1
    mex=[False]*(len(IN[v])+1)
    for pv in IN[v]:
        if dp[pv]<=len(IN[v]):
            mex[dp[pv]]=True
    for i in range(len(mex)):
        if not mex[i]:
            dp[v]=i
            break
mex=[False]*(len(IN[start])+2)
for pv in IN[start]:
    if dp[pv]!=-1 and dp[pv]<=len(IN[v])+1:
        mex[dp[pv]]=True
check=-1
for i in range(len(mex)):
    if not mex[i]:
        check=i
        break
if check==m0:
    print("POSSIBLE")
    exit()

for v in cycle:
    dp[v]=-1

#m1
dp[start]=m1
for i in range(1,len(cycle)):
    v=cycle[i]
    temp=-1
    mex=[False]*(len(IN[v])+1)
    for pv in IN[v]:
        if dp[pv]<=len(IN[v]):
            mex[dp[pv]]=True
    for i in range(len(mex)):
        if not mex[i]:
            dp[v]=i
            break
mex=[False]*(len(IN[start])+2)
for pv in IN[start]:
    if dp[pv]!=-1 and dp[pv]<=len(IN[start])+1:
        mex[dp[pv]]=True
check=-1
for i in range(len(mex)):
    if not mex[i]:
        check=i
        break
if check==m1:
    print("POSSIBLE")
    exit()

print("IMPOSSIBLE")


Measured memory_bytes: 136272
X,Y=map(int,input().split())
awa=0

if X==3:
  awa += 100000
elif X==2:
  awa += 200000
elif X==1:
  awa += 300000
  
if Y==3:
  awa += 100000
elif Y==2:
  awa += 200000
elif Y==1:
  awa += 300000
  
if X==1 and Y==1:
  awa += 400000
  
print(awa)

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

int main(){
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i = 0; i < n; i++) cin >> l[i];
    sort(l.begin(), l.end());
    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i+1; j < n; j++){
            int t = l[i] + l[j];
            int p = lower_bound(l.begin(), l.end(), t) - l.begin();
            ans += p-j-1;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
INF=10**30
N=int(input())
ball=[list(map(int,input().split()))+['r'] for i in range(N)]
ball[len(ball):len(ball)]=[list(map(int,input().split()))+['b'] for i in range(N)]
ball.sort(key=lambda x:x[0])
cnt=0
for i in range(len(ball)):
    if(ball[i][2]=='b'):
        match=INF
        Ym=-1
        for j in range(i):
            if(ball[j][2]=='r'):
                if(ball[j][1]>Ym and ball[i][1]>ball[j][1]):
                    Ym=ball[j][1]
                    match=j
        if(match!=INF):
            ball[match][1]=INF
            cnt+=1
print(cnt)

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e9;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

ll f[maxs];

int main(){
    //freopen("input00.txt","r",stdin);
    ll T = 1;
    //cin>>T;
    while(T--){
        ll n,p;
        cin>>n>>p;
        string s;
        cin>>s;
        if(p==2 or p==5){
            ll ANS=0;
            for(ll i=0;i<n;i++){
                if((s[i]-'0')%p==0){
                    ANS += i+1;
                }
            }
            cout << ANS;
            continue;
        }
        ll TEN[n+1];
        TEN[0] = 1;
        for(ll i=1;i<=n;i++){
            TEN[i] = (TEN[i-1]*10)%p;
        }
        
        ll curr=0;
        f[0]++;
        for(ll i=0;i<n;i++){
            curr = curr*10 + s[i] - '0';
            curr %= p;
            ll val = curr*TEN[n-i-1];
            val %= p;
            f[val]++;
        }
        ll ANS=0;
        for(ll i=0;i<=p;i++){
            if(f[i]){
                ANS += f[i]*(f[i]-1)/2;
            }
        }
        cout << ANS;
    }
    return 0;
}

Measured memory_bytes: 2180
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[][] A = new int[n][n];
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
        A[i][j] = 0;
      }
    }
    for(int i = 0;i < n;i++){
      int u = sc.nextInt();
      int k = sc.nextInt();
      int v = 0;
      for(int j = 0;j < k;j++){
        v = sc.nextInt();
         A[u - 1][v - 1] = 1;
      }
      }

    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++){
        if(j != n - 1)System.out.print(A[i][j]+" ");
        else System.out.println(A[i][j]);
      }     
  }
}
}


Measured memory_bytes: 31528
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	

	int A, B;
	scanf("%d%d", &A, &B);

	printf("%d", max(max(A + B, A - B), A*B));






}

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

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

    ll N;
    cin >> N;

    vector<ll> X(5);

    for(ll i = 0; i < N; i++) {
        string S;
        cin >> S;
        if(S[0] == 'M') X[0]++;
        else if(S[0] == 'A') X[1]++;
        else if(S[0] == 'R') X[2]++;
        else if(S[0] == 'C') X[3]++;
        else if(S[0] == 'H') X[4]++;
    }

    int a, b, c;
    a = 0;

    ll ans = 0;

    while(a < 5) {
        b = a + 1;
        while(b < 5) {
            c = b + 1;
            while(c < 5) {
                ans += X[a] * X[b] * X[c];
                c++;
            }
            b++;
        }
        a++;
    }

    cout << ans << endl;
}

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

int cnt(int len, int numNonZero) {
    if (len == 0 && numNonZero == 0)
        return 1;

    if (numNonZero < 0 || len == 0 || numNonZero > len)
        return 0;

    if (numNonZero == 0)
        return 1;
    else if (numNonZero == 1)
        return 9 * len;
    else if (numNonZero == 2)
        return 9 * 9 * ((len * len - len)/2);
    else if (numNonZero == 3)
        return 9 * 9 * 9 * (len*(len - 1)*(len - 2))/6;
}

//how many integers below s that contains exactly k non zero digits
int f(string s, int k) {
    int len = (int) s.length();
    int numNonZeroSoFar = 0;

    int answer = 0;
    for (int i = 0; i < len; i++) {
        int currDigit = (int) (s[i] - '0');
        for (int dig = currDigit - 1; dig >= 0; dig--) {
            if (dig == 0)
                answer += cnt(len - i - 1, k - numNonZeroSoFar);
            else
                answer += cnt(len - i - 1, k - numNonZeroSoFar - 1);
        }

        if (currDigit != 0)
            numNonZeroSoFar += 1;
    }

    return answer;
}

int main() {
    string N;
    int K;

    cin >> N >> K;

    int answer = 0;
    answer += f(N, K);

    int numNonZero = 0;
    for (int i = 0; i < N.length(); i++) {
        if (N[i] != '0')
            numNonZero += 1;
    }

    if (numNonZero == K)
        answer += 1;

    cout << answer << endl;
}


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

int main()
{
    int N;
    cin >> N;
    vector<string> S(N);
    rep(i, N) cin >> S.at(i);
    sort(S.begin(),S.end());
    S.erase(unique(S.begin(),S.end()),S.end());
    cout << S.size() << endl;
    return 0;
}

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

//create arrays outside of main()

int a[5];

int main(){

    int a;
    cin >> a;

    if (a==5 || a==7 || a==3){
        cout << "YES";
    } else {
        cout << "NO";
    }

    return 0;
}

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

using namespace std;

struct edge{int to,cost;};
typedef pair<int,int> P;

const int INF=1<<15;

int main(void)
{
	int n,m,l,k,a,h;
	while(cin>>n>>m>>l>>k>>a>>h,n){
		vector<vector<edge> > G(n);
		vector<int> cold(l);
		vector<vector<int> > memo(n,vector<int>(m+1,INF));
		priority_queue<P,vector<P>,greater<P> > q;
		for(int i=0;i<l;i++) cin>>cold[i];
		for(int i=0;i<k;i++){
			int from,to,cost;
			cin>>from>>to>>cost;
			G[from].push_back(edge{to,cost});
			G[to].push_back(edge{from,cost});
		}

		memo[h][m]=0;
		q.push(P(h,m));
		while(!q.empty()){
			P p=q.top(); q.pop();
			int from=p.first;
			int rest=p.second;
			for(int i=0;i<G[from].size();i++){
				int to=G[from][i].to;
				int cost=G[from][i].cost;
				if(find(cold.begin(),cold.end(),from)!=cold.end()){
					for(int j=0;j+rest<=m;j++){
						if(rest-cost+j >= 0 && memo[to][rest-cost+j]>memo[from][rest]+cost+j){
							memo[to][rest-cost+j]=memo[from][rest]+cost+j;
							q.push(P(to,rest-cost+j));	
						}
					}
				}else if(rest-cost >= 0 && memo[to][rest-cost]>memo[from][rest]+cost){
							memo[to][rest-cost]=memo[from][rest]+cost;
							q.push(P(to,rest-cost));	
				}
			}
		}

		int res=INF;
		for(int i=0;i<=m;i++) res=min(res,memo[a][i]);
		if(res==INF) cout<<"Help!"<<endl;
		else cout<<res<<endl;

	}

	return 0;
}

Measured memory_bytes: 2696
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
const int p=1e9+7;
int n,m,a[1005][1005],f[1005][1005];
char s[1005];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i){
		scanf("%s",s+1);
		for(int j=1;j<=m;++j)
			a[i][j]=s[j]=='.'?1:0;
	}
	f[1][1]=1;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=m;++j){
			if((i==1 && j==1) || !a[i][j])continue;
			f[i][j]=f[i-1][j]+f[i][j-1];
			if(f[i][j]>=p)f[i][j]-=p;
		}
	}
	printf("%d\n",f[n][m]);
	return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt

  val res = n match{
    case x if x <= 9 => x
    case x if x <= 99 => 9
    case x if x <= 999 => 9 + (x - 100 + 1)
    case x if x <= 9999 => 9 + 900
    case x if x <= 99999 => 9 + 900 + (x - 10000 + 1)
    case x if x <= 100000 => 9 + 900 + 90000
  }

  println(res)

}


Measured memory_bytes: 25552
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}

const ll INF=1e16;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll N;
  cin>>N;
  vector<ll> A(N);
  vector<char> op(N,'+');
  for(int i=0;i<N;i++){
    if(i!=0){cin>>op[i];}
    cin>>A[i];
  }
  vector<ll> dp1(N+1,-INF);
  vector<ll> dp2(N+1,-INF);
  vector<ll> dp3(N+1,-INF);
  dp1[0]=0;
  for(int i=0;i<N;i++){
    if(op[i]=='+'){
      dp1[i+1]=max(dp1[i+1],dp1[i]+A[i]);
      dp1[i+1]=max(dp1[i+1],dp2[i]+A[i]);
      dp1[i+1]=max(dp1[i+1],dp3[i]+A[i]);
      dp2[i+1]=max(dp2[i+1],dp2[i]-A[i]);
      dp2[i+1]=max(dp2[i+1],dp3[i]-A[i]);
      dp3[i+1]=max(dp3[i+1],dp3[i]+A[i]);
    }
    else{
      dp1[i+1]=max(dp1[i+1],dp2[i]+A[i]);
      dp1[i+1]=max(dp1[i+1],dp3[i]+A[i]);
      dp2[i+1]=max(dp2[i+1],dp1[i]-A[i]);
      dp2[i+1]=max(dp2[i+1],dp2[i]-A[i]);
      dp2[i+1]=max(dp2[i+1],dp3[i]-A[i]);
      dp3[i+1]=max(dp3[i+1],dp2[i]+A[i]);
      dp3[i+1]=max(dp3[i+1],dp3[i]+A[i]);
    }
  }
  //cout<<dp1<<endl;
  //cout<<dp2<<endl;
  dp1.back()=max(dp1.back(),dp3.back());
  cout<<max(dp1.back(),dp2.back())<<endl;

  return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#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 MOD 1000000007
#define INF 1e9
#define F first
#define S second
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(void){
    int N,ans;cin>>N;
    VI x(N,-1);
    REP(i,N)cin>>x[i];
    sort(All(x));
    ans=x[N-1]-x[0];
    if(ans%2!=0){
        ans=int(ans/2);
        ans++;
    }else{
        ans=int(ans/2);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3148
MOD = 10 ** 9 + 7

# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

A, B, C = [int(x) for x in input().split()]

ans = 0
if A + B >= C:
    ans = B + C
else:
    ans = B + A + B + 1

print(ans)

Measured memory_bytes: 3316
S=input()

from collections import Counter

c=Counter([S[0],S[1],S[2],S[3]])

if len(list(c.keys()))==2:
    flag=True
    for key in c.keys():
        if c[key]!=2:
            flag=False
            break

    if flag:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Measured memory_bytes: 3316
#include<stdio.h> 
int main(){
	int na[7]={1,3,5,7,8,10,12},nb[4]={4,6,9,11},i,j,a,b,flag;
	a=b=flag=0;
	scanf("%d %d",&a,&b);
	for(i=0;i<7;i++){
		if(na[i]==a){
			for(j=0;j<7;j++){
				if(na[j]==b){
					flag=1;
					break;
				}
			}
	//	break;
		}
	}
	if(flag==0){
		for(i=0;i<4;i++){
			if(nb[i]==a){
				for(j=0;j<4;j++){
					if(nb[j]==b){
						flag=1;
						break;
					}
				}
			//break;
			}
		}
	}
	
	if(flag==1){
		printf("Yes");
	}
	else{
		printf("No");
	}
	return 0;
}

Measured memory_bytes: 128
import sys

c = []
for i in range(3):
    c_i = list(map(int, input().split()))
    c.append(c_i)


for a1 in range(101): # 0=a<=100
    b1 = c[0][0] - a1
    b2 = c[0][1] - a1
    b3 = c[0][2] - a1
    
    a2 = c[1][0] - b1
    if a2 == c[1][1]-b2 and a2 == c[1][2]-b3:
        a3 = c[2][0] - b1
        if a3 == c[2][1]-b2 and a3 == c[2][2]-b3:
            print('Yes')
            sys.exit()

print('No')

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

int main() {

	int n,m,sum=0;
    int t[100],p[100],x[100];
	cin >> n;
	for ( int i = 0; i < n; i++)
	{
		cin >> t[i];
	}
	cin >> m;
	for (int i = 0;i < m;i++) {
		cin >> p[i]>>x[i];
	}

	for (int i = 0;i < m ;i++) {
		for (int j = 0;j < n ;j++) {
			if (j != (p[i]-1)) {
				sum += t[j];
			}
		}
		sum += x[i];
		cout << sum
			<<endl;
		sum= 0;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST       			ios_base :: sync_with_stdio(false); cin.tie(NULL);

int main() {
  FAST;
  int64_t N;
  cin >> N;
  vector<int64_t> X(N), L(N), left(N), right(N);
  vector<vector<int64_t>> data(N, vector<int64_t>(2));

  for (int64_t i = 0; i < N; i++) {
    cin >> X.at(i) >> L.at(i);
    data.at(i).at(0) = X.at(i) + L.at(i);
    data.at(i).at(1) = X.at(i) - L.at(i);
  }
  sort(data.begin(), data.end());
  int64_t length = data.at(0).at(0);
  int64_t count = 1;
  for (int64_t i = 1; i < N; i++) {
    if (data.at(i).at(1) >= length) {
      length = data.at(i).at(0);
      count++;
    }
  }
  cout << count << endl;
}

Measured memory_bytes: 8960
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;
const int inf = 1e9;
const int maxN = 2005;
bool ban[maxN];
int N, K, Q, a[maxN];

bool ok(int id, int x) {
	//cout << id << endl;
	for(int i = 1; i <= N; ++i) ban[i] = a[i] < a[id];
	ban[0] = ban[N + 1] = 1;
	int len = 0, cnt = 0;
	int ans = 0;
	int ls = id, rs = id;
	while(!ban[ls - 1]) ls--;
	while(!ban[rs + 1]) rs++;
	if(rs - ls + 1 < K) return 0;
	//cout << "************" << endl;
	//cout << ls << ' ' << rs << endl;
	for(int i = 1; i <= N + 1; ++i) {
		if(ban[i]) {
			if(len >= K) ans += min(len - K + 1, cnt);
			len = cnt = 0;
			//if(cnt) cout << id << ' ' << cnt << endl;
			continue;
		} 
		len++;
		//cout << id << ' ' << cnt << ' ' << a[i] << ' ' << a[id] << ' ' << x << endl;
		if(a[i] - a[id] <= x) cnt++;
	}
	//cout << ans << endl;
	return ans >= Q;
}

int main() {
	cin >> N >> K >> Q; for(int i = 1; i <= N; ++i) cin >> a[i];
	int ans = inf;
	for(int i = 1; i <= N; ++i) {
		int l = 0, r = inf;
		while(l < r) {
			//cout << l << ' ' << r << endl;
			int mid = (l + r) >> 1;
			if(ok(i, mid)) r = mid;
			else l = mid + 1;
		}
		//cout << a[i] << ' ' << l << endl;
		ans = min(ans, l);
	}	
	cout << ans << endl;
	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    ll n,k; cin >> n>> k;
    ll res = k;
    rep1(i,n){
        res *= k-1;
    }
    out(res);
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = readInputLine()
    
    if (S.equals("Sunny")) {
        println("Cloudy")
    } else if (S.equals("Cloudy")) {
        println("Rainy")
    } else if (S.equals("Rainy")) {
        println("Sunny")
    }
}

fun readInputLine(): String {
    return readLine()!!
}


Measured memory_bytes: 29692
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from __future__ import division, print_function
import sys


def main():
    s = sys.stdin.readline().strip()
    while True:
        s = s[:-2]
        i = len(s) // 2
        a = s[:i]
        b = s[i:]
        if a == b:
            print(len(s))
            return


if __name__ == '__main__':
    main()


Measured memory_bytes: 2568
N=int(input())
B=list(map(int,input().split(" ")))
A=[0 for _ in range(N)]
A[0]=B[0]
for i in range(N-2):
    A[i+1]=min([B[i],B[i+1]])
A[N-1]=B[N-2]
print(sum(A))

Measured memory_bytes: 3064
def comb(a, b):
  if a < b:
    return 0
  c = fact(a)
  d = fact(b)
  e = fact(a-b)
  return c//(d*e)

def fact(a):
  if a == 0:
    return 1
  return a*fact(a-1)

a, b = map(int, input().split())
res1 = comb(a, 2)
res2 = comb(b, 2)
print(res1 + res2)

Measured memory_bytes: 38256