akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n, k;
    string s;
    cin >> n >> k >> s;

    int l = 0, r = 1; // [l, r)
    int ans = 1;
    int zero = s[0] == '0';

    while (true) {
        if (r == n) break;

        if (zero == k) {
            if (s[r-1] == '1' && s[r] == '0') {
                if (s[l] == '0' && s[l+1] == '1') {
                    zero--;
                }
                l++;
            } else {
                r++;
                ans = max(ans, r - l);
            }
        } else {
            if (s[r-1] == '1' && s[r] == '0') {
                zero++;
            }
            r++;
            ans = max(ans, r - l);
        }
    }

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

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define each(a, b) for(auto (a): (b))
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define show(x) cout <<#x<<" = "<<(x)<<endl
#define spair(p) cout <<#p<<": "<<p.fi<<" "<<p.se<<endl
#define svec(v) cout<<#v<<":";rep(kbrni,v.size())cout<<" "<<v[kbrni];cout<<endl
#define sset(s) cout<<#s<<":";each(kbrni,s)cout <<" "<<kbrni;cout<<endl

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 100005;
const int LOG_N = 17;

vector<int> G[MAX_N];

int par[LOG_N][MAX_N];
int depth[MAX_N];

void dfs(int u,int p,int d)
{
    par[0][u] = p;
    depth[u] = d;
    rep(i,G[u].size()){
        if(G[u][i] != p){
            dfs(G[u][i],u,d+1);
        }
    }
}

int lca(int u,int v)
{
    if(depth[u] > depth[v]){
        swap(u,v);
    }
    rep(i,LOG_N){
        if((depth[v] - depth[u]) >> i & 1){
            v = par[i][v];
        }
    }
    if(u == v){
        return u;
    }
    for(int i=LOG_N-1;i>=0;i--){
        if(par[i][u] != par[i][v]){
            u = par[i][u];
            v = par[i][v];
        }
    }
    return par[0][u];
}

int main()
{
    int n;
    cin >> n;
    rep(i,n){
        int m;
        scanf("%d",&m);
        rep(j,m){
            int x;
            scanf("%d",&x);
            G[i].pb(x);
        }
    }
    dfs(0,-1,0);
    rep(i,LOG_N-1){
        rep(j,n){
            if(par[i][j] < 0){
                par[i+1][j] = -1;
            }else{
                par[i+1][j] = par[i][par[i][j]];
            }
        }
    }
    int q;
    cin >> q;
    rep(i,q){
        int x,y;
        scanf("%d%d",&x,&y);
        printf("%d\n",lca(x,y));
    }
    return 0;
}

Measured memory_bytes: 20304
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
 
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;
 
#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second
 
int main(int argc, char **argv) {
	int a, b, c, d, l, r;
	cin >> a >> b >> c >> d;
	l = a + b;
	r = c + d;
	cout << (l > r ? "Left" : l == r ? "Balanced" : "Right") << endl;
	return 0;
}
 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Ms(a,b) memset(a,b,sizeof a)
#define db(x) cout<<#x<<"="<<x<<endl;
#define db2(x,y) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<endl;
#define db3(x,y,z) cout<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<endl;
using namespace std;
int n,a[105];
double ans=0;
int main() {
	scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]),ans+=1.0/a[i];
	printf("%lf\n",1/ans);
	return 0;
}


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

int main(){
  int N,X,r;
  cin >> N >> X;
  vector<int> m(N);
  for(int i = 0; i < N; i++){
    cin >> m.at(i);
  }
  //一番材料を使わないドーナッツを求める 
  int min_q = m.at(0);
  int min_i = 0;
  for(int i = 1; i < N; i++){
    if(m.at(i) < min_q){
      min_q = m.at(i);
      min_i = i;
    }
  }
  //N種類のドーナッツは最低一つ作る
  for(auto q : m ) X -= q;
  //残りのお菓子の粉で一番材料を使わないドーナッツ作る
  int min_c = 0;
  while(X >= min_q){
    X -= min_q;
    min_c++;
  }
  cout << N + min_c << endl;
}

Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
mod2 = 998244353
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)



