akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int N, M;
int a[100];
int b[100];
int x;
int main()
{
	cin >> N >> M;
	for(int i=0; i<M; i++)
	{
		cin >> a[i];
	}
	for(int j=0; j<N; j++)
	{
		b[j]=0;
	}
	for(int i=0; i<M; i++)
	{
		for(int j=0; j<N; j++)
		{
			cin >> x;
			if(x==a[i])
			{
				b[j]+=1;
			}
			else
			{
				b[a[i]-1]+=1;
			}
		}
	}
	for(int j=0; j<N; j++)
	{
		cout << b[j] << endl;
	}
	return 0;
}

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


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

	long long int n;
	cin>>n;
	cout<<(2LL*n)/__gcd(2LL,n)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

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

constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

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

  int n; cin >> n;
  ll dp[n+1][4][4][4];

  rep(i, n+1) {
    rep(j, 4) {
      rep(k, 4) {
        rep(l, 4) {
          dp[i][j][k][l] = 0;
        }
      }
    }
  }

  rep(j, 4) rep(k, 4) rep(l, 4) {
    if (j==0 && k==1 && l==2) continue;
    if (j==0 && k==2 && l==1) continue;
    if (j==2 && k==0 && l==1) continue;
    dp[3][j][k][l] = 1;
  }

  // 0: A, 1: C, 2: G, 3: T
  for(int i=4; i<=n; i++) {
    rep(j, 4) {
      rep(k, 4) {
        rep(l, 4) {
          rep(m, 4) {
            if (j==0 && k==2 && l==1) continue;
            if (j==0 && k==1 && l==2) continue;
            if (j==2 && k==0 && l==1) continue;
            if (k==0 && l==2 && m==1) continue;
            if (k==0 && l==1 && m==2) continue;
            if (k==2 && l==0 && m==1) continue;
            if (j==0 && k==2 && m==1) continue;
            if (j==0 && l==2 && m==1) continue;
            dp[i][k][l][m] += dp[i-1][j][k][l];
            dp[i][k][l][m] %= mod;
          }
        }
      }
    }
  }

  ll ans = 0;
  rep(j, 4) rep(k, 4) rep(l, 4) {
    ans += dp[n][j][k][l];
    ans %= mod;
  }
  cout << ans << endl;

}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    static int[] data;
    static int[] w;

    static int root(int q) {
        if (data[q] != q) {
            data[q] = root(data[q]);
        }
        return data[q];
    }

    static void union(int p, int q) {
        int rp = root(p);
        int rq = root(q);
        if (w[rp] > w[rq]) {
            data[rq] = rp;
            w[rp] += w[rq];
        } else {
            data[rp] = rq;
            w[rq] += w[rp];
        }
    }

    static boolean find(int p, int q) {
        return root(p) == root(q);
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        data = new int[n];
        w = new int[n];
        for (int i = 0; i < n; i++) {
            data[i] = i;
            w[i] = 1;
        }
        for (int i = 0; i < m; i++) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (!find(a - 1, b - 1)) union(a - 1, b - 1);
        }
        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (data[i] == i)
                ans = Math.max(ans, w[i]);
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 60964
/*
 * atcoder/abc115/d.cpp
 */

// C++ 14
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring> // memset
#include <cassert>
using namespace std;
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)
template <class T> ostream & operator << (ostream & out, vector<T> const & v) {
  for (auto &&a: v) out << a << " "; out << endl; return out;
}
template <class T> void dump(T &a) { cout << a << endl; }
template <class T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }

/*
 *     0                 1
 *     1 2 3 4 5 6 7 8 9 0 1 2 3 4
 * L0:     p   p       p   p
 * L1:   b   p   b   b   p   b
 * L2: b           p           b
 *
 * X:              7
 */
int N; ll X;

// rec(n, x) := レベルnでx以下のpの数
ll rec(int n, ll x) {
  if (n==0) return 1;
  if (x==1) return 0;

  ll bp = (1LL<<(n+1)) - 3;
  ll p = (1LL<<(n)) - 1;
  if (x <= bp + 1) return rec(n-1, x-1);
  if (x == bp + 2) return p + 1;
  if (x <= (bp+1) * 2) return p + 1 + rec(n-1, x-bp-2);
  return p * 2 + 1;
}

void solve() {
  cin >> N >> X;
  cout << rec(N, X) << endl;
}
int main() {
  // cout.precision(15); cout << fixed;

  solve();

  return 0;
}


Measured memory_bytes: 256
#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 pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
int a[3][3],n;
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

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

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






