akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int main(){
    long long int N,ans=0;
    cin >> N;
    if(N%2==1){
        cout << 0 << endl;
    }else{
        N /= 2;
        for(long long int i=5;i<=N;i*=5){
            ans += N/i;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 384
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    flg = 1
    for i in range(H):
        for j in range(W):
            if flg == 1:
                print("#", end="")
            else:
                print(".",end="")
            flg = flg * -1
        if W % 2 == 0 :flg = flg * -1
        print()
    print()
    


Measured memory_bytes: 7008
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 5;
typedef long long ll;
template <typename T> void chkmax(T &x, T y) {x = max(x, y); }
template <typename T> void chkmin(T &x, T y) {x = min(x, y); } 
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
char s[MAXN][MAXN];
int main() {
	int n; read(n);
	if (n == 2) {
		puts("-1");
		return 0;
	}
	if (n == 5) {
		puts("aabbc");
		puts("bb.ec");
		puts("..fed");
		puts("c.f.d");
		puts("cbbaa");
		return 0;
	}
	for (int i = 1; i <= n; i++)
	for (int j = 1; j <= n; j++)
		s[i][j] = '.';
	if (n % 3 == 0) {
		for (int i = 1, j = 1; i <= n / 3; i++, j += 3) {
			s[j + 0][j + 0] = s[j + 0][j + 1] = 'a';
			s[j + 1][j + 2] = s[j + 2][j + 2] = 'a';
		}
	} else {
		int tn = n;
		if (n & 1) {
			int m = n - 7; tn -= 7;
			s[m + 1][m + 1] = s[m + 1][m + 2] = 'a';
			s[m + 1][m + 3] = s[m + 1][m + 4] = 'b';
			s[m + 1][m + 5] = s[m + 1][m + 6] = 'c';
			s[m + 2][m + 1] = s[m + 2][m + 2] = 'd';
			s[m + 2][m + 3] = s[m + 2][m + 4] = 'e';
			s[m + 3][m + 1] = s[m + 3][m + 2] = 'f';
			s[m + 3][m + 3] = s[m + 3][m + 4] = 'g';
			
			s[m + 2][m + 7] = s[m + 3][m + 7] = 'a';
			s[m + 4][m + 7] = s[m + 5][m + 7] = 'b';
			s[m + 6][m + 7] = s[m + 7][m + 7] = 'c';
			s[m + 4][m + 6] = s[m + 5][m + 6] = 'd';
			s[m + 6][m + 6] = s[m + 7][m + 6] = 'e';
			s[m + 4][m + 5] = s[m + 5][m + 5] = 'f';
			s[m + 6][m + 5] = s[m + 7][m + 5] = 'g';
		}
		for (int i = 1, j = 1; i <= tn / 2; i++, j += 2) {
			s[j + 0][j + 0] = s[j + 0][j + 1] = 'a';
			s[j + 1][j + 0] = s[j + 1][j + 1] = 'b';
			if (i != tn / 2) {
				s[j + 2][j + 0] = s[j + 3][j + 0] = 'c';
				s[j + 2][j + 1] = s[j + 3][j + 1] = 'd';
			} else {
				s[1][j + 0] = s[2][j + 0] = 'c';
				s[1][j + 1] = s[2][j + 1] = 'd';
			}
		}
	}
	for (int i = 1; i <= n; i++)
		printf("%s\n", s[i] + 1);
	return 0;
}


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

int main(int argc, char** argv){
  int N, M;
  const string MINUSINF = "-";
  
  cin >> N >> M;
  long long A[M+1];
  
  A[0]=0;
  for(int cnt0=1; cnt0<=M; cnt0++) {
    cin >> A[cnt0];
  }
  
  int w[10] = {0, 2, 5, 5, 4, 5, 6, 3, 7, 6};
  //dp[W]: マッチをW本消費してできる最大の数
  string dp[N+1];
  
//  memset(dp, 0, sizeof(dp));
  for (int i = 0; i <= N; ++i) dp[i] = MINUSINF;

  dp[0] = "";
  for(int j=0; j<=N; j++){
    string tmp = MINUSINF;
    for(int i=1; i<=M; i++){
      string tmp_i;
      if(j-w[A[i]] >= 0){
        if(dp[j-w[A[i]]] == MINUSINF) continue;
        tmp_i = to_string(A[i]) + dp[j-w[A[i]]];
        tmp_i = max(tmp_i, dp[j-w[A[i]]] + to_string(A[i]));
//       cout << "tmp_i: " << tmp_i << endl;
      }
      if(tmp_i.size() > tmp.size()) tmp = tmp_i;
      else if(tmp_i.size() == tmp.size()) tmp = max(tmp, tmp_i);

    }
    if(j != 0) dp[j] = tmp;
//    cout << "dp[" << j << "]: " << dp[j] << endl;
  }
  
//        cout << "i: " << i << ", j: " << j << ", value: " << value << endl;
  /*
  printf("%lld\n", dp[0][2]);
  printf("%lld\n", dp[1][2]);
  printf("%lld\n", dp[3][7]);
  printf("%lld\n", dp[3][9]);
  */
//  printf("%s\n", dp[N]);
  cout << dp[N] << endl;

  return 0;

}


Measured memory_bytes: 32384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

int main(){
    double p;
    int N;cin>>N;
    if(N%2==0){
        p=1/2.0;
    }else{
        p=(N/2+1)/(double)N;
    }
    printf("%.10f\n",p);
}

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

using lli = long long int;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

template <class T>ostream &operator<<(ostream &o,const pair<T, T>&p)
{o<<"("<<p.first<<", "<<p.second<<")";return o;}

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

int opl[4];
int input;

int main(void){
    cin >> input;
    rep(i, 4){
        opl[i] = input%10;
        input/=10;
    }

    rep(i, 8){
        int res = opl[3];
        queue<char> q;
        q.push(opl[3]+'0');
        rep(j, 3){
            if((1<<j)&i){
                res+=opl[2-j];
                q.push('+');
            }else{
                res-=opl[2-j];
                q.push('-');
            }
            q.push(opl[2-j]+'0');
        }
        if(res == 7){
            while(!q.empty()){
                cout << q.front();
                q.pop();
            }
            cout << "=7" << endl;
            return 0;
        }
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  string key = "keyence";
  int k = s.size() - key.size();
  if (k < 0) {
    cout << "NO" << endl;
    return 0;
  }
  for (int i = 0; i < (int)s.size() - k + 1; i++) {
    string temp = s;
    if (k > 0) temp.erase(temp.begin() + i, temp.begin() + i + k);
    if (key == temp) {
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9;
int main(){
  int r;cin>>r;
  if(1200>r){cout<<"ABC"<<endl;}
  else{
    if(2800>r){cout<<"ARC"<<endl;}
    else{cout<<"AGC"<<endl;}
  }
}

Measured memory_bytes: 256
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define Graph vector< vector<int> >
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    vector<int> C(30), dp(50010);
    for(int i = 1; i <= M; i++) cin >> C[i];

    for(int i = 1; i <= N; i++) dp[i] = INF;
    dp[0] = 0;

    for(int i = 1; i <= M; i++){
        for(int j = C[i]; j <= N; j++){
            dp[j] = min(dp[j], dp[j - C[i]] + 1);
        }
    }

    cout << dp[N] << endl;

}


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

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

// 組合せを素数で割った値を求める
// 今回は逆元を使うだけ
const int MAX = 1000007;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % MOD;
    inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
    finv[i] = finv[i - 1] * inv[i] % MOD;
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n);
  for (int i = 0; i < n; i++) cin >> a.at(i);
  
  vector<int> x(1000005);
  for (int i = 0; i < n; i++) {
    ll now = a.at(i);
    for (int j = 2; j * j <= a.at(i); j++) {
      int count = 0;
      while (now % j == 0) {
        now /= j;
        count++;
      }
      x.at(j) = max(x.at(j), count);
    }
    if (now > 1) x.at(now) = max(x.at(now), 1);
  }
  
  ll keep = 1;
  for (int i = 2; i <= 1000000; i++) {
    for (int j = 0; j < x.at(i); j++) {
      keep *= i;
      keep %= MOD;
    }
  }
  
  COMinit();
  
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += keep * inv[a.at(i)];
    ans %= MOD;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 27648
N = int(input())
S = input()

white_count = [0]*(N+1)
black_count = [0]*(N+1)

for i in range(N):
  black_count[i+1] = black_count[i]
  if S[i] == "#":
    black_count[i+1] += 1
  
S = S[::-1]
for i in range(N):
  white_count[i+1] = white_count[i]
  if S[i] == ".":
    white_count[i+1] += 1

    
answer = 10**6
for i in range(N+1):
  answer = min(answer,black_count[i]+white_count[N-i])
  
print(answer)

Measured memory_bytes: 12776
n,q = map( int, input().split() )
s = input()
lr = []
for i in range(q):
    lr.append(list( map( int, input().split() ) ) )

exist = [0]*n
for i in range(1,n):
    if s[i-1:i+1] == 'AC':
        exist[i] = exist[i-1]+1
    else:
        exist[i] = exist[i-1]

for i in range(q):
    print(exist[lr[i][1]-1]-exist[lr[i][0]-1])

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

const int N_MAX = 200005;
const int A_MAX = 1000000005;

int pair0[N_MAX];

int main(){
    int n;
    cin >> n;
    int A[N_MAX];
    for(int i = 1; i <= n; i++){
        cin >> A[i];
    }

    for(int i = 0; i <= n; i++)pair0[i] = 0;

    long long int ans = 0;
    for(int i = 1; i <= n; i++){
        int a = A[i];
        if (i-a >= 0)ans += pair0[i-a];
        if (i+a <= n)pair0[i+a]++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4680
N,M=map(int,input().split())
A=input()
def ans161(N:int, M:int, A:str):
    A=sorted(list(map(int,A.split())))
    if A[-M]< sum(A)/(4*M):
        return "No"
    else:
        return "Yes"
print(ans161(N,M,A))

Measured memory_bytes: 9184
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
  int n, k;
  cin >> n >> k;
  bool dislike[9];
  for (int i = 0; i < 10; ++i) {
    dislike[i] = false;
  }
  for (int i = 0; i < k; ++i) {
    int value;
    cin >> value;
    dislike[value] = true;
  }
  int min = 0;
  for (int i = 0; i < 10 && dislike[i]; ++i) {
    ++min;
  }
  int top = 0;
  int digits[10];
  for (int x = n; x; x /= 10) {
    digits[top] = x % 10;
    ++top;
  }
  digits[top] = 0;
  int p = top - 1;
  while (p >= 0 && dislike[digits[p]] == false) {
    --p;
  }
  if (p < 0) {
    cout << n;
    return 0;
  }
  for (int i = p - 1; i >= 0; --i) {
    digits[i] = min;
  }
  while (true) {
    int value = digits[p];
    while (value < 10 && dislike[value]) {
      ++value;
    }
    if (value < 10) {
      digits[p] = value;
      break;
    } else {
      digits[p] = min;
      ++digits[++p];
    }
  }
  for (int i = max(top - 1, p); i >= 0; --i) {
    cout << digits[i];
  }
  cout << endl;
  return 0;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

vpll G[100100];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n,m; cin>>n>>m;
  rep(i,m){
    ll l,r,d; cin>>l>>r>>d; l--,r--;
    G[l].emplace_back(r,d);
    G[r].emplace_back(l,-d);
  }
  
  vb visited(n);
  vll dist(n);
  
  rep(i,n){
    if(visited[i]) continue;
    visited[i]=true;
    queue<pll> q;
    q.emplace(i,0);
    dist[i]=0;
    while(!q.empty()){
      auto p=q.front(); q.pop();
      ll v=p.first, c=p.second;
      
      for(auto np: G[v]){
        ll nv=np.first, nc=np.second;
        if(visited[nv]){
          if(dist[nv]!=c+nc){
            cout<<"No"<<endl;
            return 0;
          }
        }else{
          visited[nv]=true;
          dist[nv]=c+nc;
          q.emplace(nv,dist[nv]);
        }
      }
      
    }
  }
  cout<<"Yes"<<endl;
 }

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
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;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int N, W;
vector<int> v, w;

int main() {
  cin >> N >> W;
  v.resize(N); w.resize(N); REP(i, N) cin >> v[i] >> w[i];
  vector<vector<int>> dp(110, vector<int>(10010));
  REP(i, N) {
    REP(k, W) {
      dp[i][k] = 0;
    }
  }
  for(int i = 0; i < N; ++i) {
    for(int k = 0; k <= W; ++k) {
      if(k - w[i] >= 0) {
        chmax(dp[i + 1][k], dp[i][k - w[i]] + v[i]); // iを0から始めるから、i+1
      }
      chmax(dp[i + 1][k], dp[i][k]);
    }
  }
  cout << dp[N][W] << endl;
}


Measured memory_bytes: 7112
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

int main() {
	int D, N;
	cin >> D >> N;
	int ans = 0;
	if (N != 100) {
		ans = pow(100, D)*N;
	}
	else {
		ans = pow(100, D)*101;
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
import java.io.*;
import java.math.BigInteger;
import java.util.*;


public class Main {

    private static List<List<Integer>> subsets;
    private static int count = 0;
    private static BigInteger thirteen = new BigInteger("13");
    private static BigInteger five = new BigInteger("5");
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        int n = in.nextInt();
        double [] a =  new double[n];
        for (int i = 0; i < a.length; i++) {
            a[i] = in.nextDouble();
        }
        double g = 0;
        double p = 1;
        for (int i = 0; i < a.length; i++) {
            g = gcd(g,a[i]);
            p*=a[i];
        }
        double s = 0;
        double lcm = p/g;
        for (int i = 0; i < a.length; i++) {
            s+=lcm/a[i];
        }

        double ans = lcm/s;
        out.println(ans);
        out.flush();
    }

    static double gcd(double a,double b) {
        return b == 0 ? a : gcd(b,a%b);
    }
}

class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }
    public Integer nextInt() {return Integer.valueOf(next());}
    public Long nextLong() {return  Long.valueOf(next());}
    public Double nextDouble() {return Double.valueOf(next());}

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}

Measured memory_bytes: 21460
/*
auth - @sportykush
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef long double ld;
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set; 
 
//#define mp make_pair
#define bug(v) cerr<<#v<<" = "<<(v)<<endl;
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define pb emplace_back
#define vii vector<int>
#define vll vector<ll>
#define vpll vector< pair <ll,ll> >
#define pll pair <ll,ll>
#define pii pair <int,int>
#define pq priority_queue< int >
#define khtm "\n"
#define F first
#define S second
#define fr(i,a,n) for(i=a;i<n;i++)
#define mem(arr,l) memset(arr,l,sizeof arr)
#define ALL(x) x.begin(), x.end()
#define frr(i,a,n) for(i=n-1;i>=a;i--)
//#define mod 1000000007
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define testcase ll T; cin>>T; while(T--)
const int MAX = 1e6 +2;
const ll inf =  1e18;
const int N = 1010;

const int mod=1e9+7;
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}


/*
important builtin functions
__gcd(value1, value2)
__builtin_ffs(x)
  Number of leading zeroes: __builtin_clz(x)
  Number of trailing zeroes : __builtin_ctz(x)
  Number of set bits: __builtin_popcount(x)
*/
 

ll i,j,k,m,l,r,n;
ll a[MAX];


int main()
{
 
  #ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
//cout << setprecision(15) << fixed;
fast


cin >> n >> k;
cout << (n<=k ? "unsafe" : "safe");

  #ifndef ONLINE_JUDGE
  cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
  #endif
 
  return 0;
 
}

Measured memory_bytes: 3656
#include <iostream>
#include <cstdio>
#define N 2
using namespace std;

class Calc{
    public:
    double A[N][N+1];
    int i, j, k;
    double tmp;
    void calcSi();
    void printSi();
};

void Calc::calcSi(){
    for(i=0;i<N-1;i++){
        for(j=i+1;j<N;j++){
            tmp = A[j][i] / A[i][i];
            for(k=i+1; k<=N; k++)
                A[j][k] -= A[i][k] * tmp;
        }
    }

    for(i=N-1; i>=0; i--){
        tmp = A[i][N];
        for(j=i+1;j<N;j++)
            tmp -= A[i][j] * A[j][N];
        A[i][N] = tmp / A[i][i];
    }
}

void Calc::printSi(){
    for(i=0;i<N;i++){
        printf("%.3f",A[i][N]);
        if(i != N-1) {
            cout << " ";
        }
    }
    cout << endl;
}

int main(void){
    Calc c;
    while(cin >> c.A[0][0] >> c.A[0][1] >> c.A[0][2] >> c.A[1][0] >> c.A[1][1] >> c.A[1][2]){
        c.calcSi();
        c.printSi();
    }
    return 0;
}

Measured memory_bytes: 1272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
    return 0;
}

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

int n;
// Peace::elem->[0]:up,[1]:right,[2]:buttom,[3]:left
struct Peace{
    char elem[4];
    void rotate(){
        char tmp=elem[3];
        elem[3]=elem[2];
        elem[2]=elem[1];
        elem[1]=elem[0];
        elem[0]=tmp;
    }
};
Peace p[9];
int allocated[9];
bool selected[9];
int cnt=0;

void dfs(int s){
    if(s==9){
        cnt++;
    }
    else{
        for(int i = 0; i < 9; i++){
            if(selected[i])
                continue;
            selected[i]=true;
            allocated[s]=i;
            // ü«
            for(int j = 0; j < 4; j++){
                // matchµÈ¢èÄûÈçAÄAµÈ¢
                // ¶¤ð`FbN
                bool isl=true;
                if(s%3!=0){
                    if(!(abs(p[allocated[s]].elem[3]-p[allocated[s-1]].elem[1])==32))
                        isl=false;
                }
                // ãð`FbN
                bool isu=true;
                if(s>=3){
                    if(!(abs(p[allocated[s]].elem[0]-p[allocated[s-3]].elem[2])==32))
                        isu=false;
                }
                // ÄA
                if(isu&&isl)
                    dfs(s+1);
                p[i].rotate();
            }
            allocated[s]=-1;
            selected[i]=false;
        }
    }
}

int main(){

    int n;
    cin>>n;
    for(int i = 0; i < n; i++){
        cnt=0;
        for(int j = 0; j < 9; j++){
            for(int k = 0; k < 4; k++)
                cin>>p[j].elem[k];
        }
        fill(allocated,allocated+9,-1);
        fill(selected,selected+9,false);
        // Às
        dfs(0);
        cout<<cnt<<endl;
    }
    return 0;
}

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

#define int long long

inline int get(vector<int> &nums, int low, int up) {
	if (low <= 0) return nums[up];
	return nums[up] - nums[low-1];
}

#undef int
int main(int argc, char const *argv[])
{
	#define int long long
	const int MOD = (int) 1e9 + 7;
	int n, k;
	cin >> n >> k;
	vector<int> a(n + 1);
	for (int i = 0; i < n; ++i)
		cin >> a[i + 1];
	vector<vector<int> > dp(n + 1, vector<int>(k + 1, 0));
	for (int i = 0; i <= n; ++i) dp[i][0] = 1;
	for (int j = 0; j <= k; ++j) dp[0][j] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 1; j <= k; ++j) {
			int low = j - a[i],
				up  = j;
			dp[i][j] = get(dp[i-1], low, up);
			dp[i][j] %= MOD;
		}
		if (i != n)
			for (int j = 1; j <= k; ++j) dp[i][j] = (dp[i][j] + dp[i][j-1]) % MOD;
	}
	cout << ((dp[n][k]%MOD)+MOD)%MOD << endl;
	return 0;
}

Measured memory_bytes: 80256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		int cnt = 0;
		int i;

		for(i = x; x <= y; x++)
		{
			if(z % x == 0)
			{
				cnt++;
			}
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 26232
#include "bits/stdc++.h"

#define REP(i, n) for(decltype(n) i = 0; i < (n); i++)
#define REP2(i, x, n) for(decltype(x) i = (x); i < (n); i++)
#define REP3(i, x, n) for(decltype(x) i = (x); i <= (n); i++)
#define RREP(i, n) for (decltype(n) i = (n) - 1;i >= 0; i--)

#define ALL(a) (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define DESCSORT(c) sort(c.begin(), c.end(), greater<int>())

#define LL long long int
#define LD long double

#define INF 1000000000
#define PI 3.14159265358979

#define _CRT_SECURE_NO_WARNINGS

using namespace std;

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

typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<LL> vll;
//==============================================

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

	cin >> n; vector<int>S(n);
	REP(i, n) cin >> S[i];

	cin >> q; vector<int>T(n);
	REP(i, q) cin >> T[i];

	int c = 0;
	SORT(S);
	REP(i, q) {
		if (binary_search(ALL(S), T[i])) {
			c++;
		}
	}

	cout << c << "\n";
	return 0;
}

Measured memory_bytes: 3436
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int H, W; cin >> H >> W;
	vector<vector<char>> C(H, vector<char>(W, 0));
	rep(i, 0, H) rep(j, 0, W) { cin >> C[i][j]; }
	rep(i, 0, H * 2) {
		rep(j, 0, W) {
			cout << C[i / 2][j];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
int gcd(int a, int b){ return (b == 0) ? a : gcd(b, a % b); }

#define Sq(x) (x)*(x)
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Reverse(c) reverse(Range(c))
#define Unique(a) a.erase(unique(Range(a)), a.end())
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, xs, sxs) vector<T> sxs(xs.size()+1); For(i, (int)xs.size()) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

// constexpr int MOD = 1e9+7;

int main(void){
    Cin(int, n, k, c, d);
    Cout((k == 1) ? 0 : (n > k) ? n-k : 0);
}

Measured memory_bytes: 256
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right
from heapq import heappush, heappop

import re
# import numpy as np
# from scipy.misc import comb

# 再帰がやばいとき
import sys
sys.setrecursionlimit(10**9)

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
def line_inpl(x): return [i_inpl() for _ in range(x)]

INF = int(1e30)
MOD = int(1e9)+7 # 10^9 + 7

# field[H][W]
def create_grid(H, W, value = 0):
    return [[ value for _ in range(W)] for _ in range(H)]

########

def solve(G):
    N = len(G)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                G[i][j] = min(G[i][j], G[i][k] + G[k][j])
    return G

def main():
    N, M = l_inpl()
    G = create_grid(N, N, INF)

    for i in range(N):
        G[i][i] = 0

    a, b, c = [], [], []
    for _ in range(M):
        ai, bi, ci = l_inpl()
        ai, bi = ai-1, bi-1
        a.append(ai)
        b.append(bi)
        c.append(ci)
        G[ai][bi] = ci
        G[bi][ai] = ci
    
    G = solve(G)

    ans = M
    for i in range(M):
        flag = False
        for j in range(N):
            if G[j][a[i]]+c[i] == G[b[i]][j]:
                flag = True
        if flag:
            ans -= 1
    
    print(ans)
if __name__ == "__main__":
    main()


Measured memory_bytes: 44784
#include <iostream>
#include <algorithm>

int main()
{
    int n;
    std::cin >> n;

    int64_t t, a;
    std::cin >> t >> a;
    for (int i = 1; i < n; ++i)
    {
        int64_t tmp_t, tmp_a;
        std::cin >> tmp_t >> tmp_a;

        if (tmp_t == 1 && tmp_a == 1)
        {
            // 自明
            t = a = std::max(t, a);
            continue;
        }

        const auto current = static_cast<double>(t) / a, target = static_cast<double>(tmp_t) / tmp_a;
        if (target > current)
        {
            // tがより増加する

            // aはtmp_aの倍数にならなければならない
            a = (a + tmp_a - 1) / tmp_a * tmp_a;
            // aは倍数になったのであまりはない
            t = a / tmp_a * tmp_t;
        }
        else
        {
            // aがより増加する

            t = (t + tmp_t - 1) / tmp_t * tmp_t;
            a = t / tmp_t * tmp_a;
        }
    }

    std::cout << t + a << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long int
#define ld long double
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define rep(i,a,b)	for(lld i=a;i<=b;i++)
#define repr(i,a,b) for(lld i=a;i>=b;i--)
#define ar array
#define pb push_back
#define mp make_pair
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
lld n,m;
lld arr[300000];
string st;
map<lld,lld> ma;
int main()
{
     ios;
     lld TESTS,q,a,s,b,r,k,c,p,h,w,d,x,y,z,xs,ys,t;
     TESTS=1;
//     ans=0;
     //cin>>TESTS;
   //  memset(dpt,0,sizeof(dpt));memset(dput,0,sizeof(dput));
    // memset(dsu1,0,sizeof(dsu1));
     while(TESTS--)
     {
         cin>>n>>x>>y;
         x--;y--;
         rep(i,0,n-1) rep(j,i+1,n-1) {
            lld val=j-i;
            val=min(val,min(abs(i-x)+abs(j-y)+1,abs(j-x)+abs(i-y)+1));
            ma[val]++;
         }
         rep(i,1,n-1) cout<<ma[i]<<"\n";
     }
    return 0;
}


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

using namespace std;

const int N = 1e6;
int x[N];
int pref[N];
int n, C;

int go(int t) {
  int acc = pref[t] * 5 + t *  C;
  for(int i = t, j = 2; i < n; i+=t, j++) {
    int cur = (pref[i + t] - pref[i]) * (2*j + 1);
    acc = min(acc + cur, (int)1e18);
  }
  return acc;
}

// (i+1)^2 - i^2 = 2i + 1
int32_t main() {
  ios::sync_with_stdio(false); cin.tie(0);

  cin >> n >> C;

  int ans = 1e18;

  for(int i = 0; i < n; i++) cin >> x[i];
  sort(x, x+n, greater<int>());

  for(int i = 0; i < 2*n; i++) pref[i+1] = pref[i] + x[i];

  for(int i = 1; i <= n; i++) {
    ans = min(ans, go(i) + n*C);
  }
  cout << ans << endl;
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <complex>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,C,L,R;
string S,T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
const long double EPS = 1e-9;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;


int main() {
    cin>>A>>B;
    mat g(3,vec(0));
    g[0] = {1,3,5,7,8,10,12};
    g[1] = {4,6,9,11};
    g[2] = {2};
    ll ga,gb;
    rep(i,3){
        for(ll e : g[i]){
            if(e == A) ga = i;
        }
    }
    rep(i,3){
        for(ll e : g[i]){
            if(e == B) gb = i;
        }
    }
    cout<<(ga == gb ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
//#include "IntMod.h"
//typedef IntMod<1000000007> MInt;

#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <functional>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define REP(i,a,n) for(int i = a; i < n; ++i)
#define REPM(i,n,a) for(int i = n - 1; i >= a; --i)
#define EPS 0.0001
#define INF 0x3FFFFFFF
#define INFD 1.0e+308
typedef long long LL;
typedef unsigned long long ULL;

typedef pair<LL, LL> PP;

int H, W, N;
int a[100001], b[100001];
map<PP, int> M;
LL out[10];
int di[9] = { -1,-1,-1,0,0,0,1,1,1 };
int dj[9] = { -1,0,1,-1,0,1,-1,0,1 };
int main() {
	cin >> H >> W >> N;
	REP(i, 0, N) {
		cin >> a[i] >> b[i];
	}

	REP(i, 0, N) {
		REP(d, 0, 9) {
			int y = a[i] + di[d];
			int x = b[i] + dj[d];
			if (y > 0 && y <= H && x > 0 && x <= W) {
				++M[make_pair(y, x)];
			}
		}
	}
	LL cnt = 0;
	for (auto it = M.begin(); it != M.end(); ++it) {
		int y = it->first.first;
		int x = it->first.second;
		if (y != 1 && y != H && x != 1 && x != W) {
			++cnt;
			++out[it->second];
		}
	}
	out[0] = (LL)(H - 2) * (W - 2) - cnt;

	REP(k, 0, 10) {
		cout << out[k] << endl;
	}
	return 0;
}

Measured memory_bytes: 57216
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin>>N;
  vector<int>vec(N);
  vector<int>v(N);
  for(int X=0;X<N;X++){
    cin>>vec.at(X);
    v.at(X)=vec.at(X);
  }
  sort(v.begin(),v.end());
  for(int X=0;X<N;X++){
    if(vec.at(X)==v.at(N-1)){
      cout<<v.at(N-2)<<endl;
    }
    else{
      cout<<v.at(N-1)<<endl;
    }
  }
}

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

int main (){
   string s,t,u;
   cin >> s >> t;
   int a,b;
   cin >> a >> b;
   cin >> u;
   if(s==u) a--;
   else if(t==u) b--;

   cout << a << " " << b << endl;

    return 0;
}


Measured memory_bytes: 256
from itertools import accumulate
def prime(n):
  if n==1:
    return False
  else:
    for i in range(2,int(n**0.5)+1):
      if n%i==0:
        return False
    else:
      return True

l = [0 for i in range(10**6)] 

for i in range(1,10**5+1):
  if i%2==0:
    continue
  else:
    if prime(i):
      if prime((i+1)//2):
        l[i] = 1
l1 = list(accumulate(l))
q = int(input())
for i in range(q):
  l,r = map(int,input().split())
  print(l1[r]-l1[l-1])

Measured memory_bytes: 55900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'

const int N=2e5;
const int mod=998244353;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	vector<pair<int,int>> a(n);
	for(int i=0;i<n;++i){
		cin>>a[i].first>>a[i].second;
	}
	sort(a.begin(),a.end());
	vector<ll> dp(N);
	dp[n]=1;
	vector<pair<int,int>> pos;
	pos.emplace_back(n,(int)2e9);
	for(int i=n-1;~i;--i){
		while(a[i].first+a[i].second>pos.back().second) pos.pop_back();
		int last=pos.back().first;
		dp[i]=dp[last]; // actived robot i
		pos.emplace_back(i,a[i].first);
		dp[i]=(dp[i]+dp[i+1])%mod; // doing nothing 
	}
	cout<<dp[0];
	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)

#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define pi pair<ll,ll>
#define pii pair<ll,pi >
#define ppi pair<pi,ll>
#define ppp pair<pi,pi >
#define ex(str,a,b) str.substr((int)(a),min((int)str.size()-a,(int)(b-a+1))) 
#define all(X) X.begin(),X.end()
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

// for pair comparison function(ascending order) use return (i1.ff < i2.ff);

/* string operations :
   str.substr (x,y) : returns a substring str[x],str[x+1],...str[x+y-1]
   __builtin_popcount(n) : no. of set bits in n.
*/

const int M = (1<<20)+5;
const int md = 1e9+7;

priority_queue<ll,vector<ll >,greater<ll > > pq;

ll pwr(ll a,ll n,ll m)
{
	ll p=1;
	while(n>0)
	{
		if(n%2==1)
			p=(p*a)%m;
		a=(a*a)%m;
		n=n/2;
	}
	return p;
}

ll n;
ll ar[M];

ll f(ll x)
{
	ll cnt = 0;
	ll i;
	for(i=1;i<=n;++i)
	{
		cnt += (ar[i]+x-1)/x;
		cnt--;
	}
	// cout << x << " " << cnt << "\n";
	return cnt;
}

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

	ll k,i;
	ll l,r,mid,ans;

	cin >> n >> k;
	for(i=1;i<=n;++i)
		cin >> ar[i];
	l = 1;
	r = 1e9;
	while(l<=r)
	{
		mid = (l+r)/2;
		if(f(mid)<=k && (mid == 1 || f(mid-1) > k))
		{
			ans = mid;
			break;
		}
		else if(f(mid)>k)
			l = mid+1;
		else
			r = mid-1;
	}
	ld x = (ld)(ans)-0.5;
	ll cnt = 0;
	for(i=1;i<=n;++i)
	{
		ld d = ar[i];
		if(d<x)
			continue;
		ld c = d/x;
		ll y = c;
		for(ll j=y-3;j<=y+3;++j)
		{
			ld v = x*(ld)(j);
			if(v>d)
			{
				cnt += j-1;
				break;
			}
		}
	}
	cout << ans << "\n";
	// if(cnt>k)
	// 	cout << ans << "\n";
	// else
	// {
	// 	x = (ld)(ans)-0.499999999;
	// 	cnt = 0;
	// 	for(i=1;i<=n;++i)
	// 	{
	// 		ld d = ar[i];
	// 		if(d<x)
	// 			continue;
	// 		ld c = d/x;
	// 		ll y = c;
	// 		for(ll j=y-3;j<=y+3;++j)
	// 		{
	// 			ld v = x*(ld)(j);
	// 			if(v>d)
	// 			{
	// 				cnt += j-1;
	// 				break;
	// 			}
	// 		}
	// 	}
	// 	if(cnt<=k)
	// 		cout << ans-1 << "\n";
	// 	else
	// 	{
	// 		if((ans%10) < 5)
	// 			cout << ans-1 << "\n";
	// 		else
	// 			cout << ans << "\n";
	// 	}
	// }
}
	

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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() <= k) {
        cout << s << endl;
    } else {
        for (int i = 0; i < k; i++) {
            cout << s.at(i);
        }
        cout << "..." << endl;
    }
}

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

int main(){
    int N,M;
    cin >> N >> M;
    vector<string> A(N);
    vector<string> B(M);

    for(int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
    for(int i = 0; i < M; i++)
    {
        cin >> B[i];
    }
    
    for(int i = 0; i < N-M+1; i++)
    {   
        for(int j = 0; j < N-M+1; j++)
        {   
            int judge = 0;
            
            for(int k = i; k < i+M; k++)
            {
                for(int l = j; l < j+M; l++)
                {
                    if(A[k][l]==B[k-i][l-j]){
                        judge++;
                    }
                }
                
            }
            if(judge == M*M){
                cout << "Yes" << endl;
                return 0;
            }
        }
        
    }

    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 384
import sys

N = int(sys.stdin.readline())
h = [int(hi) for hi in sys.stdin.readline().split(' ')]

dp = [1000000 * N] * N
dp[0] = 0

for i in range(N - 1):
    dp[i + 1] = min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
    if i < N - 2:
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))

print(dp[-1])


Measured memory_bytes: 76552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, A;
  cin >> N >> A;
  if(N % 500 == 0){
    cout << "Yes" << endl;
  }
  else if(N - (N / 500) * 500 < A){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    string N;
    cin >> N;

    int l = N.size();

    ll ans = 0;
    ll left = 0;
    for(int i=0;i<N.size();i++){
        int c = (N[i] - '0');
        left += c;
        if(c >= 1){
            ans = max(ans, left - 1 + 9 * (l - i - 1));
        }
    }
    ans = max(ans, left);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cstdio>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v) reverse(v.begin(),v.end())
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix<<(i!=N-1?' ':'\n');
	return;
}

const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18;
const ll MOD =1000000007;
#define PI 3.14159265258979

#define P pair<int,int>
#define Pll pair<ll,ll>
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

inline int in(){int x; cin>>x; return x;}

struct UnionFind{
	vector<int> par; //データiが属する親の番号
	vector<int> sizes; //根ノードiの木に含まれるデータの数

	// 最初は全てのデータiがグループiに存在するものとして初期化
	UnionFind(int n):par(n),sizes(n, 1){
		REP(i,n) par[i] = i;
	}

	// 根を張り替えながら再帰的に根ノードを探す
	int find(int x){
		if(x==par[x]) return x;
		return par[x]=find(par[x]);
	}

	// 2つのデータx, yが属する木をマージする
	void unite(int x, int y) {
		// データの根ノードを得る
		x = find(x);
		y = find(y);

		// 既に同じ木に属しているならマージしない
		if (x == y) return;

		// xの木がyの木より大きくなるようにする
		if (sizes[x] < sizes[y]) swap(x, y);

		// xがyの親になるように連結する
		par[y] = x;
		sizes[x] += sizes[y];
		sizes[y] = 0;  // sizes[y]は無意味な値となるため
	}

	// 2つのデータx, yが属する木が同じならtrueを返す
	bool same(int x, int y) {
		return find(x) == find(y);
	}

	// データxが含まれる木の大きさを返す
	int size(int x) {
		return sizes[find(x)];
	}
};
int gcd(int n,int m){
	if(m>n) return gcd(m,n);
	if(m==0) return n;
	else return gcd(m,n%m); 
}

int main(void){
	int N,A,B;
	cin>>N>>A>>B;
	print(min(A*N,B));
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
    int k, a, b;
    cin >> k >> a >> b;
  	bool test = false;
    for(int i = a; i <= b; i++) {
        if(i % k == 0) test = true;
    } if(test) cout << "OK";
  	else cout << "NG";
 
}

Measured memory_bytes: 3104
N=int(input())
D=[list(map(int,input().split())) for i in range(N)]
for i in range(N-2):
  if D[i][0]==D[i][1] and D[i+1][0]==D[i+1][1] and D[i+2][0]==D[i+2][1]:
    print('Yes')
    exit()
print('No')


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

using namespace std;

int dirs[4][2]={{-1, 0}, {0, 1}, {1, 0}, {0, -1}};

int main()
{
    //freopen("inp.in", "r", stdin);
    //ios::sync_with_stdio(false);
    int a, b;
    scanf("%d %d", &a, &b);
    int ans=a-1;
    if(b>=a) ans++;
    cout << ans << endl;
    return 0;
}


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

#define PI 3.14159265358979323846264338327950L

int main(void)
{
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    long double rad = PI * 2 * ((long double)h / 12.0 + ((long double)m / 60.0) / 12.0 - (long double)m / 60.0);
    long double rsq = (long double)(a * a + b * b) - (long double)(2 * a * b) *cosl(rad);
    printf("%20.20Lf\n", sqrtl(rsq));

    return 0;
}


Measured memory_bytes: 2508
#include<stdio.h>
#include<string.h>
#define N 36

typedef struct{
  char mark;
  int value;
}Card;

void BubbleSort(Card *, int);
void SelectionSort(Card *,int);
void print(Card *,int);
int judge(Card *, Card *, int);



int main()
{
  Card c1[N+1], c2[N+1];
  int i, n;

  scanf("%d", &n);
  for(i=0;i< n;i++){
    scanf(" %c%d",&c1[i].mark,&c1[i].value);
  }
  
  for(i=0;i< n;i++)c2[i]=c1[i];

  BubbleSort(c1,n);
  print(c1,n);
  printf("Stable\n");

  SelectionSort(c2, n);
  print(c2,n);
  
  if( judge(c1, c2, n)==0)printf("Stable\n");
  else printf("Not stable\n");

  return 0;
}



void BubbleSort(Card c1[], int n)
{
  int i, j;
  Card t;

  for( i = 0;i<n;i++ ){
    for(j=n-1; j >i;j-- ){
      if( c1[j].value<c1[j-1].value ){
        t = c1[j];
        c1[j]=c1[j-1];
        c1[j-1]=t;
      }

   }
  }
}


void SelectionSort(Card c2[], int n)
{
  int i,j,minj;
  Card t;

  for(i = 0;i<n;i++){
    minj =i;
    for(j = i;j<n;j++){
      if(c2[j].value < c2[minj].value )minj = j;
    }
    t = c2[i];
    c2[i] = c2[minj];
    c2[minj] = t;
  }
}




void print(Card c[], int n)
{
  int i;
  for(i =0; i<n; i++){
    if(i>0)printf(" ");
    printf("%c%d", c[i].mark, c[i].value);
  }
  printf("\n");
}



int judge(Card c1[],Card c2[],int n){

  int i;
  for(i= 0 ;i<n;i++){
    if(c1[i].mark!=c2[i].mark)return 1;
  }
    return 0;
  }



Measured memory_bytes: 2112
#include<cstdio>
#include<cstring>

int n,v,a[200001],fa[200001][21],l[200002][21],r[200002][21],V[21],cnt,fl[1048576],fr[1048576],k,L,R;
bool b[200001];

int ask(int x,int y) {return fa[x][y]==x?x:fa[x][y]=ask(fa[x][y],y);}
int getmin(int a,int b) {return a<b?a:b;}
int getmax(int a,int b) {return a>b?a:b;}

void unite(int x,int y,int z)
{
	int p=ask(x,z),q=ask(y,z);
	if (p==q) return;
	fa[p][z]=q;
	l[q][z]=getmin(l[p][z],l[q][z]);
	r[q][z]=getmax(r[q][z],r[p][z]);
}

int main()
{	
	scanf("%d%d",&n,&v); cnt=-1;
	memset(b,0,sizeof(b));
	for (int i=1; i<=n; i++) scanf("%d",&a[i]);
	while (v) V[++cnt]=v,v>>=1; V[++cnt]=0;
	for (int i=0; i<=cnt; i++)
	{
		for (int j=1; j<=n; j++) fa[j][i]=l[j][i]=r[j][i]=j;
		for (int j=1; j<n; j++) if (a[j+1]-a[j]<=V[i]) unite(j,j+1,i);
	}
	for (int i=0; i<=cnt; i++) r[n+1][i]=n,l[0][i]=1;
	k=(1<<cnt); 
	for (int i=0; i<k; i++) fl[i]=0,fr[i]=n+1;
	for (int i=1; i<k; i++)
		for (int j=0; j<cnt; j++)
			if ((i>>j)&1)
			{
				fl[i]=getmax(fl[i],r[ask(fl[i^(1<<j)]+1,j+1)][j+1]);
				fr[i]=getmin(fr[i],l[ask(fr[i^(1<<j)]-1,j+1)][j+1]);
			}
	for (int i=0; i<k; i++)
	{
		L=fl[i]; R=fr[i^(k-1)];
		if (R<=L+1) 
		{
			for (int j=1; j<=n; j++) printf("Possible\n"); 
			return 0;
		} 
		if (ask(L+1,0)==ask(R-1,0)) b[ask(L+1,0)]=1;
	}
	for (int i=1; i<=n; i++) if (b[ask(i,0)]) printf("Possible\n"); else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 58624
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

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

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

  int n;
  cin >> n;

  int s = 0, m = n;
  while(m != 0){
    s += m % 10;
    m /= 10;
  }

  if(n % s == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256