akhauriyash/Code-Regression huggingface dataset:
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%d",&a)
#define sf2(a,b) scanf("%d %d",&a,&b)
#define sf3(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pf2(a,b) printf("%d %d",a,b)
#define pf3(a,b,c) printf("%d %d %d",a,b,c)
#define sfl(a) scanf("%lld",&a)
#define sfl2(a,b) scanf("%lld %lld",&a,&b)
#define sfl3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pfl(a) printf("%lld",a)
#define pfl2(a,b) printf("%lld %lld",a,b)
#define pfl3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
#define tz 100000
#define clr0(a) memset(a,0,sizeof(a))
#define clr1(a) memset(a,-1,sizeof(a))
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
const int N = 1e7+9;
int ar[N], n;
main()
{
    timesave;
    ll ans=0;
    for(ll i = 1; i <= N; ++i)
        for(ll j = i; j <= N; j += i)
            ar[j]++;
    cin>>n;
    for(ll i = 1; i <= n; ++i)
        ans += i * 1ll * ar[i];
    cout<<ans<<endl;
}




Measured memory_bytes: 42704
N = int(input())
A = [input() for i in range(N)]
A = list(map(int, A))
A.sort()
count = 0
ans = 0
i = 0
while i < N:
    target = A[i]
    j = i
    while j < N:
        if target == A[j]:
            count += 1
            i += 1
            j += 1
        else:
            break
    if count % 2 == 1:
        ans += 1
    count = 0
print(ans)

Measured memory_bytes: 14236
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
int n;
pair<long long,long long> arr[100001];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for (int i=0;i<n;i++){
        long long x,l;
        cin>>x>>l;
        arr[i]=mp(x+l,x-l+1);
    }
    sort(arr,arr+n);
    long long prevend=-1e15,counter=0;
    for (int i=0;i<n;i++){
        //cout<<arr[i].first<<' '<<arr[i].second<<'\n';
        if (arr[i].second>prevend){
            counter++;
            prevend=arr[i].first;
        }
    }
    cout<<counter;
}

Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
using namespace std;
char a[100005];
int len,cnt;
int main()
{
	scanf("%s",a+1);len=strlen(a+1);
	for(int i=2;i<=len;++i) if(a[i]!=a[i-1]) ++cnt;printf("%d\n",cnt);
	return 0;
}

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

using namespace std;

using ll = long long;

