akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

double bd[] = {48,51,54,57,60,64,69,75,81,91};
string cs[] = {"light fly","fly","bantam","feather","light","light welter","welter","light middle","middle","light heavy","heavy"};
int main()
{
	double w;
	while(cin >> w)
	{
		string str=cs[10];
		for(int i=0; i<10; i++)
		{
			if(w<=bd[i])
			{
				str = cs[i];
				break;
			}
		}
		cout << str << endl;
	}

}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <stack>
#include <string>
#include <vector>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
 
int main()
{
    string s;
    cin >> s;
    int cnt = 0;
    for (int i = 0; i < s.size()/2; i++)
    {
        if (s[i] != s[s.size()-1-i])
        {
            cnt++;
        }
        
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3608
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // C - xxxxx

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();

        int[] x = new int[n];
        int[] y = new int[n];

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

        List<int[]> ptn = new ArrayList<int[]>();

        for (int j = 0; j < n; j++) {
            setPtn(0, j, new int[n], ptn);
        }

        double dist = 0;
        double total = 0;
        double ave = 0;
        for (int[] route : ptn) {
            for (int i = 0; i < n - 1; i++) {
                dist = Math
                        .sqrt(Math.pow(x[route[i]] - x[route[i + 1]], 2) + Math.pow(y[route[i]] - y[route[i + 1]], 2));
                total += dist;
            }
//            System.out.println("total=" + total);
        }
        ave = total / ptn.size();

        System.out.println(ave);
    }

    static void setPtn(int d, int c, int[] idx, List<int[]> ptn) {
        //        System.out.println(
        //                "setPtn start d=" + d + " ,c=" + c + " ,idx=" + Arrays.toString(idx) + " ,ptn.size=" + ptn.size());
        for (int k = 0; k < d; k++) {
            if (c == idx[k]) {
                //                System.out.println("setPtn c==idx[" + k + "] (" + idx[k] + ")");
                return;
            }
        }
        idx[d] = c;
        if (idx.length - 1 > d) {
            for (int l = 0; l < idx.length; l++) {
                //                System.out.println("setPtn re");
                setPtn(d + 1, l, idx, ptn);
            }
        } else {
//            System.out.print("setPtn add ");
            int[] tmpidx = idx.clone();
//            System.out.println(Arrays.toString(tmpidx));
            ptn.add(tmpidx);
        }
    }

}


Measured memory_bytes: 24132
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

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

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll n, k;
    cin >> n >> k;
    vll a(n + 1);
    rep(i, n) cin >> a[i + 1];
    vector<bool> visit(n+1, false);
    ll cur = 1;
    vll history;
    history.push_back(cur);
    visit[cur] = true;
    ll nxt;
    while(true) {
        nxt = a[cur];
        if(visit[nxt]) break;
        history.push_back(nxt);
        visit[nxt] = true;
        cur = nxt;
    }
    ll loop_st;
    for(ll i = 0; i < history.size(); i++) {
        if(history[i] == nxt) {
            loop_st = i;
            break;
        }
    }
    ll ans;
    if(k < loop_st) ans = history[k];
    else {
        k -= loop_st;
        k %= history.size() - loop_st;
        ans = history[loop_st + k];
    }
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

int main(){
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	REP(i, N) cin >> a[i];
	sort(a.begin(), a.end());

	int l = -1;
	int u = N;
	while(u-l > 1){
		int i = (l+u)/2;
		bool need = false;
		bool DP[K], DP_tmp[K];
		REP(j, K) DP[j] = false;
		DP[0] = true;
		REP(j, N){
			REP(k, K) DP_tmp[k] = DP[k];
			if (j==i) continue;
			REP(k, K){
				if (DP_tmp[k] && k+a[j]<K){
					DP[k+a[j]]=true;
				}
			}
		}
		for(int j=max(K-a[i], 0ll);j<K;j++){
			if (DP[j]) need = true;
		}
		if(need){
			u = i;
		}else{
			l = i;
		}
	}

	cout << u << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    int M = scanner.nextInt();
    int[] a = new int[A];
    int[] b = new int[B];
    int minA = 1_000_000;
    int minB = 1_000_000;
    for (int i = 0; i < A; i++) {
      a[i] = scanner.nextInt();
      minA = Math.min(minA, a[i]);
    }
    for (int i = 0; i < B; i++) {
      b[i] = scanner.nextInt();
      minB = Math.min(minB, b[i]);
    }
    int min = minA + minB;
    for (int i = 0; i < M; i++) {
      int x = scanner.nextInt() - 1;
      int y = scanner.nextInt() - 1;
      int c = scanner.nextInt();
      min = Math.min(min, Math.max(a[x] + b[y] - c, 0));
    }
    System.out.println(min);
  }
}


Measured memory_bytes: 149920
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
class b{
    public static void Main(){
        string s = Console.ReadLine();
        string sub = Console.ReadLine();
        int ans = Int32.MaxValue;
        for(int i=0; i<=(s.Length-sub.Length); i++){
            int temp = CountSub(s,sub,i);
            if(ans > temp){
                ans = temp;
            }
        }
        Console.WriteLine(ans);
    }
    public static int CountSub(string s, string sub, int strt){
        int count = 0;
        for(int i=0; i<sub.Length; i++){
            if(s[i+strt] != sub[i]){
                count++;
            }
        }
        return count;
    }
}


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

int main(){
	int n;
	string s;
	cin >> n >> s;
	vector<int> l(n);
	vector<int> r(n);
	l.at(0) = 0;
	r.at(0) = 0;
	rep(i, n){
		if(i != 0){
			l.at(i) = l.at(i-1);
			r.at(i) = r.at(i-1);
		}
		if(s.at(i) == 'W'){
			l.at(i)++;
		}else{
			r.at(i)++;
		}
	}
	int mi = min(l.at(n-2), r.at(n-1) - r.at(0));
//	cout << l.at(n-2) << ' ' << r.at(n-1) - r.at(0) << endl;
	for(int i=1; i<n-1; i++){
		int sum = l.at(i-1) + r.at(n-1) - r.at(i);
//		cout << l.at(i-1) << ' ' << r.at(n-1) - r.at(i) << endl;
		if(sum < mi) mi = sum;
	}
	cout << mi << endl;
	return 0;
}


