akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define dbg(x) cerr << ">>> " << x << endl
#define _ << ", " <<

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int ms = 200200;

std::vector<int> wtf[ms];

int main() {
  ios::sync_with_stdio(0);cin.tie(0);
  int h, w, n;
  std::cin >> h >> w >> n;
  int ans = h;
  for(int i = 0; i < n; i++) {
    int x, y;
    std::cin >> x >> y;
    wtf[x].push_back(y);
  }
  int best = 1;
  for(int i = 2; i <= h; i++) {
    std::sort(wtf[i].begin(), wtf[i].end());
    int nxtBest = best + 1;
    for(auto t : wtf[i]) {
      if(t <= best) {
        ans = std::min(ans, i - 1);
      }
      if(t == best + 1) nxtBest = best;
    }
    best = nxtBest;
  }
  std::cout << ans << '\n';
  return 0;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;

template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	os << v[0];
	for (int i = 1; i < v.size(); i++) os << " " << v[i];
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u; return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}

inline bool match(char x, char y) {
	return (x == '?' || y == '?' || x == y);
}

void Main() {
	vector<string> abc(3);
	cin >> abc;
	vint dat = {0, 1, 2};

	int ans = 6000;
	do {
		string a = abc[dat[0]], b = abc[dat[1]], c = abc[dat[2]];
		int A = a.size(), B = b.size(), C = c.size();
		bitset<2001> bc;

		vint cab, cac;
		for (int i = 0; i <= A; i++) {
			bool flag = true;
			for (int j = 0; j < B && i+j < A; j++) {
				flag &= match(a[i+j], b[j]);
			}
			if (flag) cab.push_back(i);
		}

		for (int i = 0; i <= B; i++) {
			bool flag = true;
			for (int j = 0; j < C && i+j < B; j++) {
				flag &= match(b[i+j], c[j]);
			}
			if (flag) bc[i] = true;
		}
		for (int i = 0; i <= A+B; i++) {
			bool flag = true;
			for (int j = 0; j < C && i+j < A; j++) {
				flag &= match(a[i+j], c[j]);
			}
			if (flag) cac.push_back(i);
		}
		
		for (auto &i : cab) for (auto &j : cac) {
			if (i > j) continue;
			if (j-i >= b.size() || bc[j-i]) {
				chmin(ans, max({A, i + B, j + C}));
			}
		}
	} while (next_permutation(begin(dat), end(dat)));
	cout << ans << endl;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(0);
	cout << fixed << setprecision(20);
	Main();
	return (0);
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int d;
int c[27];
int s[366][27];
int calc(vector<int> t){
    int last[26]={};
    vector<int> ret(d);
    int ans=0;
    for(int i=0; i<d; i++){
        ans+=s[i][t[i]];
        last[t[i]]=i+1;
        for(int j=0; j<26; j++){
            ans-=c[j]*(i+1-last[j]);
        }
        ret[i]=ans;
    }
    return ans;
}
//random_device rnd;
//mt19937 mt(rnd());
mt19937 mt(334);
void gen(){
    d=365;
    uniform_int_distribution<> rndc(0, 100), rnds(0, 20000);
    for(int i=0; i<26; i++) c[i]=rndc(mt);
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) s[i][j]=rnds(mt);
}
int main()
{
    cin>>d;
    for(int i=0; i<26; i++) cin>>c[i];
    for(int i=0; i<d; i++) for(int j=0; j<26; j++) cin>>s[i][j];
    //gen();
    vector<int> t(d);
    
    int last[26]={};
    for(int i=0; i<d; i++){
        int kmx=0, mx=-1e9;
        for(int k=0; k<26; k++){
            int sum=s[i][k];
            int myon=last[k];
            last[k]=i+1;
            for(int j=0; j<26; j++){
                sum-=c[j]*(i+1-last[j]);
            }
            last[k]=myon;
            if(mx<sum) kmx=k, mx=sum;
        }
        t[i]=kmx;
        last[kmx]=i+1;
    }

    uniform_int_distribution<> rndk(0, d-1), rndq(0, 25);
    clock_t start = clock();
    int ans=calc(t);
    double start_temp=100000, end_temp=0;
    const int INF=2147483647;
	uniform_int_distribution<> rndp(0, INF);
    while((double)(clock()-start)/CLOCKS_PER_SEC<1.95){
        int k, q;
        k=rndk(mt), q=rndq(mt);
        if(t[k]==q){
            continue;
        }
        int pr=t[k], ansp=ans;
        ans-=s[k][pr];
        ans+=s[k][q];
        int last[2]={};
        for(int i=0; i<d; i++){
            if(t[i]==pr) last[0]=i+1;
            else if(t[i]==q) last[1]=i+1;
            ans+=c[pr]*(i+1-last[0]);
            ans+=c[q]*(i+1-last[1]);
        }
        t[k]=q, last[0]=last[1]=0;
        for(int i=0; i<d; i++){
            if(t[i]==pr) last[0]=i+1;
            else if(t[i]==q) last[1]=i+1;
            ans-=c[pr]*(i+1-last[0]);
            ans-=c[q]*(i+1-last[1]);
        }

        double temp = start_temp + (end_temp - start_temp) * (double)(clock()-start)/CLOCKS_PER_SEC / 1.95;
        double prob = exp((ans-ansp)/temp);
        if(prob <= rndp(mt)/(double)INF){
            t[k]=pr;
            ans=ansp;
        }
    }
    for(int i=0; i<d; i++){
        cout<<t[i]+1<<endl;
    }
	//cout<<1000000+calc(t)<<endl;
	return 0;
}


