akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <sstream>
using namespace std;
 
int main(){
 int h;	//行数を格納する変数
 int w;	//列を格納する変数
  
 int count=0; //爆弾の個数を格納する変数
  
 int i,j; //for文で使う変数
 vector<string> s(50);	//マス目を格納する変数
  
 cin>>h>>w;	//行と列を入力する
  
 for(i=0;i<h;i++){
	cin>>s.at(i);	//マス目を入力する
	}
  for(i=0;i<h;i++){
  	for(j=0;j<w;j++){
      if(s.at(i).at(j)=='.'){// i行目のj文字目が爆弾マスでない時

        if(i-1>=0){
    	    if(s.at(i-1).at(j)=='#'){//上に爆弾マスがあるとき
                count++;
            }
        }

        if(i+1<h){
            if(s.at(i+1).at(j)=='#'){//下に爆弾マスがあるとき
        	    count++;
            }
        }

        if(j-1>=0){
            if(s.at(i).at(j-1)=='#'){//左に爆弾マスがあるとき
        	    count++;
            }   
        }

        if(j+1<w){
            if(s.at(i).at(j+1)=='#'){//右に爆弾マスがあるとき
        	    count++;
            }
        }

        if(i-1>=0 && j-1>=0){
            if(s.at(i-1).at(j-1)=='#'){//左上に爆弾マスがあるとき
        	    count++;
            }
        }

        if(i-1>=0 && j+1<w){
            if(s.at(i-1).at(j+1)=='#'){//右上に爆弾マスがあるとき
        	    count++;
            }
        }

        if(i+1<h && j-1>=0){
            if(s.at(i+1).at(j-1)=='#'){//左下に爆弾マスがあるとき
        	    count++;
            }
        }
        if(i+1<h && j+1<w){
            if(s.at(i+1).at(j+1)=='#'){//右下に爆弾マスがあるとき
        	    count++;
            }
        }
        
       //爆弾の個数を代入
        string str = to_string( count );
       	s.at(i).at(j)=str.at(0);
        count=0;
      }
    }
  }
  
  for(i=0;i<h;i++){
	cout<<s.at(i)<<endl;	//マス目を出力する
	}
}




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

int main() {
  string s, t;
  cin >> s >> t;
  int n = s.size(), m = t.size();
  int ans = 0, cnt = 0;
  rep(i, n - m + 1) {
    rep(j, m) {
      if (s[i + j] == t[j]) cnt++;
    }
    ans = max(ans, cnt);
    cnt = 0;
  }
  cout << m - ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
const int INF = 1e9;
const int MOD = 1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
 
int main() {
  int n,m,q;
  cin >> n >> m >> q;
  vector<vector<int>> train(n+1,vector<int>(n+1,0));
  rep(i,m){
    int l,r;
    cin >> l >> r;
    train.at(l).at(r) ++;
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      train.at(i).at(j) += train.at(i).at(j-1);
    }
  }
  for(int i=0;i<=n;i++){
    for(int j=1;j<=n;j++){
      train.at(j).at(i) += train.at(j-1).at(i);
    }
  }
  rep(i,q){
    int l,r;
    cin >> l >> r;
    cout << train.at(r).at(r)-train.at(l-1).at(r)-train.at(r).at(l-1)+train.at(l-1).at(l-1) <<endl;
  }
  //rep(i,n+1)rep(j,n+1) cout << train.at(i).at(j) << endl;
  return 0;
}




Measured memory_bytes: 1920
N,Y = map(int,input().split())

for x in range(N+1):
  for y in range(N-x+1):
    z = N-x-y
    money = x*10000+y*5000+z*1000
    if money==Y:
      print(x,y,z)
      exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include<fstream>
#include<set>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define out(str) cout << str << endl
#define ALL(a) (a).begin(),(a).end()
#define INF (1<<29)

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

ll H,W,x,y;

int main(){
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    cin>>W>>H>>x>>y;
    printf("%f ",((double)H*(double)W)/2.0);
    if(H%2==0&&W%2==0){
        if(H/2==y&&W/2==x){
            printf("1");
        }
        else printf("0");
    }
    else printf("0");
    cout<<endl;

    
    
}


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;

int main() 
{
    int n;
    cin >> n;
    vector<pair<int, int>> a;
    rep(i,n) {
        int order;
        cin >> order;
        a.push_back(make_pair(order, i));
    }
    sort(a.begin(), a.end());

    rep(i,n) {
        printf("%d%c", a[i].second + 1, i==n-1? '\n' : ' ');
    }
    return 0;
}


Measured memory_bytes: 1780
#include <iostream>
#include <vector>
using namespace std;
int main(){
int H,W,N,i,k,x;
cin >> H >> W >> N ;
vector <int> a(N);
for(i=0;i<N;i++){
cin >> a[i];
}
int c[H*W];
	for(k=0;k<a[0];k++){
	c[k] = 1;
	}
	x = 0;
for(i=1;i<N;i++){
	x +=a[i-1];
for(k=0;k<a[i];k++){
	c[x+k] = i+1;
}
}
	i=0;
	while(i!=H*W){
	cout << c[i] <<" ";
		i +=1;
		if(i%W==0 && i!=H*W){
			cout << endl;
			for(k=0;k<W;k++){
				cout << c[i+W-k-1] << " ";
			}
			cout << endl;
		i += W;}
	}
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair

#define sz(a) (int)(a).size()
#define all(a) (a).begin(), (a).end()

#define ll long long
#define ld long double

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    if (s[1] == 'R') s[1] = 'B'; else s[1] = 'R';
    cout << s;
    return 0;
}


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

using namespace std;
typedef long long ll;

const int N = 100007;