Measured memory_bytes: 3076
/*
Author: Babin Dutta
*/
 
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long int
#define pb push_back
#define mp make_pair
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define f(i,n) for(int i=0;i<n;i++)
#define ff(i,a,b) for(int i=a;i<=b;i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define mm 998244353
 
ll power(ll x, ll y, ll p)
{
    ll res = 1;  
    x = x % p;  
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
        y = y>>1; 
        x = (x*x) % p;  
    }
    return res;
}
ll modInverse(ll A,ll M)
{
    return power(A,M-2,M);
}

void solve(){
	ll n; cin>>n;
	if(n == 1) cout<<0<<endl;
	else if(n == 2) cout<<2<<endl;
	else{
		ll ans = 1ll;
		ans = ((ans%mod)*(power(10*1ll, n, mod)%mod))%mod;
		ans = ((ans%mod)-(power(9*1ll, n, mod)%mod)+mod)%mod;
		ans = ((ans%mod)-(power(9*1ll, n, mod)%mod)+mod)%mod;
		ans = ((ans%mod)+(power(8*1ll, n, mod)%mod)+mod)%mod;
		cout<<ans<<endl;
	}
}
 
int main(){
	#ifdef JUDGE
    freopen("input.txt", "rt", stdin);
    freopen("output.txt", "wt", stdout);
    #endif
	boost;
	int t=1; //cin>>t;
	for(int i=1;i<=t;i++) solve();
	return 0;
}

Measured memory_bytes: 3572
import java.io.BufferedReader
import java.io.InputStream
import java.io.InputStreamReader
import java.io.PrintWriter
import java.lang.StringBuilder
import java.util.*

fun PrintWriter.solve(sc: FastScanner) {
    val x = sc.nextInt()
    val n = sc.nextInt()
    val p = Array(n) { sc.nextInt() }
    for (i in 0 until 200) {
        if (!p.contains(x - i)) {
            println(x - i)
            return
        }
        if (!p.contains(x + i)) {
            println(x + i)
            return
        }
    }
}

fun main(args: Array<String>) {
    val writer = PrintWriter(System.out, false)
    writer.solve(FastScanner(System.`in`))
    writer.flush()
}

class FastScanner(s: InputStream) {
    private var st = StringTokenizer("")
    private val br = BufferedReader(InputStreamReader(s))

    fun next(): String {
        while (!st.hasMoreTokens()) st = StringTokenizer(br.readLine())

        return st.nextToken()
    }

    fun nextInt() = next().toInt()
    fun nextLong() = next().toLong()
    fun nextLine() = br.readLine()
    fun nextDouble() = next().toDouble()
    fun ready() = br.ready()
}

Measured memory_bytes: 38308
def resolve():
    n = int(input())
    ns = str(n)
    ln = len(ns)
    left = int(ns[0])
    c1 = int(str(left) + "9" * (ln - 1))
    c2 = int(str(left - 1) + "9" * (ln - 1))
    if c1 <= int(n):
        print(sum([int(ci) for ci in str(c1)]))
    else:
        print(sum([int(ci) for ci in str(c2)]))


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
using namespace std;

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

const long long M = 1000000007;

class Combination{
	public:
		vector<long long> fact, rev;
		Combination(int n = 200005) : fact(n), rev(n) { // n = h + w
			fact[0] = fact[1] = 1;
			range(i,2,n){
				(fact[i] = fact[i - 1] * i) %= M;
			}
			rev[n - 1] = power(fact[n - 1], M - 2) % M;
			for (int i = n - 1; i > 0; i--) {
				rev[i - 1] = rev[i] * i % M;
			}
		}
		long long power(long long x, long long n){ //べき乗 x^n mod M
			long long res = 1;
			if(n > 0){
				res = power(x, n / 2);
				if(n % 2 == 0) res = (res * res) % M;
				else res = (((res * res) % M) * x ) % M;
			}
			return res;
		}
		long long factorial(long long l, long long r){ return fact[r] * rev[l - 1] % M; }
		long long factorial(long long n){ return fact[n]; }
		long long combination(long long n, long long r){ //nCr (1,1)から(w,h)だと、引数は(w - 1, h - 1, M)
			return factorial(n - r + 1, n) * rev[r] % M;
		}
};

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

	Combination com;

	long long ans = 0;
	range(i,b, w){
		//cout <<  com.combination(h - a - 1 + i, i) << ' ' <<  com.combination(a - 1 + w - i - 1, a - 1)<< endl;
		ans += com.combination(h - a - 1 + i, i) * com.combination(a - 1 + w - i - 1, a - 1) % M;
		ans %= M;
	}
	cout << ans << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
#define MAX 131072
using namespace std;

pair<pair<int, int>, int> edge[MAX];
map<int, long long> val;