Measured memory_bytes: 4364
//14
#include<iostream>
#include<algorithm>

using namespace std;

int main(){
  for(int n;cin>>n,n;){
    const int h=10000;
    bool g[h][5]={{}};
    fill(g[h-1],g[h],true);
    while(n--){
      int d,p,q;
      cin>>d>>p>>q;
      int y;
      for(y=0;;y++){
	if(d==2){
	  if(g[y+1][q-1])break;
	}else{
	  int i;
	  for(i=0;i<p;i++){
	    if(g[y+1][q-1+i])break;
	  }
	  if(i<p)break;
	}
      }
      for(int i=0;i<p;i++){
	int dy=0,dx=0;
	((d==2)?dy:dx)=i;
	g[y-dy][q-1+dx]=true;
      }
      for(int i=0;i<h-1;i++){
	if(count(g[i],g[i+1],true)==5){
	  for(int j=i;j>=1;j--){
	    for(int x=0;x<5;x++){
	      g[j][x]=g[j-1][x];
	    }
	  }
	}
      }
    }
    cout<<count(g[0],g[h-1],true)<<endl;
  }
  return 0;
}

Measured memory_bytes: 1216
// AOJ2199
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> ipair;
typedef pair<ll,ll> lpair;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v) //vectorの中身を見る
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

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

    int n,m;
    while(cin>>n>>m){
        if(n==0&&m==0) break;
        vector<int> code(m+1,0);
        vector<ll> num(n+1,0);
        rep(i,m) cin>>code[i+1];
        rep(i,n) cin>>num[i+1];
        ll max_=pow(10,12);
        vector<vector<ll>> dp(n+5,vector<ll>(260,max_));
        for(int i=1;i<=m;i++){
            int cy=min(255,128+code[i]);
            cy=max(0,cy);
            dp[1][cy]=(num[1]-cy)*(num[1]-cy);
        }
        for(int i=1;i<=n-1;i++){
            for(int j=0;j<=255;j++){ //遷移前のyの値
                if(dp[i][j]==max_) continue;
                for(int k=1;k<=m;k++){ // 遷移する際のコード番号
                    int ny=min(255,j+code[k]);
                    ny=max(0,ny);
                    dp[i+1][ny]=min(dp[i][j]+(num[i+1]-ny)*(num[i+1]-ny),dp[i+1][ny]);
                }
            }
        }
        ll ans=max_;
        for(int i=0;i<=255;i++) ans=min(ans,dp[n][i]);
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 44608
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>

#define REP(n) for(int i = 0;i < n;i++)
#define LLREP(n) for(long long int  i = 0;i < n;i++)
typedef long long int ll;
using namespace std;
#define MAX_A 100005

int main(){

    int n,x,tmp,sum = 0,ans;
    cin >> n >> x;
    int mini = 10000000;
    for(int i = 0;i < n;i++){
        cin >> tmp;
        sum+=tmp;
        mini = min(mini,tmp);
    }
    ans = n;
    x-=sum;
    ans += x/mini;
    cout << ans << endl;
   
    return 0;
}

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

int main()
{
string s,t,u;
cin>>s>>t;
int a,b;
cin>>a>>b;
cin>>u;
if(s==u)cout<<a-1<<' '<<b;
else cout<<a<<' '<<b-1;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  int count[10][10] = {};
  for(int i=1; i<=N; i++){
    string S = to_string(i);
    int f = S.front() - '0';
    int b = S.back()  - '0';
    count[f][b]++;
  }

  int ans = 0;
  for(int i=0; i<10; i++)for(int j=0; j<10; j++){
    ans += count[i][j] * count[j][i];
  }

  cout<<ans<<endl;
}

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

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  while(1){
    int w,h;
    cin >> w >> h;
    if(!w) break;
    vector<vector<int>> s(h,vector<int>(w));
    for(int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        cin >> s[i][j];
      }
    }
    int c[4];
    for(int i = 0; i < 4; ++i) {
      cin >> c[i];
    }
    typedef vector<tuple<int,int,int>> edge;
    vector<vector<vector<edge>>> to(h,vector<vector<edge>>(w,vector<edge>(4)));
    vector<vector<vector<vector<int>>>> cost(h,vector<vector<vector<int>>>(w,vector<vector<int>>(4)));
    for (int i = 0; i < h; ++i) {
      for (int j = 0; j < w; ++j) {
        int di[] = {1,0,-1,0};
        int dj[] = {0,1,0,-1};
        for (int k = 0; k < 4; ++k) {
          int ni=i+di[k];
          int nj=j+dj[k];
          if(ni<0||nj<0||ni>=h||nj>=w)continue;
          for (int l = 0; l < 4; ++l) {
            to[i][j][l].push_back(make_tuple(ni,nj,k));
            if ((l - k + 4) % 4 == s[i][j]) {
              cost[i][j][l].push_back(0);
            } else {
              cost[i][j][l].push_back(c[(l - k + 4) % 4]);
            }
          }
        }
      }
    }
    typedef tuple<int, int, int, int> T;
    priority_queue<T, vector<T>, greater<T>> q;
    q.push(make_tuple(0,0,0,1));
    vector<vector<vector<int>>> d(h,vector<vector<int>>(w,vector<int>(4,1000000000)));
    d[0][0][1] = 0;
    while(!q.empty()) {
      auto p = q.top(); q.pop();
      int c,i,j,k;
      tie(c,i,j,k) = p;
      if (c > d[i][j][k]) continue;
      for (int l = 0; l < to[i][j][k].size(); ++l) {
        int ni,nj,nk;
        tie(ni,nj,nk) = to[i][j][k][l];
        if (d[ni][nj][nk] > d[i][j][k] + cost[i][j][k][l]) {
          d[ni][nj][nk] = d[i][j][k] + cost[i][j][k][l];
          q.push(make_tuple(d[ni][nj][nk],ni,nj,nk));
        }
      }
    }
    int minc = 1000000000;
    for (int i = 0; i < 4; ++i) {
      minc = min(minc,d[h-1][w-1][i]);
    }
    cout << minc << endl;
  }
  return 0;
}