bool f[N];
int a[1007];
int main() {
    int n, k; cin >> n >> k;

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

    for(int i = 1; i <= k; ++i) {
        for(int j = 0; j < n; ++j) {
            if(i - a[j] >= 0) f[i] = f[i] or (!f[i - a[j]]);
        }
    }

    cout << (f[k]? "First" : "Second") << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
#define int long long int
#define double long double
using namespace std;
#define INT_MAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

int num = 0;
int check(int n, int i,int t,int f,int s){
    if(i > n) return 0;
    if(t && f && s) num++;
    check(n,10 * i + 3,1,f,s);
    check(n,10 * i + 5,t,1,s);
    check(n,10 * i + 7,t,f,1);
}

signed main()
{
int n;
std::cin >> n;
check(n,3,1,0,0);
check(n,5,0,1,0);
check(n,7,0,0,1);

std::cout << num << std::endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define scn(var)         cin >> var;
#define pYes()           prt("Yes")
#define pNo()            prt("No")
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(var)      rep(i,var.size()){cout << var[i] << " ";} cout << "\n"
//----------------------------------------------------------------

int main(void) {
  int n;
  cin >> n;
  arr(a,n);

  int amax=1000010;
  vecll inv(amax);

  inv[1]=1;
  REP(i,2,amax){
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
  }

  vecll soinsu(amax,0);
  rep(i,n){
    ll tmp=0;
    ll a_copy=a[i];
    for(int j=2; j*j<=a_copy; j++){
      if(a_copy%j!=0) continue;
      tmp=0;
      while(a_copy%j==0){
        a_copy/=j;
        tmp++;
      }
      chmax(soinsu[j], tmp);
    }
    soinsu[a_copy] = max(soinsu[a_copy],(ll) 1);
  }

  ll ans=0;
  ll l=1;
  REP(i,2,amax){
    while(soinsu[i]){
      l*=i;
      l%=MOD;
      soinsu[i]--;
    }
  }

  rep(i,n){
    ans+=l*inv[a[i]];
    ans%=MOD;
  }

  prt(ans);

}


Measured memory_bytes: 15872
#include <stdio.h>

int N;
int P[222222];

char mikisinn[222222];

int main(void) {
	int i;
	int asumisu = 0, mizuhasu = 0;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 0; i < N; i++) {
		if (scanf("%d", &P[i]) != 1) return 1;
	}
	for (i = 0; i < N; i++) {
		mikisinn[P[i]] = (mikisinn[P[i] - 1] ? 1 : 2);
	}
	for (i = 1; i <= N + 1; i++) {
		if (mikisinn[i] == 1) {
			mizuhasu++;
		} else {
			if (asumisu < mizuhasu) asumisu = mizuhasu;
			mizuhasu = 1;
		}
	}
	printf("%d\n", N - asumisu);
	return 0;
}

/*

「コア」(連続する整数列)を選び、
コアより小さい整数をコアの前に、
コアより大きい整数をコアの後ろに、
それぞれ順に飛ばせばよい。

「コア」は一番長いものを選びたい。

*/


Measured memory_bytes: 2688
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,i,j,sum,ma=0;
  cin>>a>>b;
  sum=a;
  for(i=0;;i++){
	sum=sum/b;
    ma++;
    if(sum==0){
      break;
    }
  }
  cout<<ma<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<functional>
#include<map>
using namespace std;

int main() {
	int a; int p = 0;
	while (cin >> a, a) {
		if (p)cout << endl;
		int b, c, d, e;
		scanf("%d%d%d%d", &b, &c, &d, &e);
		int sum = b + c + d + e, MIN = 1<<29;
		for (int f = 0; f <= b; f++) {
			for (int g = 0; g <= c; g++) {
				for (int h = 0; h <= d; h++) {
					for (int i = 0; i <= e; i++) {
						if (f * 10 + g * 50 + h * 100 + i * 500 >= a) {
							int k =(f * 10 + g * 50 + h * 100 + i * 500)-a;
							int s = sum - f - g - h - i;
							s += k / 500;
							k %= 500;
							s += k / 100;
							k %= 100;
							s += k / 50;
							k %= 50;
							s += k / 10;
							MIN = min(MIN, s);
						}
					}
				}
			}
		}for (int f = 0; f <= b; f++) {
			for (int g = 0; g <= c; g++) {
				for (int h = 0; h <= d; h++) {
					for (int i = 0; i <= e; i++) {
						if (f * 10 + g * 50 + h * 100 + i * 500 >= a) {
							int k = (f * 10 + g * 50 + h * 100 + i * 500) - a;
							int s = sum - f - g - h - i;
							s += k / 500;
							k %= 500;
							s += k / 100;
							k %= 100;
							s += k / 50;
							k %= 50;
							s += k / 10;
							if (s == MIN) {
								if (f)cout << 10 << " " << f << endl;
								if(g)cout << 50 << " " << g << endl;
								if(h)cout << 100 << " " << h << endl;
								if(i)cout << 500 << " " << i << endl;
								goto l;
							}
						}
					}
				}
			}
		}
	l:;
		p++;
	}
}

Measured memory_bytes: 3168
//#include<iostream>
//#include<algorithm>
//#include<string>
//#include <cmath>
//#include <vector>
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define REP(x,n) for(int x=0;x<n;x++)

//vector//
#define vei vector<int> 
#define velli vector<long long int> 
#define pb(x) push_back(x) // 末尾にxを加える
#define pb2 pop_back() // 末尾削除
#define all(x) (x).begin(),(x).end() //イテレーター
#define be(x) (x).begin()
//auto  auto begin = v.begin()とか

typedef pair<int,int> P;  //q(p.first,p.second)

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

    // 降べきの順
    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    ll int ans = a[0];
    for(int i=1; i<n-1; i++){
        if(i % 2 == 0) ans += a[i/2];
        else ans += a[i/2 + 1];
    }

    cout << ans;

}