int main(void)
{
	int N, M;
	cin >> N >> M;
	val[1] = 0LL;
	val[N] = 1LL * 998244353 * 998244353;
	for (int i = 0; i < M; i++) cin >> edge[i].first.first >> edge[i].first.second >> edge[i].second;
	sort(edge, edge + M);
	for (auto e : edge)
	{
		auto lr = val.lower_bound(e.first.first);
		auto ee = val.lower_bound(e.first.second);
		if (ee->second > lr->second + e.second)
		{
			val[e.first.second] = lr->second + e.second;
			ee = val.upper_bound(e.first.second - 1);
			while (ee->second >= lr->second + e.second && ee != lr)
			{
				auto eee = ee;
				ee--;
				if (eee->first != e.first.second) val.erase(eee);
			}
		}
	}
	if (val[N] < 1LL * 998244353 * 998244353) cout << val[N] << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 7552
#include<stdio.h>


int main(){

  int n, m, p, x, sum, k, i;

  while(scanf("%d %d %d", &n, &m, &p),n){
    sum=0;
    for(i=0;i<n;i++){
      scanf("%d", &x);
      sum+=100*x;
      if(i==m-1) k=x;
    }
    sum-=sum*p/100;

    if(k==0) printf("0\n");
    else printf("%d\n", sum/k);
  }

  return 0;
}

Measured memory_bytes: 608
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N, M;
    cin >> N >> M;
    int ans = 0;
    int lmax = -1;
    int rmin = 1e9;
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        lmax = max(lmax, a);
        rmin = min(rmin, b);
    }

    for(int i = 1; i <= N; i++) {
        if(lmax <= i && i <= rmin) {
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<map>
#include<string>
#include<vector>
#include<algorithm>
#define all(c) c.begin(),c.end()
#define pb push_back
using namespace std;
int h,w,n;
vector<string> st(vector<string> s,vector<vector<bool> > f){
	for(int i=0;i<w;i++){
		string t="";
		for(int j=h-1;j>=0;j--){
			if(isalpha(s[j][i])&&!f[j][i]){
				t+=s[j][i];
			}
		}
		for(int j=0;j<t.size();j++){
			s[h-1-j][i]=t[j];
		}
		for(int j=t.size();j<h;j++){
			s[h-1-j][i]='.';
		}
	}
	return s;
}
bool ret(vector<string> s,int cnt){
	vector<vector<bool> > f(h,vector<bool>(w));
	int sum=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w-1;j++){
			if(!isalpha(s[i][j]))
				continue;
			int a=1;
			for(int k=j;k<w-1;k++){
				if(s[i][k]==s[i][k+1]){
					a++;
				}else break;
			}
			if(a>=n){
				for(int k=0;k<a;k++){
					if(!f[i][k+j]){
						sum++;
					}
					f[i][k+j]=true;
				}
			}
		}
	}
	for(int i=0;i<w;i++){
		for(int j=0;j<h-1;j++){
			if(!isalpha(s[j][i]))
				continue;
			int a=1;
			for(int k=j;k<h-1;k++){
				if(s[k][i]==s[k+1][i]){
					a++;
				}else break;
			}
			if(a>=n){
				for(int k=0;k<a;k++){
					if(!f[k+j][i]){
						sum++;
					}
					f[k+j][i]=true;
				}
			}
		}
	}
	if(cnt-sum==0)
		return true;
	if(!sum)
		return false;
	return ret(st(s,f),cnt-sum);
	
}
int main(){
	while(cin>>h>>w>>n){
		int cnt=0;
		vector<string> s(h);
		for(int i=0;i<h;i++){
			cin>>s[i];
		for(int j=0;j<w;j++){
			if(s[i][j]!='.')
				cnt++;
		}
	}
	bool flag=false;
	for(int i=h-1;i>=0;i--){
		for(int j=0;j<w-1;j++){
			if(s[i][j]==s[i][j+1])
				continue;
			swap(s[i][j],s[i][j+1]);
			flag=ret(st(s,vector<vector<bool> >(h,vector<bool>(w))),cnt);
			if(flag){
				cout<<"YES"<<endl;
				break;
			}
			swap(s[i][j],s[i][j+1]);
		}
		if(flag)
			break;
	}
	if(!flag)
			cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1036
#include <stdio.h>
#include <inttypes.h>

#define MAX 100000

int N;
int64_t A[MAX];
int64_t sa[MAX];
int64_t keisu[MAX];
int64_t a_tono_sa[MAX];
int64_t left_keisu, right_keisu;
int64_t a_value;

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	/* 1*a + 2*b + 3*c + 4*d + 5*e = 6 的なやつ */
	for (i = 0; i < N; i++) {
		if (scanf("%"SCNd64, &A[i]) != 1) return 1;
	}
	/*    a +   b +   c +   d - 4*e = 3 的なやつ */
	for (i = 1; i < N; i++) {
		sa[i - 1] = A[i] - A[i - 1];
	}
	sa[N - 1] = A[0] - A[N - 1];
	/* 5*d - 5*e = 0 的なやつ */
	for (i = 1; i < N; i++) {
		keisu[i - 1] = sa[i - 1] - sa[i];
	}
	keisu[N - 1] = sa[N - 1] - sa[0];

	/* 解の差が全て整数かをチェック */
	for (i = 0; i < N; i++) {
		if (keisu[i] % N != 0) {
			puts("NO");
			return 0;
		}
	}

	/* N-2がa、N-3がb、… */
	/* a_tono_sa[0]がaになるようにする */
	a_tono_sa[N - 1] = keisu[N - 1] / N; /* e = a + keisu[N - 1]/N */
	for (i = 0; i < N - 1; i++) {
		a_tono_sa[N - 2 - i] = a_tono_sa[(N - 2 - i) + 1] + keisu[i] / N;
	}

	/* 1*a + 2*b + 3*c + 4*d + 5*e = 6 的なやつを解く */
	left_keisu = (int64_t)N * (int64_t)(N + 1) / 2;
	right_keisu = A[0];
	for (i = 0; i < N; i++) {
		right_keisu -= (i + 1) * a_tono_sa[i];
	}

	if (right_keisu % left_keisu != 0) {
		/* aが整数でない */
		puts("NO");
		return 0;
	}

	a_value = right_keisu / left_keisu;
	for (i = 0; i < N; i++) {
		if (a_value + a_tono_sa[i] < 0) {
			/* ある場所を選ぶ操作回数が負になる */
			puts("NO");
			return 0;
		}
	}

	puts("YES");
	return 0;
}

/*

出来るとしたら、三角形みたいなやつk個で表せる
4 *   ***
3 **  *
5 *** **

2 *   *
4 **  **
6 *** ***

3 *   **
5 **  ***
4 *** *

できる必要条件：石の数の合計がN*(N+1)/2の倍数(1回の操作で取り除く石の数の倍数)
十分条件ではない：反例 {4, 1, 1}

例2
 6 ******
 9 *********
12 ************
10 **********
 8 ********

12は5*2を超える->操作3回以上
 6 ***   **    *
 9 ****  ***   **
12 ***** ****  ***
10 *     ***** ****
 8 **    *     *****

1*a + 2*b + 3*c + 4*d + 5*e = 6
2*a + 3*b + 4*c + 5*d + 1*e = 9
3*a + 4*b + 5*c + 1*d + 2*e = 12
4*a + 5*b + 1*c + 2*d + 3*e = 10
5*a + 1*b + 2*c + 3*d + 4*e = 8

   a +   b +   c +   d - 4*e = 3
   a +   b +   c - 4*d +   e = 3
   a +   b - 4*c +   d +   e = -2
   a - 4*b +   c +   d +   e = -2
-4*a +   b +   c +   d +   e = -2

5*d - 5*e = 0
5*c - 5*d = 5
5*b - 5*c = 0
5*a - 5*b = 0
5*e - 5*a = -5

d = e
c = d + 1
b = c
a = b
e = a - 1

a
b = c = d + 1 = e + 1 = a - 1 + 1 = a
c = d + 1 = a
d = e = a - 1
e = a - 1

a + b + c +   d - 4*e     = 3
a + a + a + a-1 - 4*(a-1) = 3
0=0

1*a + 2*b + 3*c + 4*d + 5*e = 6
1*a + 2*a + 3*a + 4*(a-1) + 5*(a-1) = 6
15*a = 15
a = 1
b = 1
c = 1
d = 0
e = 0

-------------------------------------

例3
1*a + 2*b + 3*c + 4*d = 1
2*a + 3*b + 4*c + 1*d = 2
3*a + 4*b + 1*c + 2*d = 3
4*a + 1*b + 2*c + 3*d = 1

   a +   b +   c - 3*d = 1
   a +   b - 3*c +   d = 1
   a - 3*b +   c +   d = -2
-3*a +   b +   c +   d = 0

4*c - 4*d = 0
4*b - 4*c = 3
4*a - 4*b = -2
4*d - 4*a = -1

a, b, c, d の差が整数でない->a, b, c, dは整数なのでありえない！

-------------------------------------

1*a + 2*b + 3*c = 4
2*a + 3*b + 1*c = 1
3*a + 1*b + 2*c = 1

   a +   b - 2*c = -3
   a - 2*b +   c = 0
-2*a +   b +   c = 3

3*b - 3*c = -3
3*a - 3*b = -3
3*c - 3*a = 6

係数の差が全て整数でも、できるとは限らない

*/


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

int main(){
    int64_t L, R;
    cin >> L >> R;
    if(R-L >= 2019){
        cout << 0 << endl;
    }else{
        int64_t ans = 2019;
        for(int64_t i=L; i<=R; i++) for(int64_t j=i+1; j<=R; j++) ans = min(ans, i*j%2019);
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define MXSZ 100010
char s[MXSZ],t[MXSZ];
int P[27][MXSZ],C[27];
void init(){
}
int bSearch(int *ar,int l,int r,int v){
    int ret = -1;
    while(l<=r){
        int m = (l+r)/2;
        if(ar[m]>=v){
            ret = ar[m];
            r = m-1;
        }
        else l = m+1;
    }
    return ret;
}
void MRoy(){
    init();
    scanf("%s%s",s,t);
    long long L = 0;
    for(int i = 0;s[i]!='\0';i++){
        int T = s[i]-'a';
        P[T][C[T]++] = i;
        L++;
    }
    long long int Loop = 0;int pos = -1;
    for(int i = 0;t[i]!='\0';i++){
        int T = t[i]-'a';
        if(C[T]==0) {
            printf("-1\n");
            return;
        }
        int res = bSearch(P[T],0,C[T]-1,pos+1);
        if(res==-1) {
            Loop++;
            pos = P[T][0];
        }
        else pos = res;
    }
    printf("%lld\n",Loop*L+pos+1ll);
    return;
}
int main(){
    MRoy();
    return 0;
}


Measured memory_bytes: 8960
// </> : towhid1zaman

#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair< int, int > pii;
typedef vector<pii>vip;
typedef pair< pii, int > ppi;
#define fill(a,b) memset(a,b,sizeof(a))
#define all(v) (v).begin(),(v).end()
#define sp(k) cout<<setprecision(k)<<fixed;
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a,b) for(int i=(a);i<=(b);++i)
#define irep(i,b,a) for(int i=(b);i>=(a);--i)
#define minv(v) *min_element(all(v))
#define maxv(v) *max_element(all(v))
#define unq(v) sort(all(v)),(v).erase(unique(all(v)),(v).end())
#define _ ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl "\n"
#define sqr(a) ((a)*(a))
#define sz(a) int(a.size())
#define ff first
#define ss second
#define pb push_back

const double pi = acos(-1.0);
const int mod = 1000000007; // (int)1e9+7
const int inf = 0x3f3f3f3f;// (int)3e18;
const int maxn = 200005;

void task(){
	int a,b,c; cin >> a >> b >> c;
	int k; cin >> k;
	for(int i = 0; i<k; i++){
		if(b<=a)b*=2;
		else if(c<=b)c*=2;
	}
	if(b>a and c>b)cout <<"Yes"<<endl;
	else cout <<"No" << endl;

}

int main(){
        _
        #ifdef OJ
        freopen("inputf.in", "r", stdin);
        freopen("outputf.in", "w", stdout);
        #endif

        int T = 1; //cin >> T;
        while(T--){
            task();
        }
        
return 0;
}




Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;

int main() {
    ios::sync_with_stdio(false);
    int n;
    string s;
    cin >> n >> s;
    vi count(n+1);
    for (int i=n-1; i>=0; i--) {
        count[i] = count[i+1] + (s[i]=='.');
    }
    int ans = n-count[0];
    int left = 0;
    for (int i=0; i<n; i++) {
        ans = min(ans, left + count[i]);
        left += (s[i]=='#');
    }
    cout << ans << '\n';
}


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

using namespace std;
// ache o minimo int positivo divisivel por 2 e N
int main()
{
    ios::sync_with_stdio(false);
    int N;
    double i;
    cin >> N;
    i = N;
    while (1)
    {
        if ((i / 2) - (int(i) / 2) == 0 && (i / N) - (int(i) / N) == 0 && i != 0)
        {
            cout << "" << (int)i;
            break;
        }
        i += N;
        //cout << i << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;

    int cnt = 0;
    char lc = '#';
    for (int i = 0; i < n; i++) {
        char c;
        cin >> c;
        if (c != lc) {
            cnt++;
            lc = c;
        }
    }

    cout << n - max(cnt - 2 * k, 1) << endl;

    return 0;
}


Measured memory_bytes: 256
object Main extends App {

  import scala.io.StdIn._
  import scala.math._
  solve
  def solve: Unit = {
    val n = readLine.trim.toInt
    if (n == 0) return
    println(solveExpression(List.tabulate(n){_ ⇒ readLine.trim}))
    solve
  }
  def solveExpression(expression: List[String]): Long = {
    def solveDepth(expression: List[String], depth: Int, result: List[Long] = Nil): (List[Long], List[String]) = {
      expression match {
        case h::t if h.isDepthN(depth) ⇒
          h.asDepthN(depth) match{
            case n if n.isDigit ⇒ solveDepth(t, depth, n.asDigit::result)
            case o ⇒
              val (numbers, rest) = solveDepth(t, depth + 1)
              o match {
                case '+' ⇒ solveDepth(rest, depth, numbers.sum::result)
                case '*' ⇒ solveDepth(rest, depth, numbers.product::result)
                case _ ⇒ ???
              }
          }
        case _ ⇒ (result, expression)
      }
    }
    solveDepth(expression, 0)._1.head
  }
  implicit class Token(str: String){
    def isDepthN(n: Int): Boolean = if (n == 0) str(n) != '.'
    else str.indices.contains(n - 1) && str(n - 1) == '.' && str(n) != '.'
    def asDepthN(n: Int): Char = str(n)

  }

  @inline
  def lowerBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) < 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  @inline
  def upperBound[T](array: Array[T], target: T)(implicit ord: Ordering[T]): Int = {
    var left = 0
    var right = array.length
    while (left < right){
      val mid = (left + right) / 2
      if (ord.compare(array(mid), target) <= 0){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44584
N = raw_input().split()

ans = ""

for i in range(2):
    if int(N[i]) % 3 == 0:
       ans = "Possible"

if int((N[0] + N[1])) % 3 == 0 :
    ans = "Possible"

if ans == "Possible":
    print ans
else:
    print "Impossible"


Measured memory_bytes: 2568
package main
 
import (
  "fmt"
  "math"
)

func min(nums ...int) int {
    if len(nums) == 0 {
        panic("funciton min() requires at least one argument.")
    }
    res := nums[0]
    for i := 0; i < len(nums); i++ {
        res = int(math.Min(float64(res), float64(nums[i])))
    }
    return res
}

func rec(n int, k int) int {
  var ans int
  
  if n == 0 { return 1 } 
  ans = min (rec(n-1, k) + k, rec(n-1, k) * 2)
    
  return ans
}
  
func main() {
  var n,k int
  fmt.Scan(&n)
  fmt.Scan(&k) 
  
  fmt.Println(rec(n,k))
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <tuple>
#include <algorithm>
#include <map>

#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
using namespace std;
using ll = long long;

#define INF 1000000000

int MAZE[20][20];
int D[20 * 20][20 * 20];

int main(void)
{

    int H, W;
    cin >> H >> W;
    char c;
    rep(i, H)
    {
        rep(j, W)
        {
            cin >> c;
            if (c == '.')
                MAZE[i][j] = 1;
            else
                MAZE[i][j] = 0;
        }
    }

    rep(i, 20 * 20)
        rep(j, 20 * 20)
            D[i][j] = INF;

    vector<pair<int, int>> DIFFS = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
    rep(i, H)
    {
        rep(j, W)
        {
            if (MAZE[i][j] == 0)
                continue;
            auto node = W * i + j;
            for (auto p : DIFFS)
            {
                auto ni = i + p.first;
                auto nj = j + p.second;
                if (ni < 0 || ni >= H || nj < 0 || nj >= W || MAZE[ni][nj] == 0)
                {
                    continue;
                }
                auto next_node = W * ni + nj;
                D[node][next_node] = 1;
                D[next_node][node] = 1;
            }
        }
    }
    rep(k, H * W)
    {
        rep(i, H * W)
        {
            rep(j, H * W)
            {
                D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
            }
        }
    }

    int ret = 0;
    rep(i, H * W)
    {
        rep(j, H * W)
        {
            if (D[i][j] != INF && i != j && D[i][j] > ret)
            {
                ret = D[i][j];
            }
        }
    }
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 4216
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
	int N;
	cin >> N;
	long int power = 1;
	long int maxp = static_cast<long int>(pow(10, 9)+7.);
	for (long int i = 2; i <= N; i++) {
		if (power*i > maxp) {
			power = (power*i)%maxp;
		} else {
			power *= i;
		}
	}
	cout << power << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long int ll;
ll M, rd, rr, cd, cr;

ll exc(ll rate, ll c) {
    if (c == 0) return 0;
    ll r = 0, l = 10000000000000000;
    while (l - r > 0) {
        ll m = (r + l) / 2;
        ll y = rate * m / 100;
        ll y1 = rate * (m - 1) / 100;
        if (y == c && y1 != c) return m;
        if (y < c) {
            r = m;
        }
        else {
            l = m;
        }
    }
    return 10000000000000000;
}

int main() {
    cin >> M >> rd >> rr >> cd >> cr;
    ll a = exc(rd, cd);
    ll b = exc(rr, cr);
    ll r = M - a - b;
    if (r < 0) {
        cout << -1 << endl;
        return 0;
    }
    cout << r << endl;
    return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int main(){
	int totalNumber, hitCount, n;
	while (cin >> totalNumber, totalNumber) {
		hitCount = 0;
		for (int i = 0; i < totalNumber/4; i++) {
			cin >> n;
			hitCount += n;
		}
		cout << hitCount << endl;
	}
    return 0;
}

Measured memory_bytes: 2996
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] str = scn.nextLine().toCharArray();
		int ans = 700;
		for(int i = 0;i < 3;i++) {
			if(str[i] == 'o')ans += 100;
		}
		System.out.println(ans);
	}

}


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

int main(){
    int n;
    cin >> n;
    vector<int> p(n);
    for (int i = 0; i < n; i++)
    {
        cin >> p[i];
    }
    int count = 1;
    for (int i = 0; i < n - 1; i++)
    {
        if(p[i]>p[i+1]){
            count++;
        }
        else{
            p[i + 1] = p[i];
        }
    }
    cout << count << endl;
}

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

#define N 200001
#define mod 1000000007

int main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
    vector<int> s[N];
    int dp[3][N], w[3], n, k, c, ans = 0;
    bool win;
    string t;
    cin >> n >> k;
    cin >> w[0] >> w[1] >> w[2];
    cin >> t;
    for(int i = 0 ; i < n ; i++){
    	if(t[i] == 'r') c = 2;
    	if(t[i] == 's') c = 0;
    	if(t[i] == 'p') c = 1;
    	s[i%k].push_back(c);
    }
    for(int i = 0 ; i < k ; i++){
    	int sz = s[i].size();

    	for(int j = 0 ; j <= sz ; j++)
    		for(int j2 = 0 ; j2 < 3 ; j2++)
    			dp[j2][j] = 0;

    	for(int j = 1 ; j <= sz ; j++){
    		c = s[i][j-1];
    		for(int j2 = 0 ; j2 < 3 ; j2++){
    			win = (c == j2);
    			for(int j3 = 0 ; j3 < 3 ; j3++){
    				if(j2 == j3) continue;
    				dp[j2][j] = max(dp[j2][j] , dp[j3][j-1] + ((win)? w[c] : 0));
    			}
    		}
    	}

    	ans += max(dp[0][sz], max(dp[1][sz], dp[2][sz]));
    }
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef pair<ll, ll> pii; 
const int N = 2e5+10, mod = 1e9+7;

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

    set<pii> s;
    ll mxa = LLONG_MIN;
    ll mna = LLONG_MAX;
    ll mxb = LLONG_MIN;
    ll mnb = LLONG_MAX;
    ll mxc = LLONG_MIN;
    ll mnc = LLONG_MAX;

    for (int i = 0; i < n; ++i) {
        ll x, y; cin >> x >> y;
        if (s.count({x, y}) == 0) {
            s.insert({x, y});
            mxa = max(mxa, x + y);
            mna = min(mna, x + y);
            mxb = max(mxb, x - y);
            mnb = min(mnb, x - y);
            mxc = max(mxc, y - x);
            mnc = min(mnc, y - x);
        }
    }

    cout << max(mxa - mna, max(mxb - mnb, mxc - mnc)) << endl;
}   

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    int t = 1;
    while (t--) solve();
    return 0;
}


Measured memory_bytes: 16148
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] A = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }

        System.out.println(solve(N, M, A) ? YES : NO);
    }

    private static boolean solve(int N, int M, int[] A) {
        int total = 0;
        Arrays.sort(A);
        for (int i=0; i<N; i++) {
            total += A[i];
        }


        int threshold = total / (4 * M) + (total%(4*M) == 0 ? 0 : 1);
        for (int i=0; i<M; i++) {
            if (A[N-i-1] < threshold) {
                return false;
            }
        }

        return true;
    }
}

