akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i,n) for(int i = 0; i < (n); ++i)
const int mod = 1e9+7;
struct mint {
    ll x;
    mint(ll x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (t == 0) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint &operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& i, mint& var) {
    ll tmp; i >> tmp;
    var.x = tmp;
    return i;
}
ostream& operator<<(ostream& o, const mint& var) {
    o << var.x;
    return o;
}
vector<mint> fac;
mint ncr(int n, int r) {
    if (fac.empty()) {
        int MAX_N = 2e6+10;
        fac.assign(MAX_N,1);
        for (int i = 0; i < MAX_N; ++i) {
            fac[i+1] = fac[i] * mint(i+1);
        }
    }
    return fac[n] / fac[n-r] / fac[r];
}

ll N, A, B, C;
mint ans;

void input() {
    cin >> N >> A >> B >> C;
}

void solve() {
    ans = mint(0);
    mint pa = mint(A) / mint(A+B);
    mint pb = mint(B) / mint(A+B);
    rep(i,N) {
        mint ans1 = pa.pow(N) * pb.pow(i);
        mint ans2 = pa.pow(i) * pb.pow(N);
        ans += ncr(N+i-1,N-1) * (ans1 + ans2) * mint(N+i);
    }
    ans *= mint(100);
    ans /= mint(A+B);
}

void output() {
    cout << ans << endl;
}

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


Measured memory_bytes: 15872
#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  rep(i, n)    for(int (i)=0; (i)<(n);  (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 T1, class T2> inline void minup(T1& m, T2 x){ if(m>x) m=static_cast<T2>(x); }
template<class T1, class T2> inline void maxup(T1& m, T2 x){ if(m<x) m=static_cast<T2>(x); }

#define INF 1000000000
#define MOD 1000000009
#define EPS 1E-9

ll gcd(ll a, ll b)
{
  ll tmp;

  while(b){
    tmp = a;
    a = b;
    b = tmp%b;
  }

  return a;
}

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

ll a, b;

int main()
{
  while(cin >> a >> b){
    cout << gcd(a, b) << " " << lcm(a, b) << endl;
  }

  return 0;
}

Measured memory_bytes: 1156
// practice with kaiboy
import java.io.*;
import java.util.*;

public class Main extends PrintWriter {
	Main() { super(System.out, true); }
	Scanner sc = new Scanner(System.in);
	public static void main(String[] $) {
		Main o = new Main(); o.main(); o.flush();
	}

	static class V {
		int i, j;
		V(int i, int j) {
			this.i = i; this.j = j;
		}
	}
	void main() {
		int n = sc.nextInt();
		int m = sc.nextInt();
		int k = sc.nextInt();
		int k_ = k * 9;
		V[] vv = new V[k_];
		k_ = 0;
		while (k-- > 0) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			for (int i = a - 2; i <= a; i++)
				for (int j = b - 2; j <= b; j++)
					if (i >= 1 && j >= 1 && i + 2 <= n && j + 2 <= m)
						vv[k_++] = new V(i, j);
		}
		Arrays.sort(vv, 0, k_, (u, v) -> u.i != v.i ? u.i - v.i : u.j - v.j);
		int[] kk = new int[10];
		for (int u = 0, v; u < k_; u = v) {
			int i = vv[u].i, j = vv[u].j;
			v = u + 1;
			while (v < k_ && vv[v].i == i && vv[v].j == j)
				v++;
			kk[v - u]++;
		}
		long z = (long) (n - 2) * (m - 2);
		for (int h = 1; h < 10; h++)
			z -= kk[h];
		println(z);
		for (int h = 1; h < 10; h++)
			println(kk[h]);
	}
}


