akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<unordered_set>
#include<cmath>
#include<limits>

using namespace std;

unordered_set<int> primes50;

bool is_prime(int n)
{
  if (n % 2 == 0 and n != 2)
    return false;
  if (primes50.count(n) != 0)
    return true;
  for (int z = 2; z <= ceil(sqrt(n)); ++z) {
    if (n % z == 0) return false;
  }
  return true;
}

int main()
{
  for (int i = 2; i < 100; ++i) {
    if (i % 2 == 1 or i == 2) {
      bool considering = true;
      for (int j = 2; j <= ceil(sqrt(i)) and j != i and considering; ++j) {
        if (!(i%j)) considering = false;
      }
      if (considering)
        primes50.insert(i);
    }
  }

  cin.ignore(numeric_limits<streamsize>::max(), '\n');

  int n;
  int count {0};

  while (cin >> n) {
    count += is_prime(n);
  }

  cout << count << endl;
}


Measured memory_bytes: 3092
from collections import defaultdict
n, k = map(int, input().split())

a = list(map(lambda x: int(x) - 1, input().split()))
s = [0] * (n + 1)
for i in range(n):
	s[i + 1] = (s[i] + a[i]) % k

mp = defaultdict(int)

ans = 0
for i in range(n + 1):
	ans += mp[s[i]]
	mp[s[i]] += 1
	if i >= k - 1:
		mp[s[i - k + 1]] -= 1
print(ans)


Measured memory_bytes: 42824
#include<stdio.h>
#define MAX  500
#define HANI (1<<21)
#define WHITE  0
#define GRAY  1
#define BLACK  2

void dijkstra(void);


int n;
int A[MAX][MAX];

int main(){
  int i,j,u,k,v,c;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      A[i][j] = HANI;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d%d",&v,&c);
      A[u][v] = c;
    }
  }

  dijkstra();
  return 0;
}


void dijkstra(){
  int min,i,u,v;
  int d[MAX],color[MAX];

  for(i=0;i<n;i++){
    d[i] = HANI;
    color[i] = WHITE;
  }

  d[0] = 0;
  color[0] = GRAY;
  while(1){
    min = HANI;
    u = -1;
    for(i = 0;i < n;i++){
      if(min > d[i] && color[i] != BLACK){
        u = i;
        min = d[i];
      }
    }
    if(u == -1) break;
    color[u] = BLACK;
    for(v=0;v<n;v++){
      if(color[v] != BLACK && A[u][v] != HANI){
        if(d[v] > d[u] + A[u][v]){
          d[v] = d[u] + A[u][v];
          color[v] = GRAY;
        }
      }
    }
  }
  for(i=0;i<n;i++){
    d[i] == HANI ? -1 : d[i];
    printf("%d %d\n",i,d[i]);
  }
}



Measured memory_bytes: 2112
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    N, K = in_nn()
    A = in_nl()

    def is_ok(x):

        cnt = 0
        for i in range(N):
            q, r = divmod(A[i], x)
            if r == 0:
                q -= 1
            cnt += q

        return cnt <= K

    def bisect(ng, ok):

        while (abs(ok - ng) > 1):
            mid = (ok + ng) // 2
            if is_ok(mid):
                ok = mid
            else:
                ng = mid
        return ok

    ans = bisect(0, 10**9 + 1)
    print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;

template <typename K,typename V>
using umap = unordered_map<K,V>;
template <typename V>
using uset = unordered_set<V>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define REP(i,n) for(int i=0;i<n;i++)
#define REPD(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(v) v.begin(),v.end()

