akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define pll pair<long long,long long>
#define pdd pair<long double,long double>
#define vll vector<ll>
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define pf push_front
priority_queue<pll,vector<pll>,greater<pll> >pq,pq1;
priority_queue<ll,vector<ll>,greater<ll> >p1;



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a,b,k;
    cin>>a>>b>>k;
    if(a>=k){
        a=a-k;
        
    }
    else{
        k=k-a;
        a=0;
        if(b>=k){
            b=b-k;
        }
        else{
            b=0;
        }
    }
    cout<<a<<" "<<b;
    return 0;
}


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

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
  ll n;
  cin >> n;
  vector<ll> xs;
  vector<ll> ys;
  for (auto i = 0; i < n; i++)
  {
    ll x, y;
    cin >> x >> y;
    xs.push_back(x);
    ys.push_back(y);
  }

  double ans = 0;
  ll road_cnt = 0;
  for (auto i = 0; i < n; i++)
  {
    for (auto j = i + 1; j < n; j++)
    {
      ll xx = xs[i] - xs[j];
      ll yy = ys[i] - ys[j];
      ans += sqrt(xx * xx + yy * yy);
      road_cnt++;
    }
  }

  cout << setprecision(10) << ans / road_cnt * (n - 1) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws FileNotFoundException {

//    	File file = new File("src/in.txt");

        //コード
//    	Scanner sc = new Scanner(file);
    	Scanner sc = new Scanner(System.in);

    	int a = sc.nextInt();

    	System.out.println(a+a*a+a*a*a);
    }
}

Measured memory_bytes: 35836
#include <bits/stdc++.h>
typedef long long LL;
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;
set<pair<double,double> > cp;
pair<double,double> relv(pair<double,double> a,pair<double,double> b)
{
  return make_pair(a.first-b.first,a.second-b.second);
}
double cross(pair<double,double> va,pair<double,double> vb)
{
  return va.first*vb.second-va.second*vb.first;
}
void crosspoint(pair<double,double> a,pair<double,double> b,pair<double,double> c,pair<double,double> d)
{
  auto ab=relv(a,b),cd=relv(c,d);
  if(!(cross(ab,relv(a,c))*cross(ab,relv(a,d)) < 0 &&
       cross(cd,relv(c,a))*cross(cd,relv(c,b)) < 0)) return;
  double midrat=cross(cd,relv(c,a))/(cross(cd,relv(c,a))+cross(cd,relv(b,d)));
  //cout << midrat << ' ' << a.first << ' ' << b.first << ' ' << ab.first << ' ' << a.second << ' ' << b.second << ' ' << ab.second << endl;
  cp.insert(make_pair(a.first-midrat*ab.first,a.second-midrat*ab.second));
}

int main(void)
{
  for(;;){
    int n;
    cin >> n;
    if(!n) return 0;
    vector<pair<pair<double,double>,pair<double,double> > >line(n);
    cp.clear();
    REP(i,n) cin >> line[i].first.first
		 >> line[i].first.second
		 >> line[i].second.first
		 >> line[i].second.second;
    int answer=1;
    REP(i,n){
      cp.clear();
      REP(j,i) crosspoint(line[i].first,line[i].second,line[j].first,line[j].second);
      answer+=cp.size()+1;
    }
    cout << answer << endl;
  }
}

Measured memory_bytes: 3136
// https://atcoder.jp/contests/abc169/tasks/abc169_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B;
    cin >> A >> B;
    cout << A * B << endl;

    return 0;
}


Measured memory_bytes: 3640
import java.io.PrintWriter

fun main(args: Array<String>) {
    val (n, m, q) = readLine()!!.split(' ').map { it.toInt() }
    val t = Array(n + 1) { IntArray(n + 1) }
    repeat(m) {
        val (l, r) = readLine()!!.split(' ').map { it.toInt() }
        for (i in 1..l)
            for (j in r..n)
                t[i][j]++
    }
    val pw = PrintWriter(System.out)
    repeat(q) {
        val (l, r) = readLine()!!.split(' ').map { it.toInt() }
        pw.println(t[l][r])
    }
    pw.flush()
}


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

int main() {
    char a, b;
    int f;
    cin >> a >> b;

    if (a == 'H')
        f = 1;
    else
        f = -1;

    if(b=='H')
        f *= 1;
    else
        f *= -1;

    char ans;
    if (f == 1)
        ans = 'H';
    else
        ans = 'D';
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
import math
ans=0
K=int(input())
for i in range(1,K+1):
  for j in range(i,K+1):
    for k in range(j,K+1):
      g1=math.gcd(i,j)
      g=math.gcd(g1,k)
      if i==j==k:
        n=1
      elif i<j<k:
        n=6
      else:
        n=3
      ans+=g*n
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n, i, j, k;
	cin >> n;
	cin >> k;
	int h[n];
	for(i = 0; i<n; i++) cin >> h[i];
	int dp[n] = {0};
	dp[0] = 0;
	for(int i = 1; i < n; ++i){
		dp[i] = INT_MAX;
      	for(int j = i-1; j >= 0 && i-j <= k; --j){
			dp[i] = min(dp[i], dp[j] + abs(h[i]-h[j]));
		}
	}
	cout<<dp[n-1]<<"\n";
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int main(){
    ll x;
    cin>>x;

    ll ans = 1;
    if(x==1){
        cout<<1<<endl;
        return 0;
    }
    ll now = 2;
    while(ans<x){
        ans+=now;
        if(ans>=x) break;
        now++;
        //cout<<ans<<" "<<now<<endl; 
    }
    cout<<now<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int sum = 0;
    for(int i=0; i<K; i++) {
      sum += p[i] + 1;
    }
    int max = sum;
    for(int i=0; i<N-K; i++) {
      sum = sum - p[i] + p[i+K];
      if(max < sum) {
        max = sum;
      }
    }
    System.out.println(String.format("%.12f", (double)max / 2));
  }
}

