akhauriyash/Code-Regression huggingface dataset:
import numpy as np
from scipy.sparse.csgraph import floyd_warshall

N,M,L = map(int,input().split())
gurahu = np.zeros((N,N))

for k in range(M):
    a,b,c = map(int,input().split())
    gurahu[a-1,b-1] = c
    gurahu[b-1,a-1] = c

gurahu = floyd_warshall(gurahu, directed=False)
gurahu = np.where((gurahu <= L) & (gurahu > 0), 1, 0)
gurahu = floyd_warshall(gurahu) - np.ones((N, N))

Q = int(input())

for k in range(Q):
    s,t = map(int,input().split())
    ans = gurahu[s-1,t-1]
    if ans == float('inf'):
        print(-1)
    else:
        print(int(ans))

Measured memory_bytes: 18836
/**
 *      ABC 84 C
 *      author  : kyomukyomupurin
 *      created : 2018-09-26 12:46:13
**/

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N; cin >> N;
    int C[N - 1] = {}; int S[N - 1] = {}; int F[N - 1] = {};

    for (auto i = 0; i < N - 1; ++i) {
        cin >> C[i] >> S[i] >> F[i];
    }

    for (auto i = 0; i < N; ++i) {
        int t = 0;
        for (auto j = i; j < N - 1; ++j) {
            if (t < S[j]){
                t += S[j] - t;
            }
            else if (t % F[j] == 0){
                ;
            }
            else {
                t += F[j] - t % F[j];
            }
            t += C[j];
        }
        cout << t << endl;
    }
    
    return 0;
}


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

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    vector<int> diff(m - 1);
    for (int i = 0; i < m; ++i){
        cin >> x[i];
    }
    if (n >= m){
        cout << 0 << endl;
        return 0;
    }
    sort(x.begin(), x.end());
    for (int i = 0; i < m - 1; ++i){
        diff[i] = abs(x[i + 1] - x[i]);
    }
    sort(diff.begin(), diff.end());
    for (int i = 0; i < n - 1; ++i){
        diff.pop_back();
    }
    int ans = 0;
    for (int i = 0; i < diff.size(); ++i){
        ans += diff[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
import sys
input = sys.stdin.readline
n = int(input())
a = [int(input()) for i in range(n)]
cur = -1
c = 0
for i in a:
  pre,cur = cur,i
  if cur == 0:
    continue
  elif cur == pre + 1:
    c += 1
  elif cur <= pre:
    c += cur
  else:
    print(-1)
    exit()
print(c)

Measured memory_bytes: 11048
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <list>
#include <stack>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#include <functional>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi   vector<int> 
#define   co(x)  cout << x << '\n' 
#define   dbg(x)  cerr << #x << " = " << x << '\n' 
#define   bitcount(x)  (int)__builtin_popcount(x) 
#define   sz(x)  (int)x.size()
#define   all(a) a.begin(),a.end() 
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std;

inline void solve(){
    int  n, a, b, c, ans = 100000000 ; 
    cin >> n >> a >> b >> c ; 
    vi bamboo(n);
    for (int &i: bamboo) cin >> i ; 
    for (int i=1;i<(1<<n);i++) { // 1 st.......
        int  x=0 , f = 0, h = 0 ; 
        for (int t=0;t<n;t++){
            if ((i>>t)&1) h += bamboo[t],x++;
        }
        f += abs(a-h)+ (x-1)*10;
        for (int j=1;j<(1<<n);j++) { // 2 nd.......
            int x =0,s=0,h=0;
            if (i&j) continue; 
            for (int t=0;t<n;t++)
                if ((j>>t)&1) h += bamboo[t],x++;
            s += abs(b-h)+(x-1)*10;
            for (int k=1;k<(1<<n);k++) { // 3 rd.......
                int  x =0,t = 0, h=0;
                if (k&j or i&k) continue ; 
                for (int t=0;t<n;t++)
                    if ((k>>t)&1) h += bamboo[t],x++;
                t += abs(c-h)+(x-1)*10; 
                if (f + s + t < ans ) { 
                    ans = f + s + t ; 
                }
            } 
        } 
    } 
    co(ans) ; 
}

signed main()
{
    int n=1; // cin>>n;
    while (n--) solve();
    return 0;
}


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

int main(){
  string ANS = "Yes";
  string S;
  cin >> S;
  int count;
  for(int i=0; i<4;i++){
    count = 0;
    for(int j=0; j<4;j++){
      if(S.at(i) == S.at(j)){
        count++;
      }
    }
    if(count != 2){
    ANS = "No";
      break;
    }
  }
  
  
  cout << ANS << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

const ll INF=1e18;
vector<ll> two;

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

  ll N;
  cin>>N;
  vector<ll> A(N+1);
  rep(i,N+1) cin>>A[i];

  two.resize(N+1,INF);
  two[0]=1;
  for(int i=1;i<=min(N,60ll);i++) two[i]=two[i-1]*2;

  vector<ll> b(N+1,0);
  b[0]=1-A[0];
  if(A[0]>=2 or(A[0]==1&&N>0)){
    cout<<-1<<endl;
    return 0;
  }

  rep(i,N+1) if(two[i]<A[i]){
    cout<<-1<<endl;
    return 0;
  }

  for(int i=1;i<=N;i++){
    if(A[i]>2*b[i-1]){
      cout<<-1<<endl;
      return 0;
    }
    b[i]=min(2*b[i-1]-A[i],two[i]-A[i]);
  }

  b[N]=0;
  for(int i=N-1;i>=0;i--){
    chmin(b[i],A[i+1]+b[i+1]);
    chmin(b[i],two[i]-A[i]);
  }
  ll ans=0;
  rep(i,N) ans+=b[i];
  rep(i,N+1) ans+=A[i];
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 5576
#include<iostream>
using namespace std;
#include<cstdio>
#include<map>
#include<queue>
#include<string>
#include<algorithm>
#include<cstring>

typedef pair<string,int> P;

int main(){
  int kaku=0;
  string body;
  while(1){
  cin>>body;
  if(body=="0")return 0;
  map<string,int> used;
  queue<P> que;
  que.push(P(body,0));
  while(!que.empty()){
    P p =que.front();que.pop();
    string now = p.first;
    int co = p.second;
    int c=1;
    for(int i=0;i<body.size();i++){
      if(now[0]==now[i+1])c++;
    }
    if(c==body.size()){
      cout<<co<<endl;
      kaku=1;
      break;
    }
    if(used[now]==1)continue;
    used[now]=1;
    for(int i=0;i<body.size()-1;i++){
      string next=now;
    if(next[i]==next[i+1])continue;
    if((next[i]=='r' && next[i+1]=='b') || (next[i]=='b' && next[i+1]=='r')){
      next[i]='g';
      next[i+1]='g';
      que.push(P(next,co+1));
    }
    if((next[i]=='r' && next[i+1]=='g') || (next[i]=='g' && next[i+1]=='r')){
      next[i]='b';
      next[i+1]='b';
      que.push(P(next,co+1));
    }
    if((next[i]=='g' && next[i+1]=='b') || (next[i]=='b' && next[i+1]=='g')){
      next[i]='r';
      next[i+1]='r';
      que.push(P(next,co+1));
    }
  }
  }
  if(kaku==0)cout<<"NA"<<endl;
  kaku=0;
}
}

Measured memory_bytes: 3396
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <chrono>
#include <vector>

using namespace std;

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    vector<pair<int, int>> t;
    if (s[0] != '1' || s[n - 1] != '0')
    {
        cout << "-1" << endl;
        return 0;
    }

    for (int i = 0; i < n / 2; i++)
    {
        if (s[i] != s[n - i - 2])
        {
            cout << "-1" << endl;
            return 0;
        }
    }
    int pre = 1;
    int cur = 1;
    for (int i = 1; i < n; i++)
    {
        if (s[i] == '1' && i != n - 1)
        {
            pre = cur;
            cur = i + 1;
            t.push_back({pre, cur});
            for (int j = pre + 1; j < cur; j++)
            {
                t.push_back({j, cur});
            }
        }
        else if (i == n - 1)
        {
            t.push_back({n - 1, n});
        }
        else
        {
            continue;
        }
    }
    for (int i = 0; i < n - 1; i++)
    {
        cout << t[i].first << " " << t[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 2484
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	vector<int> vec(3);

	for (int i = 0; i < 3; ++i) {
		cin >> vec.at(i);
	}

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

	bool ans = true;

	for (int i = 0; i < 3; ++i) {
		if (i < 2) {
			if (vec.at(i) != 5) ans = false;
		}
		else {
			if (vec.at(i) != 7) ans = false;
		}
	}

	if (ans) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	
}

Measured memory_bytes: 3580
while True:
    m,f,r=map(int,input().split())
    if(m==-1 and f==-1 and r==-1):
        break
    sum=m+f
    if(m==-1 or f==-1):
        print("F")
    elif(sum>=80):
        print("A")
    elif(sum>=65 and sum<80):
        print("B")
    elif(sum>=50 and sum<65):
        print("C")
    elif(sum>=30 and sum<50):
        if(r>=50):
            print("C")
        else:
            print("D")
    elif(sum<30):
        print("F")
    


Measured memory_bytes: 5596
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ull  unsigned long long
#define pb push_back

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 1200;
bitset < 100000 > c[30];
main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt","w", stdout);
    int n;
    cin >> n;
    int dx = 0;
    int dy = 0;
    int ct = 0;
    for (int i = 1; i <= n; i++){
        int t, x, y;
        cin >> t >> x >> y;
        int d = abs(x - dx) + abs(y - dy);
        if (d > t - ct || (t - ct - d) % 2){
            cout << "No";
            return 0;
        }
        dx = x;
        dy = y;
        ct = t;
    }
    cout << "Yes";
}


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

#define REP(i,n) for(long long i=0; i < (n); ++i)
#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)

using ll = long long;
#define INF 1e9

int N, M, Q;
vector<int> L, R, p, q;

int main(){
  cin >> N >> M >> Q;
  L.resize(M), R.resize(M), p.resize(Q), q.resize(Q);
  vector<vector<int>> table(N, vector<int>(N)),sum(N, vector<int>(N+1, 0));
  REP(i, M){
    cin >> L[i] >> R[i];
    L[i]--, R[i]--;
    table[L[i]][R[i]]++;
  }
  REP(i, N){
    REP(j, N){
      sum[i][j+1] = sum[i][j] + table[i][j];
    }
  }
  REP(i, Q){
    cin >> p[i] >> q[i];
    p[i]--, q[i]--;
  }
  REP(i, Q){
    int ans = 0;
    FOR(j, p[i], q[i]+1){
      ans += sum[j][q[i]+1]- sum[j][p[i]];
    }
    cout << ans << endl;
  }
  
  return 0;
}


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


def ans():
    for i in range(n):
        if a[i] % 2 == 0 and (a[i] % 3 != 0 and a[i] % 5 != 0):
            print('DENIED')
            return
    print('APPROVED')


ans()

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

const int MAX = 50;
int dx[8] = { 1,0,-1,0,1,1,-1,-1 };
int dy[8] = { 0,1,0,-1,1,-1,1,-1 };
int map[MAX][MAX];
int color[MAX][MAX];

void dfs(int x, int y, int c)
{
	color[x][y] = c;

	for (int i = 0; i < 8; i++) {
		int nx = x + dx[i];
		int ny = y + dy[i];

		if (nx >= 0 && nx < MAX&&ny >= 0 && ny < MAX) {
			if (map[nx][ny] == 1) {
				if (color[nx][ny] == 0) {
					dfs(nx, ny, c);
				}
			}
		}
	}
}

int main()
{
	while (true) {
		int w, h;
		cin >> w >> h;

		if (w == 0 && h == 0) {
			break;
		}

		for (int i = 0; i < MAX; i++) {
			for (int j = 0; j < MAX; j++) {
				map[i][j] = 0;
				color[i][j] = 0;
			}
		}

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				cin >> map[i][j];
			}
		}

		int ans = 0;

		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (map[i][j] == 1) {
					if (color[i][j] == 0) {
						ans++;
						dfs(i, j, ans);
					}
				}
			}
		}

		cout << ans << endl;
	}

	return 0;
}

