akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <stdio.h>
#include<cmath>
const int Times = 10;
const int N = 5500;

using namespace std;
typedef long long LL;

LL ct, cnt;
LL fac[N], num[N];

LL gcd(LL a, LL b)
{
    return b? gcd(b, a % b) : a;
}

LL multi(LL a, LL b, LL m)
{
    LL ans = 0;
    a %= m;
    while(b)
    {
        if(b & 1)
        {
            ans = (ans + a) % m;
            b--;
        }
        b >>= 1;
        a = (a + a) % m;
    }
    return ans;
}

LL quick_mod(LL a, LL b, LL m)
{
    LL ans = 1;
    a %= m;
    while(b)
    {
        if(b & 1)
        {
            ans = multi(ans, a, m);
            b--;
        }
        b >>= 1;
        a = multi(a, a, m);
    }
    return ans;
}

bool Miller_Rabin(LL n)
{
    if(n == 2) return true;
    if(n < 2 || !(n & 1)) return false;
    LL m = n - 1;
    int k = 0;
    while((m & 1) == 0)
    {
        k++;
        m >>= 1;
    }
    for(int i=0; i<Times; i++)
    {
        LL a = rand() % (n - 1) + 1;
        LL x = quick_mod(a, m, n);
        LL y = 0;
        for(int j=0; j<k; j++)
        {
            y = multi(x, x, n);
            if(y == 1 && x != 1 && x != n - 1) return false;
            x = y;
        }
        if(y != 1) return false;
    }
    return true;
}

LL pollard_rho(LL n, LL c)
{
    LL i = 1, k = 2;
    LL x = rand() % (n - 1) + 1;
    LL y = x;
    while(true)
    {
        i++;
        x = (multi(x, x, n) + c) % n;
        LL d = gcd((y - x + n) % n, n);
        if(1 < d && d < n) return d;
        if(y == x) return n;
        if(i == k)
        {
            y = x;
            k <<= 1;
        }
    }
}

void find(LL n, int c)
{
    if(n == 1) return;
    if(Miller_Rabin(n))
    {
        fac[ct++] = n;
        return ;
    }
    LL p = n;
    LL k = c;
    while(p >= n) p = pollard_rho(p, c--);
    find(p, k);
    find(n / p, k);
}

int main()
{
    LL n;
    cin>>n;
    LL q=sqrt(n);
    if (q*q<n) q++;

    LL x1=0,y1=0,x2=0,y2=0,x3=0,y3=0;
    x2=q;
    y3=q;
    y2=1;
    x3=x2*y3-n;
    cout<<x1<<' '<<y1<<' '<<x2<<' '<<y2<<' '<<x3<<' '<<y3<<endl;

    return 0;
}


Measured memory_bytes: 256
# C問題
N = int(input())
TA = []
for i in range(N):
    TA.append(list(map(int, input().split())))
#T, A互いに素なので1枚目はそのまま取ってきて良い
t = TA[0][0]
a = TA[0][1]
flag = True
for i in range(1,  N+1):
    tmp_t = 0
    tmp_a = 0
    if i == N:
        flag = False
        break
    k = max(t // TA[i][0], a // TA[i][1])   # 整数k
    while flag:   # 整数倍(足していく)していって両方がが超えた時の値が得票数になる
        tmp_t = k * TA[i][0]
        tmp_a = k * TA[i][1]
        if tmp_t >= t and tmp_a >= a:
            t = tmp_t
            a = tmp_a
            break
        k += 1
    
print(t+a)        

Measured memory_bytes: 3188
def main():
    N, A = map(int, input().split())
    x = list(map(int, input().split()))

    x.insert(0, 0)

    dp = [[[0] * (N * A + 1) for _ in range(N + 1)] for _ in range(N + 1)]
    for i in range(N + 1):
        dp[i][0][0] = 1

    for i in range(1, N + 1):
        for j in range(1, i + 1):
            for k in range(1, N * A + 1):
                dp[i][j][k] = dp[i - 1][j][k]
                if k >= x[i]:
                    dp[i][j][k] += dp[i - 1][j - 1][k - x[i]]

    ans = 0
    for j in range(1, N + 1):
        ans += dp[N][j][A * j]

    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

vector<string> split(const string& s, char c) {
    vector<string> v; stringstream ss(s); string x;
    while (getline(ss, x, c)) v.emplace_back(x); return move(v);
}
template<typename T, typename... Args>
inline string arrStr(T arr, int n) {
    stringstream s; s << "[";
    for(int i = 0; i < n - 1; i++) s << arr[i] << ",";
    s << arr[n - 1] << "]";
    return s.str();
}

#define ANTHRO(args...) {__anthro_begin(__LINE__); __anthro(split(#args, ',').begin(), args);}

inline void __anthro_begin(int line) { cerr << "#" << line << ": "; }
template<typename T> inline void __anthro_out_var(vector<T> val) { cerr << arrStr(val, val.size()); }
template<typename T> inline void __anthro_out_var(T* val) { cerr << arrStr(val,2); } //Change the values in case you want to debug something
template<typename T> inline void __anthro_out_var(T val) { cerr << val; }
inline void __anthro(vector<string>::iterator it) { cerr << endl; }

template<typename T, typename... Args>
inline void __anthro(vector<string>::iterator it, T a, Args... args) {
    cerr << it->substr((*it)[0] == ' ', it->length()) << "=";
    __anthro_out_var(a);
    cerr << "; ";
    __anthro(++it, args...);
}
//Simple Debugger

#define ll long long
#define MOD 1000000007
#define EPS 1e-9
int const INF = (int)1e9 + 1e3;
ll const INFL = (ll)1e18 + 1e6;
/*
    This is E-Knapsack2 from AtcoderJP
*/

int main(){
    ll N,W; cin>>N>>W;
    vector<ll> v(N),w(N);
    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }
    vector<vector<ll>> dp((N+1),vector<ll> (100010,INF));
    dp[0][0]=0;
    for(ll i=1;i<=N;i++){
        for(ll j=0;j<100010;j++){
            dp[i][j]=dp[i-1][j];
            if((j-v[i-1])>=0){
                dp[i][j]=min(dp[i][j],dp[i-1][j-v[i-1]]+w[i-1]);
            }
        }
    }
    ll an=-INF;
    for(ll i=0;i<100010;i++){
        if(dp[N][i]<=W){
            an=max(an,i);
            //ANTHRO(dp[N][i],i);
        }
    }
    cout<<an;
    return 0;
}


