akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

const int N = 1e3+3;


int cnt[N][N];
pair< int, int > edge[N*200];
int n, m;
vector<int> g[N];

#define u first
#define v second

void dothething(int root) {
	queue< pair<int, int> > q;
	set< pair<int, int> > vis;
	int k = 0;
	for (auto c : g[root]) {
		k++;
		q.push({c, k});
		cnt[root][c] = 1;
		vis.insert({c, k});
	} 
	while (q.empty() == false) {
		int u = q.front().u;
		int e = q.front().v; q.pop();
		for (auto v : g[u]) {
			if (v == root) continue;
			int k = vis.size();
			if (cnt[root][v] == 2) continue;
			vis.insert({v, e});
			if (vis.size() != k) {
				cnt[root][v]++;
				q.push({v, e});
			}
		}
	}
}

signed main() {
	memset(cnt, 0, sizeof(cnt));
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++) {
		scanf("%d%d", &edge[i].u, &edge[i].v);
		g[edge[i].u].push_back(edge[i].v);
	}
	for (int i = 1; i <= n; i++) {
		dothething(i);
	}
	for (int i = 1; i <= m; i++) {
		// cout << cnt[edge[i].u][edge[i].v] << '\n';
		if (cnt[edge[i].u][edge[i].v] == 1) {
			if (cnt[edge[i].v][edge[i].u] >= 1) {
				cout << "diff\n";
			}
			else {
				cout << "same\n";
			}
		} 
		else {
			if (cnt[edge[i].v][edge[i].u] >= 1) {
				cout << "same\n";
			}
			else {
				cout << "diff\n";
			}
		}
	}
}

Measured memory_bytes: 8320
#include<bits/stdc++.h>
using namespace std;
//ofstream fout("output.txt");
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define IOS ios_base::sync_with_stdio(0);
#define pi 4*atan(1)
#define f(n) for(int i=0;i<n;++i)
#define fab(a,b) for(int i=a;i<=b;++i)
#define fba(b,a) for(int i=b;i>=a;--i)
#define reset(a,x) memset(a,x,sizeof(a))
typedef pair<int,int> ipair;
typedef vector<int> vi;
int main(){
    IOS
    cin.tie(0);




       int k,n;
       cin>>k>>n;
       int arr[n];
       for (int i = 0; i <n ; ++i) {
           cin>>arr[i];

       }
       sort(arr,arr+n);
       int dist[n];
       reset(dist,0);
       dist[0]=(arr[0]-0)+(k-arr[n-1]);
       for (int j = 1; j <n ; ++j) {
           dist[j]=arr[j]-arr[j-1];
       }
       sort(dist,dist+n);
       int cnt=0;
       for(int i=0;i<n-1;++i){
           cnt+=dist[i];
       }


       cout<<cnt<<endl;






    return 0;
}











Measured memory_bytes: 1792
import numpy as np
a, b=[int(i) for i in input().split()]

for i in range(9):
  c = np.array([[10000,1000],[1,1]])
  d = np.array([b - i*5000 , a-i])
 
  x=np.linalg.solve(c, d)

  if x[0]>=0 and x[1]>=0 and round(x[0],5)-int(round(x[0],5))<0.001 and round(x[1],5)-int(round(x[1],5))<0.001:
    break
else:
  x=np.array([])
y=list(x)

if y==[]:
  print('-1 -1 -1')
else: 
  print(str(int(round(y[0],5)))+' '+str(i)+' '+str(int(round(y[1],5))))


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

int main() {
    int n , count = 0;
    cin >> n;
    vector<int> v(n,0);
    for(int i = 0;i<n;i++){
        cin >> v.at(i);
    }
    for(int i = 1;i<n-1;i++){
        if((v.at(i-1)<v.at(i)&&v.at(i)<v.at(i+1))||(v.at(i)<v.at(i-1)&&v.at(i+1)<v.at(i))){
            count++;
        }
    }
    cout << count << endl;
}


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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
	for(auto &e:u) fill_v<T>(e,v...);
}