Measured memory_bytes: 3216
def run(x, y, z):
    '''

    '''
    process_time = int(x/y) + 1 if x%y != 0 else int(x/y)
    print(process_time*z)



if __name__ == '__main__':
    x, y, z = list(map(int, input().split()))
    run(x, y, z)

Measured memory_bytes: 9104
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            int ans = 0;
            int mx = Math.max(a, Math.max(b, c));
            int sum = a + b + c;

            if ((3 * mx - sum) % 2 == 0) {
                ans = (3 * mx - sum) / 2;

            } else {
                ans = (3 * (mx + 1) - sum) / 2;

            }

            // 出力
            out.println(ans);

        }

    }
}



Measured memory_bytes: 21844
x,k,d=map(int,(input().split()))

x=abs(x)
zx=x
if x<d*k:
    wk,x=divmod(abs(x),d)
    k-=wk    
else:
    x-=d*k
    k=0

for i in range(k):
    xm=abs(x+d)
    xu=abs(x-d)
    x=min(xm,xu)
    k-=1
    if zx+x==d:
        if k%2!=0:
            x=zx
            break
        else:
            break
    zx=x
    
print(x)

Measured memory_bytes: 9204
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>

using namespace std;

#define size_t long
//
// #define vec2di(H, W)  vector<vector<int> >(H, vector<int>(W));
// #define vec2dc(H, W)  vector<vector<char> >(H, vector<char>(W));
// #define vec2dl(H, W)  vector<vector<long> >(H, vector<long>(W));
// #define vec2db(H, W)  vector<vector<bool> >(H, vector<bool>(W));