int main() {
   int n,r;
   cin >> n >> r ;
   if (n < 10) cout << r + (100*(10-n)) << endl;
   else cout << r << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.sort()

while 1 < len(a):
    while 0 != a[0]:
        r = a[1] % a[0]
        a[1] = a[0]
        a[0] = r
    a.pop(0)
print(a[0])

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

const int SIZE = 200005;
int N;
map<pair<int, int>, long long> m;

int main(){
    cin >> N;
    long long A[SIZE];
    for (int i = 0; i < N; i++)
        cin >> A[i];
    
    for (int i = 1; i <= N; i+=2)
        m[make_pair(i, i/2 + 1)] = m[make_pair(i-2, i/2)] + A[N-i];

    for (int i = 2; i <= N; i+=2){
        long long larger = max(A[N-i], A[N-i+1]);
        m[make_pair(i, i/2)] = max(m[make_pair(i-2, (i-2)/2)]+A[N-i], m[make_pair(i-3, (i-2)/2)]+larger);
    }

    for (int i = 3; i <= N; i+=2){
        m[make_pair(i, i/2)] = m[make_pair(i-2, i/2 - 1)] + A[N-i];
        m[make_pair(i, i/2)] = max(m[make_pair(i, i/2)], m[make_pair(i-3, i/2 - 1)] + A[N-i+1]);
        m[make_pair(i, i/2)] = max(m[make_pair(i, i/2)], m[make_pair(i-4, i/2 - 1)] + A[N-i+2]);
    }

    cout << m[make_pair(N, N/2)] << endl;
}

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

using namespace std;
mt19937_64 rng(58);

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    long long a;
    string b;
    cin >> a >> b;
    int dp = b.find('.');
    long long bi = stoi(b.substr(0, dp));
    long long bl = stoi(b.substr(dp+1));
    cout << (a * bi) + (a * bl / 100ll) << endl;

}

Measured memory_bytes: 3652
N = int(input())
S = [''.join(sorted(input())) for _ in range(N)]

# print(S)

D = {}
for s in S:
    if not(s in D.keys()):
        D[s] = 1
    else:
        # print(s)
        D[s] += 1


cnt = 0
for c in D.values():
    if c != 1:
        cnt += (c * (c - 1)) // 2

print (cnt)


Measured memory_bytes: 19404
#include<iostream>
using namespace std;

int main(){

	int H, W;

	cin >> H >> W;

	while( H != 0 && W != 0){			//W=0とH=0になるまで繰り返す
		for(int i = 1; i <= H; i++){		//縦軸に[＊]を増やして行く
			for(int j = 1; j <= W; j++){	//横軸に[＊]を増やして行く
				cout << ".#"[(i+j)%2 == 0];	// [#]のマークがあるときの条件を　[ この中に条件を入れる ]　
			}
			cout << endl ;
		}
		cout << endl;
		cin >> H >> W;
	}

	return 0;
}


Measured memory_bytes: 3124
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
#include <queue>
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
#define PI 3.14159265358979323846  
typedef pair<int, int> P;



int main() {
	int x, y,n,t;
	cin >> x >> y;
	if (y % 2 == 0 && x < 51 && 2*x <= y&&x*4>=y) {

		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <time.h>
#define ll long long
#define double long double
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl;
#define COYE cout<<"YES"<<endl;
#define COYe cout<<"Yes"<<endl;
#define COye cout<<"yes"<<endl;
#define CONO cout<<"NO"<<endl;
#define CONo cout<<"No"<<endl;
#define COno cout<<"no"<<endl;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define ALL(V) ((V).begin(),(V).end())
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LaL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
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;}
using namespace std;

int main(){
  ll N,M,ans=0;
  cin>>N>>M;
  ll H[N];
  REP(i,N) cin>>H[i];
  
  bool CAN[N];
  REP(i,N) CAN[i]=true;
  
  ll A[M],B[M];
  REP(i,M){
    cin>>A[i]>>B[i];
    A[i]--;
    B[i]--;
    
    if(H[A[i]]<H[B[i]]) CAN[A[i]]=false;
    if(H[A[i]]>H[B[i]]) CAN[B[i]]=false;
    if(H[A[i]]==H[B[i]]){
      CAN[A[i]]=false;
      CAN[B[i]]=false;
    }
  }
  
  REP(i,N){
    if(CAN[i]==true) ans++;
  }
  
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 6076
#include <iostream>
#define n 100000

using namespace std;

int main(void){
    int N, H[n];
    int tmp = 0, ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }

    for (int i = 0; i < N - 1; i++){
        if (H[i] >= H[i+1]){
            tmp++;
            if (tmp > ans)
                ans = tmp;
        }
        else{
            tmp = 0;
        }


    }

    cout << ans;

    return 0;
}

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

using namespace std;

char s[500][500];

int main() {
    int n, ans = 1e9, c = 0, i, j, k;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) scanf("%s", s[i]);
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (s[i][j] == '#') break;
        }
        
        if (j < n) break;
    }
    
    if (i == n) {
        puts("-1");
        
        return 0;
    }
    
    for (i = 0; i < n; i++) {
        for (j = 0; j < n; j++) {
            if (s[j][i] == '.') break;
        }
        
        if (j == n) c++;
    }
    
    for (i = 0; i < n; i++) {
        int p = 0;
        
        for (j = 0; j < n; j++) {
            if (s[i][j] == '.') p++;
        }
        
        for (j = 0; j < n; j++) {
            if (s[j][i] == '#') break;
        }
        
        if (j < n) {
            ans = min(ans, p + n - c);
        } else {
            ans = min(ans, p + n - c + 1);
        }
    }
    
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>