Measured memory_bytes: 4800
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string a,b,c;
  cin >> a >> b;
  int x,y;
  cin >> x >> y;
  cin >> c;
  if(a==c)
    x--;
  else if (b==c)
    y--;
  cout << x << " " << y;
}

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

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

long long MOD = 1000000000 + 7;
double eps = 0.0000001;

pdd getCenter(double a, double b, double c, double d, double e, double f){

  double px,py;
  pdd ret;

  py = (e-a) * (a*a + b*b - c*c - d*d);
  py -= (c-a) * (a*a + b*b - e*e - f*f);
  py /= 2 * (e-a)*(b-d) - 2 * (c-a) * (b-f);

  if(c!=a){
    px = 2*(b-d)*py - a*a - b*b + c*c + d*d;
    px /= 2 * (c-a);
  } else { 
    px = 2*(b-f) * py - a*a - b*b + e*e + f*f;
    px /= 2 * (e-a);
  }

  ret = make_pair(px,py);

  return ret;
}

int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<double> x(N);
  vector<double> y(N);

  for(int i = 0; i < N; i++){
    cin >> x[i] >> y[i];
  }

  vector<pdd> v;
  for(int i = 0; i < N-1; i++){
    for(int j = i+1; j < N; j++){
      v.push_back(make_pair( (x[i]+x[j])/2, (y[i]+y[j])/2 ));
    }
  }
  if(N >= 3){
    for(int i = 0; i < N-2; i++){
      for(int j = i+1; j < N-1; j++){
        for(int k = j+1; k < N; k++){
          // ３点が直線状にあるかどうか判定
          double tmpc = x[j] - x[i];
          double tmpd = y[j] - y[i];
          double tmpe = x[k] - x[i];
          double tmpf = y[k] - y[i];
          if(tmpc * tmpf - tmpd * tmpe == 0){
            continue;
          } else {
            pdd ret = getCenter(x[i], y[i], x[j], y[j], x[k], y[k]);
            v.push_back(ret);
            // cerr << ret.first << " " << ret.second << endl;
          }
        }
      }
    }
  }

  // 判定
  double ans = 10000;

  for(auto w: v){
    double xtmp = w.first;
    double ytmp = w.second;

    // 全点からの距離の最大値...の最小値
    double tmp = 0;
    for(int i = 0; i < N; i++){
      double r = 0;
      r += (x[i] - xtmp) * (x[i] - xtmp);
      r += (y[i] - ytmp) * (y[i] - ytmp);
      r = pow(r, 0.5);
      tmp = max(tmp, r);
    }

    ans = min(ans, tmp);
  }
  cout << ans << endl;

}



Measured memory_bytes: 4496
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(int argc, char *argv[])
{
    char s[1200];
    
    for (;;) {
        scanf("%s\n", s);
        if (s[0] == '0')
            break;
        char *p = s;
        int ans = 0;
        do {
            ans += *p - '0';        
        } while (*(++p));
        printf("%d\n", ans);
    }

    return 0;
}



Measured memory_bytes: 2092
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REP2(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define REVE(x) reverse(x.begin(), x.end())
#define all(x) (x).begin(), (x).end()
struct initon
{
    initon()
    {
        cin.tie(0);
        ios::sync_with_stdio(false);
    };
};
signed main() {
  cout << fixed << setprecision(20);
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n+1),b(m+1);
  a[0]=0;
  b[0]=0;
  REP2(i, n){
  int aa;
    cin >>aa;
    a[i]=a[i-1]+aa;
  }REP2(i, m){
  int bb;
    cin >>bb;
    b[i]=b[i-1]+bb;
  }
  int aans=0,bans=0;
  while (aans< n && a[aans + 1] <=k){
    aans++;
  }
  while (bans < m &&(a[aans] + b[bans+1])<=k){
    bans++;
  }
  int ans=aans+bans;
  while(0 <= --aans){
    while(bans < m&&a[aans]+b[bans+1]<=k){
      bans++;
    
    }
    ans=max(ans,aans+bans);
  }
   cout <<ans;
  }


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

def dfs(s):
    if int(s) > N:
        return 0
    #sが7,5,3をそれぞれ一つ以上含んでいる場合、+1、 else 0
    ret = 1 if all(s.count(c) > 0 for c in '753') else 0
    #sに7,5,3のいずれかを付け足す
    for c in '753':
        ret += dfs(s + c)
    return ret

print(dfs('0'))

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

using namespace std;
#define int int64_t
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define gsort(x) sort((x).begin(), (x).end(), greater<int>())
#define rv(s) reverse((s).begin(), (s).end())
#define pii pair<int, int>
#define re(s) reverse((s).begin(), (s).end())
#define setout(n, x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10);
const long long mod = 1e9 + 7;

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

   int n, m, a, b;
   int cnt, ans = 0;
   cin >> n >> m;
   cnt = m;
   vector<pair<int, int>> x(n);

   rep(i, n)
   {
      cin >> a >> b;
      x[i] = make_pair(a, b);
   }

   sort(all(x));

   rep(i, n)
   {
      if (i == 0 && x[i].second >= m)
      {
         cout << x[i].first * m << '\n';
         return 0;
      }
      else
      {
         if (x[i].second >= cnt)
         {
            cout << ans + (x[i].first * cnt) << '\n';
            return 0;
         }
         else
         {
            cnt -= x[i].second;
            ans += x[i].first * x[i].second;
         }
      }
   }
}

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

int dp[22][2][2][2][2];

bool canUse(int n) {
    if(n == 3 || n == 5 || n == 7) return true;
    return false;
}