Measured memory_bytes: 80256
S = input()

subStringList = [S]
length = len(S)

counter = 0
before = 1

while (not(counter == before)):
    before = counter
    for s in subStringList[:]:
        for letter in s:
            if (not(letter in "ATGC")):
                subStringList += s.split(letter)
                subStringList.remove(s)
                counter = len(subStringList)
                break

print(len(max(subStringList,key=len)))


Measured memory_bytes: 3060
MOD=10**9+7
N=int(input())
memo=[{} for _ in range(N+1)]

def ok(last4):
    for i in range(4):
        t=list(last4)
        if i>0:
            t[i-1],t[i]=t[i],t[i-1]
        if "".join(t).count("AGC")>0:
            return False
    return True

def dfs(cur,last3):
    if last3 in memo[cur]:
        return memo[cur][last3]
    if cur == N:
        return 1
    ret=0
    for c in "AGCT":
        if ok(last3+c):
            ret=(ret+dfs(cur+1,last3[1:]+c))%MOD
    memo[cur][last3]=ret
    return ret

print(dfs(0,"TTT"))

Measured memory_bytes: 9572
#include<bits/stdc++.h>
using namespace std;
typedef pair<long long,int> PA;
int main(){
  int n,m,a,b;
  long long c,d,ans=0;
  vector<PA> vec[100001];
  scanf("%d %d %lld",&n,&m,&c);
  for(int i=0;i<m;i++){
    scanf("%d %d %lld",&a,&b,&d);
    vec[a].push_back(PA(d,b));
    vec[b].push_back(PA(d,a));
    ans += d;
  }
  priority_queue<PA,vector<PA>,greater<PA> > pq;
  long long min_cost[100001];
  fill(min_cost,min_cost+100001,LLONG_MAX);
  min_cost[1] = 0;
  pq.push(PA(0,1));
  while(!pq.empty()){
    PA p = pq.top();
    pq.pop();
    for(int i=0;i<vec[p.second].size();i++){
      long long next_cost = p.first + vec[p.second][i].first;
      int next_to = vec[p.second][i].second;
      if(min_cost[next_to] > next_cost){
	min_cost[next_to] = next_cost;
	pq.push(PA(next_cost,next_to));
      }
    }
  }
  bool flag[100001]={false};
  long long rui;
  vector<PA> mati;
  rui = ans;
  for(int i=1;i<=n;i++) mati.push_back(PA(min_cost[i],i));
  sort(mati.begin(),mati.end());
  for(int i=0;i<mati.size();i++){
    flag[ mati[i].second ] = true;
    for(int j=0;j<vec[ mati[i].second ].size();j++){
      if(flag[ vec[ mati[i].second ][j].second ]) rui -= vec[ mati[i].second ][j].first;
    }
    ans = min(ans,c*mati[i].first+rui);
  }
  printf("%lld\n",ans);
  return (0);
}



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

int main(){
    int N;
    int p[52];
    int q[52];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> p[i];
        q[i] = p[i];
    }
    sort(q, q+N);
    int counter = 0;
    for(int i=0;i<N;i++){
        if(q[i] != p[i]) counter++;
    }
    if(counter > 2){
        cout << "NO" << endl;
    }
    else{
        cout << "YES" << endl;
    }

    return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (long long i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, std::vector<long long> A) {
    vector<long long> X(N), Y(N);
    rep (i, N) X[i] = i + A[i], Y[i] = i - A[i];
    map<long long, int> cnt;
    long long ans = 0;
    rep (i, N) {
        ans += cnt[Y[i]];
        cnt[X[i]]++;
    }
    cout << ans << endl;
}

int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<long long> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%lld", &A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 30624
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

struct trie {
  ll level;
  trie *cld[2];
  trie(ll level) : level(level) {
    FOR(p, cld) {
      p = NULL;
    }
  }
  ~trie() {
    FOR(p, cld) {
      if(p) {
        delete p;
      }
    }
  }
  void append(const string &s, int i) {
    int l = s.size();
    if(i >= l) {
      return;
    }
    int c = s[i] - '0';
    if(!cld[c]) {
      cld[c] = new trie(level - 1);
    }
    cld[c]->append(s, i + 1);
  }
  ll grundy() {
    if(!cld[0] && !cld[1]) {
      return 0;
    }
    ll g = 0;
    FOR(p, cld) {
      if(p) {
        g ^= p->grundy();
      } else {
        ll x = 1;
        while(level % (x * 2) == 0) {
          x *= 2;
        }
        g ^= x;
      }
    }
    return g;
  }
};

int main() {
  ios::sync_with_stdio(false);
  int n;
  ll l;
  cin >> n >> l;
  trie *t = new trie(l);
  REP(i,0,n) {
    string s;
    cin >> s;
    t->append(s, 0);
  }
  cout << (t->grundy() == 0 ? "Bob" : "Alice") << endl;
  
  delete t;
  
  return 0;
}


