akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll =long long;
using P =pair<int,int>;

int main(){
    int n,k;
    int r,s,p;
    string t;
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    vector <vector <int>> m(k);

    rep(i,n){
        m[i%k].push_back(t[i]);
        
    }

    int l,gu,tyo,pa,gu2,tyo2,pa2;
    int ans;
    int ans2;
    ans=0;
    rep(i,k){
        gu=0;
        tyo=0;
        pa=0;
        l=m[i].size();
        rep(j,l){
            if (m[i][j]=='r'){
            pa2=max(tyo,gu)+p;
            tyo2=max(pa,gu);
            gu2=max(pa,tyo);
        }
        else if(m[i][j]=='s'){
            pa2=max(tyo,gu);
            tyo2=max(pa,gu);
            gu2=max(pa,tyo)+r;
        }
        else{
            pa2=max(tyo,gu);
            tyo2=max(pa,gu)+s;
            gu2=max(pa,tyo);
        }
        pa=pa2;
        tyo=tyo2;
        gu=gu2;
        
        
    }
    ans2=max(gu,tyo);
    ans2=max(ans2,pa);
    ans+=ans2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
ll s, x2 = 1e9;
int main(){
	scanf("%lld", &s);
	if(s == 1e18) printf("0 0 %lld %lld 0 %lld", x2, x2, x2);
	else printf("0 0 %lld %lld 1 %lld\n", x2, x2-s%x2, s/x2+1);
}

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

using namespace std;

int main(){
  int A;
  int B;
  int C;
  int a=0;
  cin >> A >> B >> C;
  a=C-(A-B);
  if(a>0){
    cout << a << endl;
  }
  else{
    cout << 0 << endl;
  }
  return 0;
}

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

int main () {
    long long a, b, c;
    scanf("%lld %lld %lld", &a, &b, &c);
    int r = (c*c + a*a + b*b - 2 * (a*b + a*c + b*c) > 0) && c > a && c > b;
    printf(r ? "Yes\n" : "No\n");
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

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

int main(){
  int w,h;
  while(scanf("%d%d",&w,&h), w+h){
    int board[h][w];
    int cost[4];
    REP(i,h) REP(j,w) scanf("%d",&board[i][j]);
    REP(i,4) scanf("%d",&cost[i]);

    typedef pair<int,pair<int,pair<int,int> > > data;
    priority_queue<data> pq;
    bool memo[h][w][4];
    memset(memo, 0, sizeof(memo));
    pq.push(mp(0,mp(0,mp(0,0))));

    while(!pq.empty()){
      data d = pq.top(); pq.pop();
      int x = d.s.s.f;
      int y = d.s.s.s;
      int dir = d.s.f;
      int c = -d.f;

      if(memo[y][x][dir]) continue;
      memo[y][x][dir] = true;

      if(x == w-1 && y == h-1){
        printf("%d\n",c);
        break;
      }

      REP(i,4){
        int cc = c + (board[y][x] == i ? 0 : cost[i]);
        int dd = (dir + i) % 4;
        int xx = x + dx[dd];
        int yy = y + dy[dd];
        if(xx < 0 || y < 0) continue;
        if(xx >=w || y >=h) continue;
        if(memo[yy][xx][dd]) continue;
        pq.push(mp(-cc,mp(dd,mp(xx,yy))));
      }
    }
  }
  return 0;
}

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

long tr(int x) {
	return  1l * x * x * x; //long型にするため1l
}

int main() {
	int n, k;
	long c = 0;
	cin >> n >> k;

	if (k % 2 == 0) {
		c=tr((n + k / 2) / k);
	}
	cout << tr(n / k) + c << endl;
}

Measured memory_bytes: 256
n = int(input())
a = []
for i in range(n):
    temp = int(input())
    a.append(temp)
if a[0] != 0:
    print("-1")
else:
    check = True
    for i in range(n-1):
        if a[i+1] >= a[i] + 2:
            print("-1")
            check = False
            break
    if check:
        ans = sum(a)
        for i in range(n-1):
            if a[i+1] == a[i]+1:
                ans -= a[i]
        print(ans)

Measured memory_bytes: 11052
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	if n < 1200 {
		fmt.Println("ABC")
		return
	}
	if n < 2800 {
		fmt.Println("ARC")
		return
	}
	fmt.Println("AGC")
}


Measured memory_bytes: 512
//369ms
//通った.vectorを関数に参照渡ししたときにコピーされていて、それがボトルネックになっていたのだと思う
#include<bits/stdc++.h>
using namespace std;

vector<vector<int>> is_connected;
vector<int> node_sum;
int n,q;

void add_to_child(int node,int parent){
	for(int i=0;i<(int)is_connected[node].size();i++){
		int tar = is_connected[node][i];
		if(tar == parent){continue;}
		node_sum[tar] += node_sum[node];
		add_to_child(tar,node);
	}
}
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n >> q;
	is_connected.resize(n);
	node_sum.resize(n);
	for(int i=0;i<n;i++) node_sum[i] = 0;
	int a,b;
	for(int i=0;i<n-1;i++){
		cin >> a >> b;
		is_connected[a-1].push_back(b-1);
		is_connected[b-1].push_back(a-1);
	}
	for(int i=0;i<q;i++){
		cin >> a >> b;
		node_sum[a-1] += b;
	}
	add_to_child(0,-1);
	for(int i=0;i<n;i++){
		cout << node_sum[i] << " ";
	}
	cout << endl;
	return 0;
}


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

#define FOR(s, i, n) for(int i = s; i n; i++)
typedef long long ll;
const int INF = 1e9;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin>>n;
	vector<int> a(n);
	int allXor = 0;
	for (int i = 0; i < n; i++){
		cin>>a[i];
		allXor ^= a[i];
	}
	for (int i = 0; i < n; i++){
		cout<<(allXor^a[i])<<'\n';
	}
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio(false);
	double n, m, d; cin >> n >> m >> d;
	double ans = (double)(d == 0 ? 1 : 2) * (m - 1) * (n - d) / (double)(n * n);
	cout << fixed << setprecision(11) << ans << '\n';
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdint>
#include<cstdlib>
template<typename T>
void fin(T const& t){ std::cout << t << std::endl; exit(0); }

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  int N; std::cin >> N;
  std::vector<int64_t> s(N);
  for(int i = 0; i < N; ++i) std::cin >> s[i];
  int64_t ans = 0;
  for(int g = 1; g*2 <= N-2; ++g) {
    int64_t cur = 0;
    int l = g, r = N-1-g;
    while(l<r) {
      cur += s[l]+s[r];
      ans = std::max(ans, cur);
      l += g; r -= g;
    }
    if((N-1)%g != 0) while(r > g) {
      cur += s[l]+s[r];
      ans = std::max(ans, cur);
      l += g; r -= g;
    }
  }
  fin(ans);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<cmath>
#include <algorithm>
using namespace std;
 
int main(){
  int N;
  int p[20];
  int counter=0;
  cin >> N;

  for(int i=0;i<N;++i) cin >> p[i];
  
  for(int i=1;i<N-1;++i){
  	if(p[i]!=max({p[i-1],p[i],p[i+1]}) && p[i]!=min({p[i-1],p[i],p[i+1]})){
      ++counter;
    }
  }

  cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG true
// sort(a.begin(), a.end(), std::greater<int>());

/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/

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

    ans = abs((n - 2) * (m - 2));
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define Fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define mod 1000000007
#define maxn 100000

map <int, int> mp;

long long min_cost(int h[], int n)
{
    if(n <= 1)
        return 0;

    if(n == 2)
        return (fabs(h[2] - h[1]));

    if(mp.find(n) != mp.end())
        return mp[n];

    long long minimum = min(min_cost(h, n-1) + fabs(h[n] - h[n-1]), min_cost(h, n-2) + fabs(h[n] - h[n-2]));

    mp[n] = minimum;

    return minimum;
}

int main()
{
    Fio;
    int t=1;
//    cin >> t;
    while(t--)
    {
        int n;
        cin >> n;
        int h[n+1];
        for(int i=1; i<=n; i++)
            cin >> h[i]; 

        cout << min_cost(h, n) << endl;
    }

    return 0;
}

Measured memory_bytes: 9216
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,x;
  cin >> n;
  set<int> s;
  for(int i=0; i<n; i++) {
    cin >> x;
    s.insert(x);
  }
  if(s.size()==n) {
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

#define int            long long int
#define float          long double
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define inf            1e18
#define set_pre(x,y)   fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)

using namespace std;
int solve(vector<int>&dp,list<int>*Graph,int node)
{
    if(Graph[node].size()==0)
        return 0;
    if(dp[node]!=-1)
        return dp[node];
    for(auto c:Graph[node])
    {
        if(dp[c]==-1)
            dp[node]=max(dp[node],solve(dp,Graph,c)+1);
        else
            dp[node]=max(dp[node],dp[c]+1);
    }
    return dp[node];
}
int32_t main()
{
    int n,m;
    cin>>n>>m;
    list<int>Graph[n];
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        Graph[x-1].push_back(y-1);
    }
    vector<int>dp(n,-1);
    for(int i=0;i<n;i++)
    solve(dp,Graph,i);
    cout<<*max_element(dp.begin(),dp.end())<<endl;
}

Measured memory_bytes: 8448
package main

import (
        "fmt"
)

func solution(s string) string {
        var buf [4]int
        for i := range s {
                buf[i] = int(s[i] - '0')
        }
        out := ""
        for p := 0; p < 1<<3; p++ {
                ans := buf[0]
                var b []byte
                b = append(b, s[0])
                for i := 0; i < 3; i++ {
                        if p>>uint(i)&1 == 0 {
                                b = append(b, '+')
                                b = append(b, s[i+1])
                                ans += buf[i+1]
                        } else {
                                b = append(b, '-')
                                b = append(b, s[i+1])
                                ans -= buf[i+1]
                        }
                }
                if ans == 7 {
                        b = append(b, '=')
                        b = append(b, '7')
                        out = string(b)
                        break
                }
        }
        return out
}

func main() {
        var s string
        fmt.Scan(&s)
        fmt.Println(solution(s))
}

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

int main(){
    int h,w;

    while(1){
        cin >> h >> w;
        if(h == 0 && w == 0) break;
        for(int i = 0; i < h; i++){
            for(int j = 0; j < w; j++){
                if(i == 0 || i == h-1 || j == 0 || j == w-1){
                    cout << "#";
                }else{
                    cout << ".";
                }
            }
            cout << endl;
        }
        cout << endl;
    }

    return 0;
}

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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define repi(i,a,b) for(long long i = (long long)(a); i < (long long)(b); i++)
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
using ll = int; using vll = vector<ll>; 
static const long long INF = 1e9;

ll d[200010], e[1ll<<26], a[200010];
int main(void) {
    string s; cin >> s;
    ll n = s.length();
    vll cand; cand.push_back(0); rep(i, 26) cand.push_back(1ll<<i);

    rep(i, n) a[i+1] = a[i] ^ (1ll << (s[i] - 'a'));
    repi(i, 1, 200010) d[i] = INF;
    repi(x, 1, 1ll<<26) e[x] = INF;

    repi(i, 1, n+1) {
        for (auto x : cand) chmin(d[i], e[a[i]^x] + 1);
        chmin(e[a[i]], d[i]);
    }

    cout << d[n] << endl;

    return 0;
}


Measured memory_bytes: 264324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using Edge = pair<int, ll>;
using Graph = vector<vector<int>>;
using WeightedGraph = vector<vector<Edge>>;
const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

const int CASES = 3;

ll n, m, q;
vector<ll> a, b, c, d;
int buf[10];
ll ans = 0;
void rec(int i){
    if(i == n){
        ll tmp = 0;
        for(int j = 0; j < q; ++j){
            if(buf[a[j]] - buf[b[j]] + c[j] == 0) tmp += d[j];
        }
        ans = max(ans, tmp);
    }
    else{
        for(int j = buf[i-1]; j <= m; ++j){
            buf[i] = j;
            rec(i+1);
        }
    }
}

void solve() {
    cin >> n >> m >> q;
    a.resize(q);
    b.resize(q);
    c.resize(q);
    d.resize(q);
    for(int i = 0; i < q; ++i){
        cin >> a[i] >> b[i] >> c[i] >> d[i];
        --a[i]; --b[i];
    }
    buf[0] = 1;
    rec(1);
    cout << ans << endl;
}

int main() {
#ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt", "input5.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
#else

    solve();

#endif
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f(a, b) for (ll i = a; i <= b; i++)
#define pb push_back
#define pf push_front
#define mp make_pair
using namespace std;
#define N 200005
const ll INF = 1000000000000000001;
const ll MOD = 1000000000;

//vector< vector<ll> > g(N);
//vector< pair<ll, pair< ll, ll > > > g(N);
//ll vis[N] = {0}, par[N] = {0}, child[N] = {0},cnt = 0;


void solve(){
    ll n; cin >> n;
    ll ans =0;
    ll a[n] ;
    f(0, n-1) cin >> a[i];
    f(1, n-1){
        if(a[i] < a[i-1]) ans += a[i-1]-a[i], a[i] += (a[i-1]-a[i]);
    }
    cout << ans << "\n";
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("out.txt","w",stdout);
    #endif
    //ll t;cin >> t;for(ll index=1; index<=t; index++){
        //cout << "Case #" << index << ": " ;
        solve();
    //}
    return 0;
}

Measured memory_bytes: 5176
#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std;

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

const ll MAX_N = 1e5 + 5;
ll n, ans;
string s;

int main() {
	cin >> s;
	n = s.size();
	// if (n < 3)
	// 	exit(-1);

	ans = n;
	int rev = 0;
	for (ll i = 0; i < n; i++) {
		int tmp = (s[i] == '1');
		tmp ^= rev;

		if (ans <= i)
			continue;



		if (tmp == 0) {
			ans = max(i, n - i);
			if (i < n - i)
				rev ^= 1;
		}
	}

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
 
bool check(vector<int> vec,int cuts,int mid){
	for(int i=0;i<vec.size();i++){
		cuts -= vec[i]/mid;
		if(vec[i]%mid == 0)	cuts++;
	}
	if(cuts<0)	return false;
	return true;
}  
 
int main(){
	int n,k;
	cin>>n>>k;
	vector<int> arr(n);
	int mx = 0;
	for(int i=0;i<n;i++){
		cin>>arr[i];
		mx = max(mx,arr[i]);
	}
	int low = 1;
	int high = mx;
	int res = 0;
	while(low<=high){
		int mid = low + (high-low)/2;
		if(check(arr,k,mid)){
			res = mid;
			high = mid-1;
		}
		else
		{
			low = mid+1;
		}
	}
	cout<<res;
	return 0;
}




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

using ll = long long;
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using ull = unsigned long long;

#define NL '\n'
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x, y) scanf("%d%d",&x, &y)
#define sll(x, y) scanf("%lld%lld",&x, &y)

#define xx first
#define yy second
#define ins insert
#define mp make_pair
#define pb push_back
#define mdx ((l+r)>>1)
#define ldx ((idx<<1))
#define rdx ((idx<<1)|1)
#define sz(x) x.size()
#define pi 2.0*acos(0.0)
#define sqr(x)  ((x) * 1ll * (x))
#define all(x) (x).begin(),(x).end()
#define mem(a, b) memset(a, b, sizeof(a))
#define file_in(); freopen("input.txt", "r", stdin);
#define file_out(); freopen("output.txt", "w", stdout);
#define file_err(); freopen("serr.txt", "w", stderr);
#define rep(ii,aa,bb) for(ll (ii)=ll(aa);(ii)<(ll)(bb);++(ii))
#define _fastIO() ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define _runtime() cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n"

template<class T> T setbit(T n, T pos){n=n|(1<<pos); return n;}
template<class T> T checkbit(T n, T pos){n=n&(1<<pos); return n;}
template<class T> T gcd(T a, T b ) {return b<=0?a:gcd(b,a%b);}
template<class T> T lcm(T a, T b) {return ((a / gcd(a,b) ) * b);}





const int mxx = 1e5+9;
int n, a[mxx], b[mxx], c[mxx], dp[mxx][3];

int main(){
	_fastIO();
	cin >> n;
	rep(i, 0, n) cin >> a[i] >> b[i] >> c[i];
	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for(int i = 1; i < n; i++){
		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][0], dp[i-1][1]);
	}
	cout << max (dp[n-1][0], max(dp[n-1][1], dp[n-1][2])) << NL;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
#define dump(x)  cout << #x << " = " << (x) << endl;
 
typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;
 
void solve()
{
  int n;cin>>n;
  priority_queue<ll> a;
  for (int i=0; i<n*3; i++) {
    ll t;cin>>t;
    a.push(t);
  }
  ll ans=0;
  for (int i=0; i<n; i++) {
    a.pop();
    ans+=a.top();
    a.pop();
  }
  cout << ans << endl;
}
 
int main()
{
  solve();
  return 0;
}

Measured memory_bytes: 5872
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int A,B,C,D;
  cin>>A>>B>>C>>D;
  
  while(1){
    C-=B;
    if(C<=0){
      cout<<"Yes"<<endl;
      return 0;
      
    }
    A-=D;
    if(A<=0){
      cout<<"No"<<endl;
      return 0;
    }
  }
  
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
static const ll MOD = 1000000007;

int main(){
  vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << a[K-1] << endl;
}


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

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

    ll k;
    cin >> k;

    int res = 1;
    int now = 7;
    for(int i = 0; i < k; ++i){
        if(now % k == 0){
            cout << res << endl;
            return 0;
        }
        now %= k;
        now = now * 10 + 7;
        ++res;
    }

    cout << -1 << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define MOD (1000000007)
#define INF (1e9)
#define INFL (1e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    int n; cin >> n;
    int ans = 0;
    rep(i, n){
        int a; cin >> a;
        while(a!=1 && !(a&1)) {
            ans++;
            a >>= 1;
        }
    }
    pr(ans);
    return 0;}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;

  while(true){
    c -= b;
    if (c <= 0){
      cout << "Yes";
      break;
    }
    
    a -= d;
    if (a <= 0){
      cout << "No";
      break;
    }
    
  }
}



