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

#define int long long
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
constexpr int MOD = 1e9 + 7;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vec>;

template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) {
    return stream << p.first << " " << p.second;
}
template <typename T>
void print(const vector<vector<T>> matrix) {
    repall (vec, matrix)
        print(vec);
}
template <typename T>
void print(const vector<T> vec) {
    unsigned int len = vec.size();
    rep (i, len - 1)
        cout << vec[i] << ' ';
    cout << vec[len - 1] << '\n';
}
template <typename Arg>
void print(const Arg arg) {
    cout << arg << '\n';
}
template <typename Head, typename... Args>
void print(const Head head, const Args... args) {
    cout << head << " ";
    print(args...);
}
template <typename T>
T sum_(vector<T> vec, T init = 0) {
    return std::accumulate(all(vec), T(init));
}

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

template <typename T>
void init(vector<T>& v) {
    rep (i, v.size())
        cin >> v[i];
}

template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) {
    assert(v.size() == w.size());
    rep (i, v.size())
        cin >> v[i] >> w[i];
}

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

bool seisuu(int x) {
    double dd = sqrt((double)x) + 1e-5;
    return abs(dd - (int)(dd)) < 1e-3;
}

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    vector<vec> x(n, vec(d));

    rep (i, n)
        rep (j, d)
            cin >> x[i][j];

    int ans = 0;
    rep (i, n) {
        rep (j, n) {
            if (i >= j) continue;
            int sum = 0;
            rep (k, d)
                sum += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);

            bool ok = seisuu(sum);
            if (ok) ans++;
        }
    }
    print(ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a<=b) {
        cout << a << endl;
    } else {
        cout << a-1 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

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


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

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


/******************************************************************************************/



int main() {


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


	vector<int> alpha[30];
	vector<int> idx(26, 0);


	vector<int> cnt1(26, 0);
	vector<int> cnt2(26, 0);

	for (int i = 0; i < s.size(); i++)
	{
		cnt1[s[i] - 'a']++;
		alpha[s[i] - 'a'].push_back(i);
	}

	for (int i = 0; i < t.size(); i++)
	{
		cnt2[t[i] - 'a']++;
	}


	for (int i = 0; i < 26; i++)
	{
		if (cnt2[i] > 0 && cnt1[i] == 0) {
			cout << "-1" << endl;
			return 0;
		}
	}


	//ここからはうまくできるケース

	ll mini = -1;
	ll cycle = 0;
	ll siz = s.size();

	for (int i = 0; i < t.size(); i++)
	{
		ll id = mini - siz * cycle + 1;

		if (id >= siz) {
			
			cycle++;
			id = mini - siz * cycle + 1;
			auto itr = lower_bound(alpha[t[i] - 'a'].begin(), alpha[t[i] - 'a'].end(), id);//場所が決まる
			mini = *itr + siz * cycle;
		}
		else
		{
			//取りあえずにぶたん
			auto itr = lower_bound(alpha[t[i] - 'a'].begin(), alpha[t[i] - 'a'].end(), id);

			if (itr == alpha[t[i] - 'a'].end()) {
				cycle++;
				id = mini - siz * cycle + 1;
				itr = lower_bound(alpha[t[i] - 'a'].begin(), alpha[t[i] - 'a'].end(), id);//場所が決まる
			}
			mini = *itr + siz * cycle;
		}
	}

	cout << mini + 1 << endl;//1-index




	return 0;
}


Measured memory_bytes: 1216
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> A(N), B(N), C(N);
    REP(i, 0, N) cin >> A[i];
    REP(i, 0, N) cin >> B[i];
    REP(i, 0, N) cin >> C[i];
    sort(ALL(B));
    sort(ALL(C));

    vector<ll> BC(N);
    REP(i, 0, N) {
        BC[i] = C.end() - upper_bound(ALL(C), B[i]);
        // cout << "B : " << B[i] << " , cnt : " << BC[i] << endl;
        if (i > 0) BC[i] += BC[i - 1];
    }

    ll ans = 0;
    REP(i, 0, N) {
        int idx = upper_bound(ALL(B), A[i]) - B.begin();
        if (idx == 0) {
            ans += BC[N - 1];
        } else {
            ans += BC[N - 1] - BC[idx - 1];
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cstdio>
using namespace std;
typedef long long LL;
const int N = 5010 , mod = 1e9+7;
int n , cnt;
int head[N] , g[N] , siz[N] , f[N][N] , tmp[N];
struct edge{ int v , nex; }e[N << 1];
inline void add(int u , int v) { e[++cnt].v = v; e[cnt].nex = head[u]; head[u] = cnt; return ; }

void dfs(int x , int fa)
{
    siz[x] = 1; f[x][1] = 1;
    for(int i = head[x] , v; i ; i = e[i].nex)
    {
        v = e[i].v; if(v == fa) continue; dfs(v , x);
        for(int j = 0 ; j <= siz[x] + siz[v] ; ++j) tmp[j] = 0;
        for(int j = 1 ; j <= siz[x] ; ++j)
            for(int k = 0 ; k <= siz[v] ; ++k)
                (tmp[j + k] += (LL)f[x][j] * f[v][k] % mod) %= mod;
        for(int j = 0 ; j <= siz[x] + siz[v] ; ++j) f[x][j] = tmp[j];
        siz[x] += siz[v];
    }
    for(int i = 2 ; i <= siz[x] ; i += 2)
        (f[x][0] += mod - (LL)f[x][i] * g[i] % mod) %= mod;
}

int main()
{
    scanf("%d" , &n); int u , v;
    for(int i = 1 ; i <  n ; ++i) scanf("%d%d" , &u , &v) , add(u , v) , add(v , u);
    g[0] = 1;
    for(int i = 2 ; i <= n ; i += 2) g[i] = (LL)g[i-2] * (i-1) % mod;
    dfs(1 , 0);
    cout << mod - f[1][0] << '\n';
    return 0;
}

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

int main() {

    int n;

    cin >> n;

    map<string, int> m;

    m["AC"] = 0;
    m["WA"] = 0;
    m["TLE"] = 0;
    m["RE"] = 0;

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

        string s;
        cin >> s;


        m[s]++;

    }

    cout << "AC x " << m["AC"] << endl;
    cout << "WA x " << m["WA"] << endl;
    cout << "TLE x " << m["TLE"] << endl;
    cout << "RE x " << m["RE"] << endl;

    return 0;

}

Measured memory_bytes: 3632
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		String s1 = "";
		String s2 = "";
		String s3 = "";
		for(int i = 0; i < s.length(); i++) {
			if(i == 0) {
				s1 = s.substring(0, 1);
			} else if(i == 1) {
				s2 = s1;
				s1 = s.substring(1, 2);
				if(s2.equals(s1)) {
					System.out.println(1 + " " + 2);
					return;
				}
			} else {
				s3 = s2;
				s2 = s1;
				s1 = s.substring(i, i + 1);
				if(s1.equals(s2)) {
					System.out.println(i + " " + (i + 1));
					return;
				} else if(s1.equals(s3)) {
					System.out.println((i - 1) + " " + (i + 1));
					return;
				}
			}
		}
		System.out.println(-1 + " " + -1);
	}
}


