akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
  int H, W;
  cin >> H >> W;

  vector<int> X(H), Y(W);
  vector<vector<char>> A(H, vector<char>(W));
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> A.at(i).at(j);
      if (A.at(i).at(j) == '#') X.at(i) = 1, Y.at(j) = 1;
    }
  }

  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (X.at(i) && Y.at(j)) cout << A.at(i).at(j);
    }
    if (X.at(i)) cout << "\n";
  }
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 100000

int main(void)
{
  int N, K, Q;
  int A[MAX], score[MAX];
  int i;

  scanf("%d %d %d",&N,&K,&Q);
  for(i=0;i<Q;i++)scanf("%d",&A[i]);

  for(i=0;i<N;i++)score[i]=K-Q;

  for(i=0;i<Q;i++){
    score[A[i]-1]++;
  }

  for(i=0;i<N;i++){
    if(score[i]>0)puts("Yes");
    else puts("No");
  }


  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using VI = vector<int>;
using VB = vector<bool>;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;

// 3 からsqrt(n)までの数字に対して割り切れるかどうか判定することで素数かどうか判定できる。
// 全ての数字に対して検証する必要はない
bool isPrime(int n)
{
  if (n < 2)
    return false;
  else if (n == 2)
    return true;
  else if (n % 2 == 0)
    return false;
  double sqrtn = sqrt(n);
  for (int i = 3; i <= sqrtn; i += 2){
    if ( n % i == 0) return false;
  }
  return true;
}

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

  for (int i = x; i < 1000000; i++)
  {
    if (isPrime(i)){
      cout << i << endl;
      return 0;
    }
  }
}

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

int main(){
 while(1){
     string s, f, b;
    int m;
    cin >> s;
    if (s == "-") break;
    cin >> m;
    for(int i=0; i<m; i++){
        int h;
        cin >> h;
        f = s.substr(h, s.size() -h);
        b = s.substr(0, h);
        s = f + b;
    }
    cout << s << endl;

 }
 


  return 0;
}


Measured memory_bytes: 3152
import java.util.*;
import java.math.BigInteger;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long n = sc.nextLong();
    long a = 0;
    long b = 0;
    for (long i = 1; i * i <= n; i++) {
      if (n % i == 0) {
        a = i;
        b = n / i;
      }
    }
    System.out.println(a + b - 2);
  }
}


Measured memory_bytes: 23636
n, m = map(int, input().split())
counts = [-1] * (n + 1)
counts[0] = 1
counts[1] = 1
for _ in range(m):
  counts[int(input())] = 0
for i in range(2, n + 1):
  if counts[i] < 0:
    counts[i] = (counts[i - 1] + counts[i - 2]) % 1000000007
print(counts[n])

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl
#define inc(a, b) cin >> a >> b;

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int> >;
using vii = vector<pair<int, int> >;

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; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(a - b, 0) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
  int A[100000];
  int i,j,tmp,n,r,x,p;

  
  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  r=n-1;
  p=0;
 
  x = A[r];
  i = p-1;

  for(j=p;j <= r; j++){
    if(A[j] <= x){
      i=i+1;
      tmp = A[i];
      A[i] = A[j];
      A[j] = tmp;
    
    }
   
    /*tmp=A[i+1];
    A[i+1] = A[r];
    A[r]=tmp;*/
   
  }

  for(j=0;j<n;j++){
    if(i == j) printf("[");
    printf("%d",A[j]);
    if(i == j) printf("]");
    if(j != n-1) printf(" ");
  }
  printf("\n");
  //printf("%d\n",i+1);
 
}



Measured memory_bytes: 2116
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
	//////input///////
	int r, D;
	std::vector<int> x(200);
	cin >> r >> D >> x[0];
	
	for (int i = 1; i < 100; ++i)
	{
		x[i] = x[i - 1] * r - D;
	}

	for (int i = 1; i < 11; ++i)
	{
		cout << x[i] << endl;
	}

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N, a, b, c, d; cin >> N >> a >> b >> c >> d;
  bool ok = false;
  for (ll i = 0; i <= N-1; i++) {
    if (i*c-(N-1-i)*d <= b-a && b-a <= i*d-(N-1-i)*c) ok = true;
  }
  if (ok) {cout << "YES" << endl;}
  else {cout << "NO" << endl;}
}

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b, c = 0;
  string x;
  cin >> a >> b;
  for (int i = a; i <= b; i++){
    x = to_string(i);
    if(x[0] == x[4] && x[1] == x[3]){
      c++;
    }
  }
  cout << c << '\n';
}


Measured memory_bytes: 384
#include <cstdio>
#include <cassert>
#include <algorithm>    
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define int long long
using namespace std;

typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef unsigned long long ull; 
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
//__int128
const int maxn = 2e6;
char s[maxn];
int l[maxn], r[maxn];
signed main() {
  // freopen("in.txt", "r", stdin);
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.setf(ios::fixed); cout.precision(10);
  
  cin >> (s + 1);
  int n = (int)strlen(s + 1);
  for(int i = 1; i <= n; ++i) {
    if(s[i] == '<') {
      l[i] = l[i - 1] + 1;
    } else {
      l[i] = 0;
    }
  }
  for(int i = n; i > 0; --i) {
    if(s[i] == '>') {
      r[i] = r[i + 1] + 1;
    } else {
      r[i] = 0;
    }
  }
  long long sum = 0;
  // cout << r[1] << ' ';
  for(int i = 0; i <= n; ++i) {
    sum += max(l[i], r[i + 1]);
    // cout << max(l[i], r[i + 1]) << ' ';
  }
  // cout << l[n] << endl;
  cout << sum << endl;
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	if (s[0] == 'R') {
		if (s[1] == 'R') {
			if (s[2] == 'R') cout << 3 << '\n';
			else cout << 2 << '\n';
		}
		else cout << 1 << '\n';
	}
	else if (s[1] == 'R') {
		if (s[2] == 'R') cout << 2 << '\n';
		else cout << 1 << '\n';
	}
	else if (s[2] == 'R') cout << 1 << '\n';
	else cout << 0 << '\n';
}


Measured memory_bytes: 3620
import sys
s = input()
n = 4

for i in range(2**(n-1)):
    e = ""
    for j in range(n-1):
        if (i>>j)& 1 == 1:
            e += s[j] + "+"
        else:
            e += s[j] + "-"
    e += s[-1]
    if eval(e) == 7:
        print(e+"=7")
        sys.exit()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int a, b;
  cin >> a >> b;
  int diff = b - a;
  int ans = 0;
  for (int i = 1; i < diff; i++) {
    ans += i;
  }
  ans -= a;
  cout << ans << endl;
}


Measured memory_bytes: 3608
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

import static java.lang.Integer.parseInt;

/**
 * Graph II - Single Source Shortest Path I
 */
public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		int n = parseInt(br.readLine());

		Graph G = new Graph(n);

		for (int i = 0; i < n; i++) {
			StringTokenizer st = new StringTokenizer(br.readLine());
			int u, k;
			u = parseInt(st.nextToken());
			k = parseInt(st.nextToken());
			for (int j = 0; j < k; j++) {
				int v, c;
				v = parseInt(st.nextToken());
				c = parseInt(st.nextToken());
				Edge e = new Edge();
				e.s = G.vs[u];
				e.t = G.vs[v];
				e.cost = c;
				G.es.get(e.s).add(e);
			}
		}

		//
		G.vs[0].cost = 0;

		Queue<Vertex> pq = new PriorityQueue<>();
		pq.offer(G.vs[0]);

		while (!pq.isEmpty()) {
			Vertex s = pq.poll();
			for (Edge e : G.es.get(s)) {
				if (e.t.cost > s.cost + e.cost) {
					e.t.cost = s.cost + e.cost;
					if (!pq.contains(e.t)) {
						pq.offer(e.t);
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			System.out.println(i + " " + G.vs[i].cost);
		}

	} //end main
}

class Graph {

	static int INF = 1 << 29;

	Vertex[] vs;
	Map<Vertex, List<Edge>> es;

	Graph(int n) {
		vs = new Vertex[n];
		for (int i = 0; i < n; i++) {
			vs[i] = new Vertex();
		}
		es = new HashMap<>();
		for (int i = 0; i < n; i++) {
			es.put(vs[i], new ArrayList<>());
		}
	}
}

class Vertex implements Comparable<Vertex> {
	int cost = Graph.INF;
	boolean passed = false;

	@Override
	public int compareTo(Vertex o) {
		return Integer.compare(this.cost, o.cost);
	}
}

class Edge {
	Vertex s, t;
	int cost;
}

Measured memory_bytes: 88364
<?php

while (true) {
    $employeeCount = getStdin();
    if ($employeeCount == 0) { break; }
    
    $passedEmployees = [];
    $sums = [];
    for ($i = 0; $i < $employeeCount; $i++) {
        list($employeeNumber, $price, $salesNumber) = explodeStdin();
        if (! empty($sums[$employeeNumber])) {
            $sums[$employeeNumber] += $price * $salesNumber;
        } else {
            $sums[$employeeNumber] = $price * $salesNumber;
        }
    }
    
    foreach ($sums as $number => $sum) {
        if ($sum >= 1000000) {
            $passedEmployees[] = $number;
        }
    }

    $results[] = (count($passedEmployees) > 0) ? ($passedEmployees) : ['NA'];
}

foreach ($results as $result) {
    echo implode(PHP_EOL, $result), PHP_EOL;
}





function getStdin()
{
    return trim(fgets(STDIN));
}

function explodeStdin()
{
    return explode(' ', getStdin());
}

Measured memory_bytes: 15468
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pi = pair<int, int>;
const int MAXN = 200005;
const int mod = 1e9 + 7;

int n;
pi a[MAXN];
lint ret[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++){
		scanf("%d",&a[i].first);
		a[i].second = i;
	}
	sort(a, a + n, [&](const pi &a, const pi &b){
		return pi(-a.first, a.second) < pi(-b.first, b.second);
	});
	int run_min = 1e9;
	for(int i=0; i<n; ){
		int e = i;
		while(e < n && a[i].first == a[e].first) e++;
		for(int j=i; j<e; j++) run_min = min(run_min, a[j].second);
		ret[run_min] += 1ll * (a[i].first - a[e].first) * e;
		i = e;
	}
	for(int i=0; i<n; i++) printf("%lld\n", ret[i]);
}


