akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>

int main(void){
     
     int i,j;
     int N,D,X;
     int A[100];
     int sum;

     scanf("%d",&N);
     scanf("%d %d",&D, &X);
     for(i=0;i<N;i++){
         scanf("%d",&A[i]);
     }

     sum = X;
     for(i=0;i<N;i++){
         sum += (D-1) / A[i] +1;
     }

     printf("%d\n",sum);

  
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <map>
#include <string>

using namespace std;

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

int main()
{
  long long n;
  cin >> n;
  
  long long d[n];
  std::map<long long, long long> m;
  for (int i=0;i<n;++i) {
    cin >> d[i];
    
    long long key = d[i];
    if (m.find(key) == m.end()) {
      m[key] = 1;
    } else {
      m[key] = m[key]+1;
    }
  }
  
  long long sum[m.size()];
  long long cnt = 0;
  long long total = 0;
  long long half1 = 0;
  long long half2 = 0;
  for (auto& x:m) {
    total += x.second;
    sum[cnt] = total;
    if (n == total*2) {
      half1 = x.first;
    } else if (half1 != 0 && half2 == 0) {
      half2 = x.first;
    }
    cnt++;    
  }
  
  long long ans = 0;
  
  if (half1 == 0 || half2 == 0) {
  } else {
  //cout << half2 << "," << half1 << endl;
    ans = half2 - half1;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5504
#include<iostream>
#include<cstdio>
#include<vector>
#include<deque>
#include<queue>
#include<algorithm>
#include<cassert>
#include<climits>
#include<cstring>
#include<map>
#include<set>

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

using namespace std;

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

struct Edge{
  int to,cap,cost,rev;
  Edge(int to=0,int cap=0,int cost=0,int rev=0):to(to),cap(cap),cost(cost),rev(rev){}
};

const int MAX_V = 300, IINF = INT_MAX;
int V;
vector<Edge> G[MAX_V];
int h[MAX_V],dist[MAX_V],prevv[MAX_V],preve[MAX_V];

inline void add_edge(int from,int to,int cap,int cost){
  G[from].push_back(Edge(to,cap,cost,G[to].size()));
  G[to].push_back(Edge(from,0,-cost,G[from].size()-1));
}

ll min_cost_flow(int s,int t){
  ll res = 0;
  fill(h,h+V,0);
  while(1){
    priority_queue<ii,vector<ii>,greater<ii> > Q;
    fill(dist,dist+V,IINF);
    dist[s] = 0;
    Q.push(ii(0,s));
    while(!Q.empty()){
      ii p = Q.top(); Q.pop();
      int v = p.second;
      if( dist[v] < p.first ) continue;
      for(int i=0;i<G[v].size();i++){
        Edge &e = G[v][i];
        if( e.cap > 0 && dist[e.to] > dist[v] + e.cost + h[v] - h[e.to] ) { 
          dist[e.to] = dist[v] + e.cost + h[v] - h[e.to];
          prevv[e.to] = v;
          preve[e.to] = i;
          Q.push(ii(dist[e.to],e.to));
        }
      }
    }
    //if( dist[t] == IINF ) break;
    rep(v,V) h[v] += dist[v];
    if( h[t] >= 0LL ) break;
    ll d = IINF;
    for(int v=t;v!=s;v=prevv[v]) d = min(d,(ll)G[prevv[v]][preve[v]].cap);
    res += d * h[t];
    for(int v=t;v!=s;v=prevv[v]){
      Edge &e = G[prevv[v]][preve[v]];
      e.cap -= d;
      G[v][e.rev].cap += d;
    }
  }
  return res;
}

int main() {
  int n;
  while( cin >> n, n ) {
    vector<int> x(n),y(n),z(n);
    int sum = 0;
    rep(i,n) {
      cin >> x[i] >> y[i] >> z[i];
      sum += x[i] * y[i] * z[i];
    }
    int source = 2 * n, sink = 2 * n + 1;
    V = sink + 1;
    rep(i,V) G[i].clear();

    rep(i,n) {
      add_edge(source,i,1,0);
      add_edge(n+i,sink,1,0);
    }

    auto check = [&](int s,int t) -> bool {
      vector<int> v1(3),v2(3);
      v1[0] = x[s], v1[1] = y[s], v1[2] = z[s];
      v2[0] = x[t], v2[1] = y[t], v2[2] = z[t];
      sort(v1.begin(),v1.end());
      sort(v2.begin(),v2.end());
      rep(i,3) if( v1[i] <= v2[i] ) return false;
      return true;
    };
    
    rep(i,n) {
      rep(j,n) if( i != j ) {
	if( check(i,j) ) {
	  add_edge(i,n+j,1,-1*x[j]*y[j]*z[j]);
	}
      }
    }
    cout << sum + min_cost_flow(source,sink) << endl;
    
  }
  return 0;
}

Measured memory_bytes: 3300
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   

using namespace std;


int main() {

	int a, b;
	cin >> a >> b;

	if (a <= b) {
		cout << a << endl;
	}
	else {
		cout << a - 1 << endl;
	}

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		
		while(true) {
			String x = scan.nextLine();
			if(x.equals("0")) break;
			
			int count = 0;
			
			for(int i = 0; i < x.length(); i++) {
				int temp = Character.getNumericValue(x.charAt(i));
				count += temp;
			}
			
			System.out.println(count);
		}
		
	}

}



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

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

int bfs(const vector<string> &m, int x, int y){
  vector<vector<int>> dist(h,vector<int>(w,-1));
  queue<pair<int,int>> que;
  
  int res = 0;
  dist[x][y] = 0;
  que.push({x,y});
  
  while(!que.empty()){
    x = que.front().first; y = que.front().second;
    res = max(res,dist[x][y]);
    que.pop();
    
    rep(i,4){
      int nx = x + dx[i]; int ny = y + dy[i];
      if(nx<0||ny<0||nx>=h||ny>=w) continue;
      if(m[nx][ny] == '#') continue;
      if(dist[nx][ny] == -1){
        dist[nx][ny] = dist[x][y]+1;
        que.push({nx,ny});
      }
    }  
  }
  return res;
}

int main(){
  cin>>h>>w;
  vector<string> maze(h);
  rep(i,h) cin>>maze[i];
  
  vector<vector<int>> dist(h,vector<int>(w,-1));
  queue<int> que;
  
  int ans = 0;
  rep(i,h){
    rep(j,w){
      if(maze[i][j]=='.'){
        ans = max(ans,bfs(maze,i,j));
      }
    }
  }
  
  cout << ans << endl;
}

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

int main() {
  int H,W;
  cin>>H>>W;
  vector<vector<char>> p(H,vector<char>(W));
  vector<vector<int>> q(H,vector<int>(W));
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>p.at(i).at(j);
      if(p.at(i).at(j)=='#'){
        for(int k=-1;k<=1;k++){
        for(int l=-1;l<=1;l++){
          if(0<=i+k&&i+k<H&&0<=j+l&&j+l<W){
            q.at(i+k).at(j+l)++;
          }
        }
      }
    }
  }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(p.at(i).at(j)=='#'){
        cout<<"#";
      }
      else{
        cout<<q.at(i).at(j);
      }
    }
    cout<<endl;
  }
        
  
      
}


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