Measured memory_bytes: 30064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(ll i=(a);i<=(b);i++)
#define repi(i,n) fori(i,0,(n)-1)
#define forr(i,a,b) for(ll i=(b);i>=(a);i--)
#define repr(i,n) forr(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()
#define vec vector<ll>
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

string ways="rsp";
ll scores[3];
void solve(ll n, ll k, ll r, ll s, ll p, string t){
    scores[0]=r;
    scores[1]=s;
    scores[2]=p;
    ll ans=0;
    repi(i,k){
        ll cur=0;
        ll dp[2][3];
        repi(j,2)repi(l,3)dp[j][l]=0;
        for(ll j=i;j<n;j+=k){
            ll prev=1-cur;
            repi(m,3){
                ll tmp=0;
                repi(n,3){
                    if(m==n)continue;
                    chmax(tmp,dp[prev][n]+(t[j]==ways[m]?scores[(m+2)%3]:0));
                }
                dp[cur][m]=tmp;
            }
            cur=prev;
        }
        ll ma=0;
        repi(i,3)chmax(ma,dp[1-cur][i]);
        ans+=ma;
    }
    cout<<ans<<endl;
}

int main(){
    ll n;
    scanf("%lld",&n);
    ll k;
    scanf("%lld",&k);
    ll r;
    scanf("%lld",&r);
    ll s;
    scanf("%lld",&s);
    ll p;
    scanf("%lld",&p);
    string t;
    cin >> t;
    solve(n, k, r, s, p, t);
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <math.h>
using namespace std;


int main()
{
	int N;
	vector<int> A;

	cin >> N;

	for(int i=0; i<N+1; i++){
		A.push_back(0);
	}

	for(int i=0; i<N-1; i++){
		int tmp;
		cin >> tmp;
		A[tmp]++;
	}

	for(int i=1; i<N+1; i++){
		cout << A[i] << endl;
	}

	 
	return 0;
	
}

Measured memory_bytes: 4320
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;


int main() {
	int n, m;
	cin >> n >> m;
	vector<bool>is_AC(n, false);
	int ac = 0;
	vector<int>wa_num(n);
	for (int i = 0; i < m; i++) {
		int a;
		string s;
		cin >> a >> s;
		if (s == "AC" && !is_AC[a - 1]) {
			ac++;
			is_AC[a - 1] = true;
		}
		else if (s == "WA" && !is_AC[a - 1]) {
			wa_num[a - 1]++;
		}
	}
	int wa = 0;
	for (int i = 0; i < n; i++) {
		if (is_AC[i])wa += wa_num[i];
	}
	cout << ac << " " << wa << endl;
	return 0;
}


Measured memory_bytes: 640
Sa=input()
Sb=input()
Sc=input()

ia,ib,ic=1,0,0
card=Sa[0]

while True:
  if card=='a':
    if ia==len(Sa):
      print('A')
      break
    card=Sa[ia]
    ia+=1
  if card=='b':
    if ib==len(Sb):
      print('B')
      break
    card=Sb[ib]
    ib+=1
  if card=='c':
    if ic==len(Sc):
      print('C')
      break
    card=Sc[ic]
    ic+=1

Measured memory_bytes: 3064
#include <stdio.h>

int main(void) 
{
    double a, b, c, d, e, f;
    double x, y;

    while (scanf("%lf%lf%lf %lf%lf%lf",&a, &b, &c, &d, &e, &f) != EOF) {

        y = (c*d - a*f) / (b*d - a*e);

        if (y == -0) {
            y = 0;
        }

        x = (c - b * y) / a;

        if (x == -0) {
            x = 0;
        }

        printf("%.3f %.3f\n", x, y);
    }
    
    return 0;

}

Measured memory_bytes: 652
#include <iostream>
#include <stdint.h>

const int64_t MOD=1e9+7;

struct State{
  int64_t cnt[3][3];
  State(){
    for(int a=0;a<3;a++){
      for(int b=0;b<3;b++){
	cnt[a][b]=0;
      }
    }
  }
  void canon(){
    for(int a=0;a<3;a++){
      for(int b=0;b<3;b++){
	cnt[a][b]%=MOD;
      }
    }
  }
};

int main(){
  std::string str;
  std::cin>>str;
  struct State s;
  s.cnt[0][0]=1;
  for(char c:str){
    struct State next;
    if(c=='0'||c=='?'){
      for(int a=0;a<3;a++){
	for(int b=0;b<3;b++){
	  next.cnt[a][b%2+1]+=s.cnt[a][b];
	}
      }
    }
    if(c=='1'||c=='?'){
      for(int a=0;a<3;a++){
	for(int b=0;b<3;b++){
	  if(b>0){
	    next.cnt[a][b-1]+=s.cnt[a][b];
	  }else{
	    next.cnt[std::min(2,a+1)][b]+=s.cnt[a][b];
	  }
	}
      }
    }
    next.canon();
    s=next;
    /*
      for(int a=0;a<3;a++){
      for(int b=0;b<3;b++){
      printf("state[%d][%d]=%ld\n",a,b,s.cnt[a][b]);
      }
      }
    */
  }
  int64_t total=0;
  for(int a=0;a<3;a++){
    for(int b=0;b<3;b++){
      if(a>=b){
	total+=s.cnt[a][b];
	total%=MOD;
      }
    }
  }
  std::cout<<total<<std::endl;
  return 0;
}


Measured memory_bytes: 900
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let v: Vec<isize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();
    let mut x: isize = 0;
    let mut y: isize = 0;
    let mut z: isize = v[0];
    let mut w: isize = v[1];

    for _ in 0..v[2] {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let u: Vec<isize> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect();

        if u[2] == 1 {
            if u[0] > x {x = u[0];}
        } else if u[2] == 2 {
            if u[0] < z {z = u[0];}
        } else if u[2] == 3 {
            if u[1] > y {y = u[1];}
        } else if u[2] == 4 {
            if u[1] < w {w = u[1];}
        }
    }
    println!("{}", (if z - x > 0 {z - x} else {0}) * (if w - y > 0 {w - y} else {0}));
}