int main() {
    string S; cin >> S;
    int N = S.size();
    dp[0][0][0][0][0] = 1;
    rep(i, N) rep(less, 2) rep(nana, 2) rep(go, 2) rep(san, 2)  {
        int x = less ? 9 : S[i] - '0';
        rep(d, x + 1) {
            if(nana + go + san + d == 0 || canUse(d)) {
                dp[i + 1][less || d < x][nana || d == 7][go || d == 5][san || d == 3] += dp[i][less][nana][go][san];
            }
        }
    }
    int ans = dp[N][0][1][1][1] + dp[N][1][1][1][1];
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 256
n, k, q = map(int, input().split())
ll = [0 for i in range(n+1)]
for _ in range(q):
    a = int(input())
    ll[a] += 1

for l in ll[1:]:
    if l+k-q <= 0:
        print("No")
    else:
        print("Yes")


Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
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; }
int ctoi(char c){return c-'0';}



int n,A,B,C;
int dfs(int cur,int a,int b,int c,vector<int> &l){
  if(cur == n){
    if(min(a,min(b,c)) == 0)return INF;
    return abs(a-A) + abs(b-B) + abs(c-C)-30;
  }
  int res0 = dfs(cur+1,a,b,c,l);
  int res1 = dfs(cur+1,a+l[cur],b,c,l)+10;
  int res2 = dfs(cur+1,a,b+l[cur],c,l)+10;
  int res3 = dfs(cur+1,a,b,c+l[cur],l)+10;

  return min(res0,min(res1,min(res2,res3)));
}

// TODO: write
int main() {
  cin>>n>>A>>B>>C;
  vector<int> l(n);rep(i,n)cin>>l[i];
  print(dfs(0,0,0,0,l));
  return 0;
}

Measured memory_bytes: 3600
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define ld long double
#define INF 1000000000000000000
typedef pair<ll, ll> pll;
typedef pair<int, int> pint;

int N;
vector<vector<ll>> F(10, vector<ll>(10)), P(10, vector<ll>(11));
ll ans = -INF;

void rec(vector<ll> &A, int depth) {
    if (depth == 10) {
        ll tmp = 0;
        bool judge = 0;
        rep(i, N) {
            ll cnt = 0;
            rep(j, 10) {
                if (A[j] == 1)
                    judge = 1;
                if (F[i][j] == A[j] && A[j] == 1)
                    cnt++;
            }
            tmp += P[i][cnt];
        }

        if (judge)
            ans = max(ans, tmp);
        return;
    }

    vector<ll> AA = A;
    A.push_back(0);
    AA.push_back(1);
    rec(A, depth + 1);
    rec(AA, depth + 1);
}

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

    cin >> N;

    F.resize(N, vector<ll>(10));
    P.resize(N, vector<ll>(11));
    rep(i, N) {
        rep(j, 10) { cin >> F[i][j]; }
    }

    rep(i, N) {
        rep(j, 11) { cin >> P[i][j]; }
    }

    vector<ll> A;
    ll count = 0;
    rec(A, 0);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
	int A, B;
	cin >> A >> B;
	int tmp = A * B;
	if (tmp % 2 == 0) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func sum(g [][]int32) {
	n := len(g)
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			if i > 0 {
				g[i][j] += g[i-1][j]
			}
			if j > 0 {
				g[i][j] += g[i][j-1]
			}
			if i > 0 && j > 0 {
				g[i][j] -= g[i-1][j-1]
			}
		}
	}
}

func check(g [][]int32, sx, sy int, k int) int32 {
	k2 := k * 2

	k -= 1
	k2 -= 1
	a := g[sx+k2][sy+k2] - g[sx+k2][sy+k] - g[sx+k][sy+k2] + g[sx+k][sy+k]
	b := g[sx+k][sy+k]
	if sx > 0 {
		b -= g[sx-1][sy+k]
	}
	if sy > 0 {
		b -= g[sx+k][sy-1]
	}
	if sx > 0 && sy > 0 {
		b += g[sx-1][sy-1]
	}
	return a + b
}