int main() {
  int N, K, S;
  cin >> N >> K >> S;
  for (int i = 0; i < K; i++) cout << S << " ";
  for (int i = 0; i < N - K; i++) {
    if (S < 1000000000) cout << S + 1 << " ";
    else cout << 1 << " ";
  }
  cout << endl;
}

Measured memory_bytes: 3680
#include<stdio.h>
#include<string.h>
int main(void){
    char s[100];
    scanf("%s",s);
    int m=strlen(s),p=0,q=0,r=0,ho=0;
    for(int i=0;m>i;++i){
        if(s[i]==s[m-1-i])
        ++p;
    }
    for(int i=0;(m-1)/2>i;++i){
        if(s[i]==s[(m-1)/2-1-i])
        ++q;
    }
    for(int i=(m+1)/2;m>i;++i){
        if(s[i]==s[m-1-ho])
        ++r;
        ++ho;
    }
    if((m==p)&&((m-1)/2==q)&&(m-(m+1)/2==r))
    printf("Yes");
    else
    {
        printf("No");
    }
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
//#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
#define all(x) x.begin(),x.end()
#define puts(x) cout << x << endl
using namespace std;
int input() {
	int r;
	cin >> r;
	//scanf("%lld", &r);
	return r;
}
int ans;
signed main() {
	int r, g, b, n; cin >> r >> g >> b >> n;
	for0(i, n + 1) {
		if (i * r > n)break;
		for0(j, n + 1) {
			if (i * r + j * b > n)break;
			if ((n - (i * r + j * b)) % g == 0)ans++;
		}
	}
	puts(ans);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
vector<pair<int,int> >R; pair<int, int>G[1 << 20]; int I[1 << 20];
int N, Q, P; string S;
bool check(int M, int J) {
	int sum = 0, cnt = 1200000000; if (M < 0)return false;
	for (int i = R.size() - 1; i >= 0; i--) {
		int L2 = I[R[i].second] - M, R2 = I[R[i].second] + 1;
		if (R2 >= cnt)R2 = cnt;
		if (L2 >= R2)continue;
		int pos1 = lower_bound(G, G + N, make_pair(L2, 0)) - G;
		int pos2 = lower_bound(G, G + N, make_pair(R2, 0)) - G;
		sum += pos2 - pos1; cnt = L2;
	}
	sum = N - sum;
	if (sum <= J) { return true; }
	return false;
}
int main() {
	cin >> N >> Q; for (int i = 0; i < N; i++) { cin >> I[i]; G[i] = make_pair(I[i], i); }
	sort(G, G + N);
	for (int i = 0; i < Q; i++) {
		cin >> S >> P;
		if (S == "ADD") { P--; R.push_back(make_pair(I[P], P)); sort(R.begin(), R.end()); }
		if (S == "REMOVE") {
			P--;
			for (int j = 0; j < R.size(); j++) {
				if (R[j].second == P) { R.erase(R.begin() + j); sort(R.begin(), R.end()); break; }
			}
		}
		if (S == "CHECK") {
			int L1 = 0, R1 = 1200000000, M1;
			while (true) {
				M1 = (L1 + R1) / 2;
				bool b1 = check(M1 - 1, P), b2 = check(M1, P);
				if (b1 == false && b2 == true) { cout << M1 << endl; break; }
				if (b1 == true)R1 = M1;
				if (b2 == false)L1 = M1;
				if (M1 >= 1020000000 && b2 == false) { cout << "NA" << endl; break; }
			}
		}
	}
	return 0;
}

Measured memory_bytes: 13504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n){
    cin >> a.at(i);
  }
  ll ans=1000;
  rep(i,n-1){
    ll p=ans/a.at(i);
    ll q=ans%a.at(i);
    if(a.at(i)<a.at(i+1)){
      ans=p*a.at(i+1)+q;
    }
  }
  if(ans<1000){
    cout << 1000;
  }else{
    cout << ans;
  }
}
    
  