Measured memory_bytes: 87468
/**
 *    author:  morato
 *    created: 25.08.2020 20:06:44
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  int f = 1;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    if (x % 2 == 0) {
      f &= (x % 3 == 0 || x % 5 == 0);
    }
  }
  cout << (f ? "APPROVED\n" : "DENIED\n");
  return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int n;
	scanf("%d", &n);
	vector<int> a(9);
	for (int i = 0; i < n; i++) {
		int p;
		scanf("%d", &p);
		a[min(p / 400, 8)]++;
	}
	int cnt = 0;
	for (int i = 0; i < 8; i++) {
		if (a[i]) cnt++;
	}
	if (cnt == 0) {
		printf("%d %d\n", 1, a[8]);
	} else {
		printf("%d %d\n", cnt, cnt + a[8]);
	}
	return 0;
}

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

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  int n; cin >> n;
  cout << n * 180 - 360 << endl;
  
}


Measured memory_bytes: 256
#include<iostream>
    using namespace std;
    int main(){
      int a;
      cin>>a;
      char c[a];
      for(int i=0; i<a; i++)
      cin>>c[i];

      int b;
      cin>>b;
      char s=c[b-1];
      for(int i=0; i<a; i++){ 
       if(c[i]!=s){
          c[i]='*';
          cout<<c[i];}
        else
          cout<<c[i];
      }
      cout<<endl; 
    }


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }




int main() {
    int a,b,c,d,e,f; cin >> a >> b >> c >> d >> e >> f;
    // 全ての容量がiグラムの時に溶けてる砂糖のグラム数が記録されるdp
    // そのグラムが作れないときは-1が入ってる
    vector<int> dp(f+1,-1);
    for(int i=a*100; i<f+1; i++) {
        int tmp = -1;
        // 最低でも水が作れる
        if(i%(a*100) == 0) chmax(tmp, 0);
        if(i%(b*100) == 0) chmax(tmp, 0);
        // 4つの操作を行う
        if(i-(a*100) >= 0) chmax(tmp, dp[i-(a*100)]);
        if(i-(b*100) >= 0) chmax(tmp, dp[i-(b*100)]);
        if(i-c >= 0) {
            if(dp[i-c] >= 0) {
                int all_sugar = dp[i-c] + c;
                int all_water = i - all_sugar;
                // 砂糖が溶ける時だけ加算
                if(all_sugar <= e*all_water/100) {
                    chmax(tmp, all_sugar);
                }
            }
        }
        if(i-d >= 0) {
            if(dp[i-d] >= 0) {
                int all_sugar = dp[i-d] + d;
                int all_water = i - all_sugar;
                // 砂糖が溶ける時だけ加算
                if(all_sugar <= e*all_water/100) {
                    chmax(tmp, all_sugar);
                }
            }
        }
        dp[i] = tmp;
        //cout << tmp << endl;
    }
    int ans1 = 0;
    int ans2 = a*100;
    for(int i=a*100; i<f+1; i++) {
        double x = (100*ans1)/((ans1+ans2)*1.0);
        double y = (100*dp[i])/((dp[i]+i)*1.0);
        if(y >= x) {
            ans1 = dp[i];
            ans2 = i;
        }
    }
    cout << ans2 << endl;
    cout << ans1 << endl;
    return 0;
}


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

using namespace std;

int main() {
	int N, M;
	cin >> N >> M;
	vector < pair<long long, int>>V;
	long long ans;
	for (int i = 0; i < N; i++)
	{
		int A;
		cin >> A;
		V.push_back({ A,1 });
	}
	for (int i = 0; i < M; i++)
	{
		int B, C;
		cin >> B >> C;
		V.push_back({ C,B });
	}
	sort(V.rbegin(), V.rend());
	for (int i = 0; i < V.size(); i++)
	{
		long long C = min(V[i].second, N);
		N -= C;
		ans += C*V[i].first;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<ll, ll>;
// Welcome to my source code!

int main() {
    int sum = 0;
    for (int i = 0, s; i < 5; i++) {
        cin >> s;
        s = max(s, 40);
        sum += s;
    }
    cout << sum / 5 << endl;
}


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

int main(int argc, char *argv[])
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    string str;
    cin >> str;

    using ll = long long;
    ll result = 0;
    int blacks = 0;
    int white = 0;
    for(int i = 0; i < str.size(); ++i) {
        char ch = str[i];
        if(ch == 'B') blacks++;
        else {
            result += blacks;
            swap(str[i], str[white]);
            white++;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 720
def f(x,n):
	if x == 1: return [n];
	if x % 2 == 1:
		return f(x >> 1,n + 1) + [n]
	else:
		return [n] + f(x - 1,n + 1)

def g(x,n):
	if x == 1: return [n];
	if x % 2 == 1:
		return g(x >> 1,n + 1) + [n]
	else:
		return g(x - 1,n + 1) + [n]

n = input()
p = f(n,1) + g(n,1)
print len(p)
print ' '.join(list(map(str,p)))



Measured memory_bytes: 2568
N = int(input())
xy = [list(map(int, input().split())) for i in range(N - 1)]

MOD = 10 ** 9 + 7

class Tree:
  C, RL = {}, {}
  R, N, D = None, None, None
  def __init__(s, num):
    s.N = num
  def setC(s, a, b):
    if a in s.C: s.C[a].append(b)
    else: s.C[a] = [b]
    if b in s.C: s.C[b].append(a)
    else: s.C[b] = [a]
  def makeRank(s, root = 0):
    s.R = [0] * s.N
    s.R[root] = 1
    s.RL[1] = [root]
    F = [root]
    s.D = 2
    while F != []:
      Ft = []
      s.RL[s.D] = []
      for i in F:
        for j in s.C[i]:
          if s.R[j] == 0:
            s.R[j] = s.D
            Ft.append(j)
            s.RL[s.D].append(j)
      s.D += 1
      F = Ft
  def nasu(s, x = 0):
    DP = [[1] * 2 for _ in range(s.N)]
    for d in range(s.D - 2, 0, -1):
      for i in s.RL[d]:
        L = []
        for j in s.C[i]:
          if s.R[j] > s.R[i]:
            L.append(j)
        b = 1
        w = 1
        for k in L:
          b = b * DP[k][0] % MOD
          w = w * (DP[k][0] + DP[k][1]) % MOD
        DP[i] = [w, b]
    return (DP[x][0] + DP[x][1]) % MOD

T = Tree(N)
if N == 1:
  print(2)
  exit()
for x, y in xy:
  x -= 1
  y -= 1
  T.setC(x, y)

T.makeRank()

print(T.nasu())

Measured memory_bytes: 120152
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int x,y;cin>>x>>y;
  int a,b;
  if((y-2*x)%2==0){
    b=(y-2*x)/2;
    if(b<0){
      cout<<yesno(false)<<endl;
      return 0;
    }
    if(x-b<0){
      cout<<yesno(false)<<endl;
      return 0;
    }
  }else{
    cout<<yesno(false)<<endl;
    return 0;
  }
  cout<<yesno(true)<<endl;
  return 0;
}


Measured memory_bytes: 3628
def half_and_half(
        A: int, B: int, C: int, X: int, Y: int) -> int:
    """
    :param A: A ピザの値段
    :param B: B ピザの値段
    :param C: AB ピザの値段
    :param X: A ピザの必要数
    :param Y: B ピザの必要数
    """
    min_price = float('inf')
    for num_ab in range(max(X, Y)+1):
        num_a, num_b = max(0, X-num_ab), max(0, Y-num_ab)
        price = num_a*A + num_b*B + 2*num_ab*C
        min_price = min(min_price, price)

    return min_price


if __name__ == "__main__":
    A, B, C, X, Y = map(int, input().split())
    ans = half_and_half(A, B, C, X, Y)
    print(ans)


Measured memory_bytes: 3188
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    double a, b;

    AtCoder(FastScanner sc) {
        a = sc.nextDouble();
        b = sc.nextDouble();
    }

    void solve(PrintWriter out) {
        out.println((int) Math.ceil((a + b) / 2));
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21460
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;


typedef long long i64;
const int inf = (int)1.05e9;


int main()
{
	int a, b;

	scanf("%d%d", &a, &b);

	vector<vector<bool>> ans;

	ans.resize(2 * 10 * 2);
	for(auto& a : ans)
		a.resize(2 * 50);

	for(int i = 0; i < 2 * 10; ++i) {
		for(int j = 0; j < 2 * 50; ++j) {
			ans[i][j] = true;
			ans[i + 2 * 10][j] = false;
		}
	}

	int a_rem = a - 1;
	int b_rem = b - 1;

	for(int i = 0; i < 10; ++i) {
		for(int j = 0; j < 50; ++j) {

			if(a_rem > 0) {
				a_rem -= 1;
				ans[i * 2][j * 2] = false;
			}

			if(b_rem > 0) {
				b_rem -= 1;
				ans[i * 2 + 2 * 10 + 1][j * 2] = true;
			}
		}
	}

	printf("%d %d\n", 2 * 10 * 2, 2 * 50);

	for(int i = 0; i < 2 * 10 * 2; ++i) {
		for(int j = 0; j < 2 * 50; ++j) {
			printf("%c", ans[i][j] ? '#' : '.');
		}
		printf("\n");
	}

	return 0;
}

/* waffle */


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int N=3e3+5;
ll r,c,k,x,y,z,g[N][N],dp[N][N][4];
int main()
{
    cin>>r>>c>>k;
    while(k--){
        cin>>x>>y>>z;
        g[x][y]=z;
    }
    for(int i=1;i<=r;i++){
        for(int j=1;j<=c;j++){
            for(int k=1;k<=3;k++){
                dp[i][j][k]=max(dp[i-1][j][3]+g[i][j],max(dp[i][j-1][k-1]+g[i][j],dp[i][j-1][k]));
            }
        }
    }
    cout<<dp[r][c][3];
}