Measured memory_bytes: 6636
using System;
using System.Collections.Generic;
using System.Linq;
class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner() {
        s = new string[0];
        i = 0;
    }

    public string next() {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int Int() {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0) {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Int() + add;
        }
        return Array;
    }

    public long Long() {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0) {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++) {
            Array[i] = Long() + add;
        }
        return Array;
    }
}
class Program {
    static Scanner cin = new Scanner();
    static Dictionary<int, int> dic = new Dictionary<int, int>();
    static void Main() {
        int N = cin.Int();
        prime_factorization(N);

        int n74 = 0, n24 = 0, n14 = 0, n4 = 0, n2 = 0;
        foreach (var v in dic.Values) {
            if (v >= 74) n74++;
            if (v >= 24) n24++;
            if (v >= 14) n14++;
            if (v >= 4) n4++;
            if (v >= 2) n2++;
        }

        long ans = 0;

        ans += n74;
        ans += n24 * (n2 - 1);
        ans += n14 * (n4 - 1);
        if (n4 >= 2 && n2 >= 2) ans += n4 * (n4 - 1) / 2 * (n2 - 2);
        Console.WriteLine(ans);
        Console.ReadLine();
    }

    static void prime_factorization(int n) //Key:素数, Value:指数
    {
        for (int j = 1; j <= n; j++) {
            int i = 2, tmp = j;
            while (i * i <= j) {
                if (tmp % i == 0) {
                    if (dic.ContainsKey(i)) dic[i]++;
                    else dic[i] = 1;
                    tmp /= i;
                }
                else i++;
            }
            if (tmp > 1) {
                if (dic.ContainsKey(tmp)) dic[tmp]++;
                else dic[tmp] = 1;
            }
        }
    }

}

Measured memory_bytes: 13152
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <string>
#include <functional>

using namespace std;


int main() {
	string key;
	getline(cin, key);
	const int n = atoi(key.c_str());
	int Mods = 0;
	int m;
	for (int i = 0; i < n; i++) {
		cin >> m;
		Mods += m - 1;
	}
	cout << Mods<<endl;
	return 0;
}


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

using ll = long long;

template <typename T> T inf;
template <> constexpr int inf<int> = 1e9;
template <> constexpr ll inf<ll> = 1e18;

int main() {
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for(int i = 0; i < N; ++i) {
        cin >> T[i];
    }
    sort(T.begin(), T.end());

    int res = 0;
    int l = 0;
    for(int i = 0; i < N; ++i) {
        if(T[l] + K < T[i] || i - l >= C) {
            res++;
            l = i;
        }
    }
    cout << res + 1 << endl;
}


Measured memory_bytes: 640
#include<iostream>
#include<math.h>
#include<vector>
#include<map>


using namespace std;
int main()
{  
    int s,w;
	cin>>s>>w;
	if(s>w){
		cout<<"safe"<<endl;
	}
	else{
		cout<<"unsafe"<<endl;
	}
	
	
}
	
    