void dfs(int cur, const vector< vector<int> >& g, vector<int>& c) {
    for (const int nex : g[cur]) {
        if (c[nex] != -1) continue;
        c[nex] = 1 - c[cur];
        dfs(nex, g, c);
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector< vector<int> > g(n);
    for (int i = 1; i < n; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    vector<int> c(n, -1);
    c[0] = 0;
    dfs(0, g, c);

    vector<int> cnt(2, 0);
    for (int i = 0; i < n; ++i) {
        ++cnt[c[i]];
    }

    vector<int> hoge(n, 0);
    for (int i = 0; i < n; ++i) {
        hoge[i] = 1 + g[i].size();
        for (int j : g[i]) {
            hoge[i] += (int)g[j].size() - 1;
        }
        //cerr << i + 1 << ": " << hoge[i] << endl;
    }

    vector<int> ans(n);
    auto print = [&]() {
        for (int i = 0; i < n; ++i) {
            cout << ans[i] << " \n"[i + 1 == n];
        }
    };

    vector<int> val;
    if (cnt[0] < cnt[1]) {
        if (cnt[0] <= n / 3) {
            int foo = 1;
            int bar = 3;
            for (int i = 0; i < n; ++i) {
                if (c[i] == 0 || foo > n) {
                    ans[i] = bar;
                    bar += 3;
                } else {
                    ans[i] = foo;
                    if (foo % 3 == 1) ++foo;
                    else foo += 2;
                }
            }
            print();
            return 0;
        }
        val = {3, 2, 1};
    } else {
        if (cnt[1] <= n / 3) {
            int foo = 1;
            int bar = 3;
            for (int i = 0; i < n; ++i) {
                if (c[i] == 1 || foo > n) {
                    ans[i] = bar;
                    bar += 3;
                } else {
                    ans[i] = foo;
                    if (foo % 3 == 1) ++foo;
                    else foo += 2;
                }
            }
            print();
            return 0;
        }
        val = {3, 1, 2};
    }

    for (int i = 0; i < n; ++i) {
        if (val[c[i] + 1] > n) {
            if (val[0] > n) {
                cout << -1 << "\n";
                return 0;
            }
            ans[i] = val[0];
            val[0] += 3;
        } else {
            ans[i] = val[c[i] + 1];
            val[c[i] + 1] += 3;
        }
    }
    print();

    return 0;
}

Measured memory_bytes: 20992
N = int(input())
H = list(map(int, input().split()))

flag = 0
H[0] -= 1
for i in range(1, N):
    if H[i - 1] < H[i]:
        H[i] -= 1
    if H[i - 1] > H[i]:
        flag = 1
        break

if flag == 0:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 14396
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int cnt=0;
  string s;
  cin>>s;
  rep(i,s.size())if(s[i]=='1')cnt++;
  cout<<cnt<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int Digit_Count(int n) {
	int Tmp = n, Count = 0;
	while (Tmp) {
		Count += Tmp % 10;
		Tmp /= 10;
	}
	return Count;
}

signed main() {
	int n, Ans = INF;
	cin >> n;
	for (int i = 1; i < n; i++) {
		Ans = min(Ans, Digit_Count(i) + Digit_Count(n - i));
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ABC050C
N = int(input())
a = [int(i) for i in range(-(N%2-1), N, 2)] 
if sum(list(map(int, input().split()))) == sum(a)*2:
    D = 10**9+7
    print(2**(N//2)%D)
    
else:
    print(0)

Measured memory_bytes: 15860
def dfs(i,edge):
    if vis[i]==True:
        return
    vis[i]=True
    for j in edge[i]:
        dfs(j,edge)

N,M=map(int,input().split())
ab=[[0,0] for _ in range(M)]
for i in range(M):
    a,b=map(int,input().split())
    ab[i][0],ab[i][1]=a,b
ans=0
for i in range(M):
    edge=[[] for _ in range(N+1)]
    for j in range(M):
        if j!=i:
            edge[ab[j][0]].append(ab[j][1])
            edge[ab[j][1]].append(ab[j][0])
    vis=[False]*(N+1)
    vis[0]=True
    dfs(1,edge)
    if False in vis:
        ans+=1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int h[n];
  for(int i=0;i<n;i++)
    cin>>h[i];
  int ans[n];
  ans[0]=0;
  ans[1]=abs(h[0]-h[1]);
  for(int i=2;i<n;i++)
    ans[i]=min(abs(h[i]-h[i-1])+ans[i-1],ans[i-2]+abs(h[i]-h[i-2]));
  cout<<ans[n-1];
               
}


Measured memory_bytes: 4372
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

int n, k;
int a[100003];
int s[100003];

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

	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);

		if (i == 1)
		{
			s[i] = 0;
		}

		if (i != 1)
		{
			int res = 1000000007;

			for (int j = 1; j <= k; j++)
			{
				if (i == j) break;
				res = min(res, s[i - j] + abs(a[i - j] - a[i]));
			}

			s[i] = res;
		}
	}

	printf("%d", s[n]);

	return 0;
}


Measured memory_bytes: 1024
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
//#include <utility>
#include <set>
#include <iostream>
//#include <memory>
#include <string>
#include <vector>
#include <algorithm>
//#include <functional>
#include <sstream>
//#include <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;

void mainmain(){
	int n;
	while(cin>>n,n){
		ll ans=0;
		rep(i,n){
			int a,b,c,d;
			cin>>a>>b>>c>>d;
			int M=a+b+c;
			if(160<M||d>25) continue;
			if(140<M||d>20) ans+=1600;
			else if(120<M||d>15) ans+=1400;
			else if(100<M||d>10) ans+=1200;
			else if(80<M||d>5) ans+=1000;
			else if(60<M||d>2) ans+=800;
			else ans+=600;
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

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

using lint = long long;
using pint = pair<int, int>;
using plint = pair<lint, lint>;

constexpr lint INF = 1'010'000'000'000'000'017LL;
constexpr lint MOD = 1'000'000'007LL;
constexpr double EPS = 1e-12;
constexpr double PI = 3.14159265358979323846;

#define FOR(i, start, end) for(lint i = (start); i < end; i++)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }

lint mod(lint val, lint m){ lint res = val % m; if(res < 0) res += m; return res;}
lint modinv(lint a, lint m) { lint b = m, u = 1, v = 0; while (b) { lint t = a / b; a -= t * b; swap(a, b); u -= t * v; swap(u, v); } u %= m; if (u < 0) u += m; return u;}
lint modpow(lint a, lint n, lint mod) { lint res = 1; while (n > 0) { if (n & 1) res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
lint gcd(lint a, lint b){ if(a < b) swap(a, b); if(b == 0) return a; return gcd(b, a%b);}
lint lcm(lint a, lint b){ return a * b / gcd(a, b);}


//---------------------------------------------------------------

void Main()
{
    lint ans, N;
    cin >> N;
    vector<lint> L(N);
    REP(i, N){
        cin >> L[i];
    }
    sort(ALL(L));

    ans = 0;
    FOR(i, 0, N){
        FOR(j, i+1, N){
            FOR(k, j+1, N){
                if(L[i] + L[j] > L[k]){
                    ans ++;
                }else{
                    break;
                }
            }
        }
    }

    cout << ans << endl;
}

//---------------------------------------------------------------
int main()
{
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>

using namespace std;

const int MAXN = 100010;
typedef long long ll;

int n, m;

inline int add(int x, int y){return (x+=y)>=m?x-m:x;}
inline int mul(int x, int y){return 1ll*x*y%m;}

struct edge{
	int next, to;
	edge(int N=0,int T=0):next(N),to(T){}
}e[MAXN<<1];
int fir[MAXN], num = 0;
inline void join(int a, int b)
{
	e[++num].next = fir[a];
	fir[a] = num;
	e[num].to = b;
}

int f[MAXN], g[MAXN], ans[MAXN], pre[MAXN], suf[MAXN], t[MAXN], in[MAXN]; 

void dfs1(int u, int fa)
{
	int cnt = 0;
	f[u]    = 1;
	for(int i=fir[u]; i; i=e[i].next)
	{
		int v = e[i].to;
		if(v == fa) continue;
		dfs1(v, u);
		f[u] = mul(f[u], add(f[v], 1));
	}
	for(int i=fir[u];i;i=e[i].next)
		if(e[i].to!=fa)in[++cnt] = e[i].to;
	pre[0] = suf[cnt+1] = 1;
	for(int i=1; i<=cnt; i++)
		pre[i] = mul(pre[i-1], add(f[in[i]], 1));
	for(int i=cnt; i>=1; i--)
		suf[i] = mul(suf[i+1], add(f[in[i]], 1));
	for(int i=1; i<=cnt; i++)
		t[in[i]] = mul(pre[i-1], suf[i+1]);
}
void dfs2(int u, int fa)
{
	int cnt = 0;
	for(int i=fir[u]; i; i=e[i].next)
	{
		int v = e[i].to;
		if(v == fa)continue;
		++cnt;
		g[v] = add(mul(g[u], t[v]), 1);
		ans[v] = mul(g[v], f[v]);
		dfs2(v, u);
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b;i<n;i++)
		scanf("%d%d",&a,&b), join(a, b), join(b, a);
	dfs1(1, 0);
	g[1] = 1; ans[1] = f[1];
	dfs2(1, 0);
	for(int i=1;i<=n;i++)
		printf("%d\n" ,ans[i]);
	return 0;
}

Measured memory_bytes: 8064
import scala.io.StdIn.{readInt, readLine}
object Main {
    def main(args: Array[String]): Unit = {
        val n = readInt;
        val pre = readLine.split(" ").map(_.toInt);
        val in = readLine.split(" ").map(_.toInt);
        val tree = Tree();
        tree.build(n, pre, in);
        println(tree.postorder().mkString(" "));
    }
}

case class Tree() {
    case class TreeNode(value: Int, left: TreeNode, right: TreeNode);
    var root: TreeNode = null;
    
    def preorder(): List[Int] = {
        def _preorder(node: TreeNode, ret: List[Int]): List[Int] = {
            if (node == null) {
                ret;
            } else {
                val ret1 = node.value :: ret;
                val ret2 = _preorder(node.left, ret1);
                val ret3 = _preorder(node.right, ret2);
                ret3;
            }
        }
        _preorder(root, Nil).reverse;
    }
    
    def postorder(): List[Int] = {
        def _preorder(node: TreeNode, ret: List[Int]): List[Int] = {
            if (node == null) {
                ret;
            } else {
                val ret1 = _preorder(node.left, ret);
                val ret2 = _preorder(node.right, ret1);
                val ret3 = node.value :: ret2;
                ret3;
            }
        }
        _preorder(root, Nil).reverse;
    }
    
    def build(size: Int, pre: Array[Int], in: Array[Int]): Unit = {
        // pre の index を示すポインタ
        //  pre(prePtr) を value にもつノードが生成されたときにインクリメントする。
        var prePtr = 0
        def buildSubTree(lip: Int, rip: Int): TreeNode = {
            if (lip > rip) {
                // 探索するノードが存在しない場合はnullを返す
                null;
            } else if (lip == rip) {
                //  探索するノードが1つしかない場合は、子ノードが null の部分木を返す
                val value: Int = pre(prePtr);
                prePtr += 1;
                TreeNode(value, null, null);
            } else {
                val value: Int = pre(prePtr);
                val pivot: Int = (lip to rip).find(i => in(i) == value).get; // 無いわけない
                prePtr += 1;
                //println(s"[${value}]  prePtr : ${prePtr}");
                //if (lip == pivot) println(s"[${value}]  left: null") else println(s"[${value}]  left: " + (lip to pivot - 1).map(in(_)).mkString(" "));
                val leftSubTree = buildSubTree(lip, pivot - 1);
                //if (rip == pivot) println(s"[${value}]  right: null") else println(s"[${value}]  right: " + (pivot + 1 to rip).map(in(_)).mkString(" "));
                val rightSubTree = buildSubTree(pivot + 1,  rip);
                TreeNode(value, leftSubTree, rightSubTree);
            }
        }
        root = if (size < 1) null else {buildSubTree(0, size - 1)};
    }
}



Measured memory_bytes: 44052
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * Bus Line
 */
public class Main {

	// 15 stations
	final static int[] route = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 3, 2, 1 };

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line = "";

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = Integer.parseInt(line);
			int s, g, step1, step2;

			for (int i = 0; i < n; ++i) {
				line = br.readLine();
				s = Integer.parseInt(line.substring(0, line.indexOf(' ')));
				g = Integer.parseInt(line.substring(line.indexOf(' ') + 1));

				step1 = 0;
				step2 = Integer.MAX_VALUE;

				StringBuilder sb1 = new StringBuilder();
				StringBuilder sb2 = new StringBuilder();
				for (int j = s;; j++) {
					if (j > 14) {
						j -= 15;
					}
					++step1;
					sb1.append(route[j] + " ");
					if (route[j] == g) {
						break;
					}
				}
				if (s <= 5) {
					s = 15 - s;
					step2 = 0;
					for (int j = s;; j++) {
						if (j > 14) {
							j -= 15;
						}
						++step2;
						sb2.append(route[j] + " ");
						if (route[j] == g) {
							break;
						}
					}
				}
				if (step1 <= step2) {
					System.out.println(sb1.substring(0, sb1.length() - 1)
							.toString());
				} else {
					System.out.println(sb2.substring(0, sb2.length() - 1)
							.toString());
				}
			}
		}

	}
}

Measured memory_bytes: 16872
#####################
#複数の最小公倍数lcm
#####################
from fractions import gcd
def Lcm(list):
  L = 1
  for a in list:
    L = (a // gcd(a, L))*L
  return L
n= int(input())
A = [int(input()) for i in range(n)]
print(Lcm(A))

Measured memory_bytes: 5048
#include<bits/stdc++.h>
#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)
using namespace std;
int n,a,ans;map<int,int>m;
main(){
    scanf("%d",&n);
    rpt(n)scanf("%d",&a),++m[a];
    for(map<int,int>::iterator i=m.begin();i!=m.end();++i){
        pair<int,int>now=*i;if(now.first>now.second)ans+=now.second;else ans+=now.second-now.first;
    }
    printf("%d\n",ans);
}

Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define maxi 1e18
#define pll pair<ll,ll>
map<ll,ll> pos,pos1;
int main(){
   /*ll a,b;
    cin>>a>>b; ll giv=a;
    ll ans=1;
    if(a>b){
        cout<<ans;
    }

    else{
        while(giv<b){
            giv+=a-1;
            ans++;
        }
        cout<<ans;
    }*/
    ll n,i,ans=-1,cur=0;
    cin>>n;
    ll a[n];
    for(i=0;i<n;i++)cin>>a[i];
    ll step=1;
    for(i=0;i<n-1;i++){
        if(a[i]<a[i+1]){
            ans=max(ans,step);
            step=1;//cnt=0;
        }
        else{
            //if(a[i]==a[i+1])cur++;
            step++;
        }

        //cout<<step<<endl;
    }
    ans=max(ans,step);
    cout<<ans-1;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
using namespace std;

ll r;

int main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(0);

    cin >> r;
    cout << 3LL*r*r;

    return 0;
}


Measured memory_bytes: 256
import itertools
n, m = map(int, input().split())
kss = []

for mm in range(m):
  ks = list(map(int, input().split()))
  k = ks[0]
  s = ks[1:]
  kss.append(s)
ps = list(map(int, input().split()))

ok_count = 0
combs = [[0,1]]*n
for state in itertools.product(*combs):
  ok = True
  for mm in range(m):
    sm = 0
    for s in kss[mm]:
      sm += state[s-1]
    if sm % 2 != ps[mm]:
      ok = False
      break
  if ok:
    ok_count += 1
print(ok_count)


Measured memory_bytes: 3064
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;

//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int H, N;

  cin >> H >> N;
  int sum = 0;
  for(int i = 0 ; i < N ; i++){
  	int a;
  	cin >> a;
  	sum += a;
  }

  if(sum >= H){
  	cout << "Yes" << endl;
  }
  else{
  	cout << "No" << endl;
  }
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(a) (a).begin(), (a).end()
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);

void solve(){
    int k, x;
    cin >> k >> x;
    if(500*k >= x) {
        cout<< "Yes" << "\n";
    }
    else{
        cout << "No" << "\n";
    }
}

int main()
{
    solve();
    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a % 3 == 0 or b % 3 == 0 or (a + b) % 3 == 0 ? "Possible" : "Impossible") << endl;
}


Measured memory_bytes: 3560
#include <cstdio>
#include <iostream>
#include <string>
#define BUFMAX 100001
int main(int argc , char**argv)
{
	(void)argc;
	(void)argv;
	char buf[BUFMAX] = {};
	scanf("%s",buf);
	char c;
	for(c='a'; c<='z'; c++)
	{
		bool find = false;
		for(int p=0;p<BUFMAX;p++){
			if (buf[p]==c){find = true;break;}
		}
		if (find == false){break;} // 行末まで見つからなかった。
	}
	if (('a'<=c)&&(c<='z')){printf("%c\n",c);}else{printf("None\n");}

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define rep2(x,from,to) for(long long x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
#define INF 1000000000
#define N 1111
long long dp[N+4];
long long n;
long long ans;
int main()
{
	rep(i,N)
	{
		dp[i]=i*i*i;
	}
	while(1)
	{
		cin>>n;
		if(n==0)break;
		long long k=n*n*n;
		ans=0;
		rep2(i,1,n)
		{
			long long t=(long long)(lower_bound(dp,dp+N,k-i*i*i)-dp);
			//cout<<t<<"sss"<<endl;
			ans=max(ans,dp[t-1]+i*i*i);
		}
		cout<<k-ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner cin = new Scanner(System.in);
        int N = cin.nextInt();
        String[] s = new String[N];
        for (int i = 0; i < N; i++) {
            s[i] = cin.next();
        }

        int M = cin.nextInt();
        String[] t = new String[M];
        for (int i = 0; i < M; i++) {
            t[i] = cin.next();
        }

        Map<String, Integer> map = new HashMap<>();

        for (int i = 0; i < N; i++) {
            int x = map.getOrDefault(s[i], 0);
            map.put(s[i], x + 1);
        }

        for (int i = 0; i < M; i++) {
            int x = map.getOrDefault(t[i], 0);
            map.put(t[i], x - 1);
        }

        int max = 0;
        for (int v : map.values()) {
            max = Math.max(v, max);
        }

        System.out.println(max);
    }
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define int long long
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)3e3+5;
int a[maxn],b[maxn],dp[2][maxn][maxn];
signed main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,t;cin>>n>>t;
    rep(i,1,n)cin>>a[i]>>b[i];
    rep(i,1,n)rep(j,1,t){
        dp[0][i][j]=(j>=a[i]?max(dp[0][i-1][j],dp[0][i-1][j-a[i]]+b[i]):dp[0][i-1][j]);
    }
    rep(i,1,n)rep(j,1,t){
        dp[1][i][j]=(j>=a[n-i+1]?max(dp[1][i-1][j],dp[1][i-1][j-a[n-i+1]]+b[n-i+1]):dp[1][i-1][j]);//debug(dp[1][i][j]);
    }
    int ans=0;
    rep(i,1,n)rep(j,0,t-1){
        ans=max(ans,b[i]+dp[0][i-1][j]+dp[1][n-i][t-1-j]);
        //if(ans==90){debug(i),debug(j),debug(dp[0][i][j]),debug(dp[1][n-i+1][t-1-j]);}
    }
    cout<<ans<<endl;
    //debug(dp[0][n][t]);
}
/* 
时间背包 
时间和价值
时间获得一定的价值，t秒内能获得最大的价值. 最后一样东西可以超出t. 
all:[1,3000]
ana 做一个6000的背包？
枚举最后一个物品？ 不能保证最优  枚举最后一个，对剩下的做背包，可以保证正确性，N^3
状态里要存限制？
qscqesze饭卡问题 

dp[0][i][j] 前i个物品拿重量为j的最大价值
dp[1][i][j] 后i个物品拿重量为j的最大价值
ans=for i for j max(dp[0][i][j]+dp[1][n-i+1][t-1-j])

sol2: 时间最长的在最后不会更坏
wr
not 代码问题，样例问题
a[n-i+1]:一个地方改了，其它所有都要改。 后来加的也要改。
背包不优化，第二维 要判>=a[i]?

2 60
10 10
100 100

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

int main(){
  int n, t;
  cin >> n >> t;
  vector<vector<int>> dp(t, vector<int>(2,0));
  for(int i=0; i<n; ++i){
    int a, b;
    cin >> a >> b;
    for(int j=t-1; j>=0; --j){
      dp[j][0] = max(dp[j][0], dp[j][1]+b);
      if(j>=a)dp[j][0] = max(dp[j][0], dp[j-a][0]+b);
      if(j>=a)dp[j][1] = max(dp[j][1], dp[j-a][1]+b);
    }
  }
  cout << dp[t-1][0] << endl;
}

 */

Measured memory_bytes: 141312
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
typedef long long int ll;
typedef pair<pair<int,int>,int> t;
#define mt(i,j,k) make_pair(make_pair((i),(j)),(k))
int n,m,k;
map<t,int> memo;
int dfs(int nRest, int dest){
  if(nRest*m<dest) return 0;
  if(nRest==1) return (1<=dest&&dest<=m?1:0);
  int &res=memo[mt(m,nRest,dest)];
  if(res!=0)return res;
  for(int i=1;i<=min(m,dest-1);i++){
    res+=dfs(nRest-1,dest-i);
  }
  return res;
}
void solve(){
  ll sum=0;
  for(int i=n;i<=n*m;i++)
    sum+=dfs(n,i)*max(1,i-k);
  printf("%.8lf\n",(double)sum/pow(m,n));
}
int main(){ _;
  while(cin>>n>>m>>k,(n|m|k)!=0){
    solve();
  }
}

Measured memory_bytes: 1472
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	
	int count=0;
	int i;
	
	for(i=a;i<=b;i++){
		if(c%i==0)count++;
	}
	
	printf("%d\n",count);
	return 0;
}

Measured memory_bytes: 596
use std::io;
use std::io::BufRead;

fn main() {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    
    let (a,b) = {
        let mut n = String::new();
        stdin.read_line(&mut n).unwrap();
        let mut input = n.trim().split_whitespace();
        (
            input.next().unwrap().parse::<i32>().unwrap(),
            input.next().unwrap().parse::<i32>().unwrap(),
        )
        
    };

    let m = {
        let m = if a+b > a-b { a+b } else { a-b };
        if m > a*b { m } else { a*b }
    };

    println!("{}", m);
}


Measured memory_bytes: 4352
import itertools
import math
def distance(a,b,c,d):
    return ((a-c)**2 + (b-d)**2)**0.5
n = int(input())
x = [list(map(int,input().split())) for i in range(n)]
seq = [i for i in range(n)]
dis = 0
for s in list(itertools.permutations(seq)):
    for i in range(n-1):
        dis = dis + distance(x[s[i]][0],x[s[i]][1],x[s[i+1]][0],x[s[i+1]][1])
print(dis/math.factorial(n))

Measured memory_bytes: 8100
A,B,C=map(int,input().split())
count=0
if A==B==C and A%2==0:
    print(-1)
    exit()
while A%2==0 and B%2==0 and C%2==0:
    A,B,C=B//2+C//2,A//2+C//2,B//2+C//2
    count+=1
print(count)


Measured memory_bytes: 38384
import sys
# from math import sqrt, gcd, ceil, log
from bisect import bisect_left
from collections import defaultdict, Counter
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))

# sys.setrecursionlimit(10**6)



def solve():
	s = inp(); t = inp(); ans = 0
	for i in range(len(s)):
		ans += (s[i] != t[i])
	print(ans)


		

if __name__ == "__main__":
	solve()

Measured memory_bytes: 9796
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    int h, w; cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    vector<string> ans;
    rep(i,h){
        bool removed = true;
        rep(j,w){
            if(s[i][j] == '#') removed = false;
        }
        if(removed) continue;
        //cout << s[i] << endl;
        ans.push_back(s[i]);
    }
    rep(j,w){
        bool removed = true;
        rep(i,ans.size()){
            if(ans[i][j] == '#')removed = false;
        }
        if(removed) {
            rep(i, ans.size()){
                ans[i][j] = '*';
            }
        }
    }
    rep(i,ans.size()){
        rep(j,w){
            if(ans[i][j] == '*')continue;
            cout << ans[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int n;
    while (true) {
        int count = 0;
        cin >> n;
        if (cin.eof()) {
            return 0;
        }
        for (int i=0; i<10; i++) {
            for (int j=0; j<10; j++) {
                for (int k=0; k<10; k++) {
                    int d = n-i-j-k;
                    if (0 <= d && d < 10) {
                        count++;
                    }
                }
            }
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
using namespace std;
using ll = long long;
using ld = long double;
template<class T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

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

  for(ll A=0;A<=1000;A++){
    ll A5=A*A*A*A*A;
    ll B5=A5-X;
    for(ll B=-1000;B<=1000;B++){
      ll tmp=B*B*B*B*B;
      if(tmp==B5){
        cout << A << " " << B << endl;
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 3616
///supercalifragilisticexpialidocious.
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <cstdlib>
#include <cctype>
#include <ctime>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <numeric>
#include <utility>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <list>
#include <bitset>
#include <complex>
using namespace std;
#define f first
#define s second
#define PB pop_back 
#define pb push_back
#define mp make_pair
#define int long long
#define sz(s) (int)s.size()
#define seper(n) setprecision(n)
#define all(v) v.begin(),v.end()
#define mem(a,b) memset(a,b,sizeof a)
#define IOS ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
typedef long long ll; 
typedef map<int , int> mii;
typedef pair<int , int> pii; 
typedef map<string , int> msi;
typedef pair<int , string> pis; 
typedef pair<int , pair<int , int> > piii;
int a , b;
int32_t main()
{
		cin >> a >> b;
		if(a <= 2 * b)
				return cout << 0 << endl , 0;
		return cout << a - 2 * b << endl , 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 2000000000
using namespace std;
typedef long long ll;
int read(){
    int f = 1, x = 0;
    char c = getchar();
    while(c < '0' || c > '9'){if(c == '-') f = -f; c = getchar();}
    while(c >= '0' && c <= '9')x = x * 10 + c - '0', c = getchar();
    return f * x; 
}
ll n, a, b;
void init(){
    cin >> n >> a >> b;
}
void solve(){
    ll c = a + b;
    ll ans = a * (n / c);
    ans += min(n - (n / c) * c, a);
    cout << ans << endl;
}
int main(){
    init();
    solve();
    return 0;
}

Measured memory_bytes: 256
s = {}
s['a'] = input()
s['b'] = input()
s['c'] = input()
c = {'a': 0, 'b': 0, 'c': 0}
l = {'a': len(s['a']), 'b': len(s['b']), 'c': len(s['c'])}

turn = 'a'
while c[turn] < l[turn]:
    next_turn = s[turn][c[turn]]
    c[turn] += 1
    turn = next_turn

print(turn.upper())


Measured memory_bytes: 38256
a, b, c, d = [int(x) for x in list(str(input()))]
op = ['+', '-']
for op1 in op:
  for op2 in op:
    for op3 in op:
      if op1 == '+':
        result = a + b
      else:
        result = a - b
      if op2 == '+':
        result += c
      else:
        result -= c
      if op3 == '+':
        result += d
      else:
        result -= d
      if result == 7:
        print("{}{}{}{}{}{}{}=7".format(a, op1, b, op2, c, op3, d))
        exit()
        

Measured memory_bytes: 3064
H, W = map(int, input().split())
N = int(input())
A = list(map(int, input().split()))

ans = [[0] * W for _ in range(H)]
S = 0
for i, a in enumerate(A, start=1):
    for _ in range(a):
        h, w = divmod(S, W)
        ans[h][w] = i
        S += 1

for i, a in enumerate(ans):
    print(*a[::(-1)**i])


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

long long n,np,nv,nt;
vector<long long> box(1e5);

bool check(long long mid) {
  bool ans_bool=false;
  if(box.at(nt-1)<=box.at(mid)) {
    ans_bool=true;
  }
  else if(box.at(mid)+np >= box.at(nt-1)) {
    if(nv<=nt) {
      ans_bool=true;
    }
    else {
      long long check_sum=0;
      for(long long i=nt-1;i<n;i++) {
        if(i==mid) continue;
        check_sum+=min(np,box.at(mid)+np-box.at(i));
        if(check_sum>=np*(nv-nt)) {
          ans_bool=true;
          break;
        }
      }
    }
  }
  return ans_bool;
}

int main() {
  cin >> n >> np >> nv >> nt;
  for(long long i=0;i<n;i++) {
    cin >> box.at(i);
  }

  sort(box.rbegin(),box.rend());

  long long mx=n;
  long long mn=0;
  long long mid=(mx+mn)/2;
  while(mx-mn>=2) {
    if(check(mid)) {
      mn=mid;
    }
    else {
      mx=mid;
    }
    mid=(mn+mx)/2;
  }
  cout << mn+1 << endl;
}

Measured memory_bytes: 1024
const main = stdin => {
  const input = stdin.trim().split('\n')
  const [K, X] = input[0].split(' ').map(x => parseInt(x))
  500 * K >= X ? console.log('Yes') : console.log('No')
}

// 標準入力
main(require("fs").readFileSync("/dev/stdin", "utf8"))


Measured memory_bytes: 29696
/* ファイル名：ITP1_4_D.c	*/
/* 内容：n  個の整数 ai(i=1,2,...n)を入力し、それらの最小値、最大値、合計値を求める	*/

/* include	*/
#include <stdio.h>

/* 外部変数宣言	*/

/* プロトタイプ宣言	*/

/* 関数名main:	*/
/* 処理内容:n  個の整数 ai(i=1,2,...n)を入力し、それらの最小値、最大値、合計値を求める	*/
int main( void )
{
	/* 内部定数定義	*/
	/* 入力	*/
	int n;		/* 整数の数	*/
	int num;	/* 入力される整数	*/
	/* 出力	*/
	int min;	/* 最小値*/
	int max;	/* 最大値*/
	long long sum;	/* 合計値*/
	/* 処理 */
	int i;		/* ループ用変数	*/
	
	/*変数の初期化*/
	min = 1000000;
	max = -1000000;
	sum = 0;
	
	scanf("%d",&n);
	
	/* 整数の数だけループ*/
	for(i = 0; i < n; i++){
		scanf("%d",&num);
		
		/* 最小値かの判定	*/
		if(num < min){
			min = num;	/* 最小値だったら値を更新する	*/
		}
		else{
			/* 処理なし	*/
		}
		
		/* 最大値かの判定	*/
		if(num > max){
			max = num;	/* 最大値だったら値を更新する	*/
		}
		else{
			/* 処理なし	*/
		}
		
		/* 合計値の算出	*/
		sum = sum + num;
	}
	
	printf("%d %d %ld\n",min, max, sum);
	
	return 0;
}



Measured memory_bytes: 2132
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX=1e5+9;
ll n,dp[MAX][2],a,b,s[MAX],MOD=1e9+7,A[MAX],B[MAX];
int main()
{
	ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);
	cin>>n>>a>>b;
	for (int i=0;i<n;i++)
	{
		cin>>s[i];
		if (!i) continue;
		if (s[i]-s[i-1]<a) A[i-1]=1;
		if (s[i]-s[i-1]<b) B[i-1]=1;
	}
	for (int i=1;i<n;i++) A[i]+=A[i-1],B[i]+=B[i-1];
	for (int i=0;i<n;i++)
	{
		int p=upper_bound(s,s+i,s[i]-a)-s;
		int flg=0;
		if (i-2>=p) flg=(i>=2?B[i-2]:0)-(p?B[p-1]:0);
		int k=0;
		for (int j=p;j<i-1;j++) if (s[j+1]-s[j]<b) k++;
		flg=!flg;
		if (!flg) dp[i][0]=0;
		else if (p==i) dp[i][0]=(dp[i-1][1]+dp[i-1][0])%MOD;
		else dp[i][0]=dp[p][1];
		int q=upper_bound(s,s+i,s[i]-b)-s;
		int flgg=0;
		if (i-2>=q) flgg=(i>=2?A[i-2]:0)-(q?A[q-1]:0);
		flgg=!flgg;
		if (!flgg) dp[i][1]=0;
		else if (q==i) dp[i][1]=(dp[i-1][0]+dp[i-1][1])%MOD;
		else dp[i][1]=dp[q][0];
		if (!i) dp[i][0]=dp[i][1]=1;	
	}
	cout<<(dp[n-1][0]+dp[n-1][1])%MOD<<endl;
	return 0;
}

Measured memory_bytes: 4224
// AtCoder Beginner Contest 153 F.cpp

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>

using namespace std;

#define LL long long

int main()
{
	LL n,//モンスターの数
		d,//爆弾の効果範囲
		a,//爆弾が与えるダメージ
		position,//爆破範囲の右端の場所
		damage,//爆破させた時のダメージ量を保存
		count,//個々の爆破の回数
		dsum = 0,//ダメージのキャッシュ
		cc = 0,
		answer = 0,
		j;
	cin >> n >> d >> a;
	vector<pair<LL, LL>>xh(n);//firstに場所、secondに体力を入れる
	vector<LL>c(n, 0);
	//vector<LL>x(n);//場所
	//vector<LL>h(n);//体力
	for (int i = 0; i < n; i++) {
		cin >> xh[i].first >> xh[i].second;
	}

	sort(xh.begin(), xh.end());

	for (LL i = 0; i < n; i++) {
		xh[i].second -= dsum; //ダメージ分引く
		dsum -= c[i]; //これより先に届かない攻撃
		if (xh[i].second <= 0) continue; //死んでいたら無視
		count = (xh[i].second + a - 1) / a; //よくある切り上げテクニック
		answer += count; //答え
		if (d == 0) continue;
		position = xh[i].first + d * 2; //攻撃の端
		for (j = cc; j < n; j++) {
			if (xh[j].first > position) { //攻撃範囲を出たら
				cc = j - 1;//その一つ前が右端
				break;
			}
		}
		if (j == n) cc = n - 1; //nになって抜けたら右端はn-1
		if (cc != i) {
			dsum += count * a;
			c[cc] += count * a;
		}


		/*if (xh[i].second > 0) {       //体力が残っていたら
			count = 0;
			count = xh[i].second / a;  //爆破①
			if (xh[i].second % a != 0) //余りが出たら
				count++;       //爆破②
			answer += count;   //答えの更新
			damage = count * a;//爆破ダメージ量を保持する
			position = xh[i].first + d * 2;//爆破範囲の右端を保持

			/*cout << i << "回目の爆破" << endl
				<< "爆破ダメージ = " << damage << endl
				<< "爆破回数 = " << count;*/
				/*for (LL j = i; j < n && xh[j].first <= position; j++) {//爆破範囲の他のモンスターのダメージ計算をする
					xh[j].second -= damage;
					//cout << endl << "j = " << j << endl;
				}
		}*/
	}

	cout << answer << endl;
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
  char n[21],m[21];
  int i,j;
  scanf("%s",&n);
  for(i=0;n[i]!='\0';i++){}
  for(j=0;i>=0;i--,j++) {
  m[j]=n[i-1];
  }
 
 printf("%s\n",m);
 
  return 0;
}

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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
char b[200000], ok[100000]{ 1 };
queue<int>que;

void bfs(int u, int t) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i] = vector<int>();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = 1;
	}
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] > d[u[i]]) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] > d[u[r[i]]] && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = 1;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13636
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=200000;
char s[maxn+10];
int cnt[26],now[26],n,odd=-1,nxt[maxn+10],pre[26],d[maxn+10],b[maxn+10],c[maxn+10];
ll ans;
int main(){
	scanf("%s",s); n=strlen(s);
	for(int i=0;i<n;++i) ++cnt[s[i]-='a'];
	for(int i=0;i<26;++i){
		pre[i]=-1;
		if(cnt[i]%2==1)
			if(odd==-1) odd=i;
			else{
				printf("-1"); return 0;
			}
	}
	for(int i=n-1;i>=0;--i){
		nxt[i]=pre[s[i]]; pre[s[i]]=i;
	}
	for(int i=0,p=0;i<n/2;++i){
		while(now[s[p]]>=cnt[s[p]]/2) ++p;
		d[i]=s[p];
		++now[s[p]]; b[p]=i; pre[s[p]]=nxt[pre[s[p]]]; ++p;
	}
	if(odd!=-1){
		b[pre[odd]]=n/2; pre[odd]=nxt[pre[odd]];
	}
	for(int i=(n+1)/2;i<n;++i){
		b[pre[d[n-1-i]]]=i; pre[d[n-1-i]]=nxt[pre[d[n-1-i]]];
	}
	for(int i=n-1;i>=0;--i){
		for(int j=b[i];j;j-=j&-j) ans+=c[j];
		for(int j=b[i]+1;j<=n;j+=j&-j) ++c[j];
	}
	printf("%lld",ans); return 0;
}


Measured memory_bytes: 3072
#include <iostream>
#include <vector>
#include <string>

using namespace std;

static char RED = 'R';
static char WHITE = 'W';

vector<char> readProblem();
int getMinOperationCount(vector<char>);

int main() {
  vector<char> initialStones = readProblem();
  int minOperationCount = getMinOperationCount(initialStones);
  cout << minOperationCount << endl;
}

int getMinOperationCount(vector<char> initialStones) {
  int whiteOnLeft = 0;
  int redOnRight = 0;
  for (int idx = 0; idx < initialStones.size(); idx++) {
    if (initialStones[idx] == RED) {
      redOnRight++;
    }
  }
  
  int minOperationCount = initialStones.size(); // effectively infinite
  for (int separator = 0; separator <= initialStones.size(); separator++) {
    int operationCount = max(whiteOnLeft, redOnRight);
    if (minOperationCount > operationCount) {
      minOperationCount = operationCount;
    }
    
    if (separator < initialStones.size()) {
      if (initialStones[separator] == RED) {
        redOnRight--;
      } else {
        whiteOnLeft++;
      }
    } else {
      // we already have minimum value
      // so we don't have anything to do here.
    }
  }
  return minOperationCount;
}

vector<char> readProblem() {
  int stoneCount;
  cin >> stoneCount;
  string stoneMarks;
  cin >> stoneMarks;
  vector<char> stones(stoneCount);
  for (int idx = 0; idx < stoneCount; idx++) {
    stones[idx] = stoneMarks[idx];
  }
  return stones;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h> 
#define ll long long
using namespace std;
int main() 
{ 
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++)
    {
        cin>>h[i];
    }
    int dp[n];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<n;i++)
    {
        if(i==1)
        {
            dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        }
        else
        {
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout<<dp[n-1];
} 


Measured memory_bytes: 4324
import sys
for line in sys.stdin.readlines():
    line=map(float,line.strip().split())
    x=line[0::2]
    y=line[1::2]
    if x[1]<x[2] or x[0]>x[3] or y[1]<y[2] or y[0] > y[3]:print "NO"
    else:print "YES"

Measured memory_bytes: 4232
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  int b=0,l=0;
  for(int i=0;i<n;i++){
	cin >> a[i];
    if(b<=a[i]){
	  l++;
      b=a[i];
    }
  }
  cout << l;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string number;
  cin >> number;
  int sum = 0;
  for(int i = 0; i < (int)number.size(); ++i){
    char ch = number[i];
    sum += ch - '0';
  }
      
  int answer = sum % 9;
  if(answer == 0) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 3700
#pragma optimize "-O3"
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
queue < int > q;
const int maxN = 2 * (int)1e5 + 100;
int n;
int dist[maxN];
vector < int > g[maxN];
bool who[maxN];
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
   // freopen("input.txt", "r", stdin);
    cin >> n;
    if (n == 1) {
        cout << "First";
        return 0;
    }
    for (int i = 1; i < n; i++) {
        int a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    memset(dist, -1, sizeof dist);
    dist[1] = 0;
    q.push(1);
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (auto it : g[v]) {
            if (dist[it] == -1) {
                dist[it] = dist[v] + 1;
                q.push(it);
            }
        }
    }
    pair < int, int > best = make_pair(0, 0);
    for (int i = 1; i <= n; i++) best = max(best, make_pair(dist[i], i));
    int v = best.second;
    memset(dist, -1, sizeof dist);
    dist[v] = 0;
    q.push(v);
    while (!q.empty()) {
        int u = q.front();
        q.pop();
        for (auto it : g[u]) {
            if (dist[it] == -1) {
                dist[it] = dist[u] + 1;
                q.push(it);
            }
        }
    }
    int dim = 0;
    for (int i = 1; i <= n; i++) dim = max(dim, dist[i] + 1);
    who[0] = false;
    who[1] = true;
    who[2] = false;
    for (int i = 3; i <= n; i++) {
        who[i] = (!who[i - 1]) || (!who[i - 2]);
    }
    if (who[dim]) cout << "First";
    else cout << "Second";
   // cout << ans << '\n';
   // cout << ans << '\n';
    //if (ans % 2 == 0) cout << "Second";
   // else cout << "First";
    return 0;
}

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


int main() {
  int n;
  string s, t;
  
  cin >> n;
  cin >> s >> t ;
  
  for (int i = 0; i < n; i++){
    cout << s.at(i) << t.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll findXORofRange(ll m,ll n)
{
    ll p[4];
    if(m%2==0)
    {
       p[0]=n;
       p[1]=1;
       p[2]=n^1;
       p[3]=0;
    }
    else
    {
        p[0]=m;
        p[1]=m^n;
        p[2]=m-1;
        p[3]=(m-1)^n;
    }
    return p[(n-m) % 4];
}
int main()
{
    ll a,b;
    cin>>a>>b;
    ll c=findXORofRange(a,b);
    cout<<c<<endl;
}

Measured memory_bytes: 256