Measured memory_bytes: 4352
def parse_hash(s, pointer):
  head = s[pointer]
  if head == "[":
    pointer += 1
    op, pointer = parse_op(s, pointer)
    h1, pointer = parse_hash(s, pointer)
    h2, pointer = parse_hash(s, pointer)
    return calc(op, h1, h2), pointer + 1
  else:
    l, pointer = parse_letter(s, pointer)
    return l, pointer
 
def parse_op(s, pointer):
  return s[pointer], pointer + 1

def parse_letter(s, pointer):
  return int(s[pointer]), pointer + 1

def calc(op, h1, h2):
  if op == "+":
    return h1 | h2
  if op == "*":
    return h1 & h2
  if op == "^":
    return h1 ^ h2

from collections import defaultdict
from itertools import product
while True:
  s = input()
  if s == ".":break
  p = input()
  score = defaultdict(int)
  nums = [chr(i) for i in range(ord("0"), ord("9") + 1)]
  for a, b, c, d in product(nums, repeat=4):
    temp = s.replace("a", a)
    temp = temp.replace("b", b)
    temp = temp.replace("c", c)
    temp = temp.replace("d", d)
    score[parse_hash(temp, 0)[0]] += 1
  
  for i in range(4):
    s = s.replace(chr(ord("a") + i), p[i])
  hs = parse_hash(s, 0)
  print(hs[0], score[hs[0]])


Measured memory_bytes: 6016
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()



using namespace std;
ll N;
ll K;
ll A[100010] = {};

ll get_gcd(ll a,ll b){
  if(b > a) swap(a,b);
  if(b==0) return a;
  ll tmp = b;
  b = a % b;
  a = tmp;
  return get_gcd(a,b);
}


int main() {
  cin>>N>>K;
  REP(i,N) cin>>A[i];
 // cout<<get_gcd(N,K);
 int g = A[0];
 bool flag = false;
 while(1){
   REP(i,N){
   g = get_gcd(g,A[i]);
   if(A[i] < K) continue;
   else flag = true;
 }
 if(!flag) {cout<<"IMPOSSIBLE"<<endl; return 0;}

 if(g == 1){cout<<"POSSIBLE"<<endl; return 0;}
 if(K % g != 0){cout<<"IMPOSSIBLE"<<endl; return 0;}
 REP(i,N) A[i] /= g;
 K /=g;

 }



  return 0;
}

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

using namespace std;