class Prime():
    def __init__(self, n):
        self.M = m = int(math.sqrt(n)) + 10
        self.A = a = [True] * m
        a[0] = a[1] = False
        self.T = t = [2]
        for j in range(4, m, 2):
            a[j] = False
        for i in range(3, m, 2):
            if not a[i]:
                continue
            t.append(i)
            for j in range(i*i,m,i):
                a[j] = False
        self.ds_memo = {}
        self.ds_memo[1] = set([1])

    def is_prime(self, n):
        return self.A[n]

    def division(self, n):
        d = collections.defaultdict(int)
        for c in self.T:
            while n % c == 0:
                d[c] += 1
                n //= c
            if n < 2:
                break
        if n > 1:
            d[n] += 1
        return d.items()

    # memo
    def divisions(self, n):
        if n in self.ds_memo:
            return self.ds_memo[n]

        for c in self.T:
            if n % c == 0:
                rs = set([c])
                for cc in self.divisions(n // c):
                    rs.add(cc)
                    rs.add(cc * c)
                self.ds_memo[n] = rs
                return rs

        rs = set([1, n])
        self.ds_memo[n] = rs
        return rs

def main():
    n,k = LI()
    pr = Prime(10**5)
    c = collections.defaultdict(int)
    for i in range(k, 0, -1):
        t = k // i
        p = (pow(t, n, mod) + c[i]) % mod
        ds = pr.divisions(i)
        for kk in ds:
            if kk == i:
                continue
            c[kk] -= p
        c[i] = p

    r = sum(k*v%mod for k,v in c.items()) % mod

    return r

print(main())





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

int main()
{
    int n;
    cin >> n;
    vector<int> x(n);
    rep(i, n)
    {
        cin >> x.at(i);
    }

    // 区間の最大と最小を求める
    int minX = x.at(0);
    int maxX = x.at(0);
    rep(i, n)
    {
        minX = min(minX, x.at(i));
        maxX = max(maxX, x.at(i));
    }

    //最小の体力を求める
    int ans = INF;
    // 区間を全探索
    for (int p = minX; p <= maxX; p++)
    {
        int energy = 0;
        rep(i, n)
        {
            energy += (x.at(i) - p) * (x.at(i) - p);
        }
        ans = min(ans, energy);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

	int n,d,x[11][11];
	cin>>n>>d;
	for(int i=0;i<n;i++)
		for(int j=0;j<d;j++)
			cin>>x[i][j];

	int res=0;
	for(int i=0;i<n;i++)
		for(int j=i+1;j<n;j++)
		{
			int dis2=0;
			for(int k=0;k<d;k++)
			{
				int tmp=x[i][k]-x[j][k];
				dis2+=tmp*tmp;
			}
			res+=dis2==(int)sqrt(dis2)*(int)sqrt(dis2);
		}

	cout<<res<<endl;
			

	return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
x = list(map(int, input().split()))
x.sort()
y = []
for i in range(m - 1):
    y.append(x[i+1] - x[i])
y.sort()
if n >= m:
    print(0)
else:
    ans = 0
    for i in range(m - n):
        ans += y[i]
    print(ans)

Measured memory_bytes: 13968
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
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;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 main(){
  ll K;
  cin>>K;
  
  ll N=50,A[50];
  REP(i,N) A[i]=49+K/50;
  
  REP(i,N) A[i]-=K%50;
  REP(i,K%50) A[i]+=51;
  
  cout<<N<<endl;
  REP(i,N) cout<<A[i]<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int r, g, b, n;
    cin >> r >> g >> b >> n;
    int ans = 0;
    REP(i,n+1) REP(j,n+1){
        int x = n - r * i - g * j;
        if (x >= 0 && x % b == 0) ans++;
    }
    cout << ans << endl;

    return 0;
}


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

int main() { 	
  int N,x,xx,a;
  a=0;
  
  	cin >> N>>xx;
  for(int i=0;i<N-1;i++){
	cin>> x;
    if(xx>x){
    a=1;
      break;
    }
    
    if(xx==x){
    }else{
    x--;}
    
    xx=x;
  }
if(a==1){ 
cout << "No" <<endl;}else if(a==0){
cout << "Yes" <<endl;
}  
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <numeric>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
	int N;
	cin >> N;
	if(N/100 == 7 || (N%100)/10 == 7 || (N%10)==7)cout << "Yes" << endl;
	else cout << "No" <<endl;
	return 0;
}


Measured memory_bytes: 3676
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();

        int s = x;
        int f = 0;
        while (s != 0) {
            f += s % 10;
            s /= 10;
        }

        System.out.println(x % f == 0 ? "Yes" : "No");

    }

    void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define endl '\n'
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define zy -2147382637
#define bql 2147483647
#define ll long long
#define ull unsigned long long
#define ld long double
#define il inline
#define sz(x) x.size()
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#define maxn 100010
#define rp(i, l, r) for (int i = l; i <= r; i++)
#define rb(i, r, l) for (int i = r; i >= l; i--)
#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll min(ll a,ll b){if(a<b)return a;else return b;}
ll lowbit(ll x){return x&(-x);}
ll prime(ll x){
   if(x<=1)return false;
   for(int i=2;i<=int(sqrt(x));i++){
	   if(x%i==0)return false;
   }return true;
}
ll gcd(ll a,ll b){ll r;while(b>0){r=a%b;a=b;b=r;}return a;}
ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
inline ll read() {
	char c = getchar(); ll w = 1; ll x = 0;
	while (!isdigit(c))
		(c == '-') && (w = -w), c = getchar();
	while (isdigit(c))
		x = (x << 1) + (x << 3) + (c ^ '0'), c = getchar();
	x *= w;
}
const int dx[8] = {-1, 1, 0, 0, -1, 1, -1, 1},
		  dy[8] = {0, 0, -1, 1, -1, -1, 1, 1};
int main(){
	fast;
	ll n,k,sum=0;
	cin>>n>>k;
	char a[n+1];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<n;i++){
		if(a[i]==a[i+1])sum++;
	}cout<<min(n-1,sum+2*k)<<endl;
	return 0;
}/*『你强归你强，我永不示弱』*/


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
  static int n;
  static int[] a;

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

    n = sc.nextInt();
    a = new int[n];
    for(int i = 0; i < n; i++){
      a[i] = sc.nextInt();
    }

    long count = 0, sum = 0;
    for(int i = 0; i < n; i++){
      if(a[i] == 0){
        count += sum / 2;
        sum = 0;
      }
      sum += a[i];
    }

    count += sum / 2;

    System.out.println(count);
  }
}