Measured memory_bytes: 3616
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#define ll long long
#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define lowbit(x) (x& -x)
#define inf 0x3f3f3f3f
#define mod 1000000007
#define eps 1e-18
inline ll read(){ll tmp=0; char c=getchar(),f=1; for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1; for(;'0'<=c&&c<='9';c=getchar())tmp=tmp*10+c-'0'; return tmp*f;}
inline ll power(ll a,ll b){ll tmp=1; for(;b;b>>=1){if(b&1)tmp=tmp*a%mod; a=a*a%mod;} return tmp;}
using namespace std;
struct edge{
	int to,nxt;
}e[200010];
int fir[100010],a[100010],vis[100010];
int q[100010];
int n,m,tot=0,cnt=0;
void add(int x,int y){e[tot].to=y; e[tot].nxt=fir[x]; fir[x]=tot++;}
void bfs(int now)
{
	int h=0,t=1,i;
	++cnt; q[0]=now;
	while(h<t){
		vis[q[h]]=cnt;
		for(i=fir[q[h]];~i;i=e[i].nxt)
			if(!vis[e[i].to]){
				q[t++]=e[i].to; vis[e[i].to]=cnt;
			}
		h++;
	}
}
int main()
{
	memset(fir,255,sizeof(fir));
	int i;
	n=read(); m=read();
	for(i=1;i<=n;i++)a[i]=read();
	for(i=1;i<=m;i++){
		int x=read(),y=read();
		add(x,y); add(y,x); 
	}
	for(i=1;i<=n;i++)
		if(!vis[i])bfs(i);
	int ans=0;
	for(i=1;i<=n;i++)
		if(vis[i]==vis[a[i]])++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>

int main()
{
	
	char S[100001];
	scanf("%s", S);

	int i, count[2] = {};
	for (i = 0; S[i] != 0; i++) count[S[i] - '0']++;
	
	printf("%d\n", (count[0] < count[1])? count[0] * 2: count[1] * 2);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(time(NULL));

const int maxN = 1e5 + 9, maxV = 1e6 + 9, MOD = 998244353, SQ = 335, lg = 20, bs = 29;

map<ll, ll> mp;
ll signo[maxV], buc[maxV];
int prs[maxV], pc, f[maxV], root[maxV];

int crr[maxV], bg[maxV];

int fillOut(int* crr, int mult, int nmb) {
	if(nmb == 1) return crr[0] = mult, 1;
	int fc = f[nmb], pelon = nmb, pot = 1;
	while(pelon % fc == 0) pelon /= fc, pot *= fc;

	int ret = 0;
	for(; pot > 0; pot /= fc)
		ret += fillOut(crr + ret, mult * pot, pelon);
	return ret;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif

	int n;
	cin >> n;
	for(int i = 0, inp; i < n; i++) {
		cin >> inp;
		mp[inp]++;
	}

	for(int i = 2; i < maxV; i++) {
		if(!f[i]) prs[pc++] = f[i] = i;
		for(int j = 0; j < pc && ll(i) * prs[j] < maxV && prs[j] <= f[i]; j++)
			f[i * prs[j]] = prs[j];
	}

	signo[1] = root[1] = 1;
	for(int i = 2; i < maxV; i++) {
		int pr = i / f[i];
		signo[i] = signo[pr], root[i] = root[pr];
		if(f[pr] != f[i]) signo[i] = (MOD - signo[pr]) % MOD, root[i] *= f[i];
	}

	ll ans = 0;
	for(auto el: mp) {
		int sz = fillOut(bg, 1, el.fi);
		ll suma = 0;
		for(int i = 0; i < sz; i++) {
			ll tempo = 0;
			int oz = fillOut(crr, 1, root[el.fi / bg[i]]);
			for(int j = 0; j < oz; j++) {
				auto actual = bg[i] * crr[j];
				tempo = (tempo + buc[actual] * signo[crr[j]]) % MOD;
			}
			suma = (suma + el.fi / bg[i] * tempo) % MOD;
		}
		ans = (ans + suma * el.se) % MOD;
		ll pares = el.se * (el.se - 1) / 2 % MOD;
		ans = (ans + pares * el.fi) % MOD;

		for(int i = 0; i < sz; i++)
			buc[bg[i]] = (buc[bg[i]] + el.fi * el.se) % MOD;
	}
	//for(int i = 0; i < 14; i++) LOG << i << ' ' << buc[i] << '\n';
	cout << ans << '\n';
}


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

int main()
{
    int N ,M,s =0;
    string a;
    cin >> N >> M;
    if (N>M)
    {
        for (int i = 0; i < N; i++)
        {
            s += M*power(i);
        }
        a = to_string(s);
        cout << a << endl;
    }
    else
    {
        for (int i = 0; i < M; i++)
        {
            s += N*power(i);
        }
        a = to_string(s);
        cout << a << endl;
    }

}
int power (int a)
{
    int b = 1;
    for (int i = 0; i < a; i++)
    {
        b *= 10;
    }
    return b;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt(), b = sc.nextInt();
    String x = "", y = "";
    for (int i = 0; i < a; i++) x += Integer.toString(b);
    for (int i = 0; i < b; i++) y += Integer.toString(a);
    System.out.println((x.compareTo(y) < 0) ? x : y);
  }
}

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

int main(){
    

    int n;
    long long a;

    scanf("%d", &n);

    long long min, max;
    long long sum;
    for(int i=0; i< n; i++){
        scanf("%lld", &a);

        if(i==0){
            min = a;
            max = a;
            sum = a;
        }
        else{
            min = (min > a)?a:min;
            max = (max < a)?a:max;
            sum = sum + a;
        }
    }

    printf("%lld %lld %lld\n", min, max, sum);
    

    return 0;
}


Measured memory_bytes: 2136
import math

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
sub = min([m % 10 for m in [a,b,c,d,e] if m % 10 != 0] + [10])
time = 10 * (math.ceil(a / 10) + math.ceil(b / 10)+ math.ceil(c / 10)+ math.ceil(d / 10)+ math.ceil(e / 10)) - (10 - sub)
print(int(time))



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

int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    int i = N / 111;
    if (N % 111 != 0) ++i;
    cout << i * 111 << endl;
}


Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all_range(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t H,W;
int32_t N;
std::pair<int32_t, int32_t> pos[3000];
int32_t solve(std::pair<int32_t, int32_t>* begin, std::pair<int32_t, int32_t>* end)
{
	int32_t limit = (H + W + H + W) * 3;
	int32_t count = 0;
	for (auto iter = begin; iter != end; iter++)
	{
		auto v = *iter;
		if (v.second < v.first) {
			v.second += H + W + H + W;
		}

		if (limit < v.first) {
			++count;
			limit = v.second;
		}
		else {
			limit = std::min(limit, v.second);
		}
	}
	++count;
	return count;
}

int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >> N >> W>> H;

	for (size_t i = 0; i < N; i++)
	{
		int32_t x, y;
		char dir;
		in >> x >> y >> dir;

		auto get_lu = [&]() {
			//hで調整
			auto newx = x - (H - y);
			if (newx > 0) {
				return H + W + H + W - newx;
			}
			else {
				//wで調整
				auto newy = H - (y + x);
				return newy;
			}
		};
		auto get_ld = [&]() {
			auto newx = x - y;
			return H + newx;
		};
		auto get_ru = [&]() {
			auto newx = x + (H - y);
			return H + W + H + W - newx;
		};
		auto get_rd = [&]() {
			return H + x + y;
		};

		if (dir == 'N') {
			pos[i].first = get_ru();
			pos[i].second = get_lu();
		}
		else if (dir == 'S') {
			pos[i].first = get_ld();
			pos[i].second = get_rd();
		}
		else if (dir == 'W') {
			pos[i].first = get_lu();
			pos[i].second = get_ld();
		}
		else if (dir == 'E') {
			pos[i].first = get_rd();
			pos[i].second = get_ru();
		}
	}
	auto begin = pos;
	auto end = pos + N;
	std::sort(begin, end);
	int32_t res = (H + W + H + W) * 3;
	for (size_t i = 0; i < N; i++)
	{
		res = std::min(res, solve(begin, end));
		*end = *begin;
		end->first += H + W + H + W;
		end->second += H + W + H + W;
		++begin; ++end;
	}
	out << res << endl;
	return 0;
}
#endif



Measured memory_bytes: 3224
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define max(a, b) ((a) > (b) ? (a) : (b))

typedef struct
{
    int w;
    int v;
} goods;
long long dp[110][100100] = {0};

