akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	int N;
	cin >> N;
	
	vector<int> A(N);
	int res1 = 0;
	int res2 = 0;
	map<int, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		mp[A[i]]++;
		if (mp[A[i]] % 2 == 0) {
			if (res2 < A[i]) {
				res2 = A[i];
				if (res2 > res1) {
					swap(res1, res2);
				}
			}
		}
	}
	cout << (res1*res2) << endl;
	return 0;
	
}

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

int N, A, B, C;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int a[10];
    cin >>  a[0] >> a[1] >> a[2];
    sort(a, a+3);
    int x = a[2] - a[0];
    int y = a[2] - a[1];
    if (x%2 == 0 && y %2 == 0) {
        cout << x/2 + y/2;
        return 0;
    }
    if (x % 2 == 0 || y % 2 ==0) {
        cout << (x+1)/2 + (y+1)/2 + 1;
        return 0;
    }
    else {
        cout << x/2 + y/2 + 1;
        return 0;
    }
    
    
   
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

typedef long double ld;
const ld eps = 1.0e-10; // 許容される誤差

int64 gcd(int64 a, int64 b) { return b? gcd(b,a%b):a; }; int64 lcm(int64 a, int64 b) { return a/gcd(a,b)*b; };


int main() {
    int64 a,b,c;
    cin >> a >> b >> c;
    int64 GCD = gcd(a,b);
    GCD = gcd(GCD, c);
    a /= GCD;
    b /= GCD;
    c /= GCD;

    if ( sqrt((ld)a) + sqrt((ld)b) < sqrt((ld)c) ) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

ll gcd(ll m, ll n) {
    if (n == 0) return m;
    return gcd(n, m % n);
}

ll lcm(ll m, ll n) {
    return (m*n)/gcd(m, n);
}

void solve() {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll range = b-a+1;
    ll lcmcd = lcm(c, d);
    ll divByC = b/c-(a-1)/c;
    ll divByD = b/d-(a-1)/d;
    ll divByBoth = b/lcmcd-(a-1)/lcmcd;
    cout << range - divByC - divByD + divByBoth;
}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d %d %d', $n, $m, $l);

for ($i = 0; $i < ($n + $m); $i++) {
    if ($i < $n) {
        $A[] = explode(' ', trim(fgets(STDIN)));
    } else {
        $B[] = explode(' ', trim(fgets(STDIN)));
    }
}

for ($i = 0; $i < $n; $i++) {
    for ($j = 0; $j < $l; $j++) {
        $C[$i][$j] = 0;
        for ($k = 0; $k < $m; $k++) {
            $C[$i][$j] += memoizeProduct($A, $B, $i, $j, $k);
        }
    }
    $result[] = implode(' ', $C[$i]);
}

echo implode(PHP_EOL, $result), PHP_EOL;

function memoizeProduct($A, $B, $i, $j, $k)
{
    static $memo;

    if (isset($memo[$i][$j][$k])) {
        return $memo[$i][$j][$k];
    }

    $memo[$i][$j][$k] = $A[$i][$k] * $B[$k][$j];

    return $memo[$i][$j][$k];
}

Measured memory_bytes: 157548
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <vector>
#define loop(n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;


int main()
{
    fastio;
    ll n;
    cin>>n;
    ll arr[n];
    for(ll i=0;i<n;i++)
		cin>>arr[i];
	
	ll dp[n];
	dp[0] = 0;
	dp[1] = abs(arr[1] - arr[0]);
	for(ll i=2;i<n;i++)
	{
		dp[i] = min(abs(arr[i] - arr[i-2]) + dp[i-2],abs(arr[i] - arr[i-1]) + dp[i-1]);
	}
	cout<<dp[n-1]<<endl;
	
    return 0;
}


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

int main(){
  int x,y,z;
  cin >> x >> y >> z;
  if((x!=5&&x!=7)||
     (y!=5&&y!=7)||
     (z!=5&&z!=7)||
     (x+y+z!=17)){
    cout << "NO" << endl;
    return 0;
  }
  cout << "YES" << endl;
  return 0;
}

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    int n,k;
    cin>>n>>k;
    int mp[n+1];
    MEM(mp,0);
    for(int i=0;i<k;i++)
    {
        int p;
        cin>>p;
        for(int j=0;j<p;j++)
        {
            int x;
            cin>>x;
            mp[x]++;
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]==0)cnt++;
    }
    cout<<cnt;

}


Measured memory_bytes: 3620
#include<iostream>
#include<algorithm>
#include<stack>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	string S;

	cin >> N >> S;

	stack<char> s;
	int left=0;
	int right=0;
	for(int i=0;i<N;i++)
	{
		if(S[i]=='(')
			s.push(S[i]);
		else
		{
			if(!s.empty() && s.top()=='(')
				s.pop();
			else
				left++;
		}
	}
	right=s.size();

	string ans="";
	for(int i=0;i<left;i++)
		ans+='(';
	ans+=S;
	for(int i=0;i<right;i++)
		ans+=')';
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from collections import Counter

    n = int(readline())
    s = input()
    cur = Counter(s)

    for i in range(n - 1):
        s = input()
        nx = Counter(s)
        cur = cur & nx

    a = list(cur.elements())
    a.sort()

    print("".join(a))


if __name__ == '__main__':
    main()


Measured memory_bytes: 68400
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LONG_LONG_MAX / 2;
const ll mod = 1000000000 + 7;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  int N;
  cin >> N;
  for (int i = N; i < 1000; i++) {
    string s = to_string(i);
    if (s[0] == s[1] && s[1] == s[2]) {
      cout << i << endl;
      return 0;
    }
  }
}


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