using namespace std;
typedef pair<int, int> P;

string s;
int Q;
int l[100005], r[100005];
int rpos[500005][27];
int succ[500005][20];

bool calc(int l, int r)
{
	int p = l;
	for(int i = 19; i >= 0; i--){
		if(succ[p][i] <= r) p = succ[p][i];
	}
	return p == r;
}

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> s;
	int n = s.size();
	s = "#" + s;
	
	cin >> Q;
	for(int i = 1; i <= n; i++) cin >> l[i] >> r[i];
	
	for(int j = 0; j < 27; j++){
		rpos[n+1][j] = n+1;
		rpos[n+2][j] = n+1;
	}
	for(int i = n; i >= 1; i--){
		int c = s[i] - 'a';
		rpos[i][c] = i;
		for(int j = c+1; j < 27; j++){
			rpos[i][j] = rpos[rpos[i][j-1]+1][j-1];
		}
		for(int j = 0; j < c; j++){
			rpos[i][j] = rpos[rpos[i][26]+1][j];
		}
	}
	
	for(int i = 1; i <= n+2; i++) succ[i][0] = rpos[i][26]+1;
	for(int i = 1; i < 20; i++){
		for(int j = 1; j <= n+2; j++){
			succ[j][i] = succ[succ[j][i-1]][i-1];
		}
	}
	
	for(int i = 1; i <= Q; i++){
		if(calc(l[i], r[i]+1)) cout << "Yes" << endl;
		else cout << "No" << endl;
	}
	
	return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))

const int N = 1e3 + 5;
int dist[N][N];
vector<pair<pair<int, int>, int> > adj[N][N];
int n,m;
string mat[N];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

void dij(int x, int y){
    priority_queue<pair<int, pair<int, int> >, vector<pair<int, pair<int, int> > >, greater<pair<int, pair<int, int> > > > pq;
    pq.push({0,{x, y}});
    while(!pq.empty()){
        pair<int, pair<int, int> > p = pq.top();
        pq.pop();
        x = p.second.first, y = p.second.second;
        if(p.first >= dist[x][y])continue;
        dist[x][y] = p.first;
        for(int i = 0; i < adj[x][y].size(); i++){
            int new_d = dist[x][y] + adj[x][y][i].second;
            int x1 = adj[x][y][i].first.first;
            int y1 = adj[x][y][i].first.second;
            if(new_d < dist[x1][y1]){
                pq.push({new_d, {x1, y1}});
            }
        }
    }
}
int main(){
    FAST
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            dist[i][j] = 1000000000;
        }
    }
    int i1, j1; cin >> i1 >> j1; i1--; j1--;
    int i2, j2; cin >> i2 >> j2; i2--; j2--;
    for(int i = 0; i < n; i++){
        cin >> mat[i];
    }
    if(mat[i1][j1] == '#' || mat[i2][j2] == '#'){
        cout << -1;
        return 0;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(mat[i][j] == '.'){
                for(int s = max(0, i - 2); s <= min(i + 2, n - 1); s++){
                    for(int t = max(0, j - 2); t <= min(j + 2, m - 1); t++){
                        int r = abs(s - i) + abs(t - j);
                        if(r <= 1)continue;
                        if(mat[s][t] == '#')continue;
                        adj[i][j].pb({{s, t}, 1});
                    }
                }
                for(int a = 0; a < 4; a++){
                    int x = dx[a] + i;
                    int y = dy[a] + j;
                    if(x >= n || x < 0 || y >= m || y < 0)continue;
                    if(mat[x][y] == '#')continue;
                    adj[i][j].pb({{x, y}, 0});
                }
            }
        }
    }
    dij(i1, j1);
    int ans = 1000000000;
    if(ans == dist[i2][j2])ans = -1;
    else ans = dist[i2][j2];
    cout << ans;
    return 0;
}


Measured memory_bytes: 133420
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

def fact(n: int, mod: int):
    fac = []
    for i in range(n+1):
        fac.append(1 if i < 2 else i * fac[-1] % mod)
        
    return fac

def fact_inv(fac: list, mod: int):
    return [1 if i < 2 else pow(faci, mod-2, mod) for i, faci in enumerate(fac)]

def nCr(n: int, r: int, mod: int, fac: list, fac_inv: list):
    return fac[n] * fac_inv[r] * fac_inv[n-r] % mod

def nPr(n: int, r: int, mod: int, fac: list, fac_inv: list):
    return fac[n] * fac_inv[n-r] % mod



n,a,b,c,d = li()
MOD = 10**9+7

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


fac = fact(n, MOD)
fac_inv = fact_inv(fac, MOD)

fac_i_k_mod = [[0]*(n+1) for _ in range(n+1)]
fac_inv_i_k_mod = [[0]*(n+1) for _ in range(n+1)]
for i in range(n+1):
    for k in range(n+1):
        fac_i_k_mod[i][k] = pow(fac[i], k, MOD)
        