Measured memory_bytes: 3628
import math
N, M = map(int, input().split())
if N-M == 0:
    n = 2*math.factorial(N)*math.factorial(M)
    n %= int(7+1e9)
    print(n)
elif abs(N-M) == 1:
    n = math.factorial(N)*math.factorial(M)
    n %= int(7+1e9)
    print(n)
else:
    print(0)


Measured memory_bytes: 5184
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
const ll MOD = 1000000007;
const int inf = 1e9 + 10;
const ll INF = 4e18 + 10;
const int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
const int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
int main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);

	double n, m, d;
	cin >> n >> m >> d;
	double ans = (n - d) * (m - 1) / n / n;
	if (d) ans *= 2;
	CST(10) << ans << endl;
	return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/06/22  Problem: ABC 131 B / Link: http://abc131.contest.atcoder.jp/tasks/abc131_b  ----- */


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

	LL N, L;cin >> N >> L;
	LL all = 0;
	FOR(i, 0, N) {
		all += L + i;
	}
	LL ans = 0;
	LL mindiff = LINF;
	FOR(i, 0, N) {
		LL s = 0;
		FOR(j, 0, N) {
			if (i == j)continue;
			s += L + j;
		}
		if (abs(all - s) < mindiff) {
			ans = s;
			mindiff = abs(all - s);
		}
	}
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
    詰まった時に、別の分野の問題として考え直す（これdpでは？、グラフとしてみればいいのでは？）
    多くの問題はパターンマッチだが、パターンに落とし込むまでが難しく、そのための訓練としてわからない問題をあれこれ色々な角度から考察してみるのではないか
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

/* <--------------------------------------------> */

typedef tuple<int, int, int> T;
// get<K>(tuple型の変数)


class UnionFind{
public:
    //親の番号を格納する。親だった場合はー（その集合のサイズ）
    vector<int> parents;
    int count;

    //作る時はparentsを-1で初期化する
    //こうすることで全部ばらばらになる
    UnionFind(int n){
        parents = vector<int>(n, -1);
        count = n;
    }

    //Aがどのグループにいるか調べる
    int root(int A){
        if(parents[A]<0) return A;
        return parents[A] = root(parents[A]);
    }

    //自分のいるグループの大きさを調べる
    int size(int A){
        return -parents[root(A)];
    }

    //AとBをくっつける
    bool connect(int A, int B){
        //AとBを直接ではなく親同士をくっつける
        A=root(A);
        B=root(B);
        if(A==B){
            return false;
        }

        //大きい方（A)に小さい方（B)をくっつけたい
        if(size(A)<size(B)) swap(A, B);

        parents[A] += parents[B];
        parents[B] = A;
        --count;

        return true;
    }
};



int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n; cin >> n;
    int base=100010;
    UnionFind uni(2*base);

    vector<int> x(n), y(n);
    rep(i, n){
        cin >> x[i] >> y[i];
        uni.connect(x[i], y[i]+base);
    }

    map<int, ll> mx, my;
    rep(i, base) ++mx[uni.root(i)];
    repr(i, base, 2*base) ++my[uni.root(i)];
    ll ans=0;
    rep(r, 2*base) ans+=mx[r]*my[r];
    cout << ans-n << endl;
    
    return 0;
}


Measured memory_bytes: 26880
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.math.BigDecimal;

public class Main {
  static InputReader in;
  static PrintWriter out;

  static class Solution {
    void solve() throws IOException {
      int cnt = 0;
      int n = in.nextInt();
      for (int i = 0; i < n; i++) {
        int x = in.nextInt();
        if (primalityTest(x)) {
          cnt++;
        }
      }
      
      out.println(cnt);
//      End solve()
    }
    