Measured memory_bytes: 355712
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;;
const int maxn = 2e5 + 5;
const int mod = 998244353;

int n , p[maxn];
ii a[maxn];
int res = 0 , oy[maxn];

int bit[maxn];

void update(int x){
	for( ; x <= n ; x += x & -x)bit[x]++;
}

int query(int x){
	int res = 0;
	for( ; x > 0 ; x &= x - 1)res += bit[x];
	return res;
}

void add(int & x , ll y){
	if(y >= mod)y %= mod;
	x += y;if(x >= mod)x -= mod;
	if(x < 0)x += mod;
}

void Solve(){
	sort(a + 1 , a + n + 1);
	for(int i = 1 ; i <= n ; ++i){
		oy[i] = a[i].second;
	}
	sort(oy + 1 , oy + n + 1);
	for(int i = 1 ; i <= n ; ++i){
		int y = lower_bound(oy + 1 , oy + n + 1 , a[i].second) - oy;
		add(res , p[query(y)]);
		add(res , p[i - query(y) - 1]);
		add(res , -p[i]);
		add(res , -p[n - i + 1]);
		update(y);
	}
	fill_n(bit,maxn,0);
	for(int i = n ; i >= 1 ; --i){
		int y = (lower_bound(oy + 1 , oy + n + 1 , a[i].second) - oy);
		add(res , p[query(y)]);
		add(res , p[n - i - query(y)]);
		update(y);
	}
	fill_n(bit,maxn,0);
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);	
	cin >> n;
	p[0] = 1;for(int i = 1 ; i <= n ; ++i)p[i] = p[i - 1] * 2 % mod;
	for(int i = 1 ; i <= n ; ++i){
		cin >> a[i].first >> a[i].second;
	}
	add(res , (ll)n * p[n]);
	add(res , -n);
	Solve();
	cout << res;
}


Measured memory_bytes: 4224
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
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; }

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

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
#include<vector>

class FenwickTree {
    std::vector<long long> data;
    int MAXN;

public: long long sum(int r) {
      long long s = 0;
      while (r > 0) {
        s += data[r-1];
        r -= r & -r;
      }
      return s;
    }

public: long long sum(int l, int r) {
      return sum(r) - sum(l);
    }

    FenwickTree(int n) {
      MAXN = n;
      data.resize(n);
    }

public: void add(int p, long long x) {
      p++;
      while (p <= MAXN) {
        data[p-1] += x;
        p += p & -p;
      }
    }

public: void reset() {
      for(int i=0; i<MAXN; i++) {
        data[i] = 0;
      }
    }