int main() {

	int n;
	cin >> n;
	int maxx = 0;
	int counter = 0;
	int maxnum = 0;
	int tmp;
	for (int i = 1; i <= n; i++) {
		tmp = i;
		counter = 0;
		while (tmp % 2 == 0) {
			tmp /= 2;
			counter++;
		}
		if (counter > maxx) {
			maxx = counter;
			maxnum = i;
		}
	}
	if (n != 1) {
		cout << maxnum << endl;
	}
	else { cout << 1 << endl; }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(0); cin.tie(); cout.tie();mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount



int t, n, m, k, q, l, r;



int32_t main(){
INIT
cin>>n;
vector<int> a; a.assign(n, 0);

for(int i=0; i<n; i++){
    cin>>a[i];
}
sort(a.begin(), a.end());
vector<bool> sv; sv.assign(1000010, false);
vector<bool> v; v.assign(1000010, false);
int r=0;


for(int i=0; i<n; i++){
    if(!sv[a[i] ]){v[a[i] ]=true;}
    else{
        v[a[i] ]=false; continue;
    }
   for(int j=a[i]; j<=1000000 && a[i]!=0; j+=a[i]){
    sv[j]=true;
   }
}

for(int i=1; i<=1000000; i++){
    if(v[i]==true){
        r++;
    }
} cout<<r;


return 0;
}


Measured memory_bytes: 4340
package main

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

func main() {
        var n, c, k int
        fmt.Scan(&n, &c, &k)
        sc := bufio.NewScanner(os.Stdin)
        sc.Split(bufio.ScanWords)
        ts := make([]int, 0, n)
        for i := 0; i < n; i++ {
                sc.Scan()
                a, _ := strconv.Atoi(sc.Text())
                ts = append(ts, a)
        }
        sort.Sort(sort.IntSlice(ts))
        limit, load, numOfBus := -math.MaxInt32, 0, 0
        for _, t := range ts {
                if t > limit {
                        numOfBus++
                        load = 1
                        limit = t + k
                } else if load == c {
                        numOfBus++
                        load = 1
                        limit = t + k
                } else {
                        load++
                }
        }
        fmt.Printf("%d\n", numOfBus)
}

Measured memory_bytes: 2944
M, D = map(int, input().split())

M_list = list(range(1, M + 1, 1))
D_list = list(range(1, D + 1, 1))

ans = 0

for i in range(M):
    
    for j in range(D):
        
        if D_list[j] <= 21:
            ans += 0
        else:
            d1 = str(D_list[j])[-1]   
            d1 = int(d1)

            d2 = str(D_list[j])[-2]   
            d2 = int(d2)

            if d1 < 2 or d2 < 2:
                ans += 0
            else:
                if d1 * d2 == M_list[i]:
                    ans += 1
print(ans)    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const string EMP = " ";
const ll INF = 1LL<<60;
const ll MOD = 1000000007;

int main(){
  int h,w; cin >> h >> w;

  vector<string> g(h);
  rep(i,h) cin >> g[i];
  vector<bool> ch(h,false), cw(w,false);

  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(g[i][j] == '#') break;
      if(j+1 == w) ch[i] = true;
    }
  }
  for(int i = 0; i < w; i++){
    for(int j = 0; j < h; j++){
      if(g[j][i] == '#') break;
      if(j+1 == h) cw[i] = true;
    }
  }
  for(int i = 0; i < h; i++){
    if(ch[i]) continue;
    for(int j = 0; j < w; j++){
      if(cw[j]) continue;
      cout << g[i][j];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
printV = lambda x: print(*x, sep="\n")
printH = lambda x: print(" ".join(map(str,x)))
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	S = IS()
	S=list(map(int,"".join(S)))
	def dfs(i, total, additional):
		if i==len(S)-1:
			return total+additional
		else:
			return dfs(i+1, total, additional*10+S[i+1]) + dfs(i+1, total+additional, S[i+1])
	print(dfs(0,0,S[0]))


if __name__ == '__main__':
	main()

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <ctime>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to
#define mp(a, b) make_pair(a, b)

using namespace std;

typedef long long LL;
const int mod = 1e9 + 7;
const int N = 100010;

struct Edge{ int to, next;} edge[N];
int head[N], num, a[N], d[N];
void add_edge(int a, int b) { edge[++ num] = (Edge){b, head[a]}, head[a] = num;}

bool vis[N], v0[N];
int q[N], cnt, loop[N], nl[N], len[N], c0[N], ql[N];
void dfs(int x)
{
	vis[x] = true, q[++ cnt] = x;
	RepG(i, x) if (!vis[v]) dfs(v);
	if (!vis[a[x]]) dfs(a[x]);
}

LL w2[N], p[N], invp[N], f[N];
LL qpow(LL a, LL b)
{
	LL ret = 1, base = a;
	while (b){
		if (b & 1) ret = ret * base % mod;
		base = base * base % mod, b >>= 1;
	} 
	return ret;
}

LL C(int a, int b) { return p[a] * invp[b] % mod * invp[a - b] % mod;}

int main()
{
	//freopen("e.in", "r", stdin);
	//freopen("e.out", "w", stdout);
	
	int n;
	scanf("%d", &n);
	Rep(i, n){
		scanf("%d", &a[i]);
		add_edge(a[i], i), d[a[i]] ++;
	}
	LL ans = 1;
	Rep(i, n) if (!vis[i]){
		cnt = 0, dfs(i);
		bool flag = true;
		Rep(j, cnt) if (d[q[j]] != 1) flag = false;
		if (flag) loop[cnt] ++;
		else {
			int x = i, ll = 0;
			while (true) {
				if (c0[x]) break;
				c0[x] ++, x = a[x];
			}
			ql[++ ll] = x, v0[x] = true;
			for (int j = a[x]; j != x; j = a[j]) ql[++ ll] = j, v0[j] = true;
			Rep(j, ll) {
				bool flag0 = false;
				int x0 = ql[j];
				while (true){
					int cc = 0, tmp0;
					RepG(k, x0) if (!v0[edge[k].to]) cc ++, tmp0 = edge[k].to;
					if (!cc) break;
					else if (cc >= 2) { flag0 = true; break;}
					else x0 = tmp0, len[ql[j]] ++;
				}
				if (flag0) { printf("0\n"); return 0;}
			}
			int cl = 0;
			for (int j = ll; j; j --) {
				if (len[ql[j]]) break;
				cl ++;
			}
			Rep(j, ll) {
				nl[ql[j]] = ++ cl;
				if (len[ql[j]]){
					if (len[ql[j]] < nl[ql[j]]) ans = ans * 2 % mod;
					else if (len[ql[j]] > nl[ql[j]]) { printf("0\n"); return 0;}
					cl = 0;
				}
			}
		}
	}
	//printf("%lld\n", ans);
	w2[0] = 1, p[0] = 1, f[0] = 1;
	Rep(i, n){
		w2[i] = w2[i - 1] * 2 % mod, p[i] = p[i - 1] * i % mod;
		if (!(i & 1)) f[i] = f[i - 2] * (i - 1) % mod;
	}
	invp[n] = qpow(p[n], mod - 2);
	for (int i = n - 1; i >= 0; i --) invp[i] = invp[i + 1] * (i + 1) % mod;
	
	
	Rep(i, n) if (loop[i]) {
		//printf("%d %d\n", i, loop[i]);
		LL tmp = 0;
		for (int j = 2; j <= loop[i]; j += 2) {
			if ((i & 1) && i != 1) tmp += C(loop[i], j) * f[j] % mod * qpow(i, j / 2) % mod * w2[loop[i] - j] % mod;
			else tmp += C(loop[i], j) * f[j] % mod * qpow(i, j / 2) % mod;
			//printf("%d %lld\n", j, C(loop[i], j) * f[j] % mod * qpow(i, j / 2) % mod);
		}
		if ((i & 1) && i != 1) tmp = (tmp + w2[loop[i]]) % mod;
		else tmp = (tmp + 1) % mod;
		ans = ans * tmp % mod;
	}
	
	printf("%lld\n", ans);
	
	return 0;
}
/*
10
1 2 10 6 4 5 7 8 3 9

4
1 2 3 4

2
1 2
*/

Measured memory_bytes: 10880
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var s = int.Parse(spl[0]);
        var w = int.Parse(spl[1]);

        return s <= w ? "unsafe" : "safe";
    }
}