for i in range(n+1):
    for k in range(n+1):
        fac_inv_i_k_mod[i][k] = pow(fac_i_k_mod[i][k], MOD-2, MOD)        


for i in range(1, n+1):
    for j in range(n+1):
        dp[i][j] += dp[i-1][j]
        if i < a or i > b:
            continue
        
        for k in range(c, min(d, j//i)+1):
            if j-i*k < 0:
                continue
            
            dp[i][j] += dp[i-1][j-i*k] * nPr(j, i*k, MOD, fac, fac_inv) % MOD\
                        * fac_inv_i_k_mod[i][k] % MOD\
                        * fac_inv[k] % MOD
            dp[i][j] %= MOD
            
print(dp[n][n])


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

int main() {
  int h,w;
  string board[60];

  cin >> h >> w;
  for (int i=0; i<h; i++) cin >> board[i];

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

  for (int i=0; i<h; i++) {
    for (int j=0; j<w; j++) {
      if (board[i][j] == '#') continue;

      int num=0;
      for (int k=0; k<8; k++) {
        int ni = i+dx[k];
        int nj = j+dy[k];

        if (ni < 0 || ni > h) continue;
        if (nj < 0 || nj > w) continue;
        if (board[ni][nj] == '#') num++;
      }

      board[i][j] = char(num + '0');
    }
  }

  for (int i=0; i<h; i++) cout << board[i] << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

// ABC 49-C
// http://abc050.contest.atcoder.jp/tasks/arc066_a

public class Main {
	
	static int MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		char[] c = in.next().toCharArray();
		int clen = c.length - 1;
		boolean isValid = true;
		
		while (clen >= 0 && isValid) {
			// Check dream
			if (clen - 4 >= 0 &&
					c[clen - 4] == 'd' && c[clen - 3] == 'r' && c[clen - 2] == 'e' && c[clen - 1] == 'a' && c[clen] == 'm') {
				clen -= 5;
				continue;
			}
			// Check dreamer
			if (clen - 6 >= 0 &&
					c[clen - 6] == 'd' && c[clen - 5] == 'r' && c[clen - 4] == 'e' && c[clen - 3] == 'a' && c[clen - 2] == 'm' && c[clen - 1] == 'e' && c[clen] == 'r') {
				clen -= 7;
				continue;
			}
			// Check erase
			if (clen - 4 >= 0 &&
					c[clen - 4] == 'e' && c[clen - 3] == 'r' && c[clen - 2] == 'a' && c[clen - 1] == 's' && c[clen] == 'e') {
				clen -= 5;
				continue;
			}
			// Check eraser
			if (clen - 5 >= 0 &&
					c[clen - 5] == 'e' && c[clen - 4] == 'r' && c[clen - 3] == 'a' && c[clen - 2] == 's' && c[clen - 1] == 'e' && c[clen] == 'r') {
				clen -= 6;
				continue;
			}
			isValid = false;
		}
		System.out.println(isValid ? "YES" : "NO");
		
	}
}

Measured memory_bytes: 25828
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll h,w,n; cin >> h >> w >> n;
  ll a = max(h,w);
  
  cout << (n+a-1)/a << endl;
  
  
}

Measured memory_bytes: 3596
l, r = map(int,input().split())
if not l//2019 == r//2019:
    print(0)
else:
    l = l%2019
    r = r%2019
    ans = 10**10
    for i in range(l,r):
        for j in range(i+1,r+1):
            if ans > (i*j)%2019:
                ans = (i*j)%2019
    print(ans)


Measured memory_bytes: 2940
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(pow(n, 0.5)) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)

        return divisors
    
    N = int(input())

    div_1 = make_divisors(N)
    res = 0
    for k in div_1:
        if k == 1:
            continue
        n = N
        while n > 1:
            if n % k == 0:
                n //= k
            else:
                if n >= k:
                    n %= k
                else:
                    n -= k
        if n == 1:
            res += 1

    div_2 = make_divisors(N - 1)
    res += len(div_2) - 1
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 9360
import math
x = 0
num = list(map(int,input().split()))
n = [list(map(int, input().split())) for i in range(num[0])]
for i in range(num[0]):
  k=1
  while i+k < num[0]:
    dd = 0
    for l in range(num[1]):
      dd += (n[i][l] - n[i+k][l]) ** 2      
    d = math.sqrt(dd)
    k += 1
    if d.is_integer() == True:
      x += 1
print(x)

Measured memory_bytes: 3064
def solve():
    while 1:
        try:
            N = int(input())
            D = list(map(int, input().split(" ")))
            M = int(input())
            T = list(map(int, input().split(" ")))
            D_dict = {}
            T_dict = {}
            for d in D:
                if d not in D_dict:
                    D_dict[d] = 1
                else:
                    D_dict[d] += 1

            for t in T:
                if t not in T_dict:
                    T_dict[t] = 1
                else:
                    T_dict[t] += 1

            for key, val in T_dict.items():
                if key not in D_dict:
                    print("NO")
                    raise EndLoop
                else:
                    if val > D_dict[key]:
                        print("NO")
                        raise EndLoop

            print("YES")
            break
        except:
            break