Measured memory_bytes: 1940
n = int(input())
h = int(input())
w = int(input())
#a,b=map(int,input().split()) #横並び
#x=[int(input()) for i in range(3)] #縦に並んだのを配列に
#y=list(map(int,input().split())) #横に並んだのを配列に
print((n-h+1)*(n-w+1))
#print('YNEOS'[1::2])


Measured memory_bytes: 3316
N = int(input())
A = list(map(int,input().split()))
B = 1
# print(max(A))
if 0 in A:
    print(0)
elif max(A) > 10**18:
    print(-1)
else:
    for i in A:
        B *= i
        if B > 10 ** 18:
            B = -1
            break
    print(B)


Measured memory_bytes: 21772
import collections
n, m = map(int, input().split())

factor = []
tmp = int(m ** (1/2)) + 1
for i in range(2, tmp):
    while m % i == 0:
        m //= i
        factor.append(i)
if m > 1:
    factor.append(m)
num = list(collections.Counter(factor).most_common())

def comb(n, r):
    tmp = 1
    for i in range(r):
        tmp *= n - i
    for i in range(r):
        tmp //= r - i
    return tmp

ans = 1
for x in num:
    ans *= (comb(x[1] + n - 1, x[1]) % 1000000007)
    ans %= 1000000007
print(ans)

Measured memory_bytes: 3444
#include <bits/stdc++.h>  // clang-format off
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
struct SetupIO { SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(13); } } setup_io;
#ifndef _MY_DEBUG
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Mon Feb 10 22:50:13 JST 2020
 **/

signed main() {
    Int n;
    cin >> n;
    Int ans = 0, base = 1;
    while (n) {
        ans += base;
        base *= 2;
        n /= 2;
    }
    cout << ans << endl;
}


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

using namespace std;

struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define rep(i, n) REPS(i, 0, n)
#define REP0(i,n) for (ll i = 0; i <= (ll)(n); ++i)
#define REP1(i,n) for (ll i = 1; i <= (ll)(n); ++i)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (ll i = (a); i >= (ll)(n); --i)
#define DEP(i, n) DEPS(i, n, 0)
#define EACH(i, n) for (auto&& i : n)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* alias */
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using D = double;
using P = complex<D>;
using vs = vector<string>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; cin >> x; return x;}
inline ll IN() {ll x; cin >> x; return x;}
inline vs split(const string& t, char c) {vs v; stringstream s(t); string b; while(getline(s, b, c)) v.eb(b); return v;}
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
template <typename T, typename S> inline void print(const pair<T, S>& p) {cout << p.first << " " << p.second << endl;}
template <typename T> inline void print(const T& x) {cout << x << '\n';}
template <typename T, typename S> inline void print(const vector<pair<T, S>>& v) {for (auto&& p : v) print(p);}
template <typename T> inline void print(const vector<T>& v, string s = " ") {rep(i, v.size()) cout << v[i] << (i != (ll)v.size() - 1 ? s : "\n");}

signed main() 
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(a*b>c*d) print(a*b);
  else print(c*d);

  return 0;
}




Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
 
int table[310][310];
 
string backtrace(const string &s,const string &t,int i,int j) {
    if(i == 0 || j == 0) return "";
    else if(s[i-1] == t[j-1]) {
        return backtrace(s,t,i-1,j-1) + s[i-1];
    }else {
        if(table[i][j-1] > table[i-1][j]) return backtrace(s,t,i,j-1);
        else return backtrace(s,t,i-1,j);
    }
}
 