Measured memory_bytes: 27304
while 1:
   a, op, b = raw_input().split()
   A = int(a)
   B = int(b)
 
   if op == '?':
      break
   elif op == '+':
      print A+B
   elif op == '-':
      print A-B
   elif op == '*':
      print A*B
   elif op == '/':
      print A/B

Measured memory_bytes: 6436
#include<stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

typedef struct card{
                    char suit;
                    int value;
                     }card;

card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(card A[], int left, int mid, int right) {
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  for ( i = 0; i < n1; i++ ) L[i] = A[left + i];
  for ( i = 0; i < n2; i++ ) R[i] = A[mid + i];
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  for ( k = left; k < right; k++ ) {
    if ( L[i].value <= R[j].value )
      A[k] = L[i++];
    else
      A[k] = R[j++];
  }
}

void mergeSort(card A[], int left, int right) {
  int mid;
  if ( left + 1 < right ) {
    mid = (left + right) / 2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

int partition(card A[], int p, int r) {
  int i, j;
  card t, x;
  x = A[r];
  i = p - 1;
  for ( j = p; j < r; j++ )
    if ( A[j].value <= x.value ) {
      i++;
      t = A[i]; A[i] = A[j]; A[j] = t;
    }
  t = A[i + 1]; A[i + 1] = A[r]; A[r] = t;
  return i + 1;
}

void quickSort(card A[], int p, int r) {
  int q;
  if ( p < r ) {
    q = partition(A, p, r);
    quickSort(A, p, q - 1);
    quickSort(A, q + 1, r);
  }
}

int main() {
  int n, i, v;
  card A[MAX], B[MAX];
  char S[10];
  int stable = 1;

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }

  mergeSort(A, 0, n);
  quickSort(B, 0, n - 1);

  for ( i = 0; i < n; i++ )
    if ( A[i].suit != B[i].suit ) stable = 0;

  if ( stable == 1 ) printf("Stable\n");
  else printf("Not stable\n");
  for ( i = 0; i < n; i++ )
    printf("%c %d\n", B[i].suit, B[i].value);

  return 0;
}


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

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

def LI(): return list(map(int, sys.stdin.readline().split()))
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,t = LI()

    return t // a * b


print(main())



Measured memory_bytes: 7748
def main():
    A, B, C = map(int, input().split())
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        return 0
    else:
        return min(A*B, B*C, C*A)

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 38256
a = input()
b = input()
c = input()
sa = [a[i] for i in range(len(a))]
sb = [b[i] for i in range(len(b))]
sc = [c[i] for i in range(len(c))]

n = 'a'

while True:
  if n == 'a':
    if len(sa) == 0:
      print('A')
      break
    else:
      n = sa.pop(0)
  elif n == 'b':
    if len(sb) == 0:
      print('B')
      break
    else:
      n = sb.pop(0)
  else:
    if len(sc) == 0:
      print('C')
      break
    else:
      n = sc.pop(0)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define next Next
/*char buf[1<<21],*p1=buf,*p2=buf;
inline int gc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}*/
#define gc getchar
inline int read()
{
	int ret=0,f=0;char c=gc();
	while(!isdigit(c)){if(c=='-')f=1;c=gc();}
	while(isdigit(c)){ret=ret*10+c-48;c=gc();}
	if(f)return -ret;return ret;
}
int n;
string s;
signed main()
{
	n=read();cin>>s;
	if(n<3200)puts("red");
	else cout<<s;
}

Measured memory_bytes: 256
S = input()
a = b = c = 0
for s in S:
    if s == "0":
        c += b > 0
        a += b == 0
        b = max(0, b-1)
    elif s == "1":
        c += a > 0
        b += a == 0
        a = max(0, a-1)
print(c*2)

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

char flip(char ch) {
	if (ch=='H') return 'D';
	else if (ch=='D') return 'H';
}

int main() {
	string str;
	getline(cin, str);
	bool flag = true;
	if (str[0]=='D') {
		flag = false;
	}

	if (!flag) {
		cout << flip(str[2]) << endl;
	}
	else cout << str[2] << endl;
	return 0;
}

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

using namespace std;

int main()
{
    int n,d,x;
    cin >> n >> d >> x;

    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        ans += (d-1)/a+1;
    }
    cout << ans+x << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <cstdio>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
using namespace std;
#define INF 1LL << 30
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad) / 2 / M_PI) * 360)
struct edge
{
    ll to, cost, val;
};
template <class T, class U>
bool chmin(T &a, const U &b)
{
    if (a <= b)
        return false;
    a = b;
    return true;
}
template <class T, class U>
bool chmax(T &a, const U &b)
{
    if (a >= b)
        return false;
    a = b;
    return true;
}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll

int f(string s){
    vector<int> V;
    int count=1;
    char now=s[0];
    s=s+"?";
    for(int i=1;i<(int)s.size();i++){
        if(s[i]==now) count++;
        else{
            now=s[i];
            V.push_back(count);
            count=1;
        }
    }
    int ans=0;
    for(int i:V){
        ans+=i/2;
    }
    return ans;
}