    boolean primalityTest(int x) {
      if (x == 2) {
        return true;
      }
      
      if (x < 2 || x % 2 == 0) {
        return false;
      }
      
      int i = 3;
      while (Math.sqrt(x) >= i ) {
        if (x % i == 0) {
          return false;
        }
        
        i += 2;
      }
      
      return true;
    }
    
//    End Solution
}


  public static void main(String[] args) throws IOException {
    in = new InputReader(System.in);
    out = new PrintWriter(System.out);
    Solution solver = new Solution();
    solver.solve();
    out.close();
}


  static class InputReader {
    public BufferedReader br;
    public StringTokenizer st;

    public InputReader(InputStream stream) {
      br = new BufferedReader(new InputStreamReader(stream));
    }

    public int nextInt() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Integer.parseInt(st.nextToken());
    }

    public long nextLong() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Long.parseLong(st.nextToken());
    }

    public String next() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return st.nextToken();
    }

    public double nextDouble() throws IOException {
      while (st == null || !st.hasMoreTokens()) {
        st = new StringTokenizer(br.readLine());
      }
      return Double.parseDouble(st.nextToken());
    }

  }

}

Measured memory_bytes: 31012
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll k[101010];
ll b[101010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

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

int main() {
    cin>>W>>H;
    cin>>X>>Y;
    cout<<W*H/2.0<<" ";
    if(X*2==W && Y*2 ==H){
        cout<<1<<endl;
    }else{
        cout<<0<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int k,st[1100000],f[1100000];
int main() {
	scanf("%d",&k);
	st[1]=7%k;int r=1;
	if (st[1]==0) printf("1\n");
	else {
		f[st[1]]=1;
		while (r<=k) {
			int tmp=(st[r]*10+7)%k;
			st[++r]=tmp;
			if (f[st[r]]){
				printf("-1\n");
				return 0;
			}
			if (st[r]==0) {
				printf("%d\n",r);
				return 0;
			}
			f[st[r]]=1;
		}
	}
	return 0;
} 

Measured memory_bytes: 11640
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int t = 0;
	for(int i = 1; i <= 1e5; i++){
		if(i*i > n){
			t = i-1;
			break;
		}
	}
	cout<<t*t<<endl;
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()

using ll = long long;
using P = pair<int,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

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

    sort(all(p));

    int ans = 0;
    for (int i = 0; i < k; ++i) {
        ans += p[i];
    }

    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 3624
while 1:
    edges = [0] * 101
    try:
        a, b = map(int, raw_input().split())
        edges[a] += 1
        edges[b] += 1
    except EOFError:
        break
    while 1:
        a, b = map(int, raw_input().split())
        if a == b == 0:
            break
        edges[a] += 1
        edges[b] += 1
    if edges[1] % 2 and edges[2] % 2 and all(map(lambda a: a % 2 == 0, edges[3:])):
        print "OK"
    else:
        print "NG"

Measured memory_bytes: 4224
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 998244353;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}
ll dp[3010][3010] = {};
ll dp2[3010][3010] = {};
ll power(ll x, ll n){
    if(n == 0) return 1LL;
    ll res = power(x * x % MOD, n/2);
    if(n % 2 == 1) res = res * x % MOD;
    return res;
}

void solve(){
    ll N,S;
    cin >> N >> S;
    ll A[3010];
    rep(i,0,N) cin >> A[i];
    dp[0][0] = 1;
    ll ans = 0;
    rep(i,0,N){
        rep(j,0,S+1){
            dp[i+1][j] += dp[i][j] * 2;
            dp[i+1][j] %= MOD;
            if(j - A[i] >= 0){
                dp[i+1][j] += dp[i][j-A[i]];
                dp[i+1][j] %= MOD;
            }
        }
    }
    print(dp[N][S]);

    

}

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

Measured memory_bytes: 74236
#include<bits/stdc++.h>
#define ll long long
#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using namespace std;
typedef pair<ll, ll> pint;

const int MOD = 1000000007;
void yesno(bool b) {
    if (b) {
        cout << "Yes" << endl;
    }     else {
        cout << "No" << endl;
    }
}

int main() {
    int K;
    cin >> K;
    string S;
    cin >> S;
    int n = S.size();
    if (n <= K) {
        cout << S << endl;
    } else {
        rep(i, K) {
            cout << S[i];
        }
        cout << "..." << endl;
    }
}


Measured memory_bytes: 3632
#include <iostream>
#include <complex>
#include <vector>
using namespace std;

typedef complex<double> P;

#define INF 999999999
#define EPS (1e-10)
#define EQ(a,b) (abs((a)-(b)) < EPS)

//àÏ
double dot(P a, P b){
	return (a.real() * b.real() + a.imag() * b.imag());
}

//OÏ
double cross(P a,P b){
	return (a.real() * b.imag() - a.imag() * b.real());
}

//üªabÆ_cÌ£
double distance_ls_p(P a, P b, P c) {
  if ( dot(b-a, c-a) < EPS ) return abs(c-a);
  if ( dot(a-b, c-b) < EPS ) return abs(c-b);
  return abs(cross(b-a, c-a)) / abs(b-a);
}

//üªabãÉ_cª é©
int is_point_on_line(P a, P b, P c) {
	return EQ( cross(b-a, c-a), 0.0 ) &&
	       (dot(b-a, c-a) > -EPS) &&
	       (dot(a-b, c-b) > -EPS);
}

//pÌÚ®ãÌÊuðßé
P move(P p,double v){
	P b = -p / abs(-p); //-p ÌPÊxNg
	return p + b * v;
}

int main(void){
	int n;
	double R;

	while(cin>>R>>n && (R||n)){
		int ans = 0;
		vector<P> p(n);
		vector<double> r(n),v(n);

		for(int i=0;i<n;i++){
			cin>>p[i].real()>>p[i].imag()>>r[i]>>v[i];
		}

		while(p.size() != 0){
			int minIdx = -1;
			double minDist = INF;

			for(int i=0;i<p.size();i++){
				//r[ª ½çÈ¢êÈçJEg
				if(abs(p[i]) < R + EPS){
					ans++;
					p.erase(p.begin()+i);
					r.erase(r.begin()+i);
					v.erase(v.begin()+i);
					i--;
					continue;
				}

				P aft = move(p[i],v[i]);
				double dist = abs(aft);

				//(0,0)ðÊßµÄµÜ¤©,¼aRÌÍÍàÈçJEg
				if(is_point_on_line(p[i],aft,P(0,0)) || dist < R + EPS){
					ans++;
					p.erase(p.begin()+i);
					r.erase(r.begin()+i);
					v.erase(v.begin()+i);
					i--;
					continue;
				}

				p[i] = aft;
				if(minDist > dist){
					minIdx = i;
					minDist = dist;
				}
			}

			if(minIdx == -1) break;

			P pp = p[minIdx];
			for(int i=0;i<p.size();i++){
				P b = pp / abs(pp); //ppÌPÊxNg
				P o = b * R + b * EPS;
				//´_©çR£ê½êðn_ÆµÄ,ppûüÖ·­LÑéüªÆ p[i] Ì£ª r[i] ÈºÈç ½é
				if(distance_ls_p(o,b*10000000.0,p[i]) < r[i] + EPS){
					p.erase(p.begin()+i);
					r.erase(r.begin()+i);
					v.erase(v.begin()+i);
					i--;
				}
			}
		}

		cout<<ans<<endl;
	}

	return 0;
}

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

using namespace std;

const int MAX = 1001;
const int INF = (1<<20);
typedef pair<int,int> P;
typedef pair<int,P> PP;

int dx[4] = {1,-1,0,0};
int dy[4] = {0,0,1,-1};
char grid[MAX][MAX];
int cost[MAX][MAX];
int H,W,N;
vector<PP> V;
P f,t;

void init(){
  for(int i = 0; i <= H; i++)
    for(int j = 0; j <= W; j++)
      cost[i][j] = INF;

}

void input(){
  for(int i = 1; i <= H; i++)
    for(int j = 1; j <= W; j++){
      cin >> grid[i][j];
      PP pp;

      if(grid[i][j] == 'S' || '0' <= grid[i][j] && grid[i][j] <= '9'){
	if(grid[i][j] == 'S') pp.first = 0;
	else pp.first = grid[i][j] - '0';
	
	pp.second = P(i,j);
	V.push_back(pp);
      }
    }
}


bool isIn(P p){
  return 0 < p.first && p.first<= H && 0 < p.second && p.second <= W;
}
void solve(P p){

  int n = cost[p.first][p.second];

  for(int i = 0; i < 4; i++){
    P next = p;
    next.first += dy[i];
    next.second += dx[i];
    if(grid[next.first][next.second] != 'X' && cost[next.first][next.second] > n+1 && isIn(next)){
	cost[next.first][next.second] = n+1;
	if(next != t) solve(next);
    }
  }
}

P find(int n){
  for(int i = 0; i < V.size(); i++)
    if(V[i].first == n) return V[i].second;

}

int main(){

  cin >> H >> W >> N;

  input();
  sort(V.begin(),V.end());
  
  int ans = 0;
 
  for(int i = 1; i <= N; i++){
    init();
    f = find(i-1), t = find(i);
    cost[f.first][f.second] = 0;
    solve(f);
    ans += cost[t.first][t.second];
    
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 12788
N = int(input())
s_list=[]
t_list=[]
for i in range(N):
    s, t = input().split()
    s_list.append(s)
    t_list.append(int(t))
X = str(input())

u = t_list[s_list.index(X)+1:]
s = 0
for i in range(len(u)):
    s = s + u[i]
print(s)

Measured memory_bytes: 3060
#include <stdio.h>

int main(void)
{
	int h, w, l;
	int n, i;
	int r;
	int tmp;
	
	while (1){
		scanf("%d %d %d", &h, &w, &l);
		
		if (h == 0 && w == 0 && l == 0){
			break;
		}
		if ( h > l){
			tmp = h;
			h = l;
			l = tmp;
		}
		if ( w > l){
			tmp = w;
			w = l;
			l = tmp;
		}
		
		scanf("%d", &n);
		
		for  (i = 0; i < n; i++){
			scanf("%d", &r);
			if (r * r * 4 > h * h + w * w){
				printf("OK\n");
			}
			else {
				printf("NA\n");
			}
		}
	}
	
	return (0);
}

Measured memory_bytes: 584
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i=0;i<(n);i++)
int cost;
int a,b,c,d;
int newa,newb,newc,newd;

int rest;
int main()
{
cin >> cost;
	
		cin >>a >> b >> c >> d;
		rest = 10 *a + 50 * b + 100 * c + 500 * d - cost;
		
		newa = rest % 50 / 10;
		newb = (rest - 10 * newa) % 100/50;
		newc = (rest - 10 * newa - 50 * newb) % 500 / 100;
		newd = (rest - 10 * newa - 50 * newb - 100 * newc) / 500;

		if (a > newa) cout << 10 << " " << a - newa << endl;			
		if (b > newb) cout << 50 << " " << b - newb << endl;
		if (c > newc) cout << 100 << " " << c - newc << endl;
		if (d > newd) cout << 500 << " " << d - newd << endl;
	
	while (cin >> cost && cost != 0)
	{   
	    cout << endl;
		cin >>a >> b >> c >> d;
		rest = 10 *a + 50 * b + 100 * c + 500 * d - cost;
		
		newa = rest % 50 / 10;
		newb = (rest - 10 * newa) % 100/50;
		newc = (rest - 10 * newa - 50 * newb) % 500 / 100;
		newd = (rest - 10 * newa - 50 * newb - 100 * newc) / 500;

		if (a > newa) cout << 10 << " " << a - newa << endl;			
		if (b > newb) cout << 50 << " " << b - newb << endl;
		if (c > newc) cout << 100 << " " << c - newc << endl;
		if (d > newd) cout << 500 << " " << d - newd << endl;
	}
	return 0;
}


Measured memory_bytes: 3084
n=int(input())
a=[ list(map(int,input().split())) for x in range(2)]
#print(a)
dp=[[0]*n for _ in range(2)]
#print(dp)
dp[0][0]=a[0][0]
for i in range(1,n):
    dp[0][i]=a[0][i]+dp[0][i-1]
dp[1][0]=dp[0][0]+a[1][0]
for j in range(1,n):
    dp[1][j]=a[1][j]+max(dp[0][j],dp[1][j-1])
print(dp[1][n-1])


Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
#define fo(i,a,b) for(i=a;i<=b;i++)
using namespace std;
typedef double db;
db a,p,ans;
int i,j,k,l,t,n,m;
int main(){
	scanf("%d%lf%lf",&n,&a,&p);
	a-=p;
	t=2*n;
	l=n;
	fo(i,1,n){
		ans+=(db)(a*t+p*t*(t+1)/2)/t;
		a=a+a/l+3*p/(2*l);
		p=p+2*p/l;
		l--;
		t-=2;
	}
	printf("%.15lf\n",ans);
}

Measured memory_bytes: 256
import Foundation

#if swift(>=4.0)
extension String {
    func split(by separator: String) -> [String] {
        return self.components(separatedBy: separator)
    }
    func toArray() -> [String] {
        return self.map{String($0)}
    }
}
#else
extension String {
    func split(by separator: String) -> [String] {
        return self.componentsSeparatedByString(separator)
    }
    func count() -> Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
}
extension Array where Element: Comparable {
    func max() -> Element! {
        return self.maxElement()
    }
    func min() -> Element! {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: String) -> [String] {
    return readLine()!.split(by: separator)
}
func readIntSplit(by separator: String) -> [Int] {
    return readLine()!.split(by: separator).map{Int($0)!}
}

/*************** テストスペース ***************/



/*************** メインプログラム ***************/

let N = readInt()!
let H = readIntSplit(by: " ")
var h = [0]
var ans = 0
for i in 0..<N {
    if H[i] >= h.max()! {
        ans += 1
    }
    h += [H[i]]
}
print(ans)


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

using namespace std;
const int N=100005,M=100005;

vector<pair<int,int>> v[N];
vector<pair<int,int>> g[N];
vector<pair<int,int>> e;
vector<bool> dir(M,0);
vector<int> out(N,0);
vector<int> id(N);
vector<int> dp(N,0);

void tree()
{
    vector<bool> vis(N,0);
    vis[1]=1;
    queue<int> q;
    q.push(1);
    while(!q.empty())
    {
        int a=q.front();
        q.pop();
        for(pair<int,int> p:v[a])
        {
            int to=p.first;
            if(vis[to]) continue;
            vis[to]=1;
            g[a].push_back(make_pair(to,p.second));
            g[to].push_back(make_pair(a,p.second));
            id[to]=p.second;
            q.push(to);
        }
    }
}

void dfs(int a,int par=-1)
{
    if(out[a]&1) dp[a]=1;
    for(pair<int,int> p:g[a])
    {
        int to=p.first;
        if(to==par) continue;
        dfs(to,a);
        dp[a]+=dp[to];
    }
    if(par!=-1)
    {
        if(dp[a]&1) dir[id[a]]=1;
    }
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        v[a].push_back(make_pair(b,i));
        v[b].push_back(make_pair(a,i));
        e.push_back(make_pair(a,b));
        out[a]++;
    }
    int cnt=0;
    for(int i=1;i<=n;i++) if(out[i]&1) cnt++;
    if(cnt&1)
    {
        printf("-1\n");
        return 0;
    }
    tree();
    dfs(1);
    for(int i=0;i<m;i++)
    {
        if(dir[i]==0) printf("%d %d\n",e[i].first,e[i].second);
        else printf("%d %d\n",e[i].second,e[i].first);
    }
    return 0;
}


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

using namespace std;

int main(){
	long long a,b,c,i,z;
	
	cin>>a>>b>>c;
	
	z=0;
	for(i=a;i<=b;i++){
		if(c%i==0) z++;
	}
	
	cout<<z<<endl;
			      
	return 0;
}


Measured memory_bytes: 3084
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
ll power(ll m, ll n)
{
    if(n == 0) return 1;
    ll res = power(m * m % MOD, n / 2);
    if(n & 1) res = res * m % MOD;
    return res;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll m, n;
    cin >> m >> n;
    cout << power(m, n) << endl;
    return 0;
}




Measured memory_bytes: 3152
using System;

public class Hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var n = int.Parse(line[0]);
        var a = int.Parse(line[1]);
        line = Console.ReadLine().Trim().Split(' ');
        var x = Array.ConvertAll(line, int.Parse);
        var dp = new long[n + 1, n + 1, n * 50 + 1000];
        dp[0, 0, 0] = 1;
        for (int i = 0; i < n; i++)
            for (int j = 0; j < n; j++)
                for (int k = 0; k <= n * 50 + 1; k++)
                {
                    dp[i + 1, j, k] += dp[i, j, k];
                    dp[i + 1, j + 1, k + x[i]] += dp[i, j, k];
                }
        var rep = 0L;
        for (int i = 1; i < n + 1; i++)
            rep += dp[n, i, i * a];
        Console.WriteLine(rep);
    }
}


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

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

#define IOS             ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define read            freopen("in.txt","r",stdin)
#define write           freopen("out.txt","w",stdout)
#define loop(i,a,b)     for (ll i = a; i <= b; i++)
#define rloop(i,a,b)    for (ll i = a; i >= b; i--)
#define ms(a,x)         memset(a,x,sizeof a)
#define ll              long long int
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define rall(a)         a.rbegin(),a.rend()
#define pb              push_back
#define nl              cout<<"\n"
#define gcd(a,b)        __gcd((a),(b))
#define lcm(a,b)        ((a)*(b))/(gcd(a,b))
#define sq(a)           (a)*(a)
#define sz(a)           a.size()
#define mod             1000000007
#define PI              2*acos(0.0)


int main()
{
    IOS
    int T=1;
    //cin>>T;
    while(T--)
    {
        ll n;
        cin>>n;
        ll a[n],b[n],c[n],dp[n][3];
        loop(i,0,n-1) cin>>a[i]>>b[i]>>c[i];
        dp[0][0]=a[0];
        dp[0][1]=b[0];
        dp[0][2]=c[0];
        loop(i,1,n-1)
        {
            dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
            dp[i][1]=b[i]+max(dp[i-1][0],dp[i-1][2]);
            dp[i][2]=c[i]+max(dp[i-1][1],dp[i-1][0]);
        }
        cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    }
    return 0;
}


Measured memory_bytes: 8288
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>

using namespace std;

#define ll long long
#define ld long double
#define v vector

#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) begin(x), end(x)
#define rall(x) end(x), begin(x)

#define endl '\n'


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(const vector<ll> & a) {
  rep(i, 5)
    if (a[i]==0)
      return i+1;
  return -1;
}

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

  // failed to analyze input format
  // TODO: edit here
  vector<ll> a(5);
  rep (i, 5) {
    cin >> a[i];
  }

  auto ans = solve(a);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3196
#include<iostream>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int max(int a,int b){
	return (a>b)?a:b;
}