int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	if (s[2] == s[3] && s[4] == s[5]) {
	  cout << "Yes" << endl;
	} else {
	  cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <utility>
#include <functional>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <iomanip>
#include <numeric>
#include <complex>

using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
const int INF = (1<<30);
const ll INFL = (1LL<<62);
const ll MOD = 1000000007;
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; }
template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<class T> ll mod_pow(ll a, ll n, T mod) { mod=(ll)mod; ll res=1, p=a%mod; while(n){ if(n&1) res=res*p%mod; p=p*p%mod; n>>=1; } return res; }
template<int mod>
struct ModInt {
    using ll = long long; ll x;
    ModInt() : x(0) {}
    ModInt(int y) : x(y >= 0 ? ll(y % mod) : (ll)((mod - (-y) % mod))) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod)) {}
    ModInt &operator+=(const ModInt &rhs) { if((x += rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &rhs) { if((x += mod - rhs.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &rhs) { x = x * rhs.x % mod; return *this; }
    ModInt &operator/=(const ModInt &rhs) { *this *= rhs.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &rhs) const { return ModInt(*this) += rhs; }
    ModInt operator-(const ModInt &rhs) const { return ModInt(*this) -= rhs; }
    ModInt operator*(const ModInt &rhs) const { return ModInt(*this) *= rhs; }
    ModInt operator/(const ModInt &rhs) const { return ModInt(*this) /= rhs; }
    ModInt operator==(const ModInt &rhs) const { return x == rhs.x; }
    ModInt operator!=(const ModInt &rhs) const { return x != rhs.x; }
    friend ostream &operator<<(ostream &os, const ModInt &rhs) { return os << rhs.x; }
    friend istream &operator>>(istream &is, ModInt &rhs) { ll t; is >> t; rhs = ModInt<mod> (t); return (is); }
private:
    ModInt inverse() const { ll a = x, u = 1LL, v = 0LL, t, b = (ll)mod; while(b > 0) { t = a / b; swap(a -= t * b, b); swap(u -= t * v, v); } return  ModInt(u); }
};
using mint = ModInt<MOD>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B;
    cin >> N >> A >> B;
    vector<int> X(N);
    for(auto &&x : X) cin >> x;
    ll ans = 0;
    for(int i = 1; i < N; ++i){
        ans += min((((ll)(X[i]-X[i-1]))*((ll)A)), (ll)B);
    }
    cout << ans << endl;
    return 0;
}

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

int a;
int k=1,l=1;

int main(){
  cin >> a;
  while(k*2<=a){
    k++;
  }
  while((l*2-1)<=a){
    l++;
  }
  k-=1;
  l-=1;
  cout << k*l << endl;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
map_n = [0]*n
for i in range(n):
  map_n[i] = input()
map_m = [0]*m
for i in range(m):
  map_m[i] = input()

ans = False
for i in range(n-m+1):
  for j in range(n-m+1):
    flag = False
    for p in range(m):
      for q in range(m):
        if map_n[i+p][j+q] != map_m[p][q]:
          flag = True
          break
      if flag:
        break
    if not flag:
      ans = True
      break
  if ans:
    break

print("Yes" if ans else "No")

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

using namespace std;
#define ll long long
#define ull unsigned ll
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e5 + 10;
const ll M = 998244353;


int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    map<ll, int> pos;
    pos[x] = 1;
    ll ans[m + 2], mpos = -1, len = 0, lpos = -1;
    ans[1] = x;
    ll suum = x;
    for (int i = 2; i <= min(n, m + 1); ++i) {
        ans[i] = (ans[i - 1] * ans[i - 1]) % m;
        suum += ans[i];
        if (pos.find(ans[i]) == pos.end())
            pos[ans[i]] = i;
        else {
            mpos = pos[ans[i]];
            len = i - mpos;
            lpos = i;
            break;
        }
    }
    if (mpos == -1)
        return cout << suum << endl, 0;
    ll res = 0;
    for (int i = 1; i < mpos; ++i) {
        res += ans[i];
    }
    ll sum = ans[mpos];
    for (int i = mpos + 1; i < lpos; ++i) {
        sum += ans[i];
    }
    n -= mpos - 1;
    res += (n / len) * sum;
    n %= len;
    for (int i = mpos; i < mpos + n; ++i) {
        res += ans[i];
    }
    cout << res << endl;
}

Measured memory_bytes: 7144
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

int main(){
    while(1){
        int n,m;
        cin >> n >> m;
        if(n == 0) break;

        vector<vector<int>> adj(n);
        for(int i=0; i<m; i++){
            int a,b;
            cin >> a >> b;
            a--; b--;
            adj[a].push_back(b);
            adj[b].push_back(a);
        }
        set<int> ans;
        ans.insert(0);
        for(int i=0; i<2; i++){
            vector<int> sub;
            for(int a: ans){
                sub.insert(sub.end(), adj[a].begin(), adj[a].end());
            }
            for(int a: sub){
                ans.insert(a);
            }
        }
        cout << ans.size() -1 << endl;
    }
    return 0;
}



Measured memory_bytes: 3332
from itertools import product


def solve(bfo2, bfo1):
    ANS = [bfo2, bfo1]
    for i in s:
        if ((bfo1 == 'S' and i == 'o')
                or (bfo1 == 'W' and i == 'x')):
            ANS.append(bfo2)
        elif ((bfo1 == 'S' and i == 'x')
                or (bfo1 == 'W' and i == 'o')):
            ANS.append(*({'S', 'W'} - {bfo2}))
        bfo1, bfo2 = ANS[-1], bfo1
    return ANS


n, s = int(input()), input()

for i, j in product(['S', 'W'], repeat=2):
    ans = solve(i, j)
    if ans[:2] == ans[-2:]:
        print(*ans[1:-1], sep='')
        break
else:
    print(-1)


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

signed main(){
	long long n;	cin>>n;
	long long D=0, sum=0;
	
	for(long long i=0;i<n;i++){
		long long d,c;	cin>>d>>c;
		D+=c;
		sum+=d*c;
	}

	cout<<D-1 + ((sum-1)/9)<<endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 1e18

int main(){
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
    // printf("%d\n", N);
    return 0;
}

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

const int N = (2e5) + 5;
vector<int> adj[N];
ll subtree[N];

void dfs(int u, int p = -1) {
  for (int i = 0; i < (int) adj[u].size(); ++i) {
    int v = adj[u][i];
    if (v != p) {
      subtree[v] += subtree[u];
      dfs(v, u);
    }
  }
}

int main() { // claudio van
  int n, q; scanf("%d %d", &n, &q);
  for (int i = 0; i < n - 1; ++i) {
    int u, v; scanf("%d %d", &u, &v);
    --u; --v;
    adj[u].emplace_back(v);
    adj[v].emplace_back(u);
  }
  for (int i = 0; i < q; ++i) {
    ll p, x; scanf("%lld %lld", &p, &x);
    p--;
    subtree[p] += x;
  }
  dfs(0);
  for (int i = 0; i < n; ++i) {
    if (i != 0) printf(" ");
    printf("%lld", subtree[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 30464
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <cstdlib>
using namespace std;
int main(){
    string s;
    cin >> s;
    if(s[0] == 'a') cout << "vowel" << endl;
    else if(s[0] == 'i') cout << "vowel" << endl;
    else if(s[0] == 'u') cout << "vowel" << endl;
    else if(s[0] == 'e') cout << "vowel" << endl;
    else if(s[0] == 'o') cout << "vowel" << endl;
    else cout << "consonant" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<cstring>
#include<string>
#include<cmath>
#include<list>
#include<algorithm>
using namespace std;
#define inf 0x3f3f3f3f
typedef long long ll;
const int maxn = 2000000 + 8;
const int maxv = 10000 + 8;

int n;

int a[maxn],c[maxn],b[maxn];

int main()
{
    memset(a,0,sizeof a);
    memset(b,0,sizeof b);
    memset(c,0,sizeof c);
    scanf("%d",&n);
    for(int i = 0; i < n; ++i)
    {
        scanf("%d",&a[i]);
        c[a[i]]++;
    }
    for(int i = 1; i < maxv; ++i) {
        c[i] += c[i-1];
    }
    for(int i = n-1; i >= 0; --i)
    {
        b[c[a[i]]] = a[i];
        c[a[i]]--;
    }

    for(int i = 1; i <= n; ++i){
        printf("%s%d", i== 1 ? "":" ",b[i]);
    }
    printf("\n");
    return 0;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

/// Tip : If a and b are positive integers ; we may say - ceil (a/b) = 1 + floor ( (a-1)/b ) .

void solve ( int test_case )
{
    int n ;
    cin >> n ;

    map < int , int > h ;

    for ( int i=0 ; i < n ; i ++ )
    {
        int t ; cin >> t ;

        h[t] ++ ;
        if ( h[t] == 2 )
        {
            cout << "NO" ; line ; R ;
        }
    }

    cout << "YES" ; line ;
}

int main()
{fast
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 9600
#include<bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T>
using vec = vector<T>;

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

int main(){
  int n;
  cin >>n;
  vec<int> a(n);
  REP(i,n) cin >>a[i];

  sort(all(a));

  cout <<a[n-1]-a[0] <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

char s[4], ju[6];

int judge()
{
    if (ju[0]&1 && ju[2]&1) return 0;
    if (ju[0]&2 && ju[2]&8) return 1;
    if (ju[0]&8 && ju[2]&2) return 1;
    if (ju[4]&1 && ju[5]&4) return 1;
    if (ju[4]&4 && ju[5]&1) return 1;
    if (ju[4]&2 && ju[5]&2) return 2;
    if (ju[4]&8 && ju[5]&8) return 2;
    if (ju[0]&4 && ju[2]&4) return 2;
    if (ju[1]&2 && ju[3]&8) return 2;
    if (ju[1]&8 && ju[3]&2) return 2;
    return 3;
}

int main()
{
    char i, j, k;
    for(;;)
    {
        memset(ju, 0, sizeof(ju));
        for (i = 0; i < 6; i++)
        {
            for (j = 0; j < 3; j++)
            {
                scanf("%s", s);
                if (s[0] == '#') return 0;
                for (k = 0; k < 3; k++)
                {
                    if (s[k] == '*')
                    {
                        if (j == 0) ju[i] |= 4;
                        if (j == 2) ju[i] |= 1;
                        if (k == 0) ju[i] |= 8;
                        if (k == 2) ju[i] |= 2;
                    }
                }
            }
        }
        printf("%d\n", judge());
    }
    return 0;
}

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  ll n, m;
  cin >> n >> m;
  priority_queue<ll> p;
  for (int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    p.push(a);
  }
  for (int i = 0; i < m; i++) {
    ll now = p.top();
    p.pop();
    now /= 2;
    p.push(now);
  }

  ll ans = 0;
  while (!p.empty()) {
    ans += p.top();
    p.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 1528
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,a,b;
    cin>>k;
    int i;
    if(k>=1&&k<=1000)
    {
        cin>>a>>b;
        if(a>=1&&a<=b&&b<=1000)
        {
            i=b/k;
            if((i*k)>=a&&(i*k)<=b)
                cout<<"OK"<<endl;
            else
                cout<<"NG"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

int main()
{
	int N; cin >> N;
	if (N % 1000 == 0)
	{
		cout << 0 << '\n';
		return 0;
	}
	cout << 1000-(N % 1000) << '\n';
}


Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
constexpr double pi=3.14159265358979;

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;
}
using namespace std;

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


void solve(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    map<char,int>mp;
    rep(i,n){
      mp[s[i]]++;
    }
    ll sum=1;
    for(auto x:mp){
      sum*=(x.second+1)%mod;
      sum%=mod;
    }
    cout<<sum-1<<"\n";
    return;
}

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


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 200000;

int main(void){
    int R[MAX], n;

    cin >> n;
    for (int i = 0; i < n; i++) cin >> R[i];
    
    int maxv = R[1] - R[0];
    int minv = R[0];

    for (int i = 1; i < n; i++)
    {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }
    
    cout << maxv << endl;

    return 0;
}


Measured memory_bytes: 3852
S = input()

def M(s):
    return s > 0 and s <= 12


S1,S2 = int(S[:2]),int(S[2:])
if M(S1) and M(S2):
    print("AMBIGUOUS")
elif M(S1):
    print("MMYY")
elif M(S2):
    print("YYMM")
else:
    print("NA")


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

int main()
{
    ll n,k;
    cin>>n>>k;
    ll a[n];
    ll dp[k+1]={-1};
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++)
    {
    cin>>a[i];
    dp[a[i]]=1;
    }
    
    dp[0]=0;
    
    for(ll i=1;i<=k;i++)
    {  //cout<<i<<" "<<dp[i]<<endl;
        if(dp[i]==-1)
        {
            dp[i]=0;
            for(ll j=0;j<n;j++)
            {
                if(i-a[j]>0 && dp[ i-a[j] ]==0)
                {
                    dp[i]=1;
                    break;
                }
            }
        }
       // cout<<i<<" "<<dp[i]<<endl;
    }
    if(dp[k]==1)
    cout<<"First"<<endl;
    else
    cout<<"Second"<<endl;
    
    
}


Measured memory_bytes: 1024
import sys
input = sys.stdin.readline

def main():
    n = int(input())
    a = list(map(int, input().split()))
    sum_a = sum(a)
    kk = [0] * (10 ** 5 + 1)
    for i in a:
        kk[i] += 1

    q = int(input())
    for i in range(q):
        b, c = map(int, input().split())
        sum_a += kk[b] * (c - b)
        kk[c] += kk[b]
        kk[b] = 0
        print(sum_a)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;

int main() {
  ios::sync_with_stdio(0); 
  cin.tie(0); 
  string a, b, c;
  cin >> a >> b >> c;

  string res = {a[0], b[1], c[2]};
  cout << res << "\n";
}


Measured memory_bytes: 3600
/* include */
#include <bits/stdc++.h>
#include <boost/algorithm/string/trim.hpp>
#include <boost/range/algorithm.hpp>

/* using */
using namespace std;

/* main constructor */
struct Fast
{
    Fast()
    {
        std::cin.tie(0);
        ios::sync_with_stdio(0);
        //cout << fixed << setprecision(12);
    }
} fast;

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

/* define */
#define REP(i, x, n) for (int i = x; i < (int)(n); ++i)
#define RREP(i, x, n) for (int i = x - 1; i >= (int)(n); --i)
#define rep(i, n) REP(i, 0, n)
#define reps(i, n) REP(i, 1, n + 1)
#define rrep(i, n) RREP(i, n, 0)
#define each(i, n) for (auto &i : n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define eunique(x)  \
    boost::sort(x); \
    (x).erase(unique(all(x)), (x).end())
#define mp make_pair

/* const */
const int inf = 1e9 + 7;
const int dxl[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dyl[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dxs[4] = {1, 0, -1, 0};
const int dys[4] = {0, 1, 0, -1};

/* main */
signed main(void)
{
    int n;
    cin >> n;
    int vmid;
    int amid;
    int cnt = 0;
    vector<int> v(n, 0);
    vector<int> av(3, 0);
    rep(i, n)
    {
        cin >> v[i];
    }
    rep(i, n - 2)
    {
        copy(v.begin() + i, v.begin() + i + 3, av.begin());
        amid = av[1];
        sort(all(av));
        vmid = av[1];
        if (amid == vmid)
        {
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 256
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-9-8 21:05:03
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <functional>
#include <random> // auto rd = bind(uniform_int_distribution<int>(0, 9), mt19937(19920725));
#include <chrono> // std::chrono::system_clock::time_point start_time, end_time;
// start = std::chrono::system_clock::now();
// double elapsed = std::chrono::duration_cast<std::chrono::milliseconds>(end_time-start_time).count();
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

// const int dx[4] = {1, 0, -1, 0};
// const int dy[4] = {0, 1, 0, -1};

// const int C = 1e6+10;
// const ll M = 1000000007;

int N;
ll X;
ll x[100010];

long long gcd(long long x, long long y)
{
  return y ? gcd(y, x % y) : x;
}

int main()
{
  cin >> N >> X;
  for (auto i = 0; i < N; i++)
  {
    cin >> x[i];
    x[i] -= X;
    x[i] = abs(x[i]);
  }
  if (N == 1)
  {
    cout << x[0] << endl;
  }
  else
  {
    ll ans = gcd(x[0], x[1]);
    for (auto i = 1; i < N; i++)
    {
      ans = gcd(ans, x[i]);
    }
    cout << ans << endl;
  }
}

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define INTMAX 1000000000

using namespace std;
typedef long long ll;
typedef pair<ll ,ll> P;
const ll mod = 1e9+7;
const long double EPS = 0.0000000001;

int n, q;
string s;
int main(){
	cin >> n;
	cin >> s;
	cin >> q;
	
	// アルファベットの数に対応したsetのvectorを用意する.
	// is[0]のsetにはaが現れる位置を持たせておく。
	// set は insert とサーチが高速;
	vector<set<int>> is(26); 
	for(int i = 0; i < n; i++)is[s[i] - 'a'].insert(i);
	rep(qi, 0 ,q){
		int type;
		cin >> type;
		if(type == 1){
			int iq; char cq;
			cin >> iq >> cq;
			iq--;
			is[s[iq] - 'a'].erase(iq);
			s[iq] = cq;
			is[cq - 'a'].insert(iq);
			
		}else {
			int lq, lr;
			cin >> lq >> lr;
			lq--;
			int ans = 0;
			for(int j = 0; j < 26; j++){
				auto itr = is[j].lower_bound(lq);
				if(itr != is[j].end() and *itr < lr )ans++;
			}
			cout << ans << endl;
		}
	}

}


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

int main () {
  int n, a, b;
  cin >> n >> a >> b;
  vi x(n);
  rep(i,n) cin >> x[i];
  
  int pos = x[0];
  ll ans = 0;
  for (int i = 1; i < n; ++i) {
    int dis = x[i] - pos;
    if ((ll)dis*a < (ll)b) ans += (ll)dis*a;
    else ans += (ll)b;
    pos = x[i];
  }

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

Measured memory_bytes: 640
from math import sqrt, ceil

n = int(input())
ans = 10**10+1

for i in range(1, ceil(sqrt(n))+1):
    d, m = divmod(n, i)
    if m == 0:
        left = len(str(i))
        right = len(str(d))
        f = max(left, right)
        if f <= ans:
            ans = f
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1000];
	char str2[1000][33];
	char moji[33], moji2[33];
	char moji3;
	int max_mo, max_mo2, max_le, len;
	int a, b, c, d, zz;
	int z[1000];
	
	b = 0;
	while (scanf("%s", str) != EOF) {
		strcpy(str2[b], str);
		z[b] = strlen(str);
		b++;
	}
	
	max_mo = 0;
	max_mo2 = 0;
	for (c = 0; c < b; c++) {
		for (d = 0; d < b; d++) {
			if (strcmp(str2[c], str2[d]) == 0) {
				max_mo++;
			}
		}
		if (max_mo2 < max_mo) {
			strcpy(moji, str2[c]);
			max_mo2 = max_mo;
		}
		max_mo = 0;
	}
	
	max_le = strlen(str2[0]);
	strcpy(moji2, str2[0]);
	for (c = 1; c < b; c++) {
		if (strlen(str2[c]) > max_le) {
			max_le = strlen(str2[c]);
			strcpy(moji2, str2[c]);
		}
	}
	
	printf("%s %s\n", moji, moji2);
	
	return (0);
}

Measured memory_bytes: 576
#include<stdio.h>
long long gcd(long long a,long long b)
{
    return !b?a:gcd(b,a%b);
}
int main() 
{
	int n;
	long long t,i,lcm=1;
	
	scanf("%d",&n);
	scanf("%lld",&lcm);//这里的lcm是接下来输入多个数据的第一个数
	for(i=1;i<n;i++)
	{
		scanf("%lld",&t);//t是除第一个数之外接下来的数 
		lcm=lcm/gcd(lcm,t)*t;
	}
		
	printf("%lld\n",lcm);	
	return 0;	
}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define LEN(x) (int)x.size()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
using namespace std;
typedef int64_t i64;
typedef pair<int,int> pii;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF = 0x3f3f3f3f;

signed main()
{
  int N;
  int a[205];

  cin >> N;
  for (int i = 0; i < 2*N; ++i) cin >> a[i];
  sort(a, a+2*N);

  int ans = 0;
  for (int i = 1; i < 2*N; ++++i) {
    ans += min(a[i], a[i-1]);
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
typedef long long ll;
const int inf = 1000000001;
const ll INF = 1e18 * 4;
using namespace std;

vi decompose(int i){
    vi ans;
    for(int j=1; j<(int)sqrt(i) + 1; j++){
        if(i % j == 0){
            ans.push_back(j);
            if((int)(i / j) != j) ans.push_back(i / j);
        }
    }
    return ans;
}

int main(){
    int N; cin >> N;
    vi a;
    vi b(N+1, 0);
    vi box(N+1, 0);
    rep(i, 0, N){
        int x;
        cin >> x;
        a.push_back(x);
    }
    for(int i=N; i>0; i--){
        if((a[i-1] == 1 && b[i] % 2 == 0) || (a[i-1] == 0 && b[i] % 2 == 1)){
            b[i] += 1;
            box[i] += 1;
            vi yakusu = decompose(i);
            for(auto &j : yakusu){
                if(j == i) continue;
                b[j] += 1;
            }
        }
    }
    ll cnt = accumulate(box.begin(), box.end(), 0LL);
    cout << cnt << endl;
    rep(i, 1, N+1){
        if(box[i]) cout << i << endl;
    }
    return 0;
}




Measured memory_bytes: 3316
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
int main (void){
        int N;
        char word[100][11];
        char a;
scanf("%d\n",&N);
scanf("%s\n",word[0] );
for (int i = 1; i < N; i++) {
  scanf("%s\n",word[i] );
  for (int j = 0; j < 11; j++) {
    if (word[i-1][j]=='\0') {
      break;
    }
    a=word[i-1][j];
  }
if (a!=word[i][0]) {
  printf("No\n" );
  return 0;
}
for (int j = 0; j < i; j++) {
  if (strcmp(word[i],word[j])==0) {
    printf("No\n" );
    return 0;
  }
}
}
printf("Yes\n" );

        return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
    int h, m, s;
    int t, t3;
    
    while (1){
        scanf("%d %d %d", &h, &m, &s);
        if (h == -1 && m == -1 && s == -1) break;
        
        t = 7200 - (h * 3600) - (m * 60) - s;
        t3 = t*3;
        printf("%02d:%02d:%02d\n", t / 3600, t % 3600 / 60, t % 60);
        printf("%02d:%02d:%02d\n", t3 / 3600, t3 % 3600 / 60, t3 % 60);
    }
    
    return (0);
}

Measured memory_bytes: 612
#include<bits/stdc++.h>
using namespace std;
int  n,temp,c;
long sum=1000000;
vector<int> a(300);
int  summ (int t){
    for(int j=-100;j<=100;++j){
	long c=0;
	for(int i=0;i<t;++i){
	    c+=pow(abs((a.at(i)-j)), 2);
	}
	
	sum=min(sum,c);
    }
    return sum;
}
int main(){
    cin>>n;
    for(int k=0;k<n;k++)
	cin>>a.at(k);
int ans=summ (n);
cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <utility>
#include <functional>
#include <map>
#include <string>
#include <set>
#include <math.h>

using namespace std;

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

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

  int minT = time[0] + time[1];
  minT = min(minT, time[0] + time[2]);
  minT = min(minT, time[1] + time[2]);

  cout << minT << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
int n, w;
long long weight[102], value[102];
long long dp[102][100002];
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> w;
    for(int i = 1; i <= n; ++i)
        cin >> weight[i] >> value[i];
    for(int i = 0; i < n; ++i)
    {
        for(int j = 0; j <= w; ++j)
        {
            if(j + weight[i+1] <= w) // we can still put the item there
                dp[i+1][j + weight[i+1]] = max(dp[i+1][j + weight[i+1]], dp[i][j] + value[i+1]);
            // putting nothing = putting an item with weight 0 and value 0
            dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
        }
    }
    long long ans = 0;
    for(int j = 0; j <= w; ++j)
        ans = max(ans, dp[n][j]);
    cout << ans;
    return 0;
}


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

int main(){
    int N, A, B, n = 0, f = 0;
    string S;
    cin >> N >> A >> B >> S;
    for(int i = 0; i < N; ++i){
        if(S[i] == 'a' && n < A+B){
            ++n;
            cout << "Yes" << endl;
        }
        else if(S[i] == 'b' && n < A+B && f < B){
            ++n;
            ++f;
            cout << "Yes" << endl;
        }
        else{
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3764
#include <iostream>

using namespace std;

int main(){
        int m,f,r,score;
        while(true){
                cin >> m >> f >> r;
                score = m + f;
                if(score < 0 && r == -1) break;
                else if( m == -1 || f == -1 || score < 30) cout << "F\n";

                else if(score >= 80)    cout << "A\n";
                else if(score >= 65 && score < 80) cout << "B\n";
                else if(score >= 50 && score < 65) cout << "C\n";
                else if(score >= 30 && score < 50){
                        if(r >= 50) cout << "C\n";
                        else cout << "D\n";
                }

        }       



        return 0;
}

Measured memory_bytes: 1120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int h,w,n;
ll maze[3010][3010];
ll dp[3010][3010][4];

int main() {
    cin >> h >> w >> n;
    for (int i = 0; i < n; i++) {
        ll r,c,v;
        cin >> r >> c >> v;
        r--;
        c--;
        maze[r][c] = v;
    }
    dp[0][0][1] = maze[0][0];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            for (int k = 3; k >= 0; k--) {
                dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
                if (k+1 <= 3)
                    dp[i][j+1][k+1] = max(dp[i][j+1][k+1], dp[i][j][k] + maze[i][j+1]);
                dp[i+1][j][0] = max(dp[i+1][j][0], dp[i][j][k]);
                dp[i+1][j][1] = max(dp[i+1][j][1], dp[i][j][k] + maze[i+1][j]);
            }
        }
    }
    cout << max({dp[h-1][w-1][0], dp[h-1][w-1][1], dp[h-1][w-1][2], dp[h-1][w-1][3]}) << endl;
    return 0;
}

Measured memory_bytes: 356028
from collections import Counter

N = int(input())
A = [int(input()) for i in range(N)]

A_cp = A[:]
A_max1 = max(A_cp)
A_cp.remove(A_max1)
A_max2 = max(A_cp)

for i in A:
    print(A_max1 if i!=A_max1 else A_max2)


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

typedef long long ll;
typedef pair<int,int> P;
ll const mod = 1e9+7;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << "," << a.second << ")";return os;}

ll gcd(ll a,ll b) {
    while (b) {
        a %= b;
        swap(a,b);
    }
    return a;
}

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

int main() {
    int k,q;
    cin >> k >> q;
    array<ll,5000> d;
    for (int i = 0;i < k;++i) cin >> d[i];
    while (q--) {
        ll n,x,m;
        cin >> n >> x >> m;
        n--;
        x %= m;
        ll sum = 0,z = 0,ans = n;
        for (int i = 0;i < k;++i) sum += d[i]%m;
        for (int i = 0;i < k;++i) if (d[i]%m == 0) z++;
        ll g = gcd(sum,m);
        ll a = (n/(m/g*k))*(sum/g)%mod,b = (n/(m/g*k))*(m/g)%mod*z%mod;
        n %= m/g*k;
        (a += (x+(n/k)*sum)/m) %= mod;
        (b += (n/k)*z) %= mod;
        (ans -= a+b) %= mod;
        (ans += mod*2) %= mod;
        (x += sum*(n/k)) %= m;
        n %= k;
        for (int i = 0;i < n;++i) {
            if (x >= (x+d[i])%m) ans--;
            x = (x+d[i])%m;
        }
        cout << (ans+mod)%mod << "\n";
    }
}


Measured memory_bytes: 384
#include<stdio.h>
int ret_ans(int a)
{
    if(a == 2|| a == 4 || a == 5 || a == 7 || a == 9)
    {
        return 1;
    }
    else if(a == 0 || a == 1 || a == 6 || a == 8)
    {
        return 2;
    }
    else if(a == 3)
    {
        return 3;
    }
    return 0;
}

int main()
{
    int a;
    int ret = 0;
    char s[101];
    // 整数の入力
    scanf("%d", &a);
    if (a<0 || a>999)
    {
        return 0;
    }
    else
    {
        if(a < 10)
        {
            ret = ret_ans(a);
        }
        else if (a < 100 && a >= 10)
        {
            ret = ret_ans(a%10);
        }
        else
        {
            a = a%100;
            ret = ret_ans(a%10);
        }
    }
    // 出力
    if (ret == 1)
    {
        printf("hon");
    }
    else if (ret == 2)
    {
        printf("pon");
    }
    else if (ret == 3)
    {
        printf("bon");
    }
    return 0;
}

Measured memory_bytes: 2140
#include<stdio.h>
int main(){
int a[100000];
int n,k,i,j,pre,max;
while(1){
scanf("%d %d",&n,&k);
if(n==0&&k==0) return 0;
max=0;
pre=0;
for(i=0;i<n;i++) scanf("%d",&a[i]);
for(i=0;i<k;i++) pre+=a[i];
max=pre;
for(i=k;i<n;i++){
pre=pre+a[i]-a[i-k];
if(pre>max) max=pre;
}
printf("%d\n",max);
}
}

Measured memory_bytes: 992
main(){
  int b[101]={},i,m=0;
  while(scanf("%d",&i)!=-1)
    {
      b[i]++;
    }
  for(i=0;i<101;i++)
    {
      if(m<b[i])
	{
	m=b[i];
	}
    }
  for(i=0;i<101;i++)
    if(m==b[i])
      printf("%d\n",i);
  return 0;
}

Measured memory_bytes: 0
def main():
    H, W = map(int, input().split())
    cost = 0
    digit = []
    for i in range(10):
        digit.append([])
        a = [int(i) for i in input().split()]
        digit[i] = a

    for k in range(10):
        for i in range(10):
            for j in range(10):
                digit[i][j] = min(digit[i][j], digit[i][k] + digit[k][j])

    for i in range(H):
        A = [int(i) for i in input().split()]
        for j in range(W):
            if A[j] >= 0:
                cost += digit[A[j]][1]
    print(cost)
    




if __name__ == "__main__":
    main()


Measured memory_bytes: 40556
// Two Colors Card Game

#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <ios>
#include <iomanip>
#include <string>
#include <numeric>

using namespace std;

int main() {
    int n, m;
    cin >> n;

    string s, t;
    unordered_map<string, int> map_s;
    for (int i = 0; i < n; i++) {
        cin >> s;
        map_s[s]++;
    }

    cin >> m;
    unordered_map<string, int> map_t;
    for (int i = 0; i < m; i++) {
        cin >> t;
        map_t[t]++;
    }

    int res = 0;
    for(auto itr = map_s.begin(); itr != map_s.end(); itr++) {
        if (res < itr->second - map_t[itr->first]) {
            res = itr->second - map_t[itr->first];
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
n, m, r = list(map(int, input().split()))
rs = list(map(int, input().split()))
# construct map
import numpy as np
dists = np.ones((n + 1, n + 1)) * float('inf')
for _ in range(m):
    a, b, c = list(map(int, input().split()))
    dists[a, b] = dists[b, a] = c
for i in range(1, n + 1):
    dists[i, i] = 0

from itertools import product, permutations
for i, j in product(range(1, 1 + n), repeat=2):
    dists[j] = np.minimum(dists[j], dists[i] + dists[j, i])

ans = float('inf')
for path in permutations(rs):
    val = sum(dists[i, j] for i, j in zip(path, path[1:]))
    val = int(val)
    if val < ans:
        ans = val

print(ans)

Measured memory_bytes: 13028
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
ll m=1000000007;
ll MOD= 
998244353;
ll sieve[1000001]={0},i,j,k;
ll power(ll p, ll k)
{
ll a=1;
while(k)
{
if(k&1)
a=(a*p)%m;
p=(p*p)%m;
k>>=1;
}
return a;
}
using namespace std;
int main()
{
 
 int tc=1;
// cin>>tc;
 while(tc--)
 {
	ll ans = 0;
	ll n,s;
    cin >> n >> s;
    ll dp[s+1]={0};
    ll a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
 //dp[0]=1;
    for (int i = 0; i < n; ++i) {
        dp[0]++;
        for (int j = s; j >= 0; --j) {
			if((j-a[i])>=0)
            dp[j] += dp[j - a[i]];
            dp[j] %= MOD;
        }
        ans = (ans + dp[s]) % MOD;
    }
 
    cout << ans << endl;
	 //cout<<"\n";
 }
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
flag = 0
for i in range(n-1):
    if i==0:
        if h[i]-h[i+1]<=1:
            h[i] -=1
    else:
        if h[i-1]==h[i]:
            pass
        elif h[i-1]<h[i]:
            if h[i]-h[i+1]<=1:
                h[i]-=1
h1 = sorted(h)
if h==h1:
    print('Yes')
else:
    print('No')



Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;




int main()
{
    
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    
    vector<ll> B = A;
    for (int i = 1; i < N; i++) {
        B[i] += B[i-1];
    }
    
    ll max = A[N-1];
    
    
    int ans = 0;
    
    for (int i = 0; i < N; i++) {
        int k = i;
        ll s = B[k];
        if(s*2 >= max){
            ans = N-i;
            cout << ans << endl;
            return 0;
        }
        
        while (s*2 >= A[k+1]) {
            s = B[k+1];
            k++;
            if(s*2 >= max){
                ans = N-i;
                cout << ans << endl;
                return 0;
            }
            
        }
        i = k;
        
            
    }
    
 
    
    return 0;
}



Measured memory_bytes: 1792
//BISMILLAHIR RAHMANIR RAHIM
#include <bits/stdc++.h>
#define mem(a, b) (memset(a, b, sizeof(a)))
#define pb push_back
#define mk make_pair
#define ff first
#define ss second
#define PI acos(-1)
#define INF 2147483647
#define MOD 1000000007
#define MAX 100005
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<int, ii> pii;
typedef vector<ii> vii;
typedef priority_queue<int,vector<int>,greater<int> > PQ;

int Set(int mask, int pos){return mask = mask | (1<<pos);}
bool check(int mask, int pos){return (bool)(mask & (1<<pos));}

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

    ll h, temp;

    cin>>h;

    temp = h;

    int idx = 0;
    while(h){
        h >>= 1;
        idx++;
    }


    cout<<(1LL<<idx) - 1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <math.h>
#define PI 3.1415926535897932384626433832795

int main()
{
  
  
  double r,S,L;
  
  
  scanf("%lf",&r);
 S=r*r*PI;
 L=2*r*PI;

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


Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	if(c<=d){
		c=d;
		}
	if(c>d){
		d=c;
		}
	if(d<=e){
		d=e;
		}
	if(e<d){
		e=d;
		}
	cout<<e<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
//#include <string>
#include <algorithm>
//#include <math.h>
//#include <queue>
//#include <stack>
//#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    int n;
    vector<LL> a;
    LL tmp_a;
    int ans=0;
    int tmp_cnt;
    cin >> n;
    for(int i=0; i<n; i++){
        cin >> tmp_a;
        a.push_back(tmp_a);
    }

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

    tmp_cnt=1;
    if(n==1){
        ans++;
    }
    for(int i=1; i<n; i++){
        if(a[i]!=a[i-1]){
            //cout << i << " " << a[i] << endl;
            if(tmp_cnt%2!=0){
                //cout << i << endl;
                ans++;
            }
            tmp_cnt=1;
        }else{
            tmp_cnt++;
        }
        if(i==n-1){
            if(tmp_cnt%2!=0){
                ans++;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  string s1, s2, s3;
  cin >> s1 >> s2 >> s3;
  transform(s1.begin(), s1.end(), s1.begin(), ::toupper);
  transform(s2.begin(), s2.end(), s2.begin(), ::toupper);
  transform(s3.begin(), s3.end(), s3.begin(), ::toupper);

  cout << s1[0] << s2[0] << s3[0] << endl;
}

Measured memory_bytes: 256