Measured memory_bytes: 63768
#include<bits/stdc++.h>
using namespace std;
template<class T> void chmin(T& x, T y) {if(x > y) x = y;}
int ans = 1 << 30;
char bld[810][810];
bool came[810][810];
int H, W, K, s, t;
int dx[] = {1, 0, -1, 0};
int dy[] = {0, -1, 0, 1};

struct edge{
    int a, b, cost;
    bool operator < (const edge& e) const {
        return cost < e.cost;
    }

    bool operator > (const edge& e) const {
        return cost > e.cost;
    }
};


int main(){
    cin >> H >> W >> K;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> bld[i][j];
            if(bld[i][j] == 'S') s = i, t = j;
        }
    }
    
    priority_queue<edge, vector<edge>, greater<edge>> pq;
    pq.push(edge{s, t, 0});
    while(!pq.empty()){
        edge e = pq.top();
        pq.pop();

        if(came[e.a][e.b]) continue;
        came[e.a][e.b] = true;

        if(e.a == 1 || e.b == 1 || e.a == H || e.b == W){
            ans = 1;
        }

        chmin(ans, ((H - e.a - 1) / K) + 2);
        chmin(ans, ((e.a - 2) / K) + 2);
        chmin(ans, ((W - e.b - 1) / K) + 2);
        chmin(ans, ((e.b - 2) / K) + 2);
        
        for(int i = 0; i < 4; i++){
            int ux = e.a + dx[i];
            int uy = e.b + dy[i];

            if(bld[ux][uy] == '#') continue;
            
            if(1 <= ux && ux <= H && 1 <= uy && uy <= W && e.cost < K){
                pq.push(edge{ux, uy, e.cost + 1});
            }
        }

    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm> // sort
#include <map>       // pair
#include <vector>
using namespace std;

#define REP(a,b) for(int i =(a);i < (b);i++)
#define FOR(n) for(int i = 0; i<(n); i++)
#define COUT(c)  cout<<(c)<<endl


const int INF = 100100100;
const int MOD = (int)1e9 +7;
const double EPS = 1e-9; 

typedef long long int ll;

//char in[120];
//ex. pair
//pair<pair<string,int>,int> p[110];

int main(){
    int a,b,c; cin>>a>>b>>c;
    cout << max({a,b,c}) - min({a,b,c})<<endl;

    return 0;    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int x;
  cin >> x;
  bool ba = false;
  int a = x/100;
  int b = x % 10;
  int c = (x - a*100)/10;
  if(a == 7 || b == 7 || c == 7) ba = true;
  if(ba) cout << "Yes";
  else cout << "No";
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define MAXN 100005
int dp[MAXN],a[MAXN];
int main(){__
	int n,k;
	cin >> n >> k;
	for(int i=1; i <=n; i++){
		cin >> a[i];
		dp[i] = 1<<30;
	}

	dp[1] = 0;
	for(int i=2; i <= n; i++){
		for(int j = 1; j <= k; j++){
			if(i - j < 1) break;
			dp[i] =min(dp[i],dp[i - j] + abs(a[i] - a[i-j]));
		}
	}

	cout << dp[n] << endl;
}


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

const int MOD = (int)1e9+7;

int main(){
	int H,W,D;
	cin >> H >> W >> D;
	vector<vector<int>> A(H,vector<int>(W));
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cin >> A.at(i).at(j);
		}
	}
	int Q;
	cin >> Q;
	vector<int> L(Q),R(Q);
	for(int i=0;i<Q;i++)	cin >> L.at(i) >> R.at(i);

	map<int,pair<int,int>> A_xy;
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			A_xy[A.at(i).at(j)]=make_pair(j,i);
		}
	}
	vector<vector<int>> sum(D,vector<int>((H*W)/D+10,0));
	for(int i=0;i<D;i++){
		int pre_x;
		int pre_y;
		if(i==0){
			pre_x=A_xy.at(D).first;
			pre_y=A_xy.at(D).second;
		}
		else{
			pre_x=A_xy.at(i).first;
			pre_y=A_xy.at(i).second;	
		}
		for(int j=1;i+j*D<=H*W;j++){
			int x=A_xy.at(i+j*D).first;
			int y=A_xy.at(i+j*D).second;
			sum.at(i).at(j)=abs(pre_x-x)+abs(pre_y-y)+sum.at(i).at(j-1);
			pre_x=x;
			pre_y=y;
		}
	}
	/*
	for(int i=0;i<D;i++){
		for(int j=0;j<sum.at(i).size();j++){
			cout << sum.at(i).at(j) << ",";
		}
		cout << endl;
	}
	*/

	for(int i=0;i<Q;i++){
		int aa=L.at(i)%D;
		int ll=L.at(i)/D;
		int rr=R.at(i)/D;
		cout << sum.at(aa).at(rr)-sum.at(aa).at(ll) << endl;
	}

	return 0;
}


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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<ld, ld>;
using vll = vector<ll>;
using vld = vector<ld>;
using vpl = vector<pll>;
using vvll = vector<vll>;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(ll i=0;i<((ll)n);i++)
#define REP1(i,n) for(ll i=1;i<((ll)n);i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll mpow(ll m, ll p){
  ll power = m;
  ll res = 1;
  while(p>0){
    if(p&1)
      res = res*power%MOD;
    power = (power*power)%MOD;
    p /= 2;
  }
  return res;
}


