akhauriyash/Code-Regression huggingface dataset:
#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(){
    vector<int> t(3);
    rep(i,3) cin >> t[i];
    int ans = 1e9;
    do{
        int c = abs(t[0]-t[1]) + abs(t[1]-t[2]);
        ans = min(ans, c);
    }while(next_permutation(t.begin(), t.end()));
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    ll m;cin>>m;
    ans=100*(n-m)+1900*m;
    For(i,0,m) ans*=2;
    cout<<ans<<endl;
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		// 入力
		int k = sc.nextInt();

		int ans = 0;

		//kが偶数か
		if (k / 2 == 0) {
			ans = (k/2) * (k/2);
		} else {
			ans = ((k+1)/2) * (k/2);
		}

		// 出力
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n,m;
  while(1){
    cin>>n>>m;
    if(n==0 && m==0)break;
    pii p[10000];
    rep(i,n)
      cin>>p[i].second>>p[i].first;
    sort(p,p+n,greater<pii>());//???????????????                                 
    ll cost=0;
    rep(i,n)
      if(p[i].second<=m)
        m-=p[i].second;
      else{
        cost+=(p[i].second-m)*p[i].first;
        m=0;
      }
    cout<<cost<<endl;
  }
}

Measured memory_bytes: 3160
#include<stdio.h>
#include<iostream>

using namespace std;