int main(void)
{
    int n, w;
    goods g[110];
    scanf("%d%d", &n, &w);
    rep(i, n)
        scanf("%d%d", &g[i].w, &g[i].v);

    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= w; j++)
            if (j - g[i - 1].w >= 0)
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - g[i - 1].w] + g[i - 1].v);
            else
                dp[i][j] = dp[i - 1][j];
    /*rep(i, n + 1)
    {
        rep(j, w + 1)
            printf("%2lld ", dp[i][j]);
        putchar('\n');
    }*/

    printf("%lld", dp[n][w]);
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> veci;
typedef vector<string> vecs;
template<class T,class U> using Hash=unordered_map<T,U>;

#define REP(i, a, n) for(ll i = a; i < n; i++)
#define RREP(i, a, n) for(ll i = n-1; i >= a; i--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, 0, n)
#define MD 1000000007

template<class T> T read(){T a;cin >> a;return a;}
template<class T> void read(T& a){cin >> a;}
template<class T> void rarr(T a, int n){for(int i = 0; i < n; i++) {cin >> a[i];}}
template<class T> void write(T a){cout << a << endl;}
template<class T> void writes(vector<T> a, const char* c = " "){cout << a[0];for(int i = 1; i < (int)a.size(); i++)cout << c << a[i];cout << endl;;}
void write(double a){cout << fixed << setprecision(12) << a << endl;}
void write(long double a){cout << fixed << setprecision(12) << a << endl;}
template<class T> void warr(T a, int n, const char* c = " "){cout << a[0];for(int i = 1; i < n; i++)cout << c << a[i];cout << endl;}
void split(string s, string delim, veci& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(atoi(s.substr(pos).data()));break;}else {result.push_back(atoi(s.substr(pos, p - pos).data()));}pos = p + delim.size();}}
void split(string s, string delim, vecs& result){result.clear();string::size_type pos = 0;while(pos != string::npos){string::size_type p = s.find(delim, pos);if(p == string::npos){result.push_back(s.substr(pos));break;}else {result.push_back(s.substr(pos, p - pos));}pos = p + delim.size();}}
ll comb(ll n, ll m){ll p=1;m=min(m,n-m);for(ll i=1;i<=m;i++){p*=n-i+1;p/=i;}return p;}
ll gcd(ll a, ll b,ll& res){
    res=a+b;
    if(a<b)swap(a,b);
    while(true){
        ll k = a % b;
        res+=(a/b)*b*2;
        if(k == 0){
            res-=b;
            return b;
        }
        a = b;
        b = k;
    }
}

int main(void)
{
    ll n,x;
    cin>>n>>x;
    ll y=n-x;
    ll res;
    gcd(x,y,res);
    write(res);
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = [input() for i in range(n)]
m = int(input())
t = [input() for i in range(m)]

import collections
sc_tc = []
for i in s:
    if s.count(i) - t.count(i)> 0:
        sctc = s.count(i) - t.count(i)
    else:
        sctc = 0
    sc_tc.append(sctc)

print(max(sc_tc))

Measured memory_bytes: 3316
H, W, M, *HW = map(int, open(0).read().split())
HW = list(zip(*[iter(HW)] * 2))

A = [0] * (H + 1)
B = [0] * (W + 1)
for h, w in HW:
    A[h] += 1
    B[w] += 1

a = max(A)
b = max(B)

cnt = A.count(a) * B.count(b) - len([0 for h, w in HW if A[h] == a and B[w] == b])

print(a + b - (cnt == 0))

Measured memory_bytes: 77904
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <tuple>
#include <cmath>
#include <queue>
#include <map>

#define ll int64_t
const ll INF = 1LL << 60;

using namespace std;
const long MOD = 1e9 + 7;

vector<ll> Res_distfromS(100001);
vector<bool> Res_isReached(100001);

vector< pair< ll, ll > > Graph[100001]; //G[ノード数]:{pair<辺の距離, 行き先の頂点>}
vector< pair< ll, ll > > Graph2[100001]; //G[ノード数]:{pair<辺の距離, 行き先の頂点>}


void dijkstra(ll start) {//結果は
  fill(Res_distfromS.begin(), Res_distfromS.end(), INF);//初期化
  fill(Res_isReached.begin(), Res_isReached.end(), false);

  priority_queue< pair<ll, ll> , vector< pair<ll, ll> >, greater< pair<ll, ll> > > q; //優先度付きキュー3つ目で比較方法を指定
  q.push(make_pair(0, start));//スタートをプッシュ

  while (!q.empty()) {//キューが空になるまで繰り返し■■■■■■■■■■■■■■■■■■■
    ll dist_from_s = q.top().first; //d : sからの距離
    ll t_node = q.top().second; //t ; 行き先
    q.pop();//キューの先頭を削除
    // tie(dist_from_s, t_node) = q.top();

    if (Res_isReached[t_node]) {  //探索済みなら飛ばす
      continue;
    }
    Res_isReached[t_node] = true;
    Res_distfromS[t_node] = dist_from_s;

    for (pair<ll, ll> e : Graph[t_node]) { //forreach G[t_node]みたいな感じ:Graphよりt_nodeからつながってるアークについて調べる//
      if (Res_distfromS[e.second] <= dist_from_s + e.first) {  //枝刈り
        continue;
      }
      q.push(make_pair(dist_from_s + e.first, e.second));
    }


  }//■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■

}


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

  vector < pair<ll, ll> >doubleDist(N, make_pair(0, 0)); //pair< Sからノードiへの最小コスト(円) + tからノードiへの最小コスト(スヌーク) ,ノード番号i>
  long u1, v1, a1, b1;


  for (int i = 0; i < M; i++) {//アーク数
    cin >> u1 >> v1 >> a1 >> b1;
    Graph[u1 - 1].push_back(make_pair(a1, v1 - 1)); //グラフのノードu1-1にコストa1,行き先v1-1のパスを追加する
    Graph[v1 - 1].push_back(make_pair(a1, u1 - 1)); //グラフのノードv1-1にコストa1,行き先u1-1のパスを追加する

    Graph2[u1 - 1].push_back(make_pair(b1, v1 - 1));
    Graph2[v1 - 1].push_back(make_pair(b1, u1 - 1));

  }

  dijkstra(S - 1);//sからコストaを用いてダイクストラ

  for (int i = 0; i < N; i++) {//ノードiについて
    doubleDist[i].first = Res_distfromS[i];
  }

  for (int i = 0; i < N; i++) {
    Graph[i] = Graph2[i];
  }

  dijkstra(T - 1);//sからコストaを用いてダイクストラ

  for (int i = 0; i < N; i++) {//ノードiについて
    doubleDist[i].first += Res_distfromS[i];
    doubleDist[i].second = i;
    // cout << doubleDist[i].first << "," << doubleDist[i].second<< endl;
  }

  sort(doubleDist.begin(), doubleDist.end());//コスト順？に並べ替え

  // for (int i = 0; i < N; i++) {//ノードiについて
  //   cout << doubleDist[i].first << "," << doubleDist[i].second<< endl;
  // }

  ll now = 0;

  for (int i = 0; i < N; i++) { //各iについて出力
    for (int j = now; j < N; j++) { //nlog(n)になる
      // cout << "now:" << now << endl;
      if (i > doubleDist[j].second) {//iがj番目に安いコストの都市の番号iより大きい　=　両替不可のとき
        now++;
      } else {
        cout << (1000000000000000 - doubleDist[j].first ) << endl;
        break;
      }
    }
  }


  return 0;
}