ll mod_inv(ll m){
  return mpow(m, MOD-2);
}


struct COM{
  vll fact, fact_inv;
  COM(ll n): fact(n+1,1), fact_inv(n+1,1){
    for(ll i=1; i<=n; i++)
      fact[i] = fact[i-1]*i%MOD;
    fact_inv[n] = mod_inv(fact[n]);
    for(ll i=n; i>=1; i--)
      fact_inv[i-1] = fact_inv[i]*i%MOD;
  }

  ll calc(ll n, ll k){
    if(k<0 || n<k)
      return 0;
    ll res = fact[n]*fact_inv[n-k]%MOD*fact_inv[k]%MOD;
    return res;
  }
};


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

    ll n;
    string s;
    cin >> n >> s;
    n = s.size();

    vll v(n);
    REP(i, n) {
        if (s[i] == 'W')
            v[i] = 0;
        else
            v[i] = 1;
    }

    ll cnt = 0;
    for (ll i = n - 1; i >= 0; i--) {
        v[i] = (v[i] + cnt) % 2;
        cnt++;
    }



    ll l = 0, r = 0;
    REP(i, n) {
        if (v[i] == 1)
            r++;
        else
            l++;
    }

	if (v[0] == 1 || l != r) {
		cout << 0 << endl;
		return 0;
	}

	ll ans = 1;
	ll now_l = 0;
    REP(i, n) {
        if (v[i] == 0)
            now_l++;
        else {
            ans = ans * now_l % MOD;
            now_l--;
        }
	}

    COM com(n);
    ans = ans * com.fact[l] % MOD;

	cout << ans << endl;
}




Measured memory_bytes: 8328
"""
import random
import functools
import copy
import bisect
import array
import re
import collections
import heapq
import fractions
import itertools
import string
import math
from operator import itemgetter as ig
from bisect import bisect_left, bisect_right, insort_left, insort_right
from itertools import permutations, combinations, product, accumulate, groupby
from heapq import heappush, heappop
from collections import deque, defaultdict, Counter
import sys
sys.setrecursionlimit(10 ** 7)
# import numpy as np

inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
'''for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:'''
"""
from collections import deque, defaultdict, Counter
import math
import sys
sys.setrecursionlimit(10 ** 7)


def wi(): return list(map(int, sys.stdin.readline().split()))
# WideIntPoint


def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]


def ws(): return sys.stdin.readline().split()


def si(): return int(sys.stdin.readline())  # SingleInt


def ss(): return input()


def hi(n): return [si() for _ in range(n)]


def hs(n): return [ss() for _ in range(n)]  # HeightString


def s_list(): return list(input())


def mi(n): return [wi() for _ in range(n)]  # MatrixInt


def mip(n): return [wip() for _ in range(n)]


def ms(n): return [ws() for _ in range(n)]


def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[
    0]] for _ in range(n)]  # NumberGrid


def grid(n): return [s_list() for _ in range(n)]


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    """a,bの最小公倍数"""
    return a * b // gcd(a, b)


def main():
    x = int(input())
    a = x // 500
    b = x % 500
    c = b // 5
    print(1000*a + 5*c)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,m;
  cin >> n >> m;
  vector<pii> p(m);
  rep(i,m){
    int a,b;
    cin >> a >> b;
    p.at(i) = make_pair(b,a);
  }
  sort(p.begin(),p.end());
  int count = 0;
  int cut = 0;
  rep(i,m){
    int a,b;
    tie(b,a) = p.at(i);
    if(a < cut) continue;
    cut = b;
    count++;
  }
  cout << count << endl;
}


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