#define INF 1'000'000'000'000 //10^12
#define MOD 1'000'000'007

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  
  int n;
  cin >> n;
  
  int a[n];
  
  int even ,odd,fac4;
  
  even = odd = fac4 = 0;
  
  REP(i,n){
    cin >> a[i];
    if(a[i]%4 == 0){
      fac4++;
    }else if(a[i]%2 == 0){
      even++;
    }else{
      odd++;
    }
  }
  
  if(odd == 0){
    if(fac4 == 0 && even <= 1){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }else{
    if(even == 0){
      if(fac4 - odd >= -1){
        cout << "Yes" << endl;
      }else{
        cout << "No" << endl;
      }
    }else{
      if(fac4 >= odd){
        cout << "Yes" <<endl;
      }else{
        cout << "No" << endl;
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 4048
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long




void solve()
{
    int n;
    cin>>n;
    int a[n];
    for(auto &x:a)cin>>x;
    int ans=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                int a1=a[i],a2=a[j],a3=a[k];
                if(a1!=a2 and a1!=a3 and a2!=a3 and (a1+a2)>a3 and (a1+a3)>a2 and (a2+a3)>a1)ans++;
            }
        }
        //cout<<ans<<'\n';
    }
    cout<<ans;
    
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

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

int main()
{
  int N;
  cin >> N;
  
  int n1 = (N / 10);
  int n2 = N - (n1 * 10);
  
  if((n1 == 9) || (n2 == 9))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

int main()
{
    int h, w;
    cin >> h >> w;
    char grid[h+2][w+2];
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        cin >> grid[i][j];
    }

    int ans[h+2][w+2];
    
    for(int i=0;i<h+2;i++)
    {
        for(int j=0;j<w+2;j++)
        ans[i][j] = 0;
    }
    ans[0][1] = 1;
    for(int i=1;i<=h;i++)
    {
        for(int j=1;j<=w;j++)
        {
            if(grid[i][j] == '#')
            continue;
            ans[i][j]= (ans[i-1][j]+ ans[i][j-1])%1000000007;
        }
    }
    cout << ans[h][w];
    return 0;
}


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

int main(){
	string s;
	cin >> s;
	int a = 0;
	int b = 0;
	int c = 0;
	int d = 0;
	rep(i,s.size()){
		if(s[i] == 'N') a++;
		if(s[i] == 'W') b++;
		if(s[i] == 'S') c++;
		if(s[i] == 'E') d++;
	}
	bool can = true;
	if((a > 0 && c == 0) || (c > 0 && a == 0)) can = false;
	if((b > 0 && d == 0) || (d > 0 && b == 0)) can = false;
	if(can){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define debugArray(x, n)                                      \
  cerr << __LINE__ << ": " << #x << " = {";                   \
  for (long long hoge = 0; (hoge) < (long long)(n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];                   \
  cerr << "}" << '\n'
#define debugMatrix(x, h, w)                                         \
  cerr << __LINE__ << ": " << #x << " =\n";                          \
  for (long long hoge = 0; (hoge) < (long long)(h); ++(hoge)) {      \
    cerr << ((hoge ? " {" : "{{"));                                  \
    for (long long fuga = 0; (fuga) < (long long)(w); ++(fuga))      \
      cerr << ((fuga ? ", " : "")) << x[hoge][fuga];                 \
    cerr << "}" << (hoge + 1 == (long long)(h) ? "}" : ",") << '\n'; \
  }
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#define debugMatrix(x, h, w) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  int N;
  cin >> N;
  int D[N][2];
  for (int i = 0; i < N; i++) cin >> D[i][0] >> D[i][1];
  bool zoro = false;
  for (int i = 1; i + 1 < N; i++)
    zoro |= D[i - 1][0] == D[i - 1][1] && D[i][0] == D[i][1]
            && D[i + 1][0] == D[i + 1][1];
  cout << (zoro ? "Yes" : "No") << '\n';
  return 0;
}


Measured memory_bytes: 3636
s=input()
n=len(s)
dp=[[0]*13 for _ in range(100010)]
dp[0][0]=1
for i in range(n):
    for j in range(10):
        if s[i]==str(j) or s[i]=="?":
            for h in range(13):
                dp[i+1][(h*10+j)%13]+=dp[i][h]
    for h in range(13):
        dp[i+1][h]%=1000000007
print(dp[n][5])

Measured memory_bytes: 62044
from sys import stdin, stdout

n, k, q = map(int, raw_input().strip().split())
quer = stdin.readlines()
out = []

freq = [0] * n

for line in quer:
    x = int(line.strip())
    freq[x - 1] += 1

for i in xrange(n):
    tot = k - (q - freq[i])
    if tot <= 0:
        out.append("No")
    else:
        out.append("Yes")

stdout.write("\n".join(out))

Measured memory_bytes: 48504
n,m = map(int,input().split())
x = list(map(int,input().split()))

if n >= m:
    print(0)
else:
    x.sort()
    interval = [0]*(m-1)
    for i in range(m-1):
        interval[i] = x[i+1] - x[i]
    interval.sort(reverse = True)
    answer = x[m-1] - x[0]
    for i in range(min(m,n-1)):
        answer -= interval[i]
    print(answer)


Measured memory_bytes: 13968
N, M, X, Y = [int(i) for i in input().split()]
x = [int(i) for i in input().split()]
y = [int(i) for i in input().split()]
if max(x) < min(y) and X < max(x) + 1 <= Y:
    print("No War")
else:
    print("War")


Measured memory_bytes: 2940
time =2
list = [list(map(int, input().split())) for i in range(time)]
n, x = [i for i in list[0]]
cnt = 0
cur = 0
for i in range(n):
    if cur <= x:
        cnt += 1
    cur += list[1][i]
if cur <= x:
    cnt += 1

print(cnt)


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

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
typedef uint64_t ull;
typedef int64_t ll;
typedef pair<ll, ll> PLL;

vector<PLL> edges[100010];// edges[i].first: iの次の頂点、edges[i].second: その頂点へのコスト
signed main() {
    ll N,Q,K;
    cin>>N;
    rep(i,0,N-1){
        ll a,b,c;
        cin>>a>>b>>c;
        edges[a].emplace_back(b, c);
        edges[b].emplace_back(a, c);
    }
    cin>>Q>>K;

    vector<bool> used(N+10, false);
    vector<ll> dist(N+10, 0);
    priority_queue<PLL, vector<PLL>, greater<PLL>> q;
    q.push(PLL(0, K));
    while(!q.empty()){
        ll d = q.top().first;
        ll id = q.top().second;
        q.pop();
        if (used[id])
            continue;
        used[id] = true;
        dist[id] = d;
        for (auto e: edges[id]){
            q.push(PLL(d+e.second, e.first));
        }
    }
    rep (i,0,Q){
        ll x,y;
        cin>>x>>y;
        cout<<dist[x]+dist[y]<<endl;
    }
    return 0;
}


Measured memory_bytes: 11120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    ll n;
    cin >> n;
    ll x=n;
    int sum=0;
    while(x>0){
        sum+=x%10;
        x/=10;
    }
    bool flag;
    if(n%sum==0) flag=true;
    else flag=false;
    
    if(flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main() {
    
	int x[250],i,num;
	
	scanf("%d",&num);
	for(i=1;i<=num;i++)
	{
		scanf("%d",&x[i]);
		
	}
	for(i=1;i<=num;i++)
	{
	printf("node %d: key = %d, ",i,x[i]);
	
	if(i/2>0) printf("parent key = %d, ",x[i/2]);
	if(i*2<=num) printf("left key = %d, ",x[i*2]);
	if(i*2+1<=num) printf("right key = %d, ",x[i*2+1]);
	
	printf("\n");
    }
	return 0;
}



Measured memory_bytes: 2100
#include <iostream>
#include <vector>
#include <string>
#include <queue>

#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;


int main(void)
{
	int N;
	cin >> N;
	vector<vector<int>> A(N, vector<int>(N - 1));
	rep(i, N)rep(j, N - 1){
		cin >> A[i][j];
		A[i][j]--;
	}
	
	vector<int> idx(N, 0);
	int cnt = 0;
	queue<int> q;
	rep(i, N) q.push(i);
	while (1){
		//cout << "ok" << endl;
		vector<bool> flag(N, false);
		int n_q = q.size();
		rep(k, n_q){
			int i = q.front();
			q.pop();
			if (idx[i] >= N-1) continue;
			int match = A[i][idx[i]];
			if (flag[i] || flag[match]) continue;
			//cout << match << endl;
			if (A[match][idx[match]] == i){
				flag[i] = true;
				flag[match] = true;
				idx[i]++;
				idx[match]++;
				q.push(i);
				q.push(match);
			}
		}
		cnt++;
		int n_flag = 0;
		rep(i, N)if (flag[i]) n_flag++;
		if (n_flag == 0){
			cout << -1 << endl;
			return 0;
		}
		int n_fin = 0;
		rep(i, N)if (idx[i] == N-1) n_fin++;
		if (n_fin == N) break;
	}

	cout << cnt << endl;
	return 0;
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))




void solve(){
    string s;cin>>s;
    int l=s.length();
    cout<<s[0]<<l-2<<s[l-1];

}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;

    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 61
#define MAX 1LL << 30
#define MOD 1000000007
typedef long long ll;
typedef pair<ll,ll> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
int dx[]={1,-1,0,0},dy[]={0,0,-1,1};


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

    int N,K;
    cin>>N>>K;
    vector<ll> V(N);
    for(int i=0;i<N;i++) cin>>V[i];
    sort(V.begin(),V.end());
    N-=K;
    ll ans=0;
    for(int i=0;i<N;i++) ans+=V[i];
    cout<<ans<<endl;
}

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

c = [0]*100
for i in a:
    b = format(i,'b')[::-1]
    for x in range(len(b)):
        c[x] += int(b[x])

ans = 0
mod = 10**9+7
for i in range(100):
    ans += c[i]*(n-c[i])*2**i
    ans %= mod

print(ans)

Measured memory_bytes: 124348
#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){
    if(C > E)
      cout << C << endl;
    else
      cout << E << endl;
  }
  else{
    if(D > E)
      cout << D << endl;
    else
      cout << E << endl;
  }
  
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 100'000
#define MAX_M 100'000

using P = pair<i64, i64>;

int main() {
    i64 N, M; cin >> N >> M;
    vector<P> interval(M);
    REP(i, M) {
        i64 a, b; cin >> a >> b;
        a--; b--;
        interval[i] = {a, b};
    }
    sort(interval.begin(), interval.end(), [](const P &p1, const P &p2) {
        return p1.second < p2.second;
    });

    i64 cnt = 0;
    i64 r = -1;
    REP(i, M) {
        if (interval[i].first >= r) {
            cnt++;
            r = interval[i].second;
        }
    }
    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

ll n, m, q;
vector<ll> a, b, c, d;
vector<ll> val;
ll ans = 0;

void dfs(ll v, ll depth = 0) {
    val[depth] = v;
    if (depth == (n - 1)) {
        // rep(i, n) printf("%lld%s", val[i], (i == (n - 1)) ? "\n" : " ");
        ll tmp = 0;
        // if ((val[0] == 1) && (val[1] == 3) && (val[2] == 4)) {
        //     printf("tmp=%lld\n", tmp);
        // }
        rep(i, q) {
            if ((val[b[i]] - val[a[i]]) == c[i]) {
                tmp += d[i];
            }
            // if ((val[0] == 1) && (val[1] == 3) && (val[2] == 4)) {
            //     printf("%lld:%lld:%lld\n", val[a[i]], val[b[i]], c[i]);
            // }
        }
        ans = max(ans, tmp);
        
        return;
    }
    reps(i, v, m + 1) {
        dfs(i, depth + 1);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    rep(i, q) {
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        a[i]--; b[i]--;
    }
    val.resize(n);
    rep(i, 10) dfs(i + 1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
BIG_NUM = 2000000000

table = [[[0]*10 for i in range (0,3)] for k in range (0,4)]

N = int(input())

for loop in range(N):
    house_id,floor,room,add = map(int,input().split())
    table[house_id-1][floor-1][room-1] += add


x = 0

for i in range(4):
    if x != 0:
        print("#"*20)
    x += 1

    for a in range(3):
        for b in range(10):
            print(" %d"%(table[i][a][b]),end = "")
        print()



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

int main()
{
	vector<int> a(5);
	cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
	int m = 1900000;
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		sum += ((a[i] + 9) / 10) * 10;
	}
	for (int i = 0; i < 5; i++) {
		m = min(m, sum - (((a[i] + 9) / 10) * 10) + a[i]);
	}
	cout << m << endl;
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back
#define REP(i,a,b) for(int i=a; i<=b; i++)
#define MOD 1000000007

void solve(int test_case) {//209
	vi cs(26,1);
	string s;
	cin>>s;
	for(char c:s)cs[c-'a']--;
	char req = '.';
	REP(i,0,25)if(cs[i]){req=i+'a';break;}
	if(req!='.') {
		s.PUB(req);
		cout<<s;
		return;
	}
	while(!s.empty()) {
		char last = s.back();
		s.pop_back();
		int ch = last-'a';
		REP(i,ch+1,25) {
			if(cs[i]) {
				s.PUB(i+'a');
				cout<<s;
				return;
			}
		}
		cs[ch]=1;
	}
	cout<<-1;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	//prefill();
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
name = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
NUM = 26
id = ""
N = int(input())

while True:
  q = N // NUM
  mod = N % NUM
  if mod == 0:
    q = q-1
    mod = 26
  else:
    None

  id = name[mod-1]+id
  if q <= 0:
    break
  
  if q <= 26 and q > 0:
    id = name[q-1]+id
    break
  else:
    N = q
  
print(id)

Measured memory_bytes: 9160
L,R = map(int,input().split())

if R >= L + 2019:
    R = L + 2019

minmod = 2019
for i in range(L, R):
    for j in range(i+1, R+1):
        mod = (i * j) % 2019
        if minmod > mod:
            minmod = mod

print( minmod )


Measured memory_bytes: 2940
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <float.h>

#pragma region 定義
#define i_cin(X) scanf("%d", &X)
#define i_cin2(X,Y) scanf("%d %d",&X,&Y)
#define i_cin4(X,Y,Z,W) scanf("%d %d %d %d",&X,&Y,&Z,&W)
#define i_cin3(X,Y,Z) scanf("%d %d %d",&X,&Y,&Z)
#define l_cin(X) scanf("%ld",&X)
#define f_cin(X) scanf("%f",&X)
#define l_cin2(X,Y) scanf("%ld %ld",&X,&Y)
#define s_cin(X) scanf("%s",&X)
#define c_cin(X) scanf("%c",&X);
#define ll_cin(X) scanf("%lld", &X)
#define ull_cin(X) scanf("%llu", &X)
#define lf_cin(X) scanf("%lf", &X)

#define  i_cout(X) printf("%d\n",X)
#define  f_cout(X) printf("%g\n",X)
#define  i_cout2(X,Y) printf("%d %d\n",X,Y)
#define  l_cout(X) printf("%ld\n",X)
#define  s_cout(X) printf("%s\n",X)

#define  c_cout(X) printf("%c",X)


#define  ll_cout(X) printf("%lld\n",X)
#define  ull_cout(X) printf("%llu\n",X)



typedef long long  ll;
typedef unsigned long long  ull;

#define rept(x, s, n) for (int x = s; x < n; x++)

#define S_RTN(S)  s_cout(S);return 0


#define _itoa(A,N) sprintf(A, "%d", N);

int i_cins(int n, int* A);
int l_cins2(int n, long* A, long* B);
int s_dsort(const void* a, const void* b);
int s_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);


int s_asorts(const void* a, const void* b);

//昇順
int s_asorts(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(*(int*)b - *(int*)a);
}
int s_asort(const void* a, const void* b) {
	return(*(int*)a - *(int*)b);
}
int l_cins2(int n, long* a, long* b) {
	int i;
	rept(i, 0, n) {
		l_cin2(*(a + i), *(b + i));
	}
	return 0;
}
int i_cins(int n, int* a) {
	int i;
	for (i = 0; i < n; i++) {
		i_cin(*(a + i));
	}

	return 0;
}
int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}

long _max(long a, long b) {
	return a > b ? a : b;
}
long _min(long a, long b) {
	return a < b ? a : b;
}
int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

#pragma endregion

//167-A


int main(void) {
	char s[12],t[12];
	int ls, lt;
	s_cin(s);
	s_cin(t);
	
	ls = strlen(s); lt = strlen(t);
	if (lt != ls + 1) { S_RTN("No"); }
	
	if (memcmp(s, t, ls)) { S_RTN("No"); }
	S_RTN("Yes");





}



//#define _N 1000000000

//int main(void)
//{
//
//	int  n,i;
//	ull   tmp=1;
//
//	i_cin(n);
//
//	for (i = 1; i <= n; i++) {
//		if (!(tmp % ((ull)_N + 7)))
//			tmp = 1;
//		tmp *= (ull)i;
//	}
//	tmp %= ((ull)_N + 7);
//		
//	ull_cout(tmp);
//	return 0;
//}



Measured memory_bytes: 1576
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 100010
#define MOD 1000000007
using namespace std;
int n;
typedef long long ll;
ll dp[MAXN],h[MAXN];
ll fsp(ll x,ll y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}
	return res;
}
int main(){
	SF("%d",&n);
	dp[n+1]=1;
	for(int i=1;i<=n;i++){
		SF("%lld",&h[i]);
		if(h[i]==1){
			h[i]--;
			dp[n+1]=dp[n+1]*2ll%MOD;
		}
	}
	for(int i=1;i<=n;i++)
		if(h[i]>h[i-1]&&h[i]>h[i+1]){
			int h1=max(h[i-1],h[i+1]);
			dp[n+1]=dp[n+1]*fsp(2,h[i]-h1)%MOD;
			h[i]=h1;	
		}
	for(int i=n;i>0;i--){
		//PF("{%d}",i);
		if(h[i])
			dp[i]=dp[i+1]*2ll%MOD;
		else{
			dp[i]=dp[i+1];
			continue;
		} 
	 	ll minh=h[i],q=i;
		for(int j=i;h[j]==h[i];j++)
			if(h[j+1]>h[i]){
				q=j;
				minh++;
			}
		ll res1=0;
		ll end,sumh=0;
		if(h[i]<h[i-1])
			end=h[i];
		else
			end=h[i-1]+1;
		//PF("{%d %d}\n",minh,end);
		for(int j=q+1;minh>end;j++){
			if(h[j]>h[j-1])
				sumh+=h[j]-h[j-1];
			if(h[j]<minh){
				int minh1=max(end,h[j]);
				//PF("{%d %d %d}\n",sumh+h[i]-minh,minh-minh1,-(minh==(h[i]+1)?0:1));
				if(minh==h[i]+1)
					res1+=dp[j]*(fsp(2,sumh+h[i]-minh+q-i+2)+fsp(2,sumh+h[i]-minh+2)*(fsp(2,minh-minh1-1)-1)%MOD)%MOD;
				else
					res1+=dp[j]*(fsp(2,sumh+h[i]-minh+1)*(fsp(2,minh-minh1)-1)%MOD)%MOD;
				res1%=MOD;
				minh=minh1;
			}
		}
		dp[i]+=res1;
		dp[i]%=MOD;
		//PF("{%lld}\n",dp[i]);
	}
	PF("%lld",dp[1]);
} 


Measured memory_bytes: 128
n = gets.to_i
d = Hash.new(0)
gets.split.each {|e| d[e.to_i] += 1}
m = gets.to_i
t = Hash.new(0)
gets.split.each {|e| t[e.to_i] += 1}
puts t.all? {|k,v| d[k] >= v} ? "YES" : "NO"

Measured memory_bytes: 57584
n,m = (int(i) for i in input().split())
par,rank,ans = [i for i in range(m+n)],[0 for i in range(m+n)],"YES"
def root(x):
	if par[x]!=x: par[x] = root(par[x])
	return par[x]
def unite(x,y):
	x2,y2 = root(x),root(y)
	if x2!=y2:
		if rank[x2]<rank[y2]: par[x2] = y2
		else: par[y2] = x2
		if rank[x2]==rank[y2]: rank[x2]+=1
def same(x,y):
	return root(x)==root(y)
for i in range(n):
    y = [int(k)-1 for k in input().split()]
    for j in y[1:]: unite(j,m+i)
for i in range(1,n):
    if not same(m,m+i): ans = "NO"
print(ans)

Measured memory_bytes: 12592
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
//#define endl "\n"
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int P = 997;
const int MOD = (int)1e9 + 7;
const int N = (int)1e5 * 5;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

string s;

int sum[2][N], a[N];

void solve () {
    cin >> s;
    for (int i = 0; i < sz(s); ++i) {
        a[i] = s[i] - 'A' + 1;
    }
    int ans = 0;
    for (int i = 0; i < sz(s); ++i) {
        if (i % 2 == 0){
            ans += sum[0][a[i]] + sum[1][a[i]];
            sum[0][a[i]] ++;
        }
        if (i % 2 == 1) {
            ans += sum[1][a[i]] + sum[0][a[i]];
            sum[1][a[i]]++;
        }
    }
    
    cout << (sz(s) + 1) * sz(s) / 2 - ans - sz(s) + 1;
}

signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int t = 1;
    while (t --) {
        solve ();
    }
    return 0;
}



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

int getgroup(int x)
{
        int gA[7] = {1, 3, 5, 7, 8, 10, 12};
        int gB[4] = {4, 6, 9, 11};
        int gC[1] = {2};

        for (int i = 0; i < 7; ++i) {
                if (x == gA[i]) return 1;
        }
        for (int i = 0; i < 4; ++i) {
                if (x == gB[i]) return 2;
        }
        if (x == gC[0]) return 3;

}

int main()
{
        int x, y;
        cin >> x >> y;
        int xg = 0;
        int yg = 0;
        xg = getgroup(x);
        yg = getgroup(y);
        if (xg == yg) cout << "Yes" << endl;
        else cout << "No" << endl;


}


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

int main(){
  int n, a1, a2, ans = 0;
  cin >> n;
  
  for( int i = 0; i < n; i++){
    cin >> a1 >> a2;
    ans += a2 - a1 + 1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;


int main(){
int N;
cin>>N;
vector<long long >a(N);
rep(i,N)cin>>a[i];

int now=1;
long long ans=0;

for(int i=0;i<N;i++){
    if(a[i]!=now){
        ans++;
    }
    else{
        now++;
    }
    //if(now-1+ans>=N)break;
   
    
}

if(now==1)ans=-1;
cout<<ans<<endl;
return 0;

}
/*
3
2 1 2

1

3
2 2 2

-1

10
3 1 4 1 5 9 2 6 5 3

7

1
1

0

*/


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define ppb push_back
typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;
typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;
typedef vector<vector<int>> vvi; typedef vector<vbool> vvb;

const ll N = 100010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	ll k, q; cin >> k >> q;
	vll d(k), pre(k+1, 0);
	fori(k) cin >> d[i];
	ll n, x, m;
	fori(q) {
		cin >> n >> x >> m;
		fori(k) pre[i+1] = pre[i] + d[i]%m;
		ll ans = 0, last = x + (n-1)/k * pre[k] + pre[(n-1)%k], sub = 0;
		forj(min(k, n)) {
			ll cur = d[j]%m;
			if (cur == 0) {
				sub += (n-1)/k;
				if ((n-1)%k >= (j+1)) sub++;
			}
		}
		sub += (last/m - x/m);

		ans = n-1-sub;
		cout << ans << nl;
	}

	#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	vector<int>n(3);
	rep(i, 3)cin >> n[i];
	sort(n.begin(), n.end());
	int x = n[2] - n[1];
	int y = n[2] - n[0];
	int ans = 0;
	if (x % 2 == y % 2) {
		ans += x;
		ans += (y - x) / 2;
	}
	else {
		ans += x;
		n[0] += x;
		ans += (n[2] - n[0] + 1) / 2;
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define hell  1000000007
using namespace std;
vector<pair<long long int,long long int> > v;
int main(){
    
    long long int n,k;
	cin >> n >> k;
	
	while(n--){
		
		 long long int a,b;
		 cin >> a >> b;
		v.push_back({a,b});
	}
	
	sort(v.begin(),v.end());
	
	for(int i=0;i<v.size();i++){
		
		k -= v[i].second;
		
		if(k <= 0){
			cout << v[i].first << endl;
			break;
		}
		
	}
	return 0;
}

Measured memory_bytes: 2420
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    N = int(input())
    A = int(input())
    print(N * N - A)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
#include <cstdio>
#include <cstdlib>
using namespace std;
int n,d;
int main()
{
	scanf("%d%d",&n,&d);
	d=d*2+1;
	if(n%d==0)
		printf("%d",n/d);
	else printf("%d",n/d+1);
	return 0;
}
 

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD 1000000007
#define PI 3.1415926535897932384

template<class S, class T>ostream& operator<<(ostream&os, pair<S, T>p) { os << "[" << p.first << ", " << p.second << "]"; return os; };
template<class S>auto&operator<<(ostream&os, vector<S>t) { bool a = 1; for (auto s : t) { os << (a ? "" : " ") << s; a = 0; } return os; }

//int dx[]={1,1,1,0,-1,-1,-1,0},dy[8]={1,0,-1,-1,-1,0,1,1,1};
//
constexpr ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }


int main() {
	int a, b, c, d;
	cin >>a>>b>>c>>d;
	cout << c-(d-b) << " ";
	cout << d+(c-a) << " ";
	cout << a-(d-b) << " ";
	cout << b+(c-a) << endl;
}


Measured memory_bytes: 256
/*
welcome to my code           hi from    s_agnik1511 
Don't just copy it.
Analyze it.
coz that's what heroes do.....
*/
#include<bits/stdc++.h>
#include<algorithm>
#include<string.h>
#include<numeric>
#include<vector>
#include<math.h>
#include<map>
using namespace std;
#define dude             ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define mesc(number,character)   char f[number];memset(f,character,number);
#define mesi(number,value)   int f[number];memset(f,value,number);
#define specio           ifstream cin("input.txt");ofstream cout("output.txt");
#define fr(i,start,end)  for(i=start;i<=end;i++)
#define rf(i,start,end)  for(i=start;i>=end;i--)
#define tst              int t;cin>>t;while(t--)
#define ai               ll n,i;cin>>n;ll a[n];
#define pi               3.14159265358979323846
#define ll               long long int
#define acc              accumulate
#define ld               long double
#define pb               push_back
#define r0               return 0;
#define pp               pop_back
#define vec              vector
#define sec              second
#define S                string
#define D                double
#define len              length
#define br               break;
#define wh               while
#define fs               first
#define F                float
#define gcd              __gcd
#define sz               size
#define endl              "\n"
#define sp              " "
const ll ifn=-1000000000000000000;
const ll inf=1000000000000000000;
const int N=100000;
ll arr[1000005],n,a[1000005];
ll frog(ll i) {
    if(i==n-1) {
        return 0;
    }
    else if(i>n-1) {
        return INT_MAX;
    }
    else {
        if(arr[i]!=-1) {
            return arr[i];
        }
        else {
        ll r,l;
        l=abs(a[i]-a[i+1])+frog(i+1);
        r=INT_MAX;r=abs(a[i]-a[i+2])+frog(i+2);
        arr[i]=min(r,l);
        return arr[i];
        }
    }
}

int main() {
    dude
    memset(arr,-1,1000005);
    cin>>n;
    ll i;
    fr(i,0,n-1) {
        cin>>a[i];
    }
    cout<<frog(0);
   r0
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
string f[105];
int main(){
	cin>>n>>m;
	cout<<100<<" "<<100<<endl;
	for(int i=0;i<100;i++){
		for(int j=0;j<50;j++) f[i].pb('#');
		for(int j=0;j<50;j++) f[i].pb('.');
	}
	{
		int zan = n-1;
		for(int a=1;a<=97;a+=2){
			for(int b=1;b<=47;b+=2){
				if(zan == 0) goto nxt;
				f[a][b] = '.';
				zan--;
			}
		}
		nxt:;
	}
	{
		int zan = m-1;
		for(int a=1;a<=97;a+=2){
			for(int b=51;b<=97;b+=2){
				if(zan == 0) goto nxt2;
				f[a][b] = '#';
				zan--;
			}
		}
		nxt2:;
	}
	for(int i=0;i<100;i++) cout<<f[i]<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N, K;
   cin >> N >> K;
   string s;
   cin >> s;
   int l[N], r[N];
   int cnt = 0;
   if (s[0] == '0') {
      l[cnt] = -1;
      cnt++;
   }
   for (int i = 1; i < N; i++) {
      if (s[i - 1] == '1' && s[i] == '0') {
         l[cnt] = i - 1;
         cnt++;
      }
      if (s[i - 1] == '0' && s[i] == '1') {
         r[cnt - 1] = i;
      }
   }
   if (s[N - 1] == '0' && s[N - 2] == '0') r[cnt - 1] = N;
   /*
   for (int i = 0; i < cnt; i++) {
      cout << i << " " << l[i] << " " << r[i] << endl;
   }
   */
   if (K >= cnt) {
      cout << N << endl;
      return 0;
   }
   int ans = 0;
   for (int i = 0; i < cnt - K + 1; i++) {
      if (i == 0) chmax(ans, l[i + K] - 0 + 1);
      else if (i == cnt - K) chmax(ans, N - 1 - r[i - 1] + 1);
      else chmax(ans, l[i + K] - r[i - 1] + 1);
   }
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 896
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL;
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
    /*
    int n,k,x;
    cin>>n>>k>>x;
    vector<pair<int,int>> v(n);
    rep(i,0,n){
        if(i==x-1)continue;
        cin>>v[i].fi>>v[i].se;
        v[i].fi--;
        v[i].se--;
    }
    vector<int> c(n),s(n);
    rep(i,0,n){
        cin>>c[i];
        s[i]=i+1;
    }
    rep(i,0,x-1){
        swap(s.begin()+v[i].fi,s.begin()+v[i].se);
    }
    for(int i=min(x,))
    */
    ll x;
    cin>>x;
    cout<<x-x%500<<endl;
    
    
    
    


    return 0;
}



Measured memory_bytes: 3092
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

import javax.swing.plaf.synth.SynthSeparatorUI;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] a = new int[N];
		int max = -1000001, indexMax = -1;
		int min = 1000001, indexMin = -1;
		for(int i = 0; i < N; i++){
			a[i] = in.nextInt();
			if(a[i] < min){
				min = a[i];
				indexMin = i;
			}
			if(a[i] > max){
				max = a[i];
				indexMax = i;
			}
		}
		
		int diff = 0;
		int indexDiff = -1;
		if(Math.abs(min) > Math.abs(max)){
			diff = min;
			indexDiff = indexMin;
		}else{
			diff = max;
			indexDiff = indexMax;
		}
		
		System.out.println(2 * N - 1);
		
		/*
		for(int i = 0; i < N; i++){
			System.out.print(a[i] + " ");
		}
		System.out.println();
		*/
		
		for(int i = 0; i < N; i++){
			a[i] += a[indexDiff];
			System.out.println((indexDiff+1) + " " + (i+1));
		}
		
		/*
		for(int i = 0; i < N; i++){
			System.out.print(a[i] + " ");
		}
		System.out.println();
		*/
		
		if(diff >= 0){
			for(int i = 1; i < N; i++){
				//if(a[i] < a[i-1]) a[i] += a[i-1];
				a[i] += a[i-1];
				System.out.println((i-1+1) + " " + (i+1));
			}
		}else{
			for(int i = N - 2; i >= 0; i--){
				//if(a[i] < a[i-1]) a[i] += a[i-1];
				a[i] += a[i+1];
				System.out.println((i+1+1) + " " + (i+1));
			}
		}
		
		/*
		for(int i = 0; i < N; i++){
			System.out.print(a[i] + " ");
		}
		System.out.println();
		*/
		
	}
}


Measured memory_bytes: 22612
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
#include <cstring>
#include <iterator>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <utility>
#include <memory>
#include <functional>
#include <deque>
#include <cctype>
#include <ctime>
#include <numeric>
#include <list>
#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


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

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll;
typedef vector<vector<long long> > vvll;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}

#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define _rep(i,n) _rep2((i),0,(n))
#define _rep2(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) GET_MACRO(__VA_ARGS__, _rep2, _rep)(__VA_ARGS__)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define fi first
#define se second
#define mkp make_pair
#define DEBUG
#ifdef DEBUG
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#else
#define dump(x) 
#define debug(x) 
#endif

#define MOD 1000000007LL
#define EPS 1e-8
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)

void mainmain(){
	ll n,L;
	cin>>n>>L;
	vll v(n);
	rep(i,n){
		cin>>v[i];
	}
	rep(i,n-1){
		if(v[i]+v[i+1]>=L){
			cout<<"Possible"<<endl;
			rep(j,i){
				cout<<j+1<<endl;
			}
			for(int j=n-2; j>=i+1; j--){
				cout<<j+1<<endl;
			}
			cout<<i+1<<endl;
			return;
		}
	}
	cout<<"Impossible"<<endl;
}


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(20);
    mainmain();
}