solve()

Measured memory_bytes: 121436
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;



int main(){

	int w[10],k[10];

	for(int i = 0; i < 10; i++)scanf("%d",&w[i]);
	for(int i = 0; i < 10; i++)scanf("%d",&k[i]);

	for(int i = 1; i <= 9; i++){
		for(int p = 9; p >= i; p--){
			if(w[p] > w[p-1])swap(w[p],w[p-1]);
			if(k[p] > k[p-1])swap(k[p],k[p-1]);
		}
	}

	printf("%d %d\n",w[0]+w[1]+w[2],k[0]+k[1]+k[2]);

    return 0;
}

Measured memory_bytes: 2728
#include<iostream>
using namespace std;

int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if ((x-r)>=0&&(x+r)<=W&&(y-r)>=0&&(y+r)<=H){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    
}


Measured memory_bytes: 3096
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String A=sc.next();
		sc.close();
		
		if(Character.isUpperCase(A.charAt(0))) {
			System.out.println('A');
		}else {
			System.out.println('a');
		}
		
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<pii, int> ppiii;

void solve() {
  int n;
  cin >> n;
  double ret = 0;
  while(n--) {
    double a;
    string b;
    cin >> a >> b;
    if(b == "BTC") a *= 380000;
    ret += a;
  }
  cout << fixed << setprecision(10) << ret << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  solve();
}


Measured memory_bytes: 256
//  Created by liszt on 2019/07/21.
#include<bits/stdc++.h>
using namespace std;

int main(){
    long long n,a,b,c,d,e;cin>>n >>a >>b >>c >>d >>e;
    cout<<max({(n-1)/a,(n-1)/b,(n-1)/c,(n-1)/d,(n-1)/e})+5<<endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
def input():
    return sys.stdin.readline()[:-1]

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

    l = [0] * 9
    for i in range(N):
        n = a[i] // 400
        if n > 8:
            n = 8
        l[n] += 1

    ans_min = 0
    for i in range(8):
        if l[i] > 0:
            ans_min += 1



    gold = l[8]

    ans_max = ans_min
    ans_max += gold

    if ans_min == 0:
        ans_min = 1

    print(ans_min, ans_max)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61860
#include <cstdio>
#include <cstring>
#include <vector>
#include <set>
#include <cstdlib>
#include <map>
#include <queue>

#define X first
#define Y second
#define PB push_back

using namespace std;

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

const int N = 2e5 + 500;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;


int A[N], B[N], n;
int q[60 * N], cur, sz;

inline int prv(int x){
	return (x - 1 + n) % n;
}

inline int nxt(int x){
	return (x + 1) % n;
}

int main(){
	scanf("%d", &n);
	for(int i = 0;i < n;i++)
		scanf("%d", A + i);
	for(int i = 0;i < n;i++)
		scanf("%d", B + i);
	for(int i = 0;i < n;i++){
		if(B[i] > B[prv(i)] + B[nxt(i)] && B[i] > A[i])
			q[sz++] = i;
	}
	ll sol = 0;
	for(;cur < sz;){
		int i = q[cur++];
		int potez = (ll)(B[i] - A[i] + B[prv(i)] + B[nxt(i)] - 1) / (B[prv(i)] + B[nxt(i)]);
		if(B[i] <= potez * (B[prv(i)] + B[nxt(i)]))
			potez--;
		sol += potez;
		B[i] = B[i] - potez * (B[prv(i)] + B[nxt(i)]);
		if(B[prv(i)] > A[prv(i)] && B[prv(i)] > B[prv(prv(i))] + B[i])
			q[sz++] = prv(i);
		if(B[nxt(i)] > A[nxt(i)] && B[nxt(i)] > B[nxt(nxt(i))] + B[i])
			q[sz++] = nxt(i);
		if(B[i] > A[i] && B[i] > B[prv(i)] + B[nxt(i)])
			q[sz++] = i;
	}
	bool ans = 1;
	for(int i = 0;i < n;i++)
		ans &= (A[i] == B[i]);
	printf("%lld\n", ans ? sol : -1);
	return 0;
}

Measured memory_bytes: 9856
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <cstdlib>
#include <cmath>

#define INF 1000000000000000000
using namespace std;
typedef long long ll;


int main() {
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size() - 1] == b[0] && b[b.size() - 1] == c[0])
		cout << "YES" << endl;
	else
		cout << "NO" << endl;

	return 0;
}

Measured memory_bytes: 256
//written by NewbieChd
#include <cstdio>
#include <cctype>
#include <queue>
#include <bits/stdc++.h>
using namespace std;

const int BUF = 1000000;
char buf[BUF], *p1, *p2;
inline char getChar() { return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, BUF, stdin), p1 == p2) ? EOF : *p1++; }
inline int read() {
    register int f = 0;
    bool b = 1;
    char c;
    while (!isdigit(c = getChar()))
        if (c == 45)
            b = 0;
    do
        f = f * 10 + (c ^ 48);
    while (isdigit(c = getChar()));
    return b ? f : ~f + 1;
}