string lcs(const string &s,const string &t) {
  memset(table, 0, sizeof(table));
 
  for(int i=0; i<=s.length(); ++i)
    for(int j=0; j<=t.length(); ++j)
      table[i][j] = 0;
 
  for(int i=1; i<=s.length(); ++i) {
    for(int j=1; j<=t.length(); ++j) {
      int m = (s[i-1] == t[j-1]) ? 1 : 0;
      int value = max(table[i-1][j-1] + m, max(table[i-1][j], table[i][j-1]));
      table[i][j] = value;
    }
  }
 
  return backtrace(s,t,s.length(),t.length());
}
 
 
string lps(string s) {
    string s1,s2,ans;
    int ansl = 0;
    for(int i=1; i<s.length(); ++i) {
        string tmp = lcs(s.substr(0,i),s.substr(i));
        if(ans.length() < tmp.length()) {
            ans = tmp;
        }
    }
 
    return ans;
}
 
 
int main() {
    string input;
    while(cin>>input) {
        if(input == "#END") break;
        cout<<lps(input)<<endl;
    }
}

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

int main(void)
{
    string S,T;
    cin >> S >> T;
    bool ans = false;
 
   if(T.size() - S.size() == 1){
       if(T.substr(0, S.size()) == S){
           ans = true;
       }
   }
  
  if(ans)cout << "Yes" << endl;
  if(!ans)cout << "No" << endl;  
}

Measured memory_bytes: 3632
#include<cstdio>
#include<functional>
#include<algorithm>
using namespace std;
void func(int);

int main(void)
{
	int n,i,j,a[100],flg,cnt;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&a[i]);
	cnt=0;
	flg=1;
	while(flg==1)	{
		flg=0;
		for(j=n-1;j>0;j--)	{
			if(a[j]<a[j-1])	{
				swap(a[j],a[j-1]);
				cnt++;
				flg=1;
			}
		}
	}
	printf("%d",a[0]);
	for(i=1;i<n;i++)	printf(" %d",a[i]);
	printf("\n");
	printf("%d\n",cnt);
	return 0;
}


Measured memory_bytes: 2756
n = int(input())
h = list(map(int, input().split()))


INF = 1000000000
h += [INF] * 2
#最小値(コスト)を求める問題のため、DP配列を無限大に初期化
dp = [INF] * (n + 2)
#0番目の地点はコスト0
dp[0] = 0

for i in range(n):
  #もらうDPとやらで実装
  dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
  dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[n - 1])



Measured memory_bytes: 13924
n=int(input())
s=input()
k=len(s)
x='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
l=[]
y=0
for i in range(k):
    y=x.index(s[i])
    if y+n<25:
        l.append(x[y+n])
    else:
        l.append(x[y+n-26])
l=''.join(l)
print(l)



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