    // TODO: This function is experimental and not verified.
    // return the smallest i where sum(i) >= val
    // If sum(MAXN) < val, return MAXN
    // This function can only be called if all the data is positive or zero.
public: int lower_bound(const long long val) {
      long long now = 0;
      int ret = -1;
      int cnt = 1;
      for(int k=0; k<30; k++) {
        if (cnt*2 > MAXN) break;
        cnt *= 2;
      }
      while(cnt) {
        if (ret+cnt < MAXN && now+data[ret+cnt] < val) {
          now += data[ret+cnt];
          ret += cnt;
        }
        cnt /= 2;
      }
      return ret+1;
    }
};


class BFenwickTree {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, q; cin >> n >> q;
      auto ft = FenwickTree(n);
      rep(i, n) {
        int a; cin >> a;
        ft.add(i, a);
      }

      while(q--) {
        int kind; cin >> kind;
        if (kind == 0) {
          int p, x; cin >> p >> x;
          ft.add(p, x);
        } else {
          int l, r; cin >> l >> r;
          cout << ft.sum(l, r) << '\n';
        }
      }
    }
};

signed main() {
  BFenwickTree solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 8256
/*
　　　　　／＞　 フ
　　　　　| 　_　 _|
　 　　　／`ミ _x 彡
　　 　 /　　　 　 |
　　　 /　  ヽ　　 ?
　／￣|　　 |　|　|
　| (￣ヽ＿_ヽ_)_)
　＼二つ
 */

#include <queue>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define MP make_pair
#define ll long long
#define fi first
#define se second
using namespace std;

template <typename T>
void read(T &x) {
    x = 0; bool f = 0;
    char c = getchar();
    for (;!isdigit(c);c=getchar()) if (c=='-') f=1;
    for (;isdigit(c);c=getchar()) x=x*10+(c^48);
    if (f) x=-x;
}

template<typename F>
inline void write(F x, char ed = '\n') {
	static short st[30];short tp=0;
	if(x<0) putchar('-'),x=-x;
	do st[++tp]=x%10,x/=10; while(x);
	while(tp) putchar('0'|st[tp--]);
	putchar(ed);
}

template <typename T>
inline void Mx(T &x, T y) { x < y && (x = y); }

template <typename T>
inline void Mn(T &x, T y) { x > y && (x = y); }

const int N = 200050;
const int P = 1e9 + 7;
struct node {
	int x, y, w;
	bool operator < (const node &i) const {
		return w < i.w;
	}
}ed[N];

int ne[N<<1], to[N<<1], w[N<<1], val[N], fa[N], f[N], h[N], dep[N], tot; 
inline void add(int x, int y, int z) {
	ne[++tot] = h[x], to[h[x] = tot] = y, w[tot] = z;
}

void dfs(int x, int fat) {
	dep[x] = dep[fat] + 1;
	for (int i = h[x]; i; i = ne[i]) {
		int y = to[i]; if (y == fat) continue;
		val[y] = w[i], fa[y] = x, dfs(y, x);
	}
}

ll fpw(ll x, ll mi) {
	ll res = 1;
	for (; mi; mi >>= 1, x = x * x % P)
		if (mi & 1) res = res * x % P;
	return res;
}

int vis[N], cnt, cc, m, n;
ll res[N], sum, S;
int find(int x) { return f[x] == x ? x : f[x] = find(f[x]); }

int get(int x, int y) {
	int res = 0;
	while (x != y) {
		if (dep[x] < dep[y]) swap(x, y);
		Mx(res, val[x]), x = fa[x];
	}
	return res;
}

int main() {
	read(n), read(m), read(S);
	for (int i = 1;i <= m; i++) read(ed[i].x), read(ed[i].y), read(ed[i].w);
	sort(ed + 1, ed + m + 1);
	for (int i = 1;i <= n; i++) f[i] = i;
	for (int i = 1;i <= m; i++) {
		int x = find(ed[i].x), y = find(ed[i].y);
		if (x == y) continue; f[x] = y, sum += ed[i].w, vis[i] = 1, cnt++;
		add(ed[i].x, ed[i].y, ed[i].w), add(ed[i].y, ed[i].x, ed[i].w);
	}
	dfs(1, 0); ll ans = 1;
	if (sum > S || cnt < n - 1) return puts("0"), 0;
	cnt = 0;
	for (int i = 1;i <= m; i++) {
		if (vis[i]) continue;
		ll t = ed[i].w - get(ed[i].x, ed[i].y);
		res[++cnt] = t;
	}
	sort(res + 1, res + cnt + 1);
	int fl = 0;
	for (int i = 1;i <= cnt; i++) {
		if (res[i] + sum < S) continue;
		if (res[i] + sum > S) {
			ans = ans * (fpw(2, cc) - 1) % P * fpw(2, cnt - i + 1) % P;
//			ans = ans * fpw(2, cnt - i + 1) % P;
			cc = 0; break;
		}
		cc++, fl = 1;
	}
	if (cc) ans = ans * (fpw(2, cc) - 1) % P;
	ans = 2 * ans % P;
	if (!fl) ans = 0;
	if (sum == S) ans = (ans + (fpw(2, n - 1) - 2) * fpw(2, cnt)) % P;
	write((ans + P) % P);
	return 0;
}

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

#define ll long long
#define vec vector<ll>
#define sortv(a); sort(a.begin(), a.end());
#define rev(a); reverse(a.begin(), a.end());
#define FOR(i,a,b) for (ll i = (ll)(a); i < (b); i++)
#define ROF(i,a,b) for (ll i = (ll)(b)-1; i >= (a); i--)

ll MOD = 1000000007;
ll INF = 1LL << 60;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	int n,m;cin>>n>>m;
	vec a(n);
	FOR(i,0,n) cin>>a[i];
	sortv(a);
	ll sum=0;
	FOR(i,0,n) sum+=a[i];
	if (4*m*a[n-m]<sum) {
		cout<<"No";
	} else {
		cout<<"Yes";
	}
}

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