Measured memory_bytes: 3648
s = list(map(int, list(str(input()))))
k = int(input())

index =0
count =0
while index < len(s):
    spaceForChar = s[index]**50000
    newCount = count+ spaceForChar
    if count < k and k < newCount+1:
        print(s[index])
        break
    index+=1
    count = newCount

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

using namespace std;

const int max_n = 100111, inf = 1000111222;

int n, a[max_n];
pair<int, int> cnt[2][max_n];

int main() {

    scanf("%d", &n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
        ++cnt[i % 2][a[i]].first;
    }
    for (int i = 0; i < max_n; ++i) {
        cnt[0][i].second = i;
        cnt[1][i].second = i;
    }
    sort(cnt[0], cnt[0] + max_n);
    sort(cnt[1], cnt[1] + max_n);
    reverse(cnt[0], cnt[0] + max_n);
    reverse(cnt[1], cnt[1] + max_n);
    int ans = n;
    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            if (cnt[0][i].second != cnt[1][j].second) {
                ans = min(ans, n - cnt[0][i].first - cnt[1][j].first);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,k,q;
	cin>>n>>k>>q;
	vector<int> a(n);
	rep(i,n){
		cin>>a[i];
	}
	a.push_back(-1);
	int ans=INF;
	for(auto y:a){//最小値の決めうち
		if(y==-1) break;
		vector<multiset<int>> vec;
		multiset<int> st;
		rep(i,n+1){
			if(a[i]<y){
				if(st.size()){
					vec.push_back(st);
					st.clear();
				}
			}else{
				st.insert(a[i]);
			}
		}
		vector<int> now;
		for(auto &st:vec){
			while(st.size()>=k){
				auto itr=st.begin();
				now.push_back(*itr);
				st.erase(itr);
			}
		}
		if(now.size()<q) continue;
		sort(begin(now),end(now));
		chmin(ans,now[q-1]-y);
	}
	cout<<ans<<endl;
}

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

const int maxn = 1e5 + 5;

int dp [maxn], a [maxn];

int main () {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  dp[0] = 0;
  dp[1] = dp[0] + abs (a[1] - a[0]);
  for (int i = 2; i < n; i++) {
    dp[i] = min (dp[i - 1] + abs (a[i] - a[i - 1]), dp[i - 2] + abs (a[i] - a[i - 2]));
  }
  cout << dp[n - 1] << '\n';
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main()
{
  int N,T,A;
  int H[1001];
  int i,j;
  double p,q;
  scanf("%d",&N);
  scanf("%d",&T);
  scanf("%d",&A);
  scanf("%d",&H[0]);
  p=fabs(A-T+0.006*H[0]);
  j=1;
  for(i=1;i<N;i++){
    scanf("%d",&H[i]);
    q=p;
    p=fabs(A-T+0.006*H[i]);
    if(q<=p) p=q;
    if(p<q) j=i+1;
  }
  printf("%d",j);
  return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  priority_queue<P, vector<P>, greater<P>> q;
  ll N, M;
  cin >> N >> M;
  rep(i, N){
    ll a, b;
    cin >> a >> b;
    q.push({a, b});
  }
  ll ans = 0;
  ll cnt = 0;
  while(cnt<M){
    P p = q.top();
    q.pop();
    ll a = p.first;
    ll b = p.second;
    if(cnt + b>M){
      ans += (M-cnt) * a;
      cnt = M;
    }else{
      ans += a*b;
      cnt += b;
    }
    //cout << a << " " << b << " " << ans << " "<< cnt<< endl;
  }
  
  cout << ans;
  
  return 0;
}


Measured memory_bytes: 2548
#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 main(){
	long long n,x,ans=0;
	cin>>n>>x;
	long long a[n];
	rep(i,n)cin>>a[i];
	rep(i,n-1){
		if(a[i]+a[i+1]>x){
			ans+=(a[i]+a[i+1]-x);
			if(a[i+1]>a[i]+a[i+1]-x)a[i+1]-=(a[i]+a[i+1]-x);
			else if(a[i]>a[i]+a[i+1]-x)a[i]-=(a[i]+a[i+1]-x);
			else{
				int res=a[i]-x;
				a[i+1]=0;
				a[i]-=res;
			}
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
A = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(A[K-1])

Measured memory_bytes: 3060
#include <iostream>

int main()
{
    int a, b;
    std::cin >> a >> b;
    if(a < b) {
        std::cout << "a < b" << std::endl;
    } else if(a > b) {
        std::cout << "a > b" << std::endl;
    } else {
        std::cout << "a == b" << std::endl;
    }
    return 0;
}

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

int main(){
  ll n,i,d=0;
  cin >> n;
  vector<ll> a(n),minus(n,0);
  for(i=0;i<n;i++){
    cin >> a.at(i);
    if(i==0){
      d += abs(a.at(i));
    }else{
      d += abs(a.at(i)-a.at(i-1));
    }
  }
  d += abs(a.at(n-1));
  
  for(i=0;i<n;i++){
    if(i==0){
      if(a.at(0)*(a.at(1)-a.at(0))>=0){
        cout << d << endl;
      }else{
        cout << d-2*min(abs(a.at(0)),abs(a.at(1)-a.at(0))) << endl;
      }
    }else if(i==n-1){
      if((a.at(n-1)-a.at(n-2))*(-a.at(n-1))>=0){
        cout << d << endl;
      }else{
        cout << d-2*min(abs(a.at(n-1)),abs(a.at(n-1)-a.at(n-2))) << endl;
      }
    }else{
      if((a.at(i)-a.at(i-1))*(a.at(i+1)-a.at(i))>=0){
        cout << d << endl;
      }else{
        cout << d-2*min(abs(a.at(i)-a.at(i-1)),abs(a.at(i+1)-a.at(i))) << endl;
      }
    }
  }
}

Measured memory_bytes: 4852
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    import math
    k=int(input())
    answer=0
    l=list(range(1,k+1))
    for x in range(1,k+1):
        for y in range(1,k+1):
            for z in range(1,k+1):
                answer+=math.gcd(math.gcd(x,y),z)
    print(answer)
resolve()

Measured memory_bytes: 67924
//  ©   ___MRX___

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

#define ll long long int

int main()
{
    int n, i, j;
    string s;
    bool checker = true;

    cin >> n >> s;

    if(n % 2) {
        cout << "No" << '\n';
        return 0;
    }

    for(i = 0, j = n / 2; i < n / 2; i++, j++) {
        if(s[i] != s[j]) {
            checker = false;
            break;
        }
    }

    checker ? cout << "Yes" << '\n' : cout << "No" << '\n';

    return 0;
}


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

int main() {
string s;
int count=0;
cin>>s;
int left=0;
int right=s.size()-1;
while(left<right){
    if(s[left]!=s[right]){
        count++;
    }
    left++;
    right--;
}
cout<<count<<endl;

return 0;
}

Measured memory_bytes: 256
c1 = STDIN.readline.strip.split('')
c2 = STDIN.readline.strip.split('')
def rotate?(c1, c2)
  c1[0] == c2[2] and
    c1[1] == c2[1] and
    c1[2] == c2[0]
end
puts rotate?(c1, c2) ? 'YES' : 'NO'


Measured memory_bytes: 1788
def upper_pow2(n):
    ret = 1
    while n > 0:
        ret <<= 1
        n >>= 1
    return ret


n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
d = dict()
for x in a:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1
ans = 0
for x in a:
    if d[x] <= 0:
        continue
    if x & (x - 1):
        t = upper_pow2(x) - x
        if t in d and d[t] > 0:
            d[x] -= 1
            d[t] -= 1
            ans += 1
    else:
        if d[x] >= 2:
            d[x] -= 2
            ans += 1
print(ans)


Measured memory_bytes: 34736
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long a = sc.nextLong();
		long b = sc.nextLong();
		long x = sc.nextLong();
		sc.close();
		long ans = b / x - a / x;
		if(a % x == 0) {
			ans++;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23764
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func main() {
	sc.Split(bufio.ScanWords)

	s := make([]int, 2)
	s[0], s[1] = nextInt(), nextInt()
	sort.Ints(s)

	for i := s[0] + 1; i < s[1]; i++ {
		if abs(i-s[0]) == abs(i-s[1]) {
			fmt.Println(i)
			return
		}
	}

	fmt.Println("IMPOSSIBLE")
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int m = sc.NextInt();

        UnionFind uf = new UnionFind(n);

        for (int i = 0; i < m; i++)
        {
            int a = sc.NextInt() - 1;
            int b = sc.NextInt() - 1;
            uf.Unite(a, b);
        }

        long answer = 0;

        for (int i = 0; i < n; i++)
        {
            answer = Math.Max(answer, uf.GetSize(i));
        }

        Console.WriteLine(answer);
    }

    // 木の併合
    class UnionFind
    {
        private readonly int[] parents;
        private readonly int[] sizes;

        public UnionFind(int count)
        {
            parents = new int[count + 1];
            sizes = new int[count + 1];
            for (int i = 0; i < count + 1; i++)
            {
                parents[i] = i;
                sizes[i] = 1;
            }
        }

        // TreeのNode数の取得
        public int GetSize(int branch)
        {
            return sizes[GetRoot(branch)];
        }

        // Treeの併合、Node数の合算
        public void Unite(int x, int y)
        {
            int rootX = GetRoot(x);
            int rootY = GetRoot(y);
            if (rootX == rootY) return;
            sizes[rootX] += sizes[rootY];
            parents[rootY] = rootX;
        }

        // 同じTreeに含まれるか
        public bool IsSameRoot(int x, int y)
        {
            return GetRoot(x) == GetRoot(y);
        }

        // Rootの取得
        public int GetRoot(int n)
        {
            if (parents[n] == n)
            {
                return n;
            }
            else
            {
                return parents[n] = GetRoot(parents[n]);
            }
        }
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


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

using namespace std;

int main()
{
    long long n, m;

    cin >> n >> m;

    if(n==1 and m ==1)
        cout << 1 << endl;
    else if(n==1 or m==1)
    {
        if(n == 1)
            cout << m - 2 << endl;
        else
            cout << n - 2 << endl;
    }

    else
        cout << (n - 2) * (m - 2) << endl;
}

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

using namespace std;

int calc(const std::vector<int>& as, int k) {
  std::vector<int> counts;
  counts.reserve(200000);

  int prev_a = 0;
  int count = 0;
  for (int i = 0; i < as.size(); i++) {
    auto const a = as[i];
    if (a == prev_a) {
      count++;
      continue;
    }
    counts.push_back(count);
    count = 1;
    prev_a = a;
  }
  if (count) {
    counts.push_back(count);
  }

  if (counts.size() <= k) {
    return 0;
  }

  std::sort(counts.rbegin(), counts.rend());
  int ret = 0;
  for (int i = k; i < counts.size(); i++) {
    ret += counts[i];
  }
  return ret;
}

int main() {
  int n, k;
  std::cin >> n >> k;
  std::vector<int> as(n);
  for (int i = 0; i < n; i++) {
    std::cin >> as[i];
  }
  std::sort(as.begin(), as.end());
  std::cout << calc(as, k) << std::endl;
  return 0;
}


Measured memory_bytes: 1792
import sys
import itertools
input = sys.stdin.readline


def read_values():
    return map(int, input().split())


def read_list():
    return list(read_values())


def read_lists(N):
    return [read_list() for n in range(N)]


def main():
    N = int(input())
    res = 0
    for r in range(int(N ** 0.5), 0, -1):
        if N % r == 0:
            m = N // r - 1
            if r >= m:
                continue
            res += m
    print(res)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
	ll n,k,s,ans;
	cin>>n>>k>>s;
	for(int i=1e9;i;i--){
		if(i!=s){
			ans=i;
			break;
		}
	}
	if(n==k){
		for(int i=1;i<=n;i++)
			printf("%lld%c",s,i==n?'\n':' ');
	}else{
		for(int i=1;i<=k;i++)
			printf("%lld ",s);
		for(int i=k+1;i<=n;i++)
			printf("%lld%c",ans,i==n?'\n':' ');
	}
	return 0;
}

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

#define f(i, a, b, c) for(int i = a ; i < b ; i += c)
#define fr(i, a, b, c) for(int i = a ; i >= b ; i -= c)
#define fit(it, v) for(auto it = v.begin() ; it != v.end() ; ++it)
#define frit(it, v) for(auto it = v.rbegin() ; it != v.rend() ; ++it)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define eb emplace_back
#define pb push_back
#define lli long long int
#define modn 1000000007
#define NL '\n'

using namespace std;

typedef vector< int > vi;
typedef vector< char > vc;
typedef vector< bool > vb;
typedef vector< string > vs;
typedef vector< lli > vli;
typedef vector< vector< char > > vvc;
typedef vector< vector< int > > vvi;
typedef pair< int, int > ii;
typedef vector< ii > vii;
typedef pair< lli, int> pli;
typedef pair< lli, lli> pll;
typedef set< int > si;
typedef set< ii > sii;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	#ifdef LOCAL_TEST
		clock_t z = clock();
    	ifstream h("in");
	    ofstream g("out");
	#else
	    #define h cin
	    #define g cout
	#endif // LOCAL_TEST
	
	unordered_set< int > s;
	int n;
	h >> n;
	f(i, 0, n, 1){
		int x;
		h >> x;
		s.insert(x);
	}
	g << (s.size() == n ? "YES" : "NO");
	
	#ifdef LOCAL_TEST
		cerr << "Time taken is: " << double(clock() - z) / CLOCKS_PER_SEC << NL;
		h.close();
		g.close();
	#endif // LOCAL_TEST
}



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

def main():
    N = int(input())
    S = input()
    for key in ['SS', 'SW', 'WS', 'WW']:
        animals = list(key)
        for i in range(N + 1):
            if i < 1:
                continue
            S_i = S[i] if i < N else S[0]
            if animals[i] == 'S':
                if S_i == 'o':
                    animals += animals[-2]
                else:
                    animals += 'S' if animals[-2] == 'W' else 'W'
            else:
                if S_i == 'x':
                    animals += animals[-2]
                else:
                    animals += 'S' if animals[-2] == 'W' else 'W'
        if animals[0] == animals[-2] and animals[1] == animals[-1]:
            print(''.join(animals[:-2]))
            exit(0)
    print(-1)


if __name__ == '__main__':
    main()



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

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

    static class C {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            long n = Long.parseLong(in.next());
            long ans = -1;
            long tmp = -1;

            for (int i = 0; i < 5; i++) {
                long x = Long.parseLong(in.next());
                if (n % x == 0) {
                    tmp = n / x;
                } else {
                    tmp = n / x + 1;
                }
                ans = Math.max(ans, tmp);
            }

            // 出力
            out.println(ans + 4);

        }

    }
}



Measured memory_bytes: 35860
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int H, W;
    while(1){
        scanf("%d %d", &H, &W);
        if(H == 0 && W == 0) break;
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h> //C++の機能を「全て」読み込むための命令
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<(x)<<endl
using namespace std;
using ll = long long;
using P = pair<int,int>;
const ll inf=1e18;
const int N=2e5+10;
ll factorial(ll x){//階乗の計算
    if(x==0||x==1) return 1;
    return x*factorial(x-1);
}
ll gcd(ll a ,ll b){return b ? gcd(b,a%b) : a;}//最大公約数
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}//最小公倍数
int num_digit(ll a){//桁数を求める
    int num_dig = 0;
    while(a!=0){
        a /= 10;
        ++num_dig;
    }
    return num_dig;
}
vector<ll> digit(ll a){//桁の数字を求める
    vector<ll> dig(num_digit(a));
    for(int i=num_digit(a)-1; i>=0; --i){
        dig[i] = a%10;
        a /= 10; 
    }
    return dig;
}

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> a(m),b(m);
    rep(i,m) cin >> a[i] >> b[i];

    //バケット法
    vector<int> bucket(n);
    rep(i,m){
        ++bucket[a[i]-1];
        ++bucket[b[i]-1];
    }
    rep(i,n) cout(bucket[i]);

    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<list>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<numeric>
#include<cmath>
#include<cstdio>
#include<cstring>
using namespace std;
int a[3][4001];
int f(int p,int q){
  int i;
  if(p==1)
    return 0<=q&&q<=1000;
  if(a[p-2][q]>=0)
    return a[p-2][q];
  int sm=0;
  for(i=0;i<=1000;++i){
    if(q-i>=0)
      sm+=f(p-1,q-i);
  }
  return a[p-2][q]=sm;
}
int main(){
  memset(a,-1,sizeof(a));
  int n;
  while(cin>>n)
    cout<<f(4,n)<<endl;
  return 0;
}

Measured memory_bytes: 1220
public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		java.util.Scanner sc = new java.util.Scanner(System.in);

		int n = sc.nextInt();
		sc.nextLine();

		boolean[] Scards = new boolean[13];
		boolean[] Hcards = new boolean[13];
		boolean[] Ccards = new boolean[13];
		boolean[] Dcards = new boolean[13];

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

			String[] data = sc.nextLine().split(" ");
			int r = Integer.parseInt(data[1]);

			switch (data[0]) {
			case "S":
				Scards[r-1] = true;
				break;
			case "H":
				Hcards[r-1] = true;
				break;
			case "C":
				Ccards[r-1] = true;
				break;
			case "D":
				Dcards[r-1] = true;
				break;
			}

		}

		for (int i = 0; i < 13; i++) {
			if (Scards[i] == false) {
				System.out.println( "S " + (i+1) );
			}
		}

		for (int i = 0; i < 13; i++) {
			if (Hcards[i] == false) {
				System.out.println("H " + (i+1));
			}
		}

		for (int i = 0; i < 13; i++) {
			if (Ccards[i] == false) {
				System.out.println("C " + (i+1));
			}
		}

		for (int i = 0; i < 13; i++) {
			if (Dcards[i] == false) {
				System.out.println("D " + (i+1));
			}
		}
	}

}

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

