akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <map>
#include <stack>
#include <bitset>
#include <array>
#include <set>
#include <string>

#include <iterator>
#include <algorithm>
#include <numeric>

#include <ios>
#include <sstream>
#include <iostream>
#include <fstream>

#include <climits>
#include <cmath>

using namespace std;

#define EPS (1e-7)
#define MOD ((int)1e9+7)
#define PI (atan(1.0)*4)

using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;
using vs=vector<string>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;

void OUT(bool isTrue, string t="YES", string f="NO"){
    cout<<(isTrue?t:f)<<endl;
}
void Out(bool isTrue, string t="Yes", string f="No"){
    cout<<(isTrue?t:f)<<endl;
}
void out(bool isTrue, string t="yes", string f="no"){
    cout<<(isTrue?t:f)<<endl;
}
void bulk(){}
template <class Head, class... Tail>
void bulk(Head& head, Tail&... tail){
    cin>>head;
    bulk(tail...);
}
template <typename T>
string printItr(T b, T e, string delim=" ")
{
    stringstream ss;
    ostream_iterator<decltype(*b)> out_it(ss, delim.c_str());
    copy(b,e - 1, out_it);
    ss<<*(e-1);
    return ss.str();
}

#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define range(i,m,n) for(int i=m; i<n;i++)
#define each(i,n) for(auto i:n)
#define all(i) i.begin(),i.end()
#define cint(...) int __VA_ARGS__;bulk(__VA_ARGS__);


int main(void){
    string a,b;
    cin>>a>>b;
    reverse(all(a));
    OUT(a==b);
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int x = n;
        int ans = 0;
        while(x != 0){
            ans += x % 10;
            x /= 10;
        }
        if(n % ans == 0){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    }
}


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

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