func main() {
	var N, K int
	fmt.Scanf("%d %d", &N, &K)
	K2 := K * 2

	w := make([][]int32, 4*K)
	for i := 0; i < len(w); i++ {
		w[i] = make([]int32, 4*K)
	}
	b := make([][]int32, 4*K)
	for i := 0; i < len(b); i++ {
		b[i] = make([]int32, 4*K)
	}

	for i := 0; i < N; i++ {
		x, y, s := 0, 0, ""
		fmt.Scanf("%d %d %s", &y, &x, &s)
		c := s[0]

		if c == 'B' {
			b[x%K2][y%K2] += 1
			b[x%K2+K2][y%K2] += 1
			b[x%K2+K2][y%K2+K2] += 1
			b[x%K2][y%K2+K2] += 1
		} else {
			w[x%K2][y%K2] += 1
			w[x%K2+K2][y%K2] += 1
			w[x%K2+K2][y%K2+K2] += 1
			w[x%K2][y%K2+K2] += 1
		}
	}

	//for _, t := range w {
	//	fmt.Println(t)
	//}

	sum(b)
	sum(w)

	//fmt.Println("----")
	//for _, t := range w {
	//	fmt.Println(t)
	//}

	ans := 0
	for i := 0; i < K; i++ {
		for j := 0; j < K; j++ {
			nw := check(w, i, j, K)
			nb := check(b, i+K, j, K)
			if int(nw+nb) > ans {
				ans = int(nw + nb)
			}
		}
	}

	for i := 0; i < K; i++ {
		for j := 0; j < K; j++ {
			nb := check(b, i, j, K)
			nw := check(w, i+K, j, K)
			if int(nw+nb) > ans {
				ans = int(nw + nb)
			}
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 145280
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3e5+10;
const int mod=1e9+7;
struct  abc{
    int i,v;
}col[N],row[N];
map<pair<int,int> ,ll> mp;
bool cmp(abc &x,abc&y){
    return x.v>y.v;
}
int main() {;
 //  freopen("../in.in", "r", stdin);
//    freopen("../out.out","w",stdout);
    ios::sync_with_stdio(false);
    int t,i,j=0;
    int m,x,n,y;
    int k;
    cin>>n>>m>>k;
    for(i=1;i<=k;i++){
        cin>>x>>y;
        mp[make_pair(x,y)]=1;
        row[x].v++;row[x].i=x;
        col[y].v++;col[y].i=y;
    }
    sort(row+1,row+n+1,cmp);
    sort(col+1,col+m+1,cmp);
    ll ans=0;
    ll maxn1=row[1].v,maxn2=col[1].v;
    bool flag=true;
//    cout<<maxn1<<":"<<maxn2<<endl;
    for(i=1;i<=n&&flag;i++){
        if(row[i].v<maxn1) break;
        for(j=1;j<=m&&flag;j++){
            if(col[j].v<maxn2) break;
            ans=max(ans,row[i].v+col[j].v-mp[make_pair(row[i].i,col[j].i)]);
            if(ans==row[i].v+col[j].v) flag=false;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

#define int long long
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; }

signed main(){
	int k;
	string s;
	cin >> k;
	cin >> s;
	if(k >= s.size()){
		cout << s << endl;
	}else{
		cout << s.substr(0, k) << "..." << endl;
	}

	return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>;
using namespace std;
//#define LOCAL
#define ll long long
#define fastIO ios::sync_with_stdio(0), cin.tie(0)

bool run(string a,string b){
    for(int i=0;i<a.size();i++)
    {
        if(a[i]!=b[i])
            return false;
    }
    return true;
}
int main(){
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
     //freopen("out.txt", "w", stdout);
#else
 fastIO;
#endif
//***************************//**************************//******************************

    string s,t;
    cin>>s>>t;
    if(run(s,t)){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}


Measured memory_bytes: 3648
def div(n):
	ls = []
	i = 2
	while i*i <= n:
		c = 0
		if n%i==0:
			while n%i==0:
				n /= i
				c += 1
		if c > 0:
			ls.append([i,c])
		i += 1
	if n > 1:
		ls.append([n,1])
	ans = 1
	for b,p in ls:
		ans *= (b**(p+1)-1)/(b-1)
	return ans
	
while 1:
	n = input()
	if n == 0: break
	d = div(n) - n
	if d == n:
		print "perfect number"
	elif d < n:
		print "deficient number"
	else:
		print "abundant number"

Measured memory_bytes: 4244
#include<stdio.h>

int main(void){
 char waiwai[3];
 int i;
 char s1[10];
 char s2[10];
 char s3[10];

 scanf("%s",s1);
 scanf("%s",s2);
 scanf("%s",s3);
 
 waiwai[0]=s1[0];
 waiwai[1]=s2[0];
 waiwai[2]=s3[0];

 for(i=0;i<3;i++){
  if(waiwai[i]>96){
   printf("%c",waiwai[i]-32);
  }else{
   printf("%c",waiwai[i]);
  }
 }
 return 0;
}

Measured memory_bytes: 128
use std::io::*;

fn gcd(a: u64, b: u64) -> u64 {
    if b == 0 {
        return a;
    }
    gcd(b, a % b)
}
fn lcm(a: u64, b: u64) -> u64 {
    a / gcd(a, b) * b
}
fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let a: u64 = itr.next().unwrap().parse().unwrap();
    let b: u64 = itr.next().unwrap().parse().unwrap();
    println!("{}", lcm(a, b));
}


Measured memory_bytes: 4352
import java.util.Scanner;


public class Main {
	static Scanner sc = new Scanner(System.in);
	
	public static void main (String [] args){

		String a = sc.next();
//		int b = Integer.parseInt(sc.next());
		String c = null;
		if(a.contains("9")){
			c = "Yes";
		}else{
			c = "No";
		}
		System.out.println(c);
		System.out.flush();
		sc.close();
	}
}

Measured memory_bytes: 21204
import java.io.*;
import java.util.*;

public class Main {
	
	private static long dp[];
	private static long util(int arr[],int start,int end) {
		
		if(start >= end-1) return 0;
		
		if(dp[start] != 0) return dp[start];
		
		long ans = Long.MAX_VALUE;
		
		if(start + 2 < end) {
			ans = Math.min(Math.abs(arr[start] - arr[start + 1]) + util(arr,start + 1,end) , Math.abs(arr[start] - arr[start + 2]) + util(arr,start + 2,end));
		}else {
			ans = Math.abs(arr[start] - arr[start + 1] ) + util(arr,start + 1,end);
		}
		
		return dp[start] = ans;
		
	}
	
	private static long util1(int arr[],int n) {
		
		int first = 0;
		int second = Math.abs(arr[1] - arr[0]);
		
		if(n == 2) return second;
		
		int third = 0;
		
		for(int i=2; i<n; i++) {
			third = Math.min(Math.abs(arr[i] - arr[i-1]) + second, Math.abs(arr[i] - arr[i-2]) + first);
			first = second;
			second = third;
		}
		
		return third;
		
	}
	
	public static void main(String[] args) {
		
		FastReader sc = new FastReader();
		
		int n = sc.nextInt();
		
		int arr[] = new int[n];
		
		for(int i=0; i<n; i++) {
			arr[i] = sc.nextInt();
		}
		
		dp = new long[n+1];
		System.out.println(util1(arr,n));
	}
	
	
	
	
	
	
	 static class FastReader 
	    { 
	        BufferedReader br; 
	        StringTokenizer st; 
	  
	        public FastReader() 
	        { 
	            br = new BufferedReader(new
	                     InputStreamReader(System.in)); 
	        } 
	  
	        String next() 
	        { 
	            while (st == null || !st.hasMoreElements()) 
	            { 
	                try
	                { 
	                    st = new StringTokenizer(br.readLine()); 
	                } 
	                catch (IOException  e) 
	                { 
	                    e.printStackTrace(); 
	                } 
	            } 
	            return st.nextToken(); 
	        } 
	  
	        int nextInt() 
	        { 
	            return Integer.parseInt(next()); 
	        } 
	  
	        long nextLong() 
	        { 
	            return Long.parseLong(next()); 
	        } 
	  
	        double nextDouble() 
	        { 
	            return Double.parseDouble(next()); 
	        } 
	  
	        String nextLine() 
	        { 
	            String str = ""; 
	            try
	            { 
	                str = br.readLine(); 
	            } 
	            catch (IOException e) 
	            { 
	                e.printStackTrace(); 
	            } 
	            return str; 
	        } 
	    } 
	  

}


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

using namespace std;
using ll =long long;

#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cout << #x << " = " << (x) << endl;
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}

const ll INF = 1LL << 60;

ll n,m;
string s;
//Write From this Line

int main()
{
	cout << setprecision(10);
	cin >> n ;
	ll sum = 0 ;
	ll last ;
	ll skip = - 1 ; 
	for(int i = 1 ; i <=  n;  i++){
		sum += i;
		if(sum>=n){
			skip = sum - n ;
			last = i ;
			break;
		}
	}
	for(int i = 1 ; i <= last ; i++){
		if(i == skip)continue;
		else cout << i << endl;
	}

}


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

#define INF 1000000000000

int main(){
  int n,m;
  cin>>n>>m;
  int ans;
  for(int i=m/n;i>=1;i--){
    if(m%i==0){if(m/i>=n){ans=i;  cout<<ans; exit(0);}}
  }

}


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

int main() {
  int n;
  cin >> n;
  vector<vector<int>> range(n,(vector<int>(2)));
  rep(i, n){
    int x, r;
    cin >> x >> r;
    range.at(i).at(0) = x+r;
    range.at(i).at(1) = x-r;  
  };
  sort(range.begin(),range.end());
  int c = 1;
  int a = range.at(0).at(0);
  rep(i,n-1){
    if(range.at(i+1).at(1) >= a){
      c++;
      a = range.at(i+1).at(0);
    }
    else if(range.at(i+1).at(1) < a){
      continue;
    }
  };
  cout << c << endl;
}

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

int main(){
    ll a,b;
    cin>>a>>b;
    ll minimum=min(a,b);
    ll maximum=max(a,b);
    ll i=1;
    while(true){
        if((minimum*i)%maximum==0){
            cout<<endl<<i*minimum;
            break;
        }
        i++;
    }
}


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

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

const long long MOD = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> x(n);
  rep(i,n){
    cin >> x.at(i);
  }
  int ans = 1e6 +1,d=0;
  
  rep(p,101){
    d=0;
    rep(i,n){
      d+=(p-x.at(i))*(p-x.at(i));
    }
    if(d<ans) ans=d;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define endl '\n'
#define all(x) (x).begin(),(x).end()
#define ff first
#define ss second
#define sz(x) (int)(x).size()
#define f(n) for(int i=0;i<n;++i)
#define f2(n) for(int j=0;j<n;++j)
#define f3(n) for(int k=0;k<n;++k)
#define F(i,x,n,y) for(int i=x;i<n;i+=y)
#define fa(x,y) for(auto x:y)
 
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
 
//Warsaw debug template
#define LOCAL
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1,debug&>::type operator<<(c i){
sim > struct rge {c b,e;};
sim > rge<c> range(c i, c j) {return rge<c>{i,j};}
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug{
#ifdef LOCAL
~debug() {cerr<<endl; }
eni(!=) cerr<< boolalpha << i; ris;}
eni(==) ris <<range(begin(i),end(i)); }
sim, class b dor(pair<b,c> d){
ris<<"("<<d.first<<","<<d.second<<")";
}
sim dor(rge<c> d){
    *this << "[";
    for(auto it=d.b;it!=d.e;++it)
        *this <<"," +(it==d.b)<< *it;
    ris<<"]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) "["<<#__VA_ARGS__":"<<(__VA_ARGS__)<<"]"
//End of debug template
#define isOn(S, j) (S & (1<<j))
#define setBit(S, j) (S | (1<<j))
#define clearBit(S, j) (S & ~(1<<j))
#define toggleBit(S, j) (S ^ (1<<j))
#define lowBit(S) (S & (-S))
typedef vector<ll> vll;
vector<bool> color;
vi vis;
map<int,int> adj[100004];
void dfs(int u, bool c){
    vis[u]=1;
    color[u]=c;
    for(auto x:adj[u]){
        if(!vis[x.ff]){
            if(x.ss%2)dfs(x.ff,(c+1)%2);
            else dfs(x.ff,c);
        }
    }
}

int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n;
    cin>>n;
    color.resize(n);
    vis.resize(n);
    f(n-1){
        int a,b,c;
        cin>>a>>b>>c;
        --a;--b;
        adj[a][b]=c;
        adj[b][a]=c;;
    }
    dfs(0,0);
    for(auto x:color)cout<<x<<endl;
    return 0;
}
    


Measured memory_bytes: 16512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double db;
ll cost[20], n;
map<ll, ll> mp;
ll beishu[6] = { 2,2,3,3,5,5 };
ll dfs(ll x)
{
	if (x == 0)
		return 0;
	if (mp.count(x))
		return mp[x];
	ll ans = 0x7fffffffffffffff;
	ll ss[6] = { x / 2,x / 2 + 1,x / 3,x / 3 + 1,x / 5,x / 5 + 1 };
	for (int i = 0; i < 6; i++)
	{
		if (ss[i] < x)
		{
			ans = min(ans, dfs(ss[i]) + (ll)min((double)abs(ss[i] - x) * cost[0], abs(ss[i] * beishu[i] - x)  * (double)cost[0] + cost[beishu[i]]));
		}

	}
	mp[x] = ans;
	return mp[x];
}
int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		mp.clear();
		cin >> n >> cost[2] >> cost[3] >> cost[5] >> cost[0];
		cout << dfs(n) << endl;
	}
	return 0;
}


Measured memory_bytes: 4664
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
 
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>
 
using namespace std;
 
typedef long long LL;
typedef vector<int> VI;
 
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)
 
template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}
 
int N;
int A[100011];
 
void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    sort(A, A+N);
 
    int acc = 0;
    vector<pair<int, int> > ans;
    if (A[0] > 0) {
	acc = A[0];
	for (int i=1; i<N-1; i++) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
	ans.emplace_back(A[N-1], acc);
	acc = A[N-1] - acc;
    } else if (A[N-1] < 0) {
	acc = A[N-1];
	for (int i=N-2; i>=0; i--) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
    } else {
	acc = A[0];
	for (int i=1; i<N-1; i++) if (A[i] >= 0) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
	ans.emplace_back(A[N-1], acc);
	acc = A[N-1] - acc;
	for (int i=1; i<N-1; i++) if (A[i] < 0) {
	    ans.emplace_back(acc, A[i]);
	    acc -= A[i];
	}
    }
 
    printf("%d\n", acc);
    EACH (e, ans) printf("%d %d\n", e->first, e->second);
}
 
int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}