int main() {
    int n; cin >> n;
    int s[n]; for (int i = 0; i < n; ++i) cin >> s[i];
    int q; cin >> q;
    int t[n]; for (int i = 0; i < q; ++i) cin >> t[i];
    
    int cnt = 0;
    for (int t_i = 0; t_i < q; ++t_i) {
        for (int s_i = 0; s_i < n; ++s_i) {
            if (t[t_i] == s[s_i]) {
                ++cnt;
                break;
            }
        }
    }
    
    cout << cnt << endl;
    
    return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <vector>
#include <math.h>
using namespace std;
int main()
{
    int n,i,a,a_max=0,arr_max=0;
    vector<int> arr(100001,0);      //int arr[100001]={0};
    cin >> n;                       //scanf("%d",&n);
    
    for(i=0;i<n;i++)
    {
        cin >> a;                   //scanf("%d",&a);
        
        arr[a]++;
        if(a!=0)
        {
            arr[a-1]++;
        }
        if(a<100000)
        {
            arr[a+1]++;
        }
        
        a_max=max(a_max,a);
    }
    
    for(i=0; i < a_max+1; i++)
    {
        arr_max=max(arr_max, arr[i]);
    }
    
    cout << arr_max << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;

void solve1() {
	int a, b, c;
	cin >> a >> b >> c;
	string ans = (b - a == c - b) ? "YES" : "NO";
	cout << ans << endl;
	return;
}

void solve2() {
	string O, E;
	cin >> O >> E;
	string ans = "";
	for (int i = 0; i < O.size(); i++) {
		ans += O[i];
		if (i < E.size()) {
			ans += E[i];
		}
	}
	cout << ans << endl;

}

void solve3() {
	int N;
	map<char, int> Min;
	cin >> N;
	N--;
	string s;
	cin >> s;
	map<char, int> tmp;
	for (int j = 0; j < s.size(); j++) {
		tmp[s[j]]++;
	}
	for (auto it = tmp.begin(); it != tmp.end(); it++) {
		Min[it->first] = tmp[it->first];
	}
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		map<char, int> tmp;
		for (int j = 0; j < s.size(); j++) {
			tmp[s[j]]++;
		}
		for (auto it = Min.begin(); it != Min.end(); it++) {
			Min[it->first] = min(Min[it->first], tmp[it->first]);
		}
	}
	string ans = "";
	for (auto it = Min.begin(); it != Min.end(); it++) {
		for (int i = 0; i < it->second; i++) {
			ans += it->first;
		}
	}
	cout << ans << endl;
}

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

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

int main() {
  int n, m, l;
  unsigned long A[101][101];
  unsigned long B [101][101];
  cin >> n >> m >> l;
  for (int i =0 ; i < n ; i ++ ) {
  for (int j =0 ; j < m ; j ++ ) {
    cin >> A[i][j];
  }
  }

  for(int i = 0 ; i < m; i ++) {
    for(int j = 0; j < l ; j ++){
    cin >> B[i][j];
    }
  }

  for(int i = 0; i < n ; i ++) {
  for(int j = 0; j < l ; j ++ ) {
    unsigned long res = 0;
    for(int k = 0; k < m; k ++) {
      res += A[i][k] * B[k][j];
    }
    cout << res;
    if ( j != l-1 ) {
      cout << " " ;
  }
  }
  cout <<  endl;
  }


}

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

string s[105];

signed main() {
	int h, w; cin >> h >> w;
	rep(i, h)cin >> s[i];
	vector<int>ah, aw;
	rep(i, h) {
		int c = 0;
		rep(j, w)if (s[i][j] == '#')c++;
		if (c)ah.push_back(i);
	}
	rep(i, w) {
		int c = 0;
		rep(j, h)if (s[j][i] == '#')c++;
		if (c)aw.push_back(i);
	}

	for (int e : ah) {
		for (int f : aw) {
			cout << s[e][f];
		}cout << endl;
	}
}

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

int main()
{
    string s;
    cin >> s;
    const int n=s.size();
    bool f = true;
    for(int i=0;i<n;++i){
        if(i%2==0 && (s[i]!='R' && s[i]!='U' && s[i]!='D')) f =false;
        else if(i%2==1 && (s[i]!='L' && s[i]!='U' && s[i]!='D')) f = false;
    }
    if(f) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

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

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define IMOD 1000000007 
#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define lrep(i,n) for(long long  i = 0; i < (long long)(n); i++)
#define lrep2(i,a,n) for(long long i = (long long)(a); i <= (long long)(n); i++)

#define irrep(i,n) for(int i = (int)(n); i > -1; i--)
#define irrep2(i,a,n) for(int i = (int)(n); i >= (int)(a); i--)

typedef long long ll;
typedef std::vector<char> v_char;
typedef std::vector<v_char > v2_char;
typedef std::vector<double> v_double;
typedef std::vector<v_double > v2_double;
typedef std::vector<int> v_int;
typedef std::vector<v_int > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<v_ll > v2_ll;
typedef std::vector<std::string> v_string;
typedef std::vector<v_string > v2_string;
typedef std::vector<bool> v_bool;
typedef std::vector<v_bool > v2_bool;
typedef std::pair<ll, ll> pll;
typedef std::pair<int, int> pii;

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

using namespace std; 

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

    v_int pow2;
    int f = 1;
    
    while(f <= 100 && f <= n) {
        pow2.push_back(f);
        f*=2;
    }
    
    cout << pow2.back();
        
    return 0;
}   
/** atcoder **/


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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i = (a); i >= (b); i--)
#define FORR(i,a,b) for (int i = (a); i > (b); i--)
typedef unsigned long long ull;
typedef long long ll;

ll a[1005],b[1005];

ll check(ll n,ll x){
	if(n==0){
		if(x<=0)
			return 0;
		else
			return 1;
	}else if(x<=1+a[n-1]){
		return check(n-1,x-1);
	}else{
		return b[n-1]+1+check(n-1,x-2-a[n-1]);
	}
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    ll n,x;
    cin >> n >> x;
    memset(a,0,sizeof(a));
    memset(b,0,sizeof(b));

    a[0]=1,b[0]=1;

    FOR(i,1,n){
    	a[i]=a[i-1]*2+3;
    	b[i]=b[i-1]*2+1;
    }

    cout << check(n,x);

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define MOD (1000000007l)
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)

using namespace std;

void solve() {
  ll S;
  cin >> S;
  ll h = S / 3600;
  ll m = (S / 60) % 60;
  ll s = S % 60;
  cout << h << ":" << m << ":" << s << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  cout << fixed;
  solve();
  return 0;
}



Measured memory_bytes: 3216
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <numeric>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <thread>
#include <tuple>
#include <limits>

using namespace std;

int main() {
  int n;
  scanf("%d", &n);
  long long ans = -1;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    long long d, c;
    scanf("%lld%lld", &d, &c);
    ans += c;
    sum += d*c;
  }
  while (sum >= 10) {
    ans += sum / 10;
    sum = sum / 10 + sum % 10;
  }
  printf("%lld\n", ans);
  return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