Measured memory_bytes: 23580
S=list(input())
N=len(S)
ord_A=ord("a")
alp=[0]*26
odd=-1
for i in range(N):
  m=ord(S[i])-ord_A
  alp[m]+=1
for k in range(26):
  if alp[k]%2==1:
    if odd==-1:
      odd=k
    else:
      print(-1)
      exit()
pos=[[] for i in range(26)]
Sequence=[0]*N
d=0
alp_num=[0]*26
for i in range(N):
  m=ord(S[i])-ord_A
  alp_num[m]+=1
  if 2*alp_num[m]<=alp[m]:
    Sequence[i]=d
    pos[m].append(d)
    d+=1
  elif m==odd and alp_num[m]==alp[m]//2+1:
    Sequence[i]=N//2
  else:
    j=pos[m].pop()
    Sequence[i]=N-1-j

def add(B,a,n):
    x = a
    while x<=n:
        B[x]+=1
        x+=x&(-x)
        
def sums(B,a):
    x=a
    S=0
    while x!=0:
        S+=B[x]
        x-=x&(-x)
    return S
  
def invnumber(n,A):
  B=[0]*(n*2+1)
  invs=0
  for i in range(n):
      s=A[i]+n
      invs+=sums(B,s)
      add(B,s,n*2)
  return n*(n-1)//2-invs

print(invnumber(N,Sequence))

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

long long sign(long long A){
    return (A>0)-(A<0);
}

int main(){
    long long n;

    cin >> n;

    long long a[n];

    for(long long i = 0; i < n; i++){
        cin >> a[i];
    }

    long long count = 0;
    long long i = 0;
    while(i < n){
        while(i + 1 < n and a[i] == a[i+1]){
            i++;
        }

        if(i+1 < n and a[i] < a[i+1]){
            while(i+1 < n and a[i] <= a[i+1]){
                i++;
            }
        }
        else if(i+1 < n and a[i] > a[i+1]){
            while(i+1 < n and a[i] >= a[i+1]){
                i++;
            }
        }
        count++;
        i++;
      
    }

    printf("%lld\n", count);

    return 0;
}

Measured memory_bytes: 1024
//libraries
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//namespace
using namespace std;
using namespace __gnu_pbds;

//typedef
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

//define
#define inp(X) cin>>X;
#define inp_long(X) long long X; cin>>X;
#define inp_arr(A,N) long long A[N]; for(ll i=0;i<N;i++) {cin>>A[i];}
#define sz(A) A.size()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define endl '\n'
#define vect(A) vector<long long> A;
#define inp_vect(A,N); for(ll i=0;i<N;i++){long long q; cin>>q; A.push_back(q);}
#define forin(i,a,b) for(long long i=a;i<=b;i++)
#define forde(i,a,b) for(long long i=a;i>=b;i--)
#define fio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);