Measured memory_bytes: 4692
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	long long int n;
	cin >> n;
	int dp[100020] = {};
	for (int i = 0; i < n; i++) {
		int a;
		cin >> a;
		if (i == 0) {
			if (a != 0) {
				cout << 0;
				return 0;
			}
		}
		dp[a]++;
	}
	if (dp[0] != 1) {
		cout << 0;
		return 0;
	}
	int sum = 0;
	for (int i = 0; i < 100020; i++) {
		sum = sum + dp[i];
		if (dp[i] == 0) {
			cout << 0;
			return 0;
		}
		if (sum == n) {
			break;
		}
	}
	long long int ans = 1;
	for (int i = 1; i < 100020; i++) {
		if (dp[i] == 0) {
			break;
		}
		long long int s = 1;
		for (int j = 1; j <= dp[i]; j++) {
			s = s * dp[i - 1] % 998244353;
		}
		ans = ans * s % 998244353;
	}
	cout << ans;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
char S[100];
int f=0;
  scanf("%s",S);
  for(int i=0;S[i]!='\0';i++){
    if(i%2==0 && S[i]=='L'){
    	f=1;
        break;
    }
    else if(i%2==1 && S[i]=='R'){
    	f=1;
        break;
    }
  }
  if(f==1)printf("No\n");
  else printf("Yes\n");
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int N,Q,i,j,l,r,c=0;
  char S[100001];
  int B[100001];
  scanf("%d %d",&N,&Q);
  scanf("%s",S);
  for(i=0;i<N-1;i++){
    if(S[i]=='A'&&S[i+1]=='C'){
      c++;
    }
    B[i+1]=c;
  }
  for(i=0;i<Q;i++){
    scanf("%d %d",&l,&r);
    printf("%d\n",B[r-1]-B[l-1]);
  }
  return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