int main(){
    int n;
    cin>>n;
    int a[2][n];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++)cin>>a[i][j];
    }
    int ans=0;
    for(int i=0;i<n;i++){
        int tmp=0;
        for(int j=0;j<=i;j++){
            tmp+=a[0][j];
        }
        for(int j=i;j<n;j++){
            tmp+=a[1][j];
        }
        ans=max(ans,tmp);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3644
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define MOD 1000000007LL
#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,M;
	while(cin>>N>>M) {
		ll ans = N*M;
		if(10<=N||10<=M) ans=-1;
		cout<<ans<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int a, b, c;
    scanf("%d %d %d", &a, &b, &c);

    if (a <= c && b <= c){
        if (a + b == c){
            printf("%s", "Yes");
        }
        else {
            printf("%s", "No");
        }
    }
    else if (a <= b && c <= b){
        if (a + c == b){
            printf("%s", "Yes");
        }
        else {
            printf("%s", "No");
        }
    }
    else if (b <= a && c <= a){
        if (b + c == a){
            printf("%s", "Yes");
        }
        else {
            printf("%s", "No");
        }
    }

    return 0;
}


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

struct edge {
	int s,t;
	ll w;
};

bool comp(const edge& e1, const edge& e2) {
	return e1.w < e2.w;
}

// Union-Find tree
ll par[V_MAX];
ll ran[V_MAX];

// Init
void init(int V) {
	rep(i, V) {
		par[i] = i;
		ran[i] = 0;
	}
}

// Find root
ll find(ll x) {
	if (par[x]==x) {
		return x;
	}
	return par[x] = find(par[x]);
}

// Unite
void unite(ll x, ll y) {
	x = find(x);
	y = find(y);
	if (x==y) {
		return ;
	}

	if (ran[x] < ran[y]) {
		par[x] = y;
	} else {
		par[y] = x;
		if (ran[x]==ran[y]) ran[x]++;
	}
}

// Same?
bool same(ll x, ll y) {
	return find(x) == find(y);
}

int main(){
	int V, E;
	cin >> V >> E;
	vector<edge> es;	//edge集合

	init(V);
	rep(i,E) {
		int s,t;
		ll w;
		cin >> s>>t>>w;
		es.push_back({s,t,w});
	}

	sort(es.begin(), es.end(), comp);
	ll ans = 0;

	rep(i, E) {
		int s,t;
		ll w;
		s = es[i].s;
		t = es[i].t;
		w = es[i].w;
		if (!same(s,t)) {
			unite(s,t);
			ans+=w;
		}
	}
	cout << ans << endl;
}





Measured memory_bytes: 5152
#include<stdio.h>
int main(){
  int n,x[30]={},y[30]={},i,j,t,ans=0;
  char s[100];
  scanf("%d%s",&n,s);
  for(i=1;i<n;i++){
    for(j=0;j<i;j++){
      x[(s[j]-97)]++;
    }
    for(j=i;j<n;j++){
      y[(s[j]-97)]++;
    }
    t=0;
    for(j=0;j<30;j++){
      if(x[j]*y[j]>0) t++;
      x[j]=0;
      y[j]=0;
    }
    if(ans<t) ans=t;
  }
  printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;

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

        while (true) {
            int h = sc.nextInt();
            int w = sc.nextInt();

            if (h + w == 0) {
                return;
            }

            for (int i=0; i<h; ++i) {
                for (int j=0; j<w; ++j) {
                    if (i * j == 0 || i == h-1 || j == w-1) {
                        System.out.print("#");
                    } else {
                        System.out.print(".");
                    }
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


Measured memory_bytes: 34820
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final int n = stdin.nextInt();

	for ( int i = 0; i < n; i++ ) {
	    int[][] map = new int[9][9];
	    for ( int c = 0; c < 9; c++ ) {
		for ( int r = 0; r < 9; r++ ) {
		    map[c][r] = stdin.nextInt();
		}
	    }

	    boolean[][] ok = new boolean[9][9];
	    for ( int c = 0; c < 9; c++ ) {
		Arrays.fill( ok[c], true );
	    }

	    for ( int r = 0; r < 9; r++ ) {
		for ( int c = 0; c < 9; c++ ) {
		    if ( checkCol( r, c, map ) ) {
			ok[c][r] = false;
		    } 
		}
	    }

	    for ( int c = 0; c < 9; c++ ) {
		for ( int r = 0; r < 9; r++ ) {
		    if ( checkRow( r, c, map ) ) {
			ok[c][r] = false;
		    } 
		}
	    }

	    for ( int c = 0; c < 9; c++ ) {
		for ( int r = 0; r < 9; r++ ) {
		    if ( checkGrid( r, c, map ) ) {
			ok[c][r] = false;
		    } 
		}
	    }

	    for ( int c = 0; c < 9; c++ ) {
		for ( int r = 0; r < 9; r++ ) {
		    if ( ok[c][r] ) {
			System.out.print(" ");
		    } else {
			System.out.print("*");
		    }
		    System.out.print( map[c][r] );
		}
		System.out.println();
	    }

	    if ( i < n - 1 ) {
		System.out.println();
	    }
	    
	}	
    }

    static boolean checkCol( int r, int c, int[][] map ) {
	for ( int i = 0; i < 9; i++ ) {
	    if ( i != c && map[c][r] == map[i][r] ) {
		return true;
	    }
	}
	return false;
    }

    static boolean checkRow( int r, int c, int[][] map ) {
	for ( int i = 0; i < 9; i++ ) {
	    if ( i != r && map[c][r] == map[c][i] ) {
		return true;
	    }
	}
	return false;
    }

    static boolean checkGrid( int r, int c, int[][] map ) {
	final int ic = c / 3;
	final int ir = r / 3;

	for ( int i = ic * 3; i < (ic + 1) * 3; i++ ) {
	    for ( int j = ir * 3; j < (ir + 1) * 3; j++ ) {
		if ( i != c && j != r && map[c][r] == map[i][j] ) {
		    return true;
		}
	    }
	}
	
	return false;
    }
    
}

Measured memory_bytes: 23452
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,m,r;cin>>n>>m>>r;
  vector<int>rlist(r);
  rep(i,r){cin>>rlist[i];rlist[i]--;}
  vector<vector<int>>dist(n,vector<int>(n,1e9));
  rep(i,n)dist[i][i]=0;
  rep(i,m)
  {
    int a,b,c;cin>>a>>b>>c;
    a--;b--;
    chmin(dist[a][b],c);
    chmin(dist[b][a],c);

  }
  int res=1e9;
  rep(k,n)rep(i,n)rep(j,n)chmin(dist[i][j],dist[i][k]+dist[k][j]);
  function<void(int,int,int)> dfs=[&](int now,int flag,int l)
  {
    //if(flag==(1<<r)-1)cout<<now<<flag<<l<<endl;
    if(flag==(1<<r)-1){chmin(res,l);return ;}
    rep(i,r)
    {
      if(flag&(1<<i))continue;
      dfs(rlist[i],flag|(1<<i),l+dist[now][rlist[i]]);
    }
  };
  rep(i,r)dfs(rlist[i],1<<i,0);

  cout<<res<<endl;



  return 0;

}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,n,dif,dif2,con[500005][2],r;
bool p=false;
int main()
{
	scanf("%lld %lld %lld %lld %lld",&n,&a,&b,&c,&d);
	dif=abs(a-b);
	dif2=abs(c-d);
	n-=1;
	r=(n)/2;
	for(int i=n%2;i<=n;i+=2)
	{
		con[i][0]=(c*i)-(r*dif2);
		con[i][1]=(d*i)+(r*dif2);
		//printf("%lld %lld ----%d / %d\n",con[i][0],con[i][1],i,r);
		r--;
		if(dif>=con[i][0]&&dif<=con[i][1])
		{
			p=true;		
		}
	}
	/*if(n%2==0)
	{
		con[0][0]=0;
		con[0][1]=dif2*((n)/2);
		printf("%lld %lld ----%d\n",con[0][0],con[0][1],0);
	}*/
	if(p)printf("YES");
	else printf("NO");
}


Measured memory_bytes: 8064
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0

for x in range(A+1):
    for y in range(B+1):
        for z in range(C+1):
            if x*500 + y*100 + z*50 == X:
                cnt += 1

print(cnt)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int R = sc.nextInt();
		
		if (R < 1200) {
			System.out.println("ABC");
		} else if (R < 2800) {
			System.out.println("ARC");
		} else {
			System.out.println("AGC");			
		}
	}
}