Measured memory_bytes: 2688
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        h: usize,
        w: usize,
        s: [chars; h],
    }
    let mut dp = vec![0; w];
    let p = 1000000000 + 7;
    dp[0] = 1;
    for i in 0..h {
        if s[i][0] == '#' {
            dp[0] = 0;
        }
        for j in 1..w {
            dp[j] = (dp[j] + dp[j - 1]) % p;
            if s[i][j] == '#' {
                dp[j] = 0;
            }
        }
    }
    println! ("{}", dp[w - 1]);
}

fn main() {
    run();
}


Measured memory_bytes: 8572
#include<cstdio>
#include<iostream>
#include<cmath>
#include<ctype.h>
#include<vector>
#include<cstdlib>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<time.h>

#define ll long long
#define LL long long
#define ULL unsigned long long 
#define ull unsigned long long 
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
const ll INF = -10000000000;
using namespace std;

int memo[25] = {};

int main()
{
	string w;
	cin >> w;
	for (int i = 0; i < w.length(); i++) {
		memo[w[i] - 97]++;
	}

	for (int i = 0; i < 25; i++) {
		if (memo[i] % 2 != 0) {
			cout << "No" << endl;
			return 0;
		}
	}

	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char s[200001], t[200001];
	int i, cnt = 0;

	scanf("%s", s);
	scanf("%s", t);
	for (i = 0; s[i] != '\0'; i++)
	{
		if (s[i] != t[i])
			cnt++;
	}

	printf("%d", cnt);

	return 0;
}

Measured memory_bytes: 2116
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<int, int> pint;
template <class T> inline void chmax(T &a, const T b) { a = max(a, b); }
template <class T> inline void chmin(T &a, const T b) { a = min(a, b); }
template <class T> void pp(T v, int n) { REP(i,n) cout<<v[i]<< ' '; cout << endl; }

void inline TorF(bool tf, const string &trueMessage, const string &falseMessage) { 
  cout << (tf ? trueMessage : falseMessage) << endl;
}
void inline YESNO(bool tf) { TorF(tf, "YES", "NO"); }
void inline YesNo(bool tf) { TorF(tf, "Yes", "No"); }