Measured memory_bytes: 20128
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main(){
  int count = 0;
  string s;
  cin >> s;
  r(i,6){
    if(s.at(i)=='1')count++;
  }
  cout << count << endl;
}

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

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

  int ans = 0;

  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if (h >= K) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
ans = 0
num = 0
a = 0
x = 0
k = 0
for l in range(N):
    for j in range(k,N):
        a += A[j]
        x =  x ^ A[j]
        if a  != x:
            ans += j - l
            k = j
            x = x ^ A[l] ^ A[j]
            a = a - A[l] - A[j]
            break
        elif j == N-1:
            ans += N-l
            k = j
            x = x ^ A[l] ^ A[j]
            a = a - A[l] - A[j]
print(ans )


Measured memory_bytes: 24840
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

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

#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=3005;
const int mod=998244353;

int n,s,a[N],dp[N][N];
int rec(int i,int sum){
    if(sum==0) return n-i+2;
    if(i>n or sum<0) return 0;
    int &cache=dp[i][sum];
    if(cache!=-1) return cache;
    return cache=(rec(i+1,sum)+rec(i+1,sum-a[i]))%mod;
}
signed main(){
    FastIO;
    cin>>n>>s;
    rep(i,1,n) cin>>a[i];
    memset(dp,-1,sizeof dp);
    int ans=0;
    rep(i,1,n) ans=(ans+rec(i,s))%mod;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 35712
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }

int main(){
    ll N;
    cin >> N;
    vector<ll> b(N),v;
    rep(i,N) cin >> b[i];
    rep(i,N){
        rep(j,b.size()){
            if(b[int(b.size())-1-j] == int(b.size())-j){
                b.erase(b.begin() + int(b.size())-1-j);
                //cout << "a:"<<b.size() << " "<<j<<endl;
                v.push_back(int(b.size())+1-j);
                break;
            }
        }
    }
    if(b.size() != 0){
        cout << -1 << endl;
        return 0;
    }
    rep(i,N){
        cout << v[N-1-i] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,m,n) for(int i=m;i<n;i++)
const ll mod=1e9+7;

int main(){
  int k;
  cin>>k;
  rep(i,0,k) cout<<"ACL";
  cout<<endl;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
}
ll lcm(ll x,ll y){
  ll g=gcd(x,y);
  return x/g*y;
}

int main(){
  int n;
  cin >> n;
  vector<int>a(n);
  vector<int>b(n);
  vector<int>c(n);
  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];
  rep(i,n) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());
  
  ll sum=0;
  rep(i,n){
    ll keyb=b[i];
    ll itc=upper_bound(c.begin(),c.end(),keyb)-c.begin();
    ll ita=lower_bound(a.begin(),a.end(),keyb)-a.begin();
    itc=n-itc;
    sum+=ita*itc;
  }
  cout<<sum<<endl;
}


Measured memory_bytes: 1408
// 20
/****************************************************
https://searleser97.gitlab.io/algorithms/template.cpp
****************************************************/

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define forr(_, x, n) for (int _ = x; _ > n; _--)
#define fos(_, x, n, s) for (int _ = x; _ < n; _ += s)
#define forn(_, x, n) fos(_, x, n, 1)
#define rep(_, n) forn(_, 0, n)
#define fi first
#define se second
#define pb push_back
#define pairii pair<int, int>
#define all(x) x.begin(), x.end()
#define cerr(s) cerr << "\033[48;5;196m\033[38;5;15m" << s << "\033[0m"
// typedef __int128_t lli;
typedef long long int li;
typedef long double ld;
// 12
void _main(int tc) {
  int n, k;
  cin >> n >> k;
  vector<bool> s(10);
  rep(i, k) {
    int x;
    cin >> x;
    s[x] = 1;
  }

  forn(i, n, (int) 1e6) {
    int aux = i;
    bool flag = 0;
    for(; aux; aux /= 10) {
      if (s[aux % 10]) {
        flag = 1;
        break;
      }
    }
    if (!flag) {
      cout << i << endl;
      return;
    }
  }
}

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  _main(0); return 0;
  int tc;
  cin >> tc;
  rep(i, tc) _main(i + 1);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define enl printf("\n")