int main(){
	int sum=0,m=0,a,n,l;
	cin>>n;
	rep(i,n){
		cin>>l;
		sum+=l;
		m=max(m,l);
	}
	if(sum-m>m)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

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

    string ans;
    int N;
    cin >> N;
    while (N) {
        ans.push_back('a' + ((N - 1) % 26));
        N--;
        N /= 26;
    }
    reverse(all(ans));
    cout << ans << endl;

    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
    int w, h, n;
    int ans[2][2]={0};
    cin >> w >> h >> n;
    ans[0][1] = w;
    ans[1][1] = h;

    int x[n], y[n], a[n], i;
    for(i=0; i<n; i++) {
        cin >> x[i] >> y[i] >> a[i];
        switch(a[i]) {
            case 1:
                if(ans[0][0]<x[i]) ans[0][0] = x[i];
                break;
            case 2:
                if(ans[0][1]>x[i]) ans[0][1] = x[i];
                break;
            case 3:
                if(ans[1][0]<y[i]) ans[1][0] = y[i];
                break;
            case 4:
                if(ans[1][1]>y[i]) ans[1][1] = y[i];
                break;
        }
    }

    // cout << "x: " << ans[0][0] << " " << ans[0][1] << endl;
    // cout << "y: " << ans[1][0] << " " << ans[1][1] << endl;

    if((ans[0][0]>=ans[0][1]) || (ans[1][0]>=ans[1][1])) {
        cout << 0 << endl;
    } else {
        cout << (ans[0][1]-ans[0][0])*(ans[1][1]-ans[1][0]) << endl;
    }

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int a[100001];
int fib(int i,int n,int arr[],int k)
{
    if(i==n-1)
    {
        return 0;
    }
    int p=INT_MAX,q=INT_MAX;
        if(a[i]!=-1)
    {
        return a[i];
    }
    for(int j=1;j<=k;j++)
    {
        if(i+j<=n-1)
        {
                    q=fib(i+j,n,arr,k)+abs(arr[i]-arr[i+j]);
        }
        p=min(p,q);
    }
    a[i]=p;
    return a[i];
}
int main()
{
    int n,k;
    cin>>n>>k;
    int arr[n];
    memset(a,-1,sizeof(a));
    a[n-1]=0;
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    cout<<fib(0,n,arr,k)<<endl;


}




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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int flag[26] = {0};
char s[30];

int main(){
  scanf("%s",s);
  for(int i=0;s[i]!='\0';i++){
    flag[s[i]-'a']++;
  }
  REP(i,26){
    if(flag[i]>1){
      printf("no\n");
      return 0;
    }
  }
  printf("yes\n");
}


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 r,D,x;
  cin >> r >> D >> x;
  int tmp = (r*x-D);
  for(int i=1;i<=10;i++){
    cout << tmp << endl;
    tmp  = (r*tmp-D);
  }
  return 0;
}