Measured memory_bytes: 22612
import math
a, b, x = map(int,input().split())
V = (a**2) * b
#ans = 90.0 * (1.0 - x/V)
if a ** 2 * b / 2 <= x:
    f = 2*(a**2*b - x) / a ** 3
    print(math.degrees(math.atan(f)))
else:
    f = 2*x / (b**2*a)
    print(90 - math.degrees(math.atan(f)))

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<cmath>
#include<cstdio>
#include<cstdlib>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

typedef long double D;

const D EPS = 1e-10;

int main() {
  int n;
  cin >> n;
  srand(time(NULL));
  vector<D> x(n), y(n), z(n);
  vector<D> xxx(n), yyy(n), zzz(n);
  rep (i, n) cin >> xxx[i] >> yyy[i] >> zzz[i];
  D res = 0;
  rep (i, n) {
    x[i] = xxx[i] + (D)rand() / RAND_MAX / 1000000;
    y[i] = yyy[i] + (D)rand() / RAND_MAX / 1000000;
    z[i] = zzz[i] + (D)rand() / RAND_MAX / 1000000;
  }
  vector<int> triA, triB, triC;
  rep (i, n) rep (j, i) rep (k, i) if (j != k) {
    D xx = (y[j] - y[i]) * (z[k] - z[i]) - (z[j] - z[i]) * (y[k] - y[i]);
    D yy = (z[j] - z[i]) * (x[k] - x[i]) - (x[j] - x[i]) * (z[k] - z[i]);
    D zz = (x[j] - x[i]) * (y[k] - y[i]) - (y[j] - y[i]) * (x[k] - x[i]);
    bool ok = true;
    rep (l, n) if (i != l && j != l && k != l) {
      if (xx * (x[l] - x[i]) + yy * (y[l] - y[i]) + zz * (z[l] - z[i]) > EPS) {
	ok = false;
	break;
      }
    }
    if (ok) {
      D xxxx = (yyy[j] - yyy[i]) * (zzz[k] - zzz[i]) - (zzz[j] - zzz[i]) * (yyy[k] - yyy[i]);
      D yyyy = (zzz[j] - zzz[i]) * (xxx[k] - xxx[i]) - (xxx[j] - xxx[i]) * (zzz[k] - zzz[i]);
      D zzzz = (xxx[j] - xxx[i]) * (yyy[k] - yyy[i]) - (yyy[j] - yyy[i]) * (xxx[k] - xxx[i]);
      res += sqrt(xxxx * xxxx + yyyy * yyyy + zzzz * zzzz) / 2;
    }
  }
  printf("%.12Lf\n", res);
  return 0;
}