Measured memory_bytes: 22868
program ABC061C
    implicit none
    integer(8)::N,K,a,b,i,count
    integer(8),dimension(100000)::L
    read(5,*)N,K
    L=0
    count=0

    do i=1,N
        read(5,*)a,b
        L(a)=L(a)+b
    end do

    do i=1,100000
        count=count+L(i)
        if(count>=K)then
            print'(i0)',i
            exit
        end if
    end do
end program ABC061C

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
int maxnum(int x,int y);
int selectbig(int num[],int m);
int main(){
    int mdata[4] = {0};
    int sdata[2] = {0};
    int ans = 0;
    for(int i = 0;i < 4;i++){
        cin >> mdata[i];
    }
    for(int i = 0;i < 2;i++){
        cin >> sdata[i];
    }
    for(int i = 1;i <= 3;i++){
        ans+=selectbig(mdata,i);

    }
    ans+=maxnum(sdata[0],sdata[1]);
    cout << ans << endl;
    return 0;
}

int maxnum(int x,int y){
    if(x >= y){
        return x;
    }
    else{
        return y;
    }
}

int selectbig(int num[4],int m){
    
    sort(num,num+4);
    return num[4-m];
}

Measured memory_bytes: 3084
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
long long n,a[K],ans;
priority_queue<int> pq;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+1+n);
	pq.push(a[n]);
	for(int i=n-1;i>=1;i--)
	{
		ans+=pq.top();
		pq.pop();
		pq.push(a[i]);
		pq.push(a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5440
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

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

int main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    string b;
    cin >> b;

    int max_len = 0;
    int ans = -1;
    REP(i,b.length()){
        if (b[i] == 'A' or b[i] == 'T' or b[i] == 'C' or b[i] == 'G') max_len++;
        else {
            ans = max(max_len,ans);
            max_len = 0;
        }
    }

    cout << max(max_len,ans) << endl;

    return 0;
}

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

using namespace std;

const int mod = 1e9 + 7;

struct mint {
  int n;
  mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { return (a.n += b.n) >= mod ? a.n - mod : a.n; }
mint operator-(mint a, mint b) { return (a.n -= b.n) < 0 ? a.n + mod : a.n; }
mint operator*(mint a, mint b) { return 1LL * a.n * b.n % mod; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }
ostream &operator<<(ostream &o, mint a) { return o << a.n; }

struct BIT {
  vector<mint> dat;

  BIT(int n) : dat(n + 1) {}

  void add(int k, mint v) {
    k++;
    while (k < dat.size()) {
      dat[k] += v;
      k += k & -k;
    }
  }

  mint query(int k) {
    mint res;
    k++;
    while (k > 0) {
      res += dat[k];
      k -= k & -k;
    }
    return res;
  }
};

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  vector<int> xs(n), ys(m);
  for (int i = 0; i < n; i++) {
    scanf("%d", &xs[i]);
  }
  for (int i = 0; i < m; i++) {
    scanf("%d", &ys[i]);
  }
  vector<pair<int, int>> ps;
  vector<int> dic;
  dic.push_back(0);
  for (int i = 0; i < n; i++) {
    int l = lower_bound(ys.begin(), ys.end(), xs[i]) - ys.begin() - 1;
    int r = lower_bound(ys.begin(), ys.end(), xs[i]) - ys.begin();
    if (l != -1 && r != m) {
      ps.emplace_back(xs[i] - ys[l], ys[r] - xs[i]);
      dic.push_back(ps.back().second);
    }
  }
  sort(dic.begin(), dic.end());
  dic.erase(unique(dic.begin(), dic.end()), dic.end());
  for (auto &p : ps) {
    p.second = lower_bound(dic.begin(), dic.end(), p.second) - dic.begin();
  }
  sort(ps.begin(), ps.end(), [](auto x, auto y) {
    if (x.first != y.first) return x.first < y.first;
    return x.second > y.second;
  });
  ps.erase(unique(ps.begin(), ps.end()), ps.end());
  BIT bit0(dic.size());
  BIT bit1(dic.size());
  bit0.add(0, 1);
  for (auto p : ps) {
    mint x = bit0.query(p.second - 1);
    mint y = bit1.query(p.second - 1);
    bit0.add(p.second, 2 * (x - y));
    bit1.add(p.second, x - y);
  }
  mint x = bit0.query(dic.size() - 1);
  mint y = bit1.query(dic.size() - 1);
  cout << x - y << endl;
}

Measured memory_bytes: 2672
#include <stdio.h>
double D(double a){
a *= a;
return a;
}

int main(void){
double x1,y1,x2,y2,sum;
double len;

scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);

sum = D(x1 - x2) + D(y1 - y2);
len = sqrt(sum);

printf("%f\n",len);
return 0;
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i=0;i<N;i++){ cin >> a.at(i); }
    
    //配列の中身を数字が大きい順に並び変え
    for(int i=0;i<N;i++){
        if(i+1 < N){//次のカードが存在し
            if(a.at(i) < a.at(i+1)){//次のカードの方が数が大きかったら
                int change = a.at(i);   //
                a.at(i) = a.at(i+1);    //入れ替える
                a.at(i+1) = change;     //
                i=-1;//再度、最初からチェック
            }
        }
    }
    
    //点数計算
    int alice=0,bob=0;
    for(int i=0;i<N;i++){
        if(i % 2 == 0){ alice += a.at(i); }
        else{ bob += a.at(i); }
    }
    cout << alice - bob << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF (ll)1e18+7