const int maxN = 100003;
priority_queue <int> L;
priority_queue <int, vector <int>, greater <int> > R;

int main() {
    int Q = read(), n = 0, opt, x, cntL = 0, cntR = 0;
    long long sumL = 0, sumR = 0, sum = 0;
    for (; Q; --Q) {
        opt = read();
        if (opt == 1) {
            x = read(), ++n;
            if (n & 1)
                R.push(x), sumR += x, x = R.top(), R.pop(), sumR -= x, L.push(x), sumL += x, ++cntL;
            else
                L.push(x), sumL += x, x = L.top(), L.pop(), sumL -= x, R.push(x), sumR += x, ++cntR;
            sum += read();
        }
        else
            x = L.top(), printf("%d %lld\n", x, sum + 1ll * x * cntL - sumL + sumR - 1ll * x * cntR);
    }
    return 0;
}


Measured memory_bytes: 4476
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        ArrayList<Double> S = new ArrayList<Double>();

        while (true) {
            int n = sc.nextInt();

            if (n == 0) {
                for (int i=0; i<S.size(); i++) {
                    System.out.println(S.get(i));
                }
                break;
            }

            int[] A = new int[n];
            int[] B = new int[n];
            double sum1 = 0;
            double sum2 = 0;
            for (int i=0; i<n; i++) {
                A[i] = sc.nextInt();
                sum1 += A[i];
                sum2 += Math.pow(A[i], 2);
            }
            double s = Math.sqrt(sum2/n - Math.pow(sum1/n, 2));

            S.add(s);

        }


    }
}


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

const int MOD = 1e9 + 7;
using ll = long long;

int main() {
    int N;  cin >> N;
    vector<ll> A(N);
    ll sum = 0, sum_diag = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        sum = (sum + A[i]) % MOD;
        sum_diag = (sum_diag + A[i] * A[i] % MOD) % MOD;
    }
    cout << (sum * sum % MOD - sum_diag + MOD) % MOD * 500000004 % MOD << endl;
}


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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int num = 753;
    int ans = 1e9;
    rep(i, n - 2)
    {
        int x = 0;
        rep(j, 3)
        {
            x *= 10;
            x += s[i + j] - '0';
        }
        ans = min(ans, abs(num - x));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import java.util.*;

public class Main {
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        Double sco = 0.0;
        for (int i = 1; i <= a; i++) {
            int co = 0;
            for (int j = i; j < b;j *= 2 ) {
                co += 1;

            }

            sco += (1.0 / a) * Math.pow(0.5, co);
        }
        System.out.println(sco);
    }
}


Measured memory_bytes: 23380
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <functional>

using namespace std;

int main()
{
	int h, w;

	cin >> h >> w;

	for (int i = 0; i < w + 2; i++) {
		cout << "#";
	}
	cout << endl;

	
	for (int i = 0; i < h; i++) {
		string s;
		cin >> s;
		cout << "#" << s << "#" << endl;
	}
	for (int i = 0; i < w + 2; i++) {
		cout << "#";
	}
	cout << endl;
	

	return (0);
}

Measured memory_bytes: 256
n = int(input())
p_li = list(map(int,input().split()))
cnt = 0
for i in range(n):
    if i == 0 :
        continue
    if i == n - 1 :
        break
    original = p_li[i]
    p_i_li = [p_li[i - 1], p_li[i], p_li[i + 1]]
    p_i_li.sort()
    if p_i_li[1] == original :
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,a[100],k,zh;
int main()
{
	cin>>n>>k;
	zh=0;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	for(int i=n-1;i>n-1-k;i--)zh+=a[i];
	cout<<zh<<endl;


	return 0;
}


Measured memory_bytes: 256
K = int(input())
x = 7 % K #mod(K)
if K == 1 or K == 7:
  print(1)
  exit()
ans = 1
i = 0
while i < K:
  ans += 1
  x = (x * 10 + 7) % K
  
  
  if x == 0:
    print(ans)
    exit()
  i += 1
print('-1')

Measured memory_bytes: 9196
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)

if min(a) == 0:
    print(0)
    exit()
else:
    ans = a[0]
    for i in range(1, n, 1):
        ans = ans * a[i]
        if ans > 1e+18:
            print(-1)
            exit()
    print(ans)

Measured memory_bytes: 21604
R=[int(input()) for i in range(5)]
r=[]
p=10
for i in range(5):
    if R[i] % 10 != 0:
        p = min(p,R[i]%10)
ans = 0
for i in range(5):
    if R[i] % 10 != 0:
        if R[i] % 10 == p:
          ans += R[i]
          p = 10
        else:
          ans += R[i] - R[i] % 10 + 10
    else:
        ans += R[i]
print(ans)

Measured memory_bytes: 9140
import java.util.*;
public class Main {
	Scanner in = new Scanner(System.in);
	public static void main(String[] args) {
		new Main();
	}