int main(){
	char S[100000];
	int i=0,count=0;
	while(1){
		scanf("%c",&S[i]);
		if(S[i]=='\n')	break;

		if(i!=0 && S[i-1]!=S[i])	count++;
		i++;
	}

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


	return 0;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
XY = [list(map(int,input().split())) for _ in [0]*N]

iX = sorted(x for x,y in XY)
iY = sorted(y for x,y in XY)
X = {x:i for i,x in enumerate(iX)}
Y = {y:i for i,y in enumerate(iY)}

c = [[0]*(N+1) for i in [0]*(N+1)]
for x,y in XY:
    c[Y[y]+1][X[x]+1] = 1

for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i+1][j]
for i in range(N):
    for j in range(N):
        c[i+1][j+1] += c[i][j+1]

ans = 10**20
for l in range(N):
    for r in range(l+1,N):
        u = 0
        d = 1
        dX = iX[r] - iX[l]
        while d<N:
            if c[d+1][r+1]+c[u][l]-c[u][r+1]-c[d+1][l] >=K:
                ans = min(ans, dX*(iY[d]-iY[u]))
                u+=1
            else:d+=1

print(ans)

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

using namespace std;
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

/* [💭] [💡] [🎈] */

using namespace std;

int p[1000];

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

    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> p[i];
    sort(p, p + n);
    ll s = 0;
    for (int i = 0; i < k; i++) s += p[i];
    cout << s;

    return 0;
}

Measured memory_bytes: 3672
N,M,K = map(int,input().split())
MOD = 998244353
if M==1:
    print(1 if K==N-1 else 0)
    exit()