#define mk make_pair
#define pb emplace_back 
#define all(s) s.begin(),s.end()
typedef vector<int> vi;

void solve(){
int x=0,y=0,n=0,m=0,k=0,q=0,r=0,d=0;
cin>>n;
vi a(4,0);
vector<string> er(4);
er[0]="AC";
er[1]="WA";
er[3]="RE";
er[2]="TLE";
vector<string> st(n);
for(int i=0;i<n;i++){
	cin>>st[i];
	for(int j=0;j<4;j++){
		if(st[i]==er[j]){
		a[j]++;	
		}
	}
}
for(int i=0;i<4;i++){
	cout<<er[i]<<" x "<<a[i]<<"\n";
}
}
int main(){
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
   int t=1;
  // cin>>t;
     while(t--){
     	solve();
	 }
     return 0;
}

Measured memory_bytes: 6324
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

n = int(input())
S = []
U = []
for i in range(n):
    s = input()
    S.append(s)
    U.append(s)
m = int(input())
T = []
for i in range(m):
    t = input()
    T.append(t)
    U.append(t)
U = list(set(U))
cnt = [0] *len(U)
for i in range(n):
    for j in range(len(U)):
        if S[i] == U[j]:
            cnt[j] += 1
for i in range(m):
    for j in range(len(U)):
        if T[i] == U[j]:
            cnt[j]-=1
a = max(cnt)
print(max(a,0))

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<ll>;
using vec2 = vector<vector<ll>>;
ll inf = pow(2,62);