/*
int gcd(int a, int b){
	while(b){
		int r= a%b;
		a = b;
		b = r;
	}
	return a;
}
*/

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(auto &a_i : a) cin >> a_i;
	
	vector<int> L(n), R(n);
	L[0] = a[0];
	R[n-1] = a[n-1];
	
	for(int i=1; i<n; ++i){
		L[i] = gcd(L[i-1], a[i]);
		R[n-i-1] = gcd(R[n-i], a[n-i-1]);
	}
	
	int max_g = max(L[n-2],R[1]);
	for(int i=1; i+1<n; ++i){
		max_g = max(max_g, gcd(L[i-1],R[i+1]));
	}
	cout << max_g;
	
	return 0;
}

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define RREP0(i, n) for (int i = (n)-1; i >= 0; --i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define RREP1(i, n) for (int i = (n); i >= 1; --i)
#define pow10(n) int(1e##n + n)

typedef long long LL;
typedef pair<int, int> P;

const int INTINF = int(1e9) + 1;
const LL LLINF = LL(1e18) + 1;
long double eps = 1.0E-14;
LL gcd(LL a, LL b)
{
    return b ? gcd(b, a % b) : a;
};

LL gcd3(LL a, LL b, LL c)
{
    return gcd(a, gcd(b, c));
};

void solve()
{
    LL ans = 0;
    int K;
    cin >> K;
    REP1 (a, K)
    {
        REP1 (b, K)
        {
            REP1 (c, K)
            {
                ans += gcd3(a, b, c);
            }
        }
    }
    std::cout << ans << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(20);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;


int main() {
    int h, w, k;
    cin >> h >> w >> k;
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    vector<string> vs(1, string(w + 1, '*'));
    for (int i = 0; i < h; i++) {
        string s;
        cin >> s;
        s = "*" + s;
        vs.push_back(s);
    }
    vector<pair<int, int>> vp1, vp2;
    vp1.push_back(make_pair(x1, y1));
    int res = 0;
    while (vp1.size() > 0) {
        vp2.clear();
        for (auto node : vp1) {
            int x = node.first, y = node.second;
            if (x == x2 && y == y2) {
                cout << res << endl;
                return 0;
            }
            for (int i = 1; i <= k && x + i <= h && vs[x + i][y] != '@'; i++) {
                if (vs[x + i][y] == '.') vp2.push_back(make_pair(x + i, y));
                vs[x + i][y] = '*';
            }
            for (int i = 1; i <= k && x - i >= 1 && vs[x - i][y] != '@'; i++) {
                if (vs[x - i][y] == '.') vp2.push_back(make_pair(x - i, y));
                vs[x - i][y] = '*';
            }
            for (int i = 1; i <= k && y + i <= w && vs[x][y + i] != '@'; i++) {
                if (vs[x][y + i] == '.') vp2.push_back(make_pair(x, y + i));
                vs[x][y + i] = '*';
            }
            for (int i = 1; i <= k && y - i >= 0 && vs[x][y - i] != '@'; i++) {
                if (vs[x][y - i] == '.') vp2.push_back(make_pair(x, y - i));
                vs[x][y - i] = '*';
            }
        }
        vp1 = vp2;
        for (auto node : vp2) {
            vs[node.first][node.second] = '@';
        }
        res++;
    }
    cout << -1 << endl;
}


Measured memory_bytes: 6980
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;

ll N, A;

int main()
{
  std::cin >> N >> A;

  std::cout << (N%500 <= A ? "Yes" : "No") << std::endl;

  return 0;
}

Measured memory_bytes: 256
import collections

n = int(input())
l = [input() for _ in range(n)]
c = collections.Counter(l)

ans = []
count_max = max(c.values())
for i in c.items():
    if list(i)[1] == count_max:
        ans.append(list(i)[0])

ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 35572
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define MOD 1000000007

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

int main() {
	string s;
	cin >> s;
	int n = s.length()+1;
	int acclt[n];
	int accmt[n];
	acclt[0] = 0;
	rep(i,n-1) {
		if(s[i] == '<') {
			acclt[i+1] = acclt[i] + 1;
		}
		else {
			acclt[i+1] = 0;
		}
	}
	accmt[n-1] = 0;
	for(int i=n-2; i>=0; i--) {
		if(s[i] == '>') {
			accmt[i] = accmt[i+1] + 1;
		}
		else accmt[i] = 0;
	}
	int t[n];
	ll ans = 0;
	//rep(i,n) cout << acclt[i] << " ";
	//cout << endl;
	//rep(i,n) cout << accmt[i] << " ";
	//cout << endl;
	rep(i,n) {
		t[i] = max(acclt[i], accmt[i]);
		ans += t[i];
	}
	//rep(i,n) cout << t[i] << " ";
	//cout << endl;
	cout << ans << endl;

  return 0;
}

Measured memory_bytes: 6788
#include<bits/stdc++.h>
using namespace std;
int a[100005];
int main()
{
	int n;cin>>n;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	if(a[n]-a[1]>=2) puts("No");
	else if(a[n]==a[1]&&a[n]==n-1) puts("Yes");
	else
	{
		int pos;
		for(int i=1;i<=n;i++)
			if(a[i]!=a[i-1]) pos=i-1;
		int cnt=a[n]-pos;
		int cnt2=n-pos;
		if(cnt*2>cnt2||cnt<=0) puts("No");
		else puts("Yes");
	}
	return 0;
}

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

int main(){
	int N;
	cin>>N;
	if(N%10==3) cout<<"bon"<<endl;
    else if(N%10==0||N%10==1||N%10==6||N%10==8) cout<<"pon"<<endl;
    else cout<<"hon"<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define re register
#define M 998244353
#define int long long
using namespace std;
inline int read(){
	re int t=0;re char v=getchar();
	while(v<'0')v=getchar();
	while(v>='0')t=(t<<3)+(t<<1)+v-48,v=getchar();
	return t;
}
int n,m,a,b,c,d,ans,dp[3003][3003];
signed main(){
	a=read();b=read();c=read();d=read();
	for(re int i=1;i<=a;++i)for(re int j=1;j<=b;++j)dp[i][j]=1;
	for(re int i=1;i<=c;++i){
		for(re int j=1;j<=d;++j){
			if(i>a&&j>b)dp[i][j]=1ll*(1ll*j*dp[i-1][j]%M+1ll*i*dp[i][j-1]%M-1ll*(i-1)*(j-1)*dp[i-1][j-1]%M)%M;
			else if(i>a)dp[i][j]=(1ll*j*dp[i-1][j]%M)%M;
			else if(j>b)dp[i][j]=(1ll*i*dp[i][j-1]%M)%M;
		}
	}
	printf("%ld",(dp[c][d]+M)%M);
}

Measured memory_bytes: 74080
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()

}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let line = read_as_vec::<usize>();
    let (n, k) = (line[0], line[1]);

    let mut points: Vec<(i64, i64)> = vec![];

    for _ in 0..n{
        let line = read_as_vec::<i64>();
        let (x, y) = (line[0], line[1]);
        points.push((x, y));
    }

    //choose 2 on vertical line
    let mut ans = std::i64::MAX;
    for x1 in 0..n{
        for x2 in x1..n{
            let right = cmp::max(points[x1].0, points[x2].0);
            let left = cmp::min(points[x1].0, points[x2].0);

            for y1 in 0..n{
                for y2 in y1..n{
                    let upper = cmp::max(points[y1].1, points[y2].1);
                    let lower = cmp::min(points[y1].1, points[y2].1);

                    let mut k_counter = 0;
                    for &(x, y) in &points{
                        if x <= right && x >= left
                            && y <= upper && y >= lower{
                                k_counter += 1;
                        }
                    }

                    if k_counter >= k{
                        ans = cmp::min(ans, (right-left)*(upper-lower));
                    }
                }
            }
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<stdio.h>

int main(void){
	int sum=0,temp,temp1;
	int count=0;
	double q=0;
	
	while(scanf("%d,%d",&temp,&temp1)!=EOF){
		sum += temp*temp1;
		q += temp1;
		count++;
	}
	q=q/count;
	q+=0.5;
	temp=(int)q;
	printf("%d\n%d\n",sum,temp);
	return 0;
}

Measured memory_bytes: 588
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp15
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] input = Console.ReadLine().Split(' ');
			double A = double.Parse(input[0]);
			double B = double.Parse(input[1]);
			double H = double.Parse(input[2]);
			double M = double.Parse(input[3]);
			double pi = Math.PI;

			double argA = ((1 / 2) * pi) - ((2 * pi / 12) * H)-(2*pi/(12*60))*M;
			double argB = ((1 / 2) * pi) - ((2 * pi / 60) * M);
			double Ax = A* (Math.Cos(argA));
			double Ay = A * (Math.Sin(argA));
			double Bx = B * (Math.Cos(argB));
			double By = B * (Math.Sin(argB));
			double dist =Math.Sqrt(Math.Pow((Ax - Bx) , 2)+ Math.Pow((Ay - By), 2));
			Console.WriteLine(dist);


		}		
	}
}