using namespace std;
constexpr int INF = 1000000000;

int main() {
  while (true) {
    int n;
    cin>>n;
    if(!n) break;
    vector<int> p(n);
    for(auto& v:p) cin>>v;
    vector<vector<pair<int, int>>> dp(n+1,vector<pair<int, int>>(50000, make_pair(-INF, -INF)));
    dp[0][0] = make_pair(0,0);
    REP(i,n) {
      REP(j,50000) {
        dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        int ex = (1000 - p[i] % 1000) % 1000;
        if (ex < 500) {
          if (j + ex < 50000) {
            dp[i+1][j+ex] = max(dp[i+1][j+ex], make_pair(dp[i][j].first, dp[i][j].second - p[i]));
          }
          if (j + ex >= 500) {
            dp[i+1][j+ex-500] = max(dp[i+1][j+ex-500], make_pair(dp[i][j].first+1, dp[i][j].second - p[i]));
          }
        } else {
          dp[i+1][j+ex-500] = max(dp[i+1][j+ex-500], make_pair(dp[i][j].first+1, dp[i][j].second - p[i]));
        }
      }
    }
    pair<int, int> res(0, 0);
    REP(i,50000) res = max(res, dp[n][i]);
    cout << res.first << ' ' << -res.second << endl;
  }
  return 0;
}

Measured memory_bytes: 42804
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000001
using namespace std;

int N;
int* BIT;

void add(int loc,int value){

	BIT[loc] += value;

	loc += loc & -loc;

	while(loc <= N){
		BIT[loc] += value;
		loc += loc & -loc;
	}
}

int getSum(int loc){

	int sum = BIT[loc];

	loc -= loc & -loc;

	while(loc > 0){
		sum += BIT[loc];
		loc -= loc & -loc;
	}
	return sum;
}

int calc(int left,int right){
	return getSum(right)-getSum(left-1);
}

int main(){

	int Q,command,left,right;
	scanf("%d %d",&N,&Q);

	BIT = new int[N+1];
	for(int i = 0; i <= N; i++)BIT[i] = 0;

	for(int i = 0; i < Q; i++){

		scanf("%d %d %d",&command,&left,&right);

		if(command == 0){
			add(left,right);
		}else{
			printf("%d\n",calc(left,right));
		}
	}

	return 0;
}


Measured memory_bytes: 3148
<?php

while(1){

	list($m,$f,$r)=explode(" ",trim(fgets(STDIN)));

	// ?????????-1?????¨?????????
	if($m==-1 && $f==-1 && $r==-1){

		break;
	}

	// printf("%d%d%d\n",$m,$f,$r);

	printf("%s\n",JudgeMent($m,$f,$r));


}

function JudgeMent($m,$f,$r){

	if($m==-1 || $f==-1){

		return "F";
	}elseif($m+$f>=80){

		return "A";
	}elseif ($m+$f>=65) {

		return "B";
		# code...
	}elseif ($m+$f>=50){

		return "C";
	}elseif ($m+$f>=30 & $r>=50){

		return "C";

	}elseif ($m+$f>=30 & $r<50){

		return "D";

	}else{

		return "F";
	}

}

