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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define INPUTL(i,n) for(ll i=0 ; i<n ; i++)
const int MOD = 1000000007 ; //  , 1000000009 , 1000000023 ,998244353
const ll INF = (1e18);
const ld PI = 4*atan((ld)1);
int MAX = MOD;
void array_debug(vector<ll>ar){
    for(auto x: ar)cout << x << ' ';
    cout << '\n';
}
ll power(ll x,ll n)
{
    ll result=1;
    while(n>0){
        if(n&1)result = (result * x)%MOD;
        x=(x*x)%MOD;
        n >>= 1;
    }
    return result%MOD;
}
ll gcd(ll a , ll b){
  if(b==0)return a;
  return gcd(b,a%b);
}

int main() {
    #ifdef AVI  
        freopen("input.txt" , "r" , stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.precision(20);
    
   
    ll n;
    cin >> n;
    ll ar[n][3];
    for(ll i=0 ; i<n ; i++){
      cin >> ar[i][0] >> ar[i][1] >> ar[i][2];
    }
    ll dp[n][3];
    
    for(ll i=0 ; i<3 ; i++)dp[0][i] =  ar[0][i];
    for(ll i=1 ; i<n ; i++){
      dp[i][0] = max(dp[i-1][1] , dp[i-1][2]) + ar[i][0];
      dp[i][1] = max(dp[i-1][0] , dp[i-1][2]) + ar[i][1];
      dp[i][2] = max(dp[i-1][0] , dp[i-1][1]) + ar[i][2];
    }  
    ll res = -1;
    for(ll i=0 ; i<3 ; i++)res = max(dp[n-1][i] , res);
      cout << res;
}

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

// def
#define debug(x) cout << #x << ": " << x << endl
#define out(x) cout << x << endl
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define revrepeat(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define revrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define CYES cout << "Yes" << endl
#define CNO cout << "No" << endl
#define SPC(x) cout << fixed << setprecision(x)
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<ll> vl;
typedef vector<vector<ll>> vll;
typedef pair<int, int> P;
typedef complex<ld> Point;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MAX_V = 1e5 + 5;
const int MAX_N = 1e5 + 5;
const double PI = acos(-1);

int main() {
    vii card(3, vi(3));
    vector<vector<bool>> card_check(3, vector<bool>(3, false));
    rep(i, 3) {
        rep(j, 3) {
            cin >> card[i][j];
        }
    }
    int n;
    cin >> n;
    vi b(n);
    rep(i, n) cin >> b[i];
    rep(i, n) {
        rep(j, 3) {
            rep(k, 3) {
                if (card[j][k] == b[i]) {
                    card_check[j][k] = true;
                }
            }
        }
    }
    if ((card_check[0][0] && card_check[1][1] && card_check[2][2]) ||
        (card_check[0][0] && card_check[1][0] && card_check[2][0]) ||
        (card_check[0][0] && card_check[0][1] && card_check[0][2]) ||
        (card_check[1][0] && card_check[1][1] && card_check[1][2]) ||
        (card_check[0][1] && card_check[1][1] && card_check[2][1]) ||
        (card_check[2][0] && card_check[2][1] && card_check[2][2]) ||
        (card_check[0][2] && card_check[1][2] && card_check[2][2]) ||
        (card_check[0][2] && card_check[1][1] && card_check[2][0])) {
        CYES;
    } else {
        CNO;
    }

    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
using namespace std;
typedef long long LL;

int npr[1000005] = {0};
int n,m,k;

void sieve(int r){
	for(int i = 2;i * i <= r;i ++){
		if(npr[i]) continue;
		for(int j = i * i;j <= r;j += i) npr[j] = 1;
	}
}

int main(){
	sieve(200000);
	cin >> n;
	for(int i = n;i <= 200000;i ++){
		if(!npr[i]){
			cout << i << endl;
			break;
		}
	}
	return 0;
}

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

int func(int a,int b) {
  if(a < b)return func(b,a);
  else if(b == 0)return a;
  else return func(b,a%b);
}

int main() {
  int K;
  cin >> K;
  vector<vector<int>> gcd(K,vector<int>(K));
  int i,j,k;
  for(i=0;i<K;i++) {
    for(j=0;j<K;j++) {
      gcd[i][j] = func(i+1,j+1);
    }
  }
  long long ans = 0;
  for(i=0;i<K;i++) {
    for(j=0;j<K;j++) {
      for(k=0;k<K;k++) {
        ans += gcd[gcd[i][j]-1][k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3792
#include<bits/stdc++.h>
#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define INF 1<<64
#define sf(a) scanf("%d",&a)
using namespace std;
int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
typedef pair<int,int> pii;
vector<pii> vii;
int memo[55][3000][55],n,m,s[100];
int keisan(int num,int sum,int cou){
    if(memo[num][sum][cou]>=0)return memo[num][sum][cou];
    if(num>=n){
        if(!cou)return 0;
        else if(sum%cou||(sum/cou)!=m)return 0;
        else return 1;
    }else{
        return memo[num][sum][cou]=keisan(num+1,sum,cou)+keisan(num+1,sum+s[num],cou+1);
    }
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,0,55)rep(k,0,3000)rep(j,0,55)memo[i][k][j]=-1;
    cin >> n >> m;
    rep(i,0,n){
        cin >> s[i];
    }
    int ans=0;
    ans=keisan(0,0,0);
    cout << ans << endl;
return 0;
}


Measured memory_bytes: 71168
#include <iostream>
#include <vector>
#include <utility>
#include <cmath>
#include <iomanip>
using namespace std;

double pi=3.1415926535897932384626434;
int main() {
	int N; cin >> N;
	vector<pair<double, double>> pos;
	for(int i=0; i<N; ++i){
	    double x, y;
	    cin >> x >> y;
	    pos.push_back(make_pair(x, y));
	}
	for(int i=0; i<N; ++i){
	    double Do=-pi, Dn=pi, Uo=0, Un=0;
	    for(int j=0; j<N; ++j){
	        if(i!=j){
	            double r;
	            r=atan2(pos[j].first-pos[i].first, pos[j].second-pos[i].second);
	            if(r<0){
	                Do=max(Do, r);
	                Dn=min(Dn, r+pi);
	            }
	            else{
	                Uo=min(Uo, r-pi);
	                Un=max(Un, r);
	            }
	        }
	    }
	    cout << setprecision(10) << (max(Dn-Un, 0.0)+max(Uo-Do, 0.0))/(2*pi) << endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
using namespace std;
const int INF = 1000000000;

int main() {
    int N, K; cin >> N >> K;
    int p[N];
    for (int i = 0; i < N; i++) cin >> p[i];

    sort(p, p + N);
    int ans = 0;
    for (int i = 0; i < K; i++) ans += p[i];
    cout << ans << endl;
}

Measured memory_bytes: 3640
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int n;
  cin>>n;
  for(int i=0;i<100000;i++){
    if(i*i>n){
      cout<<(i-1)*(i-1)<<endl;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
signed main()
{
int a,b,c,d,e;
  cin>>a>>b>>c;
  if(a<b){
    d=b-a;
  }else{
    d=a-b;
  }
  if(a<c){
    e=c-a;
  }else{
    e=a-c;
  }
  if(d<e){
    cout<<"A\n";
  }else{
    cout<<"B\n";
  }
}

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

#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define ll   long long
#define ld long double
#define all(v) v.begin(),v.end()
#define pb push_back
#define S second
#define F first
#define die() return 0;


#define fmd          1000000007
#define md         998244353 
#define M           55
#define N            18
ll exp(ll a,ll b){if(b<0)return 0;ll r=1;while(b){if(b&1)r=r*a%md,r%=md;a=a*a%md;b/=2;}return r;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}

vector<ll> g[M];
vector<ll> p[M][M];
int so;
void dfs(int u,int pa){
	p[so][u].pb(u);
	for(auto x:g[u]){
		if(x!=pa){
			p[so][x]=p[so][u];
			dfs(x,u);
		}
	}
}

int solve(){
    ll n,i,j,k,m,x,y,z;
    cin>>n;
    map<pair<ll,ll>,ll> mp;
    for(i=0;i<n-1;++i){
    	cin>>x>>y;
    	x--;y--;

    	g[x].pb(y);
    	g[y].pb(x);

    	mp[{x,y}]=mp[{y,x}]=i;
    }
    for(i=0;i<n;++i){
    	so=i;
    	dfs(i,-1);
    }
    vector<pair<ll,ll> > res;
    cin>>m;
    for(i=0;i<m;++i){
    	cin>>x>>y;x--;y--;
    	res.pb({x,y});
    }
    ll ans=0;
    for(i=0;i<(1ll<<m);++i){
    	ll mask=0;
    	ll cnt=0;
    	for(ll id=0;id<m;++id){
    		if(i&(1ll<<id)){
    			++cnt;
    			vector<ll> v=p[res[id].F][res[id].S];
    			for(j=0;j+1<v.size();++j){
    				mask|=(1ll<<(mp[{v[j],v[j+1]}]));
    			}

    		}
    	}
    	ll po=0;
    	for(j=0;j<=(n-1);++j){
    		if(mask&(1ll<<j))++po;

    	}
    	if(cnt%2)
    		ans=ans-(1ll<<(n-1-po));
    	else
    		ans=ans+(1ll<<(n-1-po));

    }
    cout<<ans<<"\n";











    // trace(f(2,2));



	die();

}
 
 
int main(){
 
 
#ifndef ONLINE_JUDGE
    double _tBeg=clock();
#endif

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

    int t;
    t=1;;
    // prec();
    // cin>>t;
 
    while(t--){

        solve();
    }
 
 
 
 


#ifndef ONLINE_JUDGE
    double _tEnd=clock();
    // printf("\ntotal time %.6f\n",(_tEnd-_tBeg)/CLOCKS_PER_SEC);
#endif
 
    die();
}

Measured memory_bytes: 1024
def main() :
    n = int(input())
    lst = [int(i) for i in input().split()]

    print(" ".join(map(str, lst)));

    for i in range(1,n) :
        for j in reversed(range(i+1)) :
            if j == 0 :
                break
            elif lst[j] < lst[j-1]:
                lst[j], lst[j-1] = lst[j-1], lst[j]
        print(" ".join(map(str, lst)))






if __name__ == '__main__' :
    main()

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

using namespace std;

int main(){
    int N;
    bool ans = true;
    cin >> N;
    vector<string> W(N);
    for(int i=0;i<N;i++){
        cin >> W.at(i);
    }
    for(int i=1;i<N;i++){
        for(int j=0;j<i;j++){
            if(W.at(i)==W.at(j)){
                ans = false;
            }
        }
        if(ans==true){
            if(W.at(i-1).back()!=W.at(i).front()){
                ans = false;
            }
        }
    }
    cout << (ans==true ? "Yes" : "No") << endl;
    
}


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

using namespace std;

constexpr int MAX_N = 100100;
constexpr int INF = 1e9 + 5;

int n;
int arr[MAX_N];

int dp[MAX_N];

int main() {
    scanf(" %d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf(" %d", &arr[i]);
    }

    dp[1] = 0;
    for (int i = 2; i <= n; ++i) {
        dp[i] = -1;
        for (int j = 1; j <= 2; ++j) {
            if (i - j <= 0) continue;
            if (dp[i - j] == -1) continue;
            int cur = dp[i - j] + abs(arr[i] - arr[i - j]);
            if (dp[i] == -1 || cur < dp[i]) {
                dp[i] = cur;
            }
        }
    }

    printf("%d\n", dp[n]);

    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef unsigned long long ull; 
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  constexpr u64 &value() noexcept { return a; }
  constexpr const u64 &value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  constexpr modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  constexpr modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

using mint = modint<MOD>;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N),B(N);
    rep(i,N) cin >> A[i];
    rep(i,N) cin >> B[i];

    vector<pii> C;
    rep(i,N) {
        C.emplace_back(A[i],1);
    }
    rep(i,N) {
        C.emplace_back(B[i],0);
    }
    sort(all(C));
    int a = 0, b = 0;
    mint ans = 1;
    rep(i,2*N) {
        if (C[i].second) {
            if (b) {
                ans *= b;
                --b;
            } else ++a;
        } else {
            if (a) {
                ans *= a;
                --a;
            } else ++b;
        }
    }

    cout << ans.a << ln;
}

Measured memory_bytes: 3188
import java.io.*;
import java.util.*;
class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));
		String line = "";
		while ((line = br.readLine()) != null) {
			StringTokenizer st = new StringTokenizer(line," ");

			if (st.countTokens() != 8) break;

			double x1 = Double.parseDouble(st.nextToken());
			double y1 = Double.parseDouble(st.nextToken());
			double x2 = Double.parseDouble(st.nextToken());
			double y2 = Double.parseDouble(st.nextToken());
			double x3 = Double.parseDouble(st.nextToken());
			double y3 = Double.parseDouble(st.nextToken());
			double xp = Double.parseDouble(st.nextToken());
			double yp = Double.parseDouble(st.nextToken());

			double area12 = area(xp, yp, x1, y1, x2, y2);
			double area23 = area(xp, yp, x2, y2, x3, y3);
			double area31 = area(xp, yp, x3, y3, x1, y1);
			double area123 = area(x1, y1, x2, y2, x3, y3);

			String result = area12 + area23 + area31 - area123 < 0.0001 ? "YES" : "NO";
			System.out.println(result);
		}

	}

	static double area(double x1, double y1, double x2, double y2, double x3, double y3) {
		return 0.5 * Math.abs((x2 - x1) * (y3 - y1) - (y2 - y1) * (x3 - x1));
	}

}

Measured memory_bytes: 9684
import java.util.Scanner;

public class Main {
    public static void main (String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();

        long result = 0;
        result = (N / (A+B)) * A;

        long temp = 0;
        temp = N % (A+B);


        result =result+ Math.min(temp, A);
        System.out.println(result);
    }
}

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

int main()
{
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;

	bool isFirst0 = (s[0] == '0');
	vector<int> c;
	c.reserve(n);
	const size_t ss = s.size();
	int cn = 1;
	for (size_t i = 1; i < ss; ++i) {
		if (s[i] == s[i - 1]) {
			++cn;
		}
		else {
			c.push_back(cn);
			cn = 1;
		}
	}
	c.push_back(cn);

	int ret = 0;
	const size_t cs = c.size();
	if (isFirst0)
	{
		int temp = 0;
		for (size_t i = 0; i < 2*k; ++i) {
			if (i < cs) {
				temp += c[i];
			}
		}

		ret = temp;
		int j = 0;
		for (size_t i = 2 * k; i < cs; i += 2) {
			temp += c[i];
			if (i + 1 < cs) {
				temp += c[i + 1];
			}
			temp -= c[j];
			if (0 <= j - 1) {
				temp -= c[j - 1];
			}
			if (ret < temp) {
				ret = temp;
			}

			j += 2;
		}
	}
	else
	{
		int temp = 0;
		for (size_t i = 0; i < 2 * k + 1; ++i) {
			if (i < cs) {
				temp += c[i];
			}
		}

		ret = temp;
		int j = 1;
		for (size_t i = 2 * k + 1; i < cs; i += 2) {
			temp += c[i];
			if (i + 1 < cs) {
				temp += c[i + 1];
			}
			temp -= c[j];
			if (0 <= j - 1) {
				temp -= c[j - 1];
			}
			if (ret < temp) {
				ret = temp;
			}

			j += 2;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
  int N, K;
  cin >> N >> K;
  int x[N];
  for (int i = 0; i < N; i++)
  {
    cin >> x[i];
  }
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
    if (abs(x[i]) < abs(x[i] - K))
    {
      sum += abs(x[i]) * 2;
    }
    else
    {
      sum += abs(x[i] - K) * 2;
    }
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;

int art[10][10];
int hw[10];
int hd[10];

main(){
	int w,d;
	while(cin>>w>>d){
		if(!w && !d)break;
		
		for(int i=0;i<w;i++){
			cin>>hw[i];
		}
		for(int i=0;i<d;i++){
			cin>>hd[i];
		}
		
		sort(hw,hw+w);
		sort(hd,hd+d);
		
		int sum=0,di=d-1,wi=w-1;
		while(true){
			if(wi<0 && di<0)break;
			if(wi>=0 && di>=0 && hw[wi]==hd[di]){
				sum+=hw[wi];
				--wi;
				--di;
				continue;
			}
			
			if(wi>=0 && di>=0 && hw[wi]<hd[di]){
				sum+=hd[di];
				--di;
				continue;
			}
			
			if(wi>=0 && di>=0 && hd[di]<hw[wi]){
				sum+=hw[wi];
				--wi;
				continue;
			}
			
			if(wi<0 && di>=0){
				sum+=hd[di];
				--di;
				continue;
			}
			
			if(di<0 && wi>=0){
				sum+=hw[wi];
				--wi;
				continue;
			}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <map>
#include <iomanip>
#include <cmath>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using ll = long long;
namespace mp = boost::multiprecision;

int main()
{
    // 整数の入力
    ll N,L;
    vector<pair<ll,ll>> X;
    cin >> N;
    for(int i = 0;i<N;i++){
        ll x,l;
        cin >> x;
        cin >> l;
        X.push_back({x+l,x-l});
    }
    sort(X.begin(),X.end());
    ll last_r= X[0].first;
    ll counts = 1;
    for(int i = 1;i<N;i++){
        if (X[i].second >= last_r){
            last_r = X[i].first;
            counts++;
        }
    }
    cout << counts++ << endl;
   return 0;
}

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

typedef long long LL;

double dist;
LL N, D;
int ans;

int main(){
	cin>>N>>D;
	for(int i=0; i<N; i++){
		LL x,y;
		cin>>x>>y;
		dist = sqrt(x*x+y*y);
		//printf("dist=%f\n", dist);
		if(dist-D<=0.00000000001) ans++;
	}
	cout<<ans;
	return 0;
} 

Measured memory_bytes: 3132
s=[int(x) for x in input().split()]
f=['.'*(s[1]+2)]
for i in range(s[0]):
  f.append('.'+input()+'.')
f.append('.'*(s[1]+2))
for i in range(1,s[0]+1):
  for j in range(1,s[1]+1):
    if f[i][j]=='#':
      continue
    cnt = 0
    for v in [-1,0,1]:
      for h in [-1,0,1]:
        if f[i+v][j+h] =='#':
          cnt+=1
    f[i]=f[i][:j]+str(cnt)+f[i][j+1:]
print('\n'.join([x[1:-1] for x in f[1:-1]]))
      


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int long long N,T,SUM=0,arr,arr2;
   cin>>N>>T;
  // vector<long long>tap;
   cin>>arr;
   for(int i=1;i<N;i++)
   {
     cin>>arr2;
     if(arr2-arr>=T)
     {
         SUM+=T;
     }
     else SUM=SUM+arr2-arr;
     arr=arr2;


   }
   cout<<SUM+T;



}


Measured memory_bytes: 256
import collections

#まずは代入
n = int(input())
s = [input() for _ in range(n)]
c = collections.Counter(s).most_common() #もうリストにしちゃった<3
#この時点で, cは個数が多い順に並んでる
#たとえば入力例1だと
#[('vet', 2), ('beet', 2), ('beat', 1), ('bed', 1), ('bet', 1)]

ans = []
max = c[0][1] #最大の個数は何か? 数値を代入
for item,count in c:
	if count==max:
		ans.append(item)
	else:
		break #もうこれ以下は弱いのしかないのでbreakします

ans.sort() #辞書順に並べる

for i in range(len(ans)):
	print(ans[i])

Measured memory_bytes: 45040
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
 
int main()
{
  int A, B, C, D, E;
  cin >> A >> B >> C >> D >> E;
  
  vector<int> dish_times = {A, B, C, D, E};
  int time_cost;
  int max_time_cost = 10 - (dish_times[0] % 10);
  int max_time_cost_num = 0;
  for(int i = 1; i < 5; i++){
    time_cost = 10 - (dish_times[i] % 10);
    if(max_time_cost < time_cost && time_cost < 10){
      max_time_cost = time_cost;
      max_time_cost_num = i;
    }
  }
  
  int total_time = 0;
  for(int i = 0; i < 5; i++){
    if(i==max_time_cost_num){
      total_time += dish_times[i];
    }else if(dish_times[i]%10==0){
      total_time += dish_times[i];
    }else{
      total_time += dish_times[i] + 10 - (dish_times[i] % 10);
    }
  }
  
  cout << total_time;
}

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

freq = [[0 for _ in range(10)] for _ in range(10)]
for i in range(1, n + 1):
    l = int(str(i)[0])
    r = int(str(i)[-1])
    freq[l][r] += 1

cnt = 0
for i in range(1, n + 1):
    r = int(str(i)[0])
    l = int(str(i)[-1])
    cnt += freq[l][r]
print(cnt)

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

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

fn main() {
    let n = read::<i64>();
    println!("{}", if n % 2 == 0 { n } else { n * 2 });
}


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

int main()
{
  int N, X;
  cin >> N >> X;
  int L[N];
  for (int i = 1; i <= N; i++)
  {
    cin >> L[i];
  }

  int c = 0, s = 0;
  while (s <= X)
  {
    s = s + L[c + 1];
    c++;
  }

  cout << c << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args){
		Scanner input=new Scanner(System.in);
		int sortLong=input.nextInt();
		
		int[] sortNumber=new int[sortLong];
		
		for(int i=0;i<sortLong;i++)
			sortNumber[i]=input.nextInt();
		
		int number=sort(sortNumber);
		
		for(int i=0;i<sortNumber.length-1;i++)
			System.out.print(sortNumber[i]+" ");
		System.out.println(sortNumber[sortNumber.length-1]);
		System.out.println(number);
		
	}
	
	public static int sort(int[] sortArray){
		int minNumber;
		int changeFrequency=0;
		
		for(int i=0;i<sortArray.length-1;i++){
			for(int j=0;j<sortArray.length-1;j++){
				if(sortArray[j]>sortArray[j+1]){
					minNumber=sortArray[j+1];
					
					sortArray[j+1]=sortArray[j];
					sortArray[j]=minNumber;
					
					changeFrequency++;
				}
				
			}
		}
		
		return changeFrequency;
	}

}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    string s;
    cin >> s;
    char prev = '#';
    int32 ans = 0;
    REP(i,n){
        if(s[i] != prev){
            ans++;
            prev = s[i];
        }
    }
    ANS(ans);
    return 0;
}

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

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

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

signed main()
{   
    gearup;
    ll k,s; cin >> k >> s;
    ll res = 0;
    for(int i = 0;i<=k;i++){
        for(int j = 0;j<=k;j++){
            int z = s - (i + j);
            if(z >= 0 && z <= k) res++;
        }
    }
    out(res);
}


Measured memory_bytes: 256
def assert_(s, t):
    if s != t:
        print("No")
        exit()

def main():
    S = input()
    T = input()

    mapping = {}
    mapping_ = {}
    for i in range(len(S)):
        if S[i] in mapping:
            assert_(mapping[S[i]], T[i])
        if T[i] in mapping_:
            assert_(mapping_[T[i]], S[i])
        mapping[S[i]] = T[i]
        mapping_[T[i]] = S[i]
    print("Yes")

main()

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

int main(){
	/*input*/
	int n, m, c; cin >> n >> m >> c;
	int* b = new int [m]; 
	int** a = new int* [n];
	for(int i = 0; i < n; i++){
		a[i] = new int[m];
	}
	for(int i = 0; i < m; i++){
		cin >> b[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> a[i][j];
		}
	}
	/*calculation*/
	int o = 0;
	for(int i = 0; i < n; i++){
		int wa = 0;
		for(int j = 0; j < m; j++){
			wa+=a[i][j]*b[j];
		}
		wa+=c;
		if(wa > 0){
			o++;
		}
	} 
	/*output*/
	cout << o << endl;
	delete[] b;
	for(int i = 0; i < n; i++){
		delete[] a[i];
	}
	delete[] a;
	return 0;
}


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

#define int long long

using namespace std;

signed main() {
    ios::sync_with_stdio(false);

    int n, W;
    cin >> n >> W;
    vector<int> w(n + 1), v(n + 1);
    for(int i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }
    int dp[n + 1][W + 1];
    for(int i = 0; i <= n; i++){
        for(int j = 0; j <= W; j++){
            dp[i][j] = 0;
        }
    }
    for(int i = 1; i <= n; i++){
        for(int j = 1; j <= W; j++){
            dp[i][j] = max(dp[i][j], dp[i - 1][j]);
            if(j - w[i] >= 0) dp[i][j] = max(dp[i][j], dp[i - 1][j - w[i]] + v[i]);
        }
    }
    cout << dp[n][W];
    return 0;
}

Measured memory_bytes: 82436
#include<stdio.h>
int main(void)
{
	int i,j,n,m;
	int x[1000+1],y[1000+1],z[1000+1],a,cnt;
	scanf("%d %d",&n,&m);
	while(n!=0 && m!=0) {
		a=1;
		cnt=0;
		for(i=1;i<=n;i++) {
			scanf("%d",&x[i]);
		}
		for(j=1;j<=m;j++) {
			scanf("%d",&y[j]);
		}
		for(i=1;i<=n;i++) {
			z[i]=i;
		}
		for(j=1;j<=m;j++) {
			a=a+y[j];
			for(i=1;i<=n;i++) {
				if(a==z[i]) {
					a+=(x[i]);
					break;
				}
			}
			cnt=cnt+1;
			if(a<1) {
				a=1;
			}
			if(n<=a) {
				break;
			}
		}
		printf("%d\n",cnt);
	scanf("%d %d",&n,&m);
	}
	return 0;
}

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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

// FenwickTree (0 - indexed)
template<class T>
class FenwickTree {
    int n;
    std::vector<T> data;
public:
    FenwickTree(int n) : n(n), data(n + 1) {}

    // [0, i)の区間和を取得する
    T sum(int i) {
        T s = 0;
        for (; i > 0; i -= i & -i)s += data[i];
        return s;
    }

    // [l, r)の区間和を取得する
    T sum(int l, int r) { return sum(r) - sum(l); }

    // 要素iにxを加算する
    void add(int i, T x) { for (i++; i <= n; i += i & -i)data[i] += x; }
};

// 階乗、階乗逆元テーブル


int N;
int x[220000], y[220000];
pint point[220000];
int tw[220000];
int mod = 998244353;

signed main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
        point[i] = pint(x[i], y[i]);
    }
    sort(point, point + N);
    for (int i = 0; i < N; i++)point[i].first = i;
    for (int i = 0; i < N; i++)swap(point[i].first, point[i].second);
    sort(point, point + N);
    FenwickTree<int> l(N), r(N);
    for (int i = 0; i < N; i++)r.add(i, 1);
    int ans = 0;
    tw[0] = 1;
    for (int i = 1; i <= N; i++)tw[i] = tw[i - 1] * 2 % mod;
    for (int i = 0; i < N; i++) {
        r.add(point[i].second, -1);
        int A = l.sum(point[i].second);
        int B = l.sum(point[i].second, N);
        int C = r.sum(point[i].second);
        int D = r.sum(point[i].second, N);
        (ans += tw[N] - 1 + mod) %= mod;
        (ans -= tw[A + B] - 1 - mod) %= mod;
        (ans -= tw[A + C] - 1 - mod) %= mod;
        (ans -= tw[B + D] - 1 - mod) %= mod;
        (ans -= tw[C + D] - 1 - mod) %= mod;
        (ans += tw[A] - 1 + mod) %= mod;
        (ans += tw[B] - 1 + mod) %= mod;
        (ans += tw[C] - 1 + mod) %= mod;
        (ans += tw[D] - 1 + mod) %= mod;
        l.add(point[i].second, 1);
    }
    cout << ans << endl;

}

Measured memory_bytes: 11648
#include<stdio.h>

int gcd(int ,int);
  
int main(){

  int x, y;
  scanf("%d%d",&x,&y);

  printf("%d\n",gcd(x,y));
  return 0;
}

int gcd(x, y) {

  int r,tmp;
  
  if(x < y){
    tmp =x;
    x = y;
    y = tmp;
  }
  
    while(y > 0){
      r = x % y;
      x = y;
      y = r;
  }

  return x;
}
	       

Measured memory_bytes: 592
#include <stdio.h>

int main() {

    int i;
    int ans[10]={0};
    int a;

    for(i = 0; i < 3; i++) {
        scanf("%d", &a);
        ans[a]++;
    }
    for(i = 1; i <= 9; i++) {
        if(ans[i] == 2) {
            printf("Yes\n");
            return 0;
        }
    }
    printf("No\n");
    
    return 0;
}

Measured memory_bytes: 128
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include<set>
#include<map>
using namespace std;


int main() {
    int a, b;
    cin >> a >> b;
    if((a+b)%3 == 0 || a%3 == 0 || b%3 ==0){
        cout << "Possible" << endl;
    }
    else{
        cout << "Impossible" << endl;
    }
}


Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v) {cout << "{"; for (auto &x : v) {cout << x << ',';} cout << "}" << endl; return;}
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll powmod(ll base, ll exp, ll MOD) {ll res = 1; while (exp > 0) {if (exp % 2 == 1) res = (res * base) % MOD; base = (base * base) % MOD; exp /= 2;} return (res % MOD);}
ll mpow(ll base, ll exp) {ll res = 1; while (exp > 0) {if (exp % 2 == 1) res = (res * base); base = (base * base); exp /= 2;} return (res);}
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
void prefix(vector<ll> &v) {
	ll n = v.size();
	for(ll i=1;i<n;i++) {
		v[i]+=v[i-1];
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vector<ll> red(a);
	vector<ll> green(b);
	vector<ll> colorless(c);
	for (ll i = 0; i < a; i++) {
		cin>>red[i];
	}
	for (ll i = 0; i < b; i++) {
		cin>>green[i];
	}
	for (ll i = 0; i < c; i++) {
		cin >> colorless[i];
	}
	sort(red.begin(),red.end());
	sort(green.begin(),green.end());
	sort(colorless.begin(),colorless.end());
	reverse(red.begin(),red.end());
	reverse(green.begin(),green.end());
	reverse(colorless.begin(),colorless.end());
	priority_queue<ll, vector<ll>, greater<ll> > rr;
	priority_queue<ll, vector<ll>, greater<ll> > gg;
	for(ll i=0;i<x;i++) {
		rr.push(red[i]);
	}
	for(ll i=0;i<y;i++) {
		gg.push(green[i]);
	}
	for(ll i=0;i<c;i++) {
		ll rt = rr.top();
		ll gt = gg.top();
		if(colorless[i] > rt && colorless[i]>gt) {
			if(rt < gt) {
				rr.pop();
				rr.push(colorless[i]);
			}
			else {
				gg.pop();
				gg.push(colorless[i]);
			}
		}
		else if(colorless[i] > rt) {
			rr.pop();
				rr.push(colorless[i]);
		}
		else if(colorless[i] > gt) {
			gg.pop();
				gg.push(colorless[i]);
		}
		else {
			break;
		}
	}
	ll ans = 0;
	while(!rr.empty()) {
		ans += rr.top();
		rr.pop();
	}
	while(!gg.empty()) {
		ans += gg.top();
		gg.pop();
	}
	cout<<ans;
	return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    vector<ll> hp (n);
    for(int i=0; i<n; i++){
        ll h;
        cin >> h;
        hp.at(i) = h;
    }
    sort(hp.begin(),hp.end());
    for(int i=0; i<k; i++){
        if(hp.size() == 0) break;
        hp.pop_back();
    }
    ll ans = 0;
    for(int i=0; i<hp.size(); i++){
        ans += hp.at(i);
    }
    cout << ans;
}

Measured memory_bytes: 1920
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (true) {
            int h = Integer.parseInt(sc.next()); 
            int w = Integer.parseInt(sc.next());
            if (h == 0 && w == 0)
                break;
            for (int i = 0; i < h; i++) {
                for (int j = 0; j < w; j++)
                    if ((i+j) % 2 == 0)
                        System.out.print("#");
                    else
                        System.out.print(".");
                System.out.println();
            }
            System.out.println();
        }
    }
}


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

int main() {
    auto log10 = [](uint64_t n) {
        int log = 0;
        while (10 <= n) {
            ++log;
            n /= 10;
        }
        return log;
    };
    auto first = [](uint64_t n) {
        int last = 0;
        while (n) {
            last = n % 10;
            n /= 10;
        }
        return last;
    };

    int n; cin >> n;

    bool bad = false;
    uint64_t total = 1;
    while (n--) {
        uint64_t a; cin >> a;
        if (a == 0) {
            cout << 0 << endl;
            return 0;
        }

        if (18 <= log10(total) + log10(a) && 10 <= first(total) * first(a) || 1000000000000000000 < total * a) {
            bad = true;
        }

        /*if (18 < log10(total) + log10(a) || 1000000000000000000 < total * a) {
            bad = true;
        }*/

        total *= a;
    }

    if (bad) cout << -1 << endl;
    else cout << total << endl;
}



Measured memory_bytes: 3604
package main

import (
    "bufio"
    "fmt"
	"os"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var S string
	fmt.Scan(&S)
	if S == "ABC"{
		fmt.Println("ARC")
	} else {
		fmt.Println("ABC")
	}
}

Measured memory_bytes: 1756
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    IOS;
    int n;
    cin >> n;
    int four = 0;
    int num=n;
    if(n==1 || n==2 || n==4){
        cout << 4 <<endl;
    }else{
        for(int i=1; i<1000000; i++){
        if(num%2==0){
            num /= 2;
        }else{
            num = (num*3)+1;
        }
        if(num==4){
            four++;
        }
        if(four==2){
            cout << i+1 <<endl; 
            break;
        }
    }
    }
    
}

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

#define whole(f, x, ...)                                 \
  ([&](decltype((x)) whole) {                            \
    return (f)(begin(whole), end(whole), ##__VA_ARGS__); \
  })(x)

using namespace std;
using ll = long long;

void solve() {
  int n;
  string s;
  cin >> n >> s;
  n %= 26;
  for (char& c : s) {
    c += n;
    if (c > 'Z') {
      c = 'A' + c - 'Z' - 1;
    }
  }
  cout << s << endl;
}

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);

  solve();
  return 0;
}


Measured memory_bytes: 256
#include <float.h>
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <math.h>
#ifdef __cplusplus
#include <bits/stdc++.h>
#endif

void rsort_u32(void *base, const int count){
	uint32_t *a=base;
	uint32_t *b=malloc(count*sizeof(uint32_t));
	int c[0x100];
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(0<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(0<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(1<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(1<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(2<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(2<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	memset(c, 0, sizeof(c)); for(int i=0; i<count; i++){ c[(a[i]>>(3<<3))&0xFF]++; } for(int i=1; i<0x100; i++) c[i]+=c[i-1]; for(int i=count-1; i>=0; i--){ b[--c[(a[i]>>(3<<3))&0xFF]]=a[i]; }{void *t=a; a=b; b=t;}
	free(b);
}
int32_t nextint(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); bool s=false; if(c=='-'){s=true;c=getchar_unlocked();} uint32_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }
int64_t nextlong(void){ char c=getchar_unlocked(); while(c!='-'&&(c<'0'||'9'<c)) c=getchar_unlocked(); int s=0; if(c=='-'){s=1;c=getchar_unlocked();} uint64_t x=0; while('0'<=c && c<='9'){ x=x*10+c-'0'; c=getchar_unlocked(); } return s?-x:x; }

int a[200000];
int b[200000];
int main(void){
	int n=nextint();
	for(int i=0; i<n; i++){
		a[i]=nextint();
		b[i]=nextint();
	}
	rsort_u32(a, n);
	rsort_u32(b, n);
	int ans;
	if(n&1){
		int A=a[n/2], B=b[n/2];
		ans=B-A+1;
	}else{
		int A=a[n/2]+a[n/2-1], B=b[n/2]+b[n/2-1];
		ans=B-A+1;
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 3936
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

int main(void)
{
    IOS
    int a, b, c;
    cin >> a >> b >> c;
    int d, e, f;
    cin >> d >> e >> f;
    set<int> waters;
    for(auto i = 0;i*a*100 <= f; i++) {
        for(auto j = 0; (i*a+j*b)*100 <=f; j++) waters.insert((i*a+j*b) * 100);
    }
    waters.erase(0);
    vector<int> waterv(waters.begin(),waters.end());
    
    vector<int> sugar;
    for(auto w:waterv) sugar.push_back(w/100*e);
    //REP(i,sugar.size()) cerr << sugar[i] << endl;
    double maxc = 0;
    int ans = a * 100;
    int anss = 0;
    REP(i,waterv.size()) {
        for(auto j = 0;j*c <= sugar[i];j++) {
            for (auto k = 0; j*c+ k*d <=sugar[i]; k++) {
                int ms = 0;
                if (waterv[i] + j*c+ k*d <= f) ms = j*c+ k*d;
                double cons = static_cast<double>(ms) / (waterv[i] + ms);
                if (maxc < cons) {
                    maxc = cons;
                    ans = waterv[i] + ms;
                    anss = ms;
                }
            }
        }
        //cerr << ans << " " << anss << endl;
    }

    cout << ans << " " << anss << endl;

    return 0;
}

Measured memory_bytes: 256
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

n = int(input())
ans = 0

yakusu = make_divisors(n)

for i in yakusu:
    if i != 1 and (n//(i-1) == n%(i-1)):
        ans += i-1

print(ans)


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

using namespace std;
using ll = long long;
using edge = struct { int to; ll cost; };

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)

long long combination[10001][10001];

//void initC(int n);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve()
{
    char c;
    cin >> c;
    printf("%c\n", c+1);
}

int main()
{
    solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        ArrayList<LinkedList<Tuple>> list = new ArrayList<>();
        for(int i = 0; i <= n; i++) list.add(new LinkedList<>());
        int[] memo = new int[3];
        for (int i = 0; i < m; i++) {
            memo[0] = sc.nextInt();
            memo[1] = sc.nextInt();
            memo[2] = sc.nextInt();
            list.get(memo[0]).add(new Tuple(memo[1], memo[2]));
            list.get(memo[1]).add(new Tuple(memo[0], -memo[2]));
        }
        // DFS
        Deque<Integer> deque = new ArrayDeque<>();
        boolean[] visit = new boolean[n + 1];
        int[] distance = new int[n + 1];
        for (int i = 1; i <= n; i++) {
            if (!visit[i]) {
                distance[i] = 0;
                visit[i] = true;
                deque.push(i);
                while (!deque.isEmpty()) {
                    int curr = deque.poll();
                    Iterator<Tuple> it = list.get(curr).iterator();
                    while(it.hasNext()) {
                        Tuple next = it.next();
                        if (!visit[next.x]) {
                            visit[next.x] = true;
                            distance[next.x] = distance[curr] - next.y;
                            deque.push(next.x);
                        } else {
                            if (distance[next.x] != distance[curr] - next.y) {
                                System.out.println("No");
                                return;
                            }
                        }
                    }
                }
            }
        }
        System.out.println("Yes");
    }

    static class Tuple {
        final int x;
        final int y;
        Tuple(int x, int y) {
            this.x = x;
            this.y = y;
        }
    }
}


Measured memory_bytes: 175416
#include<stdio.h>
#include<iostream>
#include<string>
#include<cstring>

using namespace std;

int main()
{
	unsigned long long a;
	unsigned long long b;
	unsigned long long c;
	cin>>a;
	cin>>b;
	cin>>c;
	unsigned long long n=0;
		if(c>a+b)
		{
			n=a+b+b+1;
		}
		else if(c==a+b)
		{
			n=b+c;
		}
		else
		{
			n=b+c;
		}
		cout<<n;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<set>
#include<ctime>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
inline void write(int a){
	if(a>=10)write(a/10);
	putchar('0'+a%10);
}
inline void writeln(int a){
	write(a); puts("");
}
inline int read()//不管是正负数，都可以 
{
	int x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
		return positive ? x : -x;
}
int a[100];
char ch[10];
inline void print(){int i,zs=0,flag=1;
//a[9]=3; a[8]=2; a[6]=1;
	for(i=1;i<=9;i++)if(a[i]){
		break;
	}for(int j=9;j>=i;j--){if(a[j]!=9)flag=0;zs=zs*10+a[j];} 
	for(int j=i;j;j--){
		printf("? %d\n",zs+1); fflush(stdout);
		scanf("%s",&ch);
		if((ch[0]=='Y')^flag){
			putchar('!'); putchar(' ');
			for(i=9;i>=j;i--)putchar(a[i]+48); return;
		}
		zs*=10;
	}
}
inline void dfs(int p){
	if(!p){
		print(); return ;
	}
	int l=0,r=9,i; if(p==9)l++;
	while(l<r){
		int mid=(l+r)>>1;
		putchar('?'); putchar(' '); 
		for(i=9;i>p;i--)putchar(a[i]+48); 
		putchar(mid+48); for(i=p;i;i--)putchar('9'); 
		puts(""); fflush(stdout);
		scanf("%s",&ch);
		if(ch[0]=='Y')r=mid; else l=mid+1;
	}
	a[p]=l;
	dfs(p-1);
}
int main(){
	printf("? %d\n",999999999); fflush(stdout);
		scanf("%s",&ch); if(ch[0]=='N'){
			puts("! 1000000000"); return 0;
		}
	dfs(9);
	return 0;
}

Measured memory_bytes: 596
#include <cstdio>

int main(){
    int n,k;
    scanf("%d %d",&n,&k);
    int min = n / k;
    int max;
    if(n % k >= 1){
        max = min + 1;
    }else{
        max = min;
    }
    printf("%d\n",max - min);

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
#include<functional>
using namespace std;
int stoi(string x){stringstream ss;ss<<x;int tmp;ss>>tmp;return tmp;}
string itos(int x){stringstream ss;ss<<x;return ss.str();}
bool is(int x){
	for(int i=2;i*i<=x;i++)if(x%i==0)return false;
	return true;
}
int main(){
int n;
while(cin>>n,n!=0){
int cnt=0,ans=0;
for(int i=2;;i++){
	if(is(i))cnt++,ans+=i;
	if(cnt==n)break;
}
cout<<ans<<endl;

}

	return 0;
}

Measured memory_bytes: 1164