ll power(ll x,ll y)
{
    if (y == 0)
        return 1;
    ll p = power(x, y/2) % MOD;
    p = (p * p) % MOD;

    return (y%2 == 0)? p : (x * p) % MOD;
}
ll modInverse(ll a)
{
   return power(a,MOD-2);
}
int main()
{
	fio;
	ll n;
	cin>>n;
	double a[n][2];
	forin(i,0,n-1)
	{
		double x,y;
		cin>>x>>y;
		a[i][0]=x;
		a[i][1]=y;
	}
	double sum=0;
	forin(i,0,n-2)
	{
		forin(j,i+1,n-1)
		{
			sum+=sqrt(pow(a[j][0]-a[i][0],2) + pow(a[j][1]-a[i][1],2));
		}
	//	cout<<sum<<endl;
	}
	sum*=2;
	sum/=n;
	cout<<setprecision(18)<<sum<<endl;
}



Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,t;
    cin>>a>>b>>c;
    t=a+b+c;
    if(t-a==a||t-b==b||t-c==c){
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int s1,s2,s3,s4,s5,s6,s7,s8,s9,s10;
    cin>>s1>>s2>>s3>>s4>>s5>>s6>>s7>>s8>>s9>>s10;
    cout<<s1+s2+s3+s4+s5+s6+s7+s8+s9+s10<<endl;
    
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

ll dp[401][401];

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

    ll n,c;cin>>n>>c;
    vector<ll> a(n),b(n);
    rep(i,n) cin>>a[i];
    rep(i,n) cin>>b[i];

    dp[0][0]=1;
    rep(i,n){
        vector<ll> v(c+1,0);
        vector<ll> nums;
        for(ll k=a[i];k<=b[i];k++) nums.push_back(1);
        
        rep(j,c+1){
            for(auto x:nums) v[j]=(v[j]+x)%mod;
            rep(k,b[i]-a[i]+1) nums[k]=nums[k]*(a[i]+k)%mod;
        }
        rep(j,c+1){
            for(int k=0;k<=j;k++){
                dp[i+1][j]+=dp[i][k]*v[j-k]%mod;
                dp[i+1][j]%=mod;
            }
        }
    }
    cout<<dp[n][c]<<endl;
    return 0;
}


Measured memory_bytes: 1536
N,T,A,*hs=$<.read.split.map(&:to_i)

ret = hs.map.with_index {|h,i| [(T-h*0.006-A).abs,i]}.min[1] + 1
puts ret

# n = 0
# d = 10**9
# hs.each.with_index do |h,i|
#     t = T-h*0.006
#     t = (A-t).abs
#     if t < d
#         n = i
#         d = t
#     end
# end

# puts n+1


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using VI = vector<int>;
using VVI = vector<VI>;