Measured memory_bytes: 1260
program ABC101B
	character(32)::N_char
	character(32)::N_digit
	integer(8)::N,i,digit_value
	integer(8)::digit_sum=0
	
	read(5,*)N
	write(N_char,*)N
	N_char=adjustl(N_char)
	
	do i=1,len_trim(N_char)
		N_digit=N_char(i:i)
		read(N_digit,*)digit_value
		digit_sum=digit_sum+digit_value
	end do
	
	if(mod(N,digit_sum)==0)then
		print'(A)',"Yes"
	else
		print'(A)',"No"
	end if
end program ABC101B


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc083b()
}

fun abc083b() {
    val (n, a, b) = readLine()!!.split(" ").map { it.toInt() }

    val answer = (1..n).filter { i ->
        i.toString().map { it.toString().toInt() }.sum() in a..b
    }.sum()

    println(answer)
}


Measured memory_bytes: 40504
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
int pstE[300005];
char s[500005];
int main() {
    int n;
    scanf("%d", &n);
    scanf("%s", s + 1);
    for (int i = n; i >= 1; --i) {
        pstE[i] = pstE[i + 1];
        if (s[i] == 'E') pstE[i]++;
    }
    int tmp = 0;
    int res = n;
    for (int i = 1; i <= n; ++i) {
        res = min(res, tmp + pstE[i + 1]);
        if (s[i] == 'W') tmp++;
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define sum(x) accumulate(all(x),0)
#define gll greater<ll>()


void solve(){
 ll d;
  cin >> d;
  vll c(26);
  rep(i,0,26) cin >> c[i];  
  
 vvll s(d,vll(26));
  rep(i,0,d){
    rep(j,0,26) cin >> s[i][j]; 
  }
  
  vll t(d);
  rep(i,0,d) t[i]=max_element(all(s[i]))-s[i].begin();
  
  vector<set<ll>> v(26);
  rep(j,0,26){
    v[j].insert(-1);
    v[j].insert(d);
  }
  
  ll ans=0;
  rep(i,0,d){
    ans+=s[i][t[i]];
    v[t[i]].insert(i);
    
    rep(j,0,26) {
     auto x=v[j].rbegin();
      x--;
      
      ans-=c[j]*(i-*x);
      
    }
  }
  
  vll f(d,0);
  
  ll m=d*26;
  
  rep(k,0,5000){
      rep(i,0,d){
        if(f[i]>m) continue;
        rep(j,1,26){
        ll cost=ans;
      auto prev=v[t[i]].find(i);
      auto next=prev;    
      prev--;
      next++;
      cost=cost-c[t[i]]*(i-*prev)*(*next-i);
        v[t[i]].erase(i);  
      t[i]=(t[i]+j)%26;
      
      v[t[i]].insert(i);
      prev=v[t[i]].find(i);
      next=prev;
      prev--;
      next++;
      cost=cost+c[t[i]]*(i-*prev)*(*next-i);
      
      if(cost>ans) {
        ans=cost;
      }
      else {
        v[t[i]].erase(i);
        t[i]=(t[i]-j+26)%26; 
        v[t[i]].insert(i); 
        f[i]++;
      }
      }
      }
      }
  
  rep(i,0,d) cout << t[i]+1 << endl;

  
}

int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}


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

using namespace std;
int main(void)
{
    string S;
    cin >> S;
    int ans;
    int n = 3;
    int bit, i;
    vector<int> num(n + 1);
    for (i = 0; i <= n; i++) num[i] = S[i] - '0';
    for(bit = (1 << n) - 1; bit >= 0; bit--)
    {
        ans = num[0];
        for (i = 1; i <= n; i++) ans += (bit & (1 << (i - 1)) ? num[i] : -num[i]);
        if (ans == 7) break;
    }
    cout << num[0];
    for (i = 1; i <= n; i++) cout << (bit & (1 << (i - 1)) ? "+" : "-") << num[i];
    cout << "=7" << endl;
    return 0;
}

Measured memory_bytes: 256
#--Easy Linear Programming

a, b, c, k = map(int, input().split())

number = 0
count = 0
if (k <= a):
    count = count + k
    print(count)
    exit()

if (k > a):
    number = number + a
    count = count + a

kk = k - number

if (kk <= b):
    print(count)
    exit()

if (kk > b):
    number = number + b

kkk = k - number

if (kkk <= c):
    count = count - kkk
    print(count)
    exit()

if (kkk > c):
    count = count - c

print(count)


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

typedef long long lli;
typedef vector<int> Vi;
typedef vector<lli> Vl;
typedef pair<int, int> Pii;
typedef pair<lli, lli> Pll;


//===


int main()
{
	int R, G, B, N;
	cin >> R >> G >> B >> N;

	int cnt = 0;

	int mr = N / R;
	for (int r = 0; r <= mr; ++r) {
		int mg = (N - R * r) / G;
		for (int g = 0; g <= mg; ++g) {
			int b = (N - R * r - G * g) / B;
			if (R * r + G * g + B * b == N) {
				++cnt;
			}
		}
	}

	cout << cnt << endl;
}

Measured memory_bytes: 256
using System;

public class Hello
{
    public static void Main()
    {
        var a = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        for (int i = 0; i < h; i++)
        {
            string[] s = Console.ReadLine().Trim().Split(' ');
            for (int j = 0; j < w; j++)
                if (s[j] == "snuke") { Console.WriteLine("{0}{1}", a[j], i + 1); break; }
        }
    }
}

Measured memory_bytes: 11220
#include <bits/stdc++.h>
using namespace std;
map<int, int> m;
int main(){
    string n; int answer=0, k;
    cin>>n>>k;
    
    for(int i=0; i<k; i++){
        int temp;
        cin>>temp;
        m[temp]=1;
    }
   
    for(int i =0; i<n.size(); i++){
        int num = n[i]-'0'; int init = num;
        for( ; num<10; num++){
            if(m[num]!=1) break;
        }
        answer += num*pow(10, n.size()-i-1);
        if(num!=init){i=-1;
        n = to_string(answer);
        answer=0;}
        
    }

    cout<<answer;

    return 0;
}


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

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

  int cnt = 0;
  cnt = log10(N) + 1;

  int ans = 0;
  if(cnt % 2 == 0){
    for(int i = 1; i < cnt; i += 2){
      ans += 9 * pow(10, i-1);
    }
  }else{
    for(int i = 1; i < cnt; i += 2){
      ans += 9 * pow(10, i-1);
    }
    ans += N - pow(10, cnt-1) + 1;
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
  
int main(void){
    int n;
    cin >> n;
    
    int x[100];
    int max_val = 0;
    for(int i=0; i<n; i++){
        cin >> x[i];
        if (x[i] > max_val)  max_val = x[i];
        //cout << "x[i] = " << x[i] << endl;
        //cout <<"max_val = " << max_val << endl;
    }
    
    ll ans = 2500000;
    int tmp_ans = 2500000;
    int tmptmp_ans = 0;
    for(int j=1; j<=max_val; j++){
        tmptmp_ans = 0;
        for(int i=0; i<n; i++){
            tmptmp_ans += (x[i] - j) * (x[i] - j);
        }
        //cout << "tmptmp_ans = " << tmp_ans << endl << endl;
        if (tmptmp_ans < tmp_ans) tmp_ans = tmptmp_ans;
    }
    ans = tmp_ans;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()
 
#define REP(i,s,e)	for(ll i=(s); i<(e); i++)
#define rep(i,n)	REP(i,0,n)
#define REPE(i,s,e)	for(ll i=s; i>e; i--)
#define repe(i,n)	REPE(i,n,-1)


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
typedef vector<vi> vvi;
 
const int IMAX=((1<<30)-1)*2+1;
const int INF=100000000;
const double EPS=1e-10;
//int mod=1000000007


int main(){
	int n;
	cin>>n;
	vi v(2 * n, 0);
	for(int i = 0; i < 2 * n; i++) v[i] = i + 1;

	int m;
	cin>>m;

	int k;
	vi u(2 * n, 0);
	for(int j = 0; j < m; j++){
		cin>>k;
		if(k == 0){
			for(int i = 0; i < n; i++) u[i * 2] = v[i];
			for(int i = 0; i < n; i++) u[i * 2 + 1] = v[i + n];
			//v = u;
		}
		else{
			for(int i = 0; i < k; i++) u[2 * n - k + i] = v[i];
			for(int i = 0; i < 2 * n - k; i++) u[i] = v[k + i];
			//v = u;
		}
		v = u;
	}
	for(int i = 0; i < 2 * n; i++){
		cout<<v[i]<<endl;
	}
}

Measured memory_bytes: 1216
#include <iostream>

using namespace std;

int main(){
    int n = 0;
    cin >> n;  
    int difference = 0;

    for (int i=0 ;i<n; ++i){
        int x = 0;
        cin >> x;
        if (x != i+1){
            difference++;
        }
    }

    cout << (difference > 2 ? "NO" : "YES") << "\n";
    return 0;
}

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

using namespace std;

int main(){
  int N;
  cin >> N;
  vector<int> B(N, 0);
  for(int i = 1; i < N; i++){
    int A;
    cin >> A;
    A--;
    B[A]++;
  }
  
  for(int i = 0; i < N; i++) cout << B[i] << endl;
  
  return 0;
}

Measured memory_bytes: 4052
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >>n;
    vector<int>data(n);
    for(int i=0;i<n;i++)cin >>data[i];
    int count = 0,ans=0;
    for(int i=0;i<n-1;i++){
        if(data[i] >= data[i+1]){
            count ++;
        }
        else {
            ans = max(count,ans);
            count =0;
        }
        if(i == n-2){
            ans = max(count,ans);
        }
    }
    cout <<ans<<endl;
}

Measured memory_bytes: 640
from itertools import combinations_with_replacement
# n個の数列、1~mの中で数列を作る
# 2<=n<=10
# 1<=m<=10
n, m, q = map(int, input().split())

comb = combinations_with_replacement(range(1, m + 1), n)
abcd = [list(map(int, input().split())) for _ in [0] * q]

ans = 0
for A in comb:
    cnt = 0
    for a,b,c,d in abcd:
        if A[b - 1] - A[a - 1] == c:
            cnt += d
    ans = max(ans, cnt)

print(ans)


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

using namespace std;

int dp[50][500][500];

const int INF=1000000000;

int main(){
        int N, Ma, Mb;
        cin>>N>>Ma>>Mb;
        vector <int> a(N), b(N), c(N);
        for(int i=0;i<N;i++){
                cin>>a[i]>>b[i]>>c[i];
        }
        for(int i=0;i<50;i++){
                for(int j=0;j<=400;j++){
                        for(int k=0;k<=400;k++){
                                dp[i][j][k]=INF;
                        }
                }
        }

        dp[0][0][0]=0;

        for(int i=0;i<N;i++){
                for(int j=0;j<=400;j++){
                        for(int k=0;k<=400;k++){
                                if(dp[i][j][k]==INF)
                                        continue;
                                //cout<<i+1<<" "<<j+a[i]<<" "<<k+b[i]<<endl;
                                dp[i+1][j][k] = min(dp[i+1][j][k], dp[i][j][k]);
                                dp[i+1][j+a[i]][k+b[i]] = min(dp[i+1][j+a[i]][k+b[i]], dp[i][j][k]+c[i]);
                        }
                }
        }
        int res=INF;
        for(int i=1;Ma*i<=400&&Mb*i<=400;i++){
                res=min(res, dp[N][i*Ma][i*Mb]);
        }
        if(res==INF){
                res=-1;
        }
        cout<<res<<endl;
        return 0;
}


Measured memory_bytes: 48256
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#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 = n;i >= m;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define ALL(n) n.begin(),n.end()

int main() {
	int a;
	cin >> a;
	if (a > 999)cout << "ABD" << endl;
	else cout << "ABC" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000001;
constexpr ll INF= 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

ll Pow(int a) {
    ll ret = 1;
    for(int i = 0;i < a;i++) {
        ret *= 2;
        ret %= MOD;
    }
    return ret;
}

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0;i < N;i++) {
        cin >> vec.at(i);
    }
    sort(vec.begin(),vec.end());
    if(N % 2 != 0) {
        if(vec.at(0) != 0) {
            cout << 0 << endl;
        }
        else {
            bool ret = true;
            for(int i = 1;i < N;i++) {
                if(vec.at(i) != (i + 1) / 2 * 2) {
                    ret = false;
                }
            }
            if(ret == true) {
                cout << Pow(N / 2) << endl;
            }
            else {
                cout << 0 << endl;
            }
        }
    }
    else {
        bool ret = true;
        for(int i = 0;i < N;i++) {
            if(vec.at(i) != (i / 2) * 2 + 1) {
                ret = false;
            }
        }
        if(ret == true) {
            cout << Pow(N / 2) << endl;
        }
        else {
            cout << 0 << endl;
        }
    }
}

Measured memory_bytes: 640