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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

struct Point : public complex<double>
{
public:
  Point() { this->real(0);  this->imag(0); }
  Point(const double& x, const double& y) { this->real(x);  this->imag(y); }
  Point(const complex<double> w)  { this->real(w.real());  this->imag(w.imag()); }
  inline double dot(Point p){ return (conj(*this) * p).real(); }  // ??????
  inline double det(Point p){ return (conj(*this) * p).imag(); }  // ??????
};

namespace std
{
  inline bool operator < (const Point& a, const Point& b)
  {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
typedef vector<Point> Polygon;
inline Point currPoint(vector<Point> P, int i){ return P[i]; }
inline Point nextPoint(vector<Point> P, int i){ return P[(i+1)%P.size()]; }
inline Point diffPoint(vector<Point> P, int i){ return nextPoint(P, i) - currPoint(P, i); }


int ccw(Point a, Point b, Point c)
{
  b -= a;
  c -= a;
  if(b.det(c) > 0.0)    return  1;         // counter clockwise
  if(b.det(c) < 0.0)    return -1;         // clockwise
  if(b.dot(c) < 0.0)    return  2;         // c--a--b on line
  if(norm(b) < norm(c)) return -2;         // a--b--c on line
  return 0;
}

double x, y;
int q;

int main()
{
  cin >> x >> y;  Point P = Point(x, y);
  cin >> x >> y;  Point Q = Point(x, y);

  cin >> q;
  while(q--){
    cin >> x >> y;
    int c = ccw(P, Q, Point(x, y));
    if(c ==  1){ puts("COUNTER_CLOCKWISE");  continue; }
    if(c == -1){ puts("CLOCKWISE");          continue; }
    if(c ==  2){ puts("ONLINE_BACK");        continue; }
    if(c == -2){ puts("ONLINE_FRONT");       continue; }
    puts("ON_SEGMENT");
  }

  return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
int main(){
  int n,x,a,i,b;
  while(1){
    a=0;
  scanf("%d %d",&n, &x);
  if(n==0 && x==0)break;
  for(i=(x-1)/3+2;i<n+1;i++){
    if(i<(x-i)) {
      b=x-2*i;
    }else{
      b=0;
    }
    if((x-i)>2){
    a=a+((x-i)-1)/2-b;
    }
      }
  if(a<0) a=0;
  printf("%d\n",a);
  }
  return 0;
}

Measured memory_bytes: 600
#include "bits/stdc++.h"
#define ROPi(n) for(int i=0; i<n; i++)
#define ROPj(n) for(int j=0; j<n; j++)
#define ROPia(a,n) for(int i=a; i<n; i++)
using namespace std;

int main()
{
  int N, K;
	cin >> N >> K;

	vector<int> l;
	int input;
	ROPi(N) {
		cin >> input;
		l.push_back(input);
	}
	stable_sort(l.begin(), l.end());

	int ans = 0;
	ROPi(K) {
		ans += l.at(N - 1 - i);
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<n;++i)
#define ALL(x) x.begin(),x.end()

using namespace std;
typedef long long ll;

template<typename T>
T gcd(T a, T b) {
    if (a % b == 0) {
        return(b);
    }
    else {
        return(gcd(b, a % b));
    }
}

template<typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

ll mod(ll a, ll b) {
    ll ans = a % b;
    if (ans < 0) {
        ans = b + ans;
    }
    return ans;
}

int main(void) {
    ll x, y, n, ans = 0,D;
    cin >> n >> D;
    rep(i, n) {
        cin >> x >> y;
        if (x * x + y * y <= D * D) {
            ++ans;
        }
    }
    cout << ans;

}

/*
5 4 3 2 1
*/


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double PI = 4*atan(1);
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-6;
const string YES = "Possible";
const string NO = "Impossible";
#define pb push_back
#define mp make_pair

int N, M;
string S, T;

ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}

void solve()
{
	const long long L = (ll)N*M/gcd(N,M); //lowest possible length
	bool ok = true;
    for(int i=0;i<N;++i){
        ll a = i*L/N;
        if(a % (L/M) == 0){
            ll b = a/(L/M);
            if(S[i]!=T[b]){
                ok = false;
                break;
            }
        }
    }
	bool ok2 = true;
	for(int i=0;i<M;++i){
		ll a=i*L/M;
		if(a%(L/N)==0){
			ll b = a/(L/N);
			if(T[i]!=S[b]){
				ok2=false;
				break;
			}
		}
	}
	if(ok && ok2) cout << L << endl;
	else cout << -1 << endl;
}

int main()
{
	cin >> N >> M;
	cin >> S >> T;
	solve();
}

Measured memory_bytes: 512
using System;
using System.Linq;
using System.Text;

public class AtCoder_162_B
{
    public static void Main()
    {
        long n = long.Parse(Console.ReadLine());

        long sum = 0;
        for (long i = 1; i <= n; i++)
        {
            if (i % 15 != 0 && i % 3 != 0 && i % 5 != 0)
            {
                sum += i;
            }
        }

        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 27536
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const int MAXN=1e5+5;
const ll inf=(1ll<<63-1);
ll a[MAXN];
ll dp[MAXN];
int main()
{

    ll n,e,t;
    cin>>n>>e>>t;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    memset(dp,(ll)0x3f3f3f3f,sizeof(dp));
    dp[0]=0;
    ll mn=inf;
    for(int i=1,now=0;i<=n;i++){
        while(t<=2*(a[i]-a[now+1]))
        {
            mn=min(mn,dp[now]-2*a[now+1]);
            now++;
        }
        dp[i]=dp[now]+t;
        dp[i]=min(dp[i],mn+2*a[i]);

    }
    cout<<e+dp[n]<<endl;
    return 0;

}


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

int main(){
  int N;
  vector<int> A;
  
  cin>>N;
  for(int i=0;i<N;i++){
    int x;
    cin>>x;
    A.push_back(x);
  }
  
  sort(A.begin(),A.end());
  int M = A.at(1);
  
  int answer;
  
  for(int i=M;i>0;i--){
    int x=0;
    for(int j=0;j<N;j++){
      if (A.at(j)%i!=0) x++;
      if (x>1) break;
    }
    if (x<=1) {
      answer = i;
      break;
    }
  }
  
  cout<<answer<<endl;
}

Measured memory_bytes: 892
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long
#define mod 1000000007

char s[1123456];
ll k;

ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}

int main(){
  scanf("%lld",&k);
  scanf("%s",s);

  ll naga=strlen(s);
  ll ans=pom(26,k,mod);
  ll tmp=1;
  for(ll i=1;i<=k;i++){
    tmp = tmp*(i+naga-1)%mod*pom(i,mod-2,mod)%mod;
    ans += tmp*pom(25,i,mod)%mod*pom(26,k-i,mod)%mod;
    ans %= mod;
  }
  
  printf("%lld\n",ans);
  
  return 0;
}


Measured memory_bytes: 2688
N = gets.to_i
INF = N + 1
dp = Array.new(N+1,INF)
dp[0] = 0
n = N
a = 1
b = 1
ans = 0
stack = [1]
# binding.pry
while n / (a * 9) >= 1
  stack << a *= 9
end
# p a
while n / (b * 6) >= 1
  stack << b *= 6
end
stack.sort_by!{|x|x}
# p stack
stack.size.times do |i|
  stack[i].upto(N) do |j|
    dp[j] = [dp[j], dp[j - stack[i]] + 1].min
  end
end
puts dp[N]

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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main() {
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    REP(i, n) {
        int h;
        cin >> h;
        if(h >= k) cnt++;
    }
    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll x, y, a, b, s, t;
  in2(x, y);
  in2(a, b);
  s = a - x;
  t = b - y;
  out(a - t);
  hina;
  out(s + b);
  hina;
  out(x - t);
  hina;
  out(y + s);
  memi;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>

#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <deque>
#include <string>
#include <queue>

#include <algorithm>
#include <numeric>
#include <random>

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>

using namespace std;

#define forn(i, n) for (ll i = 0; i < static_cast<ll>(n); ++i)
#define sz(a) static_cast<int>((a).size())
#define pb emplace_back
#define endl '\n'
#define f first
#define s second

#ifdef LOCAL
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define dbg(...)
#endif

template<typename T>
void _dbg(const char* _s, T _h) { cerr << _s << " = " << _h << "\n"; }

template<typename T, typename... Ts>
void _dbg(const char*_s, T _h, Ts... _t) {
    int _b = 0;

    while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',')
        cerr << *_s++;

    cerr << " = " << _h << ",";
    _dbg(_s + 1, _t...);
}

using ll = long long;

const ll INF = static_cast<ll>(1e9) + 7ll;
const ll LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;

int n, m;
string s;
set<int> g[MAXN];
int cntA[MAXN], cntB[MAXN];
bool used[MAXN];

bool read() {
    if (!(cin >> n >> m >> s))
        return false;

    forn (i, m) {
        int u, v;
        cin >> u >> v;
        g[u - 1].insert(v - 1);
        g[v - 1].insert(u - 1);
    }

    return true;
}

void solve() {
    queue<int> Q;
    int rem = 0;

    for (int v = 0; v < n; ++v) {
        for (auto u : g[v]) {
            cntA[v] += (s[u] == 'A');
            cntB[v] += (s[u] == 'B');
        }

        if (cntA[v] == 0 || cntB[v] == 0) {
            Q.push(v);
            used[v] = true;
        }
    }

    while (!Q.empty()) {
        auto v = Q.front();
        Q.pop();
        ++rem;

        for (auto to : g[v]) {
            if (to == v)
                continue;

            g[to].erase(v);
            cntA[to] -= (s[v] == 'A');
            cntB[to] -= (s[v] == 'B');

            if (!used[to] && (cntA[to] == 0 || cntB[to] == 0)) {
                used[to] = true;
                Q.push(to);
            }
        }

        g[v].clear();
    }

    if (rem == n)
        cout << "No\n";
    else
        cout << "Yes\n";
}

int32_t main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

#ifdef LOCAL
    //freopen("/Users/leemonage/CLionProjects/proj/file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


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

int main() {
  int n,k,r,s,p,ans=0;
  cin>>n>>k>>r>>s>>p;
  string t;
  cin>>t;

  rep(i,k){
      int ro=n/k;
      char me='x';
      ro+=(n%k>=(i+1) ? 1 : 0);
    rep(j,ro){
      if(t.at(k*j+i)!=me){
          if(t.at(k*j+i)=='r') ans+=p;
          if(t.at(k*j+i)=='s') ans+=r;
          if(t.at(k*j+i)=='p') ans+=s;
          me=t.at(k*j+i);
      }
      else{
          me='x';
      }
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		//次回のABC
		int N = sc.nextInt();
		//桁数ゾロ目にするため
		int x = N/111;
		//割り切れないとき(670など)は
		//次回ゾロ目の時(777)に参加する
        //670/111=6, 6+1=7, 7*111=777
		if(N%111!=0) {
			x+=1;
		}
		System.out.println(111*x);
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>
#include <set>

using namespace std;
using ll = long long;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

const ll MOD = 1e9 + 7;
const ll INF = 1 << 30;
const ll INF2 = 9e18;
const double INF3 = 9e14;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
const int tx[8] = { -1,0,1,-1,1,-1,0,1 }, ty[8] = { -1,-1,-1,0,0,1,1,1 };
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define fr first
#define sc second


int main() {
	int n, s[110], sum = 0;
	cin >> n;
	for (int i = 0;i < n;i++) {
		cin >> s[i];
		sum += s[i];
	}
	if (sum % 10 != 0) {
		cout << sum << endl;
		return 0;
	}
	sort(s, s + n);
	for (int i = 0;i < n;i++) {
		if (s[i] % 10 != 0) {
			cout << sum - s[i] << endl;
			return 0;
		}
	}
	cout << 0 << endl;
}

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


int main(void)
{	
	char n[4];
	scanf("%s",n);
	
	if(n[0]==n[2]){
		printf("Yes\n");
	} else{
		printf("No\n");
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  ll n;
  cin >> n;
  map<string, int> mp;
  string s;
  rep(i, n) cin >> s, mp[s]++;
  vector<pair<int, string>> p;
  set<string> st;

  for (auto m : mp) {
    p.push_back({m.second, m.first});
  }
  sort(p.rbegin(), p.rend());

  for (auto pp : p) {
    if (pp.first >= p[0].first) st.insert(pp.second);
  }
  for (auto ss : st) cout << ss << endl;
  return 0;
}


Measured memory_bytes: 37744
n = int(input())
k = 0
count = 0
m = 0
for i in range(1, n + 1):
  count = 0
  j = i
  while j % 2 == 0:
    count += 1
    j = j // 2
  if i == 1:
    k = count
    m = i
  elif k < count:
    k = count
    m = i
print(m)

Measured memory_bytes: 2940
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
const long long INF = 99999999999999999;
const long long MOD = 1e9 + 7;
const double pi = 3.1415926535897932384626;
const int SIZE = 1 << 17;

int main() {
	int k[5], l[5], m[5][5];
	bool ans = true;
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) {
			cin >> m[i][j];
		}
	}
	l[0] = m[0][0], l[1] = m[0][1], l[2] = m[0][2], k[0] = 0, k[1] = m[1][0] - l[0], k[2] = m[2][0] - l[0];
	for (int i = 0; i < 3; ++i) {
		for (int j = 0; j < 3; ++j) { if (m[i][j] != k[i] + l[j]) { ans = false; } }
	}
	string fi = "No";
	if (ans) { fi = "Yes"; }
	cout << fi << endl;
}

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

int main(){
  long n, d;  cin >> n >> d;
  long ans = 0;

  for(long i=0; i<n; i++){
    long x, y;  cin >> x >> y;
    if(x*x+y*y <= d*d)  ans++;
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 3620
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define u64 uint64_t
#define ll long long
#define endl "\n"
#define PI acos(-1)
#define fi first
#define si second
#define mp make_pair
#define pb push_back
#define set0(arr) memset(arr,0,sizeof(arr))
#define setinf(arr) memset(arr,126,sizeof(arr))
#define vsort(v) sort(v.begin(),v.end())
#define all(x) (x).begin(),(x).end()
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using pll = pair<ll,ll>;
using vl = vector<ll>;
using vpll = vector<pll>;
using mll = map<ll,ll>;
using mcl = map<char,ll>;
using sl = set<ll>;
using sc = set<char>;
using dl = deque<ll>;
ll mod=1e9+7;
const int N=1e6+5;
vl adj[200005];
vpll adjc[200005];
ll vis[200005],dis[200005];
ll arr[N];
void dfs(ll x)
{
    vis[x]=1;
    for(ll i=0;i<adjc[x].size();i++)
    {
        auto p=adjc[x][i];
        if(!vis[p.first])
        {
            dis[p.first]=dis[x]+p.second;
            dfs(p.first);
        }
    }
}
int main()
{
    IOS;
    ll a,b,c,d,sz,n,m,p,x,y,z,i,j,k,f=0,tc,cnt=0,sum=0,mul=1,mi=1e18,ma=-1e18;
    string str;
    char ch;
    double db;
    //code
    cin>>n;
     set0(vis);
    for(i=1;i<n;i++)
    {
        cin>>a>>b>>c;
        adjc[a].pb({b,c});
        adjc[b].pb({a,c});
    }
    dis[1]=0;
    dfs(1);
   for(i=1;i<=n;i++)
   {
       cout<<dis[i]%2<<endl;
   }



    //code
    return 0;
}


Measured memory_bytes: 21968
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  cin >> n;
  vector<ll> a(n), b(n);
  rep(i,n) {
    cin >> a[i] >> b[i];
  }
  sort(all(a));
  sort(all(b));
  if (n % 2 == 0) {
    ll left1 = a[n/2-1], left2 = a[n/2];
    ll right1 = b[n/2-1], right2 = b[n/2];
    debug(left1, left2, right1, right2);
    ll ans = (right2 - left2 + 1) + right1 - left1;
    cout << ans << endl;
  }
  else {
    ll left = a[n/2], right = b[n/2];
    cout << right - left + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 6364
N, C = map(int, input().split())
X = {}
V = {}
for i in range(N):
    X[i], V[i] = map(int, input().split())

left, right = [], []
left.append(V[0] - X[0])
right.append(V[N-1] - (C - X[N-1]))
for i in range(1, N):
    left.append(left[i-1] + V[i] - X[i] + X[i-1])
    right.append(right[i-1] + V[N-i-1] - (C - X[N-i-1]) + (C - X[N-i]))

left_max = [0]
for i in range(N):
    if left[i] > left_max[i]:
        left_max.append(left[i])
    else:
        left_max.append(left_max[i])
right_max = [0]
for i in range(N):
    if right[i] > right_max[i]:
        right_max.append(right[i])
    else:
        right_max.append(right_max[i])
result = set()
for i in range(N):
    result.add(left[i]-X[i]+right_max[N-1-i])
for i in range(N):
    result.add(right[i]-(C - X[N-i-1])+left_max[N-1-i])
result = max(max(left_max), max(right_max), max(result))
print(result)

Measured memory_bytes: 58060
import sys
sys.setrecursionlimit(int(1e7))
n, m = map(int, input().split())
a = [[int(v) % 2 for v in input().split()] for _ in range(n)]
moves = []
for i in range(n):
    for j in range(m):
        if i == n - 1 and j == m - 1:
            break

        if a[i][j] == 1:
            if j == m - 1:
                moves.append((i + 1, j + 1, i + 2, j + 1))
                a[i + 1][j] ^= 1
            else:
                moves.append((i + 1, j + 1, i + 1, j + 2))
                a[i][j + 1] ^= 1

print(len(moves))
for move in moves:
    print(*move)


Measured memory_bytes: 26552
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define ll long long

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	ll ans = 0;
	pair<ll, ll> arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i].first >> arr[i].second;
	}
	for (int i = n - 1; i >= 0; i--) {
		if ((arr[i].first + ans )% arr[i].second == 0)
			continue;
		else if (arr[i].first + ans > arr[i].second) {
			ans += (arr[i].second - ((arr[i].first + ans) % arr[i].second));
		} else {
			ans += arr[i].second - (arr[i].first + ans);
		}
		//cout << ans << endl;
	}
	cout << ans << endl;
	return 0;

}


Measured memory_bytes: 5216
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) { if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(DUMPALL_ITR, (q).size()) { cerr << (q)[DUMPALL_ITR] << (DUMPALL_ITR == DUMPALL_ITR_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(T a, T b) { if (a < b) std::swap(a, b); while (b) std::swap(a %= b, b); return a; }
template<class T> T lcm(const T a, const T b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    // インタラクティブ問題では除去した方がいいかも
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    ll n; cin >> n;
    vector<string> w(n);
    REP(i, n) cin >> w[i];

    bool okay = true;

    // twice
    REP(i, n) REP(j, i) {
        if (w[i] == w[j]) {
            okay = false;
        }
    }

    // shiritori
    REP(i, n-1) {
        if (w[i].back() != w[i+1].front()) {
            okay = false;
        }
    }

    cout << Yes(okay) << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int n,k;
    string s;
    cin>>n>>k>>s;
    int a=1,b=0,c=0;
    rep(i,n){
        if(s[i]=='0'&&a==1){
            if(b==k) break;
            else b++,a=0;
        }
        if(s[i]=='1'&&a==0) a=1;
        c++;
    }
    int d=c,x=0,y=c;
    while(y<n){
        while(s[x]=='1') x++;
        while(s[x]=='0') x++;
        while(s[y]=='0') y++;
        while(s[y]=='1') y++;
        d=max(d,y-x);
    }
    cout<<d;
}

Measured memory_bytes: 512
#include <stdio.h>

int main(void) {
	// your code goes here
	int a, b, k;
	scanf("%d %d", &a, &b);
	k = (a+b)/2;
	int tm1, tm2;
	tm1 = abs(a-k);
	tm2 = abs(b-k); 
	if(tm1 == tm2){
	printf("%d\n", k);
	}
	else {
		printf("IMPOSSIBLE\n");
	}
	return 0;
}


Measured memory_bytes: 128
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def main():
    N = int(input())
    D = list(map(int, input().split()))

    count = [0] * N
    for d in D:
        count[d] += 1
    
    if D[0] != 0 or count[0] >= 2:
        print(0)
        exit()

    ans = 1
    for i in range(N):
        if i > 0:
            ans *= (count[i-1] ** count[i]) % 998244353
            ans %= 998244353

    print(ans)

    

if __name__ == '__main__':
        main()


Measured memory_bytes: 13876
N, x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
count=0
for i in range (N):
    if i ==(N-1):
        if x==a[i]:
            count+=1
    elif x>=a[i]:
        x=x-a[i]
        count+=1
print(count)

Measured memory_bytes: 3316
f1=-1;f2=-1;z1=0;z2=0
N,M,X,Y=map(int,input().split())
x=sorted(list(map(int,input().split())))
y=sorted(list(map(int,input().split())))

z1=x[-1]+1
z2=y[0]
if z1<=z2:
  if X<=x[-1] and Y>=y[0]:
    print("No War")
  else:
    print("War")
else:
  print("War")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace  std;
int dig (long long  x)
{
    int ans=0;
    while(x)
    {
        x/=10;
        ans++;

    }
    return  ans;
}


int main()
{
  int n;
  cin>>n;
  int cn=0;
  for(int i=1;i<=n;i++)
  {
      if(dig(i)%2!=0)
          cn++;
  }
  cout<<cn;
}


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

static int stack[100];
static int top = 0;

int isEmpty(void) {
  if (top == 0) {
    return -1;
  }
  return 0;
}

int isFull(void) {
  if (top == 100) {
    return -1;
  }
  return 0;
}

void push(int v) {
  if (isFull() < 0) {
    puts("push ERROR: stack full");
    exit(EXIT_FAILURE);
  }
  stack[++top] = v;
}

int pop(void) {
  if (isEmpty() < 0) {
    puts("pop ERROR: stack empty");
    exit(EXIT_FAILURE);
  }
  return stack[top--];
}

int main(void) {
  int a, b;
  char input[100];
  
  while ( scanf("%s", input) != EOF ) {
    switch (input[0]) {
    case '+':
      b = pop();
      a = pop();
      push(a+b);
      break;
    case '-':
      b = pop();
      a = pop();
      push(a-b);
      break;
    case '*':
      b = pop();
      a = pop();
      push(a*b);
      break;
    case '\n':
      break;
    default:
      push(atoi(input));
    }
  }
  printf("%d\n", pop());
  //printf("stack:\n%d\n%d\n%d\n", stack[3], stack[2], stack[1]);

  exit(EXIT_SUCCESS);
}


Measured memory_bytes: 2048
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int N, K;
    io.read(N, K);
    int ans = 1;
    for(int i = 0; i < N; i++){
        ans = min(ans * 2, ans + K);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
    using namespace std;
     
    int main(){
    	int i,j,k,c=0,s=0;
      cin>>i>>j>>k;
      if(i==5){
      	c++;
      }
      if(i==7){
      	s++;
      }
      if(j==5){
      	c++;
      }
      if(j==7){
      	s++;
      }
      if(k==5){
      	c++;
      }
      if(k==7){
      	s++;
      }
      if(c==2&&s==1){
      cout<<"YES";
      }
      else{
      cout<<"NO";
      }
    }

Measured memory_bytes: 3556
import math
def factorize(n):
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct

S = int(input())
x = int(math.ceil(math.sqrt(S)))
Z = x * x - S

if Z == 0:
    z = 0
    oz = 0
else:
    fs = factorize(Z)
    z = 1
    oz = 1
    for k, c in fs:
        while c >= 2:
            z *= k
            oz *= k
            c -= 2
        if c > 0:
            if z < oz:
                z *= k
            else:
                oz *= k




print("0 0 {} {} {} {}".format(x, z, oz, x))

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<char, ll> pcl;

#define m0(x) memset(x, 0, sizeof(x))
#define all(x) x.begin(), x.end()
#define rep(i, n) for(int i = 0; i < (n); i++)
#define asort(x) sort(all(x));
#define dsort(x, t) sort(x.begin(), x.end(), greater<t>());
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define MINS(m, s) m.insert(mp(s, 1));
#define MFIN(m, s) m.find(s) != m.end()
#define mp make_pair
#define pb push_back
#define INF (1 << 29)
const int mod = 1000000007;

ll check[1000100] = {0};

vector<ll> enum_div(ll n) {
    vector<ll> res;
    for(ll i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            res.push_back(i);
            if(i != 1 && i * i != n) {
                res.push_back(n / i);
            }
        }
    }
    return res;
}

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

    ll ans = 0;
    rep(i, n) {
        bool flag = true;
        for(auto x : enum_div(a[i])) {
            if(x != a[i] && check[x] != 0)
                flag = false;
            if(check[a[i]] != 1)
                flag = false;
        }
        if(flag) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12660
#include <stdio.h>

int exponential(int b,int p){
  if(p == 1) return b;
  return b * exponential(b,p - 1);
}

int main(){
  
  int a,b,c,K;
  scanf("%d%d%d%d",&a,&b,&c,&K);
  
  int max,ans;
  
  max = a;
  if(b > max) max = b;
  if(c > max) max = c;
  
  if(max == a) ans = a * exponential(2,K) + b + c;
  if(max == b) ans = a + b * exponential(2,K) + c;
  if(max == c) ans = a + b + c * exponential(2,K);
  
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
A,B = map(int,input().split())
if A==0:
    fa = 0
else:
    v = (A-1)%4
    fa = 1 if v==2 or v ==1 else 0
    fa = fa ^ (A-1) if v%2==0 else fa
if B==0:
    fb = 0
else:
    v = (B)%4
    fb = 1 if v==2 or v ==1 else 0
    fb = fb ^ B if v%2==0 else fb
print(fa ^ fb)

Measured memory_bytes: 61748
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define inf 12345678987654321
using namespace std;

int main()
{
    ll i,j,k,l,m,n,o,p,t,z=0;
  vector<pair<ll,ll> >vc;
  cin>>n>>m;
  for(i=1;i<=m;i++)
  {
     cin>>k>>l;
     vc.pb({min(k,l),max(k,l)});
  }
  sort(vc.begin(),vc.end());
  ll cnt=0;
  ll ind=vc[0].second;
 // cout<<endl;
  for(i=1;i<m;i++)
  {
      //cout<<vc[i].first<<" "<<vc[i].second<<" ";
      if(vc[i].first>=ind)
      {
          cnt++;
          ind=vc[i].second;
      }
     else ind=min(ind,vc[i].second);
  }
cout<<cnt+1<<endl;
    return 0;
}



Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9+7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll h,w;
    cin >> h >> w;
    ll ans = INF;
    rep1(i, max(h,w)){
        vector<ll> area(3);
        area[0] = i * w;
        area[1] = (h - i) * (w / 2);
        area[2] = (h - i) * ((w + 1) / 2);
        sort(all(area));
        chmin(ans, area[2] - area[0]);
        
        area[0] = i * w;
        area[1] = (h - i) / 2 * w;
        area[2] = ((h - i) + 1) / 2 * w;
        sort(all(area));
        chmin(ans, area[2] - area[0]);
        
        area[0] = i * h;
        area[1] = (w - i) * (h / 2);
        area[2] = (w - i) * ((h + 1) / 2);
        sort(all(area));
        chmin(ans, area[2] - area[0]);
        
        area[0] = i * h;
        area[1] = (w - i) / 2 * h;
        area[2] = ((w - i) + 1) / 2 * h;
        sort(all(area));
        chmin(ans, area[2] - area[0]);
    }
    pf(ans);
    return 0;
}


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

int tata[100010];
int g[100010];
int find(int x) {
    if (tata[tata[x]] != tata[x])
        tata[x] = find(tata[x]);
    return tata[x];
}

void unite(int a, int b)
{
    a = find(a);
    b = find(b);
    if (a == b)
        return;
    if (g[a] > g[b])
        g[a] += g[b], tata[b] = a;
    else
        g[b] += g[a], tata[a] = b;
}

int p[100010];

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

    for (int i(1); i <= n; i++)
        g[i] = 1, tata[i] = i;

    for (int i(1); i <= n; i++)
        cin >> p[i];

    while (m--) {
        cin >> a >> b;
        unite(a, b);
    }

    int ans(0);

    for (int i(1); i <= n; i++)
        ans += (find(i) == find(p[i]));

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 1408
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

res = 0
for i in range(N):
    if(A[i] < B[i]):
        res += A[i]
        tmp = B[i] - A[i]
        A[i] = 0
        if(tmp < 0):
            tmp = 0
        if(A[i+1] < tmp):
            res += A[i+1]
            A[i+1]=0
        else:
            res += tmp
            A[i+1] -= tmp
    else:
        res += B[i]
        A[i] = 0
print(res)


Measured memory_bytes: 18476
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        Map<Integer, Integer> h = new HashMap<>();
        for (int i = 0; i < m; i++) {
            int x = Integer.parseInt(sc.next());
            int y = Integer.parseInt(sc.next());
            if (x == 1) {
                if (h.containsKey(y)) {
                    h.put(y, h.get(y) + 1);
                } else {
                    h.put(y, 1);
                }
            } else if (y == n) {
                if (h.containsKey(x)) {
                    h.put(x, h.get(x) + 1);
                } else {
                    h.put(x, 1);
                }
            }
        }
        sc.close();
        for (int v : h.values()) {
            if (v == 2) {
                System.out.println("POSSIBLE");
                return;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 80320
nlist = [None] * 150

def main():
    
    stri = input()
    
    for i in range(len(stri)):
        ind = ord(stri[i])
        nlist[ind] = 1
    
    for i in range(len(nlist)):
        if nlist[i] == None and (i > 96 and i<123) :
            print(str(chr(i)))
            return
    print("None")

if __name__== "__main__" : main()

Measured memory_bytes: 3188
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <iterator>
#include <algorithm>

typedef long long lint;

using namespace std;

void showIntArray(lint a[], lint n);

int main() {
  lint r, D, x2000;
  cin >> r >> D >> x2000;
  lint xnext, xi = x2000;
  for (int i = 1; i <= 10; i++) {
    xnext = r * xi - D;
    cout << xnext << endl;
    xi = xnext;
  }
  return 0;
}

void showIntArray(lint a[], lint n) {
  for (int i=0; i<n; i++) {
    cout << a[i] << ' ';
  } cout << endl;
}


Measured memory_bytes: 256
sch = []
fin = []
total = 0
cnt,time = map(int,input().split())

for i in range(cnt):
    n,t = input().split()
    sch.append([n,int(t)])

while len(sch) > 0:
    if sch[0][1] <= time:
        total += sch[0][1]
        v = sch.pop(0)
        fin.append([v[0],total])
    else:
        total += time
        sch[0][1] -= time
        last = sch.pop(0)
        sch.append(last)

for i in range(len(fin)):
    print("{0} {1}".format(fin[i][0],fin[i][1]))

Measured memory_bytes: 17380
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  int H, W;
  cin >> H >> W;
  string S[H];
  rep(i, 0, H) { cin >> S[i]; }

  //  八方向で隣接しているマスに'#'があるか調べる。
  rep(i, 0, H) {    // 行
    rep(j, 0, W) {  //　列
      if (S[i][j] == '#') {
        cout << "#";
        continue;
      }
      int cnt = 0;
      rep(k, j - 1, j + 2) {
        if (S[i - 1][k] == '#') cnt++;
        if (S[i + 1][k] == '#') cnt++;
      }
      if (S[i][j - 1] == '#') cnt++;
      if (S[i][j + 1] == '#') cnt++;
      cout << cnt;
    }
    cout << endl;
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		while(true) {
			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			if(num1 == 0 && num2 == 0) break;

			if(num1 < num2) {
				System.out.println(num1 + " " + num2);
			} else {
				System.out.println(num2 + " " + num1);
			}
		}

		sc.close();

	}

}


Measured memory_bytes: 36276
#include <stdio.h>

int main(void) {
  int A,B,C,D;
  scanf("%d%d%d%d",&A,&B,&C,&D);

  int x;
  if (A<B)
   x=A;
   else
   x=B;
  int y;
   if(C<D)
   y=C;
   else
   y=D;

  int ans =x+y;
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=55;
ll dp[N][N*N]; 
int main(){
    int n,a;
    cin>>n>>a;
    int x;
    dp[0][0]=1;
    for(int i=0; i<n; i++){
        cin>>x;
        for(int j=i; j>=0; j--){
            for(int k=0; k<=N*j; k++){   
                dp[j+1][k+x]+=dp[j][k];
            }
        }
    }
    ll ans=0;
    for(int i=1; i<=n; i++){
        ans+=dp[i][i*a];
    }
    cout<<ans<<endl;
    //system("pause");
    return 0;
}

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

int isPrime(int p){
  int i;
  if(p == 2)return 1;
  if(p < 2 || p%2 == 0) return 0;
  i = 3;
  while(i <= sqrt(p) ){
    if(p % i == 0) return 0;
    i = i + 2;
  }
  return 1;
}

int main(){
  
  int a[10000], i, n, c = 0;
  
  scanf("%d",&n);
  
  for(i = 0; i < n; i++) {
    scanf("%d", &a[i]);
    if(isPrime(a[i]) == 1) c++;
  }
  
  printf("%d\n",c);

  return 0;
}

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

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn read_col<T: std::str::FromStr>(n: usize) -> Vec<T> {
    (0..n).map(|_| read()).collect()
}

fn main() {
    let md: Vec<u32> = read_vec();
    let m1 = md[0];
    let d1 = md[1];

    let mut cnt: u32 = 0;

    for m in 1..(m1 + 1) {
        for d in 1..(d1 + 1) {
            let d1 = d % 10;
            let d2 = d / 10;
            if d1 > 1 && d2 > 1 && m == d1 * d2 {
                cnt += 1;
            }
        }
    }

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


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

int main(){
    i64 a,n,m,ans=0;
    cin >>a>>n>>m;

    for(int ya=1;ya<10001;ya++){
        i64 x=1;

        for(int i=0;i<n;i++)x *= ya;

        if(x>m) break;

        int y=0; 

        while(x){
            y+=x%10;
            x=x/10;
        }

        if(y+a==ya) ans++;
    }

    cout <<ans<<endl;
    return 0;
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int a[100005];
int main(){
    int n;
    scanf("%d",&n);
    int b = 0, c= 0 ;
    for (int i = 0; i < n; i++){
        int x;
        scanf("%d",&x);
        if (a[x] == 0) b++;
        else c++;
        a[x]++;
    }
    printf("%d",b-c%2);
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n;
	cin>>x;
	int Max=x,Min=x;
	--n;
	for (;n;--n){
		cin>>x;
		Max=max(Max,x);
		Min=min(Min,x);
	}
	cout<<Max-Min;
	return 0;
}

Measured memory_bytes: 256
r, D, x_2000 = input().split(" ")
r, D, x_2000 = int(r), int(D), int(x_2000)
x = [0 for i in range(12)]
x[0] = x_2000

for k in range(11):
    x[k+1] = r*x[k] - D
    if k != 0:
        print(x[k])


Measured memory_bytes: 2940
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    string s;
    int w;
    cin >> s >> w;

    rep(i, s.size()) {
        if(i%w == 0) {
            cout << s[i];
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
// C - Slimes

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

int main(){
	int N;
	string S;

	cin >> N;
	cin >> S;

	int ans = 1;
	for (int i=1; i<N; i++) {
		if (S[i] != S[i-1]) ans++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>


using namespace std;

typedef long long ll;
typedef ll int__;
#define rep(i,j) for(int__ i=0;i<(int__)(j);i++)

bool solve(){
    int n;cin>>n;
    if(n==0)return false;
    vector<int> a(n);
    rep(i,n)cin>>a[i];
    double b;
    int r;
    double v,e,f;
    cin>>b>>r>>v>>e>>f;

    vector<double> interval_time(a[n-1]+1);
    interval_time[0]=0;
    rep(x,interval_time.size()-1){
        interval_time[x+1] = interval_time[x];
        if(x>=r)interval_time[x+1] += 1.0/(v - e * (double)(x-r));
        else interval_time[x+1] += 1.0/(v - f * (double)(r-x));
    }
    
    vector<double> DP(n);
    rep(i,n){
        DP[i]=interval_time[a[i]];
        rep(j,i){
            DP[i] = min(DP[i] , DP[j] + interval_time[a[i]-a[j]] + b);
        }
    }
    printf("%.10f\n",DP.back());
    
    return true;
}

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

Measured memory_bytes: 1324
#include <cstdio>
#include <iomanip>    // setw 控制输出间隔函数
#include <iostream>   // cin, cout, abs
#include <algorithm>  // max, min, swap, sort
#include <cmath>      // pow
#include <cstring>    // strlen
#include <set>        // set 集合
#include <stack>      // stack 栈
#include <queue>      // queue 队列
#include <string>     // string 字(yang)符(rou)串, substr
#include <map>
using namespace std;
int main()
{
    stack<char> s;
    string h;
    cin >> h;
    for( int i = 0; i < h.size(); i++)
    {
        if( h[i] == '0' || h[i] == '1') s.push(h[i]);
        else if(!s.empty()) s.pop();
    }
    string g;
    int l = 0;
    while(!s.empty())
    {
        g[l] = s.top();
        s.pop();
        l++;
    }
    for( int i = l - 1; i >= 0; i--)
        printf("%c", g[i]);
    puts("");
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int a,b,c,d;
int main()
{
 int i,xc,yc,n,r1,r21,r22,r2,r[50],xz,mx,my,cot=0;
  
 for(scanf("%d",&n);n!=0;scanf("%d",&n))
{  
 scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&xc,&yc);
 r[cot]=0;
 for(i=1;i<=n;i++)
 { scanf("%d%d",&mx,&my);
   r1=abs(mx-xc)+abs(my-yc);
   r21=hante(xc,yc)==0?0:hante(xc,yc)-1;
   r22=hante(mx,my);

   r2=r21+r22;
   r[cot]+=r1<r2?r1:r2;

  xc=mx,yc=my;
  


 }

 cot++;
}
 for(i=0;i<cot;i++)
  printf("%d\n",r[i]);




return 0;
}

int hante(int x,int y)
{
 if(x>=a && x<=c && y >=b && y<=d)return 0;
 
 if(x>=a && x<=c && y>d)return y-d;
   else if(x>=a && x<=c && y<b)return b-y;
 if(y >=b && y<=d && x>c)return x-c;
   else if(y >=b && y<=d && x<c)return a-x;
 int a1,a2;
 a1=x-c;
 a2=y-d;
  if(a1>0 && a2>0) return x-c+y-d;
    else if(a1<0 && a2>0) return abs(x-a)+y-d;
      else if(a1>0 && a2<0)return x-c+abs(y-b);
       else if(a1<0 && a2<0)return abs(x-a)+abs(y-b);

}


Measured memory_bytes: 2144
#include <iomanip>
#include <iostream>
#include <map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  map<string, int> S;
  int num = 0;
  rep(i, N) {
    string s;
    cin >> s;
    S[s]++;
    num = max(num, S[s]);
  }
  for (auto s : S) {
    if (num == s.second) cout << s.first << endl;
  }
  return 0;
}


Measured memory_bytes: 23808
from collections import deque
n, q = map(int, input().split())
tree = [[] for _ in range(n+1)]
cnt = [0] * (n+1)

for _ in range(n-1):
    a, b = map(int, input().split())
    tree[a].append(b)
    tree[b].append(a)

for _ in range(q):
    p, x = map(int, input().split())
    cnt[p] += x

queue = deque([1])
visited = {1}
while queue:
    now = queue.popleft()
    visited.add(now)
    for t in tree[now]:
        if t in visited:
            pass
        else:
            queue.append(t)
            cnt[t] += cnt[now]

print(*cnt[1:])









Measured memory_bytes: 64228
while True:
    a, op, b = map(str, input().split())
    if op == '?':
        break
    a, b = int(a), int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)


Measured memory_bytes: 5600
n = int(input())
s = input()

l = [30010] * 11
r = [-1] * 11
for i in range(n):
    c = int(s[i])
    r[c] = max(r[c], i)
    l[c] = min(l[c], i)
st = set([])
for i in range(n):
    c = int(s[i])
    for j in range(10):
        for k in range(10):
            if l[j] < i < r[k]:
                number = chr(j) + s[i] + chr(k)
                st.add(number)
print(len(st))

Measured memory_bytes: 42860