Measured memory_bytes: 27912
#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>
#include <bitset>
#define chmin(a, b) ((a)=min((a), (b)))
#define chmax(a, b) ((a)=max((a), (b)))
#define fs first
#define sc second
#define eb emplace_back
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
const double eps=1e-10;

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

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

    vector<int> ans;
    vector<bool> used(n, false);
    int anscnt=0;
    for(int i=n-1; i>=0; i--){

        // 1 place
        int ub;
        for(int j=n-1; j>=0; j--){
            if(b[j] == 1 && !used[j]){
                ub = j;
                ans.eb(b[j]);
                used[j] = true;
                break;
            }
        }

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

                    if(cnt + 1 == b[j]){
                        used[j] = true;
                        ans.eb(b[j]);
                        break;
                    }
                }
            }
        }
    }

    if(ans.size() != n){
        cout << -1 << endl;
        return 0;
    }

    for(int i=0; i<ans.size(); i++){
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int W = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int ans = 0;

		if (Math.abs(a-b) > W) {
			ans = Math.abs(a-b) - W;
		} else {
			ans = 0;
		}
		System.out.println( ans );
	}
}


Measured memory_bytes: 21844
//file_name:ABC85_A.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    string s;
    cin >> s;
    s[3]='8';


    ll ans = 0;

    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#define MAX 100000
#define NIL (-1)
using namespace std;

struct Node {
    int parent;
    int right;
    int left;
};

Node T[MAX];

void pre(int u) {
    if ( u == NIL ) return;

    cout << " " << u;
    pre(T[u].left);
    pre(T[u].right);
}

void in(int u) {
    if ( u == NIL ) return;

    in(T[u].left);
    cout << " " << u;
    in(T[u].right);
}

void post(int u) {
    if ( u == NIL ) return;

    post(T[u].left);
    post(T[u].right);
    cout << " " << u;
}

int main() {
    int n;
    int id, l, r;
    cin >> n;
    for ( int i = 0; i < n; ++i ) {
        T[i].parent = NIL;
    }
    for ( int i = 0; i < n; ++i ) {
        cin >> id;
        cin >> l;
        cin >> r;
        T[id].left = l;
        T[id].right = r;
        if ( l != NIL ) T[l].parent = id;
        if ( r != NIL ) T[r].parent = id;
    }

    int root = 0;

    for ( int i = 0; i < n; ++i ) {
        if ( T[i].parent == NIL ) root = i;
    }

    cout << "Preorder" << endl;
    pre(root);
    cout << endl;
    cout << "Inorder" << endl;
    in(root);
    cout << endl;
    cout << "Postorder" << endl;
    post(root);
    cout << endl;

    return 0;
}


Measured memory_bytes: 3116
#!/usr/bin/env python3
#ABC142 C

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
a = LI()
b = []
for i in range(n):
    b.append((a[i],i+1))
b.sort(key = itemgetter(0))
ans = []
for i in range(n):
    ans.append(b[i][1])
print(*ans)

Measured memory_bytes: 68572
N,W = map(int,input().split())
WV = [[0,0]] + [list(map(int,input().split())) for _ in range(N)]

sumV = sum([v for _,v in WV])
dp = [[float('inf') for _ in range(sumV+1)] for _ in range(N+1)]
dp[0][0] = 0
for i in range(1, N+1):
  tmpw, tmpv = WV[i]
  for j in range(sumV+1):
    if j-tmpv>=0:
      dp[i][j] = min(dp[i-1][j],dp[i-1][j-tmpv]+tmpw)
    else:
      dp[i][j] = dp[i-1][j]

ans = -float('inf')
for row in dp:
  for j,w in enumerate(row):
    if w<=W and ans<j:
      ans = j
print(ans)

Measured memory_bytes: 321140
a,b,c,d = gets.chomp.split.map(&:to_i)

cnt_c = b/c - (a-1)/c
cnt_d = b/d - (a-1)/d
cnt_cd = b/c.lcm(d) - (a-1)/c.lcm(d)

puts b-a+1 - cnt_c - cnt_d + cnt_cd

Measured memory_bytes: 1788
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
	    long h, w;
	    long ans = 0;
	    Scanner scan = new Scanner(System.in);
 
	    h = scan.nextLong();
	    w = scan.nextLong();
 
	    if(h == 1 || w == 1) {
	    	System.out.println(1);
	    } else {
	    	if(w%2==0 || h%2==0) {
	  	      ans = (w*h)/2;
	  	    } else {
	  	      ans = (long)((w*h)/2) + 1;
	  	    }
	  		System.out.println(ans);
	    }
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(j,n) for(int j = 0; j < (n); ++j)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define drep2(j,n) for(int j = (n)-1; j >= 0; --j)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define srep2(j,s,t) for (int j = s; j < t; ++j)
#define srep3(k,s,t) for (int k = s; j < t; ++k)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int N;
  string S;
  int K;
  cin >> N >> S >> K;
  string ans = "";
  char str = S[K-1];
  rep(i,N){
    if(S[i] != str) {
      ans += "*";
    } else {
      ans += S[i];
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//
// Created by watemus on 01.05.2020.
//

#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>

using namespace std;

#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ff first
#define ss second

using ll = long long;
using ld = long double;
#define int ll

constexpr ll INFL = 1'000'000'000'000'000'228;
constexpr int INFI = 1'000'000'228;

#ifdef LOCAL
#else
#endif


void run() {
    int s, w;
    cin >> s >> w;
    cout << (w >= s ? "unsafe" : "safe") << '\n';
}

signed main() {
#ifdef LOCAL
    std::freopen("input.txt", "r", stdin);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif
    int t = 1;
//    cin >> t;
    while (t--) {
        run();
    }
    return 0;
}

Measured memory_bytes: 3648
import java.util.*;
import java.io.*;
import java.lang.*;

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

        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();
        long d = sc.nextLong();

        System.out.println( Math.max( (Math.max(a*c,a*d)),(Math.max(b*c,b*d)) ) );
    }
}


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