	public Main() {
		while(in.hasNext())new AOJ0031().doIt();
	}
	class AOJ0031{
		void doIt(){
			int n = in.nextInt();
			ArrayList<Integer> list = new ArrayList<Integer>(); 
			for(int i=0;i<10;i++){
				if((n>>i)%2==1)list.add(1<<i);
			}
			System.out.print(list.get(0));
			for(int i=1;i<list.size();i++)System.out.print(" "+list.get(i));
			System.out.println();
		}
	}
}

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

using namespace std;

long long arr[100];
const int mod = 1e9 + 7;

int main(){
    int N, diff = 0;
    string S;
    cin >> N;
    cin >> S;
    for(int i=0; i<S.length(); i++){
        arr[S[i] - 96]++;
        if(arr[S[i] - 96] == 1) diff++ ;
    }
    long long ans = 1;
    for(int i=1; i<=26; i++){
        ans*= arr[i] + 1;
        ans = ans % mod;
    }
    cout << ans - 1 << endl;
}

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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){ if(a < b) { a = b; return true;} return false;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}

template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
  for(auto &e:t) fill_v(e,v);
}


const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

// 尺取り法
int main(){
  int n;
  cin >> n;

  vector<ll> a(n);
  REP(i, n) cin >> a[i];

  vector<ll> a_sum(n + 1, 0), a_xor(n + 1, 0);
  REP(i, n) {
    a_sum[i + 1] = a_sum[i] + a[i];
    a_xor[i + 1] = (a_xor[i] ^ a[i]);
  }

  ll ans = 0;
  REP(s, n) {
    int l = s, r = n + 1;

    while(r - l > 1){
      int m = (r + l) / 2;
      if(a_sum[m] - a_sum[s] == (a_xor[m] ^ a_xor[s])) l = m;
      else r = m;
    }

    ans += l - s;
  }

  pl(ans)

  return 0;
}

Measured memory_bytes: 4992
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 == 0 && W == 0) break;

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

Measured memory_bytes: 35976
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k,sum=0;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    sort(a,a+n);
    for(int i=0;i<k;i++)
    {
        sum+=a[i];
    }
    cout<<sum;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