Measured memory_bytes: 1664
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n, m;
        cin >> n >> m;
        if(n == 0)
            return 0;

        vector<int> a(n);
        for(int i=0; i<n; ++i)
            cin >> a[i];

        int j = 0;
        vector<int> t(n);
        t[0] = m / a[0] * a[0];
        for(int i=1; i<n; ++i){
            t[i] = t[j] / a[i] * a[i];
            if(t[i] < t[j])
                t[i] += a[i];
            if(a[i] <= a[j] && t[i] <= t[j])
                t[i] += a[i];
            if(a[i] > a[j] && t[i] < t[j])
                t[i] += a[i];
            if(t[i] > m){
                t[i] -= a[i];
                if(t[i] < t[j] || (t[i] == t[j] && a[i] < a[j]))
                    j = i;
            }
        }

        bool hope = false;
        for(int i=0; i<n; ++i){
            if(i != j && t[i] == t[j] && a[i] == a[j])
                hope = true;
        }

        if(hope)
            cout << n << endl;
        else
            cout << (j+1) << endl;
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
using namespace std;
int main(void){

    string b;
    cin >> b;
    
    if(b == "A") cout << "T" << endl;
    else if(b == "T") cout << "A" << endl;
    else if(b == "C") cout << "G" << endl;
    else if(b == "G") cout << "C" << endl;

    return 0;
}


Measured memory_bytes: 256