MAXN = N+5
fac = [1,1] + [0]*MAXN
finv = [1,1] + [0]*MAXN
inv = [0,1] + [0]*MAXN
for i in range(2,MAXN+2):
    fac[i] = fac[i-1] * i % MOD
    inv[i] = -inv[MOD%i] * (MOD // i) % MOD
    finv[i] = finv[i-1] * inv[i] % MOD

def comb(n,r):
    if n < r: return 0
    if n < 0 or r < 0: return 0
    return fac[n] * (finv[r] * finv[n-r] % MOD) % MOD

cs = []
ms = [(M * pow(M-1, N-1-K, MOD)) % MOD]
for i in range(K+1):
    cs.append(comb(N-1, i))
    if i:
        ms.append((ms[-1] * (M-1)) % MOD)

ans = 0
for c,m in zip(cs, ms[::-1]):
    ans += c*m
print(ans%MOD)


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

int main(){
	long x, y;
	cin >> x >> y;
	
	if(x<y) swap(x,y);
	
	while(x%y!=0){
		int z=x%y;
		x=y;
		y=z;	
	}
	
	cout << y << endl;
}

Measured memory_bytes: 1164
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let r: i64 = read();
    let g: i64 = read();
    let b: i64 = read();
    let n: i64 = read();

    let mut ans = 0;

    for i in 0..(n / r) + 2 {
        for j in 0..(n / g) + 2 {
            let tmp = n - i * r - g * j;
            if tmp >= 0 && (n - i * r - g * j) % b == 0 {
                ans += 1;
            }
        }
    }

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

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int n;
    cin >> n;
    vector<int> x;
    vector<int> ori;
    int left,right;
    for (int i=1; i<n+1; ++i)
    {
        int tmp;
        cin >> tmp;
        x.push_back(tmp);
        ori.push_back(tmp);
    }

    sort(x.begin(), x.end());
    left = x[(int)n/2-1];
    right = x[(int)n/2];

    for (int i=0; i<n; ++i)
    {
        if(ori[i]<=left)
        {
            cout << right << endl;
        }
        else
        {
            cout << left << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 3948
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define o0(a) cout<<a<<" "
#define o1(a) cout<<a<<"\n"
#define o2(a, b) cout<<a<<" "<<b<<"\n"
#define o3(a, b, c) cout<<a<<" "<<b<<" "<<c<<"\n"
#define i1(a) cin>>a
#define i2(a, b) cin>>a>>b
#define i3(a, b, c) cin>>a>>b>>c
#define fi first
#define se second

ll power(ll a, ll b, ll z = MOD)
{
	ll res = 1;
	a = (a%z);
	while(b)
	{
		if(b&1)
			res = (res*a)%z;
		a = (a*a)%z;
		b = b>>1;
	}
	return res;
}

ll inverse(ll a, ll z = MOD)
{
	return power(a, z-2, z);
}

ll gcd(ll a, ll b)
{
	ll temp;
	if(a < b)
	{
		temp = a;
		a = b;
		b = temp;
	}
	while(b)
	{
		temp = b;
		b = a - b;
		a = temp;
	}
	return a;
}

ll extend(ll a, ll b, ll &x, ll &y)
{
	if(b == 0)
	{
		x = 1;
		y = 0;
		return a;
	}
	ll x1, y1;
	ll g = extend(b, a%b, x1, y1);
	x = y1;
	y = x1- (a/b)*y1;
	return g;
}

ll mat_power(ll a, ll b, ll c, ll d, ll n, ll z = MOD)
{
	ll a0 = 1, b0 = 0, c0 = 0, d0 = 1;
	while(n)
	{
		if(n&1)
		{
			ll a1 = a0, b1 = b0, c1 = c0, d1 = d0;
			a0 = (a1*a + b1*c)%z;
			b0 = (a1*b + b1*d)%z;
			c0 = (c1*a + d1*c)%z;
			d0 = (c1*b + d1*d)%z;
		}
		ll a1 = a, b1 = b, c1 = c, d1 = d;
		a = (a1*a1 + b1*c1)%z;
		b = (a1*b1 + b1*d1)%z;
		c = (c1*a1 + d1*c1)%z;
		d = (c1*b1 + d1*d1)%z;
		n = n>>1;
	}
	return c0;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t = 1;
	// i1(t);
	while(t--)
	{
		ll n;
		i1(n);
		vector<int> v;
		while(n)
		{
			if((n%26) == 0)
			{
				v.push_back(26);
				n -= 26;
				n = n/26;
				continue;
			}
			v.push_back((n%26));
			n = n/26;
		}
		for(int i=v.size()-1;i>=0;i--)
			cout<<(char)(v[i]+'a'-1);
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	string S; cin >> S;
	int N = sz(S);
	F0R(i, N) {
		if (i % 2 == 0 && S[i] == 'L') {
			cout << "No" << endl; return 0;
		}
		if (i % 2 == 1 && S[i] == 'R') {
			cout << "No" << endl; return 0;
		}
	}
	
	cout << "Yes" << endl;
	
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N >> M;
    vector<int> S(N), T(M);
    for (int i = 0; i < N; ++i)
        cin >> S[i];
    for (int i = 0; i < M; ++i)
        cin >> T[i];

    vector<vector<ll>> dp(N + 2, vector<ll>(M + 2));
    dp[0][0] = 1;
    for (int i = 0; i <= N; ++i) {
        for (int j = 0; j <= M; ++j) {
            if (i > 0)
                dp[i][j] += dp[i - 1][j];
            if (j > 0)
                dp[i][j] += dp[i][j - 1];
            if (i > 0 && j > 0) {
                dp[i][j] -= dp[i - 1][j - 1];
                if (S[i - 1] == T[j - 1])
                    dp[i][j] += dp[i - 1][j - 1];
            }
            dp[i][j] %= MOD;
        }
    }

    if (dp[N][M] < 0)
        dp[N][M] += MOD;
    cout << dp[N][M] << endl;

    return 0;
}


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

K = int(input())

d = []
d.append([1] * 10)

for i in range(1, 10):
    m = []
    if i != 9:
        for j in range(10):
            if not j:
                m.append(d[i - 1][j] + d[i - 1][j + 1])
            elif j == 9:
                m.append(d[i - 1][j - 1] + d[i - 1][j])
            else:
                m.append(d[i - 1][j - 1] + d[i - 1][j] + d[i - 1][j + 1])
    else:
        for j in range(4):
            if not j:
                m.append(d[i - 1][j] + d[i - 1][j + 1])
            elif j == 9:
                m.append(d[i - 1][j - 1] + d[i - 1][j])
            else:
                m.append(d[i - 1][j - 1] + d[i - 1][j] + d[i - 1][j + 1])
    d.append(m)

n = 0
for i, x in enumerate(d):
    for j, y in enumerate(x):
        if not j:
            continue
        else:
            if n + y >= K:
                break
            else:
                n += y
    else:
        continue
    break

ans = []
am = K - n
ans = str(j)
for x in reversed(range(i)):
    if j != 0 and j != 9:
        if am <= d[x][j - 1]:
            ans += str(j - 1)
            j -= 1
        elif am <= d[x][j - 1] + d[x][j]:
            ans += str(j)
            am -= d[x][j-1]
        else:
            ans += str(j + 1)
            am -= d[x][j-1] + d[x][j]
            j += 1
    elif j == 9:
        if am <= d[x][j - 1]:
            ans += str(j - 1)
            j -= 1
        else:
            ans += str(j)
            am -= d[x][j-1]
    else:
        if am <= d[x][j]:
            ans += str(j)
        else:
            ans += str(j + 1)
            am -= d[x][j]
            j += 1

print(ans)


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

int main(){
    int N,M,C;
    cin >> N >> M >> C;
    
    vector<int> b(M);
    for(int i = 0; i < M; i++){
        cin >> b[i];
    }
    int res = 0;
    for(int i = 0; i < N; i++){
        int what = C;
        int a;
        for(int j = 0; j < M; j++){
            cin >> a;
            what += a*b[j];
        }
        if(what > 0){
            res += 1;
        }
    }
    
    cout << res << endl;
    
    return 0;
}

Measured memory_bytes: 256
/******************************************
* AUTHOR : HRITIK AGGARWAL *
******************************************/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
ll po(ll a, ll x,ll m){ if(x==0){return 1;}ll ans=1;ll k=1;  while(k<=x) {if(x&k){ans=((ans*a)%m);} k<<=1; a*=a; a%=m; }return ans; }
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)    
        cin>>a[i];
    sort(a,a+n);
    cout<<a[n/2]-a[n/2-1]<<"\n";
    //cout<<cnt<<"\n";
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int m,d;
    scanf("%d%d",&m,&d);
    int num = 0;
    for(int i = 1;i <= m;i++){
        for(int j = 22;j <= d;j++){
            if(j%10<2) continue;
            if((j%10)*(j/10) == i){
               // cout<<i<<" "<<j<<endl;
                num++;
            }
        }
    }
    printf("%d\n",num);
    return 0;
}


Measured memory_bytes: 256
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int l[500010], r[500010];
int dp[500010];

signed main() {
    int N; cin >> N;
    string s; cin >> s;
    rep(i,0,N) if(s[i] == '1') l[i+1] = l[i] + 1;
    repr(i,N-1,0) if(s[i] == '1') r[i+1] = r[i+2] + 1;

    repq(i,1,N) {
        chmax(dp[i], dp[i-1]);
        if(min(l[i-1], r[i+1]) == 0 || s[i-1] == '1') continue;

        int vl = l[i-1], vr = r[i+1];
        repq(k,1,vl) {
            chmax(dp[i+1], dp[i-k-1] + k);
        }
        repq(k,1,vr) {
            chmax(dp[i+k], dp[i-2] + k);
        }
    }
    cout << dp[N] << endl;
    return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef double db;

const ll mod  = 1e9+7;
const db eps  = 1e-9 ;
const ll maxn = 1e5+1;
const ll inf  = LLONG_MAX;
const ll minf = LLONG_MIN;

#define mp make_pair
#define pb push_back
#define endl "\n"
#define deb(x) cerr << #x << " " << x << endl

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

    string s,t;
    cin >> s >> t;

    for(ll i=0 ; i<s.size() ; ++i)
    {
        if(s[i]!=t[i])
        {
            cout << "No"; return 0;
        }
    }
    cout << "Yes";
    return 0;
} 

Measured memory_bytes: 3652
using System;

namespace A
{
    class Calc
    {
        public int fib(int n, ref int[] f)
        {
            if (n <= 1)
            {
                return 1;
            }
            else
            {
                if (f[n]!=0)
                {
                    return f[n];
                }
                else
                {
                    f[n] = fib(n - 1, ref f) + fib(n - 2, ref f);
                }
            }
            return f[n];
        }
    }

    class A
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            int n = int.Parse(input);
            int[] f = new int[n+1];
            Calc calc = new Calc();
            Console.WriteLine(calc.fib(n,ref f));
        }
    }
}