using namespace std;
int main() {
    int a, b, k;
    cin >> a >> b >> k;
    if(b-a+1>=k*2) {
        for(int i=a; i<a+k; i++) cout << i << endl;
        for(int i=b-k+1; i<=b; i++) cout << i << endl;    
    } else {
        for(int i=a; i<=b; i++) cout << i << endl;
    }


    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict

n = int(input())
a = list(map(int, input().split()))
q = int(input())
x = [list(map(int, input().split())) for _ in range(q)]

s = sum(a)
d = defaultdict(int)
for ai in a:
    d[ai] += 1

for xi in x:
    b, c = xi
    s += d[b] * (c - b)
    print(s)
    d[c] += d[b]
    d[b] = 0


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

int main() {
    int n,count = 0;
    cin >> n;
    for (int i = 1; i < n+1; i++){
        string s = to_string(i);
        if(!(s.size() % 2 == 0))count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
/*  CREATED BY
    Stream_Cipher
    13-sep-2020
*/
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define double long double
#define debug1(a) cout<<#a<<"="<<(a)<<"\n"
#define debug2(a,b) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<"\n"
#define debug3(a,b,c) cout<<#a<<"="<<(a)<<","<<#b<<"="<<(b)<<","<<#c<<"="<<(c)<<"\n"
#define fix_precision(n) cout<<fixed<<setprecision(n)
#define all(a) a.begin(),a.end()
const double pi=acos(-1.0);
int inf=0x3f3f3f3f3f3f3f3f;
const int mod=1e9+7;
const int mx=5*1000000;//5*64M bit ->5*8M byte ->40MB size for long long int (64 bit)
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
        int a,b,c;
        cin>>a>>b>>c;
        int ans=ceil((double)a/(double)b)*c;
        cout<<ans<<endl;
}

Measured memory_bytes: 3612
<?php
 
$nm = explode(' ', trim(fgets(STDIN)));
$n = $nm[0];
$m = $nm[1];

for($i=0; $i<$n; $i++){
  $a[$i] = str_split(trim(fgets(STDIN)));
}

for($i=0; $i<$m; $i++){
  $b[$i] = str_split(trim(fgets(STDIN)));
}


$ans = 'No';
for($i=0; $i<=$n-$m; $i++){
   for($j=0; $j<=$n-$m; $j++){
     
     $c = 0;
     for($k=0; $k<$m; $k++){
       for($l=0; $l<$m; $l++){
          if($a[$i+$k][$j+$l] == $b[$k][$l]) {
            $c++;   
          }
       }   
     }    
     
	if ($c == $m*$m) $ans = 'Yes';
  } 
}
  

echo $ans;

?>

Measured memory_bytes: 4604
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

func scanString() string {
	sc.Scan()
	return sc.Text()
}

func scanInts(n int) []int {
	sl := make([]int, n)
	for i := range sl {
		sl[i] = scanInt()
	}
	return sl
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	as := scanInts(n)

	var sum int
	for _, a := range as {
		sum += a - 1
	}

	fmt.Println(sum)
}


Measured memory_bytes: 1796
#include <iostream>
#include <stdio.h>

#define rep(i,min,sup) for(int i=min;i<sup;i++)
#define per(i,min,sup) for(int i=(sup-1);i>=min;i--)
#define ll long long

using namespace std;
main(){
  int K,N;
  scanf("%d %d",&K,&N);
  int A[N];
  rep(i,0,N){
    scanf("%d",&A[i]);
  }
  int maxgap=0,gap;
  rep(i,0,N-1){
    gap=A[i+1]-A[i];
    if(maxgap<gap)maxgap=gap;
  }
  gap=A[0]+K-A[N-1];
  if(maxgap<gap)maxgap=gap;
  printf("%d",K-maxgap);
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)(n-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long 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<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

struct StronglyConnectedComponents{
    int n;
    vvi graph;
    vvi gg, rg;
    vi comp, order, used;

    StronglyConnectedComponents(vvi &g): n(g.size()), gg(n), rg(n), comp(n, -1), used(n){
        rep(i,n){
            for(auto to : g[i]){
                gg[i].push_back(to);
                rg[to].push_back(i);
            }
        }
        build(graph);
    }
    int operator[](int k){
        return comp[k];
    }
    void dfs(int v){
        if(used[v]) return;
        used[v] = true;
        for(auto u : gg[v]) dfs(u);
        order.push_back(v);
    }
    void rdfs(int v, int cnt){
        if(comp[v] != -1) return;
        comp[v] = cnt;
        for(auto u : rg[v]) rdfs(u, cnt);
    }
    void build(vvi &t){
        rep(i,n) dfs(i);
        reverse(all(order));
        int ptr = 0;
        for(auto i : order) if(comp[i] == -1) rdfs(i, ptr), ptr++;

        t.resize(ptr);
        rep(i,n){
            for(auto to : gg[i]){
                int x = comp[i], y = comp[to];
                if(x == y) continue;
                t[x].push_back(y);
            }
        }
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int V,E; cin >> V >> E;
    vvi g(V);
    rep(i,E){
        int s,t; cin >> s >> t;
        g[s].push_back(t);
    }
    auto scc = StronglyConnectedComponents(g);
    int q; cin >> q;
    rep(i,q){
        int u,v; cin >> u >> v;
        if(scc[u] == scc[v]) cout << 1 << endl;
        else cout << 0 << endl;
    }
    return 0;
}


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

char str[444444];
char str2[444444];

int cnt[256];

int main()
{
	scanf("%s", str);
	int len = strlen(str);
	long long ans = len * (len - 1LL) / 2 + 1;

	for (int i = 0; i < len; i++) cnt[str[i]]++;
	for (int i = 'a'; i <= 'z'; i++) ans -= cnt[i] * (cnt[i] - 1LL) / 2;

	printf("%lld\n", ans);
}


Measured memory_bytes: 384
#include<stdio.h>
int main()
{
    long long n,k,a;
    scanf("%lld%lld",&n,&k);
    a=n%k;
    if(a < k-a)
    {
        printf("%lld\n",a);
    }
    else
    {
        printf("%lld\n",(k-a));
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

int main(void){
  int N;
  int flag = 1;
  int count = 0;

  cin >> N;
  int a[N];

  for (int i=0; i<N; i++){
    cin >> a[i];
  }

  while(1){
    for(int i=0; i<N; i++){
      if(a[i]%2==1){
        flag = 0;
      }
    }
    if(flag == 1){
      for (int i=0; i<N; i++){
        a[i] = a[i]/2;
      }
      count++;
    } else {
      break;
    }
  }
  cout << count << endl;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstdint>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

set<ll> divisor(ll n) {
    set<ll> ret;
    for(ll i = 1; i * i <= n; i++) {
        if(n % i == 0) {
            ret.insert(i);
            if(i * i != n)
                ret.insert(n / i);
        }
    }
    return ret;
}

int main() {
    ll N;
    cin >> N;
    auto div = divisor(N);
    ll sum = 0;
    for(auto x : div) {
        if(x != 1 && N % (x - 1) != N / (x - 1))
            continue;
        sum += x - 1;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;

int main() {
	int n, k, x, y;
	cin >> n >> k >> x >> y;
	int ans = 0;
	for (int i = 1; i < n + 1; i++) {
		if (i <= k) {
			ans += x;
		} else {
			ans += y;
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
	string S, T;
	cin >> S >> T;

	int ans = 0;
	for (int i = 0; i < 3; ++i) {
		if (S[i] == T[i])
			++ans;
	}

	cout << ans << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    int a,b,c,d;
    while(cin>>a>>b>>c>>d){
        while(c>0 || a>0){
            c=c-b;
            if(c<=0){
                cout<<"Yes"<<endl;
                break;
            }
            a=a-d;
            if(a<=0){
                cout<<"No"<<endl;
                break;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3620