int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  while (true) {
    int m, n; cin >> m >> n;
    if (m == 0 and n == 0) break;
    bitset<(int) 1e7> tab;
    for (int i = 0; i < n; i++) {
      int j = m;
      while (j < 1e7) {
        tab[j] = true;
        j += m;
      }
      while (tab[m]) m++;
    }
    for (int i = m; ; i++) {
      if (not tab[i]) {
        cout << i << '\n';
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 4300
#pragma warning (disable :4996)
#include <iostream>
#include <cstdio>
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 10;

struct Point { double x, y; };
void koch(int n, Point a, Point b) {
	if (n == 0) return;
	//求s,t坐标
	Point s, t, u; 
	double th = acos(-1) * 60.0 / 180.0;  //从度转换为弧度  60°
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	//求u
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;

	koch(n - 1, a, s);
	printf("%.5lf %.5lf\n", s.x, s.y);
	koch(n - 1, s, u);
	printf("%.5lf %.5lf\n", u.x, u.y);
	koch(n - 1, u, t);
	printf("%.5lf %.5lf\n", t.x, t.y);
	koch(n - 1, t, b);
}
int main() {
	int n;
	scanf("%d", &n);
	Point a, b;
	a.x = 0.0, a.y = 0.0;
	b.x = 100.0, b.y = 0.0;
	printf("%.5lf %.5lf\n", a.x, a.y);
	koch(n, a, b);
	printf("%.5lf %.5lf\n", b.x, b.y);
	return 0;
}


Measured memory_bytes: 3192
from collections import Counter

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

l = Counter(A)
count = [0] * (10**5 + 1)
for c in l.items():
  count[c[0]] = c[1]

ans = 0
for i in range(10**5-1):
  tmp = count[i] + count[i+1] + count[i+2]
  if tmp > ans:
    ans = tmp
print(ans)

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

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) cin>>a[i];
  vector<ll> acc(n);
  sort(a.begin(),a.end());
  acc[0]=a[0];
  rep(i,n-1)
    acc[i+1]=a[i+1]+acc[i];
  vector<int> b(n);
  int ans=1;
  for(int i=n-2; i>=0; i--) {
    if(acc[i]*2<a[i+1]) {
      break;
    } else {
      ans++;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 2176
n=int(input())

abc="abcdefghijklmnopqrstuvwxyz"

cnt=[[0]*n for _ in range(26)]

for i in range(n):
    temp=input()
    for j in range(26):
        cnt[j][i]=temp.count(abc[j])

ans=[]

for i in range(26):
    for j in range(min(cnt[i])):
        ans.append(abc[i])

print("".join(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

int main(){
    int n;
    cin>>n;
    int a[n];
    rep(i,n)cin>>a[i];
    sort(a,a+n,greater<int>());
    priority_queue<int> pq;
    pq.push(a[0]);
    ll ans=0;
    for(int i=1;i<n;++i){
        ans+=pq.top();
        pq.pop();
        pq.push(a[i]);
        pq.push(a[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 5084
H,W,K = gets.strip.split(" ").map(&:to_i)
map = ''

H.times do |i|
  map+=gets.strip
end

sum = 0
H2 = 2**H
W2 = 2**W
H2.times do |i|
  i2 = i.to_s(2)
  i2 = "#{'0'*(H-i2.size)}#{i2}"
  W2.times do |j|
    j2 = j.to_s(2)
    j2 = "#{'0'*(W-j2.size)}#{j2}"
    new_map = map.dup
    H.times do |k|
      W.times do |l|
        new_map[k*W+l]='R' if i2[k] == '1' || j2[l] == '1'
      end
    end
    sum +=1 if new_map.count('#')==K
  end 
end


puts sum


Measured memory_bytes: 14132
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

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

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

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func bit(n, N int) ([]int, bool) {
	ret := make([]int, N)
	idx := 0
	cnt := []int{0, 0, 0, 0}
	for n > 0 {
		ret[idx] = n % 4
		n /= 4
		idx++
	}

	for i := 0; i < N; i++ {
		cnt[ret[i]]++
	}

	f := cnt[0] != 0 && cnt[1] != 0 && cnt[2] != 0

	return ret, f
}

const inf = 1001001001001

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

	var A [3]int
	N := getInt()
	A[0], A[1], A[2] = getInt(), getInt(), getInt()
	l := make([]int, N)
	for i := 0; i < N; i++ {
		l[i] = getInt()
	}

	cnt := 1
	for i := 0; i < N; i++ {
		cnt *= 4
	}

	ans := inf

	for i := 0; i < cnt; i++ {
		b, flg := bit(i, N)
		if flg == false {
			continue
		}

		cost := 0
		for j := 0; j < 3; j++ {
			L := 0
			c := 0
			f := false
			for k, v := range b {
				if v == j {
					L += l[k]
					if f {
						c += 10
					} else {
						f = true
					}
				}
			}
			if L > A[j] {
				c += L - A[j]
			} else if L < A[j] {
				c += A[j] - L
			}
			// out(b, c, L, A[j])
			cost += c
		}
		// out("--", cost, "--")
		ans = min(ans, cost)
	}

	out(ans)
}


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

int main() {
  int A,B,C,D;
  cin >> A >> B >> C >> D;
  string S;
  for(int i = 0;i < C - A;i++) {
    S = S + "R";
  }
  for(int i = 0;i < D - B;i++) {
    S = S + "U";
  }
  for(int i = 0;i < C - A;i++) {
    S = S + "L";
  }
  for(int i = 0;i < D - B;i++) {
    S = S + "D";
  }
  S = S + "D";
  for(int i = 0;i < C - A + 1;i++) {
    S = S + "R";
  }
  for(int i = 0;i < D - B + 1;i++) {
    S = S + "U";
  }
  S = S + "L";
  S = S + "U";
  for(int i = 0;i < C - A + 1;i++) {
    S = S + "L";
  }
  for(int i = 0;i < D - B + 1;i++) {
    S = S + "D";
  }
  S = S + "R";
  cout << S << endl;
}

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

int n, k;
int dp[1010][1010] = {};

int main(){
  cin >> n >> k;

  int dp[1010][1010] = {};

  for(int i = 0;i < k;i++){
    dp[n][i] = 1;
  }

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

  int ans = 0;

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

  cout << ans << endl;

  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) { if (b == 0) return a; else return GCD(b, a % b); }
template<class T>
T LCM(T a, T b) { return a / GCD(a, b) * b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

int main() {
	int sx, sy, tx, ty;
	cin >> sx >> sy >> tx >> ty;

	// 一回目-行き
	for (int i = 0; i < ty - sy; ++i) cout << "U";
	for (int i = 0; i < tx - sx; ++i) cout << "R";

	// 一回目-帰り
	for (int i = 0; i < ty - sy; ++i) cout << "D";
	for (int i = 0; i < tx - sx; ++i) cout << "L";

	// 二回目-行き
	cout << "L";
	for (int i = 0; i < ty - sy + 1; ++i) cout << "U";
	for (int i = 0; i < tx - sx + 1; ++i) cout << "R";
	cout << "D";

	// 二回目-帰り
	cout << "R";
	for (int i = 0; i < ty - sy + 1; ++i) cout << "D";
	for (int i = 0; i < tx - sx + 1; ++i) cout << "L";
	cout << "U";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>    
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll n, d, x[10][10];
string str;

bool isint(ll num){
	for(ll i = 1; i*i <= 40*40*10; i++){
		if(i*i == num){
			return true;
		}
	}
	return false;
}

int main(){
	cin >> n >> d;
	for(ll i = 0; i < n; i++){
		for(ll di = 0; di < d; di++){
			cin >> x[i][di];
		}
	}
	
	ll ans = 0;
	for(ll i = 0; i < n; i++){
		for(ll j = 0; j < i; j++){
			ll dd = 0;
			for(ll di = 0; di < d; di++){
				dd += (x[i][di]-x[j][di])*(x[i][di]-x[j][di]);
			}
			if(isint(dd)){ans++;}
		}
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<math.h>
#define ll long long
#define fi first
#define se second
#define ld long double
#define mod 1000000007
using namespace std;
int main()
{
     ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
ll N,W,i,j;
cin>>N>>W;
vector<ll>val(N+1),wt(N+1);
for(i=1;i<=N;i++)
{
    cin>>wt[i]>>val[i];
}
ll v[N+1][W+1];
for(i=0;i<=N;i++)
{
    for(j=0;j<=W;j++)
    {
        if(i==0 || j==0)
            v[i][j]=0;
        else if(j>=wt[i])
        {
            v[i][j]=max(val[i]+v[i-1][j-wt[i]],v[i-1][j]);
        }
        else
            v[i][j]=v[i-1][j];
    }
}
cout<<v[N][W];
}



Measured memory_bytes: 79232
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

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

from decimal import Decimal

a,b,x = II()

p = x*(math.ceil(Decimal(a)/Decimal(x)))
q = x*(math.floor(Decimal(b)/Decimal(x)))

if p>b or q<a or p>q:
  print(0)
else:
  print((q-p)//x+1)

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

using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;

const ll linf = 1LL << 62;
const int inf = 99999999;
const int dx[4] = { 1,0,-1,0 };
const int dy[4] = { 0,1,0,-1 };
const ll atcoder = 1e9 + 7;

#define Endl endl
#define mp make_pair
#define all(v) v.begin(),v.end()
#define pb push_back
#define pr(x) cout << x << endl
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
#define rep(i,n) for(int i= 0;i<n;i++)
#define FOR(i,a,b) for(int i = a;i<b;i++)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll gcd(ll a, ll b) {//最大公約数
	if (a < b)swap(a, b);
	if (a%b == 0)return b;
	else gcd(b, a%b);
}

ll lcm(ll a, ll b) {//最小公倍数
	if (a < b)swap(a, b);
	return (a / gcd(a, b))*b;
}

int main() {

	int a, b;
	cin >> a >> b;
	string s;
	int cnt = 0;

	for (int i = a; i <= b; i++) {
		s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3])cnt++;
	}

	pr(cnt);

	//system("pause");
	return 0;
}



Measured memory_bytes: 256
#まだ自信をもっと答えられないんだよな
#掛け算じゃなくて最小公倍数や
#デバッグの後消す
import fractions
a,b,c,d=[int(i) for i in input().split()]
c1=b//c-a//c
if a%c==0:
    c1+=1
d1=b//d-a//d
if a%d==0:
    d1+=1
cd1=b//(c*d//fractions.gcd(c,d))-a//(c*d//fractions.gcd(c,d))
if a%(c*d)==0:
    cd1+=1
#print(c1)
#print(d1)
#print(cd1)
print(b-a+1-c1-d1+cd1)
#役立つhttps://qiita.com/chun1182/items/ddf2b6cba932b2bb0d4e


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

int main() {
    int a,b,p=0,ans=0;
    cin>>a>>b;
    if(((a*4)<b) || ((a*2)>b))
    {
        cout<<"No"<<endl;
        return 0;
    }
    if((a*4)==b)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    if((a*2)==b)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
    for(int i=1;i<a;i++)
    {
        int t;
        t = b - (i*2);
        if(t%4==0)
        {
            p = t/4;
        }
        if(p+i==a)
        {
            ans=1;
            break;
        }
    }
    if(ans)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3628
#include<algorithm>//sort(all(変数),greater<型名>())　で降順に
#include<cmath>//切り上げceil(値)
#include<deque>
#include<iomanip>//setprecision(数字)
#include<iostream>
#include<list>
#include<map>
#include<numeric> //xとyの最大公約数は__gcd(x,y),xとyの最小公倍数は(x*y)/__gcd
#include<queue>//priority_queue<型名> 変数：優先度付きキュー　最大値の探索が早い
#include<set>
#include<stack>
#include<string>
#include<vector>

#include<bits/stdc++.h>
#include<cstdio>
#include<cstdlib>
#include<tuple>
#include<utility>
#define rep0(i,n)  for(ll i=0; i<n; i++)
#define rrep0(i,n) for(ll i=n-1; 0<=i; i--)
#define rep1(i,n)  for(ll i=1; i<=n; i++)
#define rrep1(i,n) for(ll i=n; 1<=i; i--)
#define vll vector<ll>
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  ll n;  cin >> n;
  vll l(n);
  rep0(i,n){
    cin >> l[i];
  }
  sort(all(l));

  ll ans = 0;
  rep0(i,n-2){
    for(int j = i+1; j < n-1; j++){
      for(int k = j+1; k < n; k++){
        if(l[i] + l[j] <= l[k]){
          break;
        }else{
          ans++;
        }
      }
    }
  }
  cout << ans;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int k, x;
    cin >> k >> x;
    
    int sum = 500*k;
    if (sum>=x)
    {
    cout << "Yes" <<endl;
    }
    else
    {
    cout << "No" <<endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <utility>
#include <stdio.h>
#include <algorithm>
using namespace std;
int main()
{
	int n,r,l,ans[100001]={},score[100001]={};
	cin>>n>>r>>l;
	int last=0;
	int m=0;//????????£????????§?????????????????£?????????????????????ID
	for(int i=0;i<r;i++){
		int d,t,x;
		cin>>d>>t>>x;
		score[--d]+=x;
		if(x>=0){
			if((score[d]>score[m])||((score[d]==score[m])&&d<m)){
				ans[m]+=t-last;
				last=t;
				m=d;
			}
		}else if(m==d){
			int tmp=m;
			for(int j=0;j<n;j++)if(score[j]>score[tmp]||((score[j]==score[tmp])&&j<tmp))tmp=j;
			if(m!=tmp){
				ans[m]+=t-last;
				last=t;
				m=tmp;
			}
		}
	}
	ans[m]+=l-last;
	int res1=0,res2=0;
	for(int i=0;i<n;i++){
		if(res1<ans[i]){
			res1=ans[i];
			res2=i;
		}
	}
	res2++;
	cout<<res2<<endl;
	return 0;
}

Measured memory_bytes: 1948
ans = 0

def main():
    n = int(input())
    lst = list(map(int,input().split()))

    all_lst=[lst]
    make_lst(all_lst)
    print(ans)


def minus(lst):
    m = min(lst)
    global ans
    ans+=m
    return list(map(lambda x: x-m, lst))

def make_lst(all_lst):
    #tmp =0

    for lst in all_lst:
        #tmp +=1
        #if tmp >= 20:
        #    print(all_lst)
        #    exit()

        if lst != []:
            lst = minus(lst)
        lst = " ".join(map(str,lst)).split(" 0")
        for i in lst:
            if i.split() != []:
                sp_list = list(map(int,i.split()))
                if 0 in sp_list:
                    sp_list.remove(0)

                all_lst.append(sp_list)


if __name__ == "__main__":
        main()


Measured memory_bytes: 3064
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var x = cin.nextInt();
            var t = cin.nextInt();

            Console.WriteLine(Math.Max(0,x-t));
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 11092
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var num = Input.num;
        var NUM = 55556;
        var bo = new bool[NUM];
        var list = new List<int>();
        for(var i=2;i<NUM;i++)
            if (!bo[i])
            {
                if (i % 5 == 1 && list.Count != num) list.Add(i);
                for (var j = 2 * i; j < NUM; j += i)
                    bo[j] = true;
            }
        WriteLine(string.Join(" ", list));
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public  
static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


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

ll solve() {
    int N;
    cin >> N;
    vector<vector<int>> A(N, vector<int>(N));
    string s;
    for ( int i = 0; i < N; i++ ) {
        cin >> s;
        for ( int j = 0; j < N; j++ ) {
            A[i][j] = s[j] == '#' ? 1 : 0;
        }
    }
    ll bc = 0, br = 0;
    vector<int> nc(N), nr(N);
    for ( int j = 0; j < N; j++ ) {
        for ( int i = 0; i < N; i++ ) {
            nc[j] += A[i][j];
        }
        if ( nc[j] == N ) bc++;
    }
    if ( bc == N ) return 0;
    bool h = false;
    for ( int j = 0; j < N; j++ ) {
        if ( nc[j] > 0 ) h = true;
    }
    if ( !h ) return -1;

    for ( int i = 0; i < N; i++ ) {
        for ( int j = 0; j < N; j++ ) {
            nr[i] += A[i][j];
        }
        if ( nr[i] == N ) br++;
    }
    if ( br > 0 ) return N - bc;

    int mnr = N;
    for ( int i = 0; i < N; i++ ) {
        int nrc = N - nr[i];
        if ( nc[i] == 0 ) nrc++;
        mnr = min(mnr, nrc);
    }
    return mnr + N - bc;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	ll s,w; cin >> s >> w;
	if(s <= w) puts("unsafe");
	else puts("safe");
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <bits/stdc++.h>
#define ll long long
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

using namespace std;

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }

int main(){
    int K,A,B; cin >> K >> A >> B;

    for (int i = A; i <= B; i++)
    {
      if(i%K == 0) {
        cout << "OK" << endl;
        return 0;
      }
    }
    

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


Measured memory_bytes: 3564
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
template<int MOD> struct ModInt {
    static const int Mod = MOD; unsigned x; ModInt() : x(0) { }
    ModInt(signed sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    ModInt(signed long long sig) { x = sig < 0 ? sig % MOD + MOD : sig % MOD; }
    int get() const { return (int)x; }
    ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
    ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
    ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }
    ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
    ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
    ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
    ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }
    ModInt inverse() const { long long a = x, b = MOD, u = 1, v = 0;
        while (b) { long long t = a / b; a -= t * b; std::swap(a, b); u -= t * v; std::swap(u, v); }
        return ModInt(u); }
    bool operator==(ModInt that) const { return x == that.x; }
    bool operator!=(ModInt that) const { return x != that.x; }
    ModInt operator-() const { ModInt t; t.x = x == 0 ? 0 : Mod - x; return t; }
};
template<int MOD> ostream& operator<<(ostream& st, const ModInt<MOD> a) { st << a.get(); return st; };
template<int MOD> ModInt<MOD> operator^(ModInt<MOD> a, unsigned long long k) {
    ModInt<MOD> r = 1; while (k) { if (k & 1) r *= a; a *= a; k >>= 1; } return r; }
typedef ModInt<1000000007> mint;

string K; int D, N;
mint dp[10101][101][2];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> K >> D;
    int N = K.length();

    dp[0][0][0] = 1;
    rep(dgt, 0, N) rep(d, 0, D) rep(isless, 0, 2) {
        int c = K[dgt] - '0';
        rep(nxt, 0, 10) {
            if (nxt < c) dp[dgt + 1][(d + nxt) % D][1] += dp[dgt][d][isless];
            else if(nxt == c) dp[dgt + 1][(d + nxt) % D][isless] += dp[dgt][d][isless];
            else {
                if(isless) dp[dgt + 1][(d + nxt) % D][isless] += dp[dgt][d][isless];
            }
        }
    }

    cout << dp[N][0][0] + dp[N][0][1] - 1 << endl;
}


Measured memory_bytes: 8192