int main(void)
{
	int a, b;
	scanf("%d %d",&a ,&b);
	if(a<b)
	{
		printf("a < b\n");
	}
	else if(a>b)
	{
		printf("a > b\n");
	}
	else
	{
		printf("a == b\n");
	}

	return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#define INF 1100000000

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  for (int i = 0; i < N; i++) {
    cin >> P[i];
  }
  int mi = INF;
  int ans = 0;
  for (int i = 0; i < N; i++) {
    // P[j] >= P[i]
    if (mi >= P[i]) ans++;
    mi = min(mi, P[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') c=getchar(),f=-1;
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=300+10;
char s[maxn][maxn];
int main(){
	int n=read(),ans=0;
	REP(i,0,n-1) scanf("%s",s[i]);
	REP(A,0,n-1){
		bool flag=1;
		REP(i,0,n-1){
			REP(j,0,n-1) if(s[(i+A)%n][j]!=s[(j+A)%n][i]){
				flag=0;
				break;
			}
			if(!flag) break;
		}
		ans+=flag*n;
	}
	printf("%d\n",ans);
	return 0;
}

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

using namespace std;

int a,b; 

int main()
{
	cin>>a>>b;
	int cnt;
	while (b--)
	{
		int x;
		cin>>x;
		cnt+=x;
	}
	if (cnt>=a) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
} 

Measured memory_bytes: 256
N,M = gets.split.map &:to_i
ABs = M.times.map { gets.split.map(&:to_i) }

F = Array.new(N+1){[]}
ABs.each do |a,b|
    F[a] << b
    F[b] << a
end

ans = 0
Mark = []
FCount = ->(n){
    return 0 if Mark[n]
    Mark[n] = true
    ret  = 1
    F[n].each do |f|
        ret += FCount.call(f)
    end
    ret
}

p (1..N).map{ FCount.call(_1)}.max

Measured memory_bytes: 275464
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main()
{
	int N;
	cin >> N;
	vector<int> L(N);
	for (auto &x : L) {
		cin >> x;
	}
	sort(L.begin(), L.end());

	int a = accumulate(L.begin(), L.end() - 1, 0);
	int b = L.back();

	if (b < a) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <map>
using namespace std;
using ll = long long int;
#define REP(i,n) for(int i=0;i<n;i++)

bool checkExist(char c, string S)
{
    for (int index=0; index < (int)S.size(); index++)
    {
        if (c == S[index])
            return true;
    }

    return false;
}

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

    sort(S.begin(), S.end());
    bool found = false;
    for (char c='a'; c < 'z'+1; c++)
    {
        if (!checkExist(c, S))
        {
            found = true;
            cout << c << endl;
            break;
        }
    }
    if (!found)
        cout << "None" << endl;
}

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

#define ll long long
#define uint unsigned int
#define vi vector<int>
#define pii pair<int,int>

#define for0(i,n) for(int i=0; i<(n); i++)
#define for1(i,n) for(int i=1; i<=(n); i++)
#define from(i,a,b) for(int i=(a); i<=(b); i++)
#define forr(i,a,b) for(int i=(a); i>=(b); i--)

#define PB push_back
#define MP make_pair
#define FI first
#define SE second

#define all(x) (x).begin(),(x).end()
#define len(x) (int)(x).size()

#define safe_map unordered_map<long long, int, custom_hash>

#define CLK clock_t clk = clock();//Start of main
#define OCLK cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / CLOCKS_PER_SEC << '\n';//End of main

void amax(int& x, int y){if(x<y)x=y;}
void amin(int& x, int y){if(x>y)x=y;}
int gcd(int a, int b){if(b){return gcd(b,a%b);}return a;}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {  // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};






int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);
    int h,w,k; cin >> h >> w >> k;
  	string s[h];
    for0(i,h)cin>>s[i];
    int ans=0;
    for0(rm,1<<h){
        for0(cm,1<<w){
            int cnt=0;
            for0(i,h){
                if(rm>>i&1){
                    for0(j,w){
                        if(cm>>j&1){
                            if(s[i][j]=='#')cnt++;
                        }
                    }
                }
            }
            if(cnt==k)ans++;

        }
    }

    cout << ans << '\n';
  	
}




Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i, n)
  {
    cin >> a[i];
  }
  for (int i = n - 1; i > 0; i--)
  {
    cout << a[i] << " ";
  }
  cout << a[0] << endl;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);i++)