int main(int argc, char const *argv[]) {
  long N;
  scanf("%ld", &N);
  long A[N];
  long B[N];
  long D[N];
  long As = 0;
  long Bs = 0;
  bool g = 1;
  for (size_t i = 0; i < N; i++) {
    scanf("%ld", &A[i]);
    As += A[i];
  }
  for (size_t i = 0; i < N; i++) {
    scanf("%ld", &B[i]);
    Bs += B[i];
    D[i] = B[i] - A[i];
    g &= D[i] <= 0;
  }
  if (g) {
    printf("0\n");
    return 0;
  }
  if (As < Bs) {
    printf("-1\n");
    return 0;
  }
  sort(D, D+N);
  long x = 0;
  long r = 0;
  for (size_t i = 0; i < N; i++) {
    // prlongf("%d ", D[i]);
    if (D[i] > 0) {
      x += D[i];
      r++;
    }
  }
  for (size_t i = 0; D[i] < 0 && i < N; i++) {
    if (x <= -D[i]) {
      printf("%ld\n", r + 1);
      return 0;
    } else {
      x -= -D[i];
      r++;
    }
  }
  return 0;
}


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
using vec = vector<int>;

int main() {
int N;
  cin >> N;
  int ans ;
  if(N >=64 ) ans = 64;
  else if(N >= 32) ans =32;
  else if (N >=16) ans =16;
  else if (N >= 8) ans = 8;
  else if(N >= 4) ans =4;
  else if (N >=2)ans =2;
  else ans =1;
  printf("%d\n",ans);
  
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
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 <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

struct range_sum_query {
    int n;
    vector<int> dat;
    range_sum_query(int n_=0) {
        n=1;
        while(n<n_) n*=2;
        dat.resize(n*2-1,0);
    }
    // a_i=x
    void add(int i,int x) {
        i += n-1;
        dat[i]+=x;
        while(i>0) {
            i=(i-1)/2;
            dat[i]=dat[i*2+1]+dat[i*2+2];
        }
    }
    // get sum of range[a,b]
    int query(int a,int b) {
        return query(a,b,0,0,n);
    }
    int query(int a,int b,int k,int l,int r) {
        if(r<=a or b<=l) return 0;
        if(a<=l and r<=b) return dat[k];
        int sl=query(a,b,k*2+1,l,(r+l)/2);
        int sr=query(a,b,k*2+2,(r+l)/2,r);
        return (sl+sr);
    }
};

signed main() {
    int n,q;
    cin>>n>>q;
    range_sum_query seg(n);
    while(q--) {
        int com,x,y;
        cin>>com>>x>>y;
        if(com) {
            cout<<seg.query(x-1,y)<<endl;
        } else {
            seg.add(x-1,y);
        }
    }
    return 0;
}

Measured memory_bytes: 4924
local s = io.read()
local n = #s
local t = {}
for i = 1, n do
  t[i] = s:sub(i, i) == "1"
end
local function solve()
  if t[n] then print(-1) return end
  if not t[1] then print(-1) return end
  for i = 1, n - 1 do
    if t[i] ~= t[n - i] then print(-1) return end
  end
  local node = 1
  local tasks = {}
  for i = 1, n - 1 do
    print(node .. " " .. i + 1)
    if t[i] then node = i + 1 end
  end
end
solve()


Measured memory_bytes: 11796
from collections import Counter

N = int(input())
S = input()


unique = 0
not_unique = 1
for v in Counter(S).values():
    if 1 == v:
        unique += 1
    else:
        not_unique *= v + 1

print((2 ** unique * not_unique - 1 ) % (10 ** 9 + 7))

Measured memory_bytes: 40048
N = int(input())
answer = 0
for i in range(1,N+1):
    if i % 3 != 0:
        if i % 5 != 0:
            answer += i
            continue
    if i % 5 != 0:
        if i % 3 != 0:
            answer += i
            continue
print(answer)

Measured memory_bytes: 9180
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

int main()
{
	int H, W;
	cin >> H >> W;
	
	vector<string> S;
	for (auto i = 0; i < H; ++i)
	{
		string s;
		cin >> s;
		S.push_back(s);
	}

	int next[8][2] = {
		{0, -1},
		{1, -1},
		{1, 0},
		{1, 1},
		{0, 1},
		{-1, 1},
		{-1, 0},
		{-1, -1},
	};

	for (auto i = 0; i < H; ++i)
	{
		for (auto j = 0; j < W; ++j)
		{
			if (S[i][j] == '#')
			{
				continue;
			}

			auto count = 0;
			for (auto k = 0; k < 8; ++k)
			{
				auto nextX = next[k][0] + j;
				auto nextY = next[k][1] + i;

				if (nextY < 0 || nextY >= H || nextX < 0 || nextX >= W)
				{
					continue;
				}

				if (S[nextY][nextX] == '#')
				{
					++count;
				}
			}

			S[i][j] = count + '0';
		}
	}

	for (auto i = 0; i < H; ++i)
	{
		cout << S[i] << endl;
	}

	return 0;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const ll O = 1e18;
ll a[100005];
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    REP(i, 0, n) cin >> a[i];
    sort(a, a+n);
    if(a[0] == 0) {
        cout << 0 << "\n";
        return 0;
    } 
    ll o = 1;
    int pq = n, f = 0;
    while(pq > 0) {
        o *= a[0];
        if(o > O) { 
            f = 1;
            break;
        }
        --pq;
    }
    if(f) {
        cout << -1 << "\n";
        return 0; 
    }
    reverse(a, a+n);
    long double p = 1;
    REP(i, 0, n) {
        ll x = a[i];
        p *= x;

        if(p > O) {
            f = 1;
            break;
        }
    }
    if(f) p = -1;
    ll oo = p;
    cout << oo << "\n";
    return 0;
}


Measured memory_bytes: 4428
#include <bits/stdc++.h>
// #include <iostream>
// #include <vector>
// #include <map>
// #include <algorithm>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())

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

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

map<ll, ll> factor(ll n){
    map<ll, ll> mp;
    for (ll i = 2; i*i <= n; i++) {
        while (n % i == 0) {
            mp[i]++;
            n /= i;
        }
    }

    return mp;
}

void solve(){
    int H, W;
    cin >> H >> W;

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

    vector<vector<int>> history;
    int j = 0, N = 0;
    int prevx = 0, prevy = 0;
    bool state = false;
    for (int i = 0; i < H; i++) {
        for (int k = 0; k < W; k++) {
            if (state){
                // cout << prevy << " " << prevx << " " << j+1 << " " << i+1 << endl;
                history.push_back(vector<int>{prevy, prevx, i+1, j+1});
                state = false;
                a[i][j]++;
                N++;
            }

            if (a[i][j] & 1) {
                state = true;
                prevy = i+1;
                prevx = j+1;

            }

            if (i % 2 == 0) {
                if (j < W-1)
                    j += 1;
            }
            else {
                if (j > 0)
                    j -= 1;
            }
        }
    }

    cout << N << endl;
    for (int i = 0; i < (int)history.size(); i++) {
        for (int j = 0; j < 4; j++) {
            if (j == 0) cout << history[i][j];
            else cout << " " << history[i][j];
        }
        cout << endl;
    }

    return;
}

int main(int argc, char const* argv[])
{
    solve();
    return 0;
}


Measured memory_bytes: 9904
from sys import stdin,stdout

input = stdin.readline
print = stdout.write

n = int(input())

coins = [500,5]
d = {500:1000,5:5}

ans = 0

for i in coins:
    if i<=n:
        
        ans+= ((n//i) * d[i])
        n = n%i
        
print(str(ans))

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

void swap(int& a, int& b){
    int t = 0;
    t = a;
    a = b;
    b = t;
}

int main() {
  // freopen("A.txt", "r", stdin);
  int a,b,c;
  cin >> a >> b >> c;
  swap(a, b);
  swap(a, c);
  cout << a <<" "<< b << " " << c;
}



Measured memory_bytes: 256
N = int(input())
nums = [int(n) for n in input().split(" ")]

i = 0
def atcode(nums):
    global i
    for n in nums:
        if n%2==0:
            pass
        elif n==0:
            return i
        else:
            return i
    nums = [n/2 for n in nums]
    i += 1
    return atcode(nums)

print(atcode(nums))

Measured memory_bytes: 3188
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#define fr first
#define sc second
#define INF (2 << 28)
using namespace std;

typedef pair<int, bool> iP;
typedef pair<int, iP> iiP;

int n, b[2][101];
int used[2][101][201];

int Dijkstra(){
  
  fill_n(**used, 2 * 101 * 201, INF);
  priority_queue<iiP, vector<iiP>, greater<iiP> > que;
  used[0][0][0] = 0, used[1][0][0] = 0;
  que.push(iiP(0, iP(0, false))), que.push(iiP(0, iP(0, true)));
  while(!que.empty()){
    iiP p = que.top(); que.pop();
    int cnt = p.fr, y = p.sc.fr;
    bool judge = p.sc.sc;
    
    //cout << p.sc.sc << " " << p.sc.fr << " " << p.fr << endl;
    if(p.sc.fr == n-1 && b[judge][y] != 2) return cnt;

    int c = 0;
    if(b[judge][y] == 1){
      while(b[judge][y + c] == 1 && y + c < n) c++;
      c--;
      if(y + c == n-1) return cnt;
    }
    else if(b[judge][y] == 2){
      while(b[judge][y + c] == 2) c--;
    }
    for(int i = 0; i < 3; i++){
      if(y + c + i < n && cnt + 1 < used[!judge][y + c + i][cnt + 1]){
	que.push(iiP(cnt + 1, iP(y + c + i, !judge)));
	used[!judge][y + c + i][cnt + 1] = cnt + 1;
      }
    }
  }
  return INF;

}    

int main(){
  
  while(cin >> n, n){
    for(int j = 0; j < 2; j++){
      for(int i = 0; i < n; i++) cin >> b[j][i];
    }
    
    int d = Dijkstra();
    if(d == INF) cout << "NA" << endl;
    else cout << d << endl;
  }

}

Measured memory_bytes: 1364
#include<bits/stdc++.h>
using namespace std;
#define cs const
#define re register
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define y1 shinkle
#define fi first
#define se second
#define bg begin
cs int RLEN=1<<20|1;
inline char gc(){
    static char ibuf[RLEN],*ib,*ob;
    (ib==ob)&&(ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
    return (ib==ob)?EOF:*ib++;
}
#define gc getchar
inline int read(){
    char ch=gc();
    int res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline ll readll(){
    char ch=gc();
    ll res=0;bool f=1;
    while(!isdigit(ch))f^=ch=='-',ch=gc();
    while(isdigit(ch))res=(res*10)+(ch^48),ch=gc();
    return f?res:-res;
}
inline char readchar(){
	char ch=gc();
	while(isspace(ch))ch=gc();
	return ch;
}
inline int readstring(char *s){
	int top=0;char ch=gc();
	while(isspace(ch))ch=gc();
	while(!isspace(ch)&&ch!=EOF)s[++top]=ch,ch=gc();
	s[top+1]='\0';return top;
}
template<typename tp>inline void chemx(tp &a,tp b){a=max(a,b);}
template<typename tp>inline void chemn(tp &a,tp b){a=min(a,b);}
ll a,b,c,d;
map<ll,ll>mp;
ll dfs(ll n){
	if(n==0)return 0;
	if(mp.count(n))return mp[n];
	ll res=6e18;
	if(res/n>=d)chemn(res,n*d);
	if(n==1)return res;
	ll k=n/2*2;
	chemn(res,dfs(n/2)+a+d*(n-k));
	if(n>2)chemn(res,dfs(n/2+1)+a+d*(k+2-n));
	k=n/3*3;
	chemn(res,dfs(n/3)+b+d*(n-k));
	chemn(res,dfs(n/3+1)+b+d*(k+3-n));
	k=n/5*5;
	chemn(res,dfs(n/5)+c+d*(n-k));
	chemn(res,dfs(n/5+1)+c+d*(k+5-n));
	return mp[n]=res;
}
void solve(){
	ll x=readll();mp.clear();
	a=readll(),b=readll(),c=readll(),d=readll();
	cout<<dfs(x)<<'\n';
}
int main(){
	int T=read();
	while(T--)solve();
	return 0;
}

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

ll a[101010];

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n,k;
	cin>>n>>k;
	ll tp=0;
	ll v=0;
	for (int i=0;i<n;i++){
		cin>>a[i];
		if (a[i]>0) tp+=a[i];
	}
	ll hb=0;
	for (int i=0;i<k;i++){
		if (a[i]<0) hb+=a[i];
	}
	v=max(v, tp+hb);
	for (int i=k;i<n;i++){
		if (a[i-k]<0) hb-=a[i-k];
		if (a[i]<0) hb+=a[i];
		v=max(v, tp+hb);
	}
	ll hw=0;
	for (int i=0;i<k;i++){
		if (a[i]>0) hw+=a[i];
	}
	v=max(v, tp-hw);
	for (int i=k;i<n;i++){
		if (a[i-k]>0) hw-=a[i-k];
		if (a[i]>0) hw+=a[i];
		v=max(v, tp-hw);
	}
	cout<<v<<endl;
}

Measured memory_bytes: 1024
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

S = str(input())

if S[0]==S[1]==S[2]:
    print('No')
else:
    print('Yes')

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



int main(){
	cin.tie(0)->sync_with_stdio(0);
	int n, x, t;
	cin >> n >> x >> t;
	cout << (n + x - 1) / x * t << "\n";
	return 0;
}

/*

*/

////////////////////////////////////////////////////////////////////////////////////////
//                                                                                    //
//                                   Coded by Aeren                                   //
//                                                                                    //
////////////////////////////////////////////////////////////////////////////////////////

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

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

    if (n >= m / 2) {
        cout << (m / 2) << endl;
    } else {
        cout << (n + (m - n * 2) / 4) << endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <limits.h>


int main(void)
{
	int n;
	scanf("%d",&n);
	int a[n];
	int i , j;
	int max = INT_MIN;
	int min;
	for( i = 0; i < n; i++)
	{
		scanf("%d",&a[i]);
	}
	min = a[0];
	
	for( i = 1; i < n; i++)
	{
		if(max > (a[i]-min)){}
			else{
				max = a[i] - min;
			}
			if( min < a[i]){}
			else{
				min = a[i];
			}
	}
	
	printf("%d\n",max);
	
	return 0;
}


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

int main(){
	string str;
	cin >> str;
	
	/*vector<int> num(str.size());
	
	for(int i=0;i<str.size();i++){
		if(str.at(i)=='0'){
			num.at(i)=0;
		}
		else if(str.at(i)=='1'){
			num.at(i)=1;
		}
	}
	for(int i=0;i<str.size();i++){
	cout << num.at(i);
	}*/
	
	/*for(int i=0;i<str.size();i++){
	cout << str.at(i);
	}*/
	
	int odd_zero=0;
	int even_zero=0;
	int odd_one=0;
	int even_one=0;
	
	for(int i=0;i<str.size();i=i+2){
		if(str.at(i)=='1'){
			even_one++;
		}
		else if(str.at(i)=='0'){
			even_zero++;
		}
	}
	for(int i=1;i<str.size();i=i+2){
		if(str.at(i)=='1'){
			odd_one++;
		}
		else if(str.at(i)=='0'){
			odd_zero++;
		}
	}
	
	/*cout << even_zero << endl;
	cout << even_one << endl;
	cout << odd_zero << endl;
	cout << odd_one << endl;*/
	

	int zero_start=0;
	int one_start=0;
	
	zero_start=even_zero+odd_one;
	one_start=even_one+odd_zero;
	
	if(zero_start>=one_start){
		cout << one_start << endl; 
	}
	else if(zero_start<one_start){
		cout << zero_start << endl; 
	}
	

}

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

long long int cal(long long int i){
    if(i==1)return 1;
    return 2*cal(i/2)+1;
}

int main()
{
    
    cin>>n;
    cout<<cal(n)<<'\n';

    return 0;
}


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

#define N 200
#define H 1000
#define R 1000
#define MAX(A,B) \
  ( (A) > (B) ? (A) : (B) )

static int h[ N ];
static int r[ N ];
static int n;

static int k_operafan[ H + 1 ][ R + 1 ];

static int
dpFSA (
  int rh,
  int rr
  )
{
  int i;

  if ( ~k_operafan[ rh ][ rr ] ) ;
  else
  {
    k_operafan[ rh ][ rr ] = 0;

    for ( i = 0; i < n; ++i )
    {
      int res;

      if ( h[ i ] >= rh
        || r[ i ] >= rr ) continue ;

      res = dpFSA ( h[ i ], r[ i ] ) + 1;
      k_operafan[ rh ][ rr ] = MAX( k_operafan[ rh ][ rr ], res );
    }
  }

  return ( k_operafan[ rh ][ rr ] );
}

/** Application main entry point. */
int
main (
  int     argc,
  char  * argv[ ]
  )
{
  int i;

  for ( ; ; )
  {
    n = 0;

    scanf ( "%d", &i );
    if ( !( i ) ) break ;
    while ( i-- )
    {
      scanf ( "%d%d", &h[ n ], &r[ n ] );
      ++n;
    }
    scanf ( "%d", &i );
    while ( i-- )
    {
      scanf ( "%d%d", &h[ n ], &r[ n ] );
      ++n;
    }

    memset ( k_operafan, -1, sizeof ( k_operafan ) );
    printf ( "%d\n", dpFSA ( H, R ) );
  }

  return ( 0 );
}

Measured memory_bytes: 0
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;

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


    int main(){
      int n,m;
      cin>>n>>m;
      VEC(int,x,m);
      if(n>=m){
        cout<<0<<endl;
        return 0;
      }
      sort(x.begin(),x.end());
      auto dist = vec(int,m-1);
      rep(i,m-1)dist[i] = x[i+1]-x[i];
      int ans = abs(x[m-1]-x[0]);
      sort(dist.begin(),dist.end(),greater<int>());
      rep(i,n-1)ans -= dist[i];
      cout<<ans<<endl;
    }


Measured memory_bytes: 1024
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int w = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int wa = w+a, wb = w+b, diff = b-a;
		int result = 0;
		if(-w <= diff && diff <= w) {
			result = 0;
		}else {
			if(diff > 0) {
				result = b-wa;
			}else {
				result = a-wb;
			}
		}
		System.out.println(result);
	}
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define FOR0(i,n) for(int i=0, _##i=(n); i<_##i; ++i)
#define FOR(i,l,r) for(int i=(l), _##i=(r); i<_##i; ++i)
#define FORD(i,l,r) for(int i=(r), _##i=(l); --i>=_##i; )
#define repi(i,a) for(__typeof((a).begin()) i=(a).begin(), _##i=(a).end(); i!=_##i; ++i)
#define dwni(i,a) for(__typeof((a).rbegin()) i=(a).rbegin(), _##i=(a).rend(); i!=_##i; ++i)
#define SZ(a) ((int)((a).size()))
#define printCase() "Case #" << caseNum << ": "
#define pb push_back
#define mp make_pair
#define EPS (1e-9)
#define PI 3.1415926535
#define inf ((int)1e9)
#define INF ((ll)9e18)
#define mod (1000000000 + 7)
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
#define ff first
#define ss second
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define N 3005
int main() {
    SYNC
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    bitset<N> pw, ps;
    pw[0] = ps[0] = 1;
    FOR(i,100*a,N) {
        pw[i] = pw[i] | pw[i-100*a];
    }
    FOR(i,100*b,N) {
        pw[i] = pw[i] | pw[i-100*b];
    }
    FOR(i,c,N) {
        ps[i] = ps[i] | ps[i-c];
    }
    FOR(i,d,N) {
        ps[i] = ps[i] | ps[i-d];
    }

    int aw=0 ,as=0;
    long double ans = -1.0;
    FOR(tot, 1, f+1) {
        FOR(water, 1, tot+1) {
            int sugar = tot - water;
            if(pw[water] && ps[sugar] && sugar <= e*water/100) {
                long double cur = (100.0 * sugar)/tot;
                if(cur > ans) {
                    ans = cur;
                    aw = tot; as = sugar;
                }
            }
        }
    }
    cout << aw << " " << as;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
#include<queue>
#include<stack>
#include<math.h>
#include<map>
typedef long long int ll;
using namespace std;
#define maxn 0x3f3f3f3f
const int mm=1e6;
ll d[mm];
map<ll,ll> name,vis;
int main()
{
	ll n,m,i,j; string s,ss,sss;
   cin>>n; ll k=0,kk=0;
   for(i=0;i<n;i++)
   {
   cin>>d[i];name[d[i]]++;}
   for(i=0;i<n;i++)
   {
   	if(vis[d[i]]==0)
   	{
   	   k+=((name[d[i]]-1)*name[d[i]])/2;
   	   vis[d[i]]=1;
	}
   }
   for(i=0;i<n;i++)
   {
   	 kk=k;
   	 kk=kk-(name[d[i]]-1)*name[d[i]]/2;
   	 kk=kk+(name[d[i]]-1-1)*(name[d[i]]-1)/2;
   	 printf("%lld\n",kk);
   }
   

}

Measured memory_bytes: 18944
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;

int main(){ 
   string s,t;
   cin>>s>>t;
   int flag=0;
   for(int i=0;i<s.size();i++){
      char u=s[s.size()-1];
      s=u+s;
      s.pop_back();
      if(s==t) flag=1;

   }
   (flag==1)? cout<<"Yes":cout<<"No";

   
}

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

int main() {
  int n = 0;
  cin >> n;
  int ans = 0;
  vector<ll> l(n);
  rep(i,n) cin >> l[i];
  for(int i = 0; i < n; ++i) {
    for(int j = i + 1; j < n; ++j) {
      if(l[i] == l[j]) continue;
      for(int k = j + 1; k < n; ++k) {
        bool isok = true;
        if(abs(l[i] - l[j]) >= l[k] || l[i] + l[j] <= l[k] ) isok = false;
        if(l[i] == l[j] || l[i] == l[k] || l[j] == l[k]) isok = false;
        if(isok) ++ans;
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<string.h>
int main()
{
	char s[200001];
	int a,x=0,i;
	scanf("%s",s);
	a=strlen(s);
	for(i=0;i<a;i++){
		x+=s[i]-'0';
	}
	if(x%9==0) printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 1808
#include <iostream>
#include <string>

using namespace std;

int main(){
  int l;
  string s;
  cin >> s;
  l=s.size();
  while(1){
    s.pop_back();
    s.pop_back();
    l-=2;
    if(s.substr(0,l/2)==s.substr(l/2)){
      break;
    }
  }
  cout << l << endl;
}


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

using namespace std;

//ue 0
//migi 1
//shita 2
//hidari 3

int main(int argc, char const *argv[])
{
	int n;
	int x1,y1,x2,y2;

	while(1){
		cin>>n;
		if(n==0) break;

		int m;
		vector<int> v[n+1];
		for(int i1=0;i1<n+1;i1++){
			cin>>m;
			vector<int> temp;
			for(int i2=0;i2<m;i2++){
				cin>>x2>>y2;

				if(i2!=0) {
					if(x2-x1>0) {//migi
						for(int i3=0;i3<x2-x1;i3++) temp.push_back(1);
					}
					if(x2-x1<0) {//hidari
						for(int i3=0;i3<x1-x2;i3++) temp.push_back(3);
					}
					if(y2-y1>0) {//ue
						for(int i3=0;i3<y2-y1;i3++) temp.push_back(0);
					}
					if(y2-y1<0) {//shita
						for(int i3=0;i3<y1-y2;i3++) temp.push_back(2);
					}
				}
				x1=x2;
				y1=y2;
			}
			v[i1]=temp;
		}

		for(int i1=1;i1<n+1;i1++){

			bool ok = false;
			if(v[i1].size()==v[0].size()){
				for(int i2=0;i2<4;i2++){
					int i3;
					for(i3=0;i3<v[0].size();i3++){
						int dif=(v[0][i3]+i2)%4;
						if(dif!=v[i1][i3]) break;
					}

					if(i3==v[0].size()) ok=true;

					reverse(v[0].begin(), v[0].end());
					for(i3=0;i3<v[0].size();i3++){
						int dif=(v[0][i3]+i2)%4;
						if(dif!=v[i1][i3]) break;
					}

					if(i3==v[0].size()) ok=true;

					reverse(v[0].begin(), v[0].end());
				}

				
			}
			if(ok) cout<<i1<<endl;

		}
		cout<<"+++++"<<endl;


	}
	return 0;
}

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

#define int long long
#define pb push_back
#define in insert
#define F first
#define S second
#define mod 1000000007
#define endl '\n'
#define all(x)  x.begin(),x.end()
#define w(x) int x;cin>>x; while(x-->0)
#define memset(a,b) memset(a,b,sizeof(a))
#define debug(x) cout << "[ " << #x  << " : " << x << " ]" << endl;

void fast()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

}
/*
think fast
think simple
*/
void mysol()
{
	int n, k;
	cin >> n >> k;
	int arr[n];
	for (int &a : arr)
		cin >> a;
	sort(arr, arr + n);
	cout << accumulate(arr, arr + k, 0ll);
}

int32_t main()
{
	fast();
	// w(t)
	{
		mysol();
	}
	//cerr << sizeof(dp)*(1e-6) << " megabytes\n";
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
int main(){
	char a[110], b[110], c[110], t='a';
	int ap=0, bp=0, cp=0;
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	
	while(1){
		if(t=='a'){
			if(a[ap]!='\0'){
				t=a[ap];
				ap++;
			}
			else{
				printf("A");
				return 0;
			}
		}
		if(t=='b'){
			if(b[bp]!='\0'){
				t=b[bp];
				bp++;
			}
			else{
				printf("B");
				return 0;
			}
		}
		if(t=='c'){
			if(c[cp]!='\0'){
				t=c[cp];
				cp++;
			}
			else{
				printf("C");
				return 0;
			}
		}
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define EPS 1e-12
typedef complex<double> Point;
typedef vector<Point> VP;
#define X real()
#define Y imag()
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

double dot(Point a, Point b) {
  return a.X*b.X + a.Y*b.Y;
}

Point proj(Point a1, Point a2, Point p) {
  return a1 + dot(a2-a1, p-a1)/norm(a2-a1) * (a2-a1);
}

VP crosspointLC(Point a1, Point a2, Point c, double r) {
  VP ps;
  Point ft = proj(a1, a2, c);
  //if (!GE(r*r, norm(ft-c))) return ps;

  Point dir = sqrt(max(r*r - norm(ft-c), 0.0)) / abs(a2-a1) * (a2-a1);
  ps.push_back(ft + dir);
  ps.push_back(ft - dir);
  return ps;
}

namespace std {
  bool operator<(const Point a, const Point b) {
    return a.X != b.X ? a.X < b.X : a.Y < b.Y;
  }
}

int main(void){
    double cx,cy,r;
    int q;
    cin>>cx>>cy>>r>>q;
    rep(i,q){
        double x1,y1,x2,y2;
        cin>>x1>>y1>>x2>>y2;
        VP ps = crosspointLC(Point(x1,y1),Point(x2,y2),Point(cx,cy),r);
        sort(all(ps));
        printf("%.9f %.9f " ,ps[0].X,ps[0].Y);
        printf("%.9f %.9f\n",ps[1].X,ps[1].Y);
    }
    return 0;
}

Measured memory_bytes: 3284
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(void)
{
    char mojiretu[1001]={0};
    int i;
    scanf("%[^\n]",mojiretu);
    for(i=0;i<strlen(mojiretu);i++)
    {
        if(mojiretu[i]>96&&mojiretu[i]<123)
            mojiretu[i]-=32;
        printf("%c",mojiretu[i]);
    }
    printf("\n");
    return 0;
}

Measured memory_bytes: 524
#include<bits/stdc++.h>
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long
using namespace std;
int a[20][20];
int cost[20];
int main()
{
    Fast;
    long long n,m,x;
    cin>>n>>m>>x;
    for(int i=0;i<n;i++){
        cin>>cost[i];
        for(int j=0;j<m;j++){
            cin>>a[i][j];
        }
    }
    long long total=1<<n;
    long long ans=1000000000;
    for(int i=0;i<total;i++){
        long long temp=0LL;
        vector<int>v(m+1);
        for(int j=0;j<n;j++){
            if((i>>j)&1){
                temp+=cost[j];
                for(int k=0;k<m;k++){
                    v[k]+=a[j][k];
                }
            }
        }
        bool ok=true;
        for(int k=0;k<m;k++){
            if(v[k]<x){
                ok=false;
            }
        }
        if(ok){
            ans=min(ans,temp);
        }
    }
    if(ans==1e9){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3648
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

int n,k,dep[maxn],vis[maxn],cnt[maxn],U[maxn],V[maxn];
vector <int> mp[maxn];

inline void dfs(int u)
{
	vis[u]=1;
	for(int i=0;i<mp[u].size();i++)
	{
		int v=mp[u][i];
		if(vis[v]) continue;
		dep[v]=dep[u]+1; dfs(v);
	}
}

int main()
{
	n=read(); k=read();
	for(int i=1;i<n;i++)
	{
		int u=read(),v=read(); U[i]=u; V[i]=v;
		mp[u].push_back(v); mp[v].push_back(u);
	}
	int ans=0;
	if(k%2==0)
	{
		for(int i=1;i<=n;i++)
		{
			dep[i]=1; dfs(i);
			for(int j=1;j<=n;j++) vis[j]=0;
			for(int j=1;j<=2000;j++) cnt[j]=0;
			for(int j=1;j<=n;j++) cnt[dep[j]]++;
			
			int x=k/2+1,tmp=0;
			for(int j=1;j<=x;j++) tmp+=cnt[j]; ans=max(ans,tmp);
		}
	}
	else
	{
		for(int i=1;i<n;i++)
		{
			for(int j=1;j<=2000;j++) cnt[j]=0;
			for(int j=1;j<=n;j++) vis[j]=0,dep[j]=0;
			dep[U[i]]=1; vis[V[i]]=1; dfs(U[i]);
			for(int j=1;j<=n;j++) cnt[dep[j]]++;
			
			for(int j=1;j<=n;j++) vis[j]=0,dep[j]=0;
			dep[V[i]]=1; vis[U[i]]=1; dfs(V[i]);
			for(int j=1;j<=n;j++) cnt[dep[j]]++;
			
			int x=(k+1)/2,tmp=0;
			for(int j=1;j<=x;j++) tmp+=cnt[j]; ans=max(ans,tmp);
		}
	}
	cout<<n-ans<<endl;
	return 0;
}

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

int main(){
int m,h,temp;
string str;

while(1){
    cin>>str;
    if(str=="-"){
        break;
    }
    cin>>m;

    for(int i=0;i<m;i++){ /* 入れ替え回数 */
        cin>>h;
        for(int j=0;j<h;j++){
            for(int k=0;k<str.size()-1;k++){
        temp=str[k];
        str[k]=str[k+1];
        str[k+1]=temp;
            }
        }
    }

    cout<<str<<endl;
}

return 0;

}


Measured memory_bytes: 3180
#![allow(unused_imports, unused_macros, dead_code)]

macro_rules! min {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| min!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = min!($($ys),*);
        if $x < t { $x } else { t }
    }}
}
macro_rules! max {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        it.next().map(|z| it.fold(z, |x, y| max!(x, y)))
    }};
    ($x:expr) => ($x);
    ($x:expr, $($ys:expr),*) => {{
        let t = max!($($ys),*);
        if $x > t { $x } else { t }
    }}
}
macro_rules! ewriteln {
    ($($args:expr),*) => { let _ = writeln!(&mut std::io::stderr(), $($args),*); };
}
macro_rules! trace {
    ($x:expr) => { ewriteln!(">>> {} = {:?}", stringify!($x), $x) };
    ($($xs:expr),*) => { trace!(($($xs),*)) }
}
macro_rules! put {
    (.. $x:expr) => {{
        let mut it = $x.iter();
        if let Some(x) = it.next() { print!("{}", x); }
        for x in it { print!(" {}", x); }
        println!("");
    }};
    ($x:expr) => { println!("{}", $x) };
    ($x:expr, $($xs:expr),*) => { print!("{} ", $x); put!($($xs),*) }
}

const M: i64 = 1_000_000_007;

fn main() {
    let mut sc = Scanner::new();
    let a: u64 = sc.cin();
    let b: u64 = sc.cin();
    let c: u64 = sc.cin();
    let ans = c > a + b && 4 * a * b < (c - a - b).pow(2);
    put!(
        if ans {
            "Yes"
        } else {
            "No"
        });
}

use std::io::{self, Write};
use std::str::FromStr;
use std::collections::VecDeque;

struct Scanner { stdin: io::Stdin, buffer: VecDeque<String>, }
impl Scanner {
    fn new() -> Self { Scanner { stdin: io::stdin(), buffer: VecDeque::new() } }
    fn cin<T: FromStr>(&mut self) -> T {
        while self.buffer.len() == 0 {
            let mut line = String::new();
            let _ = self.stdin.read_line(&mut line);
            for w in line.split_whitespace() {
                self.buffer.push_back(String::from(w));
            }
        }
        self.buffer.pop_front().unwrap().parse::<T>().ok().unwrap()
    }
    fn chars(&mut self) -> Vec<char> { self.cin::<String>().chars().collect() }
    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T> { (0..n).map(|_| self.cin()).collect() }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
 
using namespace std;
 
vector<int> vec;
 
 
int main(void) {
	string a;
	int b;
	int c;
 
 
	cin >> a;
 
	if (a.find("7") != std::string::npos) {
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}
 
 
}

Measured memory_bytes: 3628