int main() {
  int N; cin>>N;
  vector<int> L(N, 0);
  REP(i,N) {
    int a; cin>>a;
    L[i] = a;
  }
  sort(L.begin(), L.end());
  ll ans = 0;
  //  pp(L, 10);
  REP(i, N) {
    for(int j = i+1; j < N; j++) {
      for(int k = j+1; j < N; k++) {
	if(L[k] >= L[i] + L[j]) break;
	if(L[i] >= L[j] + L[k]) continue;
	if(L[j] >= L[i] + L[k]) continue;
	ans++;
	//	cout << L[i] << L[j] << L[k] << endl;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 2019;

int main(int argc, char *argv[]) {
    ll l, r;
    cin >> l >> r;

    ll lmod = l%MOD;
    ll rmod = r%MOD;

    ll ans = LONG_LONG_MAX;
    for (int i = l; i < min(l + 2019, r); ++i) {
        for (int j = i + 1; j <= min(l + 2019, r); ++j) {
            ans = min(ans, (i%MOD*j%MOD)%MOD);
        }
    }

    MSG(ans)
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int a, b, diff, tower1 = 0;
  	scanf("%d%d", &a, &b);
  	diff = b - a;
  	for (int i = 1; i < diff; i++){
    	tower1 += i;
    }
  	printf("%d", tower1 - a);
}

Measured memory_bytes: 128
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,x;
	cin>>n;
	pair< pair<string,int>, int> p[n+1];
	for0(i,n){
		string s;
		cin>>s;
		cin>>x;
		p[i] = mp(mp(s,-x),i+1);
		}
	sort(p,p+n);
	for0(i,n) cout<<p[i].se<<nw;
	
	return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        int i = 1;
        int oldRank = -1;
        Scanner sc = new Scanner(System.in);
        List<Team> team = new ArrayList<Team>();
        while (true) {
            String[] in = sc.nextLine().split(",");
            int num = Integer.parseInt(in[0]);
            int ac = Integer.parseInt(in[1]);
            if (num == 0 && ac == 0) {
                break;
            }
            team.add(new Team(num, ac));
        }
        Collections.sort(team, new Team());
        for (Team t : team) {
            if (oldRank == -1) {
                oldRank = t.getAccept();
            }
            if (oldRank != t.getAccept()) {
                i++;
            }
            t.setRank(i);
            oldRank = t.getAccept();
        }
        while (sc.hasNext()) {
            int teamNumber = sc.nextInt();
            for (Team t : team) {
                if (teamNumber == t.getTeamNum()) {
                    System.out.println(t.getRank());
                }
            }
        }
    }
}
class Team implements Comparator<Team> {
    private int teamNumber;
    private int teamAccept;
    private int teamRank;

    public Team(int num, int ac) {
        this.teamNumber = num;
        this.teamAccept = ac;
    }

    public Team() {
    }

    public List<Team> sortTeam(List<Team> t) {
        return t;
    }

    public String getTeamString() {
        return "(" + teamNumber + "," + teamAccept + ")" + teamRank;
    }

    public void setRank(int rank) {
        this.teamRank = rank;
    }

    public int getRank() {
        return this.teamRank;
    }

    public int getAccept() {
        return this.teamAccept;
    }

    public int getTeamNum() {
        return this.teamNumber;
    }

    public int compare(Team o1, Team o2) {
        int team1 = o1.teamAccept;
        int team2 = o2.teamAccept;
        if (team1 > team2) {
            return -1;
        } else if (team1 == team2) {
            return 0;
        } else {
            return 1;
        }
    }
}

Measured memory_bytes: 17300
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
string u="abcdefghijklmnopqrstuvwxyz";

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    string s;
    cin >> s;
    int counta=0,countb=0;
    for(int i=0;i<s.length();i++){
        if(counta+countb<A+B){
            if(s[i]=='a'){
                counta++;
                puts("Yes");
            }
            else if(s[i]=='b'){
                if(countb<B){
                    countb++;
                    puts("Yes");
                }
                else puts("No");
            }
            else puts("No");
        }
        else puts("No");
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#include <stdio.h>
#define ff(i,x,y)for(int i=x;i<y+1;i++)
#define fs(i,x,y)for(int i=x;i>y-1;i--)
#define all(x) x.begin(),x.end()
#define Ins(x) inserter(x,x.begin())
using namespace std;
typedef long long ll;
ll mx1,mx2;
map<ll,int>mp;
int main()
{
    ll now;
    int n;
    scanf("%d",&n);
    ff(i,1,n)
    {
        scanf("%lld",&now);
        mp[now]++;
        if(mp[now]%2==0)
        {
            if(now>mx1)
            {
                mx2=mx1;
                mx1=now;
            }
            else if(now>mx2)
                mx2=now;
        }
    }
    cout<<mx1*mx2<<endl;
	return 0;
}


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

int main() {
    while(true) {
        string s;
        getline(cin, s);
        if (s == "END OF INPUT") return 0;
        int count = 0;
        for (int i = 0; i < s.size(); i++) {
            if (s[i] == ' ') {
                cout << count;
                count = 0;
            } else {
                count++;
                if (i == s.size() - 1) {
                    cout << count;
                }
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 2984
#include <bits/stdc++.h>
using namespace std;
#define loop(i,b,e) for(int i=b;i<=e;i++)
#define loop2(i,e,b) for(int i=e;i>=b;i--)
#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define fi first
#define se second
typedef long long ll;
typedef unsigned long long ull;
const int N = 1e6 + 5;
const ll mod = 1e9 + 7;
const int oo = 1e9;

int n,k;
int t[N];

int main() {
	scanf("%d%d",&n,&k);
	int sum = 0;
	for (int i = 0; i < n; ++i){
		scanf("%d",&t[i]);
		sum += t[i];
	}
	sort(t,t+n);
	int ans = n;
	k -= sum;
	while(k>0){
		if(k-t[0]>=0) ans++,k-=t[0];
		else break;
	}
	printf("%d",ans);
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>

using namespace std;

#define MAX_N 100000
typedef pair<char, int> card;
card A[MAX_N];

// NOTE: used for storing order of card.
map<int, vector<char> > orders;
map<int, int> indices;

#define SWAP(X, Y) do { \
  card tmp = X;         \
  X = Y;                \
  Y = tmp;              \
} while(0)

int Partition(int p, int r) {
  card x = A[r];
  int i = p - 1;
  for (int j = p; j < r; ++j) {
    if (A[j].second <= x.second) {
      i = i + 1;
      SWAP(A[i], A[j]);
    }
  }
  SWAP(A[i+1], A[r]);
  return i + 1;
}

void Quicksort(int p, int r) {
  if (p < r) {
    int q = Partition(p, r);
    Quicksort(p, q - 1);
    Quicksort(q + 1, r);
  }
}

int main(int argc, char** argv) {
  int n;
  cin >> n;
  for(int i = 0; i < n; ++i) {
    cin >> A[i].first;
    cin >> A[i].second;

    int n = A[i].second;
    orders[n].push_back(A[i].first);
    indices[n] = 0;
  }

  Quicksort(0, n - 1);

  int stable = true;
  for(int i = 0; i < n; ++i) {
    int n = A[i].second;
    if (orders[n][indices[n]] != A[i].first) {
      stable = false;
    }
    indices[n] += 1;
  }

  if (stable) {
    cout << "Stable" << endl;
  } else {
    cout << "Not stable" << endl;
  }
  for(int i = 0; i < n; ++i) {
    cout << A[i].first << " " << A[i].second << endl;
  }

  return 0;
}



Measured memory_bytes: 7796
A,B,C,D,E,F = map(int,input().split())

waters = set()
for w1 in range(0,F+1,B):
    if w1*100 > F: break
    for w2 in range(0,F+1,A):
        w = (w1+w2)*100
        if w > F: break
        if w==0: continue
        waters.add(w)

sugars = set()
for s1 in range(0,F+1,D):
    if s1 > F: break
    for s2 in range(0,F+1,C):
        s = s1+s2
        if s > F: break
        sugars.add(s)

ans_r = -1
ans_s = ans_w = None
for w in sorted(waters):
    if w > F: break
    for s in sorted(sugars):
        if w+s > F: break
        if s*100 > w*E: break
        r = 100*s/(s+w)
        if r > ans_r:
            ans_r = r
            ans_w = w
            ans_s = s
print(ans_s+ans_w, ans_s)


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

#define PI 3.14159265358979323846264338327950L
#define ll long long

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    while (n > 0) {
        int digit = n % 10;
        if (digit == 7) {
            cout << "Yes" << "\n";
            return 0;
        }
        n = n / 10;
    }
    cout << "No" << "\n";



}


Measured memory_bytes: 3620
fact = [None]*1000001
inv = [0,1]
finv = [1,1]

x, y = map(int, input().split())
total = x+y
ans = 0
MOD = 10**9+7

if total%3 == 0 and max(x,y) <= min(x,y)*2:
    fact[1] = 1
    for i in range(2,1000001):
        fact[i] = fact[i-1]*i%MOD
        inv.append((-inv[MOD%i] * (MOD//i)) % MOD)
        finv.append(finv[-1] * inv[-1] % MOD)
    step = int(total/3)
    sa = abs(x-y)
    a = int((step-sa)/2)
    b = int((step+sa)/2)
    ans = fact[step] * finv[a] * finv[b] % MOD
print(ans)

Measured memory_bytes: 127592
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  string S1, S2, S3;
  cin >> S1 >> S2 >> S3;
  cout << S1[0] << S2[0] << S3[0] << endl;
  return 0;
}

Measured memory_bytes: 3528
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		long N = GetLong();
		long M = GetLong();
		
		long ans = divisors(M).Where(x => x <= M/N).Select(x => x).Max();
		Console.WriteLine(ans);
	}

	private static List<long> divisors(long N)
	{
		List<long> divisors = new List<long>();
		
		long floorSqrtN = (long)Math.Sqrt(N);
		for(long i = 1; i < floorSqrtN; i++)
		{
			if(N % i == 0)
			{
				divisors.Add(i);
				divisors.Add(N/i);
			}
		}
		if(floorSqrtN * floorSqrtN == N)
			divisors.Add(floorSqrtN);
		
		return divisors;
	}
}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}


Measured memory_bytes: 13396
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32


def solve(N: int, X: "List[int]", L: "List[int]"):
    s = [X[i]-L[i] for i in range(N)]
    e = [X[i]+L[i] for i in range(N)]
    se = [[s[i],e[i]] for i in range(N)]
    se = sorted(se, key=lambda x:x[1])

    ans = [se[0]]

    for i in range(1, N):
        if se[i][0] < ans[-1][1]:
            continue
        else:
            ans.append(se[i])

    # print(ans)
    print(len(ans))

    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    X = [int()] * (N)  # type: "List[int]"
    L = [int()] * (N)  # type: "List[int]"
    for i in range(N):
        X[i] = int(next(tokens))
        L[i] = int(next(tokens))
    solve(N, X, L)

if __name__ == '__main__':
    main()


Measured memory_bytes: 31560
object Main extends App {
  val num = scala.io.StdIn.readLine.toInt
  val str = scala.io.StdIn.readLine

  println(RotCharList(str) rot num rawString())
}

class RotChar(val symbol: Char) {
  def rot(num: Int): RotChar = {
    val rotSymbol = symbol + num.toChar
    RotChar((if (rotSymbol > 'Z') {
      rotSymbol - ('Z' - 'A') - 1
    } else {
      rotSymbol
    }).toChar)
  }

  override def toString: String = symbol.toString

  override def equals(that: Any): Boolean = {
    that match {
      case that: RotChar => this.symbol == that.symbol
      case _ => false
    }
  }
}

object RotChar {
  def apply(symbol: Char) = new RotChar(symbol)
}


class RotCharList(val value: Seq[RotChar]) {
  def rot(num: Int) = {
    new RotCharList(value.map(_.rot(num)))
  }

  override def equals(that: Any): Boolean = {
    that match {
      case that: RotCharList => this.value == that.value
      case _ => false
    }
  }

  override def toString: String = rawString()

  def rawString(): String = {
    value.map(_.symbol).mkString
  }
}

object RotCharList {
  def apply(value: String): RotCharList = {
    new RotCharList(value.map(RotChar.apply))
  }
}

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

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = (int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dr[4] = {1, 0, -1, 0};
const int dc[4] = {0, 1, 0, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T, typename U, typename V> inline
ostream& operator<<(ostream &o, tuple<T,U,V> &p)
{
    return o << "{" << get<0>(p) << "," << get<1>(p) << "," << get<2>(p) << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

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

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    string s, t;

    cin >> s >> t;

    int n = s.size();
    int ans = 0;
    irep(i, n) {
        if(s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

/*atcoder*/


Measured memory_bytes: 3896
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApp5
{
    class Program
    {
        static void Main(string[] args)
        {
            {
                int a, b;
                for (a = 1; a <= 9; a++)
                {
                    for (b = 1; b <= 9; b++)
                    {
                        Console.WriteLine("{0}x{1}={2}", a, b, a * b);

                    }
                }







            }




        }
    }
}

Measured memory_bytes: 8916
#include<bits/stdc++.h>
using namespace std;
map<char,char> k;
int main()
{
	char n;
	k['1']='9';
	k['2']='8';
	k['3']='7';
	k['4']='6';
	k['5']='5';
	k['6']='4';
	k['7']='3';
	k['8']='2';
	k['9']='1';
	for(int i=0;i<3;i++)
	{
		cin>>n;
		cout<<k[n];
	}
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
string str;
int n,k,a[MAXN];
vector<int> G[MAXN];
int cnt[MAXN],dp[MAXN],low[MAXN];
void dfs(int v,int p)
{
    dp[v]=low[v]=0;
    cnt[v]=(str[v]=='1'?1:0);
    P tmp=P(0,0);
    for(auto to:G[v])
    {
        if(to==p) continue;
        dfs(to,v);
        dp[v]+=dp[to]+cnt[to];
        cnt[v]+=cnt[to];
        tmp=max(tmp,P(dp[to]+cnt[to],low[to]+cnt[to]));
    }
    if(tmp.S>dp[v]-tmp.F) low[v]=tmp.S-(dp[v]-tmp.F);
    else low[v]=dp[v]&1;
}
int main()
{
    scanf("%d",&n);
    cin>>str;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        u--; v--;
        G[u].push_back(v);G[v].push_back(u);
    }
    int ans=INF;
    for(int i=0;i<n;i++)
    {
        dfs(i,-1);
        if(low[i]==0) ans=min(ans,dp[i]);
    }
    if(ans==INF) puts("-1"); else printf("%d\n",ans/2);
    return 0;
}



Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N, H;
    cin >> N >> H;
    vector<int> a(N), b(N);
    priority_queue<int> qa, qb;
    for (int i = 0; i < N; i++){
        cin >> a.at(i) >> b.at(i);
        qa.push(a.at(i));
        qb.push(b.at(i));
    }
    int max_a = qa.top();
    int count = 0;
    while (H > 0) {
        int x = 0;
        if (!qb.empty()){
            x = qb.top();
            qb.pop();
        }
        if (x <= max_a){
            if (H % max_a == 0){
                count += H / max_a;
            }
            else{
                count += H / max_a + 1;
            }
            break;
        }
        else {
            H -= x;
            count ++;
        }
        //cout << H << " " << count << endl;
    }
    cout << count << endl;
}

Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL a,b;
LL gcd(LL x,LL y){
    return y ? gcd(y,x%y) : x;
}
int gao(LL x){
    int cnt = 0;
    int tp = sqrt(x);
    for(int i = 2; i <= tp; i++){
        if(x%i==0){
            cnt++;
            while(x%i==0) x/=i;
        }
        if(x==1) break;
    }
    if(x!=1) cnt++;
    return cnt;
}
int main(){
    cin >> a >> b;
    LL g = gcd(a,b);
    cout << gao(g)+1 << endl;
    return 0;
}

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

//int mod = 1000000007;
  
int main(){
  int h, w;
  cin >> h >> w;
  
  vector<string> g(h);
  
  for(int i = 0; i < h; i++){
    cin >> g.at(i);        
  }
  
  vector<vector <int>> l(h, vector<int> (w, 0)), 
  r(h, vector<int> (w, 0)),
  u(h, vector<int> (w, 0)),
  d(h, vector<int> (w, 0));
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g.at(i).at(j) == '#') l.at(i).at(j) = 0;
      else if(j == 0) l.at(i).at(j) = 1;
      else l.at(i).at(j) = l.at(i).at(j-1) + 1;
    }
  }
  
  for(int i = 0; i < h; i++){
    for(int j = w-1; j >= 0; j--){
      if(g.at(i).at(j) == '#') r.at(i).at(j) = 0;
      else if(j == w - 1) r.at(i).at(j) = 1;
      else r.at(i).at(j) = r.at(i).at(j+1) + 1;
    }
  }
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g.at(i).at(j) == '#') u.at(i).at(j) = 0;
      else if(i == 0) u.at(i).at(j) = 1;
      else u.at(i).at(j) = u.at(i - 1).at(j) + 1;
    }
  }
  
  for(int i = h - 1; i >= 0; i--){
    for(int j = 0; j < w; j++){
      if(g.at(i).at(j) == '#') d.at(i).at(j) = 0;
      else if(i == h - 1) d.at(i).at(j) = 1;
      else d.at(i).at(j) = d.at(i + 1).at(j) + 1;
    }
  }
  
  int answer = 0;
  
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g.at(i).at(j) == '#') continue;
      answer = max(answer,
                   l.at(i).at(j) + r.at(i).at(j) + u.at(i).at(j) + d.at(i).at(j) - 3);
    }
  }
  
  cout <<  answer << endl;
  
}