#define case(t) printf("Case #%d: ", (t))
#define ni(n) scanf("%d", &(n))
#define nl(n) scanf("%lld", &(n))
#define nai(a, n) for (int i = 0; i < (n); i++) ni(a[i])
#define nal(a, n) for (int i = 0; i < (n); i++) nl(a[i])
#define pri(n) printf("%d\n", (n))
#define prl(n) printf("%lld\n", (n))
#define pii pair<int, int>
#define vii vector<pii>
#define vi vector<int>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
typedef long long ll;
const double pi = acos(-1);
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const int MAXN = 1e6 + 5;
const double eps = 1e-9;
using namespace std;
ll l[MAXN], r[MAXN];

int main() {
    int n;
    ni(n);
    for (int i = 0; i < n; i++)
        nl(l[i]), nl(r[i]);
    l[n] = r[n] = 0;
    sort(l, l+n+1);
    reverse(l,l+n+1);
    sort(r,r+n+1);
    ll ans = 0, sm = 0;
    for (int i = 0; i <= n; i++) {
    	sm += 2 * (l[i] - r[i]);
    	ans = max(ans, sm);
    }
    prl(ans);
    return 0;
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
int n, a, b, c, prime[110], cnt[110];

int main(void){
    cin >> n;
    for(int i=0;i<110;i++){
        prime[i] = 1;
    }
    prime[1] = 0;
    for(int i=1;i*i<110;i++) if (prime[i]) for (int j=i*2;j<110;j+=i) prime[j] = 0;

    for(int i=1;i<=n;++i){
        for(int j=2;j<=n;++j){
            if(!prime[j]) continue;
            if(i%j==0){
                int k = i;
                while(k%j==0){
                    ++cnt[j];
                    k /= j;
                }
            }
        }
    }
    cout << endl;
    int ans = 0;
    for(int i=2;i<=n;++i){
        if(!prime[i]) continue;
        if(cnt[i]>=74) ++ans;
    }
    for(int i=2;i<=n;++i){
        if(!prime[i]) continue;
        if(cnt[i]<14) continue;
        for(int j=2;j<=n;++j){
            if(!prime[j]) continue;
            if(i==j) continue;
            if(cnt[j]>=4) ++ans;
        }
    }
    for(int i=2;i<=n;++i){
        if(!prime[i]) continue;
        if(cnt[i]<24) continue;
        for(int j=2;j<=n;++j){
            if(!prime[j]) continue;
            if(i==j) continue;
            if(cnt[j]>=2) ++ans;
        }
    }
    for(int i=2;i<=n;++i){
        if(!prime[i]) continue;
        if(cnt[i]<4) continue;
        for(int j=i+1;j<=n;++j){
            if(!prime[j]) continue;
            if(cnt[j]<4) continue;
            for(int k=2;k<=n;++k){
                if(!prime[k]) continue;
                if(i==k || j==k) continue;
                if(cnt[k]>=2) ++ans;
            }
        }
    }
    cout << ans << endl;
}

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

using P = pair<int, int>;
using State = pair<long long, P>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long m; cin >> m;
    vector<long long> a(n), sum(n+1, 0);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        sum[i+1] = sum[i] + a[i];
    }
    long long ok = 0, ng = 200005;
    while(ng - ok > 1){
        long long mid = (ok + ng) / 2;
        long long cnt = 0;
        for(int i = 0; i < n; i++){
            int idx = lower_bound(a.begin(), a.end(), mid - a[i]) - a.begin();
            cnt += (n - idx);
        }
        (cnt >= m ? ok : ng) = mid;
    }
    long long ans = 0, cnt = 0;
    for(int i = 0; i < n; i++){
        int idx = lower_bound(a.begin(), a.end(), ok - a[i]) - a.begin();
        cnt += n - idx;
        ans += sum[n] - sum[idx] + a[i] * (n - idx);
    }
    ans -= (cnt - m) * ok;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
mod = 998244353

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

table = [0]*(s+1)
table[0] = 1
ans = 0
for ai in a:
    nxt = [0]*(s+1)
    if ai <= s:
        for j in range(ai, s+1):
            nxt[j] = table[j-ai]
    table = [(2*table[i] + nxt[i])%mod for i in range(s+1)]
ans += table[-1]
ans %= mod
print(ans)


Measured memory_bytes: 73700
#include <iostream>
#include <algorithm>
#include <climits>
 
using namespace std;
 
int main() {
  
  int n, x, y;
  cin >> n;
  int maxSum = INT_MIN, minSum = INT_MAX, maxDiff = INT_MIN, minDiff = INT_MAX;
  for (int i = 0; i < n; ++i) {
    cin >> x >> y;
    maxSum = max(maxSum, x + y);
    minSum = min(minSum, x + y);
    maxDiff = max(maxDiff, x - y);
    minDiff = min(minDiff, x - y);
  }
  
  cout << max(maxSum - minSum, maxDiff - minDiff);
  
  return 0;
}

Measured memory_bytes: 3176
def main():
    a, b, x = map(int,input().split())

    ans=(b - a+1)//x
    amari = (b-a+1)%x

    if amari ==0:
        print(ans)
        exit()
    if a%x ==0:
        ans+=1
    elif amari > x- (a%x):
        ans+=1

    print(ans)


if __name__ == "__main__":
        main()


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

vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        res.push_back({a, ex});
    }

    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}


int main(){
	// sengen
	LL a,b;
	LL j[1000];
	// nyuryoku
	cin >> a >> b;
	LL g = gcd(a,b);
	const auto &gp = prime_factorize(g);
	LL ans = 1;
	for(auto x:gp){
		ans++;
	}
	// keisan
	cout << ans << endl;
	// syutsuryoku
}

