akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main(){
  int x = 0,max = 0, N;
  string S;

  cin >> N;
  cin >> S;

  for(int i = 0;i < N;i++){
    if(S[i] == 'I'){
      x++;
      if(max < x){
        max = x;
      }
    } else {
      x--;
    }
  }

  cout << max << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long maxn=2010,mod=(1e9+7);
long long n,k,a[maxn];
int main()
{
	cin>>n>>k;
	for(long long i=0;i<n;i++)
		cin>>a[i];
	long long ans=0;
	for(long long i=0;i<n;i++)
	{
		for(long long j=0;j<n;j++)
		{
			if(a[i]>a[j])
			{
				if(i<j)
				{
					long long tmp=(k+1);
					tmp*=k;
					tmp/=2;
					tmp%=mod;
					ans+=tmp;
					ans%=mod;
				}
				else
				{
					long long tmp=k;
					tmp*=(k-1);
					tmp/=2;
					tmp%=mod;
					ans+=tmp;
					ans%=mod;
				}
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
using namespace std;

int cnt[100000];

int main () {
  while (1) {
    for (int i=0; i<100000; i++) {
      cnt[i] = 0;
    }

    while (1) {
      int a, b;
      if (scanf("%d%d", &a, &b) != 2) return 0;
      if (a == 0 && b == 0) break;
      --a;
      --b;
      cnt[a]++;
      cnt[b]++;
    }
  
    if (cnt[0]%2 != 1) puts("NG");
    else if (cnt[1]%2 != 1) puts("NG");
    else {
      bool found = false;

      for (int i=2; i<100000; i++) {
        if (cnt[i]%2 != 0) {
          puts("NG");
          found = true;
          break;
        }
      }
  
      if (!found) puts("OK");
    }
  }
}

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

static const int MAX_ROW = 10;
static const int MAX_COL = 10;

struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

int GaussJordan(BitMatrix &A, bool is_extended = false) {
    int rank = 0;
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = rank; row < A.H; ++row) {
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        swap(A[pivot], A[rank]);
        for (int row = 0; row < A.H; ++row) {
            if (row != rank && A[row][col]) A[row] ^= A[rank];
        }
        ++rank;
    }
    return rank;
}

int main() {
    int N, M; cin >> N >> M;
    BitMatrix A(M, N);
    rep (i, M) {
        int k; cin >> k;
        rep (j, k) {
            int s; cin >> s;
            s--;
            A[i][s] = 1;
        }
    }
    vector<int> p(M); rep (i, M) cin >> p[i];

    int m = A.H, n = A.W;
    BitMatrix mat(M, N + 1);
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j < n; ++j) mat[i][j] = A[i][j];
        mat[i][n] = p[i];
    }
    int r = GaussJordan(mat, true);

	int ans = 1;  
    for (int row = r; row < M; ++row) if (mat[row][n]) ans = 0;
    
    rep (i, N - r) ans *= 2;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 256
s=input()
e=0
o=0
n=len(s)

for i in range(n):
    if i%2==0 and s[i]=="1":
        e+=1
    elif i%2==0 and s[i]=="0":
        o+=1
    elif i%2==1 and s[i]=="0":
        e+=1
    else:
        o+=1
print (min(e,o))

Measured memory_bytes: 39792
import numpy as np


N, M, C = map(int, input().split())
B = np.fromiter(map(int, input().split()), dtype=int)
As = list()
for i in range(N):
    a = np.fromiter(map(int, input().split()), dtype=int)
    As.append(a)
As = np.vstack(As)
print(int(np.sum(As.dot(B) + C > 0)))



Measured memory_bytes: 12488
#include <iostream>
#include <map>
using namespace std;
typedef long long ll;
ll n, ans;
string s;
map<char, ll> mp;
ll mod = 1000000007;
int main(void){
    // Your code here!
    cin >> n >> s;
    ans = 1;
    for (ll i = 0; i < n; i++)
    {
        mp[s[i]]++;
    }
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        (ans *= (itr->second + 1)) %= mod;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
#pragma region alias
#define inf LONG_MAX
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repr(i,n) for(int i=(int)(n-1);i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define sz(v) ((int)(v).size())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vec vector
using vi=vec<int>;
using vs=vec<string>;
using ii=pair<int,int>;
#pragma endregion
// define variables here
int n,x,y;
vi ans;
int shortest(int i, int j){
  return min(j-i,abs(x-i)+abs(y-j)+1);
}
void solve(){
  // write code here
  cin>>n>>x>>y;
  x--;y--;
  ans.resize(n-1,0);
  rep(i,n){
    rep(j,n){
      if(i>=j)continue;
      ans[shortest(i,j)-1]++;
    }
  }
  for(int v:ans)cout<<v<<'\n';
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  solve();
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;


int main(){
    int A,B,a,b,m=0;
    cin >> A >> B;
for(int i=1;i<1010;i++){
  a=i*0.08;
  b=i*0.10;
  if(A==a && B==b && m==0){
    cout << i << endl;
    m++;
  }
}
if(m==0){
  cout << -1 << endl;
}
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<char> vc;
typedef vector<vector<char> > vvc;
typedef vector<double> vd;
typedef vector<vector<double> > vvd;
template<class T> using vv=vector<vector< T > >;
typedef deque<int> di;
typedef deque<deque<int> > ddi;
typedef deque<bool> db;
typedef deque<deque<bool> > ddb;

// cout pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  s << p.first << " " << p.second << "\n"; return s;
}

// cout vector<pair>
template<typename T1, typename T2> ostream& operator<<(ostream& s, const vector<pair<T1, T2> >& vp) {
  int len = vp.size(); s << "\n";
  for (int i = 0; i < len; ++i) { s << vp[i]; }
    s << "\n"; return s;
}

// cout vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout deque
template<typename T> ostream& operator<<(ostream& s, const deque<T>& v) {
  int len = v.size(); s << "\n";
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  s << "\n"; return s;
}

// cout 2-dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

// cout 2-dimentional deque
template<typename T> ostream& operator<<(ostream& s, const deque< deque<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) { s << vv[i]; }
  return s;
}

int main() {
  int N;
  cin >> N;
  vll a(N+1);
  vll reverse(N+1);
  FOR (i, 1, N+1) {
    cin >> a[i];
    reverse[a[i]] = i;
  }
  set<int> added;
  added.insert(0);
  added.insert(N+1);
  ll ans = 0;
  FOR (i, 1, N+1) {
    ll order = reverse[i];
    ll l = *(--added.lower_bound(order));
    ll r = *(added.lower_bound(order));
    ans += (order - l) * (r - order) * i;
    added.insert(order);
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 13304
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		long[] x = new long[N];
		long[] y = new long[N];
		for(int i = 0; i < N; i++) {
			x[i] = sc.nextLong();
			y[i] = sc.nextLong();
		}
		sc.close();
		long ans = Long.MAX_VALUE;
		if(K == 2) {
			for(int i = 0; i < N; i++) {
				for(int j = i + 1; j < N; j++) {
					long x1 = Math.min(x[i], x[j]);
					long x2 = Math.max(x[i], x[j]);
					long y1 = Math.min(y[i], y[j]);
					long y2 = Math.max(y[i], y[j]);
					long s = (x2 - x1) * (y2 - y1);
					ans = Math.min(ans, s);
				}
			}
			System.out.println(ans);
			System.exit(0);
		}
		if(K == 3) {
			for(int i = 0; i < N; i++) {
				for(int j = i + 1; j < N; j++) {
					for(int k = j + 1; k < N; k++) {
						long x1 = Math.min(x[i], Math.min(x[j], x[k]));
						long x2 = Math.max(x[i], Math.max(x[j], x[k]));
						long y1 = Math.min(y[i], Math.min(y[j], y[k]));
						long y2 = Math.max(y[i], Math.max(y[j], y[k]));
						long s = (x2 - x1) * (y2 - y1);
						ans = Math.min(ans, s);
					}
				}
			}
			System.out.println(ans);
			System.exit(0);
		}
		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				for(int k = j + 1; k < N; k++) {
					for(int l = k + 1; l < N; l++) {
						long x1 = Math.min(Math.min(x[i], x[j]), Math.min(x[k], x[l]));
						long x2 = Math.max(Math.max(x[i], x[j]), Math.max(x[k], x[l]));
						long y1 = Math.min(Math.min(y[i], y[j]), Math.min(y[k], y[l]));
						long y2 = Math.max(Math.max(y[i], y[j]), Math.max(y[k], y[l]));
						int cnt = 0;
						for(int m = 0; m < N; m++) {
							if(x1 <= x[m] && x[m] <= x2 && y1 <= y[m] && y[m] <= y2) {
								cnt++;
							}
						}
						if(cnt >= K) {
							long s = (x2 - x1) * (y2 - y1);
							ans = Math.min(ans, s);
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 24456
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        CF_Reader in = new CF_Reader();

        long n = in.longNext();
        long blue = in.longNext();
        long red = in.longNext();

        long rem = n % (blue + red);
        long totalBlue = ((n - rem) / (blue + red)) * blue;
        totalBlue += Math.min(blue, rem);
        out.println(totalBlue);

        out.close();
    }


    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

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

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

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

        String Line() throws IOException {
            return br.readLine().trim();
        }
    }
}


Measured memory_bytes: 23124
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using VV = vector<vector<ll> >;

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; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

template < typename T >
void vprint(T &V){
	for(auto v : V){
    	cout << v << " ";
	}
	cout << endl;
}

ll N;
VV G;

// i : start
// return farthest from i
// return dist
pair<ll, ll> bfs(ll i){
    vector<ll> d(N, -1);
    queue<ll> que;

    que.push(i);
    d[i] = 0;

    while(!que.empty()){
        ll a = que.front();
        que.pop();

        for(ll to : G[a]){
            if(d[to]==-1){
                d[to] = d[a]+1;
                que.push(to);
            }
        }
    }
    ll index = max_element(ALL(d)) - d.begin();
    return make_pair(index, d[index]);
}

// 木の直径 エッジコストは1とする
ll diameter(){
    auto p = bfs(0);
    ll far_i = p.first;

    auto p2 = bfs(far_i);
    ll d = p2.second;
    return d;
}

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

    // input
    cin >> N;
    G.resize(N);

    FOR(i, 0, N-1){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        
        G[a].push_back(b);
        G[b].push_back(a);
    }

    ll d = diameter();
    
    if((d-1)%3==0){
        p("Second");
    }else{
        p("First");
    }
    
    return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  REP(i,3){
    string s;
    cin>>s;
    putchar(s[i]);
  }
  puts("");
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define intm INT_MAX
#define llm LLONG_MAX

using namespace std;
int MOD = 998244353;

int ans[2030];
int visited[2030];
vector<int> ar[2030];

void BFS(int node){
    queue<int> q;
    q.push(node);
    while( !q.empty() ){
        int cur = q.front(); q.pop();
        for(auto c: ar[cur]){
            if( !visited[c] && c != 1 ){
                visited[c] = visited[cur] + 1;
                q.push(c);
            }
        }

    }
}


int main(){
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,x,y,tmp;
	cin >> n >> x >> y;
	//assume x < y
	if( x > y ){
        y = tmp; y = x; x = tmp;
	}
	/*for(int i=1; i <= n-1; i++){
        ar[i].push_back(i+1);
        ar[i+1].push_back(i);
	}
	ar[x].push_back(y); ar[y].push_back(x);
	BFS(1);*/
	for(int i=1; i <= n-1; i++){
        for(int j=i+1; j <= n; j++){
            /*if( i<=x && y <= j ) ans[x-i+1+j-y] += 1;
            else{ ans[j-i] += 1; }*/
            ans[min(j-i, abs(x-i)+1+abs(j-y)  )] += 1;
            //cout << min(j-i, x-i+1+j-y  ) << " ";
        }
	}
	//cout << endl;
	/*
	for(int i=1; i <= n; i++) cout << visited[i] << " ";
	cout << endl;
	*/
	for(int i=1; i <= n-1; i++) cout << ans[i] << "\n";



}


Measured memory_bytes: 384
# coding: utf-8
DATA = """
1
""".split("\n")

def get_debug_line():
	for i in DATA:
		yield i

if 1:
	get_line = input
else:
	get_line = get_debug_line().__next__
	get_line()

R = int(get_line().strip())
print (2 * R * 3.1415926535)

Measured memory_bytes: 9048
#include <stdio.h>

int main()
{
  int n;
  char s[10001];
  scanf("%d %s",&n,s);
  for (int i=0; s[i] != '\0'; i++) {
    s[i] += n;
    if (s[i] > 'Z')
      s[i] -= 26;
  }
  printf("%s\n",s);
  return 0;
}


Measured memory_bytes: 128
n = int(input())
s = [[x for x in input()] for _ in range(n)]
ans = 0
d = {}
for i in range(n):
    key = "".join(sorted(s[i]))
    if key in d:
        ans += d[key]
        d[key] += 1
    else:
        d[key] = 1

print(ans)


Measured memory_bytes: 39040
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <memory.h>
using namespace std;

#define Mon 35
#define DAY 1440
#define rep(i, n) for(int i = 0; i < n; i++)

map<string, int> id;
int cnt[1000];
vector<int> log[1000];
bool present[12*Mon*DAY];

int get_m(string day, string t){
  int d = (day[0]-'0')*10+(day[1]-'0')*Mon+(day[3]-'0')*10+(day[4]-'0');
  int m = ((t[0]-'0')*10+(t[1]-'0'))*60+(t[3]-'0')*10+(t[4]-'0');
  return d * DAY + m;
}

int main(){
  string day, tim, in, ID;
  int n, num;
  while(cin >> n && n){
    num = 1;
    int res = 0;
    
    id.clear();
    memset(cnt, 0, sizeof(cnt));
    memset(present, false, sizeof(present));
    rep(i, 1000) log[i].clear();

    rep(i, n){
      cin >> day >> tim >> in >> ID;
      if(id[ID] == 0) id[ID] = num++;
      log[id[ID]].push_back(get_m(day, tim));
    }
    int gd = id["000"];
    int sz = log[gd].size()/2;
    rep(i, sz){
      int s = log[gd][2*i];
      int t = log[gd][2*i+1];
      while(s<t){
	present[s] = true;
	s++;
      }
    }
    for(int i = 1; i < num; i++){
      if(i == gd) continue;
      int sz = log[i].size()/2;
      int c = 0;
      rep(j, sz){
	int s = log[i][j*2];
	int t = log[i][j*2+1];
	while(s < t) {
	  if(present[s++]) c++;
	}
      }
      res = max(res, c);
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using vp = vector<P>;
using vt = vector<T>;
const int mod = 1000000007;
const double EPS = 1e-9;
//const long double EPS = 1e-14;
const int INF = (1<<30)-1;
//const ll INF = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
//template<class T = int> inline T in() { T x; cin >> x; return (x);}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main () {
  int a, b;
  cin >> a >> b;
  string sa = string(b,'0'+a);
  string sb = string(a,'0'+b);
  string ans = min(sa, sb);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
py = [list(map(int, input().split())) + [i + 1] for i in range(M)]
py_sort = sorted(py)
py_sort[0][1] = 1
j = 2
for i in range(1, M):
    if py_sort[i - 1][0] != py_sort[i][0]:
        j = 1
    py_sort[i][1] = j
    j += 1
py = sorted(py_sort, key=lambda x: x[2])
for i in range(M):
    print(str(py[i][0]).zfill(6) + str(py[i][1]).zfill(6))

Measured memory_bytes: 26688
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <math.h>
#include <algorithm>
#define rep(i,n) for(int i=0; i < (n); i++)
#define INF 1001001
using namespace std;
 
int main(){
  int n;
  int count[4];
  rep(i,4) count[i]=0;
  cin >> n;
  string s = "";
  rep(i,n){
    cin >> s;
    if(s=="AC"){
      count[0]++;
    }else if(s=="WA"){
      count[1]++;
    }else if(s=="TLE"){
      count[2]++;
    }else if(s=="RE"){
      count[3]++;
    }
  }

  cout << "AC x " << count[0] << endl;
  cout << "WA x " << count[1] << endl;
  cout << "TLE x " << count[2] << endl;
  cout << "RE x " << count[3] << endl;

  
}

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

int main(){
    long n,k;cin>>n>>k;
    map<long,long> mp;
    for(int i=0;i<n;i++){
        long a;cin>>a;
        mp[a]++;
    }
    auto begin = mp.begin();auto end = mp.end();
    vector<long> array;
    for(auto i=begin;i!=end;i++){
        array.push_back(i->second);
    }
    sort(array.begin(),array.end());
    long j=array.size()-k;
    long sum=0;
    for(int i=0;i<j;i++)sum+=array[i];
    cout<<sum<<endl;
}

Measured memory_bytes: 17756
a,b,c,d=map(int,input().split())
import fractions
g=fractions.gcd(c,d)
k=g*(c//g)*(d//g)
c_c=b//c-(a-1)//c
c_d=b//d-(a-1)//d
c_k=b//k-(a-1)//k
print((b-a+1)-(c_c+c_d-c_k))


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

int main() {
    int N;
    cin >>N; 
    int ans =0;
    for(int i=1; i<=N; i++){
        int count =0;
        if(i%2==0){
            continue;
        }
        for(int j=1; j<=i; j++){
            if(i%j==0){
                count++;
            }
        }
        if(count ==8){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <string>
#include <queue>
#include <deque>
#include <tuple>
#include <map>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int n; cin>>n;
	VI a(n); rep(i,n) cin>>a[i]; sort(ALL(a));
	rep(i,n-1){
		if(a[i]==a[i+1]) return cout<<"NO"<<endl,0;
	}
	cout<<"YES"<<endl;
  return 0;
}


Measured memory_bytes: 1024
W, H, N = map(int, input().split())
minX = 0
maxX = W
minY = 0
maxY = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        minX = max(minX, x)
    elif a == 2:
        maxX =min(maxX, x)
    elif a == 3:
        minY = max(minY, y)
    elif a == 4:
        maxY = min(maxY, y)

print(max(0, maxX-minX)*max(0, maxY-minY))

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

int main(){
  int a,b,c,d; cin>>a>>b>>c>>d;
  
  int i=0;
  while (a>0 && c>0){
    if (i==0){
      c-=b;
      i=1;
    }
    else{
      a-=d;
      i=0;
    }
  }
  cout<<(a>0 ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 3640
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		int startNum; // 標準入力から受け取る整数A
		int endNum; // 標準入力から受け取る整数B
		int answer = 0; // 回分数の個数
		Scanner sc = new Scanner(System.in);
		startNum = sc.nextInt();
		endNum = sc.nextInt();
		// 整数Aを初期値とするiの値が整数Bに達するまで繰り返す。
		for (int i = startNum; i <= endNum; i++) {
			String numStr = String.valueOf(i);
			char num1 = numStr.charAt(0); // 1文字目
			char num2 = numStr.charAt(1); // 2文字目
			char num4 = numStr.charAt(3); // 4文字目
			char num5 = numStr.charAt(4); // 5文字目
			//回分数かどうか判定
			if ((num1 == num5) && (num2 == num4)) {
				answer++;
			}
		}
		System.out.println(answer);

	}
}

Measured memory_bytes: 28500
n = int(input())
n_l = list(str(input()) for i in range(n))
m = int(input())
m_l = list(str(input()) for _ in range(m))

index = list(list(set(n_l)) + list(set(m_l)))
l = []

for k in range(len(index)):
    key = index[k]
    a = n_l.count(key)
    b = m_l.count(key)
    l.append(a-b)

if max(l) < 0:
    print(0)
else:
    print(max(l))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
int main(){
	string s;
	cin>>s;
	int N = s.size();
	string ans;
	for(int i=0;i<N;i+=2) ans += s[i];
	cout<<ans<<endl;
}

Measured memory_bytes: 512
n,m = map(int,input().split())
LMax,RMin = 0,n
for i in range(m):
	l,r =map(int,input().split())
	LMax = max(LMax,l)
	RMin = min(RMin,r)
if RMin < LMax:
	print(0)
else:print(RMin - LMax + 1)
	

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
using namespace std;
long long int a[100005], b[100005], c[100005], accuma = 0, accumc = 0, tot = 0;
int main()
{
    long long int n;
    cin >> n;
    for ( int i = 1; i <= n; i++ )
    {
        cin >> a[i];
    }
    sort( a+1, a+1+n );
    for ( int i = 1; i <= n; i++ )
    {
        cin >> b[i];
    }
    sort( b+1, b+1+n );
    for ( int i = 1; i <= n; i++ )
    {
        cin >> c[i];
    }
    sort( c+1, c+1+n );
    for ( int i = 1; i <= n; i++ )
    {
        for ( int j = accuma; j <= n-1; j++ )
        {
            if ( b[i] > a[j+1] && accuma != n )
            {
                accuma++;
            }
            else if ( b[i] <= a[j+1] || accuma == n )
            {
                break;
            }
        }
        for ( int j = accumc; j <= n-1; j++ )
        {
            if ( b[i] >= c[j+1] && accumc != n )
            {
                accumc++;
            }
            else if ( b[i] < c[j+1] || accumc == n )
            {
                break;
            }
        }
        tot = tot + accuma * (n-accumc);
    }
    cout << tot;
}

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  if (A + B > C + D){
    cout << "Left" << endl;  
  }
  else if (A + B == C + D){
    cout << "Balanced" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

#define oo 2000000001
#define MAX_N 200000

using namespace std;

int A[MAX_N + 1];

int main()
{
    int N, AC, WA, TLE, RE;
    char verdict[5];

    scanf("%d", &N);
    AC = WA = TLE = RE = 0;
    while(N--){
        scanf("%s", verdict);
        if(verdict[0] == 'A')
            ++AC;
        else
            if(verdict[0] == 'W')
                ++WA;
            else
                if(verdict[0] == 'T')
                    ++TLE;
                else
                    ++RE;
    }
    printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d", AC, WA, TLE, RE);

    return 0;
}


Measured memory_bytes: 1732
N, K = map(int,input().split())
sunuke_dict = dict()

for _ in range(K):
    d = input()
    s_list = input().split()

    for s_id in s_list:
        if s_id not in sunuke_dict:
            sunuke_dict[s_id] = [d]
        else:
            sunuke_dict[s_id].append(d)

print(N - len(sunuke_dict))

Measured memory_bytes: 9184
n, w = map(int, input().split())
item = [list(map(int, input().split())) for _ in range(n)]

dp = [[0]*(w+1) for _ in range(n+1)]

for i in range(n):
    for j in range(w+1):
        if j >= item[i][0]:
            dp[i+1][j] = max(dp[i][j], dp[i][j-item[i][0]]+item[i][1])
        else:
            dp[i+1][j] = dp[i][j]

print(dp[n][w])


Measured memory_bytes: 147156
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>

#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

int main () {
//  ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	string s;
	getline(cin, s);

	int n = sz(s);
	vector<char> st;
	for (int i = 0; i < n; ++i) {
		if (s[i] == 'T' && !st.empty() && st.back() == 'S') {
			st.pop_back();
		} else {
			st.pb(s[i]);
		}
   	}

   	cout << sz(st) << endl;

	return 0;
}


Measured memory_bytes: 772
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<stdio.h>
#include<queue>
#include <climits>
#include <map>
#include <set>
const long long mod = 1e9 + 7;
const int INF = 1 << 20;
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


int main()
{
    int a[4] = {10,50,100,500};
    bool flag = true;
    while(true){
        int n; cin >> n;
        if(n == 0) break;
        int x[4];
        for(int i = 0; i < 4; i++){
            cin >> x[i];
        }
        int sum = 0;
        for(int i = 0; i < 4; i++){
            sum += (a[i]*x[i]);
        }
        sum -= n;
        int r[4] = {0};
        for(int i = 3; i >= 0; i--){
            r[i] = sum / a[i];
            sum %= a[i];
        }
        if(flag){
            flag = false;
        }else{
            cout << endl;
        }
        for(int i = 0; i < 4; i++){
            if(x[i] > r[i]){
                cout << a[i] << ' ' << x[i]-r[i] << endl;
            }
        }
    }
}


Measured memory_bytes: 3072
p=[]
q=[]
n,m = map(int,input().split())
for _ in [0]*m:
  a,b = map(int,input().split())
  if a == 1:
    p += [b]
  elif b == n:
    q += [a]
p.sort()
q.sort()
i,j = 0,0
while i<len(p) and j<len(q):
    if p[i]<q[j]:
      i += 1
    elif p[i]>q[j]:
      j += 1
    else:
      print("POSSIBLE")
      exit()
print("IMPOSSIBLE")

Measured memory_bytes: 12616
#include <stdio.h>


// I/O
int get_int() {
    int n = 0;
    int c = getchar_unlocked();
    if(c == 45) {
        c = getchar_unlocked();
        while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
        return -n;
    } else if(c < 48 || 57 < c) return c;
    while(47 < c && c < 58) n = 10 * n + (c & 0xf), c = getchar_unlocked();
    return n;
}
void put_int(int n) {
    if(!n) {
        putchar_unlocked('0');
        return;
    }
    if(n < 0) n = -n, putchar_unlocked('-');
    char buf[11];
    int i = 0;
    while(n) buf[i++] = (char)(n % 10 + '0'), n /= 10;
    while(i--)putchar_unlocked(buf[i]);
}
void put_str(char *str) { while(*str) putchar_unlocked(*str++); }
//


// maximum heap
void _maxheap(int *A, const int i, const int N) {
    int l = i * 2;
    int r = i * 2 + 1;
    int max = i;
    if(l <= N && A[l] > A[max]) max = l;
    if(r <= N && A[r] > A[max]) max = r;
    if(max != i) {
        int tmp = A[i];
        A[i] = A[max];
        A[max] = tmp;
        _maxheap(A, max, N);
    }
}
void maxheap(int *A, const int N) {
    for(int i = N / 2; i > 0; --i) _maxheap(A, i, N);
}
//


int main(int argc, char **argv) {
    int h = get_int();
    int a[h + 1];
    for(int i = 1; i <= h; ++i) a[i] = get_int();
    maxheap(a, h);
    for(int i = 1; i <= h; ++i) putchar_unlocked(' '), put_int(a[i]);
    putchar_unlocked('\n');
    return 0;
}



Measured memory_bytes: 3616
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
#define MOD 1000000007
#define MAX 1000005
#define loop(i,a,b) for(long long int i=a;i<b;i++)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;
typedef long long int ll;

using namespace std;
//using namespace boost::multiprecision;

int prime[MAX];

ll modular_expo(ll x,ll n)
{
	ll ans = 1;
	while(n)
	{
		if(n&1)
		ans = (ans * x)%MOD;
		x = (x*x)%MOD;
		n = n>>1;
	}
	return ans%MOD;
}

void sieve()
{
	prime[1] = 1;
	for(int i=2;i*i<MAX;i++)
	if(prime[i]==0)
	for(int j=i*i;j<MAX;j+=i)
	prime[j] = 1;
}


int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);

ll n;
cin>>n;

ll ans=0;

for(int i=1;i<=n;i++)
{
	for(int j=1;j<=n;j++)
	{
		for(int k=1;k<=n;k++)
		ans += __gcd(i,__gcd(j,k));
	}
}
cout<<ans<<"\n";

return 0;
}


Measured memory_bytes: 3652
N, M = map(int, input().split())
mx = 0
for i in range(1, int(M**0.5)+1)[::-1]:
    if M % i == 0 and M // i >= N:
        mx = max(mx, i)
    if M % i == 0 and i >= N:
        mx = max(mx, M//i)
print(mx)

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

using namespace std;

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


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
int N=0;

int div(vector<int> &A)
{
    int ans = 0;
    while (true)
    {
        for (size_t j = 0; j < A.size(); j++)
        {

            if (A[j] % 2 != 0)
            {
                return ans;
            }else{
                A[j]=A[j]/2;
            }
            if (j == A.size() - 1)
            {
                ans++;
            }
        }
    }
}

int main(int argc, char const *argv[])
{
    cin >> N;
    vector<int> A(N);
    for (size_t i = 0; i < A.size(); i++)
    {
        cin >> A[i];
    }
    int ans=0;
    ans=div(A);
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<n;i++){
        if(n==1){
            ans = 1;
        }
        else if((i+1)*(i+1)>n){
            ans = i*i;
            break;
        }
    }
    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
    int N;
    long long min = 0;
    long long sum = 0;
    cin >> N;
    for (int i = 0; i < N; i++){
        long long A;
        cin >> A;
        
        if(min <= A){
            min = A;
        }else{
            sum += (min - A);
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;

int SumDigits(int x) {
    int sum = 0;
    int temp = x;
    while(0 < temp) {
        int digits = temp % 10;

        sum += digits;
        temp /= 10;
    }
    return sum;
}

int main(int argc, const char * argv[]) {
    int N = 0;
    int A = 0;
    int B = 0;
    cin >> N >> A >> B;
    
    int sum = 0;
    for(int i = 1; i <= N; i++) {
        int sumDigi = SumDigits(i);
        if(A <= sumDigi && sumDigi <= B) {
            sum += i;
        }
    }
    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

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

    int n, m, c;
    cin >> n >> m >> c;
    int B[m];
    int ans=0;
    REP(i, m) cin >> B[i];
    REP(i, n) {
        int res=c, a;
        REP(j, m) {
            cin >> a;
            res += B[j]*a;
        }
        if(res>0) ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int N = sc.nextInt();
	int[] a = new int[N];
	int[] b = new int[N];
	int[] c = new int[N];

	for(int i = 0; i<N; i++) {
	    a[i] = sc.nextInt();
	    b[i] = sc.nextInt();
	    c[i] = sc.nextInt();
	}

	long[][] happy = new long[N][3];
	happy[0][0] = a[0];
	happy[0][1] = b[0];
	happy[0][2] = c[0];
	for(int i = 1; i<N; i++){
	    happy[i][0] = Math.max(happy[i-1][1] + a[i], happy[i-1][2] + a[i]);
	    happy[i][1] = Math.max(happy[i-1][2] + b[i], happy[i-1][0] + b[i]);
	    happy[i][2] = Math.max(happy[i-1][0] + c[i], happy[i-1][1] + c[i]);
	}
	long result = Math.max(happy[N-1][0], happy[N-1][1]);
	result = Math.max(happy[N-1][2],result);
	System.out.println(result);
    }
}

Measured memory_bytes: 96060
#include <iostream>

using namespace std;

int main()
{
	int cars[100] ={0};
	int ptr_top = 0;
	int car_num;
	
	while ( cin >> car_num ) {
		if (car_num == 0) {
			cout << cars[ptr_top] << endl;
			ptr_top--;
		}
		else {
			ptr_top++;
			cars[ptr_top] = car_num;
		}
	}
	
	return 0;
}

Measured memory_bytes: 3072
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <sstream>
#include <set>
#include <tuple>
#include <algorithm>
#include <memory>
#include <numeric>
#include <queue>
#include <functional>
#include <cmath>
#include <cstring>
#include <map>
#include <unordered_map>
#include <sstream>

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

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


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

	vector<ll> a(4);
	vector<ll> b(4);
	vector<ll> in(4, 0);

	for (ll i = 0; i < 3; ++i)
	{
		ll a, b;
		cin >> a >> b;
		a--; b--;
		in[a]++;
		in[b]++;
	}

	sort(in.begin(), in.end());

	if (in[0] == 1 && in[1] == 1 && in[2] == 2 && in[3] == 2)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;

	}

	//system("pause");
}


Measured memory_bytes: 256
"""参考
@ct158603292321　　2019年05月03日に更新
qiita AtCoder ABC125 解説
https://qiita.com/ct158603292321/items/4cddafa5c2500a657ccf
"""
#約数
def make_divisors(n): #約数をリストで返す
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

# 初期入力
import numpy as np
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int, input().split()))
A_np =np.array(A)

#list(A)の内、任意で2つ選び約数の和集合（公約数ではない）
div_A_2 =make_divisors(A[0]) + make_divisors(A[1])
ans =[]
for i in div_A_2:
    aa= np.count_nonzero(A_np %i ==0) #iで割り切れる要素を数える
    if aa >=N-1:
        ans.append(i)
print(max(ans))

Measured memory_bytes: 23196
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

N = int(input())
if N == 1:
    print(0)
else:
    arr = factorization(N) 
    cnt = 0
    for key in arr:
        tmp = 1
        val = key[1]
        while val > 0:
            if val - tmp > tmp:
                val -= tmp
                tmp += 1
                cnt += 1
            else:
                val = 0
                cnt += 1
            
    print(cnt)

Measured memory_bytes: 9444
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
#define MAX 110000
vector<ll> eratos(int max){
  vector<ll> res;
  vector<bool> cp_list(max+1,true);
  cp_list[0]=false;
  cp_list[1]=false;
  for(ll i=2;i<=max;i++){
    if(cp_list[i]){
      res.push_back(i);
      for(ll j=2;j*i<=max;j++){
        cp_list[i*j]=false;
      }
    }
  }
  return res;
}
signed main(){
  init_io();
  ll q;
  cin >> q;
  ll l,r;
  vector<ll> primes = eratos(MAX),sum(MAX+1,0);
  bool ptable[MAX+1]={};
  for(auto i:primes){
    ptable[i] = true;
  }
  for(int i=1;i<=MAX;i++){
    ll x,y;
    sum[i] += sum[i-1];
    if(i%2==1){
      x = i;
      y = (i+1)/2;
      if(ptable[x]&ptable[y]){
        sum[i]++;
      }
    }
  }
  for(int i=0;i<q;i++){
    cin >> l >> r;
    cout << sum[r] - sum[l-1]<<endl;
  }
}


Measured memory_bytes: 1776
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>
#define ll long long

using namespace std;

long long MOD = 1000000007;

int main(){
    string S, T;
    cin >> S >> T;
    int A, B;
    cin >> A >> B;
    string U;
    cin >> U;
    if(U==S){
        A--;
    }else{
        B--;
    }
    cout << A << ' ' << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
using namespace std;
using ll = long long;


unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    vector<vector<ll>>dp(c+1,vector<ll>(d+1));
    dp[a][b] = 1;
    for (int i = 0; i < c-a; i++) {
        dp[a + i+1][b] = dp[a+i][b] * b;
        dp[a + i + 1][b] %= 998244353;
    }
    for (int i = 0; i < d-b; i++) {
        dp[a][b+i+1] = dp[a][b+i] * a;
        dp[a][b+i+1] %= 998244353;
    }
    
    for (ll i = a; i < c; i++) {
        
        for (ll j = b; j < d; j++) {
            dp[i + 1][j + 1] = dp[i + 1][j] + dp[i][j + 1] + dp[i + 1][j] * i + dp[i][j + 1] * j + (998244353-dp[i][j]) * (i * j);
            dp[i+1][j+1] %= 998244353;
        }
        
    }
    
    cout << dp[c][d] << endl;
}

Measured memory_bytes: 73740
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; i++)
        {
            p[i] = sc.NextInt();
        }

        int answer = p.Sum() - p.Max() / 2;

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

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

int fa[100001];

struct edge
{
	int u;
	int v;
}e[100001];

long long ans[100001],len[100001];

int findfa(int x)
{
	if(x!=fa[x]) fa[x]=findfa(fa[x]);
	return fa[x];
}

int main()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=1;i<=m;i++)
		cin>>e[i].u>>e[i].v;
	
	for(int i=1;i<=n;i++)
	{
		fa[i]=i;
		len[i]=1;
	}
	
	ans[m]=(long long)n*(n-1)/2;
	
	int f1,f2;
	for(int i=m;i>=1;i--)
	{
		f1=findfa(e[i].u);
		f2=findfa(e[i].v);
		if(f1==f2)
			ans[i-1]=ans[i];
		else
		{
			ans[i-1]=ans[i]-len[f2]*len[f1];
			len[f2]+=len[f1];
			fa[f1]=f2;
		}
	}
	
	for(int i=1;i<=m;i++)
		cout<<ans[i]<<endl;
	return 0;
}

Measured memory_bytes: 4096