signed main(void)
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S;
    ll K;
    cin>>S>>K;
    bool flag=true;
    for(int i=1;i<(int)S.size();i++){
        if(S[0]!=S[i]) flag=false;
    }
    if(flag){
        cout<<(int)S.size()*K/2<<endl;
        return 0;
    }
    int A=f(S+S);
    int B=f(S);
    //cout<<A<<" "<<B<<endl;
    cout<<B+(A-B)*(K-1)<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
    int n,k;
    scanf("%d%d",&n,&k);
    int x[n],grp[n],flg=0;

    for (int i = 0; i < n; ++i) {
        scanf("%d",&x[i]);
    }

    for (int i = 0; i < n-k+1; ++i) {
        if(x[i]<0 && 0<x[i+k-1]){
            grp[i]=-x[i]+x[i+k-1]+(-x[i]<x[i+k-1]?-x[i]:x[i+k-1]);
        } else if(x[i]<0){
            grp[i]=-x[i];
        } else
            grp[i]=x[i+k-1];
    }

    int min=grp[0];
    for (int i = 0; i < n - k + 1; ++i) {
        min=(min>grp[i]?grp[i]:min);
    }
    printf("%d",min);
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
int main()
{
    char a,b,c;
    cin>>a>>b>>c;
    int ans = 0;
    if(a=='R'&&b=='R'&&c=='R')
        ans = 3;
    else if((a=='R' && b=='R')|| (b=='R'&&c=='R'))
        ans= 2;
    else if(a=='R'||b=='R'||c=='R')
        ans =1;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
ll H,W,M;
ll Y[300005];
ll X[300005];
int main(){
  cin>>H>>W>>M;
  vector<P>A(M);
  for(ll i=0;i<M;i++){
  ll y,x;cin>>y>>x;
    P p(y,x);A[i]=p;
  Y[y]++;X[x]++;
  }ll ymax=0;ll xmax=0;
  for(ll i=1;i<=H;i++)
    if(ymax<Y[i])ymax=Y[i];
  for(ll i=1;i<=W;i++)
    if(xmax<X[i])xmax=X[i];
  set<ll>Symax;set<ll>Sxmax;
  for(ll  i=1;i<=H;i++)
    if(Y[i]==ymax)Symax.insert(i);
  for(ll i=1;i<=W;i++)
    if(X[i]==xmax)Sxmax.insert(i);
  ll ans=ymax+xmax;ll sum=0;
  for(ll i=0;i<M;i++){
  ll y=A[i].first;
    ll x=A[i].second;
    if(Symax.count(y) && Sxmax.count(x))
      sum++;
  }ll a=Symax.size();ll b=Sxmax.size();
  if(sum==a*b)ans--;
  cout<<ans<<endl;
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  ll now = 0;
  rep(i, n){
    ll a;
    cin >> a;
    if (i == 0) now = a;
    else {
      if (now < a) now = a;
      else if (now > a) ans += now - a;
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3628
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(a){return a?cin[cid++]:+cin[cid++];}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

var myOut = main();
if(myOut !== undefined)console.log(myOut);
function main(){
  var s = next(1), t = next(1);
  var a = next(), b = next();
  var u = next(1);
  if(s === u)a--; else b--;
  return a+" "+b;
}

Measured memory_bytes: 22076
#include <bits/stdc++.h>
#define N 200010
using namespace std;

char s[N],ans[N];
int len,nxt[N][30],F[N];
int main()
{
	scanf("%s",s);
	len=strlen(s);
	for(int i=0;i<26;i++)
	{
		nxt[len][i]=len;
		for(int j=len-1;j>=0;j--)
		{
			if(s[j]=='a'+i) nxt[j][i]=j;
			else nxt[j][i]=nxt[j+1][i];
		}
	}
	memset(F,0x3f,sizeof(F)); F[len+1]=0;
	for(int i=len-1;i>=0;i--) for(int j=0;j<26;j++)
		if(F[i]>F[nxt[i][j]+1]+1) 
				ans[i]='a'+j, F[i]=F[nxt[i][j]+1]+1;
	int i=0,l=0; while(l<F[0]) 
	{
		l++; printf("%c",ans[i]);
		i=nxt[i][ans[i]-'a']+1;
	}puts("");
	return 0;
}

Measured memory_bytes: 24832
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b;cin>>n>>a>>b;
  ll ans=a*(n/(b+a))+min(a,n%(b+a));
  print(ans);
  return 0;
}

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

const int N=2020,mod=1000000007;
int f[N][2],n,m,K,ans;
inline void reduce(int&x){x+=x>>31&mod;}
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>n>>m>>K;
	f[0][0]=1;
	for(int i=1;i<=n+m;++i){
		for(int j=0,k=0;j<=n;++j){
			if(j>=K)reduce(k-=f[j-K][0]);
			reduce(f[j][0]+=f[j][1]-mod);
			f[j][1]=k;reduce(k+=f[j][0]-mod);
			if((n-j)%(K-1)==0&&i*(K-1)<=m+j-1)reduce(ans+=f[j][1]-mod);
		}
	}
	cout<<ans<<'\n';
	return 0;
}


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

using namespace std;

#define pb          push_back
#define mp          make_pair
#define po          pop_back
#define fi          first
#define se          second
#define mxn         100001
#define ll          long long int
#define ldb         long double
#define fr(i,a,b,k)   for(ll i=a ; i<b ; i+=k)
#define frr(i,a,b,k)  for(ll i=a ; i>b ; i-=k)
#define endl        "\n"
#define deg(x)      cout<<endl<<#x<<" = "<<(x)<<endl;
#define fast        ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL));

typedef pair<ll,ll> pp;
typedef vector<ll> vi;
typedef vector<pp> vpp;
typedef vector<vi> vvi;

const int inf = INT_MAX;

ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
ll gcd(ll a,ll b){ return __gcd(a,b);}
ll lcm(ll a,ll b){return a*b/__gcd(a,b);}

void solve(ll test){

    ll n;
    cin >> n;
    vi dp(10000001,1);
    dp[0]=0;
    for(ll i=2 ; i<=n ; i++){
        for(ll j=i ; j<=n ; j+=i){
            dp[j]++;
        }
    }

    ll count = 0;
    for(ll i=0 ; i<=n ; i++){
        count += (i*dp[i]);
    }

    cout << count;

}

int main(){

    fast;
    int t=1;
    // cin >> t;
    for(int i=1 ; i<=t ; i++){
        solve(i);
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 81324
#include <cstdio>
#include <algorithm>
using namespace std;

int field[10][10], x, y, s, cnt, ma;

void s1()
{
    if (y - 1 >= 0) field[x][y-1]++;
    if (x - 1 >= 0) field[x-1][y]++;
    if (y + 1 < 10) field[x][y+1]++;
    if (x + 1 < 10) field[x+1][y]++;
}

void s2()
{
    s1();
    if (x - 1 >= 0 && y - 1 >= 0) field[x-1][y-1]++;
    if (x - 1 >= 0 && y + 1 < 10) field[x-1][y+1]++;
    if (x + 1 < 10 && y - 1 >= 0) field[x+1][y-1]++;
    if (x + 1 < 10 && y + 1 < 10) field[x+1][y+1]++;
}

void s3()
{
    s2();
    if (y - 2 >= 0) field[x][y-2]++;
    if (x - 2 >= 0) field[x-2][y]++;
    if (y + 2 < 10) field[x][y+2]++;
    if (x + 2 < 10) field[x+2][y]++;
}

int main()
{
    while(scanf("%d,%d,%d",&x,&y,&s) != EOF) {
        field[x][y]++;
        if      (s == 1) s1();
        else if (s == 2) s2();
        else if (s == 3) s3();
    }

    for(int i=0;i < 10;++i) {
        for(int j=0;j < 10;++j) {
            if (!field[i][j]) ++cnt;
            else ma = max(ma, field[i][j]);
        }
    }
    printf("%d\n%d\n", cnt, ma);

    return 0;
}

Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
const int N =5e5+5;
char s[N];
int L[N],R[N],n;

int main()
{
    scanf("%s", s+1);
    n=strlen(s+1)+1;
    for(int i=1;i<=n;i++)
        L[i]=(s[i-1]=='<')*(L[i-1]+1);
    for(int i=n;i;i--)
        R[i]=(s[i]=='>')*(R[i+1]+1);
    long long ans=0;
    for(int i=1;i<=n;i++){
        ans += max(L[i],R[i]);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 4608
#include<iostream>
#include<cstdio>

#define REP(i,b,c) for(int i=b;i<(int)c;i++)
#define rep(i,c) REP(i,0,c)

using namespace std;

int main(){
  char move1[1000];
  int i,j,k,n,m,jewel[1000][1000],move2[1000],count;
  int mapQ[50][50],startx,starty;


  for(i=0;i<=20;i++){
    for(j=0;j<=20;j++)mapQ[i][j]=0;
  }

  while(1){
for(i=0;i<=20;i++){
    for(j=0;j<=20;j++)mapQ[i][j]=0;
  }


    count = 0;
    cin >> n;
    if(n == 0)break;

    rep(i,n){
      cin >> jewel[i][0] >> jewel[i][1];
      mapQ[20-jewel[i][1]][jewel[i][0]]=1; //ツ陛ウツ静篠づ個暗環置ツづーツマツッツプツ湘」ツづ可篠ヲツつキツ（ツ１ツづ可渉可甘コツ可サツ）
	
	}

  

    cin >> m;

    rep(i,m)cin >> move1[i] >> move2[i];

    startx=10;
    starty=10;
    mapQ[starty][startx]=2; //ツスツタツーツトツ地ツ点ツづー2ツづ可渉可甘コツ可サ

    rep(i,m){
      for(j=1;j<=move2[i];j++){
	if(move1[i] == 'N'){
	  mapQ[--starty][startx];
	  if(mapQ[starty][startx] == 1)count++;
	    mapQ[starty][startx]=0;
	}
	else if(move1[i] == 'E'){
	  mapQ[starty][++startx];
	  if(mapQ[starty][startx] == 1)count++;
	  	 mapQ[starty][startx]=0;
	}
	else if(move1[i] == 'S'){
	  mapQ[++starty][startx];
	  if(mapQ[starty][startx] == 1)count++;
	   mapQ[starty][startx]=0;
	}
	else if(move1[i] == 'W'){
	  mapQ[starty][--startx];
	  if(mapQ[starty][startx] == 1)count++;
	  mapQ[starty][startx]=0;
	}

      }
    }
    //    rep(i,21){
    //   rep(j,21)cout << mapQ[i][j] << " - " ;
    //   cout << endl; 
    //   }
    //   cout << "count =" << count <<  " n =" << n << endl;    

    
    count == n ? cout << "Yes" << endl : cout << "No" << endl ; 
    
    
  }
  
  
 return 0;
 
}

 

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <queue>
#include <math.h>
#include <set>
#include <stack>
#include <deque>
#include <bitset>
using namespace std;

int main()
{
	long a, b;
	cin >> a >> b;

	if (a % 2 != b % 2)
	{
		cout << "IMPOSSIBLE" << endl;
	}
	else
	{
		cout << (a + b) / 2 << endl;
	}
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a.insert(0, 0)
a.append(0)
total = 0
for i in range(n+1):
    total += abs(a[i+1] - a[i])

for i in range(1, n+1):
    num = abs(a[i+1] - a[i]) - abs(a[i+1] - a[i-1]) + abs(a[i] - a[i-1])
    print(total - num)


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

#define ff first
#define ss second
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define boost ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define track(x) cout << #x << " : " << (x) << endl
#define all(v) v.begin(),v.end() 
#define allr(v) v.rbegin(),v.rend() 
//#define endl '\n'  
typedef  long long ll; 
typedef  unsigned long long ull; 
typedef vector< ll > edge; 
typedef pair< ll , ll > mypair;
typedef priority_queue <ll> max_heap;
typedef priority_queue <ll, vector<ll>, greater<ll> > min_heap;
const ll mod=1000000007;
const ll inf=1e15;
const ll N=3e5+10;
ll n,k;
ll v[60];
ll get(ll l,ll r)
{
	std::vector<ll> temp;
	for(ll i=0;i<l;i++) temp.pb(v[i]);
	for(ll i=r+1;i<n;i++) temp.pb(v[i]);
	sort(all(temp));
	ll ans=0;
	ll lim=k-(ll)temp.size();
	if(lim<0) return 0;
	for(auto &i:temp)
	{
		if(i<0 and lim) lim--;
		else ans+=i;
	}
	return ans;

}
int main()
{
	boost;
	cin>>n>>k;
	for(ll i=0;i<n;i++) cin>>v[i];
	ll ans=0;
	for(ll l=-1;l<n;l++)	
	{
		for(ll r=l;r<n;r++)
		{
			ans=max(ans,get(l,r));
		}
	}
	cout<<ans;
	
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  string S;
  cin >> N >> S;
  vector<char> vec = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  string ans = S;
  for (int i = 0; i < S.size(); i++) {
    char c = S.at(i);
    int j;
    for (j = 0; c != vec.at(j); j++) {
    };
    j = (j+N)%26;
    ans.at(i) = vec.at(j);
  };
  cout << ans << endl;
}

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

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		String str = br.readLine();
		char[] carray = str.toCharArray();
		for(int i = 0, k = carray.length ; i < k ; i++) {
			for(int j = 0 ; j < n ; j++) {
				if(carray[i] =='Z') {
					carray[i]='A';
				}else {
					carray[i]++;
				}
			}
		}
		String result = "";
		for(int i = 0, k = carray.length ; i<k;i++) {
			result += carray[i];					
		}
		System.out.println(result);
	}

}


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

typedef long long ll;
typedef long double ld;
typedef vector < ll > vl;
typedef vector < int > vi;
typedef vector < bool > vb;
typedef vector < vl > vvl;
typedef vector < vi > vvi;
typedef pair < int, int > pii;
typedef pair < ll, ll > pll;
typedef vector < pll > vpll;
typedef vector < pii > vpii;
typedef vector < vpll > vvpll;
typedef vector < vpii > vvpii;

#define pb push_back
#define eb emplace_back
#define pf push_front
#define all(c) (c).begin(), (c).end()
#define ff first
#define ss second
#define mp(x,y) make_pair((x), (y))
#define boost ios_base::sync_with_stdio(false); cin.tie(NULL)

const int N = 5e5+5;
const int BLK = 707;

int col[N], cnt[N], res[N];
int ans = 0;

class Query{
    public:
    int L, R, id;

    Query(int L, int R, int id) : L(L), R(R), id(id) {

    }

    bool operator < (const Query& other) const {
        if(L / BLK == other.L / BLK)
            return (L / BLK % 2) ? R < other.R : R > other.R;
        return L / BLK < other.L / BLK;
    }
};

void add(int cur){
    cnt[col[cur]]++;
    if(cnt[col[cur]] == 1)
        ans++;
}

void rem(int cur){
    cnt[col[cur]]--;
    if(cnt[col[cur]] == 0)
        ans--;
}

void solve(){
    
    int n, q; cin >> n >> q;
    for(int i = 1; i <= n; i++){ cin >> col[i]; }
    vector< Query > query;
    for(int i = 0; i < q; i++){
        int L, R; cin >> L >> R;
        query.eb(L, R, i);
    }
    sort(all(query));
    memset(cnt, 0, sizeof(cnt));
    int curL = 1, curR = 0;
    for(Query q : query){
        int L = q.L, R = q.R;
        while(curR < R){
            curR++;
            add(curR);
        }
        while(curR > R){
            rem(curR);
            curR--;
        }
        while(curL < L){
            rem(curL);
            curL++;
        }
        while(curL > L){
            curL--;
            add(curL);
        }
        res[q.id] = ans;
    }
    for(int i = 0; i < q; i++){ cout << res[i] << '\n'; }
    
}


int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    boost;

    int t = 1;
    // cin >> t;


    for(int i = 1; i <= t; i++){
        // cout << "Case #" << i << ": ";

        solve();

    }
    return 0;
}

Measured memory_bytes: 15560
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		String s = sc.next();
		if(s.equals("A")){
			System.out.println("T");
		}else if(s.equals("T")){
			System.out.println("A");
		}else if(s.equals("C")){
			System.out.println("G");
		}else{
			System.out.println("C");
		}
	}
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);;
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		int count = 0;
		for(int i = a; i <= b; i++) {
			if(c % i == 0) {
				count++;
			}
		}
		System.out.println(count);
		scan.close();
	}
}


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

Measured memory_bytes: 3760
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
const double pi = acos(-1);
const int maxn = 2e6 + 10;
const double eps = 1e-8;
const ll mod = 1e9 + 7;
const ull base = 131;
const ull mod1 = 1e9 + 9;
const ull mod2 = 1610612741;

ll a, b, c;

int main()
{
    scanf("%lld %lld.%lld", &a, &b, &c);
    ll ans = a*b + a*c/100;
    printf("%lld\n", ans);
    return 0; 
}

Measured memory_bytes: 3816