void textIO()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
}

void fastIO()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
}

long long M = 1e9+7;

long long bigMod(long long n, long long p){
    if(p == 0)
        return 1;
    if((p&1) == 0){
        long long ret = bigMod(n, p/2)%M;
        return (ret*ret)%M;
    }
    return (n%M*bigMod(n, p-1)%M)%M;
}

long long mmInv(long long x){
    return bigMod(x, M-2);
}


long long combination(long long n, long long r){
    if(r < n-r){
        r = n-r;
    }
    long long ans = 1;
    for(long long i=n;i>r;i--){
        ans=(ans*i)%M;
        ans=(ans*mmInv(n+1-i))%M;
    }
    return ans;
}



int main()
{
    //textIO();
    fastIO();

    long long n, a, b;
    cin >> n >> a >> b;
    long long tc = (bigMod(2, n)-1)%M;
    long long ans = (tc - combination(n, a) - combination(n, b))%M;
    if(ans < 0){
        cout << ans+M << '\n';
    }
    else{
        cout << ans << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()

int main() {
  int n;
  cin >> n;
  REP(casen,n) {
    int a;
    cin >> a;
    cout << "Case " << casen+1 << ":" << endl;
    REP(k,10) {
      a*=a;
      stringstream ss;
      ss << a;
      string s = ss.str();
      int le = s.length();
      REP(i,8-le) {
        s = "0" + s;
      }
      a = atoi(s.substr(2,4).c_str());
      cout << a << endl;
    }
  }
}

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

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

    int ccnt = 0;
    int accnt = 0;
    int aacnt = 0;
    bool hia = false;
    bool lc = true;
    for(int i=0; i<int(S.size()); i++) {
        if(i==0 && S[i]=='A') hia = true;
        if(S[i] == 'A') aacnt++;
        if(i>=2 && i<=int(S.size())-2 && S[i]=='C') ccnt++;
        if(S[i] == 'C') accnt++;
        if(!(S[i]>='a' && S[i]<='z') && S[i]!='A' && S[i]!='C') lc = false;       
    }

    if(hia && aacnt==1 && ccnt==1 && ccnt==accnt && lc) cout << "AC" << endl;
    else cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())

A = map(int, input().split())

Alice = 0
Bob = 0
count=0
B = []
for i in A:
    B.append(i)

for i in range(len(B)):
    if(count==0):
        Alice+=max(B)
        count=1
        index = B.index(max(B))
        B[index] = 0
    else:
        Bob+=max(B)
        count=0
        index = B.index(max(B))
        B[index] = 0

print(Alice - Bob)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define vite ios_base::sync_with_stdio(false); cin.tie(NULL);
#define tst lli T; cin>>T; while(T--)
#define mod 1000000007
#define MAX 1e9
#define MIN -1e9
#define lli long long int
#define vt vector
#define pb push_back
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    lli x,k,d;
    cin>>x>>k>>d;
    x=abs(x);
    if(x>d)
    {
        lli z=x/d;
        if(z<k)
        {
            x-=z*d;
            k-=z;
            if(k%2==1) cout<<abs(x-d);
            else cout<<abs(x);
        }
        else cout<<abs(x-k*d);
    }
    else
    {
        if(d>2*x)
        {
            if(k%2==1) cout<<abs(x-d);
            else cout<<abs(x);
        }
        else 
        {
            if(k%2==1) cout<<abs(x-d);
            else cout<<abs(x);
        }
    }
    
    cout<< endl;
    // cout<< fixed << 1.0 * clock() / CLOCKS_PER_SEC << setprecision(10);
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define ll long long
#define pii pair<int,int> 
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
string s;
int main(){
    cin>>s;
    string t;
    for(int i=1;i<=5;i++){
        t+="hi";
        if(s==t){
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256