int main(){
    ll n;cin >> n;
    string s;cin >> s;
    ll ans = 0;
    for(int i = 0;i < 1000;i++){
        vec A = {i/100, i/10-(i/100)*10, i-(i/10)*10};
        int f = 0;
        for(int j = 0;j < n;j++){
            char c = s[j];
            if(int(c)-48 == A[f]){
                f++;
            }
            if(f == 3){
                ans++;
                break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3656
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include <debug_prettyprint.hpp>
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T=int> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion


const int MOD = 998244353;
const int MAXN = 1e5+5;

ll fac[MAXN+1];
ll invfac[MAXN+1];

ll inverseModulo(ll a, ll b){
    return 1<a ? b - inverseModulo(b % a, a) * b / a : 1;
}
ll binomial(int n, int k) {
    assert(k>=0 && k<=n);
    if(k==0 || n-k==0) return 1;
    return fac[n] * invfac[k] % MOD * invfac[n-k] % MOD;
}

ll memo[MAXN]={0};
ll pairs(int x) {
    if(x<=1) return 1;
    if(x%2==0) return pairs(x-1);
    if(memo[x] > 0) return memo[x];
    return memo[x] = x * pairs(x-2) % MOD;
}

signed main() {
    FASTIO

    fac[0]=1;
    invfac[0]=1;
    RNG(i,1,MAXN) {
        fac[i] = 1LL*i*fac[i-1] % MOD;
        invfac[i] = inverseModulo(fac[i], MOD);
    }

    int n; cin>>n; n *= 2;
    vi h = READ(n);

    map<int,int> cnt;

    for(auto x : h)
        cnt[x]++;

    min_heap<vi> pq;

    for(auto e : cnt) {
        int ppl = e.second;
        vi poly = {1};
        for(int i=1; i<=ppl/2; i++) {
            ll ways = binomial(ppl, i*2) * pairs(i*2) % MOD;
            poly.push_back(ways);
        }
        pq.push(poly);
    }

    while(pq.size()>=2) {
        vi a = pq.top(); pq.pop();
        vi b = pq.top(); pq.pop();
        vi c = convolution<MOD>(a,b);
        pq.push(c);
    }

    vi poly = pq.top();

    ll ans=0;

    FOR(i,poly.size()) {
        int sgn = i%2 ? -1 : 1;
        ans = ((ans + sgn * poly[i] * pairs(n-i*2)) % MOD + MOD) % MOD;
    }

    cout<<ans<<endl;

}

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


int main() {
    vector<int> v(3);
    for(int i = 0; i < 3; i++){
        cin >> v[i];
    }
    sort(v.begin(), v.end());
    cout << v[0] + v[1];
    cout << endl;
}


Measured memory_bytes: 256
#096c
H,W = map(int, input().split())

S_array = [[0 for i in range(W+2)]]

for i in range(1,H+1):
    S = list(input())
    S_array.append([0]+S+[0])
    
S_array.append([0 for i in range(W+2)])

No_flag = 0

#H,W <= 50 なので 最大2500ループで済むので通る
for i in range(1,H+1):
    for j in range(1,W+1):
        if S_array[i][j]=="#" and S_array[i+1][j]!="#" and S_array[i][j+1]!="#" and S_array[i-1][j]!="#" and S_array[i][j-1]!="#":
            print("No")
            No_flag = 1
            break
    if No_flag == 1:
        break
else:
    print("Yes")

Measured memory_bytes: 3064
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)

bool is_prime(int num)
{
	if (num < 2)
		return false;
	else if (num == 2)
		return true;
	else if (num % 2 == 0)
		return false;

	double sqrt_num = sqrt(num);
	for (int i = 3; i <= sqrt_num; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}
	return true;
}

int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	ll X;
	cin >> X;

	while (true)
	{
		if (is_prime(X))
		{
			break;
		}
		X++;
	}

	cout << X << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

int main(){
    ll n, k;
    cin >> n >> k;
    ll x, y;
    REP(i, k){
        cin >> x >> y;
        if(y > n / 2) y = n - y + 1;
        if(x > n / 2) x = n - x + 1;
        ll p = x % 3, q = y % 3;
        if(!p) p = 3;
        if(!q) q = 3;
        if(x < y || n - x < y) cout << p << endl;
        else cout << q << endl;
    }
    return 0;
}


Measured memory_bytes: 3076
package main

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

func main() {
	N := readInt()
	S := readString()
	ms := 0
	for i := 1; i < N; i++ {
		ts := 0
		for j := 0; j < N-i; j++ {
			if S[j] == S[j+i] {
				ts++
				if ts > ms {
					ms = ts
				}
				if ts == i {
					break
				}
			} else {
				ts = 0
			}
		}
	}
	fmt.Println(ms)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 640
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <math.h>

int main(){
	double x1, y1, x2, y2;

	scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);

	printf("%lf\n", sqrt(((double)x1-x2)*((double)x1-x2) + ((double)y1-y2)*((double)y1-y2)));

	return 0;

}


Measured memory_bytes: 2100
#include <cstdio>
#include <algorithm>

using namespace std;

#define MAX_N 100
#define MAX_W 10000
#define NIL -1

int dp[MAX_N + 1][MAX_W + 1];
int N, W;
int v[MAX_N], w[MAX_W];

int rec(int i, int j) {
    if (dp[i][j] != NIL)
        return dp[i][j];

    int res;
    if (i == N)
        res = 0;
    else if (j < w[i])
        res = rec(i + 1, j);
    else
        res = max(rec(i + 1, j), rec(i + 1, j - w[i]) + v[i]);

    return dp[i][j] = res;
}

int main() {
    scanf("%d%d", &N, &W);

    for (int i = 0; i < MAX_N + 1; ++i) {
        fill_n(dp[i], MAX_W + 1, NIL);
    }

    for (int i = 0; i < N; ++i) {
        scanf("%d%d", &v[i], &w[i]);
    }

    printf("%d\n", rec(0,W));
}

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

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

	for (int i = 0; i < s.size(); i++) {

		int s_i_int = (int) (s[i] - 'A');

		s_i_int += n;

		if (26 <= s_i_int) s_i_int -= 26;

		s[i] = (char)('A' + s_i_int);

	}

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

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

for i in range(n):
  a = int(input())
  if a not in key:
    key[a] = 1
  elif key[a] == 1:
    key[a] = 0
  else:
    key[a] = 1

ans = 0
for value in key.values():
  ans += value
print(ans)

Measured memory_bytes: 15072
#include<iostream>
#include<vector>
#include<map>
#include<utility>
#define int long long
using namespace std;
const int mx=1e5+10;
vector<int>g[mx];
int vis[mx],deg[mx],ans[mx];
map<pair<int,int>,int>mp;
void dfs(int a)
{
    vis[a]=1;
    for(auto it: g[a])
    {
        if(!vis[it])
        {
            if(mp[{a,it}]%2==1)
            {
                ans[it]=ans[a]^1;
            }
            else ans[it]=ans[a];
            dfs(it);
        }
    }
}
main()
{
    //fast
    int tc=1,i,j,k;
//    cin>>tc;
    while(tc--)
    {
       int a,x,y,t;
       cin>>a;
       for(i=0;i<a-1;i++)
       {
           cin>>x>>y>>t;
           g[x].push_back(y);
           g[y].push_back(x);
           mp[{x,y}]=t;
           mp[{y,x}]=t;
       }
       dfs(1LL);
       for(i=1;i<=a;i++)
       {
          cout<<ans[i]<<endl;
       }

    }
}




Measured memory_bytes: 28064