Measured memory_bytes: 17916
#include<bits/stdc++.h>
#define lint long long int
#define rep(i,n) for(int i=0;i<int(n);i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define arep(i,a,n) for(int i=a;i<n;i++)
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define fill(a,x) fill(a.begin(),a.end(),x)
#define eb(data) emplace_back(data)
#define pb(data) emplace_back(data)
#define mp make_pair
#define ALNUM 26
#define vint vector<int>
#define vlint vector<lint>
#define F first
#define S second
#define ALL(data) data.begin(),data.end()
#define GEts(s) getline(cin,s);
#define UNIQUE(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
using namespace std;
template<typename Rast>inline void out(Rast rast){cout<<rast<<"\n";return;}
template<typename Rast>inline void in(Rast& rast){cin>>rast;return;}
template<typename T>istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename First, typename... Rest>void in(First& first, Rest&... rest){cin >> first;in(rest...);return;}
template<typename First, typename... Rest>void out(First first, Rest... rest){cout << first<<" ";out(rest...);return;}
template<typename T>T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
template<typename T1,typename T2>bool chmax(T1& a,T2 b){if(a<b){a=b;return true;}else{return false;}}
template<typename T1,typename T2>bool chmin(T1& a,T2 b){if(a>b){a=b;return true;}else{return false;}}
template<typename T>T lcm(T a, T b){return a * b / gcd(a, b);}
static const double pi = 3.141592653589793;
lint modpow(lint a,lint n,lint p){if(n==1)return a%p;if(n%2==1)return (a*modpow(a,n-1,p))%p;lint t=modpow(a,n/2,p);return (t*t)%p;}//a^n%p
lint MOD=pow(10,9)+7;
//lint MOD=998244353;
lint inf=pow(2,50);
int intinf=pow(2,30);
/**/int dirx[]={1,0};int diry[]={0,1};//*///右、下
/**int dirx[]={0,1,0,-1};int diry[]={-1,0,1,0};//*///四方位
/**int dirx[]={-1,0,1,1,1,0,-1,-1};int diry[]={-1,-1,-1,0,1,1,1,0};//*///八方位

class unionfind{
public:
	vector<int> table;
	vector<int> wod;
	void init(int size){
		table.resize(size);
		wod.resize(size);
		rep(i,size)table[i]=i,wod[i]=i;
	};
	int root(int index){
		if(table[index]==index)return index;
		else{
			int hoge=root(table[index]);
			table[index]=hoge;
			return hoge;
		}
	};
	bool same(int x,int y){
		return(root(x)==root(y));
	};
	int marge(int x,int y){
		int yroot=root(y);
		int xroot=root(x);
		if(xroot==yroot)return 0;
		table[yroot]=xroot;
		return 0;
	}
};


int main(){
	cin.tie(0);ios::sync_with_stdio(false);cout<<std::fixed<<std::setprecision(12);
	int n;
	in(n);
	vint a(n);
	in(a);
	int ans=0;
	rep(i,n){
		if(i%2==0&&a[i]%2==1)ans++;
	}
	out(ans);
	return 0;
}


Measured memory_bytes: 3652
#include <iostream>

int calc_digit_number(int n){
	int ret = 0;
	while(n > 0){
		ret++;
		n /= 10;
	}
	return ret;
}