Measured memory_bytes: 256
import heapq
n, m = map(int, input().split())
a = list(map(int, input().split(" ")))
h = []
for aa in a:
    heapq.heappush(h, -aa)
for i in range(m):
    x = heapq.heappop(h)
    heapq.heappush(h, x / 2)

ans = 0
for x in h:
    ans += int(-x)
print(ans)


Measured memory_bytes: 14180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};
int func(int n){
  int sum =1;
  rep1(i,n+1){sum *= i;}
  return sum;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
   int n,m;
   cin >> n >> m;
  int a,b;
  int ans;
  	if(n>1){a = n*(n-1)/2;}else{a = 0;}
  if(m>1){b = m*(m-1)/2;}else{b = 0;}
  	ans = a+b;
  	cout << ans << endl;
  return 0;
  
  
}

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

using namespace std;

int main()
{
	int K;
	string S;

	cin >> K >> S;

	if(S.size() > K)
	{
		cout << S.substr(0,K) << "..." << endl;
	}
	else
	{
		cout << S << endl;
	}

	return 0;
}

Measured memory_bytes: 3628
def solve():
    n = int(input())
    cnt = 0
    for i in range(n):
        a, b = map(int, input().split())
        if a == b:
            cnt += 1
        else:
            cnt = 0
        if cnt > 2:
            print("Yes")
            exit()
    print("No")
    return 0