#define int long long

using namespace std;

const int N = 1e6 + 5;
const int mod = 1e9 + 7;

int n, dp[N][2][2];

void add (int &x, int y) {
    x += y;
    if (x >= mod) x -= mod;
}

signed main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 2; j++) {
            for (int k = 0; k < 2; k++) {
                if (dp[i][j][k]) {
                    for (int nxt = 0; nxt <= 9; nxt++) {
                        add(dp[i + 1][j | (nxt == 0)][k | (nxt == 9)], dp[i][j][k]);
                    }
                }
            }
        }
    }

    cout << dp[n][1][1];
    return 0;
}


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

#define ll long long

int main(){
	ll n,x;
	cin>>n;
	ll sz[n+5], ssz[n+5];
	fill_n(sz,n+5,0);
	fill_n(ssz,n+5,0);
	for(int i=0; i<n; i++){
		cin>>x;
		sz[--x]++;
	}
	ll mx=-1,sm=0;
	for(int i=0; i<n; i++){
		if(sz[i]>0) ssz[sz[i]]++;
		sm+=sz[i];
		if(mx<sz[i]) mx=sz[i];
	}
	for(int i=1; i<=n; i++){
		int o=n/i;
		while(mx>sm/i){
			ssz[mx-1]+=ssz[mx];
			sm-=ssz[mx];
			ssz[mx]=0;
			mx--;
		}
		if(sm>mx || i==1) cout<<sm/i<<endl;
		else cout<<0<<endl;
	}
}


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

#define MAXS (60)
#define MAXA (26)

int n;
int cnt[MAXA], tmp[MAXA];
char str[MAXS];