Measured memory_bytes: 67200
from sys import stdin
input = stdin.readline
MOD = 10**9 + 7

if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    S = A[0]
    ans = 0
    for i in range(1, N):
        ans += S * A[i]
        ans %= MOD
        S += A[i]
        S %= MOD
    print(ans)

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

#define TC int T;cin>>T;for(int tc=1;tc<=T;++tc)

using ll=long long;
constexpr ll mod=1000000007;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n,k;
    cin>>n>>k;
    vector<ll>a(n);
    for(ll i=0;i<n;++i)cin>>a[i];
    ll beg=1,end=1000000000,ans=end;
    while(beg<=end){
        ll mid=beg+end>>1;
        ll cuts=0;
        for(ll i=0;i<n;++i){
            cuts += (a[i]+mid-1)/mid-1;
        }
        if(cuts<=k){
            ans=mid;
            end=mid-1;
        }else{
            beg=mid+1;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 4744
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication22
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());

            string[] x = Console.ReadLine().Split(' ');
            int[] xArray = Array.ConvertAll(x,int.Parse);

            string[] y = Console.ReadLine().Split(' ');
            int[] yArray = Array.ConvertAll(y, int.Parse);

            //p = 1?????¨???
            int sum1 = 0;
            for (int i = 0; i < n; ++i)
            {
                sum1 += Math.Abs(xArray[i] - yArray[i]);
            }
            Console.WriteLine("{0:f8}",sum1);

            //p = 2?????¨???
            double sum2 = 0;
            for (int i = 0; i < n; ++i)
            {
                sum2 += Math.Pow(Math.Abs(xArray[i] - yArray[i]),2);
            }
            sum2 = Math.Sqrt(sum2);
            Console.WriteLine("{0:f8}",sum2);

            //p = 3?????¨???
            double sum3 = 0;
            for (int i = 0; i < n; ++i)
            {
                sum3 += Math.Pow(Math.Abs(xArray[i] - yArray[i]), 3);
            }
            sum3 = Math.Pow(sum3,1.0 / 3.0);
            Console.WriteLine("{0:f8}",sum3);

            //p = ????????¨???
            double max = Math.Abs(xArray[0] - yArray[0]);
            for (int i = 1; i < n; ++i)
            {
                max = Math.Max((Math.Abs(xArray[i] - yArray[i])),max);
            }
            Console.WriteLine("{0:f8}",max);

        }
    }
}