#define N 100000
typedef long long ll;
#define ALL(v) (v).begin(),(v).end()
#define SZ(x) int(x.size())
#define OUT(a) cout<<(a)<<endl
typedef pair<int,int> P; 
#define INF 100000000
const int MAX = 1000000;
const int MOD = 1000000007;
int main(){
    int n,k;
    cin>>n>>k;
    vector<int> a(3);
    REP(i,3){
        cin>>a[i];
    }
    char t[3]={'s','p','r'};
    string s;
    cin>>s;
    ll ans=0;
    REP(i,n){
        REP(j,3){
            if(t[j]==s[i]){
                ans+=a[j];
                if(i+k<n&&s[i]==s[i+k]) s[i+k]='?';
            }
        }
    }
    OUT(ans);
    return 0;
}

Measured memory_bytes: 512
#include <cstdio>  
#include <stack>  
#include <queue>
#include <cmath>  
#include <vector>  
#include <cstring>  
#include<set>
#include<map>
#include<ctime>
#include<string>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef pair<double, double> Pd;
typedef unsigned long long uLL;
const int M = 2005;
const int N = 1000005;
const int mod = 1000000007;
const double eps = 1e-9;
const int INF = 0x3f3f3f3f;
const LL lINF = 0x3f3f3f3f3f3f3f3fLL;
const int sINF = 0xcfcfcfcf;
#define ls (rt<<1)
#define rs (rt<<1|1)
char s1[M], s2[M],s3[M];//模式串
int nt[M], len, cnt, flag, isv[M], t, res;//len为模式串长度
void getnext(char *s, int *nt)//next数组生成
{
	int len = strlen(s);
	memset(nt, 0, sizeof(nt));
	nt[0] = -1;
	int i = 0, j = -1;
	while (i < len)
	{
		if (j != -1 && s[i] != s[j])
			j = nt[j];
		else
			nt[++i] = ++j;
	}
}
int kmp(char *str, char *ptr) {//x是主串 y是模式串 
	int i = 0, j = 0;
	int ans = 0;
	int slen = strlen(str), plen = strlen(ptr);
	memset(nt, 0, sizeof(nt));
	getnext(ptr, nt);
	while (i<slen) {
		while (j != -1 && str[i] != ptr[j])//ptr部分与str匹配
			j = nt[j];
		i++;
		j++;
		if (j == plen) {
			ans++;
			j = 0;//j=0,str中的ptr串不能重叠;j=nt[j],ptr可以重叠
		}
	}
	return ans;
}
int main()
{
	while (~scanf("%s%s", s1,s2))
	{
		strcpy(s3, s1);
		strcat(s3, s1);
		if (kmp(s3, s2))
			printf("Yes\n");
		else
			printf("No\n");
	}
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
M = [(-1, -1)]*(H*W+1)
A = []
for i in range(H):
  As = list(map(int, input().split()))
  for j in range(W):
    a = As[j]
    M[a] = (i, j)
  A.append(As)
#print(M)
Dist = [0]*(H*W+1)
for k in range(0, H*W-D+1):
  i, j = M[k]
  x, y = M[k+D]
  Dist[k+D] = Dist[k]+abs(x-i)+abs(y-j)
Q = int(input())
for i in range(Q):
  L, R = map(int, input().split())
  r = Dist[R]-Dist[L]
  print(r)

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

int main() {
  int N;
  cin >> N;
  
  int i = 0;
  for(; i < N; i++){
    string col;
    cin >> col;
    
    if(col == "Y"){
      cout << "Four" << endl;
      break;
    }
  }
  if(i == N){
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 256