int main() {
   ll N;
   cin >> N;
   vector<ll> A(N);
   for(int i = 0; i < N; i++){
       cin >> A.at(i);
   }
   vector<ll> B(N);
   ll ans = 0;
   for(int i = 0; i < N-1; i++){
       if(A.at(i) > A.at(i+1)){
           ans += A.at(i) - A.at(i+1);
           A.at(i+1) = A.at(i);
       }
   }
   cout << ans << endl;
}

Measured memory_bytes: 6356
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};

int main() {

	string s,t;

	cin>>s;
	cin>>t;

	rep(i,s.size()){
		if(s[i]==t[0]){
			int r=1,f=0;
			for(int j=i+1; j<s.size(); j++){
				if(s[j]!=t[r])f=1;
				r++;
			}
			rep(k,i){
				if(s[k]!=t[r])f=1;
				r++;
			}
			if(f==0){
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    ll K, N;
    cin >> K >> N;
    vector<ll> a(N);
    rep(i, N)
    {
        cin >> a.at(i);
    }
    ll big = K + a.at(0) - a.at(N - 1);
    rep(i, N - 1)
    {
        ll dis = a.at(i + 1) - a.at(i);
        big = max(big, dis);
    }
    cout << K - big << endl;
}

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

int main() {
	// your code goes here
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n,i,j,k;
	cin>>n>>k;
	int h[n];
	for(i=0;i<n;i++)
	cin>>h[i];

	int dp[n];
	dp[0]=0;
	for(i=1;i<n;i++)
	dp[i]=INT_MAX;
	
	for(i=0;i<n;i++)
	{
	
		for(j=1;j<=k;j++)
		{
			if(i+j<n)
			{
				dp[i+j]=min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
				
			}
		}
		
	}

	
	cout<<dp[n-1];
	
	
	return 0;
}


Measured memory_bytes: 1024
#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<algorithm>
#include<iostream>
#include<cstring>
#include<fstream>
#include<bitset>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
#define INF 0X3F3F3F3F
#define N 100005
#define M 200005
#define LL long long
#define FF(i, a, b) for(int i = a; i <= b; ++i)
#define RR(i, a, b) for(int i = a; i >= b; --i)
#define FJ(i, a, b) for(int i = a; i < b; ++i)
#define SC(x) scanf("%d", &x)
#define SCC(x, y) scanf("%d%d", &x, &y)
#define SCCC(x, y, z) scanf("%d%d%d", &x, &y, &z)
#define SS(x) scanf("%s", x)
#define PR(x) printf("%d\n", x)
#define CL(a, x) memset(a, x, sizeof(a))
#define _P fd[rt]
#define _L fd[rt << 1]
#define _R fd[rt << 1 | 1]
#define MID int mid = ((l + r) >> 1)
#define lson rt<<1 ,l, mid
#define rson rt<<1 | 1, mid + 1, r
#define PB push_back
#define SZ size
#define PII pair<int, int>
#define PLL pair<long long, long long>
#define MP make_pair
#define IN freopen("in.txt", "r", stdin)
#define OUT freopen("out.txt", "w", stdout)
using namespace std;
const int MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-8;
inline void II(int &n){char ch = getchar(); n = 0; bool t = 0;
for(; ch < '0'; ch = getchar()) if(ch == '-') t = 1;
for(; ch >= '0'; n = n * 10 + ch - '0', ch = getchar()); if(t) n =- n;}
inline void OO(int a){if(a < 0) {putchar('-'); a = -a;}
if(a >= 10) OO(a / 10); putchar(a % 10 + '0');}
inline int sgn(double x){return (x > EPS) - (x < -EPS);}
struct EE{int v, nx;}E[M * 2 + N * 2]; int hd[N], EN;
void init_edge(int num){EN = 0; memset(hd, -1, (num + 3) << 2);}
void add_edge(int u, int v){
    E[EN].v = v; E[EN].nx = hd[u]; hd[u] = EN++;
    E[EN].v = u; E[EN].nx = hd[v]; hd[v] = EN++;
}
int n, m, in[N], u, v;
bool vis[N];
int cnt, s[N];
int cnt2, s2[N];
void go(int u, int par){
    for(int k = hd[u]; ~k; k = E[k].nx){
        int v = E[k].v;
        if(v == par || vis[v]) continue;
        vis[v] = 1;
        s[++cnt] = v;
        go(v, u);
        break;
    }
}
void go2(int u, int par){
    for(int k = hd[u]; ~k; k = E[k].nx){
        int v = E[k].v;
        if(v == par || vis[v]) continue;
        vis[v] = 1;
        s2[++cnt2] = v;
        go2(v, u);
        break;
    }
}
int main(){
   // IN;
    SCC(n, m);
    init_edge(n);
    FF(i, 1, m){
        SCC(u, v);
        add_edge(u, v);
        ++in[u];
        ++in[v];
    }
    cnt = 0;
    if(in[1] == 1){
        vis[1] = 1;
        s[++cnt] = 1;
        go(1, 0);
        PR(cnt);
        for(int i = 1; i <= cnt; ++i) printf("%d%c", s[i], i == cnt ? '\n' : ' ');
    }else {
        vis[1] = 1;
        s[++cnt] = 1;
        go(1, 0);
        go2(1, 0);
        PR(cnt + cnt2);
        if(cnt2 == 0){
            for(int i = 1; i <= cnt; ++i) printf("%d%c", s[i], i == cnt ? '\n' : ' ');
        }else {
            for(int i = cnt2; i >= 1; --i) printf("%d ", s2[i]);
            for(int i = 1; i <= cnt; ++i) printf("%d%c", s[i], i == cnt ? '\n' : ' ');
        }
    }
    return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
const int limit=50;
int n,m;
int a[limit],b[limit];
bool graph[limit][limit];
bool visited[limit];

void dfs(int v){
  visited[v]=true;
  for(int vv=0;vv<n;vv++){
    if (graph[v][vv]==false)continue;
    if (visited[vv]==true)continue;
    dfs(vv);
  }
}

int main(void){
  	cin >>n >>m;
  for (int i=0;i<m; i++){
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  int ans=0;
  for (int i=0;i<m; i++){
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=false;
    for(int j=0;j<n;j++)visited[j]=false;
    dfs(0);
    bool bridge=false;
    for(int j=0;j<n;j++)
      if(visited[j]==false)bridge=true;
    if(bridge)ans++;
    graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;
  }
  
      cout << ans << endl;
}


Measured memory_bytes: 256
#include<cstdio>

int main(){
  int a , b;
  scanf("%d%d",&a,&b);
  int d = a / b;
  int r = a % b;
  double f = (double)a / b;
  printf("%d %d %.5f\n",d,r,f);
  
  return 0;
}



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

#define int long long int
#define rep(a,b,c) for(int a=b;a<c;a++)
#define repm(a,b,c) for(int a=(b-1);a>=c;a--)
#define pb push_back
#define str string
#define sf(a) scanfs("%d",&a)
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define clean(used) memset(used,false,sizeof(used))
using namespace std;

const int INF = 1e18 + 9;
const int Mod = 1e9 + 7;
inline int replac(str s){double ans=0;rep(i,0,s.length()){ans+=(s[i]-'0')*pow(10,s.length()-i-1);}return (int)ans;}
inline string numstr(int m){str s="";while(m>0){char c;int a=m/10;if(a>0)a=m%(a*10);else a=m;c=(char)('0'+a);s+=c;m/=10;}str st="";for(int i=s.size()-1;i>=0;i--){st+=s[i];}return st;}
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector<pii> vii;
int h,a[200],s;
int me[200][2];
int f(int num,int sum){
    if(num >= s)return 0;
    else if(me[num][sum]>=0){
        return me[num][sum];
    }
    else{
        if((sum+a[num])%2 == h){
            return me[num][sum] = f(num+1,(sum+a[num])%2)+f(num+1,sum)+1;
        }else{
            return me[num][sum] = f(num+1,(sum+a[num])%2)+f(num+1,sum);
        }
    }
}
signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    rep(i,0,200){
        rep(j,0,2){
            me[i][j]=-1;
        }
    }
    cin >> s;
    cin >> h;
    if(h > 1){
        cout << 0 << endl;
        return 0;
    }
    rep(i,0,s){
        cin >> a[i];
    }
    int ans = 0;
    ans = f(0,0);
    if(h==0)ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long dp[3003][3003][4];
long long v[3003][3003];
int main() {
	int R, C, K;
	cin >> R >> C >> K;
	for (int i = 0; i < K; ++i) {
		long long x, y, z;
		cin >> x >> y >> z;
		x--;
		y--;
		v[x][y] = z;
	}
	dp[0][0][1] = v[0][0];
	for (int i = 0; i < R; ++i) {
		for (int j = 0; j < C; ++j) {
			for (int k = 0; k < 4; ++k) {
				dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
				dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][k]);
				//?
				//?
			}
			if (0 != v[i][j + 1]) {
				for (int k = 0; k < 3; ++k) {
					dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + v[i][j + 1]);
				}
			}
			if (0 != v[i + 1][j]) {
				for (int k = 0; k < 4; ++k) {
					dp[i + 1][j][1] = max(dp[i + 1][j][1], dp[i][j][k] + v[i + 1][j]);
				}
			}
		}
	}
	/*
	for (int i = 0; i < R; ++i) {
		for (int j = 0; j < C; ++j) {
			cout << dp[i][j][0] << "_"<<dp[i][j][1] << "_"<<dp[i][j][2] <<"_"<<dp[i][j][3] << endl;
		}
	}*/
	long long ans = max(dp[R - 1][C - 1][0], max(dp[R - 1][C - 1][1], max(dp[R - 1][C - 1][2], dp[R - 1][C - 1][3])));
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 355380
# AtCoder Beginner Contest 050 - B
# -*- encoding: UTF-8 -*-
n = int(input())
tlist = list(map(int, input().split()))
m = int(input())
mlist = []
for i in range(m):
  p_x = list(map(int, input().split()))
  mlist.append(p_x)

base = 0
for i in tlist:
  base = base + i

for p_x in mlist:
  p, x = p_x
  s = x - tlist[p-1]
  print(base + s)



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

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  int n; cin >> n;
  string s[2 * n];
  for (int i = 0; i < n; i++) {
    cin >> s[i];
    s[i] += s[i];
    s[n + i] = s[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++) {
    bool b = 1;
    for (int j = 0; j < n - 1; j++) {
      for (int k = j + 1; k < n; k++) {
        if (s[i + j][k] != s[i + k][j]) {
          b = 0;
          break;
        }
      }
    }
    res += n * b;
  }
  cout << res << "\n";
  return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = (1LL<<60);
constexpr ll MOD = (1e9+7);
//constexpr ll MOD = (998244353);
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(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

template<typename T>T gcd(T a,T b){while(1){swap(a,b);if(a==0)return b;if(b==0)return a;a%=b;}}

signed main(){

  ll n,k;
  cin>>n>>k;
  if(n%k==0){
    cout<< 0 <<endl;
    exit(0);
  }
  set<ll> st;
  st.emplace(n);
  while(1){
    if(n>k)n %= k;
    else n = abs(n-k);
    if(st.find(n)!=end(st))break;
    st.emplace(n);
    st.emplace(n%k);
  }
  cout<<*begin(st)<<endl;

}

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

int main(){
  string S,T;
  cin >> S >> T;
  set<char> s,t;
  map<char,char> m;
  for(int i=0;i<S.size();i++){
    s.insert(S.at(i));
    t.insert(T.at(i));
    if(m.count(S.at(i))){
      if(m.at(S.at(i))!=T.at(i)){
        cout << "No" << endl;
        return 0;
      }
    }else{
      m[S.at(i)]=T.at(i);
    }
  }
  if(s.size()==t.size()){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
typedef pair <int,int> pii;
typedef queue <int> Que;

const int RLEN=1<<18|1;
inline char nc() {
	static char ibuf[RLEN],*ib,*ob;
	(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
	return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
	char ch=nc(); int i=0,f=1;
	while(!isdigit(ch)) {if(ch=='-')f=-1; ch=nc();}
	while(isdigit(ch)) {i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
	return i*f;
}

const int N=2e3+50;
int n,vis[N],a[N];
vector <int> edge[N];

inline Que dfs(int x) {
	vis[x]=1;
	vector <Que> q;
	priority_queue <pii> q2;
	
	for(int e=0;e<edge[x].size();e++) {
		int v=edge[x][e]; if(vis[v]) continue;
		q.push_back(dfs(v));
	}
	
	Que now; now.push(x);
	for(int i=0;i<q.size();++i) q2.push(pii(q[i].front(),i));
	
	while(!q2.empty()) {
		int u=q2.top().second; q2.pop();
		now.push(q[u].front());
		q[u].pop();
		if(!q[u].empty()) q2.push(pii(q[u].front(),u));
 	}
 	
 	return now;
}
int main() {
	n=rd();
	for(int i=1;i<=n;i++) a[i]=rd();
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			if(__gcd(a[i],a[j])!=1) edge[i].push_back(j), edge[j].push_back(i);
	for(int i=1;i<=n;i++) sort(edge[i].begin(),edge[i].end()), edge[0].push_back(i);
	Que tq=dfs(0);
	while(!tq.empty()) {
		int u=tq.front(); tq.pop();
		if(u) cout<<a[u]<<' ';
	}
}

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

int main()
{ 
  int n, m, k, a, ans = 0;
  vector<int> a_sum(31, 0);

  cin >> n >> m;
  for (int i = 0; i < n; i++)
  {
    cin >> k;
    for (int j = 0; j < k; j++)
    {
      cin >> a;
      a_sum[a]++;
    }
  }
  for (int i = 1; i <= m; i++)
  {
    if (a_sum[i] == n)
      ans++;
  }
  cout << ans << endl;
}

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

int main(){
    int w,h,x,y;
    cin >> w >> h >> x >> y;
    long double s = (double)w / 2.0 * (double)h;
    int ism = ((x+x == w) && (y+y == h)) ? 1 : 0;
    cout << fixed << setprecision(10) << s;
    cout <<  " " << ism << endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#define mid (L+R>>1)
using namespace std;
const int maxm=200005;
int n,m,a[maxm];
inline char nc(){
	static char buf[100000],*p1=buf,*p2=buf;
	return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
inline int read(){
	int ret=0;bool f=0;char ch=nc();
	while(ch>'9'||ch<'0') f^=ch=='-',ch=nc();
	while(ch<='9'&&ch>='0') ret=ret*10+ch-'0',ch=nc();
	return f?-ret:ret;
}
bool check(int x){
	int now=a[n]<x;
	for (int i=n-1,j=n+1;i;i--,j++,now^=1)
	if((a[i]>=x)!=now||(a[j]>=x)!=now) break;
	return !now;
}
int main(){
	n=read(),m=(n<<1)-1;
	for (int i=1;i<=m;i++) a[i]=read();
	int L=1,R=m;
	while(L<=R) if(check(mid)) L=mid+1;else R=mid-1;
	printf("%d\n",R);
	return 0;
}

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

int main()
{
    int n, a;
    
    cin >> n >> a;
    
    if((n%500) <= a) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    
    return 0;
}

Measured memory_bytes: 764
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;

// 座標構造体
typedef struct point {
    double x, y;
} POINT;
// 座標間の距離
double length(POINT *a, POINT *b) {
    double x_def = pow(fabs(a->x - b->x), 2);
    double y_def = pow(fabs(a->y - b->y), 2);

    return sqrt(x_def + y_def);
}
// 道筋
int fact(int n) {
    if(n == 1)
        return 1;
    return n * fact(n - 1);
}

int main() {
    int N;
    cin >> N;
    POINT city[N];
    rep(i, N) { cin >> city[i].x >> city[i].y; }
    int route = fact(N);
    int comb = N * (N - 1) / 2;
    int edge = (N - 1) * route / comb;
    // cout << "route= " << route << endl;
    // cout << "エッジの組み合わせ= " << comb << endl;
    // cout << "各エッジの本数= " << edge << endl;

    double part_of_length = 0.0;
    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            part_of_length += length(&city[i], &city[j]);
        }
    }

    double total_length = part_of_length * (double)edge;

    cout << fixed << setprecision(15) << total_length / (double)route << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<int>x[10]; int a, b, c, d; string S, T;
int main() {
	while (true) {
		cin >> S; int p = 0; if (S == "#")break; cin >> a >> b >> c >> d; a--; b--; c--; d--; S += '/';
		for (int i = 0; i < S.size(); i++) {
			if (S[i] == '/') {
				for (int j = 0; j < T.size(); j++) { 
					if (T[j] == 'b')x[p].push_back(1);
					else { for (int k = 0; k < (T[j] - '0'); k++)x[p].push_back(0); }
				}
				p++; T = "";
			}
			else { T += S[i]; }
		}
		swap(x[a][b], x[c][d]);
		for (int i = 0; i < p; i++) {
			int c = 0;
			for (int j = 0; j < x[i].size(); j++) {
				if (x[i][j] == 0) { c++; }
				if (x[i][j] == 0 && (j == x[i].size() - 1 || x[i][j + 1] == 1)) { cout << c; c = 0; }
				if (x[i][j] == 1)cout << 'b';
			}
			if (i < p - 1)cout << '/';
		}
		cout << endl; for (int i = 0; i < 10; i++)x[i].clear();
	}
	return 0;
}

Measured memory_bytes: 3044
#include<stdio.h>

int main(){
    int a, b;
    scanf("%d %d", &a ,&b);
    while(!(a==0&&b==0)){
        for(int i=0; i<a; i++){
            for(int j=0; j<b; j++){
                if(i==0||j==0||i==a-1||j==b-1)
                printf("#");
                else printf(".");
            }
            puts("");
        }
        printf("\n");
         scanf("%d %d", &a ,&b);
    }
    
}


Measured memory_bytes: 1980
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  while (k && a >= b) {
    b *= 2;
    k--;
  }
  while (k && b >= c) {
    c *= 2;
    k--;
  }
  cout << ((a < b && b < c) ? "Yes" : "No") << endl;
  return 0;
}

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

int main(){
    while(1){
        int h,w;
        cin >> h >> w;
        if(h==0) break;
        
        for(int i=1; i<=h; i++){
            for(int j=1; j<=w; j++){
                if(i==1 || j==1 || i==h || j==w){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}



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

int a[10];
int N,A,B,C,ans;

void dfs(int now, int sa, int sb, int sc, int na, int nb, int nc) {
    if (now > N) {
        if (na > 0 && nb > 0 && nc > 0) {
            int cost = (na + nb + nc - 3) * 10;
            cost += abs(sa - A) + abs(sb - B) + abs(sc - C);
            ans = min(ans, cost);
        }
        return;
    }
    dfs(now + 1, sa, sb, sc, na, nb, nc);
    dfs(now + 1, sa + a[now], sb, sc, na + 1, nb, nc);
    dfs(now + 1, sa, sb + a[now], sc, na, nb + 1, nc);
    dfs(now + 1, sa, sb, sc + a[now], na, nb, nc + 1);
}

int main(){
    cin>>N>>A>>B>>C;
    for(int i = 1; i <= N; i++)
        cin>>a[i];
    ans=1000000000;
    dfs(1,0,0,0,0,0,0);
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
  Krishnakant Tiwari
  Problem Link:

 */
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
using namespace std;
typedef long long ll;
#define _cin      ios_base::sync_with_stdio(0);  cin.tie(0);
#define endl "\n"
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define repd(i,a,b) for(ll i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define vvll vector<vector<ll> >
#define vll vector<ll>
#define mll map<ll,ll>
#define sz(x) (ll)x.size()
#define sll set<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define eb	emplace_back
#define ppb	pop_back
#define pf	push_front
#define ppf	pop_front
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for (auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define precise(x)	cout<<fixed<<setprecision(x)
const ll MAX = 1000004;
const ll INF = 1e18L + 5;
template <class T, class U>
void chmin(T &t, const U &u)
{
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T &t, const U &u)
{
    if (t < u) t = u;
}
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << " " << H;
    debug_out(T...);
}
template <typename Arg1>
void pn(Arg1 &&arg1)
{
    cout << arg1 << "\n";
}
template <typename Arg1, typename... Args>
void pn(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << "\n";
    pn(args...);
}
template <typename Arg1>
void ps(Arg1 &&arg1)
{
    cout << arg1 << " ";
}
template <typename Arg1, typename... Args>
void ps(Arg1 &&arg1, Args &&... args)
{
    cout << arg1 << " ";
    ps(args...);
}
template <typename Arg1>
void read(Arg1 &&arg1)
{
    cin >> arg1;
}
template <typename Arg1, typename... Args>
void read(Arg1 &&arg1, Args &&... args)
{
    cin >> arg1;
    read(args...);
}

ll g[MAX];
ll a[MAX];

void solve()
{
	
	string s,t;
	read(s,t);
	ll match=0,edit=LONG_MAX;
	bool valid=true;
	ll n=s.length(),m=t.length();
	rep(i,0,n){
		match=0;
		valid=true;
		rep(j,0,m){
			if(i+j<n){
				if(s[i+j]==t[j]) match++;
			}else{
				valid=false;
				break;
			}
		}
		if(valid){
			chmin(edit,m-match);
		}else break;
	}
	pn(edit);


}


int main()
{

    _cin
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
#endif
    // ll tc;
    // cin>>tc;
    // while(tc--){
    solve();
    // }

}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main () {
  int A, B, C;
  cin >> A >> B >> C;
  if(A > B)swap(A, B);
  if(A < C && B > C)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) throws Exception {

    
        Scanner sc = new Scanner(System.in);

        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble();//
        double x2 = sc.nextDouble();// 
        double y2 = sc.nextDouble();//
    
//protected double getDistance(double x1,double y1,double x2,double y2){
        double distance = Math.sqrt((x2-x1) * (x2-x1) + (y2 - y1) * (y2 -y1));
  //public static double distance(x1,y1,x2,y2);
  //      return (double)distance;
  //       System.out.println((double)distance);
             System.out.println(String.format("%.8f",distance));
//System.out.println(String.format("%.8f", a));
    }
}



Measured memory_bytes: 28080
from collections import Counter


def solve(H, W, N, ABs):
    total = (H - 2) * (W - 2)
    points = {}
    for a, b in ABs:
        a -= 1
        b -= 1
        for i in [-1, 0, 1]:
            for j in [-1, 0, 1]:
                if 0 < a + i < H - 1 and 0 < b + j < W - 1:
                    d = (a + i, b + j)
                    if d not in points:
                        points[d] = 0
                    points[d] += 1
    c = Counter([v for v in points.values()])
    ans = [total - len(points)] + [c[f] if f in c else 0 for f in range(1, 10)]
    return "\n".join([str(a) for a in ans])

if __name__ == "__main__":
    H, W, N = map(int, input().split(" "))
    ABs = [tuple(map(int, input().split(" "))) for _ in range(N)]
    print(solve(H, W, N, ABs))


Measured memory_bytes: 189304
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define p_b push_back
#define pl pair<ll,ll>
#define m_p make_pair
#define MOD 1000000007
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,a,b) for(i=a;i>=b;i--)
#define nfs ios_base::sync_with_stdio(false);cin.tie(NULL)

string longestRepeatedSubstring(string str)
{
    int n = str.length();
    int yay[n+5][n+5];


    memset(yay, 0, sizeof(yay));

    string res = "";
    int r_l  = 0;

    int i, idx = 0;
    for (i=1; i<=n; i++)
    {
        for (int j=i+1; j<=n; j++)
        {
            if (str[i-1] == str[j-1] &&
                yay[i-1][j-1] < (j - i))
            {
                yay[i][j] = yay[i-1][j-1] + 1;

                if (yay[i][j] > r_l)
                {
                    r_l = yay[i][j];
                    idx = max(i, idx);
                }
            }
            else
                yay[i][j] = 0;
        }
    }


    if (r_l > 0)
        for (i = idx - r_l + 1; i <= idx; i++)
            res.push_back(str[i-1]);

    return res;
}

ll arr[26] ;
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll is_diff = 0;
    ll i;

    for(i=0;i<n;i++)
    {
        arr[s[i] - 'a']++;
        if(arr[s[i]-'a'] > 1)
        {

            is_diff = 1;
            break;
        }

    }
    if(is_diff==0)
    {

        cout << 0 << endl;
        return 0;

    }
    cout << longestRepeatedSubstring(s).size() << endl;
    return 0;
}


Measured memory_bytes: 98176
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,M,K=1,C;
char A,B;
ll T,a,b;
double v[55],D[55],Q,l,r;
ll ans;
//bool D[100005];
ll S[50][50]={};
string str1[55],str2="abcdefghijklmnopqrstuvwxyz";
map<string,int> m;

int main(){
	cin>>A>>B;
	if(A==B){
		cout<<"H"<<endl;
	}else cout<<"D"<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; 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(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define EPS (1e-10)
#define equals(a, b) (fabs((a)-(b)) < EPS)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int h1,m1,h2,m2,K;
  cin >> h1 >> m1 >> h2 >> m2 >> K;
  int a = h1*60+m1;
  int b = h2*60+m2;
  cout << b-a-K << endl;
  return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int a[105];

int main() {
  int x;
  cin>>x;
  int n;
  cin>>n;
  for(int i=1;i<=n;i++) {
    cin>>a[i];
  }
  int upper=-0x3f3f3f3f;
  for(int i=0;i<=n+5;i++) {
    bool f=0;
    for(int j=1;j<=n;j++) {
      if(a[j]==x+i) {
        f=1;
        break;
      }
    }
    if(!f) {
      upper=x+i;
      break;
    }
  }
  int lower=-0x3f3f3f3f;
  for(int i=0;i<=n+5;i++) {
    bool f=0;
    for(int j=1;j<=n;j++) {
      if(a[j]==x-i) {
        f=1;
        break;
      }
    }
    if(!f) {
      lower=x-i;
      break;
    }
  }
  //cout<<lower<<' '<<upper<<endl;
  if(upper-x<x-lower) {
  	cout<<upper;
  }else {
  	cout<<lower;
  }
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A < C && C<B){
    cout << "Yes" <<endl;
  }
  else if (A >C && C >B){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
#define YN(a) if(a){cout<<"Yes"<<endl;}else cout<<"No"<<endl;//条件によってYes、Noを出力する

int main(){
    int64_t h,w;
    cin>>h>>w;
    if(h%3==0 || w%3==0){
        cout<<0<<endl;
        return 0;
    }
    //3で割れない場合
    int Min = min(h,w);
    //そのまんま横or縦に切った場合
    int64_t s = h*w;
    for(int i=1;i<h;i++){
        int64_t sa;
        if(w%2==0){
            sa=abs(w*i-(w/2)*(h-i));
        }
        else{
            int64_t a,b,c;
            a = w*i;
            b = (w/2)*(h-i);
            c = (w/2+1)*(h-i);
            sa = max(a,max(b,c)) - min(a,min(b,c));
        }
        if(sa<Min){
            Min = sa;
        }
    }
    for(int i=1;i<=w;i++){
        int64_t sa;
        if(h%2==0){
            sa=abs(h*i - (h/2)*(w-i));
        }
        else{
            int64_t a,b,c;
            a = h*i;
            b = (h/2)*(w-i);
            c = (h/2+1)*(w-i);
            sa = max(a,max(b,c))-min(a,min(b,c));
        }
        if(sa<Min){
            Min = sa;
        }
    }
    cout<<Min<<endl;
}

Measured memory_bytes: 256
#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 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 VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<(_loop_int)v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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

map< int64_t, int > prime_factor(int64_t n) {
  map< int64_t, int > ret;
  for(int64_t i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

bool is_prime(int64_t x) {
  for(int64_t i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}

vector< bool > prime_table(int n) {
  vector< bool > prime(n + 1, true);
  if(n >= 0) prime[0] = false;
  if(n >= 1) prime[1] = false;
  for(int i = 2; i * i <= n; i++) {
    if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      prime[j] = false;
    }
  }
  return prime;
}

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

    vl v(n+5,1);
    //v[1] = 1;

    //auto pt = prime_table(10000000);
    ll ans=1;//i=1
    FOR(i,2,n+1){
      //DEBUG_VEC(v);
        //if(v[i]!=0) continue;
        v[i]++;
        ans += i*v[i];

        //int cnt=prime_factor(i);
        int cnt = 1;
        ll j=i+i;
        while(j <= n){
            //DEBUG(j);
            v[j] += cnt;
            j += i;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 81276
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,j) FOR(i,0,j)
#define mp std::make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef std::pair<int,int> P;
typedef std::pair<int,P> State;

const int INF = 1001001001;

// S N E W(南北東西)
const int dx[8] = {0, 0, 1, -1, 1, 1, -1, -1}, dy[8] = {1, -1, 0, 0, 1, -1, 1, -1};

int N, Q;
int C[300000];

int main(){
    std::cin >> N >> Q;

    REP(i, N){
        std::cin >> C[i];
    }
    std::sort(C, C+N);

    REP(i, Q){
        int q;
        std::cin >> q;

        int res = -1;
        for(int k=0;k<=300000;k+=q){
            int index = std::lower_bound(C, C+N, k) - C - 1; 
            if(0 <= index && index < N){
                res = std::max(res, C[index] % q);
            }
        }

        std::cout << res << std::endl;
    }
}

Measured memory_bytes: 2348
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 2e5+5;
const ll INF = 2e18;

int main(){
	ll n,cnt = 0;
	scanf("%lld",&n);
	while(n){
		cnt++;
		n >>= 1;
	}
	
	ll ans = (1ll << cnt)-1ll;
	cout << ans;
    return 0;
}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  bool flag = true;
  int time = 0, cnt = 0;
  for(int i = 0; i < 100; i++){
    if(time <= c && c <= time + a){
      cout << 60*cnt + c << endl;
      flag = false;
      break;
    }
    time += a + b;
    if(time > 60){
      cnt++, time -= 60;
    }
  }
  if(flag)cout << -1 << endl;
}

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

    for(int i=0 ; i<3 ; i++){
      a[i] = sc.nextInt();
    }
    Arrays.sort(a);
    int x = Math.abs(a[1]-a[0]);
    int y = Math.abs(a[2]-a[1]);

    System.out.println(x+y);
  }
}


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

#define int long long

template<class T>void chmod(T &a, const T &b, const T &mod) {
  int ret = (a % mod) + (b % mod);
  if (ret < 0) {
    ret += mod;
  }
  a = ret;
}

const int MOD = 1e9 + 7;
string K;
int D;

int dp[10010][2][110] = {0};

signed main() {
  cin >> K >> D;
  int n = K.size();

  dp[0][0][0] = 1;
  for (int digit = 0; digit < n; digit++) { // 上からdigit桁目
    for (int smaller : {0, 1}) {
      int lim = smaller == 1 ? 9 : K[digit] - '0'; // この桁の上限値
      for (int num = 0; num <= lim; num++) {
        for (int modD = 0; modD < D; modD++) {
          chmod(dp[digit+1][smaller || num < lim][(modD + num) % D], dp[digit][smaller][modD], MOD);
        }
      }
    }
  }

  // この部分
  int ans = 0;
  for (int smaller : {0, 1}) {
    chmod(ans, dp[n][smaller][0], MOD);
  }
  chmod(ans, -1LL, MOD);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 17408
eval"H,W,K="+`tr \\  ,`
a=2
b=1,1,2,3,5,8,13,21
H.times{a=0,*(1..W).map{|i|t=0;3.times{|j|t+=a[j+=i-1]*b[[i,j].min-1]*b[W-[i,j].max]};t},0}
p a[K].%10**9+7

Measured memory_bytes: 2136
s = str(input()).split(' ')
n = int(s[0])
x = int(s[1])
#m = list(map(int, input().split(' ')))
m = [int(input()) for i in range(n)]

mini = min(m)

c = 0

for i in range(n):
	c += 1
	x -= m[i]

while x >= 0:
	x -= mini
	c += 1

print(c-1)

Measured memory_bytes: 3064
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var h     = int.Parse(spl[0]);
        var n     = int.Parse(spl[1]);
        var magics = new Magic[n];
        for (int i=0; i<n; i++) {
            spl   = input.ReadLine().Split(' ');
            var m = new Magic();
            m.a = int.Parse(spl[0]);
            m.b = int.Parse(spl[1]);
            magics[i] = m;
        }

        var dp = new long[h + magics.Max(x=>x.a)];

        for(int i=0; i<dp.Length; i++) {
            if (i > 0 && dp[i] == 0) continue;
            foreach(var m in magics) {
                long j = m.a + i;
                long c = m.b + dp[i];
                if (j < dp.Length && (dp[j]==0 || c < dp[j])){
                    dp[j] = c;
                }
            }
        }

        long ret = long.MaxValue;
        for(int i=h; i<dp.Length; i++) {
            if(dp[i]>0 && dp[i] < ret) {
                ret = dp[i];
            }
        }

        //for(int i=0; i<dp.Length; i++) {
        //    Console.WriteLine(i + ":" + dp[i]);
        //}

        return ret;
    }

    class Magic
    {
        public int a;
        public int b;
    }
}


Measured memory_bytes: 13424
#include <cstdio>
#include <iostream>
#include <cmath>
using namespace std;

int main() {
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    printf("%.4f\n", sqrt(pow(x1-x2,2)+pow(y1-y2,2)));
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
using namespace std;
#define maxn 55
#define maxm 125005
#define int long long
#define INF 1e9 + 10
int n, X, D, ans, cnt, dp[maxm];
int w[maxn], val[maxn], pos[maxn];
int tot, V[maxn * maxn], W[maxn * maxn];

int read()
{
    int x = 0, k = 1;
    char c; c = getchar();
    while(c < '0' || c > '9') { if(c == '-') k = -1; c = getchar(); }
    while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * k;
}

struct edge
{
    int cnp, to[maxn], last[maxn], head[maxn];
    edge() { cnp = 1; }
    void add(int u, int v)
    { to[cnp] = v, last[cnp] = head[u], head[u] = cnp ++; }
}E1;

void dfs(int u)
{
    val[u] = 1;
    for(int i = E1.head[u]; i; i = E1.last[i])
    {
        int v = E1.to[i];
        dfs(v);
        w[u] += w[v]; val[u] += val[v];
    }
    pos[u] = u;
}

bool cmp(int x, int y) { return val[x] * w[y] > val[y] * w[x]; }
void Get_min(int &x, int y) { x = x < y ? x : y; }

int num[60];

signed main()
{
    n = read(), X = read(), D = read();
    w[1] = read();
    for(int i = 2; i <= n; i ++)
    {
        w[i] = read(); int x = read();
        E1.add(x, i);
    }
    dfs(1);
    for(int i = 1; i <= n*n*n; i ++) dp[i] = INF;
    for(int i = 1; i <= n; i ++)
    {
        int len = 1, lim = X/w[i];
		if(i>1) lim=min(lim,D);

		if(lim>n) num[i]=lim-n,lim=n;

        while(lim>0)
        {
			if(lim<len) len=lim;
            V[++ tot] = len * val[pos[i]];
            W[tot] = len * w[pos[i]];
			for(int j = n*n*n; ~j; j --)
	                if(j >= V[tot]) Get_min(dp[j], dp[j - V[tot]] + W[tot]);
		    lim -= len, len <<= 1;
        }
    }

	sort(pos + 1, pos + n + 1, cmp);
    int ans = 0;
    for(int i = 0; i <= n*n*n; i ++)
       {
        if(dp[i] > X) continue;
        int ret = i, left = X - dp[i];
        for(int j = 1; j <= n; j ++)
        {
            int tem = pos[j];
			int used = min(num[tem], left / w[tem]);

            left -= w[tem] * used;
            ret += val[tem] * used;
        }
        ans = max(ans, ret);
    }
    printf("%lld\n", ans);
    return 0;
}


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

typedef double db;
const int maxn = 310;
const db eps = 1e-10;
int n; db f[maxn][maxn][maxn];

db dfs(int s1, int s2, int s3) {
	db& res = f[s1][s2][s3];
	if (res > eps) return res;
	if (s1 + s2 + s3 == 0) return 0; res = 1;
	if (s1) res += dfs(s1 - 1, s2, s3) * s1 / n;
	if (s2) res += dfs(s1 + 1, s2 - 1, s3) * s2 / n;
	if (s3) res += dfs(s1, s2 + 1, s3 - 1) * s3 / n;
	if (s1 + s2 + s3 != n) res *= n / db(s1 + s2 + s3);
	return res;
}

int main() {
	scanf("%d", &n); int cnt[4];
	cnt[1] = cnt[2] = cnt[3] = 0;
	for (int i = 1, x; i <= n; i++) {
		scanf("%d", &x), cnt[x]++;
	}
	printf("%.15f", dfs(cnt[1], cnt[2], cnt[3]));
	return 0;
}

Measured memory_bytes: 225536
import Control.Monad
import Control.Applicative

square x w xn yn = [x+k*yn+l | k<-[0..w-1],l<-[0..w-1]]
main = do
    [an,bn] <- map (read :: String -> Int) . words <$> getLine
    aa <- replicateM an getLine
    bb <- replicateM bn getLine
    let a = concat aa
    let b = concat bb
    
    let snakes = [(a!!) <$> (square x bn an an) | x<-(square 0 (an-bn+1) an an)]
    putStrLn $ if (elem b snakes)
        then "Yes"
        else "No"

Measured memory_bytes: 1020
a = list(map(int, input().split()))
for i in range(2):
    if a[i] == 1:
        a[i] = 14
if a[0] > a[1]:
    print('Alice')
if a[0] < a[1]:
    print('Bob')
if a[0] == a[1]:
    print('Draw')

Measured memory_bytes: 3060