int main(int argc, char **argv){
	int a = 0;
	int b = 0;

	while(std::cin >> a >> b){
		std::cout << calc_digit_number(a + b) << std::endl;
	}
	return 0;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  cout << N*(N-1)/2 + M*(M-1)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  string S; cin>>S;
  int N=S.size();
  string ans="Yes";
  if(N%2==1) ans="No";
  else{
    rep(i,0,N){
      if(i%2==0&&S.substr(i,2)!="hi"){
        ans="No";
        break;
      }
    }
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a;
  for(int i = 0; i < n; i++){
    ll x;
    cin >> x;
    a.pb(x);
  }
  ll res[2] = {0, 0};
  for(int i = 0; i < 2; i++){
    ll sum = 0;
    for(int j = 0; j < n; j++){
      sum = sum + a[j];
      if(i == (j % 2)){
        if(sum <= 0){
          res[i] += abs(sum - 1);
          sum = 1;
        }
      }else{
        if(sum >= 0){
          res[i] += abs(sum + 1);
          sum = -1;
        }
      }
    }
  }
  cout << min(res[0], res[1]) << endl;
	return 0;
}


Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(100001);
    vector<int> dis(n, INF);
    vector<int> mark(n, -1);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    queue <int> q;
    q.emplace(0);
    while(!q.empty()){
        int x = q.front();
        q.pop();
        for(int v : to[x]){
            if(dis[v]!=INF) continue;
            dis[v]++;
            mark[v]=x;
            q.push(v);
        }
    }  
    cout << "Yes" << endl;
    for(int i = 1; i < n; ++i) {
        int ans = mark[i];
        ans++;
        cout << ans << endl; 
    }  
    return 0;
}

Measured memory_bytes: 10508
#include <stdio.h>

int main(void)
{
	int n, a, v;
	int i, max_n = 20, max = 0;
	
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		scanf("%d %d", &a, &v);
		
		if (max < v){
			max = v;
			max_n = a;
		}
		else if (max == v){
			if (max_n > a){
				max_n = a;
			}
		}
	}
	
	printf("%d %d\n", max_n, max);
	
	return (0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll a[100005];
ll dp[100005][2]; 
int main(){
	cin>>n;
	for (int i=1;i<=n;i++) cin>>a[i];
	if(a[1]!=0)dp[1][1]=(a[1]-1ll)/2ll;
	else dp[1][1]=-1e9;
	dp[1][0]=a[1]/2ll;
	for (int i=2;i<=n;i++){
		if(a[i]==0ll) dp[i][1]=-1e9,dp[i][0]=dp[i-1][0];
		else{
			dp[i][1]=(a[i]-1ll)/2ll+dp[i-1][0];
			if (a[i]>=2ll) dp[i][1]=max(dp[i][1],dp[i-1][1]+1ll+(a[i]-2ll)/2ll);
			dp[i][0]=max(a[i]/2ll+dp[i-1][0],dp[i-1][1]+1ll+(a[i]-1ll)/2ll); 
		}
	}
	cout<<dp[n][0];
}


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


#define lp(i, n)         for(int i=0;i<(int)(n);++i)
#define lpi(i, j, n)     for(int i=(j);i<(int)(n);++i)
#define lpd(i, j, n)     for(int i=(j);i>=(int)(n);--i)
#define sci(a)	scanf("%d",&a)
#define scll(a)	scanf("%lld",&a)
#define scii(a, b)	scanf("%d%d",&a, &b)
#define pri(a)	printf("%d\n",a)
#define prll(a)	printf("%lld\n",a)
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)


const double eps = 1e-8;

typedef  long long ll;

const ll mod = 1e9+7;

const int inf = 1<<30;
const int maxn = 1000500;//2e5+5;

//template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
//    return out << "(" << a.x << ", " << a.y << ")";
//}
//
//template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
//    out << "[";
//    forn(i, sz(v)) {
//        if(i) out << ", ";
//        out << v[i];
//    }
//    return out << "]";
//}



int n;
int a[maxn];
ll d;
vector<int> ans;

char s[maxn];

int f[10];

int norm(int x){
    x %= n;
    if(x < 0) x += n;
    return x;
}


inline void err(){
    puts("NO"); exit(0);
}

bool dp[1000500], vs[1000500];
bool rec(int n){
    if(n < 0) return 0;
    if(n <= 3) return 1;
    bool &ret = dp[n];
    if(vs[n]) return ret;
    vs[n] = 1;
    if(!rec(n-1) || !rec(n-2) || !rec(n-3))
        ret = 1;
    else
        ret = 0;
    return ret;
}

void solve() {
    int n,m; scii(n,m);
    puts(m>=n?"unsafe":"safe");
}


int main(){
   // freopen("in.txt","r",stdin);
    int tc = 1;
    //sci(tc);
    lp(tt,tc){
  //      printf("Case #%d: ",tt+1);
        solve();
    }
}

Measured memory_bytes: 3732
import math
from collections import defaultdict
N = int(input())
mod = 10 ** 9 + 7
d = defaultdict(int)

if (N == 1):
    print(1)
    exit()

for n in range(1, N + 1):
    for i in range(2, math.ceil(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            d[i] += 1

    if (n != 1):
        d[n] += 1

ans = 1
for i in d.values():
    ans *= (i + 1) % mod
    ans %= mod

print(ans)


Measured memory_bytes: 9724
def main():
    N, M = map(int, input().split())
    A = list(map(int, input().strip().split()))
    ans = N

    for i in A:
        if i > N:
            print(-1)
            return
        ans = ans - i
        if ans < 0:
            print(-1)
            return
    print(ans)

main()

Measured memory_bytes: 10040