if __name__ == "__main__":
    solve()


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

int main() {
	int N, M, X;
	cin >> N >> M >> X;
	int* A = (int*)malloc(sizeof(int)*M);
	for (int i = 0;i < M;i++)cin >> A[i];
	int num1 = 0, num2 = 0;
	for (int i = 0;i < M;i++) {
		if (A[i] > X)num1++;
		else num2++;
	}
	if (num1 >= num2) {
		cout << num2 << endl;
		return 0;
	}
	else {
		cout << num1 << endl;
		return 0;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
#define RRep(i, k, n) for (int i = k; i > (int)(n); i--)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define ALL(a)  (a).begin(),(a).end()
#define rALL(a)  (a).rbegin(),(a).rend()
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 long long INF = 1LL << 60;
const int MOD = 1000000007;
const double PI = acos(-1); //3.14~
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main()
{
    ll n, m; cin >> n >> m;
    vector<Pll> c(n);
    rep(i, n)
    {
        cin >> c[i].first >> c[i].second;
    }
    sort(ALL(c));

    ll ans = 0;
    rep(i, n)
    {
        ans += c[i].first * min(m, c[i].second);
        m -= min(m, c[i].second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main()
{
	int n,a,b,i,f,x=0,count=0;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++)
	{
		x=0;
	 f=i;
	while(f!=0)
	{
		x+=f%10;
		f=f/10;
	}
	if(x>=a&&x<=b) count+=i;
    }
    cout<<count<<endl;
    return 0;
}

Measured memory_bytes: 256