Measured memory_bytes: 5756
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
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> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}


int main() {
  int h,w; cin >>h >>w;
  vector<vector<string>> field(h, vector<string>(w));
  rep(i, h) rep(j, w) cin >>field[i][j];
  string res;
  rep(i, h){ rep(j, w){
    if (field[i][j] == "snuke"){
      cout <<(char)('A' + j) <<i+1 <<endl;
    }
  }}
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			string s = n.ToString();
			int m = s.Length;
			
			var dp0 = new long[m, 10, 10];
			var dp1 = new long[m, 10, 10];
			for (int i = 1; i < 10; i++) {
				if (i == s[0] - '0') {
					dp1[0, i, i]++;
				} else if (i < s[0] - '0') {
					dp0[0, i, i]++;
				}
			}

			for (int i = 1; i < m; i++) {
				int t = s[i] - '0';
				for (int j = 0; j < 10; j++) {
					dp0[i, j, j] += 1;

					for (int k = 0; k < 10; k++) {
						for (int l = 0; l < 10; l++) {
							dp0[i, k, j] += dp0[i - 1, k, l];
						}

						if (j == t) {
							for (int l = 0; l < 10; l++) {
								dp1[i, k, j] += dp1[i - 1, k, l];
							}
						} else if (j < t) {
							for (int l = 0; l < 10; l++) {
								dp0[i, k, j] += dp1[i - 1, k, l];
							}
						} 
					}
				}
			}

			long ans = 0;
			for (int i = 1; i < 10; i++) {
				for (int j = 1; j < 10; j++) {
					ans += (dp0[m - 1, i, j] + dp1[m - 1, i, j]) * (dp0[m - 1, j, i] + dp1[m - 1, j, i]);
				}
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 11220
//∑_{a=1}^K ∑{b=1}^K ∑_{c=1}^K gcd(a,b,c) を求めてください。
//ただし、gcd(a,b,c) は a,b,c の最大公約数を表します。

#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i = 0; i < (n); ++i )
#define rep_rev(n,i) for(ll i = n; i >= 0; --i )
using namespace std;
using P = pair<int, int>;
const long long INF = 1LL << 60;

int GCD2(int a, int b){
  if(a == b) return a;
  if(a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  int r = a % b;
  while(r != 0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}

int GCD3(int a, int b, int c) { return GCD2(GCD2(a,b),c); }


int main(){
  int K, sum = 0; cin >> K;
  for(int i = 1; i <= K; ++i){
    for(int j = 1; j <= K; ++j){
      for(int l = 1; l <= K; ++l){
        sum += GCD3(i,j,l);
      }
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 3676
# ほんとうに全ての値を最初に計算し、累積和のリストを作成してしまおう。
# 計算時間は421msでOKだけど、答えが間違っている。＝＞なおした

import math

def is_prime(n):
    if n == 1: return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


# 2017に似た数

def is_like2017(n):
    if is_prime(n) and is_prime((n+1)//2):
        return True
    else:
        return False


Q = int(input())

l_list = [0]*Q
r_list = [0]*Q

for i in range(Q):
    l_list[i], r_list[i] = map(int, input().split())
    

ans = [0]

for i in range(1, 100000+1):
    if i % 2 == 0:
        ans.append(ans[i-1])
    elif is_like2017(i):
        ans.append(ans[i-1] + 1)
    else:
        ans.append(ans[i-1])    
        
for i in range(Q):
    print(ans[r_list[i]]-ans[l_list[i]-1])
   

Measured memory_bytes: 12584
# coding=utf-8

###
### for python program
###

import sys
import math

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    def pnum_check(self, n):
        if (n==1):
            return False
        elif (n==2):
            return True
        else:
            for x in range(2,n):
                if(n % x==0):
                    return False
            return True

    ### GCD
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

    ### LCM
    def lcm(self, a, b):
        return (a*b)//self.gcd(a,b)

    ### Mat Multiplication
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()

### output class
class output:
    ### list
    def list(self, l):
        l = list(l)
        #print(" ", end="")
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

#abc list
#abc = [chr(ord('a') + i) for i in range(26)]

### output sample
# print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
# print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
# print(" {}".format(i), end="")

# def printA(A):
#     for i, n in enumerate(A):
#         print(n, end='')
#         if i != N-1:
#             print(' ', end='')
#     print()

# リスト内包表記 ifあり
# [x-k if x != 0 else x for x in C]

# ソート
# N = N.sort()

# 10000個の素数リスト
# P = mymath.pnum_eratosthenes(105000)

def is_integer(n):
    try:
        float(n)
    except ValueError:
        return False
    else:
        return float(n).is_integer()

def dist(A, B):
    d = 0
    for i in range(len(A)):
        d += (A[i]-B[i])**2            
    d = d**(1/2)
    return d

def get_input():
    N = []
    while True:
        try:
            #N.append(input())
            N.append(int(input()))
            #N.append(float(input()))
        except EOFError:
            break
    return N

N = get_input()

for n in N:
    ans = 2
    for i in range(2,n+1):
        ans += i
    print(ans)





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

typedef long long int ll;
ll powk(ll a, ll n){
    ll r = 1;
    for(ll i = 0;i < n;i++){
        r *= a;
    }

    return r;
}

int main()
{
    string s;
    ll k;
    cin >> s >> k;
    for(ll i = 0;i < k;i++){
        if(s[i] != '1'){
            cout << s[i];
            return 0;
        }
    }

    cout << 1;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int MAX_VALUE = 1E5 + 5; 
const int INF = 1001001001;
int main(){
  int n, W;
  cin >> n >> W;
  vector<pair<long, long>> item(n);
  for(int i = 0; i < n; ++i) cin >> item[i].first >> item[i].second;
  long long dp[n + 1][MAX_VALUE];
  for(int i = 0; i < n + 1; ++i)for(int j = 0; j < MAX_VALUE; ++j)dp[i][j] = INF;
  dp[0][0] = 0;
  for(int i = 0; i < n; ++i){
    for(int v = 0; v < MAX_VALUE; ++v){
      if(v - item[i].second >= 0) dp[i + 1][v] = min(dp[i][v - item[i].second] + item[i].first, dp[i][v]);
      else dp[i + 1][v] = dp[i][v];
    }
  }
  int ans = 0;
  for(int i = 0; i < MAX_VALUE; ++i){
    if(dp[n][i] <= W) ans = i;
  }
  cout << ans << endl;
}

Measured memory_bytes: 79104
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;

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


Measured memory_bytes: 256