Measured memory_bytes: 3516
#include<iostream>
#include<cstdio>
#include<math.h>
#include<algorithm>

int main(void){
    int A[3];
    scanf("%d %d %d",&A[0],&A[1],&A[2]);
    sort(A,A+3,std::greater<int>());
    std::cout<<10*A[0]+A[1]+A[2]<<std::endl;

    return 0;
}

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

//map<key_type, value_type>で辞書型
//blueCard[i] == "orange"などの比較が可能
int getMaxValue(vector<int> count)
{
    int max = 0;
    for (int i = 0; i < N; i++)
    {
        if (count[i] > max)
            max = count[i];
    }
    return max;
}

int main()
{
    cin >> N;
    map<int, string> blueCard;
    for (int i = 0; i < N; i++)
    {
        cin >> blueCard[i];
    }

    cin >> M;
    map<int, string> redCard;
    for (int i = 0; i < M; i++)
    {
        cin >> redCard[i];
    }

    vector<int> count(N);
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < N; j++)
        {
            if (blueCard[i] == blueCard[j])
                count[i]++;
        }
    }

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (blueCard[i] == redCard[j])
                count[i]--;
        }
    }
    int res = getMaxValue(count);
    cout << res << endl;
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.StringTokenizer;




public class Main{

	public static void main(String[] args) throws IOException, InterruptedException {
		
		Scanner sc = new Scanner(System.in);
		PrintWriter out = new PrintWriter(System.out);
		
		HashSet<Character>  a = new HashSet<Character>();
		int n = 0;
		char one = 'n';
		char two = 'n';
		boolean onea = false;
		boolean twoa = false;
		String string = sc.next();
		
		for (int i = 0; i < 4; i++) {
			if (one == 'n') {
				one = string.charAt(i);
			}
			else {
				if (two == 'n' && string.charAt(i) != one) {
					two = string.charAt(i);
					continue;
				}
				
				if (one == string.charAt(i)) {
					onea = true;
				}
				if (two == string.charAt(i)) {
					twoa = true;
				}
			}
		}
		
		if (onea && twoa) {
			out.println("Yes");
		}
		else {
			out.println("No");
		}
		
		
		out.flush();

	}
	

	
	

	
}
class Scanner {
	StringTokenizer st;
	BufferedReader br;

	public Scanner(InputStream system) {
		br = new BufferedReader(new InputStreamReader(system));
	}

	public String next() throws IOException {
		while (st == null || !st.hasMoreTokens())
			st = new StringTokenizer(br.readLine());
		return st.nextToken();
	}

	public String nextLine() throws IOException {
		return br.readLine();
	}

	public int nextInt() throws IOException {
		return Integer.parseInt(next());
	}

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

	public char nextChar() throws IOException {
		return next().charAt(0);
	}

	public Long nextLong() throws IOException {
		return Long.parseLong(next());
	}

	public boolean ready() throws IOException {
		return br.ready();
	}

	public void waitForInput() throws InterruptedException {
		Thread.sleep(3000);
	}


}

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

signed main() {
    int N;
    cin >> N;
    vector<int> W(N);
    vector<int> ac;
    ac.push_back(0);
    for (int& x : W) {
        cin >> x;
        ac.push_back(ac.back() + x);
    }

    int ans = 1e18;
    for (int i = 0; i <= N; i++) {
        ans = min(ans, abs(ac[N] - 2 * ac[i]));
    }
    cout << ans << endl;
}


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

typedef long long ll;

ll dp[505][505];

int a[505];


ll pref[504];

ll sum(int l, int r)
{
    return pref[r] - pref[l-1];
}


int main()
{
    int n;
    scanf("%d",&n);
    for(int i = 0; i < 505; i++)
    {
        for(int j = 0; j < 505; j++)
        {
            dp[i][j] = 1e15;
        }
    }
    for(int i = 0; i < n ; i++)
    {
        scanf("%d",&a[i]);
        pref[i] = a[i];
        if( i )
        {
            pref[i] += pref[i-1];
        }
    }
    for(int i = 0; i < n ; i++)
    {
        dp[i][i] = 0;
    }

    for(int len = 2; len <= n; len++)
    {
        for(int i = 0; i + len - 1 < n; i++)
        {
            int j = i + len - 1;
            for(int k = i; k < j; k++)
            {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k+1][j] + sum(i,j));
            }

        }
    }

    printf("%lld\n",dp[0][n-1]);

    return 0;
}

Measured memory_bytes: 2304
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define MOD 1000000007

int main(){
	string S;
	cin >> S;
	int ans = 0;
	int c = 0;
	for(int i=0; i<S.size(); i++){
		if(S[i] == 'A') c++;
		else if(S[i] == 'T') c++;
		else if(S[i] == 'C') c++;
		else if(S[i] == 'G') c++;
		else c = 0;
		ans = max(ans, c);
	}
	cout << max(ans, c) << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long lint;


int main(){
	string s;
	cin >> s;
	if(s[0]==s[1] && s[1]==s[2]) cout <<"No\n";
	else cout<<"Yes\n";
}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  int h, w, n; cin >> h >> w >> n;
  vector<set<int, greater<int>>> me(h + 1);
  rep(i, n) {
    int x, y; cin >> x >> y;
    me[x].insert(y);
  }
  int acc = 0;
  for (int i = 2; i <= h; i++) {
    if (me[i].size() == 0) continue;
    if (me[i].count(i - acc) > 0) {
      acc++;
    }
    auto it = me[i].lower_bound(i - acc);
    if (it != me[i].end()) {
      cout << i - 1 << '\n';
      return;
    }
  }
  cout << h << '\n';
}


Measured memory_bytes: 19072