Measured memory_bytes: 15376
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main(){

	long long l,r; cin >> l >> r;
	long long mind = 2018;
	if(r - l > 2019){
		cout << 0 << endl;
		return 0;
	}

	for(long long i = l % 2019 ; i < r % 2019; i++){
		for(long long j = i + 1; j <= r % 2019; j++){
			mind = min(((i*j)%2019) , mind);
			if(mind == 0) break;
		}

	}
	cout << mind << endl;
	
	//cout << (((l <= 2019  && r > 2019)|| l == 0 ) ? 0 : (l*(l+1))%2019 )<< endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		sc.close();

		if ((x + y) % 3 != 0) {
			System.out.println(0);
			return;
		}

		int z = (x + y) / 3;
		for (int i = 0; i <= z; i++) {
			int j = z - i;
			if (i + 2 * j == x && 2 * i + j == y) {
				System.out.println(nCr(z, i));
				return;
			}
		}
		System.out.println(0);
	}

	static long nCr(long n, long r) {
		long m = 1000000007;
		long val = 1;
		for (int i = 1; i <= r; i++) {
			val = val * (n - i + 1) % m;
			val = val * modinv(i, m) % m;
		}
		return val;
	}

	static long modinv(long a, long m) {
		long b = m;
		long u = 1;
		long v = 0;
		long tmp = 0;

		while (b > 0) {
			long t = a / b;
			a -= t * b;
			tmp = a;
			a = b;
			b = tmp;

			u -= t * v;
			tmp = u;
			u = v;
			v = tmp;
		}

		u %= m;
		if (u < 0) u += m;
		return u;
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

// modint: mod 計算を int を扱うように扱える構造体
template<int MOD> struct Fp {
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) v += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr istream& operator >> (istream &is, Fp<MOD>& x) noexcept {
        return is >> x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};

const int MOD = 1000000007;
using mint = Fp<MOD>;
const int INF = 1<<30;

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

mint one[61],zero[61];

bool func(ll x, int d){
  if(x & (1LL << d)) return true;
  else return false;
}

int main(){
  int n; cin >> n;
  rep(i,n){
    ll tmp; cin >> tmp;
    rep(d,61){
      if(func(tmp,d)) one[d] = one[d] + 1;
      else zero[d] = zero[d] + 1;
    }
  }
  
  mint ans = 0;
  rep(i,61){
    ans += (one[i] * zero[i]) * (1LL << i); 
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int64_t N,K,Z=0,Q=1000000007;
  cin>>N>>K;
  for(int i=K;i<=N+1;i++){
    Z=(Z+i*(N+1-i)+1)%Q;
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
    string buf_s,min="\0";
    int buf_i,min_a,old_a;
    bool f,f1;
    vector <string> s;
    vector <int> a;
    vector <bool> pr;
    while(cin>>buf_s>>buf_i){
    //    cout<<buf_s<<buf_i<<endl;
        s.push_back(buf_s);
        a.push_back(buf_i);
        pr.push_back(0);
    }
    for(int lop=0; lop<s.size();){
        f=1;
        for(int i=0; i<s.size(); i++){
            if((min>s[i]||f)&&!pr[i]){
                min=s[i];
                f=0;
            }
        }
        cout<<min<<endl;
        f=1;
        while (1) {
            f1=1;
            min_a=0;
            for(int i=0; i<s.size(); i++){
                if(s[i]==min){
                    if((a[min_a]>a[i]||f1)&&(pr[i]==0)){
                        min_a=i;
                        f1=0;
                    }
                }
            }
            if(f1)
                break;
            else{
                if(f){
                    cout<<a[min_a];
                    f=0;
                }
                else
                    cout<<" "<<a[min_a];
                pr[min_a]=1;
                lop++;
            }
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vi = vector<int>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vi l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];

    vi c(n+1);
    c[0] = 0;
    rep(i, n) {
        c[i+1] = c[i];
        if (i > 0) {
            c[i+1] += (s[i] == 'C' && s[i-1] == 'A');
        }
    }

    rep(i, q) {
        cout << c[r[i]] - c[l[i]] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
// ConsoleApplication106.cpp : 此文件包含 "main" 函数。程序执行将在此处开始并结束。
//
#include <iostream>
#include<fstream>
#include<cstring>
#include<algorithm>
#include<iomanip>
#include<set>
#include<map>
#include<vector>
#include<cmath>
using namespace std;
typedef long long ll;

int main()
{
	int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int n;
	cin >> n;
	cout << a[n - 1] << endl;





}


Measured memory_bytes: 256
import sys
N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[A[0]]
for i in range (N-1): #何回やるとどこに行くかのリストを作る
  B.append(A[B[-1]-1])
#print(B)
if N>=K:
  print(B[K-1])
else:
  #最後と同じやつを探す
  id=B.index(B[-1]) #最後と同じ数字
  #print('id:',id) 
  T = N-id-1 #周期
  new_L=B[id+1:N]#周期のみのリスト
  #print(new_L)
  mod = (K-N) % T
  #print(mod)
  print(new_L[mod-1])

#for i in range (K-1):
#  B = A[B-1]
#print(B)

#L=[]
#for id, x in enumerate(A):
#  L.append([id+1,x])
#print(L)
#B=L[0][1]
#for i in range (N):
#  B = L[B-1][1]

Measured memory_bytes: 32380
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	ll ans = 1;
	vector<int> num(100100, 0);
	num[0] = 3;
	rep(i, 0, n - 1)
	{
		int a; cin >> a;
		ans *= num[a];
		ans %= 1000000007;
		--num[a];
		++num[a + 1];
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
int main() {
  int n, x;
  while (scanf("%d %d", &n, &x) && !(n == 0 && x == 0)) {
    int count = 0;
    int avemin = 1;
    int avemax = (x - (x%3))/3 - 1;
    avemax = avemax < n-3 ? n-3 : avemax;
    for (int ave = avemin; ave <= avemax; ave++) {
      int lmin = 2;
      int lmax = n - ave;
      for (int l = lmin; l <= lmax; l++) {
        for (int s = 1; s < l; s++) {
          if ((ave * 3 + s + l) == x) count++;
        }
      }
    }
      printf("%d\n", count);
  }
  return 0;
}



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

using namespace std;

void solveA()
{
    int x;
    cin >> x;
    if (x == 7|| x == 5|| x == 3)
        cout << "YES\n";
    else
        cout << "NO\n";
}

void solveB()
{
    int a, b, c;
    cin >> a >> b >> c;

    int hp = max(a, b);
    hp = max(hp, c);

    int area;

    if (a == hp)
        area = (b * c) / 2;
    if (b == hp)
        area = (a * c) / 2;
    if (c == hp)
        area = (a * b) / 2;

    cout << area;
}

void solveC()
{
    int a, b;
    cin >> a >> b;
    if ((a*b) % 2 == 0)
        cout << "No\n";
    else
        cout << "Yes\n";
}

void solveD()
{
    int n, s=0, cp;

    cin >> n;
    cp = n;

    while (cp){
        s += cp%10;
        cp /= 10;
    }
    if (n % s == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

void solveE()
{
    int n, t;

    cin >> n >> t;

    int rotas[n][2];

    int coast = INT_MAX;

    for (int i = 0; i < n; i++){

        cin >> rotas[i][0] >> rotas[i][1];

        if (rotas[i][1] < t){
            coast = min(coast, rotas[i][0]);
        }
    }
    if (coast == INT_MAX)
        cout << "TLE\n";
    else
        cout << coast << "\n";
}

void solveF()
{
    int k;
    cin >> k;
    int par = 0, impar = 0;
    for (int i = 1; i <= k ; i++){
        if (i % 2 == 0)
            par++;
        else
            impar++;
    }
    cout << par * impar << endl;
}

int main(int qtd, char* nome[])
{
    ios::sync_with_stdio(false);

    solveA();

    return 0;
}


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

using namespace std;

int main() {
    int n;
    auto gret = [](const int a, const int b) {
        return (a > b) ? a : b;
    };
    auto less = [](const int a, const int b) {
        return (a < b) ? a : b;
    };

    cin >> n;
    vector<int> R(n);
    for(int i = 0; i < n; i++)
        cin >> R[i];
    
    // ある時刻tについて、時刻0からtにおける価格の最小値をless[t]、利益の最大値をgreat[t]とすると、
    // great[t] = max(great[t-1], R[t]-less[t-1])
    //   ただし、less[0] = R[0], great[0] <= great[1] = R[1] - R[0]とする
    int min = R[0], max = R[1]-R[0];
    for(int t = 1; t < n; t++) {
        max = gret(max, R[t]-min);
        min = less(min, R[t]);
    }

    cout << max << endl;

    return 0;
}


Measured memory_bytes: 3536
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)


int main()
{
  int n;
  cin>>n;
  map<int,int> a;
  int maxi=0,mixi=100000;
  rep(i,n)
  {
    int s;
    cin>>s;
    maxi=max(s,maxi),mixi=min(s,mixi);
    //まだ無かったらmapに追加
    if(a.find(s)==a.end()) a[s]=1;
    //すでにmapにあったら増やす
    else a[s]++;
  }

  //mapには入力された数のそれぞれの個数が格納されている
  //あるxを設定し，それにすることができる数を数える
  int ans=0;
  for(int i=mixi;i<=maxi;i++)
  {
    int tmp;
    if(i==mixi)
    {
      tmp=a[i]+a[i+1];
      ans=max(tmp,ans);
    }
    else if(i==maxi)
    {
      tmp=a[i]+a[i-1];
      ans=max(tmp,ans);
    }
    else
    {
      tmp=a[i-1]+a[i]+a[i+1];
      ans=max(ans,tmp);
    }
  }
  cout<<ans<<endl;

}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
        // TODO ?????????????????????????????????????????????
        
        boolean first=true;
        try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
            String line;
            int i=0,n=0,m=0,l=0;
            int[][] a=null,b=null;
            while ((line = br.readLine()) != null) {
            	String[] str=line.split(" ");
            	if(first){
            		n=Integer.parseInt(str[0]);
            		m=Integer.parseInt(str[1]);
            		l=Integer.parseInt(str[2]);
            		a=new int[n][m];
            		b=new int[m][l];
            		i=0;
            		first=false;
            	}else{
            		if(i<n){
            			for(int j=0;j<str.length;j++){
            				a[i][j]=Integer.parseInt(str[j]);
            			}
            		}else{
            			for(int j=0;j<str.length;j++){
            				b[i-n][j]=Integer.parseInt(str[j]);
            			}
            		}
            		i++;
            		if(i==n+m){
            			String[] s=new String[l];
            			for(int j=0;j<n;j++){
            				for(int k=0;k<l;k++){
            					long sum=0;
                				for(int o=0;o<m;o++){
                					sum+=(a[j][o]*b[o][k]);
                				}
                				
                				s[k]=String.valueOf(sum);
                			}
            				System.out.println(String.join(" ", s));
            			}
            			break;
            		}
            	}
            }
        }
    }

}

Measured memory_bytes: 33404
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

#define in(h, w) 0<=h&&h<H&&0<=w&&w<W

int dh[4] = {1, 0, -1, 0};
int dw[4] = {0, 1, 0, -1};

int main(){
    int W, H;
    while (cin >> W >> H and W and H) {
        int h, w;
        vector< vector<char> > map(H, vector<char>(W));
        for (int i = 0; i < H; i++)
            for (int j = 0; j < W; j++) {
                cin >> map[i][j];
                if (map[i][j] == '@') {
                    h = i;
                    w = j;
                }
            }
        int res = 1;
        queue<pair<int, int> > q;
        q.push(make_pair(h, w));
        while (!q.empty()) {
            h = q.front().first;
            w = q.front().second;
            q.pop();
            if (map[h][w] == '.') {
                res++;
                map[h][w] = '#';
            }
            for (int i = 0; i < 4; i++) {
                int th = h+dh[i];
                int tw = w+dw[i];
                if (0<=th&&th<H&&0<=tw&&tw<W) {
                    if (map[th][tw] == '.')
                        q.push(make_pair(th, tw));
                }
            }
        }
        cout << res << endl;
    }
}

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

using namespace std;

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

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

ll dp[55][55][2505]={};

int main(void) {
  int i,j,k;
  int n,a;
  cin>>n>>a;
  dp[0][0][0]=1;
  rep(i,n){
    int x;
    cin>>x;
    rep(j,55)rep(k,2505)if(dp[i][j][k]>0){
      dp[i+1][j][k]+=dp[i][j][k];
      dp[i+1][j+1][k+x]+=dp[i][j][k];
    }
  }
  ll ans=0;
  loop(j,1,55)loop(k,1,2505)if(j*a==k)ans+=dp[n][j][k];
  cout<<ans<<endl;
}


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

int main() {
  int n,k,x,y;
  cin >> n >> k >> x >> y;
  
  if(n <= k) cout << n*x << endl;
  else cout << k*x + (n-k)*y << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    // Your code here!
    string c1,c2;
    cin >> c1;
    cin >> c2;
    if(c1[0] == c2[2] && c1[2] == c2[0] && c1[1] == c2[1]){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<algorithm>
int main(){
int a;
  int b;
  scanf("%d",&a );
  scanf("%d",&b);
  int m=(a+b>a-b)?((a+b>a*b)?a+b:a*b):((a-b>a*b)?a-b:a*b);
  printf("%d",m);
  return 0;
}

Measured memory_bytes: 256
/*
START BY THE NAME OF ALMIGHTY ALLAH
THIS WONT BE ACCEPTED
STOP_GIVING_UP

██╗███████╗████████╗██╗ █████╗ ██╗  ██╗
██║██╔════╝╚══██╔══╝██║██╔══██╗██║ ██╔╝
██║███████╗   ██║   ██║███████║█████╔╝
██║╚════██║   ██║   ██║██╔══██║██╔═██╗
██║███████║   ██║   ██║██║  ██║██║  ██╗
╚═╝╚══════╝   ╚═╝   ╚═╝╚═╝  ╚═╝╚═╝  ╚═╝




*/
#include<bits/stdc++.h>
#define l(i,a,n)for(int i=a;i<n;i++)
#define pb push_back
#define in insert
#define mp make_pair
#define lw(v) sort(v.begin(),v.end());
#define hi(v) sort(v.begin(),v.end(),greater<long long>());
#define all(v) v.begin(),v.end()
#define filein freopen ("input.txt", "r", stdin)
#define fileout freopen ("output.txt", "w", stdout)
using namespace std;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long t,r=1,r1=0,r2=0,k=0,a,b,c=1,m,d=100,n,e,f=0,x=0,g,p=0,q=0,y=0,z=0;

    vector<pair<long long,long long>>v;
    vector<long long>u;
    map<string,long long>s;
    std::vector<int>::iterator it;
    string  s1,s2,s3,s4,s5,s6;
  cin>>s1;
  a=s1.size();
  s2=s1;
  reverse(all(s1));
  s3=s1.substr(0,a/2);
  s4=s3;
  reverse(all(s4));
   s5=s1.substr((a+3)/2-1,(a-(a+3)/2)+1);
  s6=s5;
  reverse(all(s6));
//cout<<s1<<" "<<s2<<endl;
//cout<<s3<<" "<<s4<<endl;
//cout<<s5<<" "<<s6<<endl;

  if(s1==s2&&s3==s4&&s6==s5)
  {
      cout<<"Yes";
  }
  else{cout<<"No";}


}


Measured memory_bytes: 3652
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, maxy = -1,maxy2=-1, mini = 999999999, mini2 = 9999999999, counter = 0, endp = 0, checker = 0;
std::string code;
vector<long long int>vec;
long long int N = 0, M = 0,R=0;
long long int costs[201][200*199/2+1],visit[10],hairetu[100000];

int main() {
	cin >> a ;
	rep(i, a) {
		cin >> hairetu[i];
		if (hairetu[i] != i+1) {
			counter++;
		}
	}
	if (counter <= 2) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}




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


int main()
{
    long M,N;
    long T[100],P[100],X[100];
    std::cin >> N;
    for(long i=0; i<N; i++){
        std::cin >> T[i];
    }
    std::cin >> M;
    for(long i=0; i<M; i++){
        std::cin >> P[i] >> X[i];
    }
    long sum=0;
    for(long i=0; i<N; i++){
        sum+=T[i];
    }
    for(long i=0; i<M; i++){
        sum-=T[P[i]-1];
        sum+=X[i];
        std::cout << sum << std::endl;
        sum-=X[i];
        sum+=T[P[i]-1];
    }
    return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	string s;
	cin >> s;
	string ans;
	for (char c : s) {
		if (c == '0') {
			ans.push_back('0');
		}
		if (c == '1') {
			ans.push_back('1');
		}
		if (c == 'B' && !ans.empty()) {
			ans.pop_back();
		}
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Scanner;


public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNextInt()){
			int d=sc.nextInt();
			int sum=0;
			for(int i=1;600>=d*(i+1);i++){
				sum+=Math.pow(i*d,2)*d;
			}
			System.out.println(sum);
		}
		sc.close();
	}
}

Measured memory_bytes: 26076