int main(){
	scanf("%d", &n);
	memset(cnt, 0x7f, sizeof cnt);
	for(int i = 1; i <= n; ++ i){
		scanf("%s", str);
		memset(tmp, 0, sizeof tmp);
		for(int j = 0; str[j]; ++ j){
			tmp[str[j] - 'a'] ++;
		}
		for(int j = 0; j < MAXA; ++ j){
			cnt[j] = std::min(cnt[j], tmp[j]);
		}
	}
	for(int i = 0; i < MAXA; ++ i){
		while(cnt[i] --){
			putchar('a' + i);
		}
	}
	putchar('\n');
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
const int MAX_N = 110;
int i, j, k, v, a[MAX_N], n;
void insertionSort(int A[MAX_N], int N) { // N??????????´??????????0-?????????????????????A
	for (i = 0; i < N-1; ++i) {
		cout << A[i] << " ";
	}
	if(i<N-1)cout<<A[N-1]<<endl;
	if(i==N-1)cout<<A[N-1]<<endl;
	for (i = 1; i < N; i++) {

		v = A[i];
		j = i - 1;
		while (j >= 0 && A[j] > v) {
			A[j + 1] = A[j];
			j--;
			A[j + 1] = v;
		}
		for (k = 0; k < N-1; ++k) {
				cout << A[k] << " ";
		}
		if(i<N-1)cout<<A[N-1]<<endl;
		if(i==N-1)cout<<A[N-1]<<endl;
	}


}

int main() {
	cin >> n;
	for (i = 0; i < n; ++i) {
		cin >> a[i];
	}
	insertionSort(a, n);
	return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define pf printf
#define sc(x) scanf("%d",&x);
#define scs(x) scanf("%s",x);
#define scl(x) scanf("%lld",&x);
#define rep(i,s,e) for(int i=s; i<=e; ++i)
#define dep(i,s,e) for(int i=s; i>=e; --i)
typedef long long ll;
using namespace std;
const int Max=2e5+5;
int a[Max],b[Max];
int main()
{
	int n;
	sc(n);
	for(int i=1;i<=n;i++){
		sc(a[i]);sc(b[i]);
	}sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	if(n%2==1){
		pf("%d\n",b[n/2+1]-a[n/2+1]+1);
	}else{
		pf("%d\n",(int)((1.0*(b[n/2+1]+b[n/2])/2-1.0*(a[n/2+1]+a[n/2])/2)*2+0.5)+1);
	} 
}


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

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

    int count = 0;

    for(int i = 0; i < S.size(); i++){
        if(S.at(i) == '1'){
            count++;
        }
        else if(S.at(i) == 0){
            return 0;
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 256
n = int(input())
x = [int(i) for i in input().split()]
c = []
for i,xi in enumerate(x):
  c.append(xi-i-1)
c.sort()
if n%2 == 1:
  b = c[n//2]
else:
  b = (c[n//2-1]+c[n//2])//2
ans = 0
for i in c:
  ans += abs(i-b)
print(ans)

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

int main() {
  int a,b,c,d,e ;
  cin >> a >> b >> c >> d >> e;
  if (a == 0) {
  cout << "1" << endl;
}
if (b == 0) {
  cout << "2" << endl;
}
   if (c == 0) {
  cout << "3" << endl;
}
   if (d == 0) {
  cout << "4" << endl;
}
   if (e == 0) {
  cout << "5" << endl;
}
  
  
  
  return 0;
}



Measured memory_bytes: 3596
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, f, n) for (ll i = (f); i < (n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define repv(v) for (auto it = (v).begin(); it != (v).end(); it++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define INIT    \
    cin.tie(0); \
    ios::sync_with_stdio(false);

template <class T>
inline bool chmax(T& a, T b) {
    return a = (a < b) ? b : a;
}
template <class T>
inline bool chmin(T& a, T b) {
    return a = (a > b) ? b : a;
}

ll const INF = 1LL << 60;
ll const MOD = 1000000007;

int main() {
    INIT;

    ll A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) {
        cout << "Possible" << endl;
    } else {
        cout << "Impossible" << endl;
    }

    return 0;
}

Measured memory_bytes: 3468
#include<iostream>
#include<algorithm>
#include<vector>
#include<sstream>
using namespace std;

bool comp(pair<int,int> x, pair<int,int> y){
    if(x.second != y.second)    return x.second > y.second;
    else                        return x.first < y.first;
}

int main(){
    int m;
    while(1){
        scanf("%d\n", &m);
        if(m == 0)  break;

        vector<pair<int,int>> v;
        
        for(int i = 0; i < m; i++){
            string x;
            getline(cin, x);
            stringstream ss;
            ss << x;
            int id, score = 0;
            ss >> id;
            int tmp, pos = 0, accum = 0, flame = 1;
            int bias[30] = {};
            bool first = true;
            while(flame < 10){
                ss >> tmp;
                score += tmp * (1 + bias[pos]);
                accum += tmp;
                if(first){
                    if(accum == 10){
                        bias[pos+1]++;
                        bias[pos+2]++;
                        accum = 0;
                        flame++;
                    }else{
                        first = false;
                    }
                }else{
                    if(accum == 10){
                        bias[pos+1]++;
                    }
                    first = true;
                    accum = 0;
                    flame++;
                }
                pos++;
            }

            while(ss >> tmp){
                score += tmp * (1 + bias[pos]);
                pos++;
            }    

            v.push_back({id, score});
        }

        sort(v.begin(), v.end(), comp);

        for(int i = 0; i < v.size(); i++){
            cout << v[i].first << " " << v[i].second << endl;
        }
    }
    return 0;
}


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

int main() 
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n,x;
    map<int,int> mp;
    while(cin >> n)
    {
        mp.clear();
        for(int i = 0; i < n; i++)
        {
            cin >> x;
            mp[x] = mp[x-1] + 1;
            if(mp.find(x-1) != mp.end())
                mp.erase(x-1);
        }
        int ans = n;
        for(auto it : mp)
            ans = min(ans, n - it.second);
        cout << ans << '\n';
    }    
    return 0;
}

Measured memory_bytes: 9600
n=int(input())
edge=[[]for i in range(n+1)]
for i in range(1,n+1):
    s=list(input())
    for j in range(i,n+1):
        if s[j-1]=="1":
            edge[i].append(j)
            edge[j].append(i)



ans=0
for i in range(1,n+1):
    bubun=[[] for iii in range(n+1)]
    bubun[0].append(i)
    check=0
    for j in range(n):
        for k in bubun[j]:
            for y in edge[k]:
                if y in bubun[j-1]:
                    continue
                elif y in bubun[j]:
                    break
                elif y in bubun[j+1]:
                    continue
                else:
                    bubun[j+1].append(y)
            else:
                continue
            break
        else:
            continue
        break
    else:
        for ii in bubun:
            if ii:
                check+=1
        ans=max(ans,check)
if ans==0:
    print(-1)
else:
    print(ans)
        

Measured memory_bytes: 43372
#include<stdio.h>
  
#define MAXLEN 20000
  
typedef struct Pool {
    int position;
    int area;
} P;
char buf[ MAXLEN+2 ];
int stack[ MAXLEN+2 ];
P areas[ 10002 ];
int sindex, aindex;
  
int main( int argc, char *argv[] )
{
    int pool, sum = 0;
    int i, j;
  
    fgets( buf, MAXLEN, stdin );   
    sindex = aindex = 0;
    for( i=0; '\0'!=buf[i]; i++ ) {
        if( '\\' == buf[i] ) {
            stack[ sindex++ ] = i;
        } else if( 0 < sindex && '/' == buf[i] ) {
            j = stack[ --sindex ];
            pool = i - j;
            sum += pool;
            while( 0 < aindex ) {
                if( j < areas[ aindex-1 ].position ) {
                    pool += areas[ --aindex ].area;
                } else {
                    break;
                }
            }
            areas[ aindex ].position = j;
            areas[ aindex++ ].area = pool;
        }
    }
    printf( "%d\n", sum );
    printf( "%d", aindex );
    if( 0 < aindex ) printf( " " );
    for( i=0; i<aindex; i++ ) {
        printf( "%d", areas[ i ].area );
        if( i != aindex-1 ) printf( " " );
    }
    printf( "\n" );
      
    return 0;
}

Measured memory_bytes: 1860
def f(s)
	s =~ /(\d?m)?(\d?c)?(\d?x)?(\d?i)?/
	[$1,$2,$3,$4].map{|x| x ? g(x) : 0}.inject(:+)
end

def g(s)
	n = 0
	s =~ /(\d?)(\w)/
	c = ($1 == "" ? 1 : $1.to_i)
	x = {?m => 1000, ?c => 100, ?x => 10, ?i => 1}[$2]
	c * x
end

def h(n)
	s = ""
	k = n / 1000
	s += (k > 1 ? k.to_s : "") + "m" if k > 0
	n %= 1000
	k = n / 100
	s += (k > 1 ? k.to_s : "") + "c" if k > 0
	n %= 100
	k = n / 10
	s += (k > 1 ? k.to_s : "") + "x" if k > 0
	n %= 10
	k = n
	s += (k > 1 ? k.to_s : "") + "i" if k > 0
	s
end

n = gets.to_i
n.times {
	x, y = gets.chomp.split
	puts h(f(x) + f(y))
}

Measured memory_bytes: 6120
using System;
using System.Collections.Generic;

public class Program
{
    public static void Main(string[] args)
    {
        var sa = Console.ReadLine().Split(' ');
        var list = new SortedSet<int>();
        list.Add(int.Parse(sa[0] + sa[1]) + int.Parse(sa[2]));
        list.Add(int.Parse(sa[0] + sa[2]) + int.Parse(sa[1]));

        list.Add(int.Parse(sa[1] + sa[2]) + int.Parse(sa[0]));
        list.Add(int.Parse(sa[1] + sa[0]) + int.Parse(sa[2]));

        list.Add(int.Parse(sa[2] + sa[1]) + int.Parse(sa[0]));
        list.Add(int.Parse(sa[2] + sa[0]) + int.Parse(sa[1]));
        Console.WriteLine(list.Max);
    }
}

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

using namespace std;

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

    vector<string> d(2);
    cin >> d[0] >> d[1];

    int idx = 0;
    long long res = 1;
    if (d[0][0] == d[1][0]) {
        idx += 1;
        res *= 3;
    } else {
        idx += 2;
        res *= 6;
    }

    while (idx < n) {
        if (d[0][idx - 1] == d[1][idx - 1]) {
            if (d[0][idx] == d[1][idx]) {
                idx += 1;
                res *= 2;
            } else {
                idx += 2;
                res *= 2;
            }
        } else {
            if (d[0][idx] == d[1][idx]) {
                idx += 1;
                res *= 1;
            } else {
                idx += 2;
                res *= 3;
            }
        }

        res %= 1000000007;
    }

    cout << res << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <atcoder/all>

using namespace std;
using namespace atcoder;

#define REP(i,n) for((i)=0;(i)<(int)(n);(i)++)
#define snuke(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

typedef long long ll;

int main(void){
	int N,M,i;
	
	cin >> N >> M;
	dsu d(N);
	
	int ans = N - 1;
	
	REP(i,M){
		int a,b;
		scanf("%d%d", &a, &b);
		a--; b--;
		
		if(!d.same(a, b)){
			d.merge(a, b);
			ans--;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3808
#include<stdio.h>
#include<string.h>
int main()
{
	char str[10000] = { 0 }, str2[10000];
	int i, m, n, j, joi, ioi;
	while (scanf("%s", str) != EOF){
		joi = 0;
		ioi = 0;
		n = strlen(str);
		for (i = 0; i < n; i++) {
			if (str[i] == 'J'&&str[i + 1] == 'O'&&str[i + 2] == 'I') {
				joi++;
			}
			if (str[i] == 'I'&&str[i + 1] == 'O'&&str[i + 2] == 'I') {
				ioi++;
			}
		}
		printf("%d\n%d\n", joi,ioi);
	}
	return 0;
}

Measured memory_bytes: 2696
//ITP1_7 Spreadsheet
// 20160313 make 7:08-7:20 make 2jigen hairetsu ni suru 7:20-
//tochuu oyasumi site 7:08-10:08 3jikan kaaaa
//??¢??°???"{"?????????????????????????????????indent-sexp(ESC C-q)or(C-M-q) ?????\???????????¨???????????¢??°?????´??¢???????????????????????????????????????

#include <stdio.h>
int main(void)
{
  int r,c;
  scanf("%d%d",&r,&c);//%d no aida ni kuurann ha irenakutemo yoi
  int i,j;
  // array initialization
  int A[101][101] = {0};

  // input and calculation
  for(i = 0; i < r; i++)
    {
      for(j = 0;j<c;j++)
        {
          scanf("%d",&A[i][j]);
          A[r][j] +=A[i][j];
          A[i][c] +=A[i][j];
        }
      A[r][c] +=A[i][j];
      }
  // output
  for(i = 0; i <= r; i++)
    {
      for(j = 0; j <= c;j++)
        {
          printf("%d",A[i][j]);
          if(j!=c)printf(" ");
        }
      if(i!=r)printf("\n");
    }
printf("\n");
return 0;
}

Measured memory_bytes: 652
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
 
        Scanner sc = new Scanner(System.in);
 
        while(true){
 
            int a = sc.nextInt();
            String op = sc.next();
            int b = sc.nextInt();
 
            if(op.equals("?"))break;
 
            int ans = 0;
 
            switch(op){
            case "+":
                ans = a+b;
                break;
            case "-":
                ans = a-b;
                break;
            case "*":
                ans = a*b;
                break;
            case "/":
                ans = a/b;
                break;
            }
 
            System.out.printf("%d\n", ans);
        }
    }
}


Measured memory_bytes: 26432
// Problem : D - Chat in a Circle
// Contest : AtCoder - AtCoder Beginner Contest 173
// URL : https://atcoder.jp/contests/abc173/tasks/abc173_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*
 *   ﷽
 * In the name of Allah, the Most Gracious, the Most Merciful
 */

#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>
#include <climits>

using namespace std;

int main()
{
	int n;
	cin>>n;
	vector<int> arr(n);
	n -= 2;
	for(auto &e : arr) cin >> e;
	sort(arr.rbegin(), arr.rend());
	unsigned long long int ans = arr[0];
	int i = 1;
	while(n > 1)
	{
		ans += 2*arr[i];
		n -= 2;
		i++;
	}
	if(n) ans+=arr[i];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 3676
using System;

namespace ABC087_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int x = int.Parse(str1);
            string str2 = Console.ReadLine();
            int a = int.Parse(str2);
            string str3 = Console.ReadLine();
            int b = int.Parse(str3);
            Console.WriteLine((x - a) % b);
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+100;
int a[maxn],v1[maxn],v2[maxn];
int main()
{
    int n;scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;scanf("%d",&x);
        if(i%2) v1[x]++;
        else v2[x]++;
    }
    int ma1=0,id1,ma2=0,id2;
    int Ma1=0,Id1,Ma2=0,Id2;
    for(int i=1;i<maxn;i++)
    {
        if(v1[i]>ma1) ma2=ma1,id2=id1,ma1=v1[i],id1=i;
        else if(v1[i]>ma2) ma2=v1[i],id2=i;
        if(v2[i]>Ma1) Ma2=Ma1,Ma1=v2[i],Id2=Id1,Id1=i;
        else if(v2[i]>Ma2) Ma2=v2[i],Id2=i;
    }
    if(id1!=Id1) printf("%d\n",n-ma1-Ma1);
    else printf("%d\n",n-max(ma1+Ma2,ma2+Ma1));
    return 0;
}


Measured memory_bytes: 1152
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

//#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << 0; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

void solve() {
    int k, x;
    cin >> k >> x;
    cout << (k * 500 >= x ? "Yes" : "No");
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


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

#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 INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    int N; cin>>N;
    if(N%10==0||N%10==1||N%10==6||N%10==8)cout<<"pon"<<endl;
    else if(N%10==3)cout<<"bon"<<endl;
    else cout<<"hon"<<endl;
}


Measured memory_bytes: 3636
##入力は以下の形式で標準入力から与えられる。
##N A B
n, a, b = gets.chomp.split(" ").map(&:to_i)

##制約
##1 ≤ N ≤ 10^4
##1 ≤ A ≤ B ≤ 36
##入力はすべて整数である

##1以上 N以下の整数のうち、
##10進法での各桁の和が A 以上 B 以下であるものの総和を出力せよ。
a_num = []
(1..n).each do |num|
  a_one = num.to_s.split("").map(&:to_i)
  
  sum = 0
  a_one.each do |v|
    sum += v
  end
  
  if sum >= a && sum <= b
    a_num << num
  end
end

# p a_num

sum_v = 0
a_num.each do |val|
  sum_v += val
end

p sum_v

Measured memory_bytes: 3836
import java.util.*;

class Main {
	static final Integer ZERO = Integer.valueOf(0);
	Scanner sc;
	int N, K;
	HashMap<Long, Integer> h;
	long[] S;
	
	private void calc() {
		sc = new Scanner(System.in);
		N = sc.nextInt();
		K = sc.nextInt();
		S = new long[N+1];
		h = new HashMap<>(N*4/3);
		
		S[0] = 0;
		for (int i = 1; i < N+1; i++) S[i] = (S[i-1] + (sc.nextInt() - 1))%K;
		long cnt = 0;
		for (int i = 1; i < N+1; i++) {
			long r = S[i-1];
			h.put( r, h.getOrDefault(r, ZERO) + 1);
			if (i >= K) {
				r = S[i-K];
				int v = h.get(r);
				if (v > 1) h.put(r, v-1);
				else h.remove(r);
			}
			cnt += h.getOrDefault(S[i]%K, ZERO);
		}
		System.out.println(cnt);
	}
	
	public static void main(String[] args) {
		new Main().calc();
	}
}


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

char s[1005];
int len;

int main() {
	scanf("%s" , s + 1);
	len = strlen(s + 1);
	if(s[len] == 's') s[++len] = 'e';
	s[++len] = 's';
	printf("%s" , s + 1);
	return 0;
}

Measured memory_bytes: 3208
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <utility>
#include <math.h>

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n) for(int i=1;i<=(n);i++)
#define lol long long
#define mp make_pair
#define fi first
#define se second
#define pu push_back
#define SYOU(x) setprecision(x+1)
#define abs(x,y) (max(x,y)-min(x,y))

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const int MOD=int(1e9)+7;

using namespace std;

/*lol x,a[25];
lol power;
void flutes(int i,lol sum){
    if(i==n){
	power=min(abs(x,sum),power);
	return;
    }
    if(sum>=x){
	power=min(abs(x,sum),power);
	return;
    }
    
    for(int j=i+1;j<=n;j++){
	flutes(j,sum+a[j]);
	power=min(abs(x,sum),power);
    }
    return;
    }*/

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,q;
    int l,r;
    string s;
    cin>>n>>q>>s;
    
    int ans[100005]={};
    rep(i,n){
	if(s[i]=='A' && s[i+1]=='C'){
	    ans[i]++;
	}
	ans[i]+=ans[i-1];
//	cout << ans[i] << " \n"[i == n - 1];
    }
    
    reps(i,q){
	cin>>l>>r;
//	cout<<ans[r-2]<<' '<<ans[l-2]<<'\n';
	cout<<ans[r-2]-ans[l-2]<<'\n';
    }

    return 0;
}


Measured memory_bytes: 1488
# ABC089D - Practical Skill Test
def main():
    H, W, D, *X = map(int, open(0).read().split())
    memo = {}  # memo[i] := coordinate of i
    for i, a in enumerate(zip(*[iter(X[: H * W])] * W), 1):
        for j, x in enumerate(a, 1):
            memo[x] = (i, j)
    dist = [0] * (H * W + 1)  # dist[i] := distance to i from 1
    for r in range(D + 1, H * W + 1):
        rx, ry = memo[r]
        l = r - D
        lx, ly = memo[r - D]
        dist[r] = dist[l] + abs(rx - lx) + abs(ry - ly)
    ans = []
    for l, r in zip(*[iter(X[H * W + 1 :])] * 2):
        ans.append(dist[r] - dist[l])
    print("\n".join(map(str, ans)))


if __name__ == "__main__":
    main()

Measured memory_bytes: 41976
#include<bits/stdc++.h>
using namespace std;
 bool exist[5001][5001];
 
inline bool check(int x, int y){
  if(x<0 || y<0 || x>5000 || y>5000)return false;
  return exist[x][y];
}
 
int main(){
  int n;
  while(cin >> n, n){
    memset(exist,0,sizeof(exist));
    vector<int> x(n), y(n);
 
    for(int i=0;i<n;i++){
      cin >> x[i] >> y[i];
      exist[x[i]][y[i]] = 1;
    }
 
    int ans = 0;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
    int dx = x[i]-x[j], dy = y[i]-y[j];
 
    if( check(x[i]+dy,  y[i]-dx) && check(x[j]+dy,  y[j]-dx) ){
      ans = max(ans, dx*dx + dy*dy);
    }
    if( check(x[i]-dy,  y[i]+dx) && check(x[j]-dy,  y[j]+dx) ){
      ans = max(ans, dx*dx + dy*dy);
    }
      }
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 25648
using System;

namespace Atcoder_program_test_Csharp
{
    using System;
    class Program
    {
        static void Main(string[] args)
        {
            int P, Q, R,Result_A, Result_B, Result_C;
            string line = Console.ReadLine();
            string[] str = line.Split(' ');
            P = int.Parse(str[0]);
            Q = int.Parse(str[1]);
            R = int.Parse(str[2]);
            Result_A = P + Q;
            Result_B = Q + R;
            Result_C = P + R;
            if (Result_A < Result_B)
            {
                if (Result_A < Result_C)
                {
                    Console.Write(Result_A);
                }
                else Console.Write(Result_C);
            }
            else if (Result_B < Result_C)
                 {
                   Console.Write(Result_B);
                 }
                 else Console.Write(Result_C);
        }
    }
}

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

int main()
{
int a,b,c;
cin>>a>>b>>c;
int k;
cin>>k;
while(k>0&&b<=a)
{
b*=2;
k--;
}

while(k>0&&c<=b)
{
c*=2;
k--;

}
if(b>a&&c>b)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;


return 0;
}

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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

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

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

  int n;
  cin >> n;

  vector<int> v(n);
  rep(i, n) { cin >> v[i]; }

  int ans = inf;

  REP(i, 100) {
    int sum = 0;
    rep(j, n) {
      sum += ((v[j] - i) * (v[j] - i));
    }
    debug(sum);
    ans = min(ans, sum);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static int aa = 0;

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

        for (char tmp : s.toCharArray()) {
            if (tmp == 'o') next--;
        }

        System.out.println(next - (15 - s.length()) <= 0 ? "YES" : "NO");

    }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;
const ll mod = 1000000007;

int main()
{
  ll n; cin >> n;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  ll l = 0, r = 0;
  ll x = 0;
  ll y = 0;
  ll ans = 0;
  while (l < n) {
    while (r < n) {
      x += a[r];
      y ^= a[r];
      r++;
      if (x != y) {
        r--;
        x -= a[r];
        y ^= a[r];
        break;
      }
      ans++;
    }
    x -= a[l];
    y ^= a[l];
    l++;
    ans += r-l;
}
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
N = int(input())
W = list(map(int, input().split()))
a = 0
b = sum(W)
dif = b

for i in range(N):
  a += W[i]
  b -= W[i]
  if dif > abs(b-a):
    dif = abs(b-a)
  else:
    break
    
print(dif)

Measured memory_bytes: 9168