int N,x;
int main(){
    cin >> N >> x;
    long long int pre = 0;
    long long int ans = 0;
    cin >> pre;
    for(int i=1; i<N; i++){
        long long int eat=0;
        long long int y;
        cin >> y;
        if ( pre + y > x ) {
            eat = pre + y - x;
            ans += eat;
        }
        pre = max(y - eat,eat-eat);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int top,S[1000];

void push(int x){
 
   top++;
   S[top] = x;
   // printf("%d",x);
 }

int pop(){
   
   top--;
   return S[top+1];
 }


int main(){
  int a,b;
  top=0;
  char s[100];

  while( scanf("%s",s) != EOF ){
    if ( s[0] == '+' ){
      a =pop();
      b =pop();
      push(a + b);
      
    } else if ( s[0] == '-' ){
      b=pop();
      a=pop();
      push(a - b);
    } else if ( s[0] == '*' ){
      a=pop();
      b=pop();
      push(a * b);
    } else {
      push(atoi(s));

    }
  
  }
  printf("%d\n",pop());

  return 0;
}



Measured memory_bytes: 2052
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double d;
  cin >> d;
  int D = 1000*d;
  double ans = d/sqrt(2)*2;
  for(int x = 0; x * x <= D*D; x += 1000) {
    double y = sqrt(D*D-x*x);
    // cerr << "(x,y) = " << x/1000 << "," << y/1000 << endl;
    double X = x/1000;
    double Y = y/1000;
    if(Y >= 1.0) {
      ans = max(ans, X+Y);
    }
    else {
      ans = max(ans, X+1);
    }
  }
 
  cout.setf(ios::fixed);
  cout.precision(12);
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 1284
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

long long a, b, n;

int main() {
    cin >> a >> b >> n;
    long long ch = n/b;
    if(ch == 0) {
        cout << a*n/b - a * (n/b) << endl;
    }else {
        cout << a*(b-1)/b - a * ((b-1)/b) << endl;
    }
}

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

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 ff			 first
#define ss			 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 endl		     "\n"
#define abs(x)		 fabs(x)
#define all(v) 		 v.begin(),v.end()
#define pcase(z,x)   cout<<"Case "<<z<<": "<<x<<"\n"
#define mod          1000000007
#define WakandaForever     ios_base::sync_with_stdio(0); cin.tie(0);

int main()
{
    WakandaForever
    string s;
    cin>>s;
    int n = s.size();
    if(s[n-1]=='s') s += "es";
    else s += 's';

    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 3660
function Main(input)
{
	input = input % 10;
	var d = "";

	if (input == 3)
	{
		d = "bon";
	}else if ([2, 4, 5, 7, 9].includes(input))
	{
		d = "hon";
	}else{
		d = "pon";
	}

	console.log(d);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29464
/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,k,s;
int main(){
	fastio;
	cin>>n>>k>>s;
	rb(i,1,k) cout<<s<<" ";
	int is=1;
	while(n){
		if(s%is!=0)break;
		is++;
	} 
	rb(i,k+1,n) cout<<is<<" "; 
	return 0;
}


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

int main() {
  long long a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;
  
  bool ans = true;
  
  if (a < b){
    if ((a + (v * t)) < (b + (w * t))){
      ans = false;
    }
  }
  else{
    if ((a - (v * t)) > (b - (w * t))){
      ans = false;
    }
  }
  
  if (ans){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3636
n = gets.chomp.to_i
a = gets.chomp.split(" ").map(&:to_i)
count = 0
a.each_with_index  do |item,i|
    j = i + 1
    if item % 2 == 1 &&  j % 2 == 1
        count += 1
    end
end
puts count

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

#define ld long double
#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(int i=a ; i<=b ; i++)
#define FORD(i,a,b) for(int i=a ; i>=b ; i--)
#define INF 1000000000
#define ll long long int
#define eps (1e-8)
#define sq(x) ( (x)*(x) )
#define all(x) x.begin(),x.end()
#define flog2(n) 64 - __builtin_clzll(n) - 1
#define popcnt(n) __builtin_popcountll(n)

using namespace std;

typedef pair < int, int > pii;
typedef pair < ll, ll > pll;

ll d[105][100005];

ll s[105][100005];

int a[105];

const int K = 1e9 + 7;

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

    int n, k;
    cin >> n >> k;

    FOR (i, 1, n) {
    	cin >> a[i];
    }

    d[0][0] = 1;
    s[0][0] = 1;
     
    FOR (i, 1, n) {
    	d[i][0] = d[i - 1][0];
    	FOR (j, 1, k) {
    		d[i][j] = (d[i - 1][j] + d[i][j - 1]) % K;
    	}

    	FORD (j, k, a[i] + 1) {
    		d[i][j] = (d[i][j] - d[i][j - a[i] - 1] + K) % K;
    	}

    }

    cout << d[n][k] << endl;

    return 0;
}

Measured memory_bytes: 80128
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<cmath>
#include<iomanip>
#include<set>
#include<numeric>
#include<sstream>
#include<random>
#include<cassert>
#include<complex>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;
int dy[] = {0, 0, -1, 1, -1, 1, -1, 1};
int dx[] = {1, -1, 0, 0, -1, 1, 1, -1};
#define ceil(a, b) a / b + !!(a % b)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)

int face[7];
void roll(int tmp, int a, int b, int c) {
    face[1] = face[a];
    face[a] = face[b];
    face[b] = face[c];
    face[c] = tmp;
}
int main() {
    rrep(i, 1, 6 + 1) cin >> face[i];
    string s; cin >> s;
    rep(i, s.size()) {
        int tmp = face[1];
        if (s[i] == 'N') {
            roll(tmp, 2, 6, 5);
        } else if (s[i] == 'E') {
            roll(tmp, 4, 6, 3);
        } else if (s[i] == 'W') {
            roll(tmp, 3, 6, 4);
        } else {
            roll(tmp, 5, 6, 2);
        }
    }
    cout << face[1] << endl;
}



Measured memory_bytes: 3208
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>
#include<iomanip>
#include<functional>

using namespace std;
typedef long long int ll;

#define C cout<<
#define E <<endl

ll n,m,aa[100010];
int tc[10];

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>aa[i];
        aa[i]%4 ? aa[i]%2 ? tc[1]++:tc[2]++:tc[4]++;
    }
    
    if(tc[2]){
        C (tc[4]>=tc[1] ? "Yes":"No") E;
    }
    else{
        C (tc[4]+1>=tc[1] ? "Yes":"No") E;
    }
}

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

int main() {
  
  int64_t x; cin >> x;
  
  int64_t ans = x / 11 * 2;
  
  if (1 <= x % 11 && x % 11 <= 6) ans++;
  
  if (7 <= x % 11) ans += 2;
  
  cout << ans << endl;
  
}

Measured memory_bytes: 3620
import math

n = int(input())
lis = [0]*n
for i in range(n):
  x,y = map(float,input().split())
  lis[i] = [x,y]
ans = 0
for i in range(n):
  for j in range(i+1,n):
    ans += ((lis[i][0]-lis[j][0])**2+(lis[i][1]-lis[j][1])**2)**0.5

a = 2*ans/n
print(a)
    

Measured memory_bytes: 3064
#include<stdio.h>
int main() {
	int a, b;
	scanf("%d%d",&a, &b);
	int c, d, e;
	c = a + b;
	d = a - b;
	e = a * b;
	if (c >= d && c >= e) {
		printf("%d", c);
	}
	else if (d > c && d >= e) {
		printf("%d", d);
	}
	else {
		printf("%d", e);
	}
	return 0;
}

Measured memory_bytes: 128
import collections

n = int(input())
s = list(input() for i in range(n))
m = int(input())
t = list(input() for j in range(m))

s = collections.Counter(s)
t = collections.Counter(t)

s -= t
s = dict(s)

print(max(s.values()) if len(s) != 0 else 0)

Measured memory_bytes: 38256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

int main(void) {
	string s_1, s_2;
	cin >> s_1 >> s_2;

	if (s_1[0] == s_2[2] and s_1[1] == s_2[1] and s_1[2] == s_2[0]) {
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int a, b; cin >> a >> b;

    int cnt = 0;
    if(b == 1){
        OP(cnt);
    }else{
        while(0 < b){
            b -= a;
            cnt++;
            if(b == 0) break;
            b++;
        }
        OP(cnt);
    }
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < (int)(N); i++)
#define req(i,f,N) for(int i = f; i < (int)(N); i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)
#define db(i) cout << #i << " = " << i;

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int MOD = 998244353;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);


// キーワード //
#define elif else if

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);

    int A, B, C, K;
    cin >> A >> B >> C >> K;

    if (A >= K) cou(K);
    elif (A + B >= K) cou(A);
    else cou(A - (K - A - B));



}

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

typedef long long int LLI;
LLI power[3982];

LLI POW5(LLI a)
{
	return a*a*a*a*a;  
}

void precompute()
{
	for(LLI i=0;i<3982;++i) power[i]=POW5(i);
	return;
}

void solve()
{
	LLI X;
	cin>>X;
	for(LLI A=0;A<=3981;++A){
		for(LLI B=0;B<=3981;++B){
			if(power[A]-power[B]==X){
				cout<<A<<" "<<B;
				return;
			}
			else if(power[A]+power[B]==X){
				cout<<A<<" -"<<B;
				return;
			}
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	precompute();
	solve();
	return 0;
}

Measured memory_bytes: 3676
/**
 * Author RDP
 * 
**/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <bitset>
#include <iomanip>
#define endl '\n'
#define bp(x) __builtin_popcount(x)
#define zf(x) __builtin_clz(x)
#define zl(x) __builtin_ctz(x)
#define par(x) __bultin_parity(x)
#define FAST_IO ios::sync_with_stdio(0); std::cin.tie(0);
typedef long long ll;
using namespace std;

void test_case()
{
    FAST_IO
    int n, ex;
    cin >> n;
    vector <int > m(n + 1, 0);
    for(int i = 0 ; i < n - 1; i++)
    {
        cin >>ex;
        m[ex] ++;
    }
    for(int i =1; i <=n ; i ++)
    {
        cout << m[i] <<endl;
    }
    return ;
}
int main()
{
    FAST_IO
    test_case();
    return 0;
}

Measured memory_bytes: 3964
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

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


Measured memory_bytes: 3596
<?php
$n = (int)trim(fgets(STDIN));
$base = range(1, $n);
$all = fact($n);

$input = explode(' ', trim(fgets(STDIN)));
$p_left = 0;
$p_right = $n;
$p_remain = $base;
$p_all = $all;
for ($i=0; $i < $n; $i++) { 
	$tmp = (int)$input[$i];
	$idx = bsearch($p_remain, $tmp);
	// var_dump($p_remain);
	// var_dump($idx);
	$p_left  = $p_left + ($p_all / count($p_remain) * $idx);
	$p_right = $p_left + $p_all / count($p_remain);

	unset($p_remain[$idx]);
	$p_remain = array_values($p_remain);
	$p_all = fact(count($p_remain));
}
$input = explode(' ', trim(fgets(STDIN)));
$q_left = 0;
$q_right = $n;
$q_remain = $base;
$q_all = $all;
for ($i=0; $i < $n; $i++) { 
	$tmp = (int)$input[$i];
	$idx = bsearch($q_remain, $tmp);
	// var_dump($q_remain);
	// var_dump($idx);
	$q_left  = $q_left + ($q_all / count($q_remain) * $idx);
	$q_right = $q_left + $q_all / count($q_remain);

	unset($q_remain[$idx]);
	$q_remain = array_values($q_remain);
	$q_all = fact(count($q_remain));
}

// var_dump($p_left);
// var_dump($p_right);
// var_dump($q_left);
// var_dump($q_right);
echo abs($p_right - $q_right);


function fact($n)
{
	$r = 1;
	for ($i=1; $i <= $n; $i++) { 
		$r *= $i;
	}
	return $r;
}

function bsearch($array, $t)
{
	$left = 0;
	$right = count($array);
	while ($left < $right) {
		$mid = (int)floor(($left + $right) / 2);
		if ($array[$mid] == $t) {
			return $mid;
		}
		if ($array[$mid] < $t) {
			$left = $mid + 1;
		}else{
			$right = $mid;
		}
	}
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    // cout << fixed << setprecision(10) << flush;

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

    int M = 0;
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            M = max(M, abs(a[i]-a[j]));
        }
    }
    cout << M << endl;
    return 0;
}

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

int main(){
  string s;
  cin >> s;
  int ans=1e7;
  int n=s.size();
  
  for (int i=0; i<n-2; i++) 
  {
    int sum = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
    ans = min(ans, abs(sum-753));
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import numpy as np
n=int(input())
a=np.array(list(map(int,input().split())))
a0,a1= np.unique(a,return_counts=True)
suma=np.sum(a)
a2=np.array([0]*100001)
for j in range(a0.size):
  a2[a0[j]]=a1[j]
#print(suma)
#print(a0)
#print(a1)
q=int(input())
for i in range(q):
  b,c=map(int,input().split())
  sumb=a2[b]
  a2[b]=0
  a2[c]+=sumb
  sumc=sumb*(c-b)
  suma+=sumc
  print(suma)

Measured memory_bytes: 39036
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
int main()
{
	int n,i;
	ll ans=0;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		int ni;
		scanf("%d",&ni);
		ans += ni-1;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 384
n, w = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(n)]
lst.sort(key=lambda x:x[0] / x[1], reverse=True)
rest = w
ans = 0
for val, wei in lst:
  if rest >= wei:
    ans += val
    rest -= wei
  else:
    ans += val / wei * rest
    break
print(ans)


Measured memory_bytes: 26352
#include<iostream>
using namespace std;
long memoization[86] = {};



long ryuka(int a){
    
    if (a == 1)
        memoization[1] = 1;
    if (a == 0)
        memoization[0] = 2;
    
    if (memoization[a] == 0)
        memoization[a] = ryuka(a-1)+ ryuka(a-2);
    return memoization[a];
    
}

int main(){
    int n;
    cin >> n;
    cout << ryuka(n)<< endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600
#define MOD 1000000007

vector<pair<int,int>> check[305];
long dp[305][305][305];

long solve(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int l,r,x;
    cin>>l>>r>>x;
    check[r].pb(mp(l,x));
    // rを更新するとき
    // l以上でちょうどx色 でなければ更新できない
    // 1から考える
  }

  auto possible = [&](int mx, int i, int j){
    for(auto &p : check[mx]){
      int l = p.fi, x = p.se;
      bool bi = l<=i, bj = l<=j;
      if(x==1) if(bi || bj) return false;
      if(x==2) if(!(bi^bj)) return false;
      if(x==3) if(!bi || !bj) return false;
    }
    return true;
  };

  fill(dp[0][0], dp[305][0], 0);
  dp[0][0][0] = 1;

  rep(i,n) rep(j,n) rep(k,n) if(dp[i][j][k]>0){
    int mx = max(i,max(j,k));
    if(possible(mx+1, j, k)) (dp[mx+1][j][k] += dp[i][j][k])%=MOD;
    if(possible(mx+1, i, k)) (dp[i][mx+1][k] += dp[i][j][k])%=MOD;
    if(possible(mx+1, i, j)) (dp[i][j][mx+1] += dp[i][j][k])%=MOD;
  }

  long ans = 0;
  rep(i,n) rep(j,n){
    ans += (dp[i][j][n] + dp[i][n][j] + dp[n][i][j])%MOD;
    ans %= MOD;
  }
  return ans;
}

int main(){
  cout << solve() << endl;

  return 0;
}


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

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

    long int total = N*(N+1)/2;
    long int sum3 = (N/3)*(3+(N/3)*3)/2;
    long int sum5 = (N/5)*(5+(N/5)*5)/2;
    long int sum15 = (N/15)*(15+(N/15)*15)/2;

    long int answer = total -(sum3 + sum5) + sum15;

    cout << answer << endl;
}

Measured memory_bytes: 3620
import sys
from collections import deque

N, M = map(int, sys.stdin.readline().strip().split())

edges = [[] for _ in range(N)]
for _ in range(M):
    a, b = map(int, sys.stdin.readline().strip().split())
    edges[a-1].append(b-1)
    edges[b-1].append(a-1)

q = deque()
q.append((0, -1))

# 幅優先探索
visited = set()
ans = {} # どの部屋に戻るべきか
while q:
    pos, prev = q.popleft()
    if pos in visited:
        continue
    ans[pos] = prev
    visited.add(pos)

    for next_pos in edges[pos]:
        q.append((next_pos, pos))

if len(ans) != N:
    print("No")
    sys.exit()

print("Yes")
for (pos, prev) in sorted(ans.items()):
    if pos == 0:
        continue
    print(prev+1)

Measured memory_bytes: 119400
n, k = map(int, input().split())
d = [0] * (10 ** 5 + 10)
for _ in range(n):
    a, b = map(int, input().split())

    d[a] += b
for i in range(len(d)):
    k -= d[i]
    if k <= 0:
        print(i)
        break

Measured memory_bytes: 5748
fun main(args: Array<String>) {
    val (n,k)= readLine()!!.split(" ").map { it.toInt() }
    readLine()!!.split(" ").map { it.toInt() }
            .groupBy { it }
            .map { it.value.size }
            .sortedDescending()
            .drop(k)
            .sum()
            .let { println(it) }
}

Measured memory_bytes: 94692
import java.util.*;
public class Main{
    public static void main(String[] args){
	new Main().run();
    }
    Scanner sc = new Scanner(System.in);

    char[][] map;
    char[][] round; // "":未, B:黒, W:白, x:黒でも白でもない n:杭
    int w, h;
    int B, W;


    void run(){
	while(sc.hasNext()){
	    w = sc.nextInt();
	    h = sc.nextInt();
	    if(w==0 && h==0) break;
	    
	    map = new char[h][w];
	    round = new char[h][w];
	    
	    for(int i=0; i<h; i++){
		String s = sc.next();
		Arrays.fill(round[i], 'o');
		for(int k=0; k<w; k++)
		    map[i] = s.toCharArray();
	    }
	    
	    for(int i=0; i<h; i++)
		for(int k=0; k<w; k++){
		    solve(i, k, map[i][k]);
		}
	    
	    count();
	    //show();
	    System.out.println(B+" "+W);
	}
    }

    void solve(int a, int b, char c){
	if(a<0 || a>=h || b<0 || b>=w) return;
	if(round[a][b]=='x' || round[a][b]=='n' || c=='.') return;
	
	if(map[a][b]=='B' || map[a][b]=='W'){
	    c = map[a][b];
	    round[a][b] = 'n';
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
	else if(round[a][b]=='o'){
	    round[a][b] = c;
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
	else if( (round[a][b]=='B' && c=='W') || (round[a][b]=='W' && c=='B')){
	    round[a][b] = 'x';
	    solve(a+1, b, c);
	    solve(a-1, b, c);
	    solve(a, b+1, c);
	    solve(a, b-1, c);
	}
    }

    void count(){
	B = 0;
	W = 0;
	for(int i=0; i<h; i++)
	    for(int k=0; k<w; k++)
		if(round[i][k]=='B') B++;
		else if(round[i][k]=='W') W++;
    }

    void show(){
	for(int i=0; i<h; i++){
	    for(int k=0; k<w; k++)
		System.out.print(round[i][k]+" ");
	    System.out.println();
	}
	System.out.println("-------------------");
    }
}

Measured memory_bytes: 61992
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <map>
const int MOD = 1e9+7;
typedef long long ll;
using namespace std;


int main(){
	ll a, b, c;
	cin >> a >> b >> c;
	ll d = c - a - b;
	if (d < 0){
		cout << "No" << endl;
		return 0;
	}
	if (4*a*b < d*d) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
 }



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

  int A,B,C,D;

  cin>>A>>B>>C>>D;

  if(D<=A||B<=C) cout << 0 << endl;
  

  else if(A<=C&&B<=D) cout << B-C << endl;

  else if(C<=A&&D<=B) cout << D-A << endl;

  else if(A<=C&&D<=B) cout << D-C << endl;

  else if(C<=A&&B<=D) cout << B-A << endl;


  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Serialization;

class Program
{
    static void Main()
    {
        new Program().Solve();
    }

    void Solve()
    {
        var k = int.Parse(Console.ReadLine());
        var s = Console.ReadLine();
        Console.WriteLine(s.Length <= k ? s : s.Substring(0, k) + "...");
    }

    #region Console.Read 関係
    long[] ReadLongArray() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    long ReadLong() => long.Parse(Console.ReadLine());
    #endregion
}

Measured memory_bytes: 27536
import sys
s = input()
for i in range(len(s)):
    if i%2 == 0:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()
    else:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            print('No')
            sys.exit()
print('Yes')

Measured memory_bytes: 8980
N = int(input())
arr = []
for i in range(1, N+1):
    if i % 5 == 0 and i % 3 == 0:
        continue
    elif i % 3 == 0:
        continue
    elif i % 5 == 0:
        continue
    arr.append(i)
print(sum(arr))


Measured memory_bytes: 30000
from sys import stdin

def main():
    input = lambda: stdin.readline()[:-1]
    N, K, Q = map(int, input().split())
    A = [int(input()) for _ in [0] * Q]

    point = [0] * N
    for a in A:
        point[a-1] += 1
    for i, j in enumerate(point):
        point[i] = K + j - Q
    for i in point:
        print('Yes' if i > 0 else 'No')

main()


Measured memory_bytes: 11780
#include<iostream>
using namespace std;
long n,k;
main()
{
	while(cin>>n>>k,n)
	{
		n--;
		long keta=1,test=1;
		while(n>=9*test*keta)
		{
			n-=test*9*keta;
			keta++;
			test*=10;
		}
		int now=n/(test*keta)+1;
		n%=test*keta;
		for(int i=1;i<keta;i++)
		{
			now=now*10+n/(test/10*keta);
			test/=10;
			n%=test*keta;
		}
		while(k>0)
		{
			string out="";
			int tmp=now++;
			while(tmp)out=(char)(tmp%10+'0')+out,tmp/=10;
			for(int i=n;k&&i<out.size();i++)
			{
				k--;
				cout<<out[i];
			}
			n=0;
		}
		cout<<endl;
	}
}


Measured memory_bytes: 2992
#include <stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int num[n];
  int count = 0;
  for(int i = 0; i < n; i++) scanf("%d", &num[i]);
  for(int i = 0; i < n; i++){
    int minj = i;
    for(int j = i; j < n; j++){
      if(num[j] < num[minj]) {
        minj = j;
      }
    }
    if(i != minj) count++;
    int tmp = num[minj];
    num[minj] = num[i];
    num[i] = tmp;
  }
  for(int i = 0; i < n; i++){
    printf("%d", num[i]);
    if(i != n - 1) printf(" ");
    else printf("\n");
  }
  printf("%d\n", count);
  return 0;
}

Measured memory_bytes: 1820
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <algorithm>

int main()
{
  std::string str;
  std::cin >> str;

  std::stack< char > stk;
  
  for (std::string::iterator it = str.begin(); it != str.end(); it++) {
    if (*it == 'B') {
      if (!stk.empty()) stk.pop();
    } else {
      stk.push(*it);
    }
  }

  std::string ans;
  while (!stk.empty()) {
    char c = stk.top();
    ans.push_back(c);
    stk.pop();
  }

  std::reverse(ans.begin(), ans.end());
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <list>
#include <map>
#include <iostream>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

using namespace std;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
    int n, m;
    const int MOD = 1e9 + 7;
    int x;
    cin >> n >> m;
    vector<bool> broken(n, false);
    forn(i, m) {
        cin >> x;
        broken[x] = true;
    }

    vi f(n + 1, 0);
    f[0] = 1;
    if (broken[1]) f[1] = 0;
    else f[1] = 1;
    for (int i = 2; i<= n; ++i) {
        if (broken[i]) f[i] = 0;
        else f[i] = (f[i - 1] + f[i - 2]) % MOD;
    }
    cout << f[n] << endl;

    return 0;
}



Measured memory_bytes: 640
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int n;
	cin >> n;
	string s;
	cin >> s;
	s = "-" + s;
	bool sw[n+2] = {}, las, fir, ch = false;
	REP(i, 2){
		if(ch) break;
		REP(j, 2){
			if(ch) break;
			sw[1] = i;
			sw[n] = j;
			sw[0] = j;
			las = j;
			fir = i;
			for(int k = 1; k <= n; k++){
				if(s[k] == 'o') sw[k+1] = sw[k-1];
				else sw[k+1] = !sw[k-1];
				if(!sw[k]) sw[k+1] = !sw[k+1];
				//cout << k << " " << sw[k-1] << " " << sw[k] << " " << sw[k+1] << endl;
			}
			if(fir == sw[n+1] && las == sw[n]) ch = true;
		}
	}
	if(ch){
		REP1(i, n){
			if(sw[i]) cout << "S";
			else cout << "W";
		}
		cout << endl;
	}
	else cout << -1 << endl;
}

Measured memory_bytes: 636
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  int n; cin >> n;
  string s; cin >> s;
  int now = 0, mn = 0;
  for (char c : s) {
    if (c == '(') {
      ++now;
    } else {
      --now;
    }
    mn = min(mn, now);
  }
  string ans = "";
  REP(_, abs(mn)) ans += '(';
  ans += s;
  now += abs(mn);
  REP(_, now) ans += ')';
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
using System;

public class Problem_C
{
  public static void Main()
  {
    var n = int.Parse(Console.ReadLine());
    var x = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var y = new int[n];
    Array.Copy(x, y, x.Length);
    Array.Sort(y);

    foreach (var val in x)
    {
      if (val < y[n / 2]) Console.WriteLine($"{y[n / 2]}");
      else Console.WriteLine($"{y[(n / 2) - 1]}");
    }
  }
}


Measured memory_bytes: 34888
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int cnt = 0;
ll g, A, B, C;
const int MAX = 15001000;
bool IsPrime[MAX];
int MinFactor[MAX];


ll GCD(ll a, ll b){
    if(b==0) return a;

    return GCD(b, a % b);
}

map<int, int> factorize(ll n)// 素因数分解
{
	map<int, int> ret;
	for(ll i = 2; i*i <= n; ++i)
	{
        // if(n % i != 0) continue;

		while(n % i == 0){
			ret[i]++;
			n /= i;
		}
	}
	if(n != 1) ret[n]++;
	
	return ret;
}

void solve(){
    g = GCD(A, B);

    map<int, int> mp = factorize(g);

    for(auto itr = mp.begin(); itr != mp.end(); ++itr)
        cnt++;
    cnt++;

    cout << cnt << endl;
}

int main(){
    cin >> A >> B;

    solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		int connect[] = new int[n];

		for(int i = 0; i < m; i++){
			int a = sc.nextInt() - 1;
			int b = sc.nextInt() - 1;

			connect[a]++;
			connect[b]++;
		}

		for(int i = 0; i < n; i++){
			System.out.println(connect[i]);
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005;
const ll INF=1LL<<60;
vector<int> prime;//i番目の素数
bool is_prime[MAX+1];

void sieve(int n){
    for(int i=0;i<=n;i++){
        is_prime[i]=true;
    }
    
    is_prime[0]=is_prime[1]=false;
    
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i;j<=n;j+=i){
                is_prime[j] = false;
            }
        }
    }
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    sieve(MAX-3);
    int N;cin>>N;
    map<ll,int> MA;
    ll ans=0;
    bool zero=false;
    
    vector<ll> cube;
    for(ll p:prime){
        if(p*p*p>10000000000) break;
        cube.push_back(p*p*p);
    }
    
    while(N--){
        ll a;cin>>a;
        
        for(ll c:cube){
            while(a%c==0) a/=c;
        }
        
        if(a==1){
            zero=true;
            continue;
        }
        
        MA[a]++;
    }
    
    if(zero) ans++;
    
    for(auto it=MA.begin();it!=MA.end();it++){
        if((*it).second==0) continue;
        
        ll a=(*it).first,b=1;
        
        for(auto p:prime){
            int cnt=0;
            while(a/p*p==a){
                a/=p;
                cnt++;
            }
            
            if(cnt==1){
                if(b*p>10000000000||b*p*p>10000000000) b=100000000000;
                else b*=p*p;
            }
            if(cnt==2){
                b*=p;
            }
            
            if(a==1) break;
            if(b>10000000000) break;
            
            if(p*p>a){
                if(a<=1000000){
                    b*=a*a;
                    a=1;
                }
                break;
            }
        }
        
        if(a>1){
            a=(*it).first;
            ans+=MA[a];
            MA[a]=0;
            continue;
        }
        
        a=(*it).first;
        
        ans+=max(MA[a],MA[b]);
        
        MA[a]=0;
        MA[b]=0;
    }
    
    cout<<ans<<endl;
     
}


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

#define debug(x) cerr<<#x<<'='<<x<<' '
#define f first
#define s second

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

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	ll h,cnt=0;
	cin >> h;
	while (h > 0) {
		++cnt;
		h/=2;
	}
	ll ans = 0;
	--cnt;
	while (cnt) {
		ans += pow(2,cnt);
		//debug(pow(2,cnt));
		--cnt;
	}
	cout << ans+1;
	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;

int main()
{
    string S;
    cin >> S;
    string prev, next;
    int count = 0;
    for (const char ch : S)
    {
        next += ch;
        if (prev != next)
        {
            prev = next;
            next = "";
            ++count;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>

using namespace std;

int main()
{
	int n, cnt = 0, input;
	vector<int> vec;
	bool flag = 1;

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> input;
		vec.push_back(input);
	}

	for (int i = 0; i < n; i++)
	{
		int minj = i;
		for (int j = i; j < n; j++)
		{
			if (vec[j] < vec[minj])
			{
				minj = j;
			}

				
		}
		swap(vec[i], vec[minj]);
		if (i != minj)
			cnt++;
	}


	int i = 0;

	for (auto a : vec)
	{
		cout << (i ? " " : "") << a;
		i++;
	}

	cout << endl;

	cout << cnt << endl;
}

Measured memory_bytes: 3136
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#include<bits/stdc++.h>
#define fr first
#define sc second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define forn(i,n) for(int i =1;i<= (n);++i)
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordset;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
const int inf = 1e9+7;
const int nmax = 500005;
const ll linf = LLONG_MAX;
const ll mod = 1000000007;

char a;

int main(){
    cin >> a;
    cout << ++a;
    fast;
}


Measured memory_bytes: 256
import itertools

n = int(input())
a = list(map(int, input().split()))

aggregated_a = {x: sum(1 for _ in iter) for (x, iter) in itertools.groupby(sorted(a))}
counts = [aggregated_a[a_i] if a_i in aggregated_a else 0 for a_i in range(100000)]
print(max(sum(counts[a_i - 1 : a_i + 2]) for a_i in range(100000)))


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

using namespace std;

const int MOD = 1000000007;

template <class T> void dump(const vector<T>& vec) {
  for (const T& value : vec) {
    cout << value << " ";
  }
  cout << endl;
}
void dump(const vector<vector<long long>> dp) {
  cout << "dump start" << endl;

  for (auto row : dp) {
    dump(row);
  }
  
  cout << "dump end" << endl;
}

// vectorの長さ足りなかったら追加
template <class T> void expand(vector<T>& vec, int size, T value) { //Tを複数の型で呼べるようにする。template関数という
  while (vec.size() < size) {
    vec.push_back(value);
  }
}

template <class T> void add_mod(T& target, T operand) {
  target = (target + operand) % MOD;
}

int main() {
  int n,m;
  cin >> n;
  cin >> m;
  int ss[n];
  int ts[m];
  for (int i = 0; i< n; i++) {
    cin >> ss[i];
  }
  for (int i = 0; i< m; i++) {
    cin >> ts[i];
  }
 
  // dpは[t側が次どこをみるか] = こうなる場合は何通りか
  // よく考えたら、部分文字列の長さは保存しておく必要がないので、[k]の次元は削除した
  vector<long long> dp;
  dp.assign(m, 0);

  for (int i = 0; i < n; i++) {
    long long k = 1; // 長さ0同士もマッチするので、初期値は1

    for (int j = 0; j < m; j++) {
      bool is_same = ss[i] == ts[j];

      // cout << "i: " << i << " j: " << j << " is_same: " << is_same << endl;

      // 変更前の値を保持しておく
      long long before_value = dp[j];

      // 累積(k)から、今回マッチした分を計算して更新
      if (is_same) {
        add_mod(dp[j], k); //j以前に成立している部分文字列に対し、今の文字を追加しても部分文字列として成り立つ
      }

      // 変更前の値を、kに累積して、j+1で使う
      add_mod(k, before_value);

      // cout << "dump ks:";
      // dump(ks);
    }
    
    //dump(dp);
  }
  
  long long result = 1; // どちらも()の場合はdpに保存されないので、初期値は1
  for (const long long& value : dp) {
    // cout << "x:" << dp2[k] << endl;
    add_mod(result, value);
  }
  
  cout << result << endl;
  
  return 0;
}


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

int main(){

	string s,t;
	cin >> s >> t;
	int ans=0;
	int now_max=0;
	for(int i=0;i<s.length()-t.length()+1;i++){
		now_max=0;
		for(int j=0;j<t.length();j++){
			if(s[j+i]==t[j])now_max++;
		}
		ans=max(ans,now_max);
	}

	cout << t.length()-ans << endl;
}


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

int main()
{
  string S,T;
  cin >> S >> T;
  int ans=0;
  for(int i=0;i<S.size();i++){
    if(!(S.at(i)==T.at(i))){
      ans++;
    }
  }
      
  cout << ans << endl;

return 0;
}

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

using namespace std;

typedef long long LL;

int main()
{
    int n,ok=0,dupl=0;
    cin>>n;
    for (;n;--n)
    {
        int x,y;
        cin>>x>>y;
        if (x==y)
            ++dupl;
        else
            dupl=0;
        if (dupl==3)
            ok=1;
    }
    if (ok)
        cout<<"Yes";
    else
        cout<<"No";
}



Measured memory_bytes: 3620
#include <stdio.h>

int main(void) {
	int M, D, a, b, i, j, cnt=0;
	scanf("%d %d", &M, &D);
	for(j=1; j<=M; j++){
		for(i=1; i<=D; i++){
			a = i / 10;
			b = i % 10;
			if(a*b==j && a>=2 && b>=2){
			//	printf("%d %d\n", j, i);
				cnt++;
			}
		}
	}
	printf("%d", cnt);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
 
using namespace std;
 
typedef unsigned long long ll;
 
 
int main(){
 int n;cin>>n;
 vector<int>stone(n);
 vector<int>dp(n);
 for(int i = 0 ; i< n ; i++){
	 cin>>stone[i];
 }
 dp[0]=0;
 dp[1]=0;
 dp[2]=abs(stone[1]-stone[0]);
 dp[3]=abs(stone[2]-stone[0]);

 for(int i = 2 ; i< n-1 ; i++){
	 dp[i+1]=min(dp[i]+abs(stone[i-1]-stone[i]),abs(dp[i-1]+abs(stone[i]-stone[i-2])));

 }

 

 cout<<min(dp[n-1]+abs(stone[n-2]-stone[n-1]),dp[n-2]+abs(stone[n-1]-stone[n-3]));

	
	
	
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

/* 二項係数 C(n,k) mod p を計算 */
const int MOD = 1000000007;
const int MAX = 201000;
long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

long long COM(int n, int k) {
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll ans = 0;
  COMinit();
  FOR(i, 1, n + 1) {
    ll x = COM(i - 1, k - 1);
    ll y = COM(n - i, k - 1);
    ll t = (x + (MOD - y) % MOD) % MOD;
    ans += (MOD + a[i - 1]) % MOD * t % MOD;
    ans %= MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define sz(a) (int)(a).size()
#define pb(a) push_back(a)
using namespace std;

typedef vector<int> vi;
typedef long long ll;


int dfs(int w,vector<vi>& v,vi& dp ){
	int n;
	if(dp[w]!=-1)
		return dp[w];
	if(sz(v[w])==0)
		dp[w]=0;
	for(int j=0;j<sz(v[w]);j++){
		n=v[w][j];
		dp[w]=max(dfs(n,v,dp)+1,dp[w]);
	}
	return dp[w];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	vector<vi> v(n);
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		v[a-1].pb(b-1);
	}
	vi dp(n,-1);
	int res=0;
	for(int i=0;i<n;i++){
		res=max(dfs(i,v,dp),res);
	}
	cout<<res<<"\n";
	
}


Measured memory_bytes: 9600
#include <iostream>
using namespace std;
int main(void){
   int E,Y;
   cin >> E >> Y;
   if(E == 0){
       if(1868 <= Y && Y <= 1911){
           cout << "M" << Y-1868+1  << endl;
       }
       else if(1912 <= Y && Y <= 1925){
           cout << "T" << Y-1912+1 << endl;
       }
       else if(1926 <= Y && Y <= 1988){
           cout << "S" << Y-1926+1 << endl;
       }
       else if(1989 <= Y && Y <= 2016){
           cout << "H" << Y-1989+1 << endl;
       }
   }
   else if(E == 1){
       cout << 1868+Y-1 << endl;
   }
   else if(E == 2){
       cout << 1868+44+Y-1 << endl;
   }
   else if(E == 3){
       cout << 1868+44+14+Y-1 << endl;
   }
   else if(E == 4){
       cout << 1868+44+14+63+Y-1 << endl;
   }
} 


Measured memory_bytes: 3092
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline
prime=[True]*300000
prime[0]=False
prime[1]=False
for i in range(2,int(300000**0.5)+1):
    if prime[i]:
        for j in range(i*2,300000,i):
            prime[j]=False
while 1:
    n=int(input().rstrip())
    if n==0:
        break
    cnt=0
    for i in range(n+1,n*2+1):
        if prime[i]:
            cnt+=1
    